share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert03.lua
author Wuzzy <Wuzzy2@mail.ru>
Tue, 28 May 2019 00:48:17 +0200
changeset 15073 6f51c75994a4
parent 15007 3ed1cbd31754
permissions -rw-r--r--
Semi-standardize usage of icons in many mission panels * Question mark: Decision / user input * Exclamation mark: Tutorial message / information * Hedgehog: Mission introduction * -amSkip: Mission failure * Star: Mission success / end of game
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     1
------------------- ABOUT ----------------------
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     2
--
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     3
-- Hero has to use the rc plane end perform some
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     4
-- flying tasks
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     5
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     6
HedgewarsScriptLoad("/Scripts/Locale.lua")
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     7
HedgewarsScriptLoad("/Scripts/Animate.lua")
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     8
HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua")
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     9
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    10
-- globals
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    11
local missionName = loc("Precise flying")
12431
9f3387907e06 Fix even more bad/broken loc()'s in scripts (hopefully the last one)
Wuzzy <almikes@aol.com>
parents: 12093
diff changeset
    12
local challengeObjectives = loc("Use the RC plane and destroy the all the targets.").."|"..
9f3387907e06 Fix even more bad/broken loc()'s in scripts (hopefully the last one)
Wuzzy <almikes@aol.com>
parents: 12093
diff changeset
    13
	loc("Each time you destroy all the targets on your current level you'll get teleported to the next level.").."|"..
9f3387907e06 Fix even more bad/broken loc()'s in scripts (hopefully the last one)
Wuzzy <almikes@aol.com>
parents: 12093
diff changeset
    14
	loc("You'll have only one RC plane at the start of the mission.").."|"..
9f3387907e06 Fix even more bad/broken loc()'s in scripts (hopefully the last one)
Wuzzy <almikes@aol.com>
parents: 12093
diff changeset
    15
	loc("During the game you can get new RC planes by collecting the weapon crates.")
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    16
local currentTarget = 1
9608
e2d4c2198e55 added captions with rules and objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9606
diff changeset
    17
-- dialogs
e2d4c2198e55 added captions with rules and objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9606
diff changeset
    18
local dialog01 = {}
e2d4c2198e55 added captions with rules and objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9606
diff changeset
    19
-- mission objectives
e2d4c2198e55 added captions with rules and objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9606
diff changeset
    20
local goals = {
12582
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12580
diff changeset
    21
	["init"] = {missionName, loc("Challenge objectives"), challengeObjectives, 1, 30000},
9608
e2d4c2198e55 added captions with rules and objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9606
diff changeset
    22
}
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    23
-- hogs
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    24
local hero = {
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    25
	name = loc("Hog Solo"),
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    26
	x = 100,
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    27
	y = 170
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    28
}
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    29
-- teams
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    30
local teamA = {
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    31
	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: 12938
diff changeset
    32
	color = -6
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    33
}
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    34
-- creates & targets
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    35
local rcCrates = {
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    36
	{ x = 1680, y = 240},
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    37
	{ x = 2810, y = 720},
9606
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
    38
	{ x = 2440, y = 660},
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
    39
	{ x = 256, y = 1090},
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    40
}
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    41
local targets = {
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    42
	{ x = 2070, y = 410},
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    43
	{ x = 3880, y = 1430},
9606
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
    44
	{ x = 4000, y = 1430},
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
    45
	{ x = 2190, y = 1160},
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
    46
	{ x = 2190, y = 1460},
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
    47
	{ x = 2110, y = 1700},
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
    48
	{ x = 2260, y = 1700},
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
    49
	{ x = 2085, y = 1330},
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
    50
	{ x = 156, y = 1400},
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
    51
	{ x = 324, y = 1400},
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
    52
	{ x = 660, y = 1310},
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
    53
	{ x = 1200, y = 1310},
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
    54
	{ x = 1700, y = 1310},
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    55
}
12569
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
    56
local targetsDead = {}
12568
8a9919381629 ASA, desert03: Change box appearance, don't lose as long there are still flames in game
Wuzzy <almikes@aol.com>
parents: 12544
diff changeset
    57
local flameCounter = 0
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    58
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    59
-------------- LuaAPI EVENT HANDLERS ------------------
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    60
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    61
function onGameInit()
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    62
	GameFlags = gfOneClanMode
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    63
	Seed = 1
13755
110d6c1e817f Lua: Rename globals: NoPointX→NO_CURSOR, cMaxTurnTime→MAX_TURN_TIME, cMaxHogHealth→MAX_HOG_HEALTH
Wuzzy <Wuzzy2@mail.ru>
parents: 13669
diff changeset
    64
	TurnTime = MAX_TURN_TIME
12582
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12580
diff changeset
    65
	Ready = 30000
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    66
	CaseFreq = 0
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    67
	MinesNum = 0
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    68
	MinesTime = 1
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    69
	Explosives = 0
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    70
	Map = "desert03_map"
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    71
	Theme = "Desert"
12473
d652c6f5d5f1 Disable Sudden Death for a couple of ASA missions
Wuzzy <almikes@aol.com>
parents: 12431
diff changeset
    72
	-- Disable SuddenDeath
d652c6f5d5f1 Disable Sudden Death for a couple of ASA missions
Wuzzy <almikes@aol.com>
parents: 12431
diff changeset
    73
	WaterRise = 0
d652c6f5d5f1 Disable Sudden Death for a couple of ASA missions
Wuzzy <almikes@aol.com>
parents: 12431
diff changeset
    74
	HealthDecrease = 0
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
    75
14493
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13755
diff changeset
    76
	-- Hero
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13755
diff changeset
    77
	teamA.name = AddMissionTeam(teamA.color)
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13755
diff changeset
    78
	hero.gear = AddMissionHog(1)
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13755
diff changeset
    79
	hero.name = GetHogName(hero.gear)
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    80
	AnimSetGearPosition(hero.gear, hero.x, hero.y)
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
    81
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    82
	initCheckpoint("desert03")
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
    83
12582
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12580
diff changeset
    84
	AnimInit()
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    85
end
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    86
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    87
function onGameStart()
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    88
	FollowGear(hero.gear)
12580
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12569
diff changeset
    89
	ShowMission(unpack(goals["init"]))
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    90
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    91
	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
9606
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
    92
	AddEvent(onLose, {hero.gear}, lose, {hero.gear}, 0)
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    93
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    94
	-- original crates and targets
12938
e65aa3c3d4e6 Refactor scripts to use SpawnSupplyCrate (where it makes sense)
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
    95
	SpawnSupplyCrate(rcCrates[1].x, rcCrates[1].y, amRCPlane)
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    96
	targets[1].gear = AddGear(targets[1].x, targets[1].y, gtTarget, 0, 0, 0, 0)
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
    97
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    98
	-- hero ammo
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    99
	AddAmmo(hero.gear, amRCPlane, 1)
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   100
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   101
	SendHealthStatsOff()
9608
e2d4c2198e55 added captions with rules and objectives
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9606
diff changeset
   102
	AddAnim(dialog01)
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   103
end
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   104
9606
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   105
function onGameTick()
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   106
	AnimUnWait()
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   107
	if ShowAnimation() == false then
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   108
		return
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   109
	end
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   110
	ExecuteAfterAnimations()
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   111
	CheckEvents()
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   112
end
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   113
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   114
function onGameTick20()
9610
fabff82cf0b8 win stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9608
diff changeset
   115
	checkTargetsDestroyed()
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   116
end
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   117
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   118
function onAmmoStoreInit()
9606
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   119
	SetAmmo(amNothing, 0, 0, 0, 0)
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   120
	SetAmmo(amRCPlane, 0, 0, 0, 1)
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   121
end
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   122
15007
3ed1cbd31754 Backed out changeset 4596357d002d (onPreciseLocal causes desyncs)
Wuzzy <Wuzzy2@mail.ru>
parents: 14903
diff changeset
   123
function onPrecise()
9606
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   124
	if GameTime > 3000 then
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
   125
		SetAnimSkip(true)
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   126
	end
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   127
end
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   128
12568
8a9919381629 ASA, desert03: Change box appearance, don't lose as long there are still flames in game
Wuzzy <almikes@aol.com>
parents: 12544
diff changeset
   129
function onGearAdd(gear)
8a9919381629 ASA, desert03: Change box appearance, don't lose as long there are still flames in game
Wuzzy <almikes@aol.com>
parents: 12544
diff changeset
   130
	if GetGearType(gear) == gtFlame then
8a9919381629 ASA, desert03: Change box appearance, don't lose as long there are still flames in game
Wuzzy <almikes@aol.com>
parents: 12544
diff changeset
   131
		flameCounter = flameCounter + 1
8a9919381629 ASA, desert03: Change box appearance, don't lose as long there are still flames in game
Wuzzy <almikes@aol.com>
parents: 12544
diff changeset
   132
	end
12580
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12569
diff changeset
   133
	if GetGearType(gear) == gtRCPlane then
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12569
diff changeset
   134
		HideMission()
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12569
diff changeset
   135
	end
12568
8a9919381629 ASA, desert03: Change box appearance, don't lose as long there are still flames in game
Wuzzy <almikes@aol.com>
parents: 12544
diff changeset
   136
end
8a9919381629 ASA, desert03: Change box appearance, don't lose as long there are still flames in game
Wuzzy <almikes@aol.com>
parents: 12544
diff changeset
   137
8a9919381629 ASA, desert03: Change box appearance, don't lose as long there are still flames in game
Wuzzy <almikes@aol.com>
parents: 12544
diff changeset
   138
function onGearDelete(gear)
8a9919381629 ASA, desert03: Change box appearance, don't lose as long there are still flames in game
Wuzzy <almikes@aol.com>
parents: 12544
diff changeset
   139
	if GetGearType(gear) == gtFlame then
8a9919381629 ASA, desert03: Change box appearance, don't lose as long there are still flames in game
Wuzzy <almikes@aol.com>
parents: 12544
diff changeset
   140
		flameCounter = flameCounter - 1
8a9919381629 ASA, desert03: Change box appearance, don't lose as long there are still flames in game
Wuzzy <almikes@aol.com>
parents: 12544
diff changeset
   141
	end
12569
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   142
	for t=1, #targets do
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   143
		if gear == targets[t].gear then
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   144
			targetsDead[t] = true
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   145
			break
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   146
		end
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   147
	end
12568
8a9919381629 ASA, desert03: Change box appearance, don't lose as long there are still flames in game
Wuzzy <almikes@aol.com>
parents: 12544
diff changeset
   148
end
8a9919381629 ASA, desert03: Change box appearance, don't lose as long there are still flames in game
Wuzzy <almikes@aol.com>
parents: 12544
diff changeset
   149
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   150
-------------- EVENTS ------------------
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   151
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   152
function onHeroDeath(gear)
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   153
	if not GetHealth(hero.gear) then
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   154
		return true
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   155
	end
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   156
	return false
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   157
end
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   158
9606
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   159
function onLose(gear)
12568
8a9919381629 ASA, desert03: Change box appearance, don't lose as long there are still flames in game
Wuzzy <almikes@aol.com>
parents: 12544
diff changeset
   160
	if GetHealth(hero.gear) and currentTarget < 4 and GetAmmoCount(hero.gear, amRCPlane) == 0 and flameCounter <= 0 then
9606
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   161
		return true
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   162
	end
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   163
	return false
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   164
end
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   165
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   166
-------------- ACTIONS ------------------
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   167
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   168
function heroDeath(gear)
9606
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   169
	gameOver()
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   170
end
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   171
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   172
function lose(gear)
13648
690cc84e9fd6 Use capcolDefault in Lua scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13588
diff changeset
   173
	AddCaption(loc("Out of ammo!"), capcolDefault, capgrpMessage2)
12568
8a9919381629 ASA, desert03: Change box appearance, don't lose as long there are still flames in game
Wuzzy <almikes@aol.com>
parents: 12544
diff changeset
   174
	PlaySound(sndStupid, hero.gear)
9606
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   175
	gameOver()
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   176
end
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   177
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   178
----------------- Other Functions -----------------
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   179
9610
fabff82cf0b8 win stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9608
diff changeset
   180
function checkTargetsDestroyed()
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   181
	if currentTarget == 1 then
12569
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   182
		if targetsDead[1] then
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   183
			AddCaption(loc("Level 1 clear!"))
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   184
			SetGearPosition(hero.gear, 3590, 90)
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   185
			currentTarget = 2
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   186
			setTargets(currentTarget)
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   187
		end
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   188
	elseif currentTarget == 2 then
12569
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   189
		if targetsDead[2] and targetsDead[3] then
9606
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   190
			AddCaption(loc("Level 2 clear!"))
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   191
			SetGearPosition(hero.gear, 1110, 580)
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   192
			currentTarget = 3
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   193
			setTargets(currentTarget)
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   194
		end
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   195
	elseif currentTarget == 3 then
12569
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   196
		local allDead = true
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   197
		for t=3, #targets do
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   198
			if targetsDead[t] ~= true then
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   199
				allDead = false
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   200
			end
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   201
		end
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   202
		if allDead then
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   203
			currentTarget = 4
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   204
			win()
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   205
		end
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   206
	end
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   207
end
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   208
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   209
function setTargets(ct)
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   210
	if ct == 2 then
12938
e65aa3c3d4e6 Refactor scripts to use SpawnSupplyCrate (where it makes sense)
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   211
		SpawnSupplyCrate(rcCrates[2].x, rcCrates[2].y, amRCPlane)
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   212
		for i=2,3 do
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   213
			targets[i].gear = AddGear(targets[i].x, targets[i].y, gtTarget, 0, 0, 0, 0)
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   214
		end
9606
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   215
	elseif ct == 3 then
12568
8a9919381629 ASA, desert03: Change box appearance, don't lose as long there are still flames in game
Wuzzy <almikes@aol.com>
parents: 12544
diff changeset
   216
		SpawnUtilityCrate(rcCrates[4].x, rcCrates[4].y, amNothing)
12938
e65aa3c3d4e6 Refactor scripts to use SpawnSupplyCrate (where it makes sense)
Wuzzy <Wuzzy2@mail.ru>
parents: 12592
diff changeset
   217
		SpawnSupplyCrate(rcCrates[3].x, rcCrates[3].y, amRCPlane, 2)
9606
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   218
		for i=4,13 do
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   219
			targets[i].gear = AddGear(targets[i].x, targets[i].y, gtTarget, 0, 0, 0, 0)
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   220
		end
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   221
	end
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   222
end
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   223
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   224
function win()
12569
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   225
	AddCaption(loc("Victory!"))
6a8c90a53249 ASA,desert03: Fix no victory after destroying all targets
Wuzzy <almikes@aol.com>
parents: 12568
diff changeset
   226
	PlaySound(sndVictory, hero.gear)
9630
df942cfac4e6 add bonuses
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9610
diff changeset
   227
	saveBonus(1, 1)
9642
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9631
diff changeset
   228
	SendStat(siGameResult, loc("Congratulations, you are the best!"))
11697
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9758
diff changeset
   229
	SendStat(siCustomAchievement, loc("You have destroyed all the targets."))
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9758
diff changeset
   230
	SendStat(siCustomAchievement, loc("You are indeed the best PAotH pilot."))
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9758
diff changeset
   231
	SendStat(siCustomAchievement, loc("Next time you play \"Searching in the dust\" you'll have an RC plane available."))
12544
19192a3cb674 Use correct kill counts for the remaining ASA missions as well
Wuzzy <almikes@aol.com>
parents: 12543
diff changeset
   232
	sendSimpleTeamRankings({teamA.name})
11957
63988f36debf Save mission success for A Space Adventure missions
Wuzzy <almikes@aol.com>
parents: 11697
diff changeset
   233
	SaveCampaignVar("Mission12Won", "true")
11970
72be38f6d0c0 Complete space campaign's spacetrip mission if all main+side missions are completed
Wuzzy <almikes@aol.com>
parents: 11957
diff changeset
   234
	checkAllMissionsCompleted()
9605
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   235
	EndGame()
66cd14e5bdad part of desert03 side mission - map not finished yet, will be commited later
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   236
end
9606
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   237
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   238
function gameOver()
14493
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13755
diff changeset
   239
	SendStat(siGameResult, string.format(loc("%s lost, try again!"), hero.name))
11697
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9758
diff changeset
   240
	SendStat(siCustomAchievement, loc("You have to destroy all the targets."))
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9758
diff changeset
   241
	SendStat(siCustomAchievement, loc("You will fail if you run out of ammo and there are still targets available."))
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 9758
diff changeset
   242
	SendStat(siCustomAchievement, loc("Read the challenge objectives from within the mission for more details."))
12544
19192a3cb674 Use correct kill counts for the remaining ASA missions as well
Wuzzy <almikes@aol.com>
parents: 12543
diff changeset
   243
	sendSimpleTeamRankings({teamA.name})
9606
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   244
	EndGame()
1d088cc31ff8 mission mechanioncs seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9605
diff changeset
   245
end