share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua
branchspacecampaign
changeset 9316 213b4267db81
parent 9314 b7ee054888f8
child 9318 413dd0eab399
equal deleted inserted replaced
9314:b7ee054888f8 9316:213b4267db81
     8 -- there is and rescue them.
     8 -- there is and rescue them.
     9 
     9 
    10 -- TODO
    10 -- TODO
    11 -- Fix some glitches when gaining control on animations
    11 -- Fix some glitches when gaining control on animations
    12 -- Round time after check point 2
    12 -- Round time after check point 2
    13 -- Enemys take control
    13 -- Check if enemy weapons are good
       
    14 -- Create event to end game if professor killed
    14 -- Continue with the rest :P
    15 -- Continue with the rest :P
    15 
    16 
    16 HedgewarsScriptLoad("/Scripts/Locale.lua")
    17 HedgewarsScriptLoad("/Scripts/Locale.lua")
    17 HedgewarsScriptLoad("/Scripts/Animate.lua")
    18 HedgewarsScriptLoad("/Scripts/Animate.lua")
    18 
    19 
    19 ----------------- VARIABLES --------------------
    20 ----------------- VARIABLES --------------------
    20 -- globals
    21 -- globals
    21 local campaignName = loc("A Space Adventure")
    22 local campaignName = loc("A Space Adventure")
    22 local missionName = loc("Moon, stop for fuels!")
    23 local missionName = loc("Moon, stop for fuels!")
    23 local weaponsAcquired = false
    24 local weaponsAcquired = false
       
    25 local battleZone = false
    24 local checkPointReached = 1 -- 1 is start of the game
    26 local checkPointReached = 1 -- 1 is start of the game
    25 -- dialogs
    27 -- dialogs
    26 local dialog01 = {}
    28 local dialog01 = {}
    27 local dialog02 = {}
    29 local dialog02 = {}
       
    30 local dialog03 = {}
    28 -- mission objectives
    31 -- mission objectives
    29 local goals = {
    32 local goals = {
    30 	[dialog01] = {missionName, loc("Getting ready"), loc("Go to the upper platform and get the weapons in the crates!"), 1, 4500},
    33 	[dialog01] = {missionName, loc("Getting ready"), loc("Go to the upper platform and get the weapons in the crates!"), 1, 4500},
    31 	[dialog02] = {missionName, loc("Prepare to fight"), loc("Go down and save these PAoTH hogs!"), 1, 5000}
    34 	[dialog02] = {missionName, loc("Prepare to fight"), loc("Go down and save these PAoTH hogs!"), 1, 5000},
       
    35 	[dialog03] = {missionName, loc("The fight begins!"), loc("Neutralize your enemies and be careful!"), 1, 5000}
    32 }
    36 }
    33 -- crates
    37 -- crates
    34 local weaponsY = 100
    38 local weaponsY = 100
    35 local bazookaX = 70
    39 local bazookaX = 70
    36 local parachuteX = 110
    40 local parachuteX = 110
   155 end
   159 end
   156 
   160 
   157 function onGameStart()
   161 function onGameStart()
   158 	-- wait for the first turn to start
   162 	-- wait for the first turn to start
   159 	AnimWait(hero.gear, 3000)
   163 	AnimWait(hero.gear, 3000)
   160 
       
   161 	FollowGear(hero.gear)
   164 	FollowGear(hero.gear)
   162 	
   165 	
   163 	ShowMission(campaignName, missionName, loc("Hog Solo has to refuel his saucer.")..
   166 	ShowMission(campaignName, missionName, loc("Hog Solo has to refuel his saucer.")..
   164 	"|"..loc("Rescue the imprisoned PAoTH team and get your fuels!"), -amSkip, 0)	
   167 	"|"..loc("Rescue the imprisoned PAoTH team and get your fuels!"), -amSkip, 0)
       
   168 	
       
   169 	
       
   170 	AddAmmo(minion1.gear, amDEagle, 2)
       
   171 	AddAmmo(minion2.gear, amDEagle, 2)
       
   172 	AddAmmo(minion3.gear, amDEagle, 2)
       
   173 	AddAmmo(minion1.gear, amBazooka, 2)
       
   174 	AddAmmo(minion2.gear, amBazooka, 2)
       
   175 	AddAmmo(minion3.gear, amBazooka, 2)
       
   176 	AddAmmo(minion1.gear, amGrenade, 2)
       
   177 	AddAmmo(minion2.gear, amGrenade, 2)
       
   178 	AddAmmo(minion3.gear, amGrenade, 2)
   165 	
   179 	
   166 	-- check for death has to go first
   180 	-- check for death has to go first
   167 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
   181 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
       
   182 	AddEvent(onBattleZone, {hero.gear}, battleZone, {hero.gear}, 0)
   168 
   183 
   169 	if checkPointReached == 1 then
   184 	if checkPointReached == 1 then
   170 		AddAmmo(hero.gear, amRope, 2)
   185 		AddAmmo(hero.gear, amRope, 2)
   171 		SpawnAmmoCrate(bazookaX, weaponsY, amBazooka)
   186 		SpawnAmmoCrate(bazookaX, weaponsY, amBazooka)
   172 		SpawnAmmoCrate(parachuteX, weaponsY, amParachute)
   187 		SpawnAmmoCrate(parachuteX, weaponsY, amParachute)
   173 		SpawnAmmoCrate(grenadeX, weaponsY, amGrenade)
   188 		SpawnAmmoCrate(grenadeX, weaponsY, amGrenade)
   174 		SpawnAmmoCrate(deserteagleX, weaponsY, amDEagle)
   189 		SpawnAmmoCrate(deserteagleX, weaponsY, amDEagle)
   175 		AddEvent(onWeaponsPlatform, {hero.gear}, weaponsPlatform, {hero.gear}, 0)
   190 		AddEvent(onWeaponsPlatform, {hero.gear}, weaponsPlatform, {hero.gear}, 0)
       
   191 		TurnTimeLeft = 0
   176 		AddAnim(dialog01)
   192 		AddAnim(dialog01)
   177 	elseif checkPointReached == 2 then	
   193 	elseif checkPointReached == 2 then	
   178 		AddAmmo(hero.gear, amBazooka, 2)
   194 		AddAmmo(hero.gear, amBazooka, 2)
   179 		AddAmmo(hero.gear, amParachute, 2)
   195 		AddAmmo(hero.gear, amParachute, 2)
   180 		AddAmmo(hero.gear, amGrenade, 2)
   196 		AddAmmo(hero.gear, amGrenade, 2)
   181 		AddAmmo(hero.gear, amDEagle, 2)
   197 		AddAmmo(hero.gear, amDEagle, 2)
   182 		SetWind(80)		
   198 		SetWind(80)		
   183 		GameFlags = bor(GameFlags,gfDisableWind)
   199 		GameFlags = bor(GameFlags,gfDisableWind)
   184 		weaponsAcquired = true
   200 		weaponsAcquired = true
       
   201 		TurnTimeLeft = 0
   185 		AddAnim(dialog02)
   202 		AddAnim(dialog02)
   186 	end
   203 	end
   187 end
   204 end
   188 
   205 
   189 function onAmmoStoreInit()
   206 function onAmmoStoreInit()
   192 	SetAmmo(amGrenade, 0, 0, 0, 2)
   209 	SetAmmo(amGrenade, 0, 0, 0, 2)
   193 	SetAmmo(amDEagle, 0, 0, 0, 2)
   210 	SetAmmo(amDEagle, 0, 0, 0, 2)
   194 end
   211 end
   195 
   212 
   196 function onGameTick()
   213 function onGameTick()
       
   214 	--WriteLnToConsole("ON GAME TICK")
   197 	AnimUnWait()
   215 	AnimUnWait()
   198 	if ShowAnimation() == false then
   216 	if ShowAnimation() == false then
   199 		return
   217 		return
   200 	end
   218 	end
   201 	ExecuteAfterAnimations()
   219 	ExecuteAfterAnimations()
   202 	CheckEvents()
   220 	CheckEvents()
   203 	if CurrentHedgehog ~= hero.gear then
   221 	if CurrentHedgehog ~= hero.gear and not battleZone then
   204 		TurnTimeLeft = 0
   222 		TurnTimeLeft = 0
   205 	end
   223 	end
   206 end
   224 end
   207 
   225 
   208 function onNewTurn()
   226 function onNewTurn()
   209 	if not weaponsAcquired and CurrentHedgehog ~= hero.gear then
   227 	WriteLnToConsole("ON NEW TURN")
   210 		TurnTimeLeft = 0
   228 	WriteLnToConsole("HOG IS "..CurrentHedgehog.." minion 1 is "..minion1.gear)
   211 	elseif not weaponsAcquired and CurrentHedgehog == hero.gear then
   229 		
       
   230 	if not weaponsAcquired and not battleZone and CurrentHedgehog ~= hero.gear then
       
   231 		WriteLnToConsole("TURN CASE 1")
       
   232 		TurnTimeLeft = 0
       
   233 	elseif not weaponsAcquired and not battleZone and CurrentHedgehog == hero.gear then
       
   234 		WriteLnToConsole("TURN CASE 2")
   212 		TurnTimeLeft = -1
   235 		TurnTimeLeft = -1
   213 	elseif CurrentHedgehog == paoth1.gear or CurrentHedgehog == paoth1.gear
   236 	elseif CurrentHedgehog == paoth1.gear or CurrentHedgehog == paoth2.gear
   214 		or CurrentHedgehog == paoth3.gear or CurrentHedgehog == paoth4.gear
   237 		or CurrentHedgehog == paoth3.gear or CurrentHedgehog == paoth4.gear then
   215 		or CurrentHedgehog == professor.gear then
   238 		WriteLnToConsole("TURN CASE 3")
       
   239 		TurnTimeLeft = 0
       
   240 	elseif CurrentHedgehog == professor.gear then
       
   241 		AnimSwitchHog(hero.gear)
   216 		TurnTimeLeft = 0
   242 		TurnTimeLeft = 0
   217 	end
   243 	end
   218 end
   244 end
   219 
   245 
   220 function onPrecise()
   246 function onPrecise()
       
   247 	WriteLnToConsole("ON PRECISE")
   221 	if GameTime > 3000 then
   248 	if GameTime > 3000 then
   222 		SetAnimSkip(true)   
   249 		SetAnimSkip(true)   
   223 	end
   250 	end
   224 end
   251 end
   225 
   252 
   230 end
   257 end
   231 
   258 
   232 -------------- EVENTS ------------------
   259 -------------- EVENTS ------------------
   233 
   260 
   234 function onWeaponsPlatform(gear)
   261 function onWeaponsPlatform(gear)
   235 	if GetX(gear) > bazookaX-200 and GetX(gear) < deserteagleX+400  and GetY(gear) < weaponsY+150 and StoppedGear(gear) then
   262 	if not hero.dead and GetX(gear) > bazookaX-200 and GetX(gear) < deserteagleX+400  
       
   263 		and GetY(gear) < weaponsY+150 and StoppedGear(gear) then
   236 		return true
   264 		return true
   237 	end
   265 	end
   238 	return false
   266 	return false
   239 end
   267 end
   240 
   268 
   241 function onHeroDeath(gear)
   269 function onHeroDeath(gear)
   242 	if hero.dead then
   270 	if hero.dead then
       
   271 		return true
       
   272 	end
       
   273 	return false
       
   274 end
       
   275 
       
   276 function onBattleZone(gear)
       
   277 	if not hero.dead and GetX(gear) > 1900 and StoppedGear(gear) then
   243 		return true
   278 		return true
   244 	end
   279 	end
   245 	return false
   280 	return false
   246 end
   281 end
   247 
   282 
   259 function heroDeath(gear)
   294 function heroDeath(gear)
   260 	
   295 	
   261 	EndGame()
   296 	EndGame()
   262 end
   297 end
   263 
   298 
       
   299 function battleZone(gear)
       
   300 	TurnTimeLeft = 0
       
   301 	battleZone = true
       
   302 	AddAnim(dialog03)
       
   303 end
       
   304 
   264 -------------- ANIMATIONS ------------------
   305 -------------- ANIMATIONS ------------------
   265 
   306 
   266 function Skipanim(anim)
   307 function Skipanim(anim)
   267 	if goals[anim] ~= nil then
   308 	if goals[anim] ~= nil then
   268 		ShowMission(unpack(goals[anim]))
   309 		ShowMission(unpack(goals[anim]))
   269     end
   310     end
       
   311     if anim == dialog03 then
       
   312 		startCombat()
       
   313 	end
   270 end
   314 end
   271 
   315 
   272 function AnimationSetup()
   316 function AnimationSetup()
   273 	-- DIALOG 01 - Start, welcome to moon
   317 	-- DIALOG 01 - Start, welcome to moon
   274 	AddSkipFunction(dialog01, Skipanim, {dialog01})
   318 	AddSkipFunction(dialog01, Skipanim, {dialog01})
   289 	AddSkipFunction(dialog02, Skipanim, {dialog02})
   333 	AddSkipFunction(dialog02, Skipanim, {dialog02})
   290 	table.insert(dialog02, {func = AnimCaption, args = {hero.gear, loc("Checkpoint reached!"),  4000}})
   334 	table.insert(dialog02, {func = AnimCaption, args = {hero.gear, loc("Checkpoint reached!"),  4000}})
   291 	table.insert(dialog02, {func = AnimSay, args = {hero.gear, loc("I've made it! YEAAAAAH!"), SAY_SHOUT, 4000}})
   335 	table.insert(dialog02, {func = AnimSay, args = {hero.gear, loc("I've made it! YEAAAAAH!"), SAY_SHOUT, 4000}})
   292 	table.insert(dialog02, {func = AnimSay, args = {paoth1.gear, loc("Nice! Now hurry up and get down! You have to rescue my friends!"), SAY_SHOUT, 7000}})
   336 	table.insert(dialog02, {func = AnimSay, args = {paoth1.gear, loc("Nice! Now hurry up and get down! You have to rescue my friends!"), SAY_SHOUT, 7000}})
   293 	table.insert(dialog02, {func = AnimSwitchHog, args = {hero.gear}})
   337 	table.insert(dialog02, {func = AnimSwitchHog, args = {hero.gear}})
       
   338 	-- DIALOG 03 - Hero spotted and has no weapons
       
   339 	AddSkipFunction(dialog03, Skipanim, {dialog03})
       
   340 	table.insert(dialog03, {func = AnimCaption, args = {hero.gear, loc("Get ready to fight!"), 4000}})
       
   341 	table.insert(dialog03, {func = AnimSay, args = {minion1.gear, loc("Look boss! There is the target!"), SAY_SHOUT, 4000}})
       
   342 	table.insert(dialog03, {func = AnimSay, args = {professor.gear, loc("Prepare for battle!"), SAY_SHOUT, 4000}})
       
   343 	table.insert(dialog03, {func = AnimSay, args = {hero.gear, loc("Oops, I've been spotted and I have no weapons! I am doomed!"), SAY_THINK, 4000}})
       
   344 	table.insert(dialog03, {func = startCombat, args = {hero.gear}})
   294 end
   345 end
   295 
   346 
   296 ------------------- custom "animation" functions --------------------------
   347 ------------------- custom "animation" functions --------------------------
   297 
   348 
   298 function startCombat()
   349 function startCombat()