share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua
author Wuzzy <Wuzzy2@mail.ru>
Sat, 29 Sep 2018 21:59:36 +0200
changeset 13819 25de751feb02
parent 13745 2bb7141496a9
child 14493 7bb7e5e54f70
permissions -rw-r--r--
ASA, ice02: Fix recorded time being 6 seconds more than reality
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     1
------------------- ABOUT ----------------------
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     2
--
9831
afa4e3e04cc5 typos correction
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9810
diff changeset
     3
-- Hero has get into an Red Strawberries ambush
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     4
-- He has to eliminate the enemies by using limited
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     5
-- ammo of sniper rifle and watermelon
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     6
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     7
HedgewarsScriptLoad("/Scripts/Locale.lua")
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     8
HedgewarsScriptLoad("/Scripts/Animate.lua")
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     9
HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua")
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    10
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    11
----------------- VARIABLES --------------------
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    12
-- globals
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    13
local missionName = loc("Precise shooting")
12227
6ffb18cf4c57 Add infinite skipping in fruit03 mission
Wuzzy <almikes@aol.com>
parents: 12093
diff changeset
    14
local timeLeft = 0
6ffb18cf4c57 Add infinite skipping in fruit03 mission
Wuzzy <almikes@aol.com>
parents: 12093
diff changeset
    15
local lastWeaponUsed = amNothing
6ffb18cf4c57 Add infinite skipping in fruit03 mission
Wuzzy <almikes@aol.com>
parents: 12093
diff changeset
    16
local firstTurn = true
12580
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12578
diff changeset
    17
local battleStarted = false
11697
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9831
diff changeset
    18
local challengeObjectives = loc("Use your available weapons in order to eliminate the enemies.").."|"..
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9831
diff changeset
    19
	loc("You can only use the sniper rifle or the watermelon bomb.").."|"..
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9831
diff changeset
    20
	loc("You'll have only 2 watermelon bombs during the game.").."|"..
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9831
diff changeset
    21
	loc("You'll get an extra sniper rifle every time you kill an enemy hog with a limit of max 4 rifles.").."|"..
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9831
diff changeset
    22
	loc("You'll get an extra teleport every time you kill an enemy hog with a limit of max 2 teleports.").."|"..
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9831
diff changeset
    23
	loc("The first turn will last 25 sec and every other turn 15 sec.").."|"..
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9831
diff changeset
    24
	loc("If you skip a turn then the turn time left will be added to your next turn.").."|"..
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9831
diff changeset
    25
	loc("Some parts of the land are indestructible.")
9596
feb3d880852d added challenge objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9595
diff changeset
    26
-- dialogs
feb3d880852d added challenge objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9595
diff changeset
    27
local dialog01 = {}
feb3d880852d added challenge objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9595
diff changeset
    28
-- mission objectives
feb3d880852d added challenge objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9595
diff changeset
    29
local goals = {
12582
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12580
diff changeset
    30
	["init"] = {missionName, loc("Challenge objectives"), challengeObjectives, 1, 35000},
9596
feb3d880852d added challenge objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9595
diff changeset
    31
}
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    32
-- hogs
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    33
local hero = {
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    34
	name = loc("Hog Solo"),
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
    35
	x = 1100,
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
    36
	y = 560
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    37
}
12976
f306a0c2899c Fix incorrect round counting in fruit03, too
Wuzzy <Wuzzy2@mail.ru>
parents: 12913
diff changeset
    38
local heroTurns = 0
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    39
local enemiesOdd = {
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9600
diff changeset
    40
	{name = loc("Hog 1"), x = 2000 , y = 175},
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9600
diff changeset
    41
	{name = loc("Hog III"), x = 1950 , y = 1110},
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9600
diff changeset
    42
	{name = loc("Hog 100"), x = 1270 , y = 1480},
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9600
diff changeset
    43
	{name = loc("Hog Saturn"), x = 240 , y = 790},
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9600
diff changeset
    44
	{name = loc("Hog nueve"), x = 620 , y = 1950},
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9600
diff changeset
    45
	{name = loc("Hog onze"), x = 720 , y = 1950},
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9600
diff changeset
    46
	{name = loc("Hog dertien"), x = 1620 , y = 1950},
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9600
diff changeset
    47
	{name = loc("Hog 3x5"), x = 1720 , y = 1950},
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    48
}
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    49
local enemiesEven = {
9601
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9600
diff changeset
    50
	{name = loc("Hog two"), x = 660, y = 140},
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9600
diff changeset
    51
	{name = loc("Hog D"), x = 1120, y = 1250},
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9600
diff changeset
    52
	{name = loc("Hog exi"), x = 1290, y = 1250},
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9600
diff changeset
    53
	{name = loc("Hog octo"), x = 820, y = 1950},
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9600
diff changeset
    54
	{name = loc("Hog decar"), x = 920, y = 1950},
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9600
diff changeset
    55
	{name = loc("Hog Hephaestus"), x = 1820, y = 1950},
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9600
diff changeset
    56
	{name = loc("Hog 7+7"), x = 1920, y = 1950},
6af4ca27421a added death planet side mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9600
diff changeset
    57
	{name = loc("Hog EOF"), x = 1200, y = 560},
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    58
}
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    59
-- teams
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    60
local teamA = {
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    61
	name = loc("Hog Solo"),
13588
141cdfe0f3ca Switch almost all Lua calls of AddTeam to using default clan colors instead of hardcoded color
Wuzzy <Wuzzy2@mail.ru>
parents: 12976
diff changeset
    62
	color = -6
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    63
}
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    64
local teamB = {
12578
a778c1bb032e ASA: Explain team abbreviations + update changelog
Wuzzy <almikes@aol.com>
parents: 12543
diff changeset
    65
	-- Red Strawberries 1
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    66
	name = loc("RS1"),
13588
141cdfe0f3ca Switch almost all Lua calls of AddTeam to using default clan colors instead of hardcoded color
Wuzzy <Wuzzy2@mail.ru>
parents: 12976
diff changeset
    67
	color = -1
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    68
}
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    69
local teamC = {
12578
a778c1bb032e ASA: Explain team abbreviations + update changelog
Wuzzy <almikes@aol.com>
parents: 12543
diff changeset
    70
	-- Red Strawberries 2
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    71
	name = loc("RS2"),
13588
141cdfe0f3ca Switch almost all Lua calls of AddTeam to using default clan colors instead of hardcoded color
Wuzzy <Wuzzy2@mail.ru>
parents: 12976
diff changeset
    72
	color = -1
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    73
}
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    74
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    75
-------------- LuaAPI EVENT HANDLERS ------------------
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    76
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    77
function onGameInit()
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    78
	GameFlags = gfDisableWind + gfInfAttack
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    79
	Seed = 1
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
    80
	TurnTime = 15000
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    81
	CaseFreq = 0
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    82
	MinesNum = 0
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    83
	MinesTime = 1
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    84
	Explosives = 0
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    85
	Map = "fruit03_map"
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    86
	Theme = "Fruit"
12473
d652c6f5d5f1 Disable Sudden Death for a couple of ASA missions
Wuzzy <almikes@aol.com>
parents: 12227
diff changeset
    87
	-- Disable Sudden Death
d652c6f5d5f1 Disable Sudden Death for a couple of ASA missions
Wuzzy <almikes@aol.com>
parents: 12227
diff changeset
    88
	WaterRise = 0
d652c6f5d5f1 Disable Sudden Death for a couple of ASA missions
Wuzzy <almikes@aol.com>
parents: 12227
diff changeset
    89
	HealthDecrease = 0
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
    90
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    91
	-- Hog Solo
12592
0b27d8b4f8e7 Use Default voice in A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 12591
diff changeset
    92
	AddTeam(teamA.name, teamA.color, "Simple", "Island", "Default", "hedgewars")
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    93
	hero.gear = AddHog(hero.name, 0, 100, "war_desertgrenadier1")
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    94
	AnimSetGearPosition(hero.gear, hero.x, hero.y)
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    95
	-- enemies
9598
5c378d7d2e4d image, description and hats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9597
diff changeset
    96
	local hats = { "Bandit", "fr_apple", "fr_banana", "fr_lemon", "fr_orange",
5c378d7d2e4d image, description and hats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9597
diff changeset
    97
					"fr_pumpkin", "Gasmask", "NinjaFull", "NinjaStraight", "NinjaTriangle" }
12592
0b27d8b4f8e7 Use Default voice in A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 12591
diff changeset
    98
	AddTeam(teamC.name, teamC.color, "bp2", "Island", "Default", "cm_bars")
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    99
	for i=1,table.getn(enemiesEven) do
9810
54c0fdec4600 changing math functions that may cause desyncs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9758
diff changeset
   100
		enemiesEven[i].gear = AddHog(enemiesEven[i].name, 1, 100, hats[GetRandom(table.getn(hats))+1])
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   101
		AnimSetGearPosition(enemiesEven[i].gear, enemiesEven[i].x, enemiesEven[i].y)
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
   102
	end
12592
0b27d8b4f8e7 Use Default voice in A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 12591
diff changeset
   103
	AddTeam(teamB.name, teamB.color, "bp2", "Island", "Default", "cm_bars")
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   104
	for i=1,table.getn(enemiesOdd) do
9810
54c0fdec4600 changing math functions that may cause desyncs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9758
diff changeset
   105
		enemiesOdd[i].gear = AddHog(enemiesOdd[i].name, 1, 100, hats[GetRandom(table.getn(hats))+1])
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   106
		AnimSetGearPosition(enemiesOdd[i].gear, enemiesOdd[i].x, enemiesOdd[i].y)
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   107
	end
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
   108
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   109
	initCheckpoint("fruit03")
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
   110
12582
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12580
diff changeset
   111
	AnimInit()
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   112
end
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   113
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   114
function onGameStart()
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   115
	FollowGear(hero.gear)
12580
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12578
diff changeset
   116
	ShowMission(unpack(goals["init"]))
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
   117
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   118
	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
9597
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   119
	AddEvent(onHeroWin, {hero.gear}, heroWin, {hero.gear}, 0)
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
   120
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   121
	--hero ammo
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   122
	AddAmmo(hero.gear, amTeleport, 2)
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   123
	AddAmmo(hero.gear, amSniperRifle, 2)
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   124
	AddAmmo(hero.gear, amWatermelon, 2)
12582
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12580
diff changeset
   125
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12580
diff changeset
   126
	AddAmmo(hero.gear, amSkip, 100)
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12580
diff changeset
   127
	timeLeft = 0
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12580
diff changeset
   128
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   129
	--enemies ammo
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   130
	AddAmmo(enemiesOdd[1].gear, amDEagle, 100)
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   131
	AddAmmo(enemiesOdd[1].gear, amSniperRifle, 100)
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   132
	AddAmmo(enemiesOdd[1].gear, amWatermelon, 1)
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   133
	AddAmmo(enemiesOdd[1].gear, amGrenade, 5)
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   134
	AddAmmo(enemiesEven[1].gear, amDEagle, 100)
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   135
	AddAmmo(enemiesEven[1].gear, amSniperRifle, 100)
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   136
	AddAmmo(enemiesEven[1].gear, amWatermelon, 1)
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   137
	AddAmmo(enemiesEven[1].gear, amGrenade, 5)
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
   138
12976
f306a0c2899c Fix incorrect round counting in fruit03, too
Wuzzy <Wuzzy2@mail.ru>
parents: 12913
diff changeset
   139
	turnHogs()
f306a0c2899c Fix incorrect round counting in fruit03, too
Wuzzy <Wuzzy2@mail.ru>
parents: 12913
diff changeset
   140
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   141
	SendHealthStatsOff()
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   142
end
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   143
9592
a39cb287e83e a bug fix
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9591
diff changeset
   144
function onNewTurn()
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   145
	if CurrentHedgehog == hero.gear then
12227
6ffb18cf4c57 Add infinite skipping in fruit03 mission
Wuzzy <almikes@aol.com>
parents: 12093
diff changeset
   146
		if firstTurn then
12583
5b23c42ef150 ASA fruit03: Fix skipping not adding to turn time in next turn
Wuzzy <almikes@aol.com>
parents: 12582
diff changeset
   147
			-- Unique game rule in this mission: First turn has more time
13745
2bb7141496a9 Use SetTurnTimeLeft and SetReadyTimeLeft in all scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13690
diff changeset
   148
			SetTurnTimeLeft(25000)
12582
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12580
diff changeset
   149
			-- Generous ready time on first turn to give more time to read
13745
2bb7141496a9 Use SetTurnTimeLeft and SetReadyTimeLeft in all scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13690
diff changeset
   150
			SetReadyTimeLeft(35000)
12580
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12578
diff changeset
   151
			battleStarted = true
12582
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12580
diff changeset
   152
			firstTurn = false
12227
6ffb18cf4c57 Add infinite skipping in fruit03 mission
Wuzzy <almikes@aol.com>
parents: 12093
diff changeset
   153
		end
6ffb18cf4c57 Add infinite skipping in fruit03 mission
Wuzzy <almikes@aol.com>
parents: 12093
diff changeset
   154
		if lastWeaponUsed == amSkip then
13745
2bb7141496a9 Use SetTurnTimeLeft and SetReadyTimeLeft in all scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13690
diff changeset
   155
			SetTurnTimeLeft(TurnTime + timeLeft)
9594
749ef5bd0eaf fixed the time adding in new hero turn
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9593
diff changeset
   156
		end
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   157
		timeLeft = 0
12976
f306a0c2899c Fix incorrect round counting in fruit03, too
Wuzzy <Wuzzy2@mail.ru>
parents: 12913
diff changeset
   158
		heroTurns = heroTurns + 1
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   159
	end
9592
a39cb287e83e a bug fix
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9591
diff changeset
   160
end
a39cb287e83e a bug fix
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9591
diff changeset
   161
9596
feb3d880852d added challenge objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9595
diff changeset
   162
function onGameTick()
feb3d880852d added challenge objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9595
diff changeset
   163
	AnimUnWait()
feb3d880852d added challenge objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9595
diff changeset
   164
	if ShowAnimation() == false then
feb3d880852d added challenge objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9595
diff changeset
   165
		return
feb3d880852d added challenge objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9595
diff changeset
   166
	end
feb3d880852d added challenge objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9595
diff changeset
   167
	ExecuteAfterAnimations()
feb3d880852d added challenge objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9595
diff changeset
   168
	CheckEvents()
feb3d880852d added challenge objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9595
diff changeset
   169
end
feb3d880852d added challenge objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9595
diff changeset
   170
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   171
function onGameTick20()
9594
749ef5bd0eaf fixed the time adding in new hero turn
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9593
diff changeset
   172
	if CurrentHedgehog == hero.gear and TurnTimeLeft ~= 0 then
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   173
		timeLeft = TurnTimeLeft
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   174
	end
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   175
end
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   176
12911
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   177
-- Display ammo icon above gear. i = offset (start at 1)
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   178
local function displayAmmoIcon(gear, ammoType, i)
12913
9abb04174323 Precise Shooting mission: Fix Lua errors when enemy dies after hero
Wuzzy <Wuzzy2@mail.ru>
parents: 12911
diff changeset
   179
	if not GetHealth(gear) then
9abb04174323 Precise Shooting mission: Fix Lua errors when enemy dies after hero
Wuzzy <Wuzzy2@mail.ru>
parents: 12911
diff changeset
   180
		return
9abb04174323 Precise Shooting mission: Fix Lua errors when enemy dies after hero
Wuzzy <Wuzzy2@mail.ru>
parents: 12911
diff changeset
   181
	end
12911
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   182
	local x = GetX(gear) + 2
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   183
	local y = GetY(gear) + 32 * i
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   184
	local vgear = AddVisualGear(x, y, vgtAmmo, 0, true)
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   185
	if vgear ~= nil then
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   186
		local vgtFrame = ammoType
13690
09ea1faf97ca Remove calls to GetVisualGearValues where it's not needed
Wuzzy <Wuzzy2@mail.ru>
parents: 13588
diff changeset
   187
		SetVisualGearValues(vgear,nil,nil,nil,nil,nil,vgtFrame)
12911
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   188
	end
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   189
end
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   190
9600
7daf157d8b52 fix check if deleted gear is hog
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9599
diff changeset
   191
function onGearDelete(gear)
12913
9abb04174323 Precise Shooting mission: Fix Lua errors when enemy dies after hero
Wuzzy <Wuzzy2@mail.ru>
parents: 12911
diff changeset
   192
	if (isEnemyHog(gear) and GetHealth(hero.gear)) then
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   193
		local availableTeleports = GetAmmoCount(hero.gear,amTeleport)
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   194
		local availableSniper = GetAmmoCount(hero.gear,amSniperRifle)
12911
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   195
		local ammolist = ""
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   196
		local tele = false
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   197
		if availableTeleports < 2 then
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   198
			AddAmmo(hero.gear, amTeleport, availableTeleports + 1 )
12911
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   199
			displayAmmoIcon(hero.gear, amTeleport, 1)
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   200
			tele = true
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   201
			ammolist = ammolist .. string.format(loc("%s (+1)"), GetAmmoName(amTeleport))
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   202
		end
9600
7daf157d8b52 fix check if deleted gear is hog
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9599
diff changeset
   203
		if availableSniper < 4 then
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   204
			AddAmmo(hero.gear, amSniperRifle, availableSniper + 1 )
12911
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   205
			displayAmmoIcon(hero.gear, amSniperRifle, 2)
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   206
			if tele then
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   207
				ammolist = ammolist .. " • "
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   208
			end
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   209
			ammolist = ammolist .. string.format(loc("%s (+1)"), GetAmmoName(amSniperRifle))
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   210
		end
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   211
		-- Show collected ammo
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   212
		if ammolist ~= "" then
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   213
			PlaySound(sndShotgunReload)
4ea0691d0ad5 ASA: Fruit03: Show collected ammo
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   214
			AddCaption(ammolist, GetClanColor(GetHogClan(hero.gear)), capgrpAmmoinfo)
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   215
		end
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   216
	end
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   217
end
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   218
12580
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12578
diff changeset
   219
-- Hide mission panel when player does anything
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12578
diff changeset
   220
function hideMissionOnAction()
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12578
diff changeset
   221
	if battleStarted then
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12578
diff changeset
   222
		HideMission()
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12578
diff changeset
   223
	end
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12578
diff changeset
   224
end
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12578
diff changeset
   225
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12578
diff changeset
   226
onSlot = hideMissionOnAction
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12578
diff changeset
   227
onSetWeapon = hideMissionOnAction
12583
5b23c42ef150 ASA fruit03: Fix skipping not adding to turn time in next turn
Wuzzy <almikes@aol.com>
parents: 12582
diff changeset
   228
onAttack = hideMissionOnAction
5b23c42ef150 ASA fruit03: Fix skipping not adding to turn time in next turn
Wuzzy <almikes@aol.com>
parents: 12582
diff changeset
   229
function onHogAttack(ammoType)
5b23c42ef150 ASA fruit03: Fix skipping not adding to turn time in next turn
Wuzzy <almikes@aol.com>
parents: 12582
diff changeset
   230
	hideMissionOnAction()
5b23c42ef150 ASA fruit03: Fix skipping not adding to turn time in next turn
Wuzzy <almikes@aol.com>
parents: 12582
diff changeset
   231
	if CurrentHedgehog == hero.gear then
5b23c42ef150 ASA fruit03: Fix skipping not adding to turn time in next turn
Wuzzy <almikes@aol.com>
parents: 12582
diff changeset
   232
		lastWeaponUsed = ammoType
5b23c42ef150 ASA fruit03: Fix skipping not adding to turn time in next turn
Wuzzy <almikes@aol.com>
parents: 12582
diff changeset
   233
	end
5b23c42ef150 ASA fruit03: Fix skipping not adding to turn time in next turn
Wuzzy <almikes@aol.com>
parents: 12582
diff changeset
   234
end
9596
feb3d880852d added challenge objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9595
diff changeset
   235
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   236
-------------- EVENTS ------------------
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   237
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   238
function onHeroDeath(gear)
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   239
	if not GetHealth(hero.gear) then
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   240
		return true
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   241
	end
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   242
	return false
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   243
end
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   244
9597
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   245
function onHeroWin(gear)
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   246
	local enemies = enemiesOdd
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   247
	for i=1,table.getn(enemiesEven) do
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   248
		table.insert(enemies, enemiesEven[i])
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   249
	end
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   250
	local allDead = true
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   251
	for i=1,table.getn(enemies) do
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   252
		if GetHealth(enemies[i].gear) then
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   253
			allDead = false
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   254
			break
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   255
		end
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   256
	end
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   257
	return allDead
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   258
end
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   259
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   260
-------------- ACTIONS ------------------
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   261
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   262
function heroDeath(gear)
9642
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9631
diff changeset
   263
	SendStat(siGameResult, loc("Hog Solo lost, try again!"))
11697
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9831
diff changeset
   264
	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
   265
	SendStat(siCustomAchievement, loc("Read the challenge objectives from within the mission for more details."))
12543
952afc3d2df2 Show correct kill counts in all ASA missions (fixes #147)
Wuzzy <almikes@aol.com>
parents: 12519
diff changeset
   266
	sendSimpleTeamRankings({teamB.name, teamC.name, teamA.name})
9597
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   267
	EndGame()
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   268
end
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   269
83fa1ba837b8 add custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9596
diff changeset
   270
function heroWin(gear)
9630
df942cfac4e6 add bonuses
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9601
diff changeset
   271
	saveBonus(2, 1)
9642
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9631
diff changeset
   272
	SendStat(siGameResult, loc("Congratulations, you won!"))
12976
f306a0c2899c Fix incorrect round counting in fruit03, too
Wuzzy <Wuzzy2@mail.ru>
parents: 12913
diff changeset
   273
	SendStat(siCustomAchievement, string.format(loc("You completed the mission in %d rounds."), heroTurns))
11897
0526a26ddd6e Save fastest rounds in Killing the specialists and Precise shooting missions
Wuzzy <almikes@aol.com>
parents: 11697
diff changeset
   274
	local record = tonumber(GetCampaignVar("FastestPreciseShooting"))
12976
f306a0c2899c Fix incorrect round counting in fruit03, too
Wuzzy <Wuzzy2@mail.ru>
parents: 12913
diff changeset
   275
	if record ~= nil and heroTurns >= record then
11897
0526a26ddd6e Save fastest rounds in Killing the specialists and Precise shooting missions
Wuzzy <almikes@aol.com>
parents: 11697
diff changeset
   276
		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: 11697
diff changeset
   277
	end
12976
f306a0c2899c Fix incorrect round counting in fruit03, too
Wuzzy <Wuzzy2@mail.ru>
parents: 12913
diff changeset
   278
	if record == nil or heroTurns < record then
f306a0c2899c Fix incorrect round counting in fruit03, too
Wuzzy <Wuzzy2@mail.ru>
parents: 12913
diff changeset
   279
		SaveCampaignVar("FastestPreciseShooting", tostring(heroTurns))
11897
0526a26ddd6e Save fastest rounds in Killing the specialists and Precise shooting missions
Wuzzy <almikes@aol.com>
parents: 11697
diff changeset
   280
		if record ~= nil then
0526a26ddd6e Save fastest rounds in Killing the specialists and Precise shooting missions
Wuzzy <almikes@aol.com>
parents: 11697
diff changeset
   281
			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: 11697
diff changeset
   282
		end
0526a26ddd6e Save fastest rounds in Killing the specialists and Precise shooting missions
Wuzzy <almikes@aol.com>
parents: 11697
diff changeset
   283
	end
11697
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9831
diff changeset
   284
	SendStat(siCustomAchievement, loc("You will gain some extra ammo from the crates the next time you play the \"Getting to the device\" mission."))
12543
952afc3d2df2 Show correct kill counts in all ASA missions (fixes #147)
Wuzzy <almikes@aol.com>
parents: 12519
diff changeset
   285
	sendSimpleTeamRankings({teamA.name, teamB.name, teamC.name})
11957
63988f36debf Save mission success for A Space Adventure missions
Wuzzy <almikes@aol.com>
parents: 11897
diff changeset
   286
	SaveCampaignVar("Mission10Won", "true")
11970
72be38f6d0c0 Complete space campaign's spacetrip mission if all main+side missions are completed
Wuzzy <almikes@aol.com>
parents: 11957
diff changeset
   287
	checkAllMissionsCompleted()
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   288
	EndGame()
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   289
end
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   290
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   291
------------------ Other Functions -------------------
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   292
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   293
function turnHogs()
9592
a39cb287e83e a bug fix
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9591
diff changeset
   294
	if GetHealth(hero.gear) then
a39cb287e83e a bug fix
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9591
diff changeset
   295
		for i=1,table.getn(enemiesEven) do
a39cb287e83e a bug fix
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9591
diff changeset
   296
			if GetHealth(enemiesEven[i].gear) then
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   297
				if GetX(enemiesEven[i].gear) < GetX(hero.gear) then
9592
a39cb287e83e a bug fix
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9591
diff changeset
   298
					HogTurnLeft(enemiesEven[i].gear, false)
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   299
				elseif GetX(enemiesEven[i].gear) > GetX(hero.gear) then
9592
a39cb287e83e a bug fix
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9591
diff changeset
   300
					HogTurnLeft(enemiesEven[i].gear, true)
a39cb287e83e a bug fix
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9591
diff changeset
   301
				end
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   302
			end
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   303
		end
9592
a39cb287e83e a bug fix
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9591
diff changeset
   304
		for i=1,table.getn(enemiesOdd) do
a39cb287e83e a bug fix
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9591
diff changeset
   305
			if GetHealth(enemiesOdd[i].gear) then
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   306
				if GetX(enemiesOdd[i].gear) < GetX(hero.gear) then
9592
a39cb287e83e a bug fix
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9591
diff changeset
   307
					HogTurnLeft(enemiesOdd[i].gear, false)
9593
ac522dd06f00 changed map and fixed some bugs regarding hog turning and adding more teleport
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9592
diff changeset
   308
				elseif GetX(enemiesOdd[i].gear) > GetX(hero.gear) then
9592
a39cb287e83e a bug fix
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9591
diff changeset
   309
					HogTurnLeft(enemiesOdd[i].gear, true)
a39cb287e83e a bug fix
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9591
diff changeset
   310
				end
9590
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   311
			end
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   312
		end
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   313
	end
347e799f01de fruit side mission map and some logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   314
end
9596
feb3d880852d added challenge objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9595
diff changeset
   315
12913
9abb04174323 Precise Shooting mission: Fix Lua errors when enemy dies after hero
Wuzzy <Wuzzy2@mail.ru>
parents: 12911
diff changeset
   316
function isEnemyHog(gear)
9abb04174323 Precise Shooting mission: Fix Lua errors when enemy dies after hero
Wuzzy <Wuzzy2@mail.ru>
parents: 12911
diff changeset
   317
	for i=1, table.getn(enemiesOdd) do
9600
7daf157d8b52 fix check if deleted gear is hog
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9599
diff changeset
   318
		if gear == enemiesOdd[i].gear then
12913
9abb04174323 Precise Shooting mission: Fix Lua errors when enemy dies after hero
Wuzzy <Wuzzy2@mail.ru>
parents: 12911
diff changeset
   319
			return true
9600
7daf157d8b52 fix check if deleted gear is hog
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9599
diff changeset
   320
		end
7daf157d8b52 fix check if deleted gear is hog
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9599
diff changeset
   321
	end
12913
9abb04174323 Precise Shooting mission: Fix Lua errors when enemy dies after hero
Wuzzy <Wuzzy2@mail.ru>
parents: 12911
diff changeset
   322
	for i=1, table.getn(enemiesEven) do
9abb04174323 Precise Shooting mission: Fix Lua errors when enemy dies after hero
Wuzzy <Wuzzy2@mail.ru>
parents: 12911
diff changeset
   323
		if gear == enemiesEven then
9abb04174323 Precise Shooting mission: Fix Lua errors when enemy dies after hero
Wuzzy <Wuzzy2@mail.ru>
parents: 12911
diff changeset
   324
			return true
9600
7daf157d8b52 fix check if deleted gear is hog
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9599
diff changeset
   325
		end
7daf157d8b52 fix check if deleted gear is hog
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9599
diff changeset
   326
	end
12913
9abb04174323 Precise Shooting mission: Fix Lua errors when enemy dies after hero
Wuzzy <Wuzzy2@mail.ru>
parents: 12911
diff changeset
   327
	return false
9600
7daf157d8b52 fix check if deleted gear is hog
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9599
diff changeset
   328
end