share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua
branchspacecampaign
changeset 9542 d1ea2d1540f2
parent 9540 92329918463f
child 9544 e247251fa751
equal deleted inserted replaced
9540:92329918463f 9542:d1ea2d1540f2
    10 -- globals
    10 -- globals
    11 local campaignName = loc("A Space Adventure")
    11 local campaignName = loc("A Space Adventure")
    12 local missionName = loc("Fruit planet, Searching the Device!")
    12 local missionName = loc("Fruit planet, Searching the Device!")
    13 local inBattle = false
    13 local inBattle = false
    14 local tookPartInBattle = false
    14 local tookPartInBattle = false
    15 local firstRoundAfterBattle = false
       
    16 local previousHog = -1
    15 local previousHog = -1
    17 -- dialogs
    16 -- dialogs
    18 local dialog01 = {}
    17 local dialog01 = {}
    19 local dialog02 = {}
    18 local dialog02 = {}
    20 local dialog03 = {}
    19 local dialog03 = {}
    24 	[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},
    23 	[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},
    25 	[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},
    24 	[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},
    26 	[dialog03] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack Captain Lime before he attacks back"), 1, 4000},
    25 	[dialog03] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack Captain Lime before he attacks back"), 1, 4000},
    27 	[dialog04] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack the assasins before they attack back"), 1, 4000},
    26 	[dialog04] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack the assasins before they attack back"), 1, 4000},
    28 }
    27 }
    29 -- crates types=[0:ammo,1:utility,2:health]
    28 -- crates
    30 local crates = {
    29 local crates = {
    31 	{type = 0, name = amDEagle, x = 1680, y = 1650},
    30 	{name = amDEagle, x = 1680, y = 1650},
    32 	{type = 0, name = amGirder, x = 1680, y = 1160},
    31 	{name = amGirder, x = 1680, y = 1160},
    33 	{type = 0, name = amRope, x = 1400, y = 1870},
    32 	{name = amRope, x = 1400, y = 1870},
    34 }
    33 }
    35 local weaponCrate = { x = 1360, y = 1870}
    34 local weaponCrate = { x = 1360, y = 1870}
    36 -- hogs
    35 -- hogs
    37 local hero = {}
    36 local hero = {}
    38 local green1 = {}
    37 local green1 = {}
    40 local green3 = {}
    39 local green3 = {}
    41 -- teams
    40 -- teams
    42 local teamA = {}
    41 local teamA = {}
    43 local teamB = {}
    42 local teamB = {}
    44 local teamC = {}
    43 local teamC = {}
    45 local teamD = {}
       
    46 -- hedgehogs values
    44 -- hedgehogs values
    47 hero.name = "Hog Solo"
    45 hero.name = "Hog Solo"
    48 hero.x = 1200
    46 hero.x = 1200
    49 hero.y = 820
    47 hero.y = 820
    50 hero.dead = false
    48 hero.dead = false
   114 end
   112 end
   115 
   113 
   116 function onGameStart()
   114 function onGameStart()
   117 	AnimWait(hero.gear, 3000)
   115 	AnimWait(hero.gear, 3000)
   118 	FollowGear(hero.gear)
   116 	FollowGear(hero.gear)
   119 	WriteLnToConsole("***"..GetCampaignVar("Fruit01JoinedBattle"))
   117 	
   120 	if GetCampaignVar("Fruit01JoinedBattle") and GetCampaignVar("Fruit01JoinedBattle") == "true" then
   118 	if GetCampaignVar("Fruit01JoinedBattle") and GetCampaignVar("Fruit01JoinedBattle") == "true" then
   121 		tookPartInBattle = true
   119 		tookPartInBattle = true
   122 	end
   120 	end
   123 	
   121 	
   124 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
   122 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
   192 	
   190 	
   193 	SendHealthStatsOff()
   191 	SendHealthStatsOff()
   194 end
   192 end
   195 
   193 
   196 function onNewTurn()
   194 function onNewTurn()
   197 	WriteLnToConsole("TURNS "..TotalRounds.." and hog: "..CurrentHedgehog.." PREVIOUS: "..previousHog)
       
   198 	if not inBattle and CurrentHedgehog == green1.gear then
   195 	if not inBattle and CurrentHedgehog == green1.gear then
   199 		WriteLnToConsole("1")
       
   200 		TurnTimeLeft = 0
   196 		TurnTimeLeft = 0
   201 	elseif CurrentHedgehog == green2.gear or CurrentHedgehog == green3.gear then
   197 	elseif CurrentHedgehog == green2.gear or CurrentHedgehog == green3.gear then
   202 			WriteLnToConsole("2")
       
   203 			TurnTimeLeft = 0
   198 			TurnTimeLeft = 0
   204 	elseif inBattle then
   199 	elseif inBattle then
   205 		if CurrentHedgehog == green1.gear and previousHog ~= hero.gear then
   200 		if CurrentHedgehog == green1.gear and previousHog ~= hero.gear then
   206 			WriteLnToConsole("IIIIIIIIFFFFFFFFFF")
       
   207 			TurnTimeLeft = 0
   201 			TurnTimeLeft = 0
   208 			return
   202 			return
   209 		end
   203 		end
   210 		for i=1,table.getn(redHedgehogs) do
   204 		for i=1,table.getn(redHedgehogs) do
   211 			if CurrentHedgehog == redHedgehogs[i].gear and previousHog ~= hero.gear then
   205 			if CurrentHedgehog == redHedgehogs[i].gear and previousHog ~= hero.gear then
   212 				TurnTimeLeft = 0
   206 				TurnTimeLeft = 0
   213 				return
   207 				return
   214 			end
   208 			end
   215 		end
   209 		end
   216 		WriteLnToConsole("IN BATTLE")
       
   217 		TurnTimeLeft = 20000
   210 		TurnTimeLeft = 20000
   218 		wind()
   211 		wind()
   219 	elseif not inBattle and CurrentHedgehog == hero.gear then
   212 	elseif not inBattle and CurrentHedgehog == hero.gear then
   220 	WriteLnToConsole("4")
       
   221 		TurnTimeLeft = -1
   213 		TurnTimeLeft = -1
   222 		wind()
   214 		wind()
   223 	else
   215 	else
   224 		WriteLnToConsole("6")
       
   225 		TurnTimeLeft = 0
   216 		TurnTimeLeft = 0
   226 	end
   217 	end
   227 	previousHog = CurrentHedgehog
   218 	previousHog = CurrentHedgehog
   228 	WriteLnToConsole("5")
       
   229 end
   219 end
   230 
   220 
   231 function onGameTick()
   221 function onGameTick()
   232 	AnimUnWait()
   222 	AnimUnWait()
   233 	if ShowAnimation() == false then
   223 	if ShowAnimation() == false then
   301 end
   291 end
   302 
   292 
   303 -------------- ACTIONS ------------------
   293 -------------- ACTIONS ------------------
   304 
   294 
   305 function heroDeath(gear)
   295 function heroDeath(gear)
       
   296 	SendStat('siGameResult', loc("Hog Solo lost, try again!")) --1
       
   297 	SendStat('siCustomAchievement', loc("To win the game you have to get the bottom crates and come back to the surface")) --11
       
   298 	SendStat('siCustomAchievement', loc("You can use the other 2 hogs to assist you")) --11
       
   299 	if tookPartInBattle then
       
   300 		SendStat('siCustomAchievement', loc("You'll have to eliminate the Strawberry Assasins at the end")) --11
       
   301 	else
       
   302 		SendStat('siCustomAchievement', loc("You'll have to eliminate Captain Lime at the end")) --11	
       
   303 	end
       
   304 	SendStat('siPlayerKills','0',teamA.name)
   306 	EndGame()
   305 	EndGame()
   307 end
   306 end
   308 
   307 
   309 function deviceCrates(gear)
   308 function deviceCrates(gear)
   310 	TurnTimeLeft = 0
   309 	TurnTimeLeft = 0
   319 	AddAmmo(hero.gear, amSwitch, 0)
   318 	AddAmmo(hero.gear, amSwitch, 0)
   320 	AddEvent(onSurface, {hero.gear}, surface, {hero.gear}, 0)
   319 	AddEvent(onSurface, {hero.gear}, surface, {hero.gear}, 0)
   321 end
   320 end
   322 
   321 
   323 function surface(gear)
   322 function surface(gear)
   324 	WriteLnToConsole("surface first round")
       
   325 	previousHog = -1
   323 	previousHog = -1
   326 	if tookPartInBattle then
   324 	if tookPartInBattle then
   327 		if GetHealth(green1.gear) then
   325 		if GetHealth(green1.gear) then
   328 			HideHog(green1.gear)
   326 			HideHog(green1.gear)
   329 		end
   327 		end
   338 		HideHog(green2.gear)
   336 		HideHog(green2.gear)
   339 	end
   337 	end
   340 	if GetHealth(green3.gear) then
   338 	if GetHealth(green3.gear) then
   341 		HideHog(green3.gear)
   339 		HideHog(green3.gear)
   342 	end
   340 	end
   343 	WriteLnToConsole("surface in battle")
       
   344 	inBattle = true
   341 	inBattle = true
   345 end
   342 end
   346 
   343 
   347 function captainLimeDeath(gear)
   344 function captainLimeDeath(gear)
   348 	-- hero win in scenario of escape in 1st part
   345 	-- hero win in scenario of escape in 1st part
       
   346 	SendStat('siGameResult', loc("Congratulations, you won!")) --1
       
   347 	SendStat('siCustomAchievement', loc("You retrieved the lost part")) --11
       
   348 	SendStat('siCustomAchievement', loc("You defended yourself against Captain Lime")) --11
       
   349 	SendStat('siPlayerKills','1',teamA.name)
       
   350 	SendStat('siPlayerKills','0',teamB.name)
   349 	EndGame()
   351 	EndGame()
   350 end
   352 end
   351 
   353 
   352 function redTeamDeath(gear)
   354 function redTeamDeath(gear)
   353 	-- hero win in battle scenario
   355 	-- hero win in battle scenario
       
   356 	SendStat('siGameResult', loc("Congratulations, you won!")) --1
       
   357 	SendStat('siCustomAchievement', loc("You retrieved the lost part")) --11
       
   358 	SendStat('siCustomAchievement', loc("You defended yourself against Strawberry Assasins")) --11
       
   359 	SendStat('siPlayerKills','1',teamA.name)
       
   360 	SendStat('siPlayerKills','0',teamC.name)
   354 	EndGame()
   361 	EndGame()
   355 end
   362 end
   356 
   363 
   357 -------------- ANIMATIONS ------------------
   364 -------------- ANIMATIONS ------------------
   358 
   365 
   413 	TurnTimeLeft = 0
   420 	TurnTimeLeft = 0
   414 end
   421 end
   415 
   422 
   416 function wind()
   423 function wind()
   417 	if GetY(CurrentHedgehog) > 1350 then
   424 	if GetY(CurrentHedgehog) > 1350 then
   418 		WriteLnToConsole("INTO WIND -40")
       
   419 		SetWind(-40)
   425 		SetWind(-40)
   420 	else
   426 	else
   421 		SetWind(math.random(-100,100))
   427 		SetWind(math.random(-100,100))
   422 	end
   428 	end
   423 end
   429 end