share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua
author Periklis Ntanasis <pntanasis@gmail.com>
Wed, 21 Aug 2013 02:06:31 +0300
branchspacecampaign
changeset 9552 90d69a2c1729
parent 9550 59061246a25c
child 9554 054eede3b718
permissions -rw-r--r--
checkpoint system seems complete
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     1
------------------- ABOUT ----------------------
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     2
--
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     3
-- In this adventure hero gets the lost part with
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     4
-- the help of the green bananas hogs.
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     5
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     6
HedgewarsScriptLoad("/Scripts/Locale.lua")
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     7
HedgewarsScriptLoad("/Scripts/Animate.lua")
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     8
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     9
----------------- VARIABLES --------------------
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    10
-- globals
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    11
local campaignName = loc("A Space Adventure")
9529
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
    12
local missionName = loc("Fruit planet, Searching the Device!")
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    13
local inBattle = false
9529
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
    14
local tookPartInBattle = false
9536
7456b28a3421 this seems to work fine for the escape scenario
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9534
diff changeset
    15
local previousHog = -1
9548
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
    16
local checkPointReached = 1 -- 1 is normal spawn
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    17
-- dialogs
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    18
local dialog01 = {}
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    19
local dialog02 = {}
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    20
local dialog03 = {}
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
    21
local dialog04 = {}
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    22
-- mission objectives
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    23
local goals = {
9529
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
    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},
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
    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},
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
    26
	[dialog03] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack Captain Lime before he attacks back"), 1, 4000},
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
    27
	[dialog04] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack the assasins before they attack back"), 1, 4000},
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    28
}
9542
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
    29
-- crates
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
    30
local eagleCrate = {name = amDEagle, x = 1680, y = 1650}
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
    31
local girderCrate =	{name = amGirder, x = 1680, y = 1160}
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
    32
local ropeCrate = {name = amRope, x = 1400, y = 1870}
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
    33
local weaponCrate = { x = 1360, y = 1870}
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    34
-- hogs
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    35
local hero = {}
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    36
local green1 = {}
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    37
local green2 = {}
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    38
local green3 = {}
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    39
-- teams
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    40
local teamA = {}
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    41
local teamB = {}
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    42
local teamC = {}
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    43
-- hedgehogs values
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    44
hero.name = "Hog Solo"
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    45
hero.x = 1200
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    46
hero.y = 820
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    47
hero.dead = false
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    48
green1.name = "Captain Lime"
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    49
green1.x = 1050
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    50
green1.y = 820
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
    51
green1.dead = false
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    52
green2.name = "Mister Pear"
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    53
green2.x = 1350
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    54
green2.y = 820
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    55
green3.name = "Lady Mango"
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    56
green3.x = 1450
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    57
green3.y = 820
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    58
local redHedgehogs = {
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    59
	{ name = "Poisonous Apple" },
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    60
	{ name = "Dark Strawberry" },
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    61
	{ name = "Watermelon Heart" },
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    62
	{ name = "Deadly Grape" }
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    63
}
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    64
teamA.name = loc("Hog Solo and GB")
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    65
teamA.color = tonumber("38D61C",16) -- green
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    66
teamB.name = loc("Captain Lime")
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
    67
teamB.color = tonumber("38D61D",16) -- greenish
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    68
teamC.name = loc("Fruit Assasins")
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    69
teamC.color = tonumber("FF0000",16) -- red
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    70
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    71
function onGameInit()
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
    72
	GameFlags = gfDisableWind
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    73
	Seed = 1
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    74
	TurnTime = 20000
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    75
	CaseFreq = 0
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    76
	MinesNum = 0
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    77
	MinesTime = 1
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    78
	Explosives = 0
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    79
	Delay = 3
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
    80
	SuddenDeathTurns = 200
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    81
	Map = "fruit02_map"
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    82
	Theme = "Fruit"
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    83
	
9548
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
    84
	WriteLnToConsole("CHECKPOINT IS "..checkPointReached)
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
    85
	-- load checkpoints, problem getting the campaign variable
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
    86
	local health = 100
9548
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
    87
	if tonumber(GetCampaignVar("Fruit02CheckPoint")) then
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
    88
		WriteLnToConsole("**TRUE**")
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
    89
		checkPointReached = tonumber(GetCampaignVar("Fruit02CheckPoint"))
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
    90
		if checkPointReached ~= 1 then
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
    91
			WriteLnToConsole("++++++++++++++HEEEEEEEREEEEEEEEEEEEE")
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
    92
			loadHogsPositions()
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
    93
			health = tonumber(GetCampaignVar("HeroHealth"))
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
    94
		end
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
    95
	end
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
    96
	
9548
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
    97
	WriteLnToConsole("CHECKPOINT IS "..checkPointReached)
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    98
	-- Hog Solo and Green Bananas
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    99
	AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy")
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   100
	hero.gear = AddHog(hero.name, 0, health, "war_desertgrenadier1")
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   101
	AnimSetGearPosition(hero.gear, hero.x, hero.y)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   102
	HogTurnLeft(hero.gear, true)	
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   103
	green2.gear = AddHog(green2.name, 0, 100, "war_desertgrenadier1")
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   104
	AnimSetGearPosition(green2.gear, green2.x, green2.y)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   105
	HogTurnLeft(green2.gear, true)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   106
	green3.gear = AddHog(green3.name, 0, 100, "war_desertgrenadier1")
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   107
	AnimSetGearPosition(green3.gear, green3.x, green3.y)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   108
	HogTurnLeft(green3.gear, true)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   109
	-- Captain Lime
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   110
	AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "cm_birdy")
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   111
	green1.human = AddHog(green1.name, 0, 100, "war_desertgrenadier1")
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   112
	AnimSetGearPosition(green1.human, green1.x, green1.y)
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   113
	green1.bot = AddHog(green1.name, 1, 100, "war_desertgrenadier1")
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   114
	AnimSetGearPosition(green1.bot, green1.x, green1.y)
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   115
	green1.gear = green1.human
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   116
	-- Fruit Assasins
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   117
	AddTeam(teamC.name, teamC.color, "Bone", "Island", "HillBilly", "cm_birdy")
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   118
	for i=1,table.getn(redHedgehogs) do
9540
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   119
		redHedgehogs[i].gear =  AddHog(redHedgehogs[i].name, 1, 100, "war_desertgrenadier1")
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   120
		AnimSetGearPosition(redHedgehogs[i].gear, 2010 + 50*i, 630)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   121
	end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   122
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   123
	AnimInit()
9529
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   124
	AnimationSetup()	
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   125
end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   126
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   127
function onGameStart()
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   128
	AnimWait(hero.gear, 3000)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   129
	FollowGear(hero.gear)
9542
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   130
	
9540
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   131
	if GetCampaignVar("Fruit01JoinedBattle") and GetCampaignVar("Fruit01JoinedBattle") == "true" then
9529
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   132
		tookPartInBattle = true
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   133
	end
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   134
	
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   135
	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   136
	AddEvent(onDeviceCrates, {hero.gear}, deviceCrates, {hero.gear}, 0)
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   137
	
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   138
	-- Hog Solo and GB weapons
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   139
	AddAmmo(hero.gear, amSwitch, 100)
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   140
	AddAmmo(hero.gear, amTeleport, 100)
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   141
	-- Captain Lime weapons
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   142
	AddAmmo(green1.bot, amBazooka, 6)
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   143
	AddAmmo(green1.bot, amGrenade, 6)
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   144
	AddAmmo(green1.bot, amDEagle, 2)
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   145
	HideHog(green1.bot)
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   146
	-- Assasins weapons
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   147
	AddAmmo(redHedgehogs[1].gear, amBazooka, 6)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   148
	AddAmmo(redHedgehogs[1].gear, amGrenade, 6)
9540
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   149
	AddAmmo(redHedgehogs[1].bot, amDEagle, 6)
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   150
	for i=1,table.getn(redHedgehogs) do
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   151
		HideHog(redHedgehogs[i].gear)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   152
	end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   153
	
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   154
	-- explosives
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   155
	-- I wanted to use FindPlace but doesn't accept height values...
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   156
	local x1 = 950
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   157
	local x2 = 1306
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   158
	local y1 = 1210
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   159
	local y2 = 1620
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   160
	while true do
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   161
		if y2<y1 then
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   162
			break
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   163
		end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   164
		if x2<x1 then
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   165
			x2 = 1305
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   166
			y2 = y2 - 50
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   167
		end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   168
		if not TestRectForObstacle(x2+25, y2+25, x2-25, y2-25, true) then
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   169
			AddGear(x2, y2, gtExplosives, 0, 0, 0, 0)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   170
		end
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   171
		x2 = x2 - 25
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   172
	end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   173
	AddGear(3128, 1680, gtExplosives, 0, 0, 0, 0)
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   174
	
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   175
	--mines
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   176
	AddGear(3135, 1680, gtMine, 0, 0, 0, 0)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   177
	AddGear(3145, 1680, gtMine, 0, 0, 0, 0)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   178
	AddGear(3155, 1680, gtMine, 0, 0, 0, 0)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   179
	AddGear(3165, 1680, gtMine, 0, 0, 0, 0)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   180
	AddGear(3175, 1680, gtMine, 0, 0, 0, 0)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   181
	AddGear(3115, 1680, gtMine, 0, 0, 0, 0)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   182
	AddGear(3105, 1680, gtMine, 0, 0, 0, 0)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   183
	AddGear(3095, 1680, gtMine, 0, 0, 0, 0)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   184
	AddGear(3085, 1680, gtMine, 0, 0, 0, 0)
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   185
	AddGear(3075, 1680, gtMine, 0, 0, 0, 0)	
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   186
9548
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   187
	WriteLnToConsole("CHECKPOINT IS "..checkPointReached)
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   188
	if checkPointReached == 1 then
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   189
		AddAmmo(hero.gear, amFirePunch, 3)
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   190
		AddEvent(onCheckPoint1, {hero.gear}, checkPoint1, {hero.gear}, 0)
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   191
		AddEvent(onCheckPoint2, {hero.gear}, checkPoint2, {hero.gear}, 0)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   192
		AddEvent(onCheckPoint3, {hero.gear}, checkPoint3, {hero.gear}, 0)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   193
		AddEvent(onCheckPoint4, {hero.gear}, checkPoint4, {hero.gear}, 0)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   194
		if tookPartInBattle then
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   195
			AddAnim(dialog01)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   196
		else
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   197
			AddAnim(dialog02)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   198
		end
9548
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   199
	elseif checkPointReached == 2 then
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   200
		AddEvent(onCheckPoint2, {hero.gear}, checkPoint2, {hero.gear}, 0)
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   201
		AddEvent(onCheckPoint3, {hero.gear}, checkPoint3, {hero.gear}, 0)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   202
		AddEvent(onCheckPoint4, {hero.gear}, checkPoint4, {hero.gear}, 0)
9548
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   203
	elseif checkPointReached == 3 then
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   204
		AddEvent(onCheckPoint1, {hero.gear}, checkPoint1, {hero.gear}, 0)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   205
		AddEvent(onCheckPoint3, {hero.gear}, checkPoint3, {hero.gear}, 0)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   206
		AddEvent(onCheckPoint4, {hero.gear}, checkPoint4, {hero.gear}, 0)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   207
	elseif checkPointReached == 4 then
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   208
		AddEvent(onCheckPoint4, {hero.gear}, checkPoint4, {hero.gear}, 0)		
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   209
	elseif checkPointReached == 5 then
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   210
		-- EMPTY
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   211
	end
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   212
	if checkPointReached ~= 1 then
9548
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   213
		loadWeapons()
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   214
	end
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   215
	
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   216
	-- girders
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   217
	if checkPointReached > 1 then
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   218
		PlaceGirder(1580, 875, 4)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   219
		PlaceGirder(1800, 875, 4)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   220
	end
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   221
	
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   222
	-- place crates
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   223
	if checkPointReached < 2 then
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   224
		SpawnAmmoCrate(girderCrate.x, girderCrate.y, girderCrate.name)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   225
	end
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   226
	if checkPointReached < 5 then
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   227
		SpawnAmmoCrate(eagleCrate.x, eagleCrate.y, eagleCrate.name)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   228
	end
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   229
	SpawnAmmoCrate(ropeCrate.x, ropeCrate.y, ropeCrate.name)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   230
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   231
	if tookPartInBattle then
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   232
		SpawnAmmoCrate(weaponCrate.x, weaponCrate.y, amWatermelon)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   233
	else
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   234
		SpawnAmmoCrate(weaponCrate.x, weaponCrate.y, amSniperRifle)		
9548
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   235
	end
9529
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   236
	
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   237
	SendHealthStatsOff()
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   238
end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   239
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   240
function onNewTurn()
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   241
	if not inBattle and CurrentHedgehog == green1.gear then
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   242
		TurnTimeLeft = 0
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   243
	elseif CurrentHedgehog == green2.gear or CurrentHedgehog == green3.gear then
9544
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   244
		TurnTimeLeft = 0
9536
7456b28a3421 this seems to work fine for the escape scenario
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9534
diff changeset
   245
	elseif inBattle then
7456b28a3421 this seems to work fine for the escape scenario
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9534
diff changeset
   246
		if CurrentHedgehog == green1.gear and previousHog ~= hero.gear then
7456b28a3421 this seems to work fine for the escape scenario
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9534
diff changeset
   247
			TurnTimeLeft = 0
7456b28a3421 this seems to work fine for the escape scenario
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9534
diff changeset
   248
			return
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   249
		end
9540
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   250
		for i=1,table.getn(redHedgehogs) do
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   251
			if CurrentHedgehog == redHedgehogs[i].gear and previousHog ~= hero.gear then
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   252
				TurnTimeLeft = 0
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   253
				return
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   254
			end
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   255
		end
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   256
		TurnTimeLeft = 20000
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   257
		wind()
9540
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   258
	elseif not inBattle and CurrentHedgehog == hero.gear then
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   259
		TurnTimeLeft = -1
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   260
		wind()
9536
7456b28a3421 this seems to work fine for the escape scenario
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9534
diff changeset
   261
	else
7456b28a3421 this seems to work fine for the escape scenario
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9534
diff changeset
   262
		TurnTimeLeft = 0
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   263
	end
9536
7456b28a3421 this seems to work fine for the escape scenario
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9534
diff changeset
   264
	previousHog = CurrentHedgehog
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   265
end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   266
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   267
function onGameTick()
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   268
	AnimUnWait()
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   269
	if ShowAnimation() == false then
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   270
		return
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   271
	end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   272
	ExecuteAfterAnimations()
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   273
	CheckEvents()
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   274
end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   275
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   276
function onGearDelete(gear)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   277
	if gear == hero.gear then
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   278
		hero.dead = true
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   279
	elseif gear == green1.bot then
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   280
		green1.dead = true
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   281
	end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   282
end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   283
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   284
function onAmmoStoreInit()
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   285
	SetAmmo(amDEagle, 0, 0, 0, 6)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   286
	SetAmmo(amGirder, 0, 0, 0, 3)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   287
	SetAmmo(amRope, 0, 0, 0, 1)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   288
	SetAmmo(amWatermelon, 0, 0, 0, 1)
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   289
	SetAmmo(amSniperRifle, 0, 0, 0, 1)
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   290
end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   291
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   292
function onPrecise()
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   293
	if GameTime > 3000 then
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   294
		SetAnimSkip(true)   
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   295
	end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   296
end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   297
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   298
-------------- EVENTS ------------------
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   299
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   300
function onHeroDeath(gear)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   301
	if hero.dead then
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   302
		return true
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   303
	end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   304
	return false
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   305
end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   306
9532
4fa58a49ace1 more dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9529
diff changeset
   307
function onDeviceCrates(gear)
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   308
	if not hero.dead and GetY(hero.gear)>1850 and GetX(hero.gear)>1340 and GetX(hero.gear)<1640 then
9532
4fa58a49ace1 more dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9529
diff changeset
   309
		return true
4fa58a49ace1 more dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9529
diff changeset
   310
	end
4fa58a49ace1 more dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9529
diff changeset
   311
	return false
4fa58a49ace1 more dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9529
diff changeset
   312
end
4fa58a49ace1 more dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9529
diff changeset
   313
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   314
function onSurface(gear)
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   315
	if not hero.dead and GetY(hero.gear)<850 and  StoppedGear(hero.gear) then
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   316
		return true
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   317
	end
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   318
	return false
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   319
end
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   320
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   321
function onGaptainLimeDeath(gear)
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   322
	if green1.dead then
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   323
		return true
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   324
	end
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   325
	return false
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   326
end
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   327
9540
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   328
function onRedTeamDeath(gear)
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   329
	local redDead = true
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   330
	for i=1,table.getn(redHedgehogs) do
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   331
		if GetHealth(redHedgehogs[i].gear) then
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   332
			redDead = false
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   333
			break
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   334
		end
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   335
	end
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   336
	return redDead
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   337
end
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   338
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   339
function onCheckPoint1(gear)
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   340
	-- before barrel jump
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   341
	if not hero.dead and GetX(hero.gear) > 2850 and GetX(hero.gear) < 2945 
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   342
			and GetY(hero.gear) > 808 and GetY(hero.gear) < 852 and	not isHeroAtWrongPlace() then
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   343
		return true
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   344
	end
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   345
	return false
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   346
end
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   347
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   348
function onCheckPoint2(gear)
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   349
	-- before barrel jump
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   350
	if ((GetHealth(green2.gear) and GetX(green2.gear) > 2850 and GetX(green2.gear) < 2945 and GetY(green2.gear) > 808 and GetY(green2.gear) < 852)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   351
			or (GetHealth(green3.gear) and GetX(green3.gear) > 2850 and GetX(green3.gear) < 2945 and GetY(green3.gear) > 808 and GetY(green3.gear) < 852))
9548
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   352
			and not isHeroAtWrongPlace() then
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   353
		return true
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   354
	end
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   355
	return false
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   356
end
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   357
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   358
function onCheckPoint3(gear)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   359
	-- after barrel jump
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   360
	if ((GetHealth(green2.gear) and GetY(green2.gear) > 1550 and GetX(green2.gear) < 3000 and StoppedGear(green2.gear)) 
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   361
			or (GetHealth(green3.gear) and GetY(green3.gear) > 1550 and GetX(green3.gear) < 3000 and StoppedGear(green2.gear)))
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   362
			and not isHeroAtWrongPlace() then
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   363
		return true
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   364
	end
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   365
	return false
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   366
end
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   367
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   368
function onCheckPoint4(gear)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   369
	-- hero at crates
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   370
	if not hero.dead and GetX(hero.gear) > 1288 and GetX(hero.gear) < 1420 
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   371
			and GetY(hero.gear) > 1840 and	not isHeroAtWrongPlace() then
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   372
		return true
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   373
	end
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   374
	return false
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   375
end
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   376
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   377
-------------- ACTIONS ------------------
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   378
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   379
function heroDeath(gear)
9542
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   380
	SendStat('siGameResult', loc("Hog Solo lost, try again!")) --1
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   381
	SendStat('siCustomAchievement', loc("To win the game Hog Solo has to get the bottom crates and come back to the surface")) --11
9542
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   382
	SendStat('siCustomAchievement', loc("You can use the other 2 hogs to assist you")) --11
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   383
	if tookPartInBattle then
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   384
		SendStat('siCustomAchievement', loc("You'll have to eliminate the Strawberry Assasins at the end")) --11
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   385
	else
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   386
		SendStat('siCustomAchievement', loc("You'll have to eliminate Captain Lime at the end")) --11	
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   387
	end
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   388
	SendStat('siPlayerKills','0',teamA.name)
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   389
	EndGame()
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   390
end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   391
9532
4fa58a49ace1 more dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9529
diff changeset
   392
function deviceCrates(gear)
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   393
	TurnTimeLeft = 0
9532
4fa58a49ace1 more dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9529
diff changeset
   394
	if not tookPartInBattle then
4fa58a49ace1 more dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9529
diff changeset
   395
		AddAnim(dialog03)
4fa58a49ace1 more dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9529
diff changeset
   396
	else
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   397
		for i=1,table.getn(redHedgehogs) do
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   398
			RestoreHog(redHedgehogs[i].gear)
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   399
		end
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   400
		AddAnim(dialog04)
9532
4fa58a49ace1 more dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9529
diff changeset
   401
	end
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   402
	AddAmmo(hero.gear, amSwitch, 0)
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   403
	AddEvent(onSurface, {hero.gear}, surface, {hero.gear}, 0)
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   404
end
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   405
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   406
function surface(gear)
9536
7456b28a3421 this seems to work fine for the escape scenario
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9534
diff changeset
   407
	previousHog = -1
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   408
	if tookPartInBattle then
9540
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   409
		if GetHealth(green1.gear) then
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   410
			HideHog(green1.gear)
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   411
		end
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   412
		AddEvent(onRedTeamDeath, {green1.gear}, redTeamDeath, {green1.gear}, 0)
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   413
	else
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   414
		DeleteGear(green1.human)
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   415
		RestoreHog(green1.bot)
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   416
		green1.gear = green1.bot
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   417
		AddEvent(onGaptainLimeDeath, {green1.gear}, captainLimeDeath, {green1.gear}, 0)
9536
7456b28a3421 this seems to work fine for the escape scenario
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9534
diff changeset
   418
	end
9540
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   419
	if GetHealth(green2.gear) then
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   420
		HideHog(green2.gear)
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   421
	end
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   422
	if GetHealth(green3.gear) then
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   423
		HideHog(green3.gear)
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   424
	end
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   425
	inBattle = true
9532
4fa58a49ace1 more dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9529
diff changeset
   426
end
4fa58a49ace1 more dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9529
diff changeset
   427
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   428
function captainLimeDeath(gear)
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   429
	-- hero win in scenario of escape in 1st part
9542
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   430
	SendStat('siGameResult', loc("Congratulations, you won!")) --1
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   431
	SendStat('siCustomAchievement', loc("You retrieved the lost part")) --11
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   432
	SendStat('siCustomAchievement', loc("You defended yourself against Captain Lime")) --11
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   433
	SendStat('siPlayerKills','1',teamA.name)
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   434
	SendStat('siPlayerKills','0',teamB.name)
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   435
	EndGame()
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   436
end
9540
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   437
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   438
function redTeamDeath(gear)
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   439
	-- hero win in battle scenario
9542
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   440
	SendStat('siGameResult', loc("Congratulations, you won!")) --1
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   441
	SendStat('siCustomAchievement', loc("You retrieved the lost part")) --11
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   442
	SendStat('siCustomAchievement', loc("You defended yourself against Strawberry Assasins")) --11
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   443
	SendStat('siPlayerKills','1',teamA.name)
d1ea2d1540f2 custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9540
diff changeset
   444
	SendStat('siPlayerKills','0',teamC.name)
9540
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   445
	EndGame()
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   446
end
92329918463f game against red team seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9538
diff changeset
   447
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   448
function checkPoint1(gear)
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   449
	saveCheckPoint(2)
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   450
end
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   451
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   452
function checkPoint2(gear)
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   453
	saveCheckPoint(3)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   454
end
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   455
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   456
function checkPoint3(gear)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   457
	saveCheckPoint(4)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   458
end
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   459
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   460
function checkPoint4(gear)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   461
	saveCheckPoint(5)
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   462
end
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   463
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   464
-------------- ANIMATIONS ------------------
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   465
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   466
function Skipanim(anim)
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   467
	if goals[anim] ~= nil then
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   468
		ShowMission(unpack(goals[anim]))
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   469
    end
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   470
    TurnTimeLeft = 0
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   471
end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   472
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   473
function AnimationSetup()
9529
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   474
	-- DIALOG 01 - Start, Captain Lime helps Hog Solo because he took part in the battle
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   475
	AddSkipFunction(dialog01, Skipanim, {dialog01})
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   476
	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 3000}})
9529
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   477
	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("Somewhere else in the planet of fruits Captain Lime helps Hog Solo..."), 5000}})
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   478
	table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("You fought bravely and you helped us win this battle!"), SAY_SAY, 5000}})
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   479
	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 is hidden."), SAY_SAY, 7000}})
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   480
	table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("I know that your resources are low due to the battle but I'll send with you two of my best hogs to assist you."), SAY_SAY, 7000}})
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   481
	table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("Good luck!"), SAY_SAY, 2000}})
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   482
	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 500}})
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   483
	table.insert(dialog01, {func = AnimSwitchHog, args = {hero.gear}})
9529
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   484
	-- DIALOG02 - Start, Hog Solo escaped from the previous battle
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   485
	AddSkipFunction(dialog02, Skipanim, {dialog02})
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   486
	table.insert(dialog02, {func = AnimWait, args = {hero.gear, 3000}})
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   487
	table.insert(dialog02, {func = AnimCaption, args = {hero.gear, loc("Somewhere else in the planet of fruits Hog Solo gets closer to the device..."), 5000}})
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   488
	table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("You are the one who fled! So, you are alive..."), SAY_SAY, 4000}})
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   489
	table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("I'm still low on hogs. If you are not afraid I could use a set of extra hands"), SAY_SAY, 4000}})
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   490
	table.insert(dialog02, {func = AnimWait, args = {hero.gear, 8000}})
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   491
	table.insert(dialog02, {func = AnimSay, args = {hero.gear, loc("I am sorry but I was looking for a device that may be hidden somewhere around here"), SAY_SAY, 4500}})
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   492
	table.insert(dialog02, {func = AnimWait, args = {green1.gear, 12500}})
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   493
	table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("Many long forgotten things can be found in the same tunnels that we are about to search!"), SAY_SAY, 7000}})
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   494
	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}})
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   495
	table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("What do you say? Are you in?"), SAY_SAY, 3000}})
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   496
	table.insert(dialog02, {func = AnimWait, args = {hero.gear, 1800}})
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   497
	table.insert(dialog02, {func = AnimSay, args = {hero.gear, loc("Ok then!"), SAY_SAY, 2000}})
e95aab9130d8 first dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9527
diff changeset
   498
	table.insert(dialog02, {func = AnimSwitchHog, args = {hero.gear}})
9532
4fa58a49ace1 more dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9529
diff changeset
   499
	-- DIALOG03 - At crates, hero learns that Captain Lime is bad
4fa58a49ace1 more dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9529
diff changeset
   500
	AddSkipFunction(dialog03, Skipanim, {dialog03})
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   501
	table.insert(dialog03, {func = AnimWait, args = {hero.gear, 4000}})
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   502
	table.insert(dialog03, {func = FollowGear, args = {hero.gear}})
9532
4fa58a49ace1 more dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9529
diff changeset
   503
	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}})
4fa58a49ace1 more dialogs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9529
diff changeset
   504
	table.insert(dialog03, {func = AnimWait, args = {green1.gear, 4000}})
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   505
	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}})
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   506
	table.insert(dialog03, {func = goToThesurface, args = {hero.gear}})
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   507
	-- DIALOG04 - At crates, hero learns about the assasins ambush
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   508
	AddSkipFunction(dialog04, Skipanim, {dialog04})
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   509
	table.insert(dialog04, {func = AnimWait, args = {hero.gear, 4000}})
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   510
	table.insert(dialog04, {func = FollowGear, args = {hero.gear}})
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   511
	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}})
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   512
	table.insert(dialog04, {func = AnimWait, args = {redHedgehogs[1].gear, 4000}})
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   513
	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}})
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   514
	table.insert(dialog04, {func = goToThesurface, args = {hero.gear}})
9527
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   515
end
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   516
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   517
------------- OTHER FUNCTIONS ---------------
676fc574ff42 fruit planet part 2
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   518
9534
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   519
function goToThesurface()
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   520
	TurnTimeLeft = 0
662edfec06be many dialogs and events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9532
diff changeset
   521
end
9538
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   522
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   523
function wind()
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   524
	if GetY(CurrentHedgehog) > 1350 then
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   525
		SetWind(-40)
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   526
	else
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   527
		SetWind(math.random(-100,100))
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   528
	end
51596e01c5df scenario of escape seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9536
diff changeset
   529
end
9544
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   530
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   531
function saveHogsPositions()
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   532
	local positions;
9544
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   533
	positions = GetX(hero.gear)..","..GetY(hero.gear)
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   534
	if GetHealth(green2.gear) then
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   535
		positions = positions..","..GetX(green2.gear)..","..GetY(green2.gear)
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   536
	end
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   537
	if GetHealth(green3.gear) then
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   538
		positions = positions..","..GetX(green3.gear)..","..GetY(green3.gear)
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   539
	end
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   540
	SaveCampaignVar("HogsPosition", positions)
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   541
end
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   542
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   543
function loadHogsPositions()
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   544
	WriteLnToConsole("load hogs positions")
9544
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   545
	local positions;
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   546
	if GetCampaignVar("HogsPosition") then
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   547
		positions = GetCampaignVar("HogsPosition")
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   548
	else
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   549
		return
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   550
	end
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   551
	WriteLnToConsole("positions : "..positions)
9544
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   552
	positions = split(positions,",")
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   553
	WriteLnToConsole("--------------- "..hero.x)
9544
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   554
	if positions[1] then
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   555
		hero.x = positions[1]
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   556
		hero.y = positions[2]
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   557
	end
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   558
	if positions[3] then
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   559
		green2.x = tonumber(positions[3])
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   560
		green2.y = tonumber(positions[4])
9544
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   561
	end
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   562
	if positions[5] then
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   563
		green3.x = tonumber(positions[5])
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   564
		green3.y = tonumber(positions[6])
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   565
		WriteLnToConsole("---------"..green3.y)
9544
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   566
	end
e247251fa751 position saving functions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9542
diff changeset
   567
end
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   568
9548
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   569
function saveWeapons()
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   570
	-- firepunch - gilder - deagle - watermelon - sniper
9550
59061246a25c fixed weapon type typo
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9548
diff changeset
   571
	WriteLnToConsole("SAVE WEAPONS TRIGGERED: "..GetAmmoCount(hero.gear, amFirePunch)..GetAmmoCount(hero.gear, amGilder)..
59061246a25c fixed weapon type typo
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9548
diff changeset
   572
			GetAmmoCount(hero.gear, amDEagle)..GetAmmoCount(hero.gear, amWatermelon)..GetAmmoCount(hero.gear, amSniperRifle))
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   573
	SaveCampaignVar("HeroAmmo", GetAmmoCount(hero.gear, amFirePunch)..GetAmmoCount(hero.gear, amGirder)..
9548
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   574
			GetAmmoCount(hero.gear, amDEagle)..GetAmmoCount(hero.gear, amWatermelon)..GetAmmoCount(hero.gear, amSniperRifle))
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   575
end
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   576
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   577
function loadWeapons()
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   578
	local ammo = GetCampaignVar("HeroAmmo")
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   579
	WriteLnToConsole("GILDER "..tonumber(ammo:sub(2,2)))
9550
59061246a25c fixed weapon type typo
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9548
diff changeset
   580
	AddAmmo(hero.gear, amFirePunch, tonumber(ammo:sub(1,1)))
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   581
	AddAmmo(hero.gear, amGirder, tonumber(ammo:sub(2,2)))
9548
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   582
	AddAmmo(hero.gear, amDEagle, tonumber(ammo:sub(3,3)))
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   583
	AddAmmo(hero.gear, amWatermelon, tonumber(ammo:sub(4,4)))
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   584
	AddAmmo(hero.gear, amSniperRifle, tonumber(ammo:sub(5,5)))
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   585
end
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   586
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   587
function isHeroAtWrongPlace()
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   588
	if GetX(hero.gear) > 1480 and GetX(hero.gear) < 1892 and GetY(hero.gear) > 1000 and GetY(hero.gear) < 1220 then
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   589
		return true
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   590
	end
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   591
	return false
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   592
end
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   593
9548
38630665c9ab check point fixes
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9546
diff changeset
   594
-- splits number by delimiter
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   595
function split(s, delimiter)
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   596
	local res = {}
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   597
	local first = ""
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   598
	for i=1,s:len() do
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   599
		if s:sub(1,1) == delimiter then
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   600
			table.insert(res, tonumber(first))
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   601
			first = ""
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   602
		else
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   603
			first = first..s:sub(1,1)
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   604
		end
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   605
		s = s:sub(2)
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   606
	end
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   607
	if first:len() > 0 then
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   608
		table.insert(res, tonumber(first))
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   609
	end
9546
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   610
	return res
f7530a7e5612 added custom lua split
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9544
diff changeset
   611
end
9552
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   612
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   613
function saveCheckPoint(cpoint)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   614
	AnimCaption(hero.gear, loc("Checkpoint reached!"), 3000)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   615
	SaveCampaignVar("Fruit02CheckPoint", cpoint)
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   616
	SaveCampaignVar("HeroHealth", GetHealth(hero.gear))
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   617
	saveHogsPositions()
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   618
	saveWeapons()
90d69a2c1729 checkpoint system seems complete
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9550
diff changeset
   619
end