share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua
changeset 12588 da2bdc34bb1c
parent 12587 3016c64b5a7f
child 12589 46a10d3fa619
equal deleted inserted replaced
12587:3016c64b5a7f 12588:da2bdc34bb1c
    17 -- dialogs
    17 -- dialogs
    18 local dialog01 = {}
    18 local dialog01 = {}
    19 local dialog02 = {}
    19 local dialog02 = {}
    20 local dialog03 = {}
    20 local dialog03 = {}
    21 local dialog04 = {}
    21 local dialog04 = {}
       
    22 local dialog05 = {}
    22 -- mission objectives
    23 -- mission objectives
    23 local minesTimeText = loc("Mines time: 0 seconds")
    24 local minesTimeText = loc("Mines time: 0 seconds")
    24 local goals = {
    25 local goals = {
    25 	[dialog01] = {missionName, loc("Exploring the tunnel"), loc("Search for the device with the help of the other hedgehogs ").."|"..loc("Hog Solo has to reach the last crates") .. "|" .. minesTimeText, 1, 4000},
    26 	[dialog01] = {missionName, loc("Exploring the tunnel"), loc("Search for the device with the help of the other hedgehogs ").."|"..loc("Hog Solo has to reach the last crates") .. "|" .. minesTimeText, 1, 4000},
    26 	[dialog02] = {missionName, loc("Exploring the tunnel"), loc("Explore the tunnel with the other hedgehogs and search for the device").."|"..loc("Hog Solo has to reach the last crates") .. "|" .. minesTimeText, 1, 4000},
    27 	[dialog02] = {missionName, loc("Exploring the tunnel"), loc("Explore the tunnel with the other hedgehogs and search for the device").."|"..loc("Hog Solo has to reach the last crates") .. "|" .. minesTimeText, 1, 4000},
   250 	elseif gear == deviceCrate.gear then
   251 	elseif gear == deviceCrate.gear then
   251 		if band(GetGearMessage(gear), gmDestroy) ~= 0 then
   252 		if band(GetGearMessage(gear), gmDestroy) ~= 0 then
   252 			PlaySound(sndShotgunReload)
   253 			PlaySound(sndShotgunReload)
   253 			AddCaption(loc("Anti-Gravity Device Part (+1)"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpAmmostate)
   254 			AddCaption(loc("Anti-Gravity Device Part (+1)"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpAmmostate)
   254 			deviceCrate.collected = true
   255 			deviceCrate.collected = true
       
   256 			if deviceCrate.collector == nil then
       
   257 				deviceCrate.collector = CurrentHedgehog
       
   258 				if deviceCrate.collector == nil then
       
   259 				AddCaption("XXXXX", 0xFF0000FF, capgrpMessage2)
       
   260 				end
       
   261 			end
   255 			-- Spawn rope crate
   262 			-- Spawn rope crate
   256 			SpawnUtilityCrate(ropeCrate.x, ropeCrate.y, ropeCrate.name)
   263 			SpawnUtilityCrate(ropeCrate.x, ropeCrate.y, ropeCrate.name)
   257 		end
   264 		end
   258 	end
   265 	end
   259 end
   266 end
   355 		EndGame()
   362 		EndGame()
   356 		ended = true
   363 		ended = true
   357 	end
   364 	end
   358 end
   365 end
   359 
   366 
       
   367 -- Device crate got taken
   360 function deviceCrateEvent(gear)
   368 function deviceCrateEvent(gear)
   361 	SetGearMessage(hero.gear, 0)
   369 	-- Stop hedgehog
   362 	if not tookPartInBattle then
   370 	SetGearMessage(deviceCrate.collector, 0)
   363 		-- Captain Lime turns evil
   371 	if deviceCrate.collector == hero.gear then
   364 		AddAnim(dialog03)
   372 		-- Hog Solo collected the device crate
   365 	else
   373 
   366 		-- Fruit Assassins attack
   374 		if not tookPartInBattle then
   367 		for i=1,table.getn(redHedgehogs) do
   375 			-- Captain Lime turns evil
   368 			RestoreHog(redHedgehogs[i].gear)
   376 			AddAnim(dialog03)
   369 		end
   377 		else
   370 		AddAnim(dialog04)
   378 			-- Fruit Assassins attack
   371 	end
   379 			for i=1,table.getn(redHedgehogs) do
   372 	-- needs to be set to true for both plots
   380 				RestoreHog(redHedgehogs[i].gear)
   373 	permitCaptainLimeDeath = true
   381 			end
   374 	AddAmmo(hero.gear, amSwitch, 0)
   382 			AddAnim(dialog04)
   375 	AddEvent(onSurface, {hero.gear}, surface, {hero.gear}, 0)
   383 		end
       
   384 		-- needs to be set to true for both plots
       
   385 		permitCaptainLimeDeath = true
       
   386 		AddAmmo(hero.gear, amSwitch, 0)
       
   387 		AddEvent(onSurface, {hero.gear}, surface, {hero.gear}, 0)
       
   388 	else
       
   389 		-- Player let the Green Bananas collect the crate.
       
   390 		-- How dumb!
       
   391 		-- Player will lose for this.
       
   392 		AnimationSetup05(deviceCrate.collector)
       
   393 		AddAnim(dialog05)
       
   394 	end
   376 end
   395 end
   377 
   396 
   378 function surface(gear)
   397 function surface(gear)
   379 	previousHog = -1
   398 	previousHog = -1
   380 	if tookPartInBattle then
   399 	if tookPartInBattle then
   381 		if GetHealth(green1.gear) then
   400 		escapeHog(green1.gear)
   382 			HideHog(green1.gear)
       
   383 		end
       
   384 		AddEvent(onRedTeamDeath, {green1.gear}, redTeamDeath, {green1.gear}, 0)
   401 		AddEvent(onRedTeamDeath, {green1.gear}, redTeamDeath, {green1.gear}, 0)
   385 	else
   402 	else
   386 		SetHogLevel(green1.gear, 1)
   403 		SetHogLevel(green1.gear, 1)
   387 		-- Equip Captain Lime with weapons
   404 		-- Equip Captain Lime with weapons
   388 		AddAmmo(green1.gear, amBazooka, 6)
   405 		AddAmmo(green1.gear, amBazooka, 6)
   389 		AddAmmo(green1.gear, amGrenade, 6)
   406 		AddAmmo(green1.gear, amGrenade, 6)
   390 		AddAmmo(green1.gear, amDEagle, 2)
   407 		AddAmmo(green1.gear, amDEagle, 2)
   391 		AddEvent(onGaptainLimeDeath, {green1.gear}, captainLimeDeath, {green1.gear}, 0)
   408 		AddEvent(onGaptainLimeDeath, {green1.gear}, captainLimeDeath, {green1.gear}, 0)
   392 	end
   409 	end
   393 	EndTurn(true)
   410 	EndTurn(true)
   394 	if GetHealth(green2.gear) then
   411 	escapeHog(green2.gear)
   395 		HideHog(green2.gear)
   412 	escapeHog(green3.gear)
   396 	end
       
   397 	if GetHealth(green3.gear) then
       
   398 		HideHog(green3.gear)
       
   399 	end
       
   400 	inBattle = true
   413 	inBattle = true
   401 end
   414 end
   402 
   415 
   403 function captainLimeDeath(gear)
   416 function captainLimeDeath(gear)
   404 	-- hero win in scenario of escape in 1st part
   417 	-- hero win in scenario of escape in 1st part
   426 	if goals[anim] ~= nil then
   439 	if goals[anim] ~= nil then
   427 		ShowMission(unpack(goals[anim]))
   440 		ShowMission(unpack(goals[anim]))
   428 	end
   441 	end
   429 	if anim == dialog03 then
   442 	if anim == dialog03 then
   430 		makeCptLimeEvil()
   443 		makeCptLimeEvil()
       
   444 	elseif anim == dialog05 then
       
   445 		heroIsAStupidFool()
   431 	else
   446 	else
   432 		EndTurn(true)
   447 		EndTurn(true)
   433 	end
   448 	end
   434 end
   449 end
   435 
   450 
   461 	table.insert(dialog02, {func = AnimSay, args = {hero.gear, loc("Okay then!"), SAY_SAY, 2000}})
   476 	table.insert(dialog02, {func = AnimSay, args = {hero.gear, loc("Okay then!"), SAY_SAY, 2000}})
   462 	table.insert(dialog02, {func = AnimSwitchHog, args = {hero.gear}})
   477 	table.insert(dialog02, {func = AnimSwitchHog, args = {hero.gear}})
   463 	table.insert(dialog02, {func = ShowMission, args = goals[dialog02]})
   478 	table.insert(dialog02, {func = ShowMission, args = goals[dialog02]})
   464 	-- DIALOG03 - At crates, hero learns that Captain Lime is bad
   479 	-- DIALOG03 - At crates, hero learns that Captain Lime is bad
   465 	AddSkipFunction(dialog03, Skipanim, {dialog03})
   480 	AddSkipFunction(dialog03, Skipanim, {dialog03})
   466 	table.insert(dialog03, {func = AnimWait, args = {hero.gear, 1250}})
   481 	table.insert(dialog03, {func = AnimWait, args = {hero.gear, 2000}})
   467 	table.insert(dialog03, {func = FollowGear, args = {hero.gear}})
   482 	table.insert(dialog03, {func = FollowGear, args = {hero.gear}})
   468 	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}})
   483 	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}})
   469 	table.insert(dialog03, {func = AnimWait, args = {green1.gear, 4000}})
   484 	table.insert(dialog03, {func = AnimWait, args = {green1.gear, 4000}})
   470 	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}})
   485 	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}})
   471 	table.insert(dialog03, {func = ShowMission, args = goals[dialog03]})
   486 	table.insert(dialog03, {func = ShowMission, args = goals[dialog03]})
   472 	table.insert(dialog03, {func = makeCptLimeEvil, args = {hero.gear}})
   487 	table.insert(dialog03, {func = makeCptLimeEvil, args = {hero.gear}})
   473 	-- DIALOG04 - At crates, hero learns about the Assassins ambush
   488 	-- DIALOG04 - At crates, hero learns about the Assassins ambush
   474 	AddSkipFunction(dialog04, Skipanim, {dialog04})
   489 	AddSkipFunction(dialog04, Skipanim, {dialog04})
   475 	table.insert(dialog04, {func = AnimWait, args = {hero.gear, 4000}})
   490 	table.insert(dialog04, {func = AnimWait, args = {hero.gear, 2000}})
   476 	table.insert(dialog04, {func = FollowGear, args = {hero.gear}})
   491 	table.insert(dialog04, {func = FollowGear, args = {hero.gear}})
   477 	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}})
   492 	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}})
   478 	table.insert(dialog04, {func = AnimWait, args = {redHedgehogs[1].gear, 4000}})
   493 	table.insert(dialog04, {func = AnimWait, args = {redHedgehogs[1].gear, 4000}})
   479 	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}})
   494 	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}})
   480 	table.insert(dialog04, {func = ShowMission, args = goals[dialog04]})
   495 	table.insert(dialog04, {func = ShowMission, args = goals[dialog04]})
   481 	table.insert(dialog04, {func = goToThesurface, args = {hero.gear}})
   496 	table.insert(dialog04, {func = goToThesurface, args = {hero.gear}})
   482 end
   497 end
   483 
   498 
       
   499 function AnimationSetup05(collector)
       
   500 	-- DIALOG05 - A member or the green bananas collected the target crate and steals it. Player loses
       
   501 	AddSkipFunction(dialog05, Skipanim, {dialog05})
       
   502 	table.insert(dialog05, {func = AnimWait, args = {collector, 2000}})
       
   503 	table.insert(dialog05, {func = FollowGear, args = {collector}})
       
   504 	table.insert(dialog05, {func = AnimSay, args = {collector, loc("Oh yes! I got the device part! Now it belongs to me alone."), SAY_SAY, 4000}})
       
   505 	table.insert(dialog05, {func = AnimWait, args = {collector, 3000}})
       
   506 	table.insert(dialog05, {func = AnimSay, args = {hero.gear, loc("Hey! I was supposed to collect it!"), SAY_SHOUT, 3000}})
       
   507 	table.insert(dialog05, {func = AnimWait, args = {hero.gear, 3000}})
       
   508 	table.insert(dialog05, {func = AnimSay, args = {collector, loc("I don't care. It's worth a fortune! Good bye, you idiot!"), SAY_SAY, 5000}})
       
   509 	table.insert(dialog05, {func = heroIsAStupidFool, args = {collector}})
       
   510 
       
   511 end
       
   512 
   484 ------------- OTHER FUNCTIONS ---------------
   513 ------------- OTHER FUNCTIONS ---------------
       
   514 
       
   515 -- Hide hog and create a simple escaping effect, if hog exists.
       
   516 -- No-op is hog does not exist
       
   517 function escapeHog(gear)
       
   518 	if GetHealth(gear) then
       
   519 		AddVisualGear(GetX(gear), GetY(gear), vgtSmokeWhite, 0, false)
       
   520 		for i=1, 4 do
       
   521 			AddVisualGear(GetX(gear)-16+math.random(32), GetY(gear)-16+math.random(32), vgtSmokeWhite, 0, false)
       
   522 		end
       
   523 		HideHog(gear)
       
   524 	end
       
   525 end
   485 
   526 
   486 function makeCptLimeEvil()
   527 function makeCptLimeEvil()
   487 	-- Turn Captain Lime evil
   528 	-- Turn Captain Lime evil
   488 	SetHogLevel(green1.gear, 1)
   529 	SetHogLevel(green1.gear, 1)
   489 	EndTurn(true)
   530 	EndTurn(true)
   491 
   532 
   492 function goToThesurface()
   533 function goToThesurface()
   493 	EndTurn(true)
   534 	EndTurn(true)
   494 end
   535 end
   495 
   536 
       
   537 -- Player let wrong hog collect crate
       
   538 function heroIsAStupidFool()
       
   539 	if not ended then
       
   540 		escapeHog(deviceCrate.collector)
       
   541 		AddCaption(loc("The device part has been stolen!"))
       
   542 		sendSimpleTeamRankings({teamA.name})
       
   543 		SendStat(siGameResult, loc("Hog Solo lost, try again!"))
       
   544 		SendStat(siCustomAchievement, loc("Oh no, the Green Bananas have betrayed Hog Solo and stole the anti-gravity device part!"))
       
   545 		SendStat(siCustomAchievement, loc("Only Hog Solo can be trusted with the crate."))
       
   546 		EndGame()
       
   547 		ended = true
       
   548 	end
       
   549 end
       
   550 
   496 function wind()
   551 function wind()
   497 	SetWind(GetRandom(201)-100)
   552 	SetWind(GetRandom(201)-100)
   498 end
   553 end
   499 
   554