share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/final.lua
author sheepluva
Sun, 08 Dec 2019 02:09:19 +0100
branchhedgeroid
changeset 15520 de08a3ae4f8d
parent 15086 3a561db2a71c
permissions -rw-r--r--
hedgeroid/frontlib: update proto and weapons number
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9632
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     1
------------------- ABOUT ----------------------
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     2
--
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     3
-- Hero has collected all the anti-gravity device
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     4
-- parts but because of the size of the meteorite
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     5
-- he needs to detonate some faulty explosives that
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     6
-- PAotH have previously placed on it.
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     7
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     8
HedgewarsScriptLoad("/Scripts/Locale.lua")
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     9
HedgewarsScriptLoad("/Scripts/Animate.lua")
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    10
HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua")
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    11
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    12
----------------- VARIABLES --------------------
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    13
-- globals
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    14
local missionName = loc("The big bang")
9781
5eb7c3778045 removed bouncy terrain, added visual mark on non-portal/indestructible areas, changed map so only way to win is by using the portal gun
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9758
diff changeset
    15
local challengeObjectives = loc("Find a way to detonate all the explosives and stay alive!").."|"..
13579
9c83afd65e8c ASA, final mission: Redraw map and mask to make borders more distingushable
Wuzzy <Wuzzy2@mail.ru>
parents: 12938
diff changeset
    16
							loc("Areas with a security outline are indestructible.").."|"..
9c83afd65e8c ASA, final mission: Redraw map and mask to make borders more distingushable
Wuzzy <Wuzzy2@mail.ru>
parents: 12938
diff changeset
    17
							loc("Areas with a green dashed outline are portal-proof.").."|"..
12231
3ec0261e01f0 Display mines timer in all missions with non-default timer
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
    18
							loc("Mines time: 0 seconds")
12599
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
    19
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
    20
local dialog01 = {}
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
    21
local explosives = {}
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
    22
local currentHealth = 1
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
    23
local currentDamage = 0
9632
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    24
-- hogs
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    25
local hero = {
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    26
	name = loc("Hog Solo"),
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    27
	x = 790,
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    28
	y = 70
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    29
}
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    30
-- teams
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    31
local teamA = {
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    32
	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: 13579
diff changeset
    33
	color = -6
9632
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    34
}
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    35
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    36
-------------- LuaAPI EVENT HANDLERS ------------------
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    37
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    38
function onGameInit()
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    39
	GameFlags = gfDisableWind + gfOneClanMode
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    40
	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
    41
	TurnTime = MAX_TURN_TIME
9632
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    42
	CaseFreq = 0
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    43
	MinesNum = 0
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    44
	MinesTime = 1
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    45
	Explosives = 0
9781
5eb7c3778045 removed bouncy terrain, added visual mark on non-portal/indestructible areas, changed map so only way to win is by using the portal gun
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9758
diff changeset
    46
	HealthCaseAmount = 35
9632
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    47
	Map = "final_map"
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    48
	Theme = "EarthRise"
12473
d652c6f5d5f1 Disable Sudden Death for a couple of ASA missions
Wuzzy <almikes@aol.com>
parents: 12231
diff changeset
    49
	-- Disable Sudden Death
d652c6f5d5f1 Disable Sudden Death for a couple of ASA missions
Wuzzy <almikes@aol.com>
parents: 12231
diff changeset
    50
	WaterRise = 0
d652c6f5d5f1 Disable Sudden Death for a couple of ASA missions
Wuzzy <almikes@aol.com>
parents: 12231
diff changeset
    51
	HealthDecrease = 0
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
    52
14493
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13775
diff changeset
    53
	-- Hero
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13775
diff changeset
    54
	teamA.name = AddMissionTeam(teamA.color)
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13775
diff changeset
    55
	hero.gear = AddMissionHog(1)
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13775
diff changeset
    56
	hero.name = GetHogName(hero.gear)
9632
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    57
	AnimSetGearPosition(hero.gear, hero.x, hero.y)
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
    58
9632
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    59
	initCheckpoint("final")
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
    60
9632
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    61
	AnimInit()
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    62
end
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    63
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    64
function onGameStart()
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    65
	AnimWait(hero.gear, 3000)
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    66
	FollowGear(hero.gear)
15072
d59da429d22c Add 2 mission panel icons: hedgehog and flags
Wuzzy <Wuzzy2@mail.ru>
parents: 15007
diff changeset
    67
	ShowMission(missionName, loc("Objectives"), challengeObjectives, 1, 7500)
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
    68
9632
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    69
	-- explosives
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    70
	x = 400
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    71
	while x < 815 do
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
    72
		local gear = AddGear(x, 500, gtExplosives, 0, 0, 0, 0)
9810
54c0fdec4600 changing math functions that may cause desyncs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9802
diff changeset
    73
		x = x + GetRandom(26) + 15
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
    74
		table.insert(explosives, gear)
9632
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    75
	end
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    76
	-- mines
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    77
	local x = 360
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    78
	while x < 815 do
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    79
		AddGear(x, 480, gtMine, 0, 0, 0, 0)
9810
54c0fdec4600 changing math functions that may cause desyncs
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9802
diff changeset
    80
		x = x + GetRandom(16) + 5
9632
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    81
	end
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
    82
	-- health crate
9781
5eb7c3778045 removed bouncy terrain, added visual mark on non-portal/indestructible areas, changed map so only way to win is by using the portal gun
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9758
diff changeset
    83
	SpawnHealthCrate(910, 5)
9632
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    84
	-- ammo crates
12938
e65aa3c3d4e6 Refactor scripts to use SpawnSupplyCrate (where it makes sense)
Wuzzy <Wuzzy2@mail.ru>
parents: 12599
diff changeset
    85
	SpawnSupplyCrate(930, 1000, amRCPlane)
e65aa3c3d4e6 Refactor scripts to use SpawnSupplyCrate (where it makes sense)
Wuzzy <Wuzzy2@mail.ru>
parents: 12599
diff changeset
    86
	SpawnSupplyCrate(1260, 652, amGirder)
e65aa3c3d4e6 Refactor scripts to use SpawnSupplyCrate (where it makes sense)
Wuzzy <Wuzzy2@mail.ru>
parents: 12599
diff changeset
    87
	SpawnSupplyCrate(1220, 652, amPickHammer)
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
    88
9632
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    89
	-- ammo
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
    90
	AddAmmo(hero.gear, amPortalGun, 1)
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
    91
	AddAmmo(hero.gear, amFirePunch, 1)
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
    92
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
    93
	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
12599
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
    94
	AddEvent(onBoom, {hero.gear}, heroBoomReaction, {hero.gear}, 0)
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
    95
	AnimationSetup()
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
    96
9632
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    97
	SendHealthStatsOff()
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    98
end
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    99
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   100
function onGameTick()
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   101
	AnimUnWait()
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   102
	if ShowAnimation() == false then
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   103
		return
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   104
	end
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   105
	ExecuteAfterAnimations()
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   106
	CheckEvents()
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   107
end
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   108
9632
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   109
function onAmmoStoreInit()
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   110
	SetAmmo(amRCPlane, 0, 0, 0, 1)
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   111
	SetAmmo(amPickHammer, 0, 0, 0, 2)
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   112
	SetAmmo(amGirder, 0, 0, 0, 1)
9dd1c36d8b54 final mission map and most logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   113
end
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   114
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   115
function onNewTurn()
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   116
	currentDamage = 0
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   117
	currentHealth = GetHealth(hero.gear)
12599
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   118
	if onBoom(hero.gear) then
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   119
		heroWin(hero.gear)
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   120
	end
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   121
end
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   122
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   123
function onGearDamage(gear, damage)
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   124
	if gear == hero.gear then
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   125
		currentDamage = currentDamage + damage
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   126
	end
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   127
end
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   128
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   129
-------------- EVENTS ------------------
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   130
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   131
function onHeroDeath(gear)
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   132
	if not GetHealth(hero.gear) then
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   133
		return true
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   134
	end
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   135
	return false
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   136
end
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   137
12599
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   138
function onBoom(gear)
15086
3a561db2a71c ASA: Check if hero is still alive before claiming victory
Wuzzy <Wuzzy2@mail.ru>
parents: 15072
diff changeset
   139
	if (not IsHogAlive(gear)) or (not StoppedGear(gear)) then
3a561db2a71c ASA: Check if hero is still alive before claiming victory
Wuzzy <Wuzzy2@mail.ru>
parents: 15072
diff changeset
   140
		return false
3a561db2a71c ASA: Check if hero is still alive before claiming victory
Wuzzy <Wuzzy2@mail.ru>
parents: 15072
diff changeset
   141
	end
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   142
	for i=1,table.getn(explosives) do
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   143
		if GetHealth(explosives[i]) then
15086
3a561db2a71c ASA: Check if hero is still alive before claiming victory
Wuzzy <Wuzzy2@mail.ru>
parents: 15072
diff changeset
   144
			return false
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   145
		end
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   146
	end
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   147
	if currentHealth <= currentDamage then
15086
3a561db2a71c ASA: Check if hero is still alive before claiming victory
Wuzzy <Wuzzy2@mail.ru>
parents: 15072
diff changeset
   148
		return false
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   149
	end
15086
3a561db2a71c ASA: Check if hero is still alive before claiming victory
Wuzzy <Wuzzy2@mail.ru>
parents: 15072
diff changeset
   150
	return true
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   151
end
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   152
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   153
-------------- ACTIONS ------------------
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   154
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   155
function heroDeath(gear)
14493
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13775
diff changeset
   156
	SendStat(siGameResult, string.format(loc("%s lost, try again!"), hero.name))
9642
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9634
diff changeset
   157
	SendStat(siCustomAchievement, loc("You have to destroy all the explosives without dying!"))
13579
9c83afd65e8c ASA, final mission: Redraw map and mask to make borders more distingushable
Wuzzy <Wuzzy2@mail.ru>
parents: 12938
diff changeset
   158
	SendStat(siCustomAchievement, loc("Areas surrounded by a security border are indestructible."))
9c83afd65e8c ASA, final mission: Redraw map and mask to make borders more distingushable
Wuzzy <Wuzzy2@mail.ru>
parents: 12938
diff changeset
   159
	SendStat(siCustomAchievement, loc("Areas surrounded by a green dashed outline are portal-proof and repel portals."))
12544
19192a3cb674 Use correct kill counts for the remaining ASA missions as well
Wuzzy <almikes@aol.com>
parents: 12543
diff changeset
   160
	sendSimpleTeamRankings({teamA.name})
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   161
	EndGame()
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   162
end
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   163
12599
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   164
function heroBoomReaction(gear)
13775
baf15d31cd42 ASA, final: Don't say "missed" or "yes sir" after blowing up barrels
Wuzzy <Wuzzy2@mail.ru>
parents: 13755
diff changeset
   165
	SetSoundMask(sndMissed, true)
baf15d31cd42 ASA, final: Don't say "missed" or "yes sir" after blowing up barrels
Wuzzy <Wuzzy2@mail.ru>
parents: 13755
diff changeset
   166
	SetSoundMask(sndYesSir, true)
12599
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   167
	if GetHealth(gear) and GetHealth(gear) > 0 then
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   168
		HogSay(gear, loc("Kaboom! Hahahaha! Take this, stupid meteorite!"), SAY_SHOUT, 2)
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   169
	end
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   170
end
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   171
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   172
function heroWin(gear)
12599
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   173
	AddAnim(dialog01)
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   174
end
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   175
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   176
function win()
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   177
	SetWeapon(amNothing)
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   178
	AnimSetInputMask(0)
9802
00216d609140 desert01 fixed destructible terrain marks and cosmos marks for completed main missions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9781
diff changeset
   179
	saveCompletedStatus(7)
11954
079d687671b2 Store campaign victories in campaign variable "Won"
Wuzzy <almikes@aol.com>
parents: 11697
diff changeset
   180
	SaveCampaignVar("Won", "true")
11970
72be38f6d0c0 Complete space campaign's spacetrip mission if all main+side missions are completed
Wuzzy <almikes@aol.com>
parents: 11957
diff changeset
   181
	checkAllMissionsCompleted()
9642
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9634
diff changeset
   182
	SendStat(siGameResult, loc("Congratulations, you have saved Hogera!"))
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9634
diff changeset
   183
	SendStat(siCustomAchievement, loc("Hogera is safe!"))
12544
19192a3cb674 Use correct kill counts for the remaining ASA missions as well
Wuzzy <almikes@aol.com>
parents: 12543
diff changeset
   184
	sendSimpleTeamRankings({teamA.name})
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   185
	EndGame()
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   186
end
12599
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   187
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   188
------------ ANIMATION STUFF ------------
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   189
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   190
function Skipanim(anim)
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   191
	if anim == dialog01 then
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   192
		win()
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   193
	end
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   194
end
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   195
15007
3ed1cbd31754 Backed out changeset 4596357d002d (onPreciseLocal causes desyncs)
Wuzzy <Wuzzy2@mail.ru>
parents: 14903
diff changeset
   196
function onPrecise()
12599
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   197
	if GameTime > 3000 then
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   198
		SetAnimSkip(true)
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   199
	end
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   200
end
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   201
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   202
function AnimationSetup()
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   203
	-- DIALOG 01 - Start, welcome to moon
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   204
	AddSkipFunction(dialog01, Skipanim, {dialog01})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   205
	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 100}})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   206
	table.insert(dialog01, {func = FollowGear, args = {hero.gear}})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   207
	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Hooray! I actually did it! Hogera is safe!"), SAY_SHOUT, 3000}})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   208
	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("I'm so glad this is finally over!"), SAY_SAY, 3000}})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   209
	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 4000}})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   210
	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Wait a moment …"), SAY_THINK, 2000}})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   211
	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("If some good old explosives were enough to save Hogera …"), SAY_THINK, 5000}})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   212
	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("… why did I risk my life to collect all the parts of the anti-gravity device?"), SAY_THINK, 6000}})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   213
	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("It was completely useless!"), SAY_THINK, 3000}})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   214
	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("We could just have blown up the meteorite from the the beginning!"), SAY_THINK, 5000}})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   215
        -- Hogerian =  Inhabitant of the planet Hogera
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   216
	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Stupid, stupid Hogerians!"), SAY_SAY, 5000}})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   217
	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Or maybe this was all part of an evil plan, so evil that even Prof. Hogevil can't think of it!"), SAY_THINK, 9000}})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   218
	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Nah, probably everyone was just stupid."), SAY_THINK, 4000}})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   219
	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Except me, of course! I just saved a whole planet!"), SAY_THINK, 5000}})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   220
	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("But one thing's for sure:"), SAY_THINK, 4000}})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   221
	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Hogera is definitely the last planet I saved!"), SAY_THINK, 4000}})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   222
	table.insert(dialog01, {func = win, args = {hero.gear}})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   223
end
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12592
diff changeset
   224