share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua
branchspacecampaign
changeset 9461 0058a9863724
parent 9459 8c653c0dd332
child 9463 653af9cec589
equal deleted inserted replaced
9459:8c653c0dd332 9461:0058a9863724
     7 HedgewarsScriptLoad("/Scripts/Animate.lua")
     7 HedgewarsScriptLoad("/Scripts/Animate.lua")
     8 
     8 
     9 ----------------- VARIABLES --------------------
     9 ----------------- VARIABLES --------------------
    10 -- globals
    10 -- globals
    11 local campaignName = loc("A Space Adventure")
    11 local campaignName = loc("A Space Adventure")
    12 local missionName = loc("Ice planet, a frozen adventure!")
    12 local missionName = loc("Ice planet, A Saucer Race!")
       
    13 local challengeStarted = false
    13 local currentWaypoint = 1
    14 local currentWaypoint = 1
    14 local radius = 75
    15 local radius = 75
    15 -- dialogs
    16 -- dialogs
    16 local dialog01 = {}
    17 local dialog01 = {}
    17 -- mission objectives
    18 -- mission objectives
    18 local goals = {
    19 local goals = {
    19 	[dialog01] = {missionName, loc("Getting ready"), loc("Collect the icegun and get the device part from Thanta"), 1, 4500},
    20 	[dialog01] = {missionName, loc("Getting ready"), loc("Use your saucer and pass from the rings!"), 1, 4500},
    20 }
    21 }
    21 -- hogs
    22 -- hogs
    22 local hero = {}
    23 local hero = {}
    23 local ally = {}
    24 local ally = {}
    24 -- teams
    25 -- teams
    57 }
    58 }
    58 
    59 
    59 -------------- LuaAPI EVENT HANDLERS ------------------
    60 -------------- LuaAPI EVENT HANDLERS ------------------
    60 
    61 
    61 function onGameInit()
    62 function onGameInit()
       
    63 	GameFlags = gfInvulnerable
    62 	Seed = 1
    64 	Seed = 1
    63 	TurnTime = 15000
    65 	TurnTime = 15000
    64 	CaseFreq = 0
    66 	CaseFreq = 0
    65 	MinesNum = 0
    67 	MinesNum = 0
    66 	MinesTime = 1
    68 	MinesTime = 1
    77 	ally.gear = AddHog(ally.name, 0, 100, "tophats")
    79 	ally.gear = AddHog(ally.name, 0, 100, "tophats")
    78 	AnimSetGearPosition(ally.gear, ally.x, ally.y)
    80 	AnimSetGearPosition(ally.gear, ally.x, ally.y)
    79 	HogTurnLeft(ally.gear, true)
    81 	HogTurnLeft(ally.gear, true)
    80 	
    82 	
    81 	AnimInit()
    83 	AnimInit()
    82 	--AnimationSetup()	
    84 	AnimationSetup()	
    83 end
    85 end
    84 local wp = 0
    86 
    85 function onGameStart()
    87 function onGameStart()
    86 	AnimWait(hero.gear, 3000)
    88 	AnimWait(hero.gear, 3000)
    87 	FollowGear(hero.gear)
    89 	FollowGear(hero.gear)
    88 	
    90 	
       
    91 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
       
    92 	
    89 	AddAmmo(hero.gear, amJetpack, 2)
    93 	AddAmmo(hero.gear, amJetpack, 2)
    90 	
    94 	
    91 	-- place a waypoint
    95 	-- place a waypoint
    92 	placeNextWaypoint()
    96 	placeNextWaypoint()
    93 	
    97 	
    94 	SendHealthStatsOff()
    98 	SendHealthStatsOff()
       
    99 	AddAnim(dialog01)
       
   100 end
       
   101 
       
   102 function onNewTurn()
       
   103 	if not hero.dead and CurrentHedgehog == ally.gear and challengeStarted then
       
   104 		heroLost()
       
   105 	end
       
   106 end
       
   107 
       
   108 function onGameTick()
       
   109 	AnimUnWait()
       
   110 	if ShowAnimation() == false then
       
   111 		return
       
   112 	end
       
   113 	ExecuteAfterAnimations()
       
   114 	CheckEvents()
    95 end
   115 end
    96 
   116 
    97 function onGameTick20()
   117 function onGameTick20()
    98 	if checkIfHeroInWaypoint() then
   118 	if checkIfHeroInWaypoint() then
    99 		if not placeNextWaypoint() then
   119 		if not placeNextWaypoint() then
   107 	if gear == hero.gear then
   127 	if gear == hero.gear then
   108 		hero.dead = true
   128 		hero.dead = true
   109 	end
   129 	end
   110 end
   130 end
   111 
   131 
       
   132 function onPrecise()
       
   133 	if GameTime > 3000 then
       
   134 		SetAnimSkip(true)   
       
   135 	end
       
   136 end
       
   137 
       
   138 -------------- EVENTS ------------------
       
   139 
       
   140 function onHeroDeath(gear)
       
   141 	if hero.dead then
       
   142 		return true
       
   143 	end
       
   144 	return false
       
   145 end
       
   146 
       
   147 -------------- OUTCOMES ------------------
       
   148 
       
   149 function heroDeath(gear)
       
   150 	heroLost()
       
   151 end
       
   152 
       
   153 -------------- ANIMATIONS ------------------
       
   154 
       
   155 function Skipanim(anim)
       
   156 	if goals[anim] ~= nil then
       
   157 		ShowMission(unpack(goals[anim]))
       
   158     end
       
   159     startFlying()
       
   160 end
       
   161 
       
   162 function AnimationSetup()
       
   163 	-- DIALOG 01 - Start, some story telling
       
   164 	AddSkipFunction(dialog01, Skipanim, {dialog01})
       
   165 	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 3000}})
       
   166 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("In the ice planet flying saucer stadium..."), 5000}})
       
   167 	table.insert(dialog01, {func = AnimSay, args = {ally.gear, loc("This is the olympic stadium of saucer flying..."), SAY_SAY, 4000}})
       
   168 	table.insert(dialog01, {func = AnimSay, args = {ally.gear, loc("All the saucer pilots dream one day to come here and compete with the best!"), SAY_SAY, 5000}})
       
   169 	table.insert(dialog01, {func = AnimSay, args = {ally.gear, loc("Now you have the chance to try and get the place that you deserve between the best..."), SAY_SAY, 6000}})
       
   170 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("Use the saucer and pass from the rings..."), 5000}})
       
   171 	table.insert(dialog01, {func = AnimSay, args = {ally.gear, loc("... can you do it?"), SAY_SAY, 2000}})
       
   172 	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 500}})
       
   173 	table.insert(dialog01, {func = startFlying, args = {hero.gear}})	
       
   174 end
       
   175 
   112 ------------------ Other Functions -------------------
   176 ------------------ Other Functions -------------------
   113 
   177 
       
   178 function startFlying()
       
   179 	AnimSwitchHog(ally.gear)
       
   180 	TurnTimeLeft = 0
       
   181 	challengeStarted = true
       
   182 end
       
   183 
   114 function placeNextWaypoint()
   184 function placeNextWaypoint()
   115 	WriteLnToConsole("IN PLACE NEXT POINT")
       
   116 	if currentWaypoint > 1 then
   185 	if currentWaypoint > 1 then
   117 		local wp = waypoints[currentWaypoint-1]
   186 		local wp = waypoints[currentWaypoint-1]
   118 		DeleteVisualGear(wp.gear)
   187 		DeleteVisualGear(wp.gear)
   119 	end
   188 	end
   120 	if currentWaypoint < 16 then
   189 	if currentWaypoint < 16 then
   121 		local wp = waypoints[currentWaypoint]
   190 		local wp = waypoints[currentWaypoint]
   122 		wp.gear = AddVisualGear(1,1,vgtCircle,1,true)
   191 		wp.gear = AddVisualGear(1,1,vgtCircle,1,true)
   123 		SetVisualGearValues(wp.gear, wp.x,wp.y, 20, 200, 0, 0, 100, radius, 3, 0xff0000ff)
   192 		SetVisualGearValues(wp.gear, wp.x,wp.y, 20, 200, 0, 0, 100, radius, 3, 0xff0000ff)
   124 		-- add bonus time and "fuel"		
   193 		-- add bonus time and "fuel"
   125 		WriteLnToConsole("Before "..TurnTimeLeft)
       
   126 		if currentWaypoint % 2 == 0 then
   194 		if currentWaypoint % 2 == 0 then
   127 			AddAmmo(hero.gear, amJetpack, GetAmmoCount(hero.gear, amJetpack)+1)
   195 			AddAmmo(hero.gear, amJetpack, GetAmmoCount(hero.gear, amJetpack)+1)
   128 			if TurnTimeLeft <= 10000 then
   196 			if TurnTimeLeft <= 20000 then
   129 				TurnTimeLeft = TurnTimeLeft + 8000
   197 				TurnTimeLeft = TurnTimeLeft + 8000
   130 			end		
   198 			end		
   131 		else
   199 		else
   132 			if TurnTimeLeft <= 7000 then
   200 			if TurnTimeLeft <= 14000 then
   133 				TurnTimeLeft = TurnTimeLeft + 6000
   201 				TurnTimeLeft = TurnTimeLeft + 6000
   134 			end
   202 			end
   135 		end		
   203 		end	
   136 		WriteLnToConsole("After "..TurnTimeLeft)
       
   137 		radius = radius - 4
   204 		radius = radius - 4
   138 		currentWaypoint = currentWaypoint + 1
   205 		currentWaypoint = currentWaypoint + 1
   139 		return true
   206 		return true
   140 	end
   207 	end
   141 	return false
   208 	return false
   150 			return true
   217 			return true
   151 		end
   218 		end
   152 	end
   219 	end
   153 	return false
   220 	return false
   154 end
   221 end
       
   222 
       
   223 function heroLost()
       
   224 	SendStat('siGameResult', loc("Oh man! Learn how to fly!")) --1
       
   225 	SendStat('siCustomAchievement', loc("To win the game you have to pass into the rings in time")) --11
       
   226 	SendStat('siCustomAchievement', loc("You'll get extra time in case you need it when you pass a ring")) --11
       
   227 	SendStat('siCustomAchievement', loc("Every 2 rings you'll get extra flying saucers")) --11
       
   228 	SendStat('siCustomAchievement', loc("Use space button twice to change flying saucer while being on air")) --11
       
   229 	SendStat('siCustomAchievement', loc("Pause the game to have a look where is the next ring")) --11
       
   230 	SendStat('siPlayerKills','0',teamA.name)
       
   231 	EndGame()
       
   232 end