share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/final.lua
author Wuzzy <Wuzzy2@mail.ru>
Sat, 18 May 2019 16:54:51 +0200
changeset 15023 3ed1cbd31754
parent 14919 4596357d002d
child 15088 d59da429d22c
permissions -rw-r--r--
Backed out changeset 4596357d002d (onPreciseLocal causes desyncs)
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!").."|"..
13574
9c83afd65e8c ASA, final mission: Redraw map and mask to make borders more distingushable
Wuzzy <Wuzzy2@mail.ru>
parents: 12933
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: 12933
diff changeset
    17
							loc("Areas with a green dashed outline are portal-proof.").."|"..
12226
3ec0261e01f0 Display mines timer in all missions with non-default timer
Wuzzy <almikes@aol.com>
parents: 12049
diff changeset
    18
							loc("Mines time: 0 seconds")
12594
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
    19
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
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"),
13583
141cdfe0f3ca Switch almost all Lua calls of AddTeam to using default clan colors instead of hardcoded color
Wuzzy <Wuzzy2@mail.ru>
parents: 13574
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
13752
110d6c1e817f Lua: Rename globals: NoPointX→NO_CURSOR, cMaxTurnTime→MAX_TURN_TIME, cMaxHogHealth→MAX_HOG_HEALTH
Wuzzy <Wuzzy2@mail.ru>
parents: 13664
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"
12468
d652c6f5d5f1 Disable Sudden Death for a couple of ASA missions
Wuzzy <almikes@aol.com>
parents: 12226
diff changeset
    49
	-- Disable Sudden Death
d652c6f5d5f1 Disable Sudden Death for a couple of ASA missions
Wuzzy <almikes@aol.com>
parents: 12226
diff changeset
    50
	WaterRise = 0
d652c6f5d5f1 Disable Sudden Death for a couple of ASA missions
Wuzzy <almikes@aol.com>
parents: 12226
diff changeset
    51
	HealthDecrease = 0
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9642
diff changeset
    52
14509
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13799
diff changeset
    53
	-- Hero
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13799
diff changeset
    54
	teamA.name = AddMissionTeam(teamA.color)
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13799
diff changeset
    55
	hero.gear = AddMissionHog(1)
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13799
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)
13574
9c83afd65e8c ASA, final mission: Redraw map and mask to make borders more distingushable
Wuzzy <Wuzzy2@mail.ru>
parents: 12933
diff changeset
    67
	ShowMission(missionName, loc("Challenge objectives"), challengeObjectives, -amSkip, 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
12933
e65aa3c3d4e6 Refactor scripts to use SpawnSupplyCrate (where it makes sense)
Wuzzy <Wuzzy2@mail.ru>
parents: 12594
diff changeset
    85
	SpawnSupplyCrate(930, 1000, amRCPlane)
e65aa3c3d4e6 Refactor scripts to use SpawnSupplyCrate (where it makes sense)
Wuzzy <Wuzzy2@mail.ru>
parents: 12594
diff changeset
    86
	SpawnSupplyCrate(1260, 652, amGirder)
e65aa3c3d4e6 Refactor scripts to use SpawnSupplyCrate (where it makes sense)
Wuzzy <Wuzzy2@mail.ru>
parents: 12594
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)
12594
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
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: 12587
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)
12594
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
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: 12587
diff changeset
   119
		heroWin(hero.gear)
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
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
12594
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   138
function onBoom(gear)
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   139
	local win = true
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   140
	for i=1,table.getn(explosives) do
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   141
		if GetHealth(explosives[i]) then
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   142
			win = false
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   143
			break
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   144
		end
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
	if currentHealth <= currentDamage then
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   147
		win = false
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   148
	end
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   149
	return win
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   150
end
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   151
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   152
-------------- ACTIONS ------------------
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   153
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   154
function heroDeath(gear)
14509
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13799
diff changeset
   155
	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
   156
	SendStat(siCustomAchievement, loc("You have to destroy all the explosives without dying!"))
13574
9c83afd65e8c ASA, final mission: Redraw map and mask to make borders more distingushable
Wuzzy <Wuzzy2@mail.ru>
parents: 12933
diff changeset
   157
	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: 12933
diff changeset
   158
	SendStat(siCustomAchievement, loc("Areas surrounded by a green dashed outline are portal-proof and repel portals."))
12539
19192a3cb674 Use correct kill counts for the remaining ASA missions as well
Wuzzy <almikes@aol.com>
parents: 12538
diff changeset
   159
	sendSimpleTeamRankings({teamA.name})
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   160
	EndGame()
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   161
end
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   162
12594
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   163
function heroBoomReaction(gear)
13799
baf15d31cd42 ASA, final: Don't say "missed" or "yes sir" after blowing up barrels
Wuzzy <Wuzzy2@mail.ru>
parents: 13752
diff changeset
   164
	SetSoundMask(sndMissed, true)
baf15d31cd42 ASA, final: Don't say "missed" or "yes sir" after blowing up barrels
Wuzzy <Wuzzy2@mail.ru>
parents: 13752
diff changeset
   165
	SetSoundMask(sndYesSir, true)
12594
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   166
	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: 12587
diff changeset
   167
		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: 12587
diff changeset
   168
	end
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   169
end
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   170
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   171
function heroWin(gear)
12594
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   172
	AddAnim(dialog01)
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   173
end
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   174
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   175
function win()
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   176
	SetWeapon(amNothing)
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   177
	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
   178
	saveCompletedStatus(7)
11949
079d687671b2 Store campaign victories in campaign variable "Won"
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   179
	SaveCampaignVar("Won", "true")
11965
72be38f6d0c0 Complete space campaign's spacetrip mission if all main+side missions are completed
Wuzzy <almikes@aol.com>
parents: 11952
diff changeset
   180
	checkAllMissionsCompleted()
9642
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9634
diff changeset
   181
	SendStat(siGameResult, loc("Congratulations, you have saved Hogera!"))
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9634
diff changeset
   182
	SendStat(siCustomAchievement, loc("Hogera is safe!"))
12539
19192a3cb674 Use correct kill counts for the remaining ASA missions as well
Wuzzy <almikes@aol.com>
parents: 12538
diff changeset
   183
	sendSimpleTeamRankings({teamA.name})
9634
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   184
	EndGame()
8032df67a249 custom stats and win/lose events
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9632
diff changeset
   185
end
12594
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   186
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   187
------------ ANIMATION STUFF ------------
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   188
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   189
function Skipanim(anim)
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   190
	if anim == dialog01 then
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   191
		win()
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   192
	end
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   193
end
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   194
15023
3ed1cbd31754 Backed out changeset 4596357d002d (onPreciseLocal causes desyncs)
Wuzzy <Wuzzy2@mail.ru>
parents: 14919
diff changeset
   195
function onPrecise()
12594
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   196
	if GameTime > 3000 then
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   197
		SetAnimSkip(true)
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   198
	end
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   199
end
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   200
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   201
function AnimationSetup()
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   202
	-- DIALOG 01 - Start, welcome to moon
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   203
	AddSkipFunction(dialog01, Skipanim, {dialog01})
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   204
	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: 12587
diff changeset
   205
	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: 12587
diff changeset
   206
	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: 12587
diff changeset
   207
	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: 12587
diff changeset
   208
	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: 12587
diff changeset
   209
	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: 12587
diff changeset
   210
	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: 12587
diff changeset
   211
	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: 12587
diff changeset
   212
	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: 12587
diff changeset
   213
	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: 12587
diff changeset
   214
        -- Hogerian =  Inhabitant of the planet Hogera
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   215
	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: 12587
diff changeset
   216
	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: 12587
diff changeset
   217
	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: 12587
diff changeset
   218
	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: 12587
diff changeset
   219
	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: 12587
diff changeset
   220
	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: 12587
diff changeset
   221
	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: 12587
diff changeset
   222
end
d8adae379d3c A Space Adventure: Add outro sequence / epilogue in the final mission
Wuzzy <almikes@aol.com>
parents: 12587
diff changeset
   223