share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua
branchspacecampaign
changeset 9388 790d4f7d57d1
parent 9386 808d38b2182c
child 9390 9956b1fbac8b
equal deleted inserted replaced
9386:808d38b2182c 9388:790d4f7d57d1
     4 -- antigravity device. He has to capture Icy Pit who
     4 -- antigravity device. He has to capture Icy Pit who
     5 -- knows where the device is hidden. Hero will be
     5 -- knows where the device is hidden. Hero will be
     6 -- able to use only the ice gun for this mission.
     6 -- able to use only the ice gun for this mission.
     7 
     7 
     8 -- TODO
     8 -- TODO
     9 -- alter map so hero may climb to the higher place
       
    10 -- maybe use rope challenge to go there
     9 -- maybe use rope challenge to go there
    11 -- add checkpoints
    10 -- add checkpoints
    12 -- fix the stats
    11 -- fix the stats
    13 -- Add first checkpoint save if icegun is taken
    12 -- manually set the frozen hogs to last frozen for fixed number of turns
       
    13 -- SetState(bandit1.gear,bor(GetState(bandit1.gear),gstFrozen))
       
    14 -- SetEffect(bandit1.gear,heFrozen,9999999)
    14 
    15 
    15 HedgewarsScriptLoad("/Scripts/Locale.lua")
    16 HedgewarsScriptLoad("/Scripts/Locale.lua")
    16 HedgewarsScriptLoad("/Scripts/Animate.lua")
    17 HedgewarsScriptLoad("/Scripts/Animate.lua")
    17 
    18 
    18 ----------------- VARIABLES --------------------
    19 ----------------- VARIABLES --------------------
    55 ally.x = 300
    56 ally.x = 300
    56 ally.y = 1840
    57 ally.y = 1840
    57 bandit1.name = "Thanta"
    58 bandit1.name = "Thanta"
    58 bandit1.x = 3240
    59 bandit1.x = 3240
    59 bandit1.y = 1280
    60 bandit1.y = 1280
       
    61 bandit1.dead = false
    60 bandit2.name = "Billy Frost"
    62 bandit2.name = "Billy Frost"
    61 bandit2.x = 1480
    63 bandit2.x = 1480
    62 bandit2.y = 1990
    64 bandit2.y = 1990
    63 bandit3.name = "Ice Jake"
    65 bandit3.name = "Ice Jake"
    64 bandit3.x = 1860
    66 bandit3.x = 1860
    65 bandit3.y = 1150
    67 bandit3.y = 1150
    66 bandit4.name = "John Snow"
    68 bandit4.name = "John Snow"
    67 bandit4.x = 3250
    69 bandit4.x = 3200
    68 bandit4.y = 970
    70 bandit4.y = 970
    69 bandit5.name = "White Tee"
    71 bandit5.name = "White Tee"
    70 bandit5.x = 3300
    72 bandit5.x = 3280
    71 bandit5.y = 600
    73 bandit5.y = 600
    72 teamA.name = loc("Allies")
    74 teamA.name = loc("Allies")
    73 teamA.color = tonumber("FF0000",16) -- red
    75 teamA.color = tonumber("FF0000",16) -- red
    74 teamB.name = loc("Frozen Bandits")
    76 teamB.name = loc("Frozen Bandits")
    75 teamB.color = tonumber("0033FF",16) -- blues
    77 teamB.color = tonumber("0033FF",16) -- blues
   106 	HogTurnLeft(bandit1.gear, true)
   108 	HogTurnLeft(bandit1.gear, true)
   107 	bandit2.gear = AddHog(bandit2.name, 1, 100, "tophats")
   109 	bandit2.gear = AddHog(bandit2.name, 1, 100, "tophats")
   108 	AnimSetGearPosition(bandit2.gear, bandit2.x, bandit2.y)
   110 	AnimSetGearPosition(bandit2.gear, bandit2.x, bandit2.y)
   109 	bandit3.gear = AddHog(bandit3.name, 1, 100, "tophats")
   111 	bandit3.gear = AddHog(bandit3.name, 1, 100, "tophats")
   110 	AnimSetGearPosition(bandit3.gear, bandit3.x, bandit3.y)
   112 	AnimSetGearPosition(bandit3.gear, bandit3.x, bandit3.y)
   111 	bandit4.gear = AddHog(bandit4.name, 1, 100, "tophats")
   113 	bandit4.gear = AddHog(bandit4.name, 1, 40, "tophats")
   112 	AnimSetGearPosition(bandit4.gear, bandit4.x, bandit4.y)
   114 	AnimSetGearPosition(bandit4.gear, bandit4.x, bandit4.y)
   113 	HogTurnLeft(bandit4.gear, true)
   115 	HogTurnLeft(bandit4.gear, true)
   114 	bandit5.gear = AddHog(bandit5.name, 1, 100, "tophats")
   116 	bandit5.gear = AddHog(bandit5.name, 1, 40, "tophats")
   115 	AnimSetGearPosition(bandit5.gear, bandit5.x, bandit5.y)
   117 	AnimSetGearPosition(bandit5.gear, bandit5.x, bandit5.y)
   116 	HogTurnLeft(bandit5.gear, true)
   118 	HogTurnLeft(bandit5.gear, true)
   117 	
   119 	
   118 	-- get the check point
   120 	-- get the check point
   119 	if tonumber(GetCampaignVar("Ice01CheckPoint")) then
   121 	if tonumber(GetCampaignVar("Ice01CheckPoint")) then
   121 	end
   123 	end
   122 	
   124 	
   123 	if checkPointReached == 1 then
   125 	if checkPointReached == 1 then
   124 		-- Start of the game
   126 		-- Start of the game
   125 	elseif checkPointReached == 2 then
   127 	elseif checkPointReached == 2 then
       
   128 		iceGunTaken = true
   126 		AnimSetGearPosition(hero.gear, 840, 1650)
   129 		AnimSetGearPosition(hero.gear, 840, 1650)
       
   130 	elseif checkPointReached == 3 then		
       
   131 		iceGunTaken = true
       
   132 		heroAtFinaleStep = true
       
   133 		heroVisitedAntiFlyArea = true
       
   134 		AnimSetGearPosition(hero.gear, 1450, 910)
   127 	end
   135 	end
   128 	
   136 	
   129 	AnimInit()
   137 	AnimInit()
   130 	AnimationSetup()	
   138 	AnimationSetup()	
   131 end
   139 end
   174 	
   182 	
   175 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 1)
   183 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 1)
   176 	AddEvent(onHeroFinalStep, {hero.gear}, heroFinalStep, {hero.gear}, 0)
   184 	AddEvent(onHeroFinalStep, {hero.gear}, heroFinalStep, {hero.gear}, 0)
   177 	AddEvent(onAntiFlyArea, {hero.gear}, antiFlyArea, {hero.gear}, 1)
   185 	AddEvent(onAntiFlyArea, {hero.gear}, antiFlyArea, {hero.gear}, 1)
   178 	AddEvent(onNonAntiFlyArea, {hero.gear}, nonAntiFlyArea, {hero.gear}, 1)
   186 	AddEvent(onNonAntiFlyArea, {hero.gear}, nonAntiFlyArea, {hero.gear}, 1)
       
   187 	AddEvent(onThantaDeath, {bandit1.gear}, thantaDeath, {bandit1.gear}, 1)
   179 	
   188 	
   180 	AddAmmo(hero.gear, amJetpack, 99)
   189 	AddAmmo(hero.gear, amJetpack, 99)
   181 	AddAmmo(bandit1.gear, amBazooka, 5)
   190 	AddAmmo(bandit1.gear, amBazooka, 5)
   182 	AddAmmo(bandit2.gear, amBazooka, 4)
   191 	AddAmmo(bandit2.gear, amBazooka, 4)
   183 	AddAmmo(bandit3.gear, amMine, 2)
   192 	AddAmmo(bandit3.gear, amMine, 2)
   189 		AddAmmo(hero.gear, amBazooka, 1)
   198 		AddAmmo(hero.gear, amBazooka, 1)
   190 		SpawnAmmoCrate(icegunX, icegunY, amIceGun)
   199 		SpawnAmmoCrate(icegunX, icegunY, amIceGun)
   191 		AddEvent(onColumnCheckPoint, {hero.gear}, columnCheckPoint, {hero.gear}, 0)
   200 		AddEvent(onColumnCheckPoint, {hero.gear}, columnCheckPoint, {hero.gear}, 0)
   192 		AddEvent(onHeroAtIceGun, {hero.gear}, heroAtIceGun, {hero.gear}, 0)
   201 		AddEvent(onHeroAtIceGun, {hero.gear}, heroAtIceGun, {hero.gear}, 0)
   193 		AddAnim(dialog01)
   202 		AddAnim(dialog01)
   194 	elseif checkPointReached == 2 then		
   203 	elseif checkPointReached == 2 then
   195 		AddAmmo(hero.gear, amIceGun, 8)
   204 		AddAmmo(hero.gear, amIceGun, 8)
       
   205 		AnimCaption(hero.gear, loc("Go to Thanta and get the device part!"), 5000)
       
   206 	elseif checkPointReached == 3 then
       
   207 		AddAmmo(hero.gear, amIceGun, 6)
       
   208 		AnimCaption(hero.gear, loc("Go to Thanta and get the device part!"), 5000)
   196 	end
   209 	end
   197 	
   210 	
   198 end
   211 end
   199 
   212 
   200 function onNewTurn()		
   213 function onNewTurn()		
   204 	elseif not heroVisitedAntiFlyArea and CurrentHedgehog == hero.gear then
   217 	elseif not heroVisitedAntiFlyArea and CurrentHedgehog == hero.gear then
   205 		TurnTimeLeft = -1
   218 		TurnTimeLeft = -1
   206 	elseif not heroAtFinaleStep and (CurrentHedgehog == bandit1.gear or CurrentHedgehog == bandit4.gear or CurrentHedgehog == bandit5.gear) then		
   219 	elseif not heroAtFinaleStep and (CurrentHedgehog == bandit1.gear or CurrentHedgehog == bandit4.gear or CurrentHedgehog == bandit5.gear) then		
   207 		AnimSwitchHog(hero.gear)
   220 		AnimSwitchHog(hero.gear)
   208 		TurnTimeLeft = 0
   221 		TurnTimeLeft = 0
       
   222 	elseif heroAtFinaleStep and (CurrentHedgehog == bandit2.gear or CurrentHedgehog == bandit3.gear) then
       
   223 		AnimSwitchHog(hero.gear)
       
   224 		TurnTimeLeft = 0
   209 	elseif CurrentHedgehog == ally.gear then
   225 	elseif CurrentHedgehog == ally.gear then
   210 		TurnTimeLeft = 0
   226 		TurnTimeLeft = 0
   211 	end
   227 	end
   212 end
   228 end
   213 
   229 
   225 end
   241 end
   226 
   242 
   227 function onGearDelete(gear)
   243 function onGearDelete(gear)
   228 	if gear == hero.gear then
   244 	if gear == hero.gear then
   229 		hero.dead = true
   245 		hero.dead = true
       
   246 	elseif gear == bandit1.gear then
       
   247 		bandit1.dead = true
   230 	end
   248 	end
   231 end
   249 end
   232 
   250 
   233 function onPrecise()
   251 function onPrecise()
   234 	if GameTime > 3000 then
   252 	if GameTime > 3000 then
   258 	end
   276 	end
   259 	return false
   277 	return false
   260 end
   278 end
   261 
   279 
   262 function onHeroFinalStep(gear)
   280 function onHeroFinalStep(gear)
   263 	if not hero.dead and GetY(gear) < 900 and GetX(gear) > 1400 then
   281 	if not hero.dead and GetY(gear) < 960 and GetX(gear) > 1400 then
   264 		return true
   282 		return true
   265 	end
   283 	end
   266 	return false
   284 	return false
   267 end
   285 end
   268 
   286 
   273 	return false
   291 	return false
   274 end
   292 end
   275 
   293 
   276 function onHeroAtIceGun(gear)
   294 function onHeroAtIceGun(gear)
   277 	if not hero.dead and GetX(gear) < icegunX+15 and GetX(gear) > icegunX-15 and GetY(gear) > icegunY-15 and GetY(gear) < icegunY+15 then
   295 	if not hero.dead and GetX(gear) < icegunX+15 and GetX(gear) > icegunX-15 and GetY(gear) > icegunY-15 and GetY(gear) < icegunY+15 then
       
   296 		return true
       
   297 	end
       
   298 	return false
       
   299 end
       
   300 
       
   301 function onThantaDeath(gear)
       
   302 	if bandit1.dead then
   278 		return true
   303 		return true
   279 	end
   304 	end
   280 	return false
   305 	return false
   281 end
   306 end
   282 
   307 
   308 	EndGame()
   333 	EndGame()
   309 end
   334 end
   310 
   335 
   311 function heroFinalStep(gear)
   336 function heroFinalStep(gear)
   312 	heroAtFinaleStep = true
   337 	heroAtFinaleStep = true
       
   338 	SaveCampaignVar("Ice01CheckPoint", "3")
       
   339 	SaveCampaignVar("HeroHealth", GetHealth(hero.gear))	
       
   340 	WriteLnToConsole("Final Step")
   313 end
   341 end
   314 
   342 
   315 function columnCheckPoint(gear)
   343 function columnCheckPoint(gear)
   316 	SaveCampaignVar("Ice01CheckPoint", "2")
   344 	SaveCampaignVar("Ice01CheckPoint", "2")	
   317 	WriteLnToConsole("I AM HERE")
   345 	SaveCampaignVar("HeroHealth", GetHealth(hero.gear))
   318 	AnimCaption(hero.gear, loc("Checkpoint reached!"), 5000)
   346 	AnimCaption(hero.gear, loc("Checkpoint reached!"), 5000)
   319 end
   347 end
   320 
   348 
   321 function heroAtIceGun(gear)
   349 function heroAtIceGun(gear)
   322 	iceGunTaken=true
   350 	iceGunTaken=true
       
   351 end
       
   352 
       
   353 function thantaDeath(gear)
       
   354 	SendStat('siGameResult', loc("Hog Solo lost, try again!")) --1
       
   355 	-- more custom stats
       
   356 	EndGame()
   323 end
   357 end
   324 
   358 
   325 -------------- ANIMATIONS ------------------
   359 -------------- ANIMATIONS ------------------
   326 
   360 
   327 function Skipanim(anim)
   361 function Skipanim(anim)