share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua
branchspacecampaign
changeset 9426 f89c512925da
parent 9424 9a150b7862e9
child 9428 b483a2683d08
equal deleted inserted replaced
9424:9a150b7862e9 9426:f89c512925da
     6 -- lost part.
     6 -- lost part.
     7 
     7 
     8 -- TODO
     8 -- TODO
     9 -- maybe use same name in missionName and frontend mission name..
     9 -- maybe use same name in missionName and frontend mission name..
    10 -- in this map I have to track the weapons the player has in checkpoints
    10 -- in this map I have to track the weapons the player has in checkpoints
    11 -- GENRAL NOTE: change hats :D
    11 -- GENERAL NOTE: change hats :D
    12 
    12 
    13 HedgewarsScriptLoad("/Scripts/Locale.lua")
    13 HedgewarsScriptLoad("/Scripts/Locale.lua")
    14 HedgewarsScriptLoad("/Scripts/Animate.lua")
    14 HedgewarsScriptLoad("/Scripts/Animate.lua")
    15 
    15 
    16 ----------------- VARIABLES --------------------
    16 ----------------- VARIABLES --------------------
    17 -- globals
    17 -- globals
    18 local campaignName = loc("A Space Adventure")
    18 local campaignName = loc("A Space Adventure")
    19 local missionName = loc("Desert planet, lost in sand!")
    19 local missionName = loc("Desert planet, lost in sand!")
       
    20 local heroIsInBattle = false
       
    21 local ongoingBattle = 0
    20 local checkPointReached = 1 -- 1 is normal spawn
    22 local checkPointReached = 1 -- 1 is normal spawn
    21 -- dialogs
    23 -- dialogs
    22 local dialog01 = {}
    24 local dialog01 = {}
    23 -- mission objectives
    25 -- mission objectives
    24 local goals = {
    26 local goals = {
    58 hero.dead = false
    60 hero.dead = false
    59 ally.name = "Chief Sandologist"
    61 ally.name = "Chief Sandologist"
    60 ally.x = 1660
    62 ally.x = 1660
    61 ally.y = 40
    63 ally.y = 40
    62 smuggler1.name = "Sanndy"
    64 smuggler1.name = "Sanndy"
    63 smuggler1.x = 320
    65 smuggler1.x = 400
    64 smuggler1.y = 235
    66 smuggler1.y = 235
    65 smuggler2.name = "Spike"
    67 smuggler2.name = "Spike"
    66 smuggler2.x = 736
    68 smuggler2.x = 736
    67 smuggler2.y = 860
    69 smuggler2.y = 860
    68 smuggler3.name = "Sandstorm"
    70 smuggler3.name = "Sandstorm"
    77 
    79 
    78 -------------- LuaAPI EVENT HANDLERS ------------------
    80 -------------- LuaAPI EVENT HANDLERS ------------------
    79 
    81 
    80 function onGameInit()
    82 function onGameInit()
    81 	Seed = 1
    83 	Seed = 1
    82 	TurnTime = 25000
    84 	TurnTime = 20000
    83 	CaseFreq = 0
    85 	CaseFreq = 0
    84 	MinesNum = 0
    86 	MinesNum = 0
    85 	MinesTime = 1
    87 	MinesTime = 1
    86 	Explosives = 0
    88 	Explosives = 0
    87 	Delay = 3
    89 	Delay = 3
    98 	AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy")
   100 	AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy")
    99 	ally.gear = AddHog(ally.name, 0, 100, "war_desertgrenadier1")
   101 	ally.gear = AddHog(ally.name, 0, 100, "war_desertgrenadier1")
   100 	AnimSetGearPosition(ally.gear, ally.x, ally.y)
   102 	AnimSetGearPosition(ally.gear, ally.x, ally.y)
   101 	-- Smugglers
   103 	-- Smugglers
   102 	AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "cm_birdy")
   104 	AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "cm_birdy")
   103 	smuggler1.gear = AddHog(smuggler1.name, 1, 120, "tophats")
   105 	smuggler1.gear = AddHog(smuggler1.name, 1, 100, "tophats")
   104 	AnimSetGearPosition(smuggler1.gear, smuggler1.x, smuggler1.y)
   106 	AnimSetGearPosition(smuggler1.gear, smuggler1.x, smuggler1.y)
   105 	smuggler2.gear = AddHog(smuggler2.name, 1, 120, "tophats")
   107 	smuggler2.gear = AddHog(smuggler2.name, 1, 100, "tophats")
   106 	AnimSetGearPosition(smuggler2.gear, smuggler2.x, smuggler2.y)	
   108 	AnimSetGearPosition(smuggler2.gear, smuggler2.x, smuggler2.y)	
   107 	smuggler3.gear = AddHog(smuggler3.name, 1, 120, "tophats")
   109 	smuggler3.gear = AddHog(smuggler3.name, 1, 100, "tophats")
   108 	AnimSetGearPosition(smuggler3.gear, smuggler3.x, smuggler3.y)	
   110 	AnimSetGearPosition(smuggler3.gear, smuggler3.x, smuggler3.y)	
   109 	
   111 	
   110 	AnimInit()
   112 	AnimInit()
   111 	AnimationSetup()	
   113 	AnimationSetup()	
   112 end
   114 end
   113 
   115 
   114 function onGameStart()
   116 function onGameStart()
   115 	AnimWait(hero.gear, 3000)
   117 	AnimWait(hero.gear, 3000)
   116 	FollowGear(hero.gear)
   118 	FollowGear(hero.gear)
   117 	
   119 	
   118 	AddAmmo(hero.gear, amRope, 10)
   120 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
       
   121 	AddEvent(onHeroAtFirstBattle, {hero.gear}, heroAtFirstBattle, {hero.gear}, 1)
       
   122 	AddEvent(onHeroFleeFirstBattle, {hero.gear}, heroFleeFirstBattle, {hero.gear}, 1)
       
   123 	
       
   124 	-- hero ammo
       
   125 	AddAmmo(hero.gear, amRope, 2)
       
   126 	AddAmmo(hero.gear, amBazooka, 3)
       
   127 	AddAmmo(hero.gear, amParachute, 1)
       
   128 	AddAmmo(hero.gear, amGrenade, 6)
       
   129 	AddAmmo(hero.gear, amDEagle, 4)
       
   130 	-- smugglers ammo
       
   131 	AddAmmo(smuggler1.gear, amBazooka, 2)
       
   132 	AddAmmo(smuggler1.gear, amGrenade, 2)
       
   133 	AddAmmo(smuggler1.gear, amDEagle, 2)
   119 	
   134 	
   120 	-- spawn crates	
   135 	-- spawn crates	
   121 	SpawnAmmoCrate(btorch1X, btorch1Y, amBlowTorch)
   136 	SpawnAmmoCrate(btorch1X, btorch1Y, amBlowTorch)
   122 	SpawnAmmoCrate(btorch2X, btorch2Y, amBlowTorch)
   137 	SpawnAmmoCrate(btorch2X, btorch2Y, amBlowTorch)
   123 	SpawnAmmoCrate(btorch3X, btorch3Y, amBlowTorch)
   138 	SpawnAmmoCrate(btorch3X, btorch3Y, amBlowTorch)
   126 	SpawnAmmoCrate(rope3X, rope3Y, amRope)
   141 	SpawnAmmoCrate(rope3X, rope3Y, amRope)
   127 	SpawnAmmoCrate(portalX, portalY, amPortalGun)
   142 	SpawnAmmoCrate(portalX, portalY, amPortalGun)
   128 	SpawnAmmoCrate(constructX, constructY, amConstruction)
   143 	SpawnAmmoCrate(constructX, constructY, amConstruction)
   129 	
   144 	
   130 	SpawnHealthCrate(3300, 970)
   145 	SpawnHealthCrate(3300, 970)
   131 	SpawnHealthCrate(480, 460)
   146 	SpawnHealthCrate(680, 460)
   132 	
   147 	
   133 	-- adding mines - BOOM!
   148 	-- adding mines - BOOM!
   134 	AddGear(1280, 460, gtMine, 0, 0, 0, 0)
   149 	AddGear(1280, 460, gtMine, 0, 0, 0, 0)
   135 	AddGear(270, 460, gtMine, 0, 0, 0, 0)
   150 	AddGear(270, 460, gtMine, 0, 0, 0, 0)
   136 	AddGear(3460, 60, gtMine, 0, 0, 0, 0)
   151 	AddGear(3460, 60, gtMine, 0, 0, 0, 0)
   157 	while x < 2900 do
   172 	while x < 2900 do
   158 		AddGear(x, 470, gtMine, 0, 0, 0, 0)
   173 		AddGear(x, 470, gtMine, 0, 0, 0, 0)
   159 		x = x + math.random(8,20)
   174 		x = x + math.random(8,20)
   160 	end
   175 	end
   161 	
   176 	
       
   177 	SendHealthStatsOff()
   162 	AddAnim(dialog01)
   178 	AddAnim(dialog01)
       
   179 end
       
   180 
       
   181 function onNewTurn()
       
   182 	if CurrentHedgehog ~= hero.gear and not heroIsInBattle then
       
   183 		TurnTimeLeft = 0
       
   184 	elseif CurrentHedgehog == hero.gear and not heroIsInBattle then
       
   185 		TurnTimeLeft = -1
       
   186 	elseif (CurrentHedgehog == smuggler2.gear or CurrentHedgehog == smuggler3.gear) and ongoingBattle == 1 then
       
   187 		AnimSwitchHog(hero.gear)
       
   188 		TurnTimeLeft = 0
       
   189 	elseif CurrentHedgehog == ally.gear then
       
   190 		TurnTimeLeft = 0
       
   191 	end
       
   192 	WriteLnToConsole("CURRENT HEDGEHOG IS "..CurrentHedgehog)
   163 end
   193 end
   164 
   194 
   165 function onGameTick()
   195 function onGameTick()
   166 	AnimUnWait()
   196 	AnimUnWait()
   167 	if ShowAnimation() == false then
   197 	if ShowAnimation() == false then
   188 	if GameTime > 3000 then
   218 	if GameTime > 3000 then
   189 		SetAnimSkip(true)   
   219 		SetAnimSkip(true)   
   190 	end
   220 	end
   191 end
   221 end
   192 
   222 
       
   223 -------------- EVENTS ------------------
       
   224 
       
   225 function onHeroDeath(gear)
       
   226 	if hero.dead then
       
   227 		return true
       
   228 	end
       
   229 	return false
       
   230 end
       
   231 
       
   232 function onHeroAtFirstBattle(gear)
       
   233 	if not hero.dead and not heroIsInBattle and GetX(hero.gear) <= 1450 
       
   234 			and GetY(hero.gear) <= GetY(smuggler1.gear)+5 and GetY(hero.gear) >= GetY(smuggler1.gear)-5 then
       
   235 		return true
       
   236 	end
       
   237 	return false
       
   238 end
       
   239 
       
   240 function onHeroFleeFirstBattle(gear)
       
   241 	if not hero.dead and GetHealth(smuggler1.gear) and heroIsInBattle and ongoingBattle == 1 and (GetX(hero.gear) > 1450 
       
   242 			or (GetY(hero.gear) < GetY(smuggler1.gear)-80 or GetY(hero.gear) > GetY(smuggler1.gear)+300)) then
       
   243 		return true
       
   244 	end
       
   245 	return false
       
   246 end
       
   247 
       
   248 -------------- OUTCOMES ------------------
       
   249 
       
   250 function heroDeath(gear)
       
   251 	SendStat('siGameResult', loc("Hog Solo lost, try again!")) --1
       
   252 	SendStat('siCustomAchievement', loc("To win the game you have to find the right crate")) --11
       
   253 	SendStat('siCustomAchievement', loc("You can avoid some battles")) --11
       
   254 	SendStat('siCustomAchievement', loc("Use your ammo wisely")) --11
       
   255 	SendStat('siPlayerKills','1',teamB.name)
       
   256 	SendStat('siPlayerKills','0',teamC.name)
       
   257 	EndGame()
       
   258 end
       
   259 
       
   260 function heroAtFirstBattle(gear)
       
   261 	WriteLnToConsole("**HERO AT FIRST BATTLE")
       
   262 	TurnTimeLeft = 0
       
   263 	heroIsInBattle = true
       
   264 	ongoingBattle = 1	
       
   265 	AnimSwitchHog(smuggler1.gear)
       
   266 	TurnTimeLeft = 0
       
   267 end
       
   268 
       
   269 function heroFleeFirstBattle(gear)
       
   270 	WriteLnToConsole("++HERO FLEE FIRST BATTLE")
       
   271 	TurnTimeLeft = 0
       
   272 	heroIsInBattle = false
       
   273 	ongoingBattle = 0
       
   274 end
       
   275 
   193 -------------- ANIMATIONS ------------------
   276 -------------- ANIMATIONS ------------------
   194 
   277 
   195 function Skipanim(anim)
   278 function Skipanim(anim)
   196 	if goals[anim] ~= nil then
   279 	if goals[anim] ~= nil then
   197 		ShowMission(unpack(goals[anim]))
   280 		ShowMission(unpack(goals[anim]))
   198     end
   281     end
       
   282     AnimSwitchHog(hero.gear)
   199 end
   283 end
   200 
   284 
   201 function AnimationSetup()
   285 function AnimationSetup()
   202 	-- DIALOG 01 - Start, getting info about the device
   286 	-- DIALOG 01 - Start, getting info about the device
   203 	AddSkipFunction(dialog01, Skipanim, {dialog01})
   287 	AddSkipFunction(dialog01, Skipanim, {dialog01})