share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua
changeset 9772 30a9e740ec09
parent 9758 3b8058b251b8
child 10289 c3a77ff02a23
equal deleted inserted replaced
9771:6fb8dafe57f7 9772:30a9e740ec09
    12 local missionName = loc("Chasing the blue hog")
    12 local missionName = loc("Chasing the blue hog")
    13 local challengeObjectives = loc("Use the rope in order to catch the blue hedgehog").."|"..
    13 local challengeObjectives = loc("Use the rope in order to catch the blue hedgehog").."|"..
    14 	loc("You have to stand very close to him")
    14 	loc("You have to stand very close to him")
    15 local currentPosition = 1
    15 local currentPosition = 1
    16 local previousTimeLeft = 0
    16 local previousTimeLeft = 0
    17 local startChallenge = falses
    17 local startChallenge = false
    18 -- dialogs
    18 -- dialogs
    19 local dialog01 = {}
    19 local dialog01 = {}
    20 local dialog02 = {}
    20 local dialog02 = {}
    21 -- mission objectives
    21 -- mission objectives
    22 local goals = {
    22 local goals = {
    82 	ShowMission(missionName, loc("Challenge Objectives"), challengeObjectives, -amSkip, 0)
    82 	ShowMission(missionName, loc("Challenge Objectives"), challengeObjectives, -amSkip, 0)
    83 
    83 
    84 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
    84 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
    85 
    85 
    86 	AddAmmo(hero.gear, amRope, 1)
    86 	AddAmmo(hero.gear, amRope, 1)
    87 	AddAmmo(hero.gear, amSkip, 1)
       
    88 
    87 
    89 	SendHealthStatsOff()
    88 	SendHealthStatsOff()
    90 	hogTurn = runner.gear
    89 	hogTurn = runner.gear
    91 	AddAnim(dialog01)
    90 	AddAnim(dialog01)
    92 end
    91 end
    93 
    92 
    94 function onNewTurn()
    93 function onNewTurn()
    95 	if startChallenge then
    94 	if startChallenge and currentPosition < 5 then
    96 		if CurrentHedgehog ~= hero.gear then
    95 		if CurrentHedgehog ~= hero.gear then
    97 			TurnTimeLeft = 0
    96 			TurnTimeLeft = 0
    98 		else
    97 		else
    99 			if GetAmmoCount(hero.gear, amRope) == 0  then
    98 			if GetAmmoCount(hero.gear, amRope) == 0  then
   100 				lose()
    99 				lose()
   114 	ExecuteAfterAnimations()
   113 	ExecuteAfterAnimations()
   115 	CheckEvents()
   114 	CheckEvents()
   116 end
   115 end
   117 
   116 
   118 function onGameTick20()
   117 function onGameTick20()
   119 	if isHeroNextToRunner() then
   118 	if GetHealth(hero.gear) and startChallenge and isHeroNextToRunner() and currentPosition < 5 then
   120 		moveRunner()
   119 		moveRunner()
   121 	end
   120 	end
   122 end
   121 end
   123 
   122 
   124 function onPrecise()
   123 function onPrecise()
   148 	if goals[anim] ~= nil then
   147 	if goals[anim] ~= nil then
   149 		ShowMission(unpack(goals[anim]))
   148 		ShowMission(unpack(goals[anim]))
   150     end
   149     end
   151     if anim == dialog01 then
   150     if anim == dialog01 then
   152 		moveRunner()
   151 		moveRunner()
       
   152 	elseif anim == dialog02 then
       
   153 		win()
   153     end
   154     end
   154 end
   155 end
   155 
   156 
   156 function AnimationSetup()
   157 function AnimationSetup()
   157 	-- DIALOG 01 - Start, game instructions
   158 	-- DIALOG 01 - Start, game instructions
   189 	end
   190 	end
   190 	return false
   191 	return false
   191 end
   192 end
   192 
   193 
   193 function moveRunner()
   194 function moveRunner()
   194 	if currentPosition > 3 then
   195 	if currentPosition == 4 then
       
   196 		currentPosition = currentPosition + 1
   195 		if GetX(hero.gear) > GetX(runner.gear) then
   197 		if GetX(hero.gear) > GetX(runner.gear) then
   196 			HogTurnLeft(runner.gear, false)
   198 			HogTurnLeft(runner.gear, false)
   197 		end
   199 		end
       
   200 		AddAnim(dialog02)
   198 		TurnTimeLeft = 0
   201 		TurnTimeLeft = 0
   199 		AddAnim(dialog02)
   202 	elseif currentPosition < 4 then
   200 	else
       
   201 		if not startChallenge then
   203 		if not startChallenge then
   202 			startChallenge = true
   204 			startChallenge = true
   203 		end
   205 		end
   204 		AddAmmo(hero.gear, amRope, 1)
   206 		AddAmmo(hero.gear, amRope, 1)
   205 		if currentPosition ~= 1 then
   207 		if currentPosition ~= 1 then
   209 				AnimSay(runner.gear, loc("You got me"), SAY_SAY, 3000)
   211 				AnimSay(runner.gear, loc("You got me"), SAY_SAY, 3000)
   210 			end
   212 			end
   211 			previousTimeLeft = TurnTimeLeft
   213 			previousTimeLeft = TurnTimeLeft
   212 		end
   214 		end
   213 		currentPosition = currentPosition + 1
   215 		currentPosition = currentPosition + 1
       
   216 		AddVisualGear(GetX(runner.gear), GetY(runner.gear), vgtExplosion, 0, false) 
   214 		SetGearPosition(runner.gear, runner.places[currentPosition].x, runner.places[currentPosition].y)
   217 		SetGearPosition(runner.gear, runner.places[currentPosition].x, runner.places[currentPosition].y)
   215 		TurnTimeLeft = 0
   218 		TurnTimeLeft = 0
   216 	end
   219 	end
   217 end
   220 end
   218 
   221