share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua
branchspacecampaign
changeset 9596 feb3d880852d
parent 9595 1acc5c3dc066
child 9597 83fa1ba837b8
equal deleted inserted replaced
9595:1acc5c3dc066 9596:feb3d880852d
    11 ----------------- VARIABLES --------------------
    11 ----------------- VARIABLES --------------------
    12 -- globals
    12 -- globals
    13 local missionName = loc("Precise shooting")
    13 local missionName = loc("Precise shooting")
    14 local timeLeft = 10000
    14 local timeLeft = 10000
    15 local lastWeaponUsed = amSniperRifle
    15 local lastWeaponUsed = amSniperRifle
       
    16 local challengeObjectives = loc("Use your available weapons in order to eliminate the enemies").."|"..
       
    17 	loc("You can only use the Sniper Rifle or the Watermelon bomb").."|"..
       
    18 	loc("You'll have only 2 watermelon bombs during the game").."|"..
       
    19 	loc("You'll get an extra Sniper Rifle every time you kill an enemy hog with a limit of max 3 rifles").."|"..
       
    20 	loc("You'll get an extra Teleport every time you kill an enemy hog with a limit of max 2 teleports").."|"..
       
    21 	loc("The first turn will last 25 sec and every other turn 15 sec").."|"..
       
    22 	loc("If you skip the game your time left will be added to your next turn").."|"..
       
    23 	loc("Some parts of the land are indestructible")
       
    24 -- dialogs
       
    25 local dialog01 = {}
       
    26 -- mission objectives
       
    27 local goals = {
       
    28 	[dialog01] = {missionName, loc("Challenge Objectives"), challengeObjectives, 1, 4500},
       
    29 }
    16 -- hogs
    30 -- hogs
    17 local hero = {
    31 local hero = {
    18 	name = loc("Hog Solo"),
    32 	name = loc("Hog Solo"),
    19 	x = 1100,
    33 	x = 1100,
    20 	y = 560
    34 	y = 560
    83 	end
    97 	end
    84 	
    98 	
    85 	initCheckpoint("fruit03")
    99 	initCheckpoint("fruit03")
    86 	
   100 	
    87 	AnimInit()
   101 	AnimInit()
    88 	--AnimationSetup()
   102 	AnimationSetup()
    89 end
   103 end
    90 
   104 
    91 function onGameStart()
   105 function onGameStart()
    92 	AnimWait(hero.gear, 3000)
   106 	AnimWait(hero.gear, 3000)
    93 	FollowGear(hero.gear)
   107 	FollowGear(hero.gear)
       
   108 	ShowMission(missionName, loc("Challenge Objectives"), challengeObjectives, -amSkip, 0)
    94 	
   109 	
    95 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
   110 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
    96 	
   111 	
    97 	--hero ammo
   112 	--hero ammo
    98 	AddAmmo(hero.gear, amTeleport, 2)
   113 	AddAmmo(hero.gear, amTeleport, 2)
   107 	AddAmmo(enemiesEven[1].gear, amSniperRifle, 100)
   122 	AddAmmo(enemiesEven[1].gear, amSniperRifle, 100)
   108 	AddAmmo(enemiesEven[1].gear, amWatermelon, 1)
   123 	AddAmmo(enemiesEven[1].gear, amWatermelon, 1)
   109 	AddAmmo(enemiesEven[1].gear, amGrenade, 5)
   124 	AddAmmo(enemiesEven[1].gear, amGrenade, 5)
   110 	
   125 	
   111 	SendHealthStatsOff()
   126 	SendHealthStatsOff()
       
   127 	AddAnim(dialog01)
   112 end
   128 end
   113 
   129 
   114 function onNewTurn()
   130 function onNewTurn()
   115 	if CurrentHedgehog == hero.gear then
   131 	if CurrentHedgehog == hero.gear then
   116 		if GetAmmoCount(hero.gear, amSkip) == 0 then
   132 		if GetAmmoCount(hero.gear, amSkip) == 0 then
   118 			AddAmmo(hero.gear, amSkip, 1)
   134 			AddAmmo(hero.gear, amSkip, 1)
   119 		end
   135 		end
   120 		timeLeft = 0
   136 		timeLeft = 0
   121 	end
   137 	end
   122 	turnHogs()
   138 	turnHogs()
       
   139 end
       
   140 
       
   141 function onGameTick()
       
   142 	AnimUnWait()
       
   143 	if ShowAnimation() == false then
       
   144 		return
       
   145 	end
       
   146 	ExecuteAfterAnimations()
       
   147 	CheckEvents()
   123 end
   148 end
   124 
   149 
   125 function onGameTick20()
   150 function onGameTick20()
   126 	if CurrentHedgehog == hero.gear and TurnTimeLeft ~= 0 then
   151 	if CurrentHedgehog == hero.gear and TurnTimeLeft ~= 0 then
   127 		timeLeft = TurnTimeLeft
   152 		timeLeft = TurnTimeLeft
   140 			AddAmmo(hero.gear, amSniperRifle, availableSniper + 1 )
   165 			AddAmmo(hero.gear, amSniperRifle, availableSniper + 1 )
   141 		end
   166 		end
   142 	end
   167 	end
   143 end
   168 end
   144 
   169 
       
   170 function onPrecise()
       
   171 	if GameTime > 3000 then
       
   172 		SetAnimSkip(true)   
       
   173 	end
       
   174 end
       
   175 
   145 -------------- EVENTS ------------------
   176 -------------- EVENTS ------------------
   146 
   177 
   147 function onHeroDeath(gear)
   178 function onHeroDeath(gear)
   148 	if not GetHealth(hero.gear) then
   179 	if not GetHealth(hero.gear) then
   149 		return true
   180 		return true
   154 -------------- ACTIONS ------------------
   185 -------------- ACTIONS ------------------
   155 
   186 
   156 -- game ends anyway but I want to sent custom stats probably...
   187 -- game ends anyway but I want to sent custom stats probably...
   157 function heroDeath(gear)
   188 function heroDeath(gear)
   158 	EndGame()
   189 	EndGame()
       
   190 end
       
   191 
       
   192 -------------- ANIMATIONS ------------------
       
   193 
       
   194 function Skipanim(anim)
       
   195 	if goals[anim] ~= nil then
       
   196 		ShowMission(unpack(goals[anim]))
       
   197     end
       
   198     startBattle()
       
   199 end
       
   200 
       
   201 function AnimationSetup()
       
   202 	-- DIALOG 01 - Start, game instructions
       
   203 	AddSkipFunction(dialog01, Skipanim, {dialog01})
       
   204 	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 3000}})
       
   205 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("Somewhere in the Fruit Planet Hog Solo got lost..."), 5000}})
       
   206 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("...and got ambushed by the Red Strawberies"), 5000}})
       
   207 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("Use your available weapons in order to eliminate the enemies"), 5000}})
       
   208 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("You can only use the Sniper Rifle or the Watermelon bomb"), 5000}})
       
   209 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("You'll have only 2 watermelon bombs during the game"), 5000}})
       
   210 	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 3 rifles"), 5000}})
       
   211 	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}})
       
   212 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("The first turn will last 25 sec and every other turn 15 sec"), 5000}})
       
   213 	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}})
       
   214 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("Some parts of the land are indestructible"), 5000}})
       
   215 	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 500}})
       
   216 	table.insert(dialog01, {func = startBattle, args = {hero.gear}})	
   159 end
   217 end
   160 
   218 
   161 ------------------ Other Functions -------------------
   219 ------------------ Other Functions -------------------
   162 
   220 
   163 function turnHogs()
   221 function turnHogs()
   180 				end
   238 				end
   181 			end
   239 			end
   182 		end
   240 		end
   183 	end
   241 	end
   184 end
   242 end
       
   243 
       
   244 function startBattle()
       
   245 	AnimSwitchHog(enemiesOdd[table.getn(enemiesOdd)].gear)
       
   246 	TurnTimeLeft = 0
       
   247 	-- these 2 are needed in order hero has 10 sec more in the first turn
       
   248 	timeLeft = 10000
       
   249 	AddAmmo(hero.gear, amSkip, 0)
       
   250 end