share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua
branchspacecampaign
changeset 9527 676fc574ff42
child 9529 e95aab9130d8
equal deleted inserted replaced
9525:8bcfb3a9f92b 9527:676fc574ff42
       
     1 ------------------- ABOUT ----------------------
       
     2 --
       
     3 -- In this adventure hero gets the lost part with
       
     4 -- the help of the green bananas hogs.
       
     5 
       
     6 HedgewarsScriptLoad("/Scripts/Locale.lua")
       
     7 HedgewarsScriptLoad("/Scripts/Animate.lua")
       
     8 
       
     9 ----------------- VARIABLES --------------------
       
    10 -- globals
       
    11 local campaignName = loc("A Space Adventure")
       
    12 local missionName = loc("Fruit planet, Searching the Part!")
       
    13 local inBattle = false
       
    14 -- dialogs
       
    15 local dialog01 = {}
       
    16 local dialog02 = {}
       
    17 local dialog03 = {}
       
    18 -- mission objectives
       
    19 local goals = {
       
    20 	[dialog01] = {missionName, loc("Ready for Battle?"), loc("Walk left if you want to join Captain Lime or right if you want to decline his offer"), 1, 4000},
       
    21 	[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},
       
    22 	[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},
       
    23 }
       
    24 -- crates types=[0:ammo,1:utility,2:health]
       
    25 local crates = {
       
    26 	{type = 0, name = amDEagle, x = 1680, y = 1650},
       
    27 	{type = 0, name = amGirder, x = 1680, y = 1160},
       
    28 	{type = 0, name = amWatermelon, x = 1360, y = 1870},
       
    29 	{type = 0, name = amRope, x = 1400, y = 1870},
       
    30 }
       
    31 -- hogs
       
    32 local hero = {}
       
    33 local green1 = {}
       
    34 local green2 = {}
       
    35 local green3 = {}
       
    36 -- teams
       
    37 local teamA = {}
       
    38 local teamB = {}
       
    39 local teamC = {}
       
    40 local teamD = {}
       
    41 -- hedgehogs values
       
    42 hero.name = "Hog Solo"
       
    43 hero.x = 1200
       
    44 hero.y = 820
       
    45 hero.dead = false
       
    46 green1.name = "Captain Lime"
       
    47 green1.x = 1050
       
    48 green1.y = 820
       
    49 green2.name = "Mister Pear"
       
    50 green2.x = 1350
       
    51 green2.y = 820
       
    52 green3.name = "Lady Mango"
       
    53 green3.x = 1450
       
    54 green3.y = 820
       
    55 local redHedgehogs = {
       
    56 	{ name = "Poisonous Apple" },
       
    57 	{ name = "Dark Strawberry" },
       
    58 	{ name = "Watermelon Heart" },
       
    59 	{ name = "Deadly Grape" }
       
    60 }
       
    61 teamA.name = loc("Hog Solo and GB")
       
    62 teamA.color = tonumber("38D61C",16) -- green
       
    63 teamB.name = loc("Captain Lime")
       
    64 teamB.color = tonumber("38D61C",16) -- green
       
    65 teamC.name = loc("Fruit Assasins")
       
    66 teamC.color = tonumber("FF0000",16) -- red
       
    67 
       
    68 function onGameInit()
       
    69 	Seed = 1
       
    70 	TurnTime = 20000
       
    71 	CaseFreq = 0
       
    72 	MinesNum = 0
       
    73 	MinesTime = 1
       
    74 	Explosives = 0
       
    75 	Delay = 3
       
    76 	SuddenDeathTurns = 100
       
    77 	HealthCaseAmount = 50
       
    78 	Map = "fruit02_map"
       
    79 	Theme = "Fruit"
       
    80 	
       
    81 	-- Hog Solo and Green Bananas
       
    82 	AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy")
       
    83 	hero.gear = AddHog(hero.name, 0, 100, "war_desertgrenadier1")
       
    84 	AnimSetGearPosition(hero.gear, hero.x, hero.y)
       
    85 	HogTurnLeft(hero.gear, true)	
       
    86 	green2.gear = AddHog(green2.name, 0, 100, "war_desertgrenadier1")
       
    87 	AnimSetGearPosition(green2.gear, green2.x, green2.y)
       
    88 	HogTurnLeft(green2.gear, true)
       
    89 	green3.gear = AddHog(green3.name, 0, 100, "war_desertgrenadier1")
       
    90 	AnimSetGearPosition(green3.gear, green3.x, green3.y)
       
    91 	HogTurnLeft(green3.gear, true)
       
    92 	-- Captain Lime
       
    93 	AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "cm_birdy")
       
    94 	green1.gear =  AddHog(green1.name, 0, 100, "war_desertgrenadier1")
       
    95 	AnimSetGearPosition(green1.gear, green1.x, green1.y)
       
    96 	-- Fruit Assasins
       
    97 	AddTeam(teamC.name, teamC.color, "Bone", "Island", "HillBilly", "cm_birdy")
       
    98 	for i=1,table.getn(redHedgehogs) do
       
    99 		redHedgehogs[i].gear =  AddHog(redHedgehogs[i].name, 0, 100, "war_desertgrenadier1")
       
   100 		AnimSetGearPosition(redHedgehogs[i].gear, 2010 + 50*i, 630)
       
   101 	end
       
   102 
       
   103 	AnimInit()
       
   104 	--AnimationSetup()	
       
   105 end
       
   106 
       
   107 function onGameStart()
       
   108 	AnimWait(hero.gear, 3000)
       
   109 	FollowGear(hero.gear)
       
   110 	
       
   111 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
       
   112 	
       
   113 	-- Hog Solo and GB weapons
       
   114 	AddAmmo(hero.gear, amFirePunch, 3)
       
   115 	AddAmmo(hero.gear, amSwitch, 100)
       
   116 	-- Assasins weapons
       
   117 	AddAmmo(redHedgehogs[1].gear, amBazooka, 6)
       
   118 	AddAmmo(redHedgehogs[1].gear, amGrenade, 6)
       
   119 	for i=1,table.getn(redHedgehogs) do
       
   120 		HideHog(redHedgehogs[i].gear)
       
   121 	end
       
   122 	
       
   123 	-- place crates
       
   124 	for i=1,table.getn(crates) do
       
   125 		SpawnAmmoCrate(crates[i].x, crates[i].y, crates[i].name)
       
   126 	end
       
   127 	
       
   128 	-- explosives
       
   129 	-- I wanted to use FindPlace but doesn't accept height values...
       
   130 	local x1 = 950
       
   131 	local x2 = 1305
       
   132 	local y1 = 1210
       
   133 	local y2 = 1620
       
   134 	while true do
       
   135 		if y2<y1 then
       
   136 			break
       
   137 		end
       
   138 		if x2<x1 then
       
   139 			x2 = 1305
       
   140 			y2 = y2 -60
       
   141 		end
       
   142 		if not TestRectForObstacle(x2+25, y2+25, x2-25, y2-25, true) then
       
   143 			AddGear(x2, y2, gtExplosives, 0, 0, 0, 0)
       
   144 		end
       
   145 		x2 = x2 - 30
       
   146 	end
       
   147 	AddGear(3128, 1680, gtExplosives, 0, 0, 0, 0)
       
   148 	--mines
       
   149 	AddGear(3135, 1680, gtMine, 0, 0, 0, 0)
       
   150 	AddGear(3145, 1680, gtMine, 0, 0, 0, 0)
       
   151 	AddGear(3155, 1680, gtMine, 0, 0, 0, 0)
       
   152 	AddGear(3165, 1680, gtMine, 0, 0, 0, 0)
       
   153 	AddGear(3175, 1680, gtMine, 0, 0, 0, 0)
       
   154 	AddGear(3115, 1680, gtMine, 0, 0, 0, 0)
       
   155 	AddGear(3105, 1680, gtMine, 0, 0, 0, 0)
       
   156 	AddGear(3095, 1680, gtMine, 0, 0, 0, 0)
       
   157 	AddGear(3085, 1680, gtMine, 0, 0, 0, 0)
       
   158 	AddGear(3075, 1680, gtMine, 0, 0, 0, 0)
       
   159 	
       
   160 	--AddAnim(dialog01)
       
   161 	SendHealthStatsOff()
       
   162 end
       
   163 
       
   164 function onNewTurn()
       
   165 	if CurrentHedgehog == green1.gear then
       
   166 		TurnTimeLeft = 0
       
   167 	elseif not inBattle then
       
   168 		TurnTimeLeft = -1
       
   169 	end
       
   170 end
       
   171 
       
   172 function onGameTick()
       
   173 	AnimUnWait()
       
   174 	if ShowAnimation() == false then
       
   175 		return
       
   176 	end
       
   177 	ExecuteAfterAnimations()
       
   178 	CheckEvents()
       
   179 end
       
   180 
       
   181 function onGearDelete(gear)
       
   182 	if gear == hero.gear then
       
   183 		hero.dead = true
       
   184 	end
       
   185 end
       
   186 
       
   187 function onAmmoStoreInit()
       
   188 	SetAmmo(amDEagle, 0, 0, 0, 6)
       
   189 	SetAmmo(amGirder, 0, 0, 0, 3)
       
   190 	SetAmmo(amRope, 0, 0, 0, 1)
       
   191 	SetAmmo(amWatermelon, 0, 0, 0, 1)
       
   192 end
       
   193 
       
   194 function onPrecise()
       
   195 	if GameTime > 3000 then
       
   196 		SetAnimSkip(true)   
       
   197 	end
       
   198 end
       
   199 
       
   200 -------------- EVENTS ------------------
       
   201 
       
   202 function onHeroDeath(gear)
       
   203 	if hero.dead then
       
   204 		return true
       
   205 	end
       
   206 	return false
       
   207 end
       
   208 
       
   209 -------------- ACTIONS ------------------
       
   210 
       
   211 function heroDeath(gear)
       
   212 	EndGame()
       
   213 end
       
   214 
       
   215 -------------- ANIMATIONS ------------------
       
   216 
       
   217 function Skipanim(anim)
       
   218 	if goals[anim] ~= nil then
       
   219 		ShowMission(unpack(goals[anim]))
       
   220     end
       
   221 end
       
   222 
       
   223 function AnimationSetup()
       
   224 	-- DIALOG 01 - Start, Captain Lime talks explains to Hog Solo
       
   225 	AddSkipFunction(dialog01, Skipanim, {dialog01})
       
   226 	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 3000}})
       
   227 	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("Somewhere in the planet of fruits a terrible war is about to begin..."), 5000}})
       
   228 	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("I was told that as the leader of the king's guard, no one knows this world better than you!"), SAY_SAY, 5000}})
       
   229 	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("So, I kindly ask for your help."), SAY_SAY, 3000}})
       
   230 	table.insert(dialog01, {func = AnimWait, args = {green1.gear, 2000}})
       
   231 	table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("You couldn't have come to a worse time Hog Solo!"), SAY_SAY, 3000}})
       
   232 	table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("The clan of the Red Strawberry wants to take over the dominion and overthrone king Pineapple."), SAY_SAY, 5000}})
       
   233 	table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("Under normal circumstances we could easily defeat them but we have kindly sent most of our men to the kingdom of sand to help to the annual dusting of the king's palace."), SAY_SAY, 8000}})
       
   234 	table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("However the army of Yellow Watermelons is about to attack any moment now."), SAY_SAY, 4000}})
       
   235 	table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("I would gladly help you if we won this battle but under these circumstances I'll only help you if you fight for our side."), SAY_SAY, 6000}})
       
   236 	table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("What do you say? Will you fight for us?"), SAY_SAY, 3000}})
       
   237 	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 500}})
       
   238 	table.insert(dialog01, {func = ShowMission, args = {missionName, loc("Ready for Battle?"), loc("Walk left if you want to join Captain Lime or right if you want to decline his offer"), 1, 7000}})
       
   239 	table.insert(dialog01, {func = AnimSwitchHog, args = {hero.gear}})
       
   240 end
       
   241 
       
   242 ------------- OTHER FUNCTIONS ---------------
       
   243