share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua
author Wuzzy <Wuzzy2@mail.ru>
Fri, 31 May 2019 11:10:01 +0200
changeset 15102 3a561db2a71c
parent 14953 ff4003a90ff8
child 15522 5eda4d7056bc
permissions -rw-r--r--
ASA: Check if hero is still alive before claiming victory
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     1
------------------- ABOUT ----------------------
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     2
--
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     3
-- Hero has been surrounded my some space villains
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     4
-- He has to defeat them in order to escape
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     5
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     6
HedgewarsScriptLoad("/Scripts/Locale.lua")
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     7
HedgewarsScriptLoad("/Scripts/Animate.lua")
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     8
HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua")
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     9
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    10
----------------- VARIABLES --------------------
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    11
-- globals
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    12
local missionName = loc("Killing the specialists")
11692
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9831
diff changeset
    13
local challengeObjectives = loc("Use your available weapons in order to eliminate the enemies.").."|"..
12935
ff42888333bc Killing The Specialists mission: Fix misleading hints, add messages and visual effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12900
diff changeset
    14
	loc("The enemy hogs play in a random order.").."|"..
11692
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9831
diff changeset
    15
	loc("At the start of the game each enemy hog has only the weapon that he is named after.").."|"..
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9831
diff changeset
    16
	loc("A random hedgehog will inherit the weapons of his deceased team-mates.").."|"..
12935
ff42888333bc Killing The Specialists mission: Fix misleading hints, add messages and visual effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12900
diff changeset
    17
	loc("After you killed an enemy, you'll lose the weapon that he is named after.").."|"..
ff42888333bc Killing The Specialists mission: Fix misleading hints, add messages and visual effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12900
diff changeset
    18
	loc("If only one enemy is left, you'll get bonus ammo.").."|"..
ff42888333bc Killing The Specialists mission: Fix misleading hints, add messages and visual effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12900
diff changeset
    19
	loc("If you hurt an enemy, you'll get one third of the damage dealt.").."|"..
ff42888333bc Killing The Specialists mission: Fix misleading hints, add messages and visual effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12900
diff changeset
    20
	loc("If you kill an enemy, your health will be set to 100.")
9602
a8ed4853963e dialogs with objectives added
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9601
diff changeset
    21
-- mission objectives
a8ed4853963e dialogs with objectives added
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9601
diff changeset
    22
local goals = {
12575
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12565
diff changeset
    23
	["init"] = {missionName, loc("Challenge objectives"), challengeObjectives, 1, 35000},
9602
a8ed4853963e dialogs with objectives added
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9601
diff changeset
    24
}
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    25
-- hogs
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    26
local hero = {
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    27
	name = loc("Hog Solo"),
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    28
	x = 850,
14602
72b4bdd5052c ASA: Tweak spawning height of hedgehogs
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
    29
	y = 469,
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    30
	mortarAmmo = 2,
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    31
	firepunchAmmo = 1,
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    32
	deagleAmmo = 4,
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    33
	bazookaAmmo = 2,
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    34
	grenadeAmmo = 4,
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    35
}
12970
dc35a79c6ef9 Fix Killing the Specialists recording the turn count way too low
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
    36
local heroTurns = 0
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    37
local enemies = {
14602
72b4bdd5052c ASA: Tweak spawning height of hedgehogs
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
    38
	{ name = GetAmmoName(amMortar), x = 1890, y = 535, weapon = amMortar, additionalWeapons = {}},
72b4bdd5052c ASA: Tweak spawning height of hedgehogs
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
    39
	{ name = GetAmmoName(amDEagle), x = 1390, y = 815, weapon = amDEagle, additionalWeapons = {}},
72b4bdd5052c ASA: Tweak spawning height of hedgehogs
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
    40
	{ name = GetAmmoName(amGrenade), x = 186, y = 62, weapon = amGrenade, additionalWeapons = {}},
72b4bdd5052c ASA: Tweak spawning height of hedgehogs
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
    41
	{ name = GetAmmoName(amFirePunch), x = 330, y = 285, weapon = amFirePunch, additionalWeapons = {}},
72b4bdd5052c ASA: Tweak spawning height of hedgehogs
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
    42
	{ name = GetAmmoName(amBazooka), x = 1950, y = 152, weapon = amBazooka, additionalWeapons = {}},
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    43
}
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    44
-- teams
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    45
local teamA = {
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    46
	name = loc("Hog Solo"),
13583
141cdfe0f3ca Switch almost all Lua calls of AddTeam to using default clan colors instead of hardcoded color
Wuzzy <Wuzzy2@mail.ru>
parents: 13092
diff changeset
    47
	color = -6
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    48
}
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    49
local teamB = {
11692
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9831
diff changeset
    50
	name = loc("5 Deadly Hogs"),
13583
141cdfe0f3ca Switch almost all Lua calls of AddTeam to using default clan colors instead of hardcoded color
Wuzzy <Wuzzy2@mail.ru>
parents: 13092
diff changeset
    51
	color = -1
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    52
}
12089
0183b4c448bf Fix Killing the Specialists giving you a free turn after killing Desert Eagle with a desert eagle with shot 1-3
Wuzzy <almikes@aol.com>
parents: 12088
diff changeset
    53
-- After hero killed an enemy, his weapons will be reset in the next round
0183b4c448bf Fix Killing the Specialists giving you a free turn after killing Desert Eagle with a desert eagle with shot 1-3
Wuzzy <almikes@aol.com>
parents: 12088
diff changeset
    54
local heroWeaponResetPending = false
12575
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12565
diff changeset
    55
local battleStarted = false
12577
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12575
diff changeset
    56
local firstTurn = true
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    57
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    58
-------------- LuaAPI EVENT HANDLERS ------------------
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    59
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    60
function onGameInit()
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    61
	Seed = 1
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    62
	TurnTime = 25000
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    63
	CaseFreq = 0
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    64
	MinesNum = 0
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    65
	MinesTime = 1
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    66
	Explosives = 0
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    67
	Map = "death02_map"
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    68
	Theme = "Hell"
12468
d652c6f5d5f1 Disable Sudden Death for a couple of ASA missions
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
    69
	-- Disable Sudden Death
d652c6f5d5f1 Disable Sudden Death for a couple of ASA missions
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
    70
	WaterRise = 0
d652c6f5d5f1 Disable Sudden Death for a couple of ASA missions
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
    71
	HealthDecrease = 0
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9644
diff changeset
    72
14509
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 14422
diff changeset
    73
	-- Hero
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 14422
diff changeset
    74
	teamA.name = AddMissionTeam(teamA.color)
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 14422
diff changeset
    75
	hero.gear = AddMissionHog(100)
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 14422
diff changeset
    76
	hero.name = GetHogName(hero.gear)
14602
72b4bdd5052c ASA: Tweak spawning height of hedgehogs
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
    77
	SetGearPosition(hero.gear, hero.x, hero.y)
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    78
	-- enemies
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    79
	shuffleHogs(enemies)
14953
ff4003a90ff8 Enable automatic voicepack language selection for all missions
Wuzzy <Wuzzy2@mail.ru>
parents: 14602
diff changeset
    80
	teamB.name = AddTeam(teamB.name, teamB.color, "skull", "Island", "Default_qau", "cm_skull")
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    81
	for i=1,table.getn(enemies) do
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    82
		enemies[i].gear = AddHog(enemies[i].name, 1, 100, "war_desertgrenadier1")
14602
72b4bdd5052c ASA: Tweak spawning height of hedgehogs
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
    83
		SetGearPosition(enemies[i].gear, enemies[i].x, enemies[i].y)
72b4bdd5052c ASA: Tweak spawning height of hedgehogs
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
    84
		if enemies[i].x > hero.x then
72b4bdd5052c ASA: Tweak spawning height of hedgehogs
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
    85
			HogTurnLeft(enemies[i].gear, true)
72b4bdd5052c ASA: Tweak spawning height of hedgehogs
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
    86
		end
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    87
	end
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9644
diff changeset
    88
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    89
	initCheckpoint("death02")
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9644
diff changeset
    90
12577
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12575
diff changeset
    91
	AnimInit()
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    92
end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    93
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    94
function onGameStart()
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    95
	AnimWait(hero.gear, 3000)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    96
	FollowGear(hero.gear)
12575
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12565
diff changeset
    97
	ShowMission(unpack(goals["init"]))
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9644
diff changeset
    98
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    99
	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   100
	AddEvent(onHeroWin, {hero.gear}, heroWin, {hero.gear}, 0)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   101
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   102
	--hero ammo
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   103
	AddAmmo(hero.gear, amSkip, 100)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   104
	AddAmmo(hero.gear, amRope, 2)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   105
	refreshHeroAmmo()
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   106
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   107
	SendHealthStatsOff()
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   108
end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   109
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   110
function onNewTurn()
12577
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12575
diff changeset
   111
	battleStarted = true
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12575
diff changeset
   112
	if firstTurn then
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12575
diff changeset
   113
		-- Generous ready time in first turn to more time to read the mission panel
13742
2bb7141496a9 Use SetTurnTimeLeft and SetReadyTimeLeft in all scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   114
		SetReadyTimeLeft(35000)
12577
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12575
diff changeset
   115
		firstTurn = false
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12575
diff changeset
   116
	end
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   117
	if CurrentHedgehog ~= hero.gear then
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   118
		enemyWeapons()
12970
dc35a79c6ef9 Fix Killing the Specialists recording the turn count way too low
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   119
	else
dc35a79c6ef9 Fix Killing the Specialists recording the turn count way too low
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   120
		heroTurns = heroTurns + 1
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   121
	end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   122
end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   123
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   124
function onGearDelete(gear)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   125
	if isHog(gear) then
12940
39b7b3ed619e Add healing visual effect + heal msg in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 12936
diff changeset
   126
		-- Set health to 100 (with heal effect, if health was smaller)
12935
ff42888333bc Killing The Specialists mission: Fix misleading hints, add messages and visual effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12900
diff changeset
   127
		local healthDiff = 100 - GetHealth(hero.gear)
12940
39b7b3ed619e Add healing visual effect + heal msg in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 12936
diff changeset
   128
		if healthDiff > 1 then
39b7b3ed619e Add healing visual effect + heal msg in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 12936
diff changeset
   129
			HealHog(hero.gear, healthDiff, true, 0x00FF00FF)
39b7b3ed619e Add healing visual effect + heal msg in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 12936
diff changeset
   130
		else
39b7b3ed619e Add healing visual effect + heal msg in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 12936
diff changeset
   131
			SetHealth(hero.gear, 100)
39b7b3ed619e Add healing visual effect + heal msg in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 12936
diff changeset
   132
		end
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   133
		local deadHog = getHog(gear)
9603
47b8edc799f5 changed some left amDynamite to amMortar
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9602
diff changeset
   134
		if deadHog.weapon == amMortar then
47b8edc799f5 changed some left amDynamite to amMortar
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9602
diff changeset
   135
			hero.mortarAmmo = 0
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   136
		elseif deadHog.weapon == amFirePunch then
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   137
			hero.firepunchAmmo = 0
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   138
		elseif deadHog.weapon == amDEagle then
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   139
			hero.deagleAmmo = 0
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   140
		elseif deadHog.weapon == amBazooka then
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   141
			hero.bazookaAmmo = 0
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   142
		elseif deadHog.weapon == amGrenade then
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   143
			hero.grenadeAmmo = 0
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9644
diff changeset
   144
		end
9810
54c0fdec4600 changing math functions that may cause desyncs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9758
diff changeset
   145
		local randomHog = GetRandom(table.getn(enemies))+1
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   146
		while not GetHealth(enemies[randomHog].gear) do
9810
54c0fdec4600 changing math functions that may cause desyncs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9758
diff changeset
   147
			randomHog = GetRandom(table.getn(enemies))+1
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   148
		end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   149
		table.insert(enemies[randomHog].additionalWeapons, deadHog.weapon)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   150
		for i=1,table.getn(deadHog.additionalWeapons) do
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   151
			table.insert(enemies[randomHog].additionalWeapons, deadHog.additionalWeapons[i])
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   152
		end
12089
0183b4c448bf Fix Killing the Specialists giving you a free turn after killing Desert Eagle with a desert eagle with shot 1-3
Wuzzy <almikes@aol.com>
parents: 12088
diff changeset
   153
		heroWeaponResetPending = true
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   154
	end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   155
end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   156
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   157
function onGearDamage(gear, damage)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   158
	if isHog(gear) and GetHealth(hero.gear) then
12936
b9904380ce26 Killing The Specialists: Fix health boost division
Wuzzy <Wuzzy2@mail.ru>
parents: 12935
diff changeset
   159
		local bonusHealth = div(damage, 3)
12940
39b7b3ed619e Add healing visual effect + heal msg in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 12936
diff changeset
   160
		HealHog(hero.gear, bonusHealth, true, 0xFF0000FF)
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   161
	end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   162
end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   163
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   164
function onGameTick()
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   165
	AnimUnWait()
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   166
	if ShowAnimation() == false then
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   167
		return
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   168
	end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   169
	ExecuteAfterAnimations()
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   170
	CheckEvents()
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   171
end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   172
12935
ff42888333bc Killing The Specialists mission: Fix misleading hints, add messages and visual effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12900
diff changeset
   173
function onGameTick20()
ff42888333bc Killing The Specialists mission: Fix misleading hints, add messages and visual effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12900
diff changeset
   174
	-- Refresh hero ammo immediately after its not his turn anymore
ff42888333bc Killing The Specialists mission: Fix misleading hints, add messages and visual effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12900
diff changeset
   175
	if CurrentHedgehog ~= hero.gear and heroWeaponResetPending then
ff42888333bc Killing The Specialists mission: Fix misleading hints, add messages and visual effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12900
diff changeset
   176
		refreshHeroAmmo()
ff42888333bc Killing The Specialists mission: Fix misleading hints, add messages and visual effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12900
diff changeset
   177
	end
ff42888333bc Killing The Specialists mission: Fix misleading hints, add messages and visual effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12900
diff changeset
   178
end
ff42888333bc Killing The Specialists mission: Fix misleading hints, add messages and visual effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12900
diff changeset
   179
12575
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12565
diff changeset
   180
-- Hide mission panel when player does anything
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12565
diff changeset
   181
function hideMissionOnAction()
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12565
diff changeset
   182
	if battleStarted then
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12565
diff changeset
   183
		HideMission()
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12565
diff changeset
   184
	end
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12565
diff changeset
   185
end
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12565
diff changeset
   186
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12565
diff changeset
   187
onHogAttack = hideMissionOnAction
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12565
diff changeset
   188
onAttack = hideMissionOnAction
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12565
diff changeset
   189
onSlot = hideMissionOnAction
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12565
diff changeset
   190
onSetWeapon = hideMissionOnAction
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   191
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   192
-------------- EVENTS ------------------
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   193
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   194
function onHeroDeath(gear)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   195
	if not GetHealth(hero.gear) then
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   196
		return true
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   197
	end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   198
	return false
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   199
end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   200
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   201
function onHeroWin(gear)
15102
3a561db2a71c ASA: Check if hero is still alive before claiming victory
Wuzzy <Wuzzy2@mail.ru>
parents: 14953
diff changeset
   202
	if not IsHogAlive(gear) then
3a561db2a71c ASA: Check if hero is still alive before claiming victory
Wuzzy <Wuzzy2@mail.ru>
parents: 14953
diff changeset
   203
		return false
3a561db2a71c ASA: Check if hero is still alive before claiming victory
Wuzzy <Wuzzy2@mail.ru>
parents: 14953
diff changeset
   204
	end
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   205
	local allDead = true
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   206
	for i=1,table.getn(enemies) do
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   207
		if GetHealth(enemies[i].gear) then
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   208
			allDead = false
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   209
			break
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   210
		end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   211
	end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   212
	return allDead
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   213
end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   214
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   215
-------------- ACTIONS ------------------
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   216
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   217
function heroDeath(gear)
14509
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 14422
diff changeset
   218
	SendStat(siGameResult, string.format(loc("%s lost, try again!"), hero.name))
11692
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9831
diff changeset
   219
	SendStat(siCustomAchievement, loc("You have to eliminate all the enemies."))
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9831
diff changeset
   220
	SendStat(siCustomAchievement, loc("Read the challenge objectives from within the mission for more details."))
12538
952afc3d2df2 Show correct kill counts in all ASA missions (fixes #147)
Wuzzy <almikes@aol.com>
parents: 12468
diff changeset
   221
	sendSimpleTeamRankings({teamB.name, teamA.name})
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   222
	EndGame()
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   223
end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   224
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   225
function heroWin(gear)
9630
df942cfac4e6 add bonuses
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9603
diff changeset
   226
	saveBonus(3, 4)
9642
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9631
diff changeset
   227
	SendStat(siGameResult, loc("Congratulations, you won!"))
12970
dc35a79c6ef9 Fix Killing the Specialists recording the turn count way too low
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   228
	SendStat(siCustomAchievement, string.format(loc("You completed the mission in %d rounds."), heroTurns))
dc35a79c6ef9 Fix Killing the Specialists recording the turn count way too low
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   229
	local record = tonumber(GetCampaignVar("FastestSpecialistsWin"))
dc35a79c6ef9 Fix Killing the Specialists recording the turn count way too low
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   230
	if record ~= nil and heroTurns >= record then
11892
0526a26ddd6e Save fastest rounds in Killing the specialists and Precise shooting missions
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   231
		SendStat(siCustomAchievement, string.format(loc("Your fastest victory so far: %d rounds"), record))
0526a26ddd6e Save fastest rounds in Killing the specialists and Precise shooting missions
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   232
	end
12970
dc35a79c6ef9 Fix Killing the Specialists recording the turn count way too low
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   233
	if record == nil or heroTurns < record then
dc35a79c6ef9 Fix Killing the Specialists recording the turn count way too low
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   234
		SaveCampaignVar("FastestSpecialistsWin", tostring(heroTurns))
11892
0526a26ddd6e Save fastest rounds in Killing the specialists and Precise shooting missions
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   235
		if record ~= nil then
0526a26ddd6e Save fastest rounds in Killing the specialists and Precise shooting missions
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   236
			SendStat(siCustomAchievement, loc("This is a new personal best, congratulations!"))
0526a26ddd6e Save fastest rounds in Killing the specialists and Precise shooting missions
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   237
		end
0526a26ddd6e Save fastest rounds in Killing the specialists and Precise shooting missions
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   238
	end
12970
dc35a79c6ef9 Fix Killing the Specialists recording the turn count way too low
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   239
	-- An old version of this mission was buggy and stored a turn record WAY too low.
dc35a79c6ef9 Fix Killing the Specialists recording the turn count way too low
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   240
	-- Let's clear the broken variable (FastestSpecialistsKill) here.
dc35a79c6ef9 Fix Killing the Specialists recording the turn count way too low
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   241
	SaveCampaignVar("FastestSpecialistsKill", "")
11692
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9831
diff changeset
   242
	SendStat(siCustomAchievement, loc("The next 4 times you play the \"The last encounter\" mission you'll get 20 more hit points and a laser sight."))
12538
952afc3d2df2 Show correct kill counts in all ASA missions (fixes #147)
Wuzzy <almikes@aol.com>
parents: 12468
diff changeset
   243
	sendSimpleTeamRankings({teamA.name, teamB.name})
11952
63988f36debf Save mission success for A Space Adventure missions
Wuzzy <almikes@aol.com>
parents: 11892
diff changeset
   244
	SaveCampaignVar("Mission11Won", "true")
11965
72be38f6d0c0 Complete space campaign's spacetrip mission if all main+side missions are completed
Wuzzy <almikes@aol.com>
parents: 11952
diff changeset
   245
	checkAllMissionsCompleted()
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   246
	EndGame()
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   247
end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   248
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   249
------------ Other Functions -------------------
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   250
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   251
function shuffleHogs(hogs)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   252
    local hogsNumber = table.getn(hogs)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   253
    for i=1,hogsNumber do
9810
54c0fdec4600 changing math functions that may cause desyncs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9758
diff changeset
   254
		local randomHog = GetRandom(hogsNumber) + 1
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   255
		hogs[i], hogs[randomHog] = hogs[randomHog], hogs[i]
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   256
    end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   257
end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   258
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   259
function refreshHeroAmmo()
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   260
	local extraAmmo = 0
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   261
	if getAliveEnemiesCount() == 1 then
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   262
		extraAmmo = 2
12935
ff42888333bc Killing The Specialists mission: Fix misleading hints, add messages and visual effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12900
diff changeset
   263
		PlaySound(sndShotgunReload)
ff42888333bc Killing The Specialists mission: Fix misleading hints, add messages and visual effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12900
diff changeset
   264
		AddCaption(loc("Reinforcements! +2 of each weapon!"), GetClanColor(GetHogClan(hero.gear)), capgrpAmmoinfo)
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   265
	end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   266
	AddAmmo(hero.gear, amMortar, hero.mortarAmmo + extraAmmo)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   267
	AddAmmo(hero.gear, amFirePunch, hero.firepunchAmmo + extraAmmo)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   268
	AddAmmo(hero.gear, amDEagle, hero.deagleAmmo + extraAmmo)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   269
	AddAmmo(hero.gear, amBazooka, hero.bazookaAmmo + extraAmmo)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   270
	AddAmmo(hero.gear, amGrenade, hero.grenadeAmmo + extraAmmo)
12089
0183b4c448bf Fix Killing the Specialists giving you a free turn after killing Desert Eagle with a desert eagle with shot 1-3
Wuzzy <almikes@aol.com>
parents: 12088
diff changeset
   271
	heroWeaponResetPending = false
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   272
end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   273
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   274
function enemyWeapons()
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   275
	for i=1,table.getn(enemies) do
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   276
		if GetHealth(enemies[i].gear) and enemies[i].gear == CurrentHedgehog then
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   277
			AddAmmo(enemies[i].gear, amMortar, 0)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   278
			AddAmmo(enemies[i].gear, amFirePunch, 0)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   279
			AddAmmo(enemies[i].gear, amDEagle, 0)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   280
			AddAmmo(enemies[i].gear, amBazooka, 0)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   281
			AddAmmo(enemies[i].gear, amGrenade, 0)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   282
			AddAmmo(enemies[i].gear, enemies[i].weapon, 1)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   283
			for w=1,table.getn(enemies[i].additionalWeapons) do
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   284
				AddAmmo(enemies[i].gear, enemies[i].additionalWeapons[w], 1)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   285
			end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   286
		end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   287
	end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   288
end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   289
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   290
function isHog(gear)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   291
	local hog = false
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   292
	for i=1,table.getn(enemies) do
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   293
		if gear == enemies[i].gear then
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   294
			hog = true
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   295
			break
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   296
		end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   297
	end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   298
	return hog
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   299
end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   300
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   301
function getHog(gear)
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   302
	for i=1,table.getn(enemies) do
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   303
		if gear == enemies[i].gear then
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   304
			return enemies[i]
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   305
		end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   306
	end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   307
end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   308
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   309
function getAliveEnemiesCount()
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   310
	local count = 0
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   311
	for i=1,table.getn(enemies) do
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   312
		if GetHealth(enemies[i].gear) then
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   313
			count = count + 1
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   314
		end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   315
	end
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   316
	return count
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   317
end