share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua
changeset 9782 6c3cad32d4f4
parent 9765 6cad4393a315
child 9783 1e6b91080bfc
equal deleted inserted replaced
9781:5eb7c3778045 9782:6c3cad32d4f4
    41 local rope3X = 2460
    41 local rope3X = 2460
    42 local portalY = 480
    42 local portalY = 480
    43 local portalX = 1465
    43 local portalX = 1465
    44 local girderY = 1630
    44 local girderY = 1630
    45 local girderX = 3350
    45 local girderX = 3350
       
    46 -- win crates
       
    47 local btorch2 = {}
       
    48 local girder = {}
    46 -- hogs
    49 -- hogs
    47 local hero = {}
    50 local hero = {}
    48 local ally = {}
    51 local ally = {}
    49 local smuggler1 = {}
    52 local smuggler1 = {}
    50 local smuggler2 = {}
    53 local smuggler2 = {}
   126 		AnimSetGearPosition(hero.gear, 1680, 920)
   129 		AnimSetGearPosition(hero.gear, 1680, 920)
   127 		HogTurnLeft(hero.gear, true)
   130 		HogTurnLeft(hero.gear, true)
   128 	elseif checkPointReached == 4 then
   131 	elseif checkPointReached == 4 then
   129 		AnimSetGearPosition(hero.gear, 1160, 1180)
   132 		AnimSetGearPosition(hero.gear, 1160, 1180)
   130 	elseif checkPointReached == 5 then
   133 	elseif checkPointReached == 5 then
   131 		AnimSetGearPosition(hero.gear, girderX+40, girderY-30)
   134 		local positions = GetCampaignVar("HogsPosition")
       
   135 		positions = split(positions,",")
       
   136 		local x
       
   137 		local y
       
   138 		if positions[1] then
       
   139 			x = positions[1]
       
   140 			y = positions[2]
       
   141 		else
       
   142 			-- this should *NEVER* happen, remove?
       
   143 			x = girderX+40
       
   144 			y = girderY-30
       
   145 		end
       
   146 		AnimSetGearPosition(hero.gear, x, y)
   132 	end
   147 	end
   133 
   148 
   134 	AnimInit()
   149 	AnimInit()
   135 	AnimationSetup()
   150 	AnimationSetup()
   136 end
   151 end
   144 	AddEvent(onHeroFleeFirstBattle, {hero.gear}, heroFleeFirstBattle, {hero.gear}, 1)
   159 	AddEvent(onHeroFleeFirstBattle, {hero.gear}, heroFleeFirstBattle, {hero.gear}, 1)
   145 	AddEvent(onHeroAtCheckpoint4, {hero.gear}, heroAtCheckpoint4, {hero.gear}, 0)
   160 	AddEvent(onHeroAtCheckpoint4, {hero.gear}, heroAtCheckpoint4, {hero.gear}, 0)
   146 	AddEvent(onHeroAtThirdBattle, {hero.gear}, heroAtThirdBattle, {hero.gear}, 0)
   161 	AddEvent(onHeroAtThirdBattle, {hero.gear}, heroAtThirdBattle, {hero.gear}, 0)
   147 	AddEvent(onCheckForWin1, {hero.gear}, checkForWin1, {hero.gear}, 0)
   162 	AddEvent(onCheckForWin1, {hero.gear}, checkForWin1, {hero.gear}, 0)
   148 	AddEvent(onCheckForWin2, {hero.gear}, checkForWin2, {hero.gear}, 0)
   163 	AddEvent(onCheckForWin2, {hero.gear}, checkForWin2, {hero.gear}, 0)
       
   164 	AddEvent(onCrateDestroyed, {hero.gear}, crateDestroyed, {hero.gear}, 0)
   149 
   165 
   150 	-- smugglers ammo
   166 	-- smugglers ammo
   151 	AddAmmo(smuggler1.gear, amBazooka, 2)
   167 	AddAmmo(smuggler1.gear, amBazooka, 2)
   152 	AddAmmo(smuggler1.gear, amGrenade, 2)
   168 	AddAmmo(smuggler1.gear, amGrenade, 2)
   153 	AddAmmo(smuggler1.gear, amDEagle, 2)
   169 	AddAmmo(smuggler1.gear, amDEagle, 2)
   254 	SetAmmo(amRope, 0, 0, 0, 1)
   270 	SetAmmo(amRope, 0, 0, 0, 1)
   255 	SetAmmo(amPortalGun, 0, 0, 0, 1)
   271 	SetAmmo(amPortalGun, 0, 0, 0, 1)
   256 	SetAmmo(amGirder, 0, 0, 0, 3)
   272 	SetAmmo(amGirder, 0, 0, 0, 3)
   257 end
   273 end
   258 
   274 
       
   275 function onGearAdd(gear)
       
   276 	if GetGearType(gear) == gtCase then
       
   277 		if GetX(gear) == btorch2X and GetY(gear) == btorch2Y then
       
   278 			btorch2.gear = gear
       
   279 			btorch2.destroyed = false
       
   280 			btorch2.deleted = false
       
   281 		elseif GetX(gear) == girderX and GetY(gear) == girderY then
       
   282 			girder.gear = gear
       
   283 			girder.destroyed = false
       
   284 			girder.deleted = false
       
   285 		end
       
   286 	end
       
   287 end
       
   288 
       
   289 function onGearDamage(gear, damage)
       
   290 	if gear == girder.gear then
       
   291 		girder.destroyed = true
       
   292 	elseif gear == btorch2.gear then
       
   293 		btorch2.destroyed = true
       
   294 	end
       
   295 end
       
   296 
   259 function onGearDelete(gear)
   297 function onGearDelete(gear)
       
   298 	if gear == girder.gear then
       
   299 		girder.deleted = true
       
   300 	elseif gear == btorch2.gear then
       
   301 		btorch2.deleted = true
       
   302 	end
   260 	if gear == hero.gear then
   303 	if gear == hero.gear then
   261 		hero.dead = true
   304 		hero.dead = true
   262 	elseif (gear == smuggler1.gear or gear == smuggler2.gear or gear == smuggler3.gear) and heroIsInBattle then
   305 	elseif (gear == smuggler1.gear or gear == smuggler2.gear or gear == smuggler3.gear) and heroIsInBattle then
   263 		heroIsInBattle = false
   306 		heroIsInBattle = false
   264 		ongoingBattle = 0
   307 		ongoingBattle = 0
   328 	end
   371 	end
   329 	return false
   372 	return false
   330 end
   373 end
   331 
   374 
   332 function onCheckForWin1(gear)
   375 function onCheckForWin1(gear)
   333 	if not hero.dead and GetX(hero.gear) > btorch2X-30 and GetX(hero.gear) < btorch2X+30
   376 	if not hero.dead and not btorch2.destroyed and btorch2.deleted then
   334 			and GetY(hero.gear) > btorch2Y-30 and GetY(hero.gear) < btorch2Y+30 then
       
   335 		return true
   377 		return true
   336 	end
   378 	end
   337 	return false
   379 	return false
   338 end
   380 end
   339 
   381 
   340 function onCheckForWin2(gear)
   382 function onCheckForWin2(gear)
   341 	if not hero.dead and GetX(hero.gear) > girderX-30 and GetX(hero.gear) < girderX+30
   383 	if not hero.dead and not girder.destroyed and girder.deleted then
   342 			and GetY(hero.gear) > girderY-30 and GetY(hero.gear) < girderY+30 then
   384 		return true
       
   385 	end
       
   386 	return false
       
   387 end
       
   388 
       
   389 function onCrateDestroyed(gear)
       
   390 	if not hero.dead and girder.destroyed or btorch2.destroyed then
   343 		return true
   391 		return true
   344 	end
   392 	end
   345 	return false
   393 	return false
   346 end
   394 end
   347 
   395 
   348 -------------- ACTIONS ------------------
   396 -------------- ACTIONS ------------------
   349 
   397 
   350 function heroDeath(gear)
   398 function heroDeath(gear)
   351 	SendStat(siGameResult, loc("Hog Solo lost, try again!"))
   399 	lose()
   352 	SendStat(siCustomAchievement, loc("To win the game you have to find the right crate"))
       
   353 	SendStat(siCustomAchievement, loc("You can avoid some battles"))
       
   354 	SendStat(siCustomAchievement, loc("Use your ammo wisely"))
       
   355 	SendStat(siPlayerKills,'1',teamB.name)
       
   356 	SendStat(siPlayerKills,'0',teamC.name)
       
   357 	EndGame()
       
   358 end
   400 end
   359 
   401 
   360 function heroAtFirstBattle(gear)
   402 function heroAtFirstBattle(gear)
   361 	AnimCaption(hero.gear, loc("A smuggler! Prepare for battle"), 5000)
   403 	AnimCaption(hero.gear, loc("A smuggler! Prepare for battle"), 5000)
   362 	TurnTimeLeft = 0
   404 	TurnTimeLeft = 0
   397 	AnimSay(smuggler3.gear, loc("Who's there?! I'll get you..."), SAY_SHOUT, 5000)
   439 	AnimSay(smuggler3.gear, loc("Who's there?! I'll get you..."), SAY_SHOUT, 5000)
   398 	AnimSwitchHog(smuggler3.gear)
   440 	AnimSwitchHog(smuggler3.gear)
   399 	TurnTimeLeft = 0
   441 	TurnTimeLeft = 0
   400 end
   442 end
   401 
   443 
       
   444 function crateDestroyed(gear)
       
   445 	lose()
       
   446 end
       
   447 
   402 -- for some weird reson I couldn't call the same action for both events
   448 -- for some weird reson I couldn't call the same action for both events
   403 function checkForWin1(gear)
   449 function checkForWin1(gear)
   404 	checkForWin()
   450 	checkForWin()
   405 end
   451 end
   406 
   452 
   407 function checkForWin2(gear)
   453 function checkForWin2(gear)
   408 	-- ok lets place one more checkpoint as next part seems challenging without rope
   454 	-- ok lets place one more checkpoint as next part seems challenging without rope
   409 	if cratesFound ==  0 then
   455 	if cratesFound ==  0 then
   410 		saveCheckPointLocal("5")
   456 		saveCheckPointLocal("5")
       
   457 		SaveCampaignVar("HogsPosition", GetX(hero.gear)..","..GetY(hero.gear))
   411 	end
   458 	end
   412 
   459 
   413 	checkForWin()
   460 	checkForWin()
   414 end
   461 end
   415 
   462 
   509 		SendStat(siPlayerKills,'1',teamC.name)
   556 		SendStat(siPlayerKills,'1',teamC.name)
   510 		SendStat(siPlayerKills,'0',teamB.name)
   557 		SendStat(siPlayerKills,'0',teamB.name)
   511 		EndGame()
   558 		EndGame()
   512 	end
   559 	end
   513 end
   560 end
       
   561 
       
   562 function lose()
       
   563 	SendStat(siGameResult, loc("Hog Solo lost, try again!"))
       
   564 	SendStat(siCustomAchievement, loc("To win the game you have to find the right crate"))
       
   565 	SendStat(siCustomAchievement, loc("You can avoid some battles"))
       
   566 	SendStat(siCustomAchievement, loc("Use your ammo wisely"))
       
   567 	SendStat(siCustomAchievement, loc("Don't destroy the device crate!"))
       
   568 	SendStat(siPlayerKills,'1',teamB.name)
       
   569 	SendStat(siPlayerKills,'0',teamC.name)
       
   570 	EndGame()
       
   571 end