share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua
changeset 12572 5358c4f23643
parent 12538 952afc3d2df2
child 12573 a778c1bb032e
equal deleted inserted replaced
12571:903a30fb49e6 12572:5358c4f23643
    64 	{ name = loc("Dark Strawberry") },
    64 	{ name = loc("Dark Strawberry") },
    65 	{ name = loc("Watermelon Heart") },
    65 	{ name = loc("Watermelon Heart") },
    66 	{ name = loc("Deadly Grape") }
    66 	{ name = loc("Deadly Grape") }
    67 }
    67 }
    68 teamA.name = loc("Hog Solo and GB")
    68 teamA.name = loc("Hog Solo and GB")
    69 teamA.color = tonumber("38D61C",16) -- green
    69 teamA.color = 0x38D61C -- green
    70 teamB.name = loc("Captain Lime")
    70 teamB.name = loc("Captain Lime")
    71 teamB.color = tonumber("38D61D",16) -- greenish
    71 teamB.color = 0x38D61D -- greenish
    72 teamC.name = loc("Fruit Assassins")
    72 teamC.name = loc("Fruit Assassins")
    73 teamC.color = tonumber("FF0000",16) -- red
    73 teamC.color = 0xFF0000 -- red
    74 
    74 
    75 function onGameInit()
    75 function onGameInit()
    76 	GameFlags = gfDisableWind
    76 	GameFlags = gfDisableWind
    77 	Seed = 1
    77 	Seed = 1
    78 	TurnTime = 20000
    78 	TurnTime = 20000
   100 	green3.gear = AddHog(green3.name, 0, 100, "hair_red")
   100 	green3.gear = AddHog(green3.name, 0, 100, "hair_red")
   101 	AnimSetGearPosition(green3.gear, green3.x, green3.y)
   101 	AnimSetGearPosition(green3.gear, green3.x, green3.y)
   102 	HogTurnLeft(green3.gear, true)
   102 	HogTurnLeft(green3.gear, true)
   103 	-- Captain Lime
   103 	-- Captain Lime
   104 	AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "congo-brazzaville")
   104 	AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "congo-brazzaville")
   105 	green1.human = AddHog(green1.name, 0, 100, "war_desertofficer")
   105 	green1.gear= AddHog(green1.name, 0, 100, "war_desertofficer")
   106 	AnimSetGearPosition(green1.human, green1.x, green1.y)
   106 	AnimSetGearPosition(green1.gear, green1.x, green1.y)
   107 	green1.bot = AddHog(green1.name, 1, 100, "war_desertofficer")
       
   108 	AnimSetGearPosition(green1.bot, green1.x, green1.y)
       
   109 	green1.gear = green1.human
       
   110 	-- Fruit Assassins
   107 	-- Fruit Assassins
   111 	local assasinsHats = { "NinjaFull", "NinjaStraight", "NinjaTriangle" }
   108 	local assasinsHats = { "NinjaFull", "NinjaStraight", "NinjaTriangle" }
   112 	AddTeam(teamC.name, teamC.color, "Bone", "Island", "HillBilly", "cm_scout")
   109 	AddTeam(teamC.name, teamC.color, "Bone", "Island", "HillBilly", "cm_scout")
   113 	for i=1,table.getn(redHedgehogs) do
   110 	for i=1,table.getn(redHedgehogs) do
   114 		redHedgehogs[i].gear =  AddHog(redHedgehogs[i].name, 1, 100, assasinsHats[GetRandom(3)+1])
   111 		redHedgehogs[i].gear =  AddHog(redHedgehogs[i].name, 1, 100, assasinsHats[GetRandom(3)+1])
   130 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
   127 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
   131 	AddEvent(onDeviceCrates, {hero.gear}, deviceCrateEvent, {hero.gear}, 0)
   128 	AddEvent(onDeviceCrates, {hero.gear}, deviceCrateEvent, {hero.gear}, 0)
   132 
   129 
   133 	-- Hog Solo and GB weapons
   130 	-- Hog Solo and GB weapons
   134 	AddAmmo(hero.gear, amSwitch, 100)
   131 	AddAmmo(hero.gear, amSwitch, 100)
   135 	-- Captain Lime weapons
       
   136 	AddAmmo(green1.bot, amBazooka, 6)
       
   137 	AddAmmo(green1.bot, amGrenade, 6)
       
   138 	AddAmmo(green1.bot, amDEagle, 2)
       
   139 	HideHog(green1.bot)
       
   140 	-- Assassins weapons
   132 	-- Assassins weapons
   141 	AddAmmo(redHedgehogs[1].gear, amBazooka, 6)
   133 	AddAmmo(redHedgehogs[1].gear, amBazooka, 6)
   142 	AddAmmo(redHedgehogs[1].gear, amGrenade, 6)
   134 	AddAmmo(redHedgehogs[1].gear, amGrenade, 6)
   143 	AddAmmo(redHedgehogs[1].bot, amDEagle, 6)
   135 	AddAmmo(redHedgehogs[1].bot, amDEagle, 6)
   144 	for i=1,table.getn(redHedgehogs) do
   136 	for i=1,table.getn(redHedgehogs) do
   250 end
   242 end
   251 
   243 
   252 function onGearDelete(gear)
   244 function onGearDelete(gear)
   253 	if gear == hero.gear then
   245 	if gear == hero.gear then
   254 		hero.dead = true
   246 		hero.dead = true
   255 	elseif gear == green1.bot then
   247 	elseif gear == green1.gear then
   256 		green1.dead = true
   248 		green1.dead = true
   257 	elseif gear == deviceCrate.gear then
   249 	elseif gear == deviceCrate.gear then
   258 		if band(GetGearMessage(gear), gmDestroy) ~= 0 then
   250 		if band(GetGearMessage(gear), gmDestroy) ~= 0 then
   259 			PlaySound(sndShotgunReload)
   251 			PlaySound(sndShotgunReload)
   260 			AddCaption(loc("Anti-Gravity Device Part (+1)"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpAmmostate)
   252 			AddCaption(loc("Anti-Gravity Device Part (+1)"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpAmmostate)
   342 		SendStat(siGameResult, loc("Hog Solo lost, try again!"))
   334 		SendStat(siGameResult, loc("Hog Solo lost, try again!"))
   343 		SendStat(siCustomAchievement, loc("To win the game, Hog Solo has to get the bottom crates and come back to the surface."))
   335 		SendStat(siCustomAchievement, loc("To win the game, Hog Solo has to get the bottom crates and come back to the surface."))
   344 		SendStat(siCustomAchievement, loc("You can use the other 2 hogs to assist you."))
   336 		SendStat(siCustomAchievement, loc("You can use the other 2 hogs to assist you."))
   345 		SendStat(siCustomAchievement, loc("Do not destroy the crates!"))
   337 		SendStat(siCustomAchievement, loc("Do not destroy the crates!"))
   346 		if tookPartInBattle then
   338 		if tookPartInBattle then
   347 			SendStat(siCustomAchievement, loc("You'll have to eliminate the Strawberry Assassins at the end."))
   339 			SendStat(siCustomAchievement, loc("You'll have to eliminate the Fruit Assassins at the end."))
   348 			if permitCaptainLimeDeath then
   340 			if permitCaptainLimeDeath then
   349 				sendSimpleTeamRankings({teamC.name, teamA.name})
   341 				sendSimpleTeamRankings({teamC.name, teamA.name})
   350 			else
   342 			else
   351 				sendSimpleTeamRankings({teamA.name})
   343 				sendSimpleTeamRankings({teamA.name})
   352 			end
   344 			end
   365 end
   357 end
   366 
   358 
   367 function deviceCrateEvent(gear)
   359 function deviceCrateEvent(gear)
   368 	SetGearMessage(hero.gear, 0)
   360 	SetGearMessage(hero.gear, 0)
   369 	if not tookPartInBattle then
   361 	if not tookPartInBattle then
       
   362 		-- Captain Lime turns evil
   370 		AddAnim(dialog03)
   363 		AddAnim(dialog03)
   371 	else
   364 	else
       
   365 		-- Fruit Assassins attack
   372 		for i=1,table.getn(redHedgehogs) do
   366 		for i=1,table.getn(redHedgehogs) do
   373 			RestoreHog(redHedgehogs[i].gear)
   367 			RestoreHog(redHedgehogs[i].gear)
   374 		end
   368 		end
   375 		AddAnim(dialog04)
   369 		AddAnim(dialog04)
   376 	end
   370 	end
   386 		if GetHealth(green1.gear) then
   380 		if GetHealth(green1.gear) then
   387 			HideHog(green1.gear)
   381 			HideHog(green1.gear)
   388 		end
   382 		end
   389 		AddEvent(onRedTeamDeath, {green1.gear}, redTeamDeath, {green1.gear}, 0)
   383 		AddEvent(onRedTeamDeath, {green1.gear}, redTeamDeath, {green1.gear}, 0)
   390 	else
   384 	else
   391 		DeleteGear(green1.human)
   385 		SetHogLevel(green1.gear, 1)
   392 		RestoreHog(green1.bot)
   386 		-- Equip Captain Lime with weapons
   393 		green1.gear = green1.bot
   387 		AddAmmo(green1.gear, amBazooka, 6)
       
   388 		AddAmmo(green1.gear, amGrenade, 6)
       
   389 		AddAmmo(green1.gear, amDEagle, 2)
   394 		AddEvent(onGaptainLimeDeath, {green1.gear}, captainLimeDeath, {green1.gear}, 0)
   390 		AddEvent(onGaptainLimeDeath, {green1.gear}, captainLimeDeath, {green1.gear}, 0)
   395 	end
   391 	end
   396 	if GetHealth(green2.gear) then
   392 	if GetHealth(green2.gear) then
   397 		HideHog(green2.gear)
   393 		HideHog(green2.gear)
   398 	end
   394 	end
   415 function redTeamDeath(gear)
   411 function redTeamDeath(gear)
   416 	-- hero win in battle scenario
   412 	-- hero win in battle scenario
   417 	saveCompletedStatus(3)
   413 	saveCompletedStatus(3)
   418 	SendStat(siGameResult, loc("Congratulations, you won!"))
   414 	SendStat(siGameResult, loc("Congratulations, you won!"))
   419 	SendStat(siCustomAchievement, loc("You retrieved the lost part."))
   415 	SendStat(siCustomAchievement, loc("You retrieved the lost part."))
   420 	SendStat(siCustomAchievement, loc("You defended yourself against the Strawberry Assassins."))
   416 	SendStat(siCustomAchievement, loc("You defended yourself against the Fruit Assassins."))
   421 	sendSimpleTeamRankings({teamA.name, teamC.name})
   417 	sendSimpleTeamRankings({teamA.name, teamC.name})
   422 	EndGame()
   418 	EndGame()
   423 end
   419 end
   424 
   420 
   425 -------------- ANIMATIONS ------------------
   421 -------------- ANIMATIONS ------------------
   426 
   422 
   427 function Skipanim(anim)
   423 function Skipanim(anim)
   428 	if goals[anim] ~= nil then
   424 	if goals[anim] ~= nil then
   429 		ShowMission(unpack(goals[anim]))
   425 		ShowMission(unpack(goals[anim]))
   430     end
   426 	end
   431     EndTurn(true)
   427 	if anim == dialog03 then
       
   428 		makeCptLimeEvil()
       
   429 	else
       
   430 		EndTurn(true)
       
   431 	end
   432 end
   432 end
   433 
   433 
   434 function AnimationSetup()
   434 function AnimationSetup()
   435 	-- DIALOG 01 - Start, Captain Lime helps Hog Solo because he took part in the battle
   435 	-- DIALOG 01 - Start, Captain Lime helps Hog Solo because he took part in the battle
   436 	AddSkipFunction(dialog01, Skipanim, {dialog01})
   436 	AddSkipFunction(dialog01, Skipanim, {dialog01})
   440 	table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("So, as promised I have brought you where I think that the device you are looking for is hidden."), SAY_SAY, 7000}})
   440 	table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("So, as promised I have brought you where I think that the device you are looking for is hidden."), SAY_SAY, 7000}})
   441 	table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("I know that your resources are low due to the battle but I'll send two of my best hogs to assist you."), SAY_SAY, 7000}})
   441 	table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("I know that your resources are low due to the battle but I'll send two of my best hogs to assist you."), SAY_SAY, 7000}})
   442 	table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("Good luck!"), SAY_SAY, 2000}})
   442 	table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("Good luck!"), SAY_SAY, 2000}})
   443 	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 500}})
   443 	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 500}})
   444 	table.insert(dialog01, {func = AnimSwitchHog, args = {hero.gear}})
   444 	table.insert(dialog01, {func = AnimSwitchHog, args = {hero.gear}})
       
   445 	table.insert(dialog01, {func = ShowMission, args = goals[dialog01]})
   445 	-- DIALOG02 - Start, Hog Solo escaped from the previous battle
   446 	-- DIALOG02 - Start, Hog Solo escaped from the previous battle
   446 	AddSkipFunction(dialog02, Skipanim, {dialog02})
   447 	AddSkipFunction(dialog02, Skipanim, {dialog02})
   447 	table.insert(dialog02, {func = AnimWait, args = {hero.gear, 3000}})
   448 	table.insert(dialog02, {func = AnimWait, args = {hero.gear, 3000}})
   448 	table.insert(dialog02, {func = AnimCaption, args = {hero.gear, loc("Somewhere else on the planet of fruits Hog Solo gets closer to the device"), 5000}})
   449 	table.insert(dialog02, {func = AnimCaption, args = {hero.gear, loc("Somewhere else on the planet of fruits Hog Solo gets closer to the device"), 5000}})
   449 	table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("You are the one who fled! So, you are alive."), SAY_SAY, 4000}})
   450 	table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("You are the one who fled! So, you are alive."), SAY_SAY, 4000}})
   455 	table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("If you help us you can keep the device if you find it but we'll keep everything else."), SAY_SAY, 7000}})
   456 	table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("If you help us you can keep the device if you find it but we'll keep everything else."), SAY_SAY, 7000}})
   456 	table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("What do you say? Are you in?"), SAY_SAY, 3000}})
   457 	table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("What do you say? Are you in?"), SAY_SAY, 3000}})
   457 	table.insert(dialog02, {func = AnimWait, args = {hero.gear, 1800}})
   458 	table.insert(dialog02, {func = AnimWait, args = {hero.gear, 1800}})
   458 	table.insert(dialog02, {func = AnimSay, args = {hero.gear, loc("Okay then!"), SAY_SAY, 2000}})
   459 	table.insert(dialog02, {func = AnimSay, args = {hero.gear, loc("Okay then!"), SAY_SAY, 2000}})
   459 	table.insert(dialog02, {func = AnimSwitchHog, args = {hero.gear}})
   460 	table.insert(dialog02, {func = AnimSwitchHog, args = {hero.gear}})
       
   461 	table.insert(dialog02, {func = ShowMission, args = goals[dialog02]})
   460 	-- DIALOG03 - At crates, hero learns that Captain Lime is bad
   462 	-- DIALOG03 - At crates, hero learns that Captain Lime is bad
   461 	AddSkipFunction(dialog03, Skipanim, {dialog03})
   463 	AddSkipFunction(dialog03, Skipanim, {dialog03})
   462 	table.insert(dialog03, {func = AnimWait, args = {hero.gear, 1250}})
   464 	table.insert(dialog03, {func = AnimWait, args = {hero.gear, 1250}})
   463 	table.insert(dialog03, {func = FollowGear, args = {hero.gear}})
   465 	table.insert(dialog03, {func = FollowGear, args = {hero.gear}})
   464 	table.insert(dialog03, {func = AnimSay, args = {hero.gear, loc("Hooray! I've found it, now I have to get back to Captain Lime!"), SAY_SAY, 4000}})
   466 	table.insert(dialog03, {func = AnimSay, args = {hero.gear, loc("Hooray! I've found it, now I have to get back to Captain Lime!"), SAY_SAY, 4000}})
   465 	table.insert(dialog03, {func = AnimWait, args = {green1.gear, 4000}})
   467 	table.insert(dialog03, {func = AnimWait, args = {green1.gear, 4000}})
   466 	table.insert(dialog03, {func = AnimSay, args = {green1.gear, loc("This Hog Solo is so naive! When he returns I'll shoot him and keep that device for myself!"), SAY_THINK, 4000}})
   468 	table.insert(dialog03, {func = AnimSay, args = {green1.gear, loc("This Hog Solo is so naive! When he returns I'll shoot him and keep that device for myself!"), SAY_THINK, 4000}})
   467 	table.insert(dialog03, {func = goToThesurface, args = {hero.gear}})
   469 	table.insert(dialog03, {func = ShowMission, args = goals[dialog03]})
       
   470 	table.insert(dialog03, {func = makeCptLimeEvil, args = {hero.gear}})
   468 	-- DIALOG04 - At crates, hero learns about the Assassins ambush
   471 	-- DIALOG04 - At crates, hero learns about the Assassins ambush
   469 	AddSkipFunction(dialog04, Skipanim, {dialog04})
   472 	AddSkipFunction(dialog04, Skipanim, {dialog04})
   470 	table.insert(dialog04, {func = AnimWait, args = {hero.gear, 4000}})
   473 	table.insert(dialog04, {func = AnimWait, args = {hero.gear, 4000}})
   471 	table.insert(dialog04, {func = FollowGear, args = {hero.gear}})
   474 	table.insert(dialog04, {func = FollowGear, args = {hero.gear}})
   472 	table.insert(dialog04, {func = AnimSay, args = {hero.gear, loc("Hooray! I've found it, now I have to get back to Captain Lime!"), SAY_SAY, 4000}})
   475 	table.insert(dialog04, {func = AnimSay, args = {hero.gear, loc("Hooray! I've found it, now I have to get back to Captain Lime!"), SAY_SAY, 4000}})
   473 	table.insert(dialog04, {func = AnimWait, args = {redHedgehogs[1].gear, 4000}})
   476 	table.insert(dialog04, {func = AnimWait, args = {redHedgehogs[1].gear, 4000}})
   474 	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}})
   477 	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}})
       
   478 	table.insert(dialog04, {func = ShowMission, args = goals[dialog04]})
   475 	table.insert(dialog04, {func = goToThesurface, args = {hero.gear}})
   479 	table.insert(dialog04, {func = goToThesurface, args = {hero.gear}})
   476 end
   480 end
   477 
   481 
   478 ------------- OTHER FUNCTIONS ---------------
   482 ------------- OTHER FUNCTIONS ---------------
       
   483 
       
   484 function makeCptLimeEvil()
       
   485 	-- Turn Captain Lime evil
       
   486 	SetHogLevel(green1.gear, 1)
       
   487 	EndTurn(true)
       
   488 end
   479 
   489 
   480 function goToThesurface()
   490 function goToThesurface()
   481 	EndTurn(true)
   491 	EndTurn(true)
   482 end
   492 end
   483 
   493