share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua
branchspacecampaign
changeset 9612 825856c67563
parent 9611 ef374528a9fb
child 9613 142ba1d08205
equal deleted inserted replaced
9611:ef374528a9fb 9612:825856c67563
    12 local missionName = loc("Chasing ghosts in moon")
    12 local missionName = loc("Chasing ghosts in moon")
    13 local challengeObjectives = loc("Use your available weapons in order to catch the other hog").."|"..
    13 local challengeObjectives = loc("Use your available weapons in order to catch the other hog").."|"..
    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 = false
    17 -- dialogs
    18 -- dialogs
    18 local dialog01 = {}
    19 local dialog01 = {}
    19 -- mission objectives
    20 -- mission objectives
    20 local goals = {
    21 local goals = {
    21 	[dialog01] = {missionName, loc("Challenge Objectives"), challengeObjectives, 1, 4500},
    22 	[dialog01] = {missionName, loc("Challenge Objectives"), challengeObjectives, 1, 4500},
    58 	Map = "moon02_map"
    59 	Map = "moon02_map"
    59 	Theme = "Cheese"
    60 	Theme = "Cheese"
    60 	
    61 	
    61 	-- Hog Solo
    62 	-- Hog Solo
    62 	AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy")
    63 	AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy")
    63 	hero.gear = AddHog(hero.name, 0, 100, "war_desertgrenadier1")
    64 	hero.gear = AddHog(hero.name, 0, 1, "war_desertgrenadier1")
    64 	AnimSetGearPosition(hero.gear, hero.x, hero.y)
    65 	AnimSetGearPosition(hero.gear, hero.x, hero.y)
    65 	-- Crazy Runner
    66 	-- Crazy Runner
    66 	AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "cm_birdy")
    67 	AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "cm_birdy")
    67 	runner.gear = AddHog(runner.name, 0, 100, "war_desertgrenadier1")
    68 	runner.gear = AddHog(runner.name, 0, 100, "war_desertgrenadier1")
    68 	AnimSetGearPosition(runner.gear, runner.places[1].x, runner.places[1].y)
    69 	AnimSetGearPosition(runner.gear, runner.places[1].x, runner.places[1].y)
    78 	AnimWait(hero.gear, 3000)
    79 	AnimWait(hero.gear, 3000)
    79 	FollowGear(hero.gear)
    80 	FollowGear(hero.gear)
    80 	ShowMission(missionName, loc("Challenge Objectives"), challengeObjectives, -amSkip, 0)
    81 	ShowMission(missionName, loc("Challenge Objectives"), challengeObjectives, -amSkip, 0)
    81 	
    82 	
    82 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
    83 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
    83 	AddEvent(onLose, {hero.gear}, lose, {hero.gear}, 0)
       
    84 	
    84 	
    85 	AddAmmo(hero.gear, amRope, 1)
    85 	AddAmmo(hero.gear, amRope, 1)
       
    86 	AddAmmo(hero.gear, amSkip, 1)
    86 	AddAmmo(hero.gear, amTeleport, 100)
    87 	AddAmmo(hero.gear, amTeleport, 100)
    87 	
    88 	
    88 	SendHealthStatsOff()
    89 	SendHealthStatsOff()
    89 	hogTurn = runner.gear
    90 	hogTurn = runner.gear
    90 	AddAnim(dialog01)
    91 	AddAnim(dialog01)
    91 end
    92 end
    92 
    93 
    93 function onNewTurn()
    94 function onNewTurn()
    94 	WriteLnToConsole("NEW TURN "..CurrentHedgehog)
    95 	WriteLnToConsole("NEW TURN "..CurrentHedgehog)
    95 	if CurrentHedgehog == hero.gear then
    96 	if startChallenge then
    96 		TurnTimeLeft = runner.places[currentPosition].turnTime + previousTimeLeft
    97 		if CurrentHedgehog ~= hero.gear then
    97 		WriteLnToConsole("Turn Time is "..TurnTimeLeft)
    98 			TurnTimeLeft = 0
    98 		previousTimeLeft = 0
    99 		else
    99 		WriteLnToConsole("STILL HERE AND "..TurnTimeLeft.." prev hog = "..hogTurn)
   100 			if GetAmmoCount(hero.gear, amRope) == 0  then
   100 	else
   101 				lose()
   101 		TurnTimeLeft = 0
   102 			end
       
   103 			TurnTimeLeft = runner.places[currentPosition].turnTime + previousTimeLeft
       
   104 			previousTimeLeft = 0
       
   105 		end
   102 	end
   106 	end
   103 end
   107 end
   104 
   108 
   105 function onGameTick()
   109 function onGameTick()
   106 	AnimUnWait()
   110 	AnimUnWait()
   130 		return true
   134 		return true
   131 	end
   135 	end
   132 	return false
   136 	return false
   133 end
   137 end
   134 
   138 
   135 function onLose(gear)
       
   136 	if (GetAmmoCount(hero.gear, amRope) == 0 and previousTimeLeft == 0) or (CurrentHedgehog == hero.gear and TurnTimeLeft == 0)then
       
   137 		return true
       
   138 	end
       
   139 	return false
       
   140 end
       
   141 
       
   142 -------------- ACTIONS ------------------
   139 -------------- ACTIONS ------------------
   143 
   140 
   144 function heroDeath(gear)
   141 function heroDeath(gear)
   145 	-- game over
   142 	-- game over
   146 	WriteLnToConsole("END GAME 1")
   143 	WriteLnToConsole("END GAME 1")
   147 	EndGame()
       
   148 end
       
   149 
       
   150 function lose(gear)
       
   151 	-- game over
       
   152 	WriteLnToConsole("END GAME 2")
       
   153 	EndGame()
   144 	EndGame()
   154 end
   145 end
   155 
   146 
   156 -------------- ANIMATIONS ------------------
   147 -------------- ANIMATIONS ------------------
   157 
   148 
   185 	end
   176 	end
   186 	return false
   177 	return false
   187 end
   178 end
   188 
   179 
   189 function moveRunner()
   180 function moveRunner()
       
   181 	if not startChallenge then
       
   182 		startChallenge = true
       
   183 	end
   190 	AddAmmo(hero.gear, amRope, 1)
   184 	AddAmmo(hero.gear, amRope, 1)
   191 	-- add anim dialogs here
   185 	-- add anim dialogs here
   192 	if currentPosition ~= 1 then
   186 	if currentPosition ~= 1 then
   193 		PlaySound(sndVictory)
   187 		PlaySound(sndVictory)
   194 		AnimSay(runner.gear, loc("You got me"), SAY_SAY, 3000)
   188 		AnimSay(runner.gear, loc("You got me"), SAY_SAY, 3000)
   195 		previousTimeLeft = TurnTimeLeft
   189 		previousTimeLeft = TurnTimeLeft
   196 	end
   190 	end
   197 	currentPosition = currentPosition + 1
   191 	currentPosition = currentPosition + 1
   198 	SetGearPosition(runner.gear, runner.places[currentPosition].x, runner.places[currentPosition].y)
   192 	SetGearPosition(runner.gear, runner.places[currentPosition].x, runner.places[currentPosition].y)
   199 	WriteLnToConsole("HERE 1")
   193 	WriteLnToConsole("HERE 1")
   200 	AnimSwitchHog(runner.gear)
   194 		WriteLnToConsole("HERE A")
   201 	TurnTimeLeft = 0
   195 		TurnTimeLeft = 0
   202 	WriteLnToConsole("HERE 2")
   196 	WriteLnToConsole("HERE 2")
   203 end
   197 end
       
   198 
       
   199 function lose()
       
   200 	-- game over
       
   201 	WriteLnToConsole("ROPE "..GetAmmoCount(hero.gear, amRope))
       
   202 	WriteLnToConsole("PREVIOUS TIME "..previousTimeLeft)
       
   203 	WriteLnToConsole("HOG "..CurrentHedgehog)
       
   204 	WriteLnToConsole("TurnTimeLeft "..TurnTimeLeft)
       
   205 	WriteLnToConsole("END GAME 2")
       
   206 	EndGame()
       
   207 end
       
   208 
       
   209 function heroOutOfRope()
       
   210 	if GetAmmoCount(hero.gear, amRope) == 0  then
       
   211 		return true
       
   212 	end
       
   213 	return false
       
   214 end