share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua
branchspacecampaign
changeset 9534 662edfec06be
parent 9532 4fa58a49ace1
child 9536 7456b28a3421
equal deleted inserted replaced
9532:4fa58a49ace1 9534:662edfec06be
    14 local tookPartInBattle = false
    14 local tookPartInBattle = false
    15 -- dialogs
    15 -- dialogs
    16 local dialog01 = {}
    16 local dialog01 = {}
    17 local dialog02 = {}
    17 local dialog02 = {}
    18 local dialog03 = {}
    18 local dialog03 = {}
       
    19 local dialog04 = {}
    19 -- mission objectives
    20 -- mission objectives
    20 local goals = {
    21 local goals = {
    21 	[dialog01] = {missionName, loc("Getting the Device"), loc("With the help of the other hogs search for the device").."|"..loc("Hog Solo has to reach the last crates"), 1, 4000},
    22 	[dialog01] = {missionName, loc("Getting the Device"), loc("With the help of the other hogs search for the device").."|"..loc("Hog Solo has to reach the last crates"), 1, 4000},
    22 	[dialog02] = {missionName, loc("Battle Starts Now!"), loc("You have choose to fight! Lead the Green Bananas to battle and try not to let them be killed"), 1, 4000},
    23 	[dialog02] = {missionName, loc("Getting the Device"), loc("Explore the tunnel with the other hogs and search for the device").."|"..loc("Hog Solo has to reach the last crates"), 1, 4000},
    23 	[dialog03] = {missionName, loc("Ready for Battle?"), loc("You have choose to flee... Unfortunately the only place where you can launch your saucer is in the most left side of the map"), 1, 4000},
    24 	[dialog03] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack Captain Lime before he attacks back"), 1, 4000},
       
    25 	[dialog04] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack the assasins before they attack back"), 1, 4000},
    24 }
    26 }
    25 -- crates types=[0:ammo,1:utility,2:health]
    27 -- crates types=[0:ammo,1:utility,2:health]
    26 local crates = {
    28 local crates = {
    27 	{type = 0, name = amDEagle, x = 1680, y = 1650},
    29 	{type = 0, name = amDEagle, x = 1680, y = 1650},
    28 	{type = 0, name = amGirder, x = 1680, y = 1160},
    30 	{type = 0, name = amGirder, x = 1680, y = 1160},
    29 	{type = 0, name = amWatermelon, x = 1360, y = 1870},
       
    30 	{type = 0, name = amRope, x = 1400, y = 1870},
    31 	{type = 0, name = amRope, x = 1400, y = 1870},
    31 }
    32 }
       
    33 local weaponCrate = { x = 1360, y = 1870}
    32 -- hogs
    34 -- hogs
    33 local hero = {}
    35 local hero = {}
    34 local green1 = {}
    36 local green1 = {}
    35 local green2 = {}
    37 local green2 = {}
    36 local green3 = {}
    38 local green3 = {}
   112 	if GetCampaignVar(Fruit01JoinedBattle) and GetCampaignVar(Fruit01JoinedBattle) == "true" then
   114 	if GetCampaignVar(Fruit01JoinedBattle) and GetCampaignVar(Fruit01JoinedBattle) == "true" then
   113 		tookPartInBattle = true
   115 		tookPartInBattle = true
   114 	end
   116 	end
   115 	
   117 	
   116 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
   118 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
       
   119 	AddEvent(onDeviceCrates, {hero.gear}, deviceCrates, {hero.gear}, 0)
   117 	
   120 	
   118 	-- Hog Solo and GB weapons
   121 	-- Hog Solo and GB weapons
   119 	AddAmmo(hero.gear, amFirePunch, 3)
   122 	AddAmmo(hero.gear, amFirePunch, 3)
   120 	AddAmmo(hero.gear, amSwitch, 100)
   123 	AddAmmo(hero.gear, amSwitch, 100)
       
   124 	AddAmmo(hero.gear, amTeleport, 100)
   121 	-- Assasins weapons
   125 	-- Assasins weapons
   122 	AddAmmo(redHedgehogs[1].gear, amBazooka, 6)
   126 	AddAmmo(redHedgehogs[1].gear, amBazooka, 6)
   123 	AddAmmo(redHedgehogs[1].gear, amGrenade, 6)
   127 	AddAmmo(redHedgehogs[1].gear, amGrenade, 6)
   124 	for i=1,table.getn(redHedgehogs) do
   128 	for i=1,table.getn(redHedgehogs) do
   125 		HideHog(redHedgehogs[i].gear)
   129 		HideHog(redHedgehogs[i].gear)
   126 	end
   130 	end
   127 	
   131 	
   128 	-- place crates
   132 	-- place crates
   129 	for i=1,table.getn(crates) do
   133 	for i=1,table.getn(crates) do
   130 		SpawnAmmoCrate(crates[i].x, crates[i].y, crates[i].name)
   134 		SpawnAmmoCrate(crates[i].x, crates[i].y, crates[i].name)
       
   135 	end
       
   136 	if tookPartInBattle then
       
   137 		SpawnAmmoCrate(weaponCrate.x, weaponCrate.y, amWatermelon)
       
   138 	else
       
   139 		SpawnAmmoCrate(weaponCrate.x, weaponCrate.y, amSniperRifle)		
   131 	end
   140 	end
   132 	
   141 	
   133 	-- explosives
   142 	-- explosives
   134 	-- I wanted to use FindPlace but doesn't accept height values...
   143 	-- I wanted to use FindPlace but doesn't accept height values...
   135 	local x1 = 950
   144 	local x1 = 950
   170 	
   179 	
   171 	SendHealthStatsOff()
   180 	SendHealthStatsOff()
   172 end
   181 end
   173 
   182 
   174 function onNewTurn()
   183 function onNewTurn()
   175 	if CurrentHedgehog == green1.gear then
   184 	WriteLnToConsole("TURNS "..TotalRounds.." and hog: "..CurrentHedgehog)
       
   185 	if not inBattle and CurrentHedgehog == green1.gear then
   176 		TurnTimeLeft = 0
   186 		TurnTimeLeft = 0
       
   187 	elseif CurrentHedgehog == green2.gear or CurrentHedgehog == green3.gear then
       
   188 		if inBattle then
       
   189 			SwitchHog(hero.gear)
       
   190 			TurnTimeLeft = 20000
       
   191 		else
       
   192 			TurnTimeLeft = 0
       
   193 		end
       
   194 	elseif inBattle then
       
   195 		WriteLnToConsole("IN BATTLE")
       
   196 		TurnTimeLeft = 20000
   177 	elseif not inBattle then
   197 	elseif not inBattle then
   178 		TurnTimeLeft = -1
   198 		TurnTimeLeft = -1
   179 	end
   199 	end
   180 end
   200 end
   181 
   201 
   197 function onAmmoStoreInit()
   217 function onAmmoStoreInit()
   198 	SetAmmo(amDEagle, 0, 0, 0, 6)
   218 	SetAmmo(amDEagle, 0, 0, 0, 6)
   199 	SetAmmo(amGirder, 0, 0, 0, 3)
   219 	SetAmmo(amGirder, 0, 0, 0, 3)
   200 	SetAmmo(amRope, 0, 0, 0, 1)
   220 	SetAmmo(amRope, 0, 0, 0, 1)
   201 	SetAmmo(amWatermelon, 0, 0, 0, 1)
   221 	SetAmmo(amWatermelon, 0, 0, 0, 1)
       
   222 	SetAmmo(amSniperRifle, 0, 0, 0, 1)
   202 end
   223 end
   203 
   224 
   204 function onPrecise()
   225 function onPrecise()
   205 	if GameTime > 3000 then
   226 	if GameTime > 3000 then
   206 		SetAnimSkip(true)   
   227 		SetAnimSkip(true)   
   221 		return true
   242 		return true
   222 	end
   243 	end
   223 	return false
   244 	return false
   224 end
   245 end
   225 
   246 
       
   247 function onSurface(gear)
       
   248 	if not hero.dead and GetY(hero.gear)<850 and  StoppedGear(hero.gear) then
       
   249 		return true
       
   250 	end
       
   251 	return false
       
   252 end
       
   253 
   226 -------------- ACTIONS ------------------
   254 -------------- ACTIONS ------------------
   227 
   255 
   228 function heroDeath(gear)
   256 function heroDeath(gear)
   229 	EndGame()
   257 	EndGame()
   230 end
   258 end
   231 
   259 
   232 function deviceCrates(gear)
   260 function deviceCrates(gear)
       
   261 	TurnTimeLeft = 0
   233 	if not tookPartInBattle then
   262 	if not tookPartInBattle then
   234 		AddAnim(dialog03)
   263 		AddAnim(dialog03)
   235 	else
   264 	else
   236 	
   265 		for i=1,table.getn(redHedgehogs) do
   237 	end
   266 			RestoreHog(redHedgehogs[i].gear)
       
   267 		end
       
   268 		AddAnim(dialog04)
       
   269 	end
       
   270 	AddAmmo(hero.gear, amSwitch, 0)
       
   271 	AddEvent(onSurface, {hero.gear}, surface, {hero.gear}, 0)
       
   272 end
       
   273 
       
   274 function surface(gear)
       
   275 	-- TODO: after going to the surface first round must be played by the player
       
   276 	AnimSwitchHog(hero.gear)
       
   277 	TurnTimeLeft = 20000
       
   278 	inBattle = true
   238 end
   279 end
   239 
   280 
   240 -------------- ANIMATIONS ------------------
   281 -------------- ANIMATIONS ------------------
   241 
   282 
   242 function Skipanim(anim)
   283 function Skipanim(anim)
   243 	if goals[anim] ~= nil then
   284 	if goals[anim] ~= nil then
   244 		ShowMission(unpack(goals[anim]))
   285 		ShowMission(unpack(goals[anim]))
   245     end
   286     end
       
   287     TurnTimeLeft = 0
   246 end
   288 end
   247 
   289 
   248 function AnimationSetup()
   290 function AnimationSetup()
   249 	-- DIALOG 01 - Start, Captain Lime helps Hog Solo because he took part in the battle
   291 	-- DIALOG 01 - Start, Captain Lime helps Hog Solo because he took part in the battle
   250 	AddSkipFunction(dialog01, Skipanim, {dialog01})
   292 	AddSkipFunction(dialog01, Skipanim, {dialog01})
   271 	table.insert(dialog02, {func = AnimWait, args = {hero.gear, 1800}})
   313 	table.insert(dialog02, {func = AnimWait, args = {hero.gear, 1800}})
   272 	table.insert(dialog02, {func = AnimSay, args = {hero.gear, loc("Ok then!"), SAY_SAY, 2000}})
   314 	table.insert(dialog02, {func = AnimSay, args = {hero.gear, loc("Ok then!"), SAY_SAY, 2000}})
   273 	table.insert(dialog02, {func = AnimSwitchHog, args = {hero.gear}})
   315 	table.insert(dialog02, {func = AnimSwitchHog, args = {hero.gear}})
   274 	-- DIALOG03 - At crates, hero learns that Captain Lime is bad
   316 	-- DIALOG03 - At crates, hero learns that Captain Lime is bad
   275 	AddSkipFunction(dialog03, Skipanim, {dialog03})
   317 	AddSkipFunction(dialog03, Skipanim, {dialog03})
       
   318 	table.insert(dialog03, {func = AnimWait, args = {hero.gear, 4000}})
       
   319 	table.insert(dialog03, {func = FollowGear, args = {hero.gear}})
   276 	table.insert(dialog03, {func = AnimSay, args = {hero.gear, loc("Hoo Ray! I've found it, now I have to get back to Captain Lime!"), SAY_SAY, 4000}})
   320 	table.insert(dialog03, {func = AnimSay, args = {hero.gear, loc("Hoo Ray! I've found it, now I have to get back to Captain Lime!"), SAY_SAY, 4000}})
   277 	table.insert(dialog03, {func = AnimWait, args = {green1.gear, 4000}})
   321 	table.insert(dialog03, {func = AnimWait, args = {green1.gear, 4000}})
   278 	table.insert(dialog03, {func = AnimSay, args = {green1.gear, loc("This Hog Solo is so naive! I am gonna shout him when he returns and keep his device for me!"), SAY_THINK, 4000}})
   322 	table.insert(dialog03, {func = AnimSay, args = {green1.gear, loc("This Hog Solo is so naive! I am gonna shoot him when he returns and keep his device for me!"), SAY_THINK, 4000}})
   279 	table.insert(dialog03, {func = AnimSwitchHog, args = {hero.gear}})
   323 	table.insert(dialog03, {func = goToThesurface, args = {hero.gear}})
       
   324 	-- DIALOG04 - At crates, hero learns about the assasins ambush
       
   325 	AddSkipFunction(dialog04, Skipanim, {dialog04})
       
   326 	table.insert(dialog04, {func = AnimWait, args = {hero.gear, 4000}})
       
   327 	table.insert(dialog04, {func = FollowGear, args = {hero.gear}})
       
   328 	table.insert(dialog04, {func = AnimSay, args = {hero.gear, loc("Hoo Ray! I've found it, now I have to get back to Captain Lime!"), SAY_SAY, 4000}})
       
   329 	table.insert(dialog04, {func = AnimWait, args = {redHedgehogs[1].gear, 4000}})
       
   330 	table.insert(dialog04, {func = AnimSay, args = {redHedgehogs[1].gear, loc("We have spotted the enemy! We'll attack when the enemies start gathering!"), SAY_THINK, 4000}})
       
   331 	table.insert(dialog04, {func = goToThesurface, args = {hero.gear}})
   280 end
   332 end
   281 
   333 
   282 ------------- OTHER FUNCTIONS ---------------
   334 ------------- OTHER FUNCTIONS ---------------
   283 
   335 
       
   336 function goToThesurface()
       
   337 	TurnTimeLeft = 0
       
   338 end