share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua
changeset 14633 bd15c8551318
parent 14509 7bb7e5e54f70
child 14636 c3c0f94a5333
equal deleted inserted replaced
14632:3cf7799e04b5 14633:bd15c8551318
   116 	hero.name = GetHogName(hero.gear)
   116 	hero.name = GetHogName(hero.gear)
   117 	AnimSetGearPosition(hero.gear, hero.x, hero.y)
   117 	AnimSetGearPosition(hero.gear, hero.x, hero.y)
   118 	HogTurnLeft(hero.gear, true)
   118 	HogTurnLeft(hero.gear, true)
   119 	-- Ally
   119 	-- Ally
   120 	teamA.name = AddTeam(teamA.name, teamA.color, "heart", "Island", "Default", "cm_face")
   120 	teamA.name = AddTeam(teamA.name, teamA.color, "heart", "Island", "Default", "cm_face")
       
   121 	SetTeamPassive(teamA.name, true)
   121 	ally.gear = AddHog(ally.name, 0, 100, "war_airwarden02")
   122 	ally.gear = AddHog(ally.name, 0, 100, "war_airwarden02")
   122 	AnimSetGearPosition(ally.gear, ally.x, ally.y)
   123 	AnimSetGearPosition(ally.gear, ally.x, ally.y)
   123 	-- Frozen Bandits
   124 	-- Frozen Bandits
   124 	teamB.name = AddTeam(teamB.name, teamB.color, "plant2", "Island", "Default", "cm_pirate")
   125 	teamB.name = AddTeam(teamB.name, teamB.color, "plant2", "Island", "Default", "cm_pirate")
   125 	bandit1.gear = AddHog(bandit1.name, 1, 120, "Santa")
   126 	bandit1.gear = AddHog(bandit1.name, 1, 120, "Santa")
   232 	end
   233 	end
   233 
   234 
   234 	SendHealthStatsOff()
   235 	SendHealthStatsOff()
   235 end
   236 end
   236 
   237 
       
   238 function getNextBandit(hog)
       
   239 	local continue = true
       
   240 	local startHog = hog
       
   241 	while true do
       
   242 		if (GetHealth(hog) and GetEffect(hog, heFrozen) < 256) and
       
   243 		( (heroAtFinalStep and (hog == bandit1.gear or hog == bandit4.gear or hog == bandit5.gear)) or
       
   244 		((not heroAtFinalStep) and (hog == bandit2.gear or hog == bandit3.gear)) ) then
       
   245 			return hog
       
   246 		end
       
   247 		if hog == bandit1.gear then
       
   248 			hog = bandit2.gear
       
   249 		elseif hog == bandit2.gear then
       
   250 			hog = bandit3.gear
       
   251 		elseif hog == bandit3.gear then
       
   252 			hog = bandit4.gear
       
   253 		elseif hog == bandit4.gear then
       
   254 			hog = bandit5.gear
       
   255 		elseif hog == bandit5.gear then
       
   256 			hog = bandit1.gear
       
   257 		end
       
   258 		if startHog == hog then
       
   259 			return nil
       
   260 		end
       
   261 	end
       
   262 end
       
   263 
   237 function onNewTurn()
   264 function onNewTurn()
   238 	heroDamageAtCurrentTurn = 0
   265 	heroDamageAtCurrentTurn = 0
   239 	-- round has to start if hero goes near the column
   266 	-- round has to start if hero goes near the column
   240 	if not heroVisitedAntiFlyArea and CurrentHedgehog ~= hero.gear then
   267 	if not heroVisitedAntiFlyArea and CurrentHedgehog ~= hero.gear then
   241 		EndTurn(true)
   268 		SkipTurn()
   242 	elseif not heroVisitedAntiFlyArea and CurrentHedgehog == hero.gear then
   269 	elseif not heroVisitedAntiFlyArea and CurrentHedgehog == hero.gear then
   243 		SetTurnTimeLeft(MAX_TURN_TIME)
   270 		SetTurnTimeLeft(MAX_TURN_TIME)
   244 	elseif not heroAtFinalStep and (CurrentHedgehog == bandit1.gear or CurrentHedgehog == bandit4.gear or CurrentHedgehog == bandit5.gear) then
   271 	elseif (GetHogTeamName(CurrentHedgehog) == teamB.name) then
   245 		AnimSwitchHog(hero.gear)
   272 		local nextBandit = getNextBandit(CurrentHedgehog)
   246 		EndTurn(true)
   273 		if nextBandit ~= nil then
   247 	elseif heroAtFinalStep and (CurrentHedgehog == bandit2.gear or CurrentHedgehog == bandit3.gear) then
   274 			if CurrentHedgehog ~= nextBandit then
   248 		if (GetHealth(bandit1.gear) and GetEffect(bandit1.gear,heFrozen) > 256) and
   275 				AnimSwitchHog(nextBandit)
   249 			((GetHealth(bandit4.gear) and GetEffect(bandit4.gear,heFrozen) > 256) or not GetHealth(bandit4.gear)) and
   276 			end
   250 			((GetHealth(bandit5.gear) and GetEffect(bandit5.gear,heFrozen) > 256) or not GetHealth(bandit5.gear)) then
       
   251 			EndTurn(true)
       
   252 		else
   277 		else
   253 			AnimSwitchHog(hero.gear)
   278 			SkipTurn()
   254 			EndTurn(true)
   279 		end
   255 		end
       
   256 	elseif CurrentHedgehog == ally.gear then
       
   257 		-- This switches back to hero (indirectly)
       
   258 		SwitchHog(bandit1.gear)
       
   259 		EndTurn(true)
       
   260 	end
   280 	end
   261 	-- frozen hogs accounting
   281 	-- frozen hogs accounting
   262 	if CurrentHedgehog == hero.gear and heroAtFinalStep and TurnTimeLeft > 0 then
   282 	if CurrentHedgehog == hero.gear and heroAtFinalStep and TurnTimeLeft > 0 then
   263 		if bandit1.frozen then
   283 		if bandit1.frozen then
   264 			if bandit1.roundsToUnfreeze == 0 then
   284 			if bandit1.roundsToUnfreeze == 0 then