share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua
changeset 12577 e2b5c6e805e8
parent 12575 0c5ce463949b
child 12578 5b23c42ef150
equal deleted inserted replaced
12576:1fb961480b3c 12577:e2b5c6e805e8
    25 	loc("Some parts of the land are indestructible.")
    25 	loc("Some parts of the land are indestructible.")
    26 -- dialogs
    26 -- dialogs
    27 local dialog01 = {}
    27 local dialog01 = {}
    28 -- mission objectives
    28 -- mission objectives
    29 local goals = {
    29 local goals = {
    30 	["init"] = {missionName, loc("Challenge objectives"), challengeObjectives, 1, 30000},
    30 	["init"] = {missionName, loc("Challenge objectives"), challengeObjectives, 1, 35000},
    31 }
    31 }
    32 -- hogs
    32 -- hogs
    33 local hero = {
    33 local hero = {
    34 	name = loc("Hog Solo"),
    34 	name = loc("Hog Solo"),
    35 	x = 1100,
    35 	x = 1100,
   105 		AnimSetGearPosition(enemiesOdd[i].gear, enemiesOdd[i].x, enemiesOdd[i].y)
   105 		AnimSetGearPosition(enemiesOdd[i].gear, enemiesOdd[i].x, enemiesOdd[i].y)
   106 	end
   106 	end
   107 
   107 
   108 	initCheckpoint("fruit03")
   108 	initCheckpoint("fruit03")
   109 
   109 
   110 	AnimInit(true)
   110 	AnimInit()
   111 	AnimationSetup()
       
   112 end
   111 end
   113 
   112 
   114 function onGameStart()
   113 function onGameStart()
   115 	AnimWait(hero.gear, 3000)
       
   116 	FollowGear(hero.gear)
   114 	FollowGear(hero.gear)
   117 	ShowMission(unpack(goals["init"]))
   115 	ShowMission(unpack(goals["init"]))
   118 
   116 
   119 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
   117 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
   120 	AddEvent(onHeroWin, {hero.gear}, heroWin, {hero.gear}, 0)
   118 	AddEvent(onHeroWin, {hero.gear}, heroWin, {hero.gear}, 0)
   121 
   119 
   122 	--hero ammo
   120 	--hero ammo
   123 	AddAmmo(hero.gear, amTeleport, 2)
   121 	AddAmmo(hero.gear, amTeleport, 2)
   124 	AddAmmo(hero.gear, amSniperRifle, 2)
   122 	AddAmmo(hero.gear, amSniperRifle, 2)
   125 	AddAmmo(hero.gear, amWatermelon, 2)
   123 	AddAmmo(hero.gear, amWatermelon, 2)
       
   124 
       
   125 	-- these 2 are needed in order hero has 10 sec more in the first turn
       
   126 	AddAmmo(hero.gear, amSkip, 100)
       
   127 	timeLeft = 0
       
   128 
   126 	--enemies ammo
   129 	--enemies ammo
   127 	AddAmmo(enemiesOdd[1].gear, amDEagle, 100)
   130 	AddAmmo(enemiesOdd[1].gear, amDEagle, 100)
   128 	AddAmmo(enemiesOdd[1].gear, amSniperRifle, 100)
   131 	AddAmmo(enemiesOdd[1].gear, amSniperRifle, 100)
   129 	AddAmmo(enemiesOdd[1].gear, amWatermelon, 1)
   132 	AddAmmo(enemiesOdd[1].gear, amWatermelon, 1)
   130 	AddAmmo(enemiesOdd[1].gear, amGrenade, 5)
   133 	AddAmmo(enemiesOdd[1].gear, amGrenade, 5)
   132 	AddAmmo(enemiesEven[1].gear, amSniperRifle, 100)
   135 	AddAmmo(enemiesEven[1].gear, amSniperRifle, 100)
   133 	AddAmmo(enemiesEven[1].gear, amWatermelon, 1)
   136 	AddAmmo(enemiesEven[1].gear, amWatermelon, 1)
   134 	AddAmmo(enemiesEven[1].gear, amGrenade, 5)
   137 	AddAmmo(enemiesEven[1].gear, amGrenade, 5)
   135 
   138 
   136 	SendHealthStatsOff()
   139 	SendHealthStatsOff()
   137 	AddAnim(dialog01)
       
   138 end
   140 end
   139 
   141 
   140 function onNewTurn()
   142 function onNewTurn()
   141 	if CurrentHedgehog == hero.gear then
   143 	if CurrentHedgehog == hero.gear then
   142 		if firstTurn then
   144 		if firstTurn then
       
   145 			-- Unique game rule in this mission
   143 			TurnTimeLeft = 25000
   146 			TurnTimeLeft = 25000
       
   147 			-- Generous ready time on first turn to give more time to read
       
   148 			ReadyTimeLeft = 35000
   144 			battleStarted = true
   149 			battleStarted = true
       
   150 			firstTurn = false
   145 		end
   151 		end
   146 		if lastWeaponUsed == amSkip then
   152 		if lastWeaponUsed == amSkip then
   147 			TurnTimeLeft = TurnTime + timeLeft
   153 			TurnTimeLeft = TurnTime + timeLeft
   148 		end
   154 		end
   149 		timeLeft = 0
   155 		timeLeft = 0
   186 	end
   192 	end
   187 end
   193 end
   188 
   194 
   189 onHogAttack = hideMissionOnAction
   195 onHogAttack = hideMissionOnAction
   190 onAttack = hideMissionOnAction
   196 onAttack = hideMissionOnAction
   191 onLeft = hideMissionOnAction
       
   192 onRight = hideMissionOnAction
       
   193 onUp = hideMissionOnAction
       
   194 onDown = hideMissionOnAction
       
   195 onLJump = hideMissionOnAction
       
   196 onHJump = hideMissionOnAction
       
   197 onSlot = hideMissionOnAction
   197 onSlot = hideMissionOnAction
   198 onSetWeapon = hideMissionOnAction
   198 onSetWeapon = hideMissionOnAction
   199 onTimer = hideMissionOnAction
       
   200 
       
   201 function onPrecise()
       
   202 	if GameTime > 3000 then
       
   203 		SetAnimSkip(true)
       
   204 	end
       
   205 end
       
   206 
   199 
   207 -------------- EVENTS ------------------
   200 -------------- EVENTS ------------------
   208 
   201 
   209 function onHeroDeath(gear)
   202 function onHeroDeath(gear)
   210 	if not GetHealth(hero.gear) then
   203 	if not GetHealth(hero.gear) then
   255 	SendStat(siCustomAchievement, loc("You will gain some extra ammo from the crates the next time you play the \"Getting to the device\" mission."))
   248 	SendStat(siCustomAchievement, loc("You will gain some extra ammo from the crates the next time you play the \"Getting to the device\" mission."))
   256 	sendSimpleTeamRankings({teamA.name, teamB.name, teamC.name})
   249 	sendSimpleTeamRankings({teamA.name, teamB.name, teamC.name})
   257 	SaveCampaignVar("Mission10Won", "true")
   250 	SaveCampaignVar("Mission10Won", "true")
   258 	checkAllMissionsCompleted()
   251 	checkAllMissionsCompleted()
   259 	EndGame()
   252 	EndGame()
   260 end
       
   261 
       
   262 -------------- ANIMATIONS ------------------
       
   263 
       
   264 function Skipanim(anim)
       
   265 	startBattle()
       
   266 end
       
   267 
       
   268 function AnimationSetup()
       
   269 	-- DIALOG 01 - Start, game instructions
       
   270 	AddSkipFunction(dialog01, Skipanim, {dialog01})
       
   271 	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 3000}})
       
   272 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("Somewhere in the Fruit Planet Hog Solo got lost ..."), 5000}})
       
   273 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("... and got ambushed by the Red Strawberries"), 5000}})
       
   274 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("Use your available weapons in order to eliminate the enemies"), 5000}})
       
   275 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("You can only use the sniper rifle or the watermelon bomb"), 5000}})
       
   276 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("You'll have only 2 watermelon bombs during the game"), 5000}})
       
   277 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("You'll get an extra sniper rifle every time you kill an enemy hog with a limit of max 4 rifles"), 5000}})
       
   278 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("You'll get an extra teleport every time you kill an enemy hog with a limit of max 2 teleports"), 5000}})
       
   279 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("The first turn will last 25 sec and every other turn 15 sec"), 5000}})
       
   280 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("If you skip the game your time left will be added to your next turn"), 5000}})
       
   281 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("Some parts of the land are indestructible"), 5000}})
       
   282 	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 500}})
       
   283 	table.insert(dialog01, {func = startBattle, args = {hero.gear}})
       
   284 end
   253 end
   285 
   254 
   286 ------------------ Other Functions -------------------
   255 ------------------ Other Functions -------------------
   287 
   256 
   288 function turnHogs()
   257 function turnHogs()
   306 			end
   275 			end
   307 		end
   276 		end
   308 	end
   277 	end
   309 end
   278 end
   310 
   279 
   311 function startBattle()
   280 function onSwitch()
   312 	AnimSwitchHog(enemiesOdd[table.getn(enemiesOdd)].gear)
   281 	ReadyTimeLeft = ReadyTimeLeft + 2000
   313 	EndTurn(true)
   282 	PlaySound(sndExtraTime)
   314 	-- these 2 are needed in order hero has 10 sec more in the first turn
       
   315 	timeLeft = 0
       
   316 	AddAmmo(hero.gear, amSkip, 100)
       
   317 end
   283 end
   318 
   284 
   319 function isHog(gear)
   285 function isHog(gear)
   320 	local hog = false
   286 	local hog = false
   321 	for i=1,table.getn(enemiesOdd) do
   287 	for i=1,table.getn(enemiesOdd) do