share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua
changeset 12575 0c5ce463949b
parent 12573 a778c1bb032e
child 12577 e2b5c6e805e8
equal deleted inserted replaced
12574:2a7cc304c8be 12575:0c5ce463949b
    12 -- globals
    12 -- globals
    13 local missionName = loc("Precise shooting")
    13 local missionName = loc("Precise shooting")
    14 local timeLeft = 0
    14 local timeLeft = 0
    15 local lastWeaponUsed = amNothing
    15 local lastWeaponUsed = amNothing
    16 local firstTurn = true
    16 local firstTurn = true
       
    17 local battleStarted = false
    17 local challengeObjectives = loc("Use your available weapons in order to eliminate the enemies.").."|"..
    18 local challengeObjectives = loc("Use your available weapons in order to eliminate the enemies.").."|"..
    18 	loc("You can only use the sniper rifle or the watermelon bomb.").."|"..
    19 	loc("You can only use the sniper rifle or the watermelon bomb.").."|"..
    19 	loc("You'll have only 2 watermelon bombs during the game.").."|"..
    20 	loc("You'll have only 2 watermelon bombs during the game.").."|"..
    20 	loc("You'll get an extra sniper rifle every time you kill an enemy hog with a limit of max 4 rifles.").."|"..
    21 	loc("You'll get an extra sniper rifle every time you kill an enemy hog with a limit of max 4 rifles.").."|"..
    21 	loc("You'll get an extra teleport every time you kill an enemy hog with a limit of max 2 teleports.").."|"..
    22 	loc("You'll get an extra teleport every time you kill an enemy hog with a limit of max 2 teleports.").."|"..
    24 	loc("Some parts of the land are indestructible.")
    25 	loc("Some parts of the land are indestructible.")
    25 -- dialogs
    26 -- dialogs
    26 local dialog01 = {}
    27 local dialog01 = {}
    27 -- mission objectives
    28 -- mission objectives
    28 local goals = {
    29 local goals = {
    29 	[dialog01] = {missionName, loc("Challenge objectives"), challengeObjectives, 1, 4500},
    30 	["init"] = {missionName, loc("Challenge objectives"), challengeObjectives, 1, 30000},
    30 }
    31 }
    31 -- hogs
    32 -- hogs
    32 local hero = {
    33 local hero = {
    33 	name = loc("Hog Solo"),
    34 	name = loc("Hog Solo"),
    34 	x = 1100,
    35 	x = 1100,
   111 end
   112 end
   112 
   113 
   113 function onGameStart()
   114 function onGameStart()
   114 	AnimWait(hero.gear, 3000)
   115 	AnimWait(hero.gear, 3000)
   115 	FollowGear(hero.gear)
   116 	FollowGear(hero.gear)
   116 	ShowMission(missionName, loc("Challenge objectives"), challengeObjectives, -amSkip, 0)
   117 	ShowMission(unpack(goals["init"]))
   117 
   118 
   118 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
   119 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
   119 	AddEvent(onHeroWin, {hero.gear}, heroWin, {hero.gear}, 0)
   120 	AddEvent(onHeroWin, {hero.gear}, heroWin, {hero.gear}, 0)
   120 
   121 
   121 	--hero ammo
   122 	--hero ammo
   138 
   139 
   139 function onNewTurn()
   140 function onNewTurn()
   140 	if CurrentHedgehog == hero.gear then
   141 	if CurrentHedgehog == hero.gear then
   141 		if firstTurn then
   142 		if firstTurn then
   142 			TurnTimeLeft = 25000
   143 			TurnTimeLeft = 25000
       
   144 			battleStarted = true
   143 		end
   145 		end
   144 		if lastWeaponUsed == amSkip then
   146 		if lastWeaponUsed == amSkip then
   145 			TurnTimeLeft = TurnTime + timeLeft
   147 			TurnTimeLeft = TurnTime + timeLeft
   146 		end
   148 		end
   147 		timeLeft = 0
   149 		timeLeft = 0
   174 		if availableSniper < 4 then
   176 		if availableSniper < 4 then
   175 			AddAmmo(hero.gear, amSniperRifle, availableSniper + 1 )
   177 			AddAmmo(hero.gear, amSniperRifle, availableSniper + 1 )
   176 		end
   178 		end
   177 	end
   179 	end
   178 end
   180 end
       
   181 
       
   182 -- Hide mission panel when player does anything
       
   183 function hideMissionOnAction()
       
   184 	if battleStarted then
       
   185 		HideMission()
       
   186 	end
       
   187 end
       
   188 
       
   189 onHogAttack = hideMissionOnAction
       
   190 onAttack = hideMissionOnAction
       
   191 onLeft = hideMissionOnAction
       
   192 onRight = hideMissionOnAction
       
   193 onUp = hideMissionOnAction
       
   194 onDown = hideMissionOnAction
       
   195 onLJump = hideMissionOnAction
       
   196 onHJump = hideMissionOnAction
       
   197 onSlot = hideMissionOnAction
       
   198 onSetWeapon = hideMissionOnAction
       
   199 onTimer = hideMissionOnAction
   179 
   200 
   180 function onPrecise()
   201 function onPrecise()
   181 	if GameTime > 3000 then
   202 	if GameTime > 3000 then
   182 		SetAnimSkip(true)
   203 		SetAnimSkip(true)
   183 	end
   204 	end
   239 end
   260 end
   240 
   261 
   241 -------------- ANIMATIONS ------------------
   262 -------------- ANIMATIONS ------------------
   242 
   263 
   243 function Skipanim(anim)
   264 function Skipanim(anim)
   244 	if goals[anim] ~= nil then
   265 	startBattle()
   245 		ShowMission(unpack(goals[anim]))
       
   246     end
       
   247     startBattle()
       
   248 end
   266 end
   249 
   267 
   250 function AnimationSetup()
   268 function AnimationSetup()
   251 	-- DIALOG 01 - Start, game instructions
   269 	-- DIALOG 01 - Start, game instructions
   252 	AddSkipFunction(dialog01, Skipanim, {dialog01})
   270 	AddSkipFunction(dialog01, Skipanim, {dialog01})