share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert02.lua
author Wuzzy <Wuzzy2@mail.ru>
Fri, 21 Dec 2018 23:17:10 +0100
changeset 14522 4e7fbbdca061
parent 14509 7bb7e5e54f70
child 14596 28d00ceb8b54
permissions -rw-r--r--
ASA cosmos: Remove unneccary message when hero dies after moon was reached
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     1
------------------- ABOUT ----------------------
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     2
--
9471
867f020b0621 seems ok, stats to be added
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9469
diff changeset
     3
-- Hero has to get to the surface as soon as possible.
867f020b0621 seems ok, stats to be added
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9469
diff changeset
     4
-- Tunnel is about to get flooded.
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     5
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     6
HedgewarsScriptLoad("/Scripts/Locale.lua")
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     7
HedgewarsScriptLoad("/Scripts/Animate.lua")
13839
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
     8
HedgewarsScriptLoad("/Scripts/Achievements.lua")
9582
bf314b2258b3 less variables used to save the checkpoints - potential breakage xD
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9574
diff changeset
     9
HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua")
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    10
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    11
----------------- VARIABLES --------------------
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    12
-- globals
9574
da3d39667881 strings checked, all ok except ice02 that will be probably changed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9490
diff changeset
    13
local missionName = loc("Running for survival")
9474
c255f6c46e33 stats and minor corrections, difficulty adjustment
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9471
diff changeset
    14
local startChallenge = false
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    15
-- dialogs
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    16
local dialog01 = {}
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    17
-- mission objectives
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    18
local goals = {
12227
5afbffc6725d Fix bad mission texts in A Space Adventure
Wuzzy <almikes@aol.com>
parents: 12226
diff changeset
    19
	[dialog01] = {missionName, loc("Getting ready"), loc("Use the rope to quickly get to the surface!") .. "|" .. loc("Mines time: 1 second"), 1, 4500},
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    20
}
13839
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
    21
-- For an achievement/award (see below)
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
    22
local cratesCollected = 0
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
    23
local totalCrates = 0
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
    24
local damageTaken = false
9490
b93448b75fa4 fix bugs and some changes regarting the difficulty in desert02
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
    25
-- health crates
b93448b75fa4 fix bugs and some changes regarting the difficulty in desert02
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
    26
healthX = 565
b93448b75fa4 fix bugs and some changes regarting the difficulty in desert02
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
    27
health1Y = 1400
b93448b75fa4 fix bugs and some changes regarting the difficulty in desert02
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
    28
health2Y = 850
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    29
-- hogs
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    30
local hero = {}
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    31
-- teams
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    32
local teamA = {}
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    33
-- hedgehogs values
9574
da3d39667881 strings checked, all ok except ice02 that will be probably changed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9490
diff changeset
    34
hero.name = loc("Hog Solo")
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    35
hero.x = 1600
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    36
hero.y = 1950
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    37
hero.dead = false
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    38
teamA.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: 12587
diff changeset
    39
teamA.color = -6
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    40
-- way points
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    41
local current waypoint = 1
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9645
diff changeset
    42
local waypoints = {
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    43
	[1] = {x=1450, y=140},
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    44
	[2] = {x=990, y=580},
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    45
	[3] = {x=1650, y=950},
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    46
	[4] = {x=620, y=630},
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    47
	[5] = {x=1470, y=540},
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    48
	[6] = {x=1960, y=60},
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    49
	[7] = {x=1600, y=400},
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    50
	[8] = {x=240, y=940},
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    51
	[9] = {x=200, y=530},
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    52
	[10] = {x=1180, y=120},
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    53
	[11] = {x=1950, y=660},
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    54
	[12] = {x=1280, y=980},
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    55
	[13] = {x=590, y=1100},
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    56
	[14] = {x=20, y=620},
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    57
	[15] = {x=hero.x, y=hero.y}
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    58
}
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    59
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    60
-------------- LuaAPI EVENT HANDLERS ------------------
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    61
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    62
function onGameInit()
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    63
	GameFlags = gfOneClanMode
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    64
	Seed = 1
9474
c255f6c46e33 stats and minor corrections, difficulty adjustment
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9471
diff changeset
    65
	TurnTime = 8000
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    66
	CaseFreq = 0
9490
b93448b75fa4 fix bugs and some changes regarting the difficulty in desert02
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
    67
	HealthCaseAmount = 50
9471
867f020b0621 seems ok, stats to be added
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9469
diff changeset
    68
	MinesNum = 500
867f020b0621 seems ok, stats to be added
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9469
diff changeset
    69
	MinesTime = 1000
867f020b0621 seems ok, stats to be added
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9469
diff changeset
    70
	MineDudPercent = 75
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    71
	Explosives = 0
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    72
	SuddenDeathTurns = 1
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    73
	WaterRise = 150
9490
b93448b75fa4 fix bugs and some changes regarting the difficulty in desert02
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
    74
	HealthDecrease = 0
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    75
	Map = "desert02_map"
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    76
	Theme = "Desert"
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9645
diff changeset
    77
14509
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 14422
diff changeset
    78
	-- Hero
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 14422
diff changeset
    79
	teamA.name = AddMissionTeam(teamA.color)
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 14422
diff changeset
    80
	hero.gear = AddMissionHog(100)
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 14422
diff changeset
    81
	hero.name = GetHogName(hero.gear)
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    82
	AnimSetGearPosition(hero.gear, hero.x, hero.y)
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    83
	HogTurnLeft(hero.gear, true)
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9645
diff changeset
    84
9582
bf314b2258b3 less variables used to save the checkpoints - potential breakage xD
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9574
diff changeset
    85
	initCheckpoint("desert02")
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9645
diff changeset
    86
12088
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12049
diff changeset
    87
	AnimInit(true)
9490
b93448b75fa4 fix bugs and some changes regarting the difficulty in desert02
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
    88
	AnimationSetup()
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    89
end
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    90
12469
2041d1e98ab2 Allow skipping in two ASA missions
Wuzzy <almikes@aol.com>
parents: 12227
diff changeset
    91
function onAmmoStoreInit()
2041d1e98ab2 Allow skipping in two ASA missions
Wuzzy <almikes@aol.com>
parents: 12227
diff changeset
    92
	SetAmmo(amRope, 9, 0, 0, 0)
2041d1e98ab2 Allow skipping in two ASA missions
Wuzzy <almikes@aol.com>
parents: 12227
diff changeset
    93
	SetAmmo(amSkip, 9, 0, 0, 0)
2041d1e98ab2 Allow skipping in two ASA missions
Wuzzy <almikes@aol.com>
parents: 12227
diff changeset
    94
end
2041d1e98ab2 Allow skipping in two ASA missions
Wuzzy <almikes@aol.com>
parents: 12227
diff changeset
    95
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    96
function onGameStart()
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    97
	AnimWait(hero.gear, 3000)
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    98
	FollowGear(hero.gear)
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9645
diff changeset
    99
12575
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12539
diff changeset
   100
	ShowMission(unpack(goals[dialog01]))
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12539
diff changeset
   101
	HideMission()
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12539
diff changeset
   102
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   103
	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
9471
867f020b0621 seems ok, stats to be added
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9469
diff changeset
   104
	AddEvent(onHeroSafe, {hero.gear}, heroSafe, {hero.gear}, 0)
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9645
diff changeset
   105
9490
b93448b75fa4 fix bugs and some changes regarting the difficulty in desert02
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   106
	SpawnHealthCrate(healthX, health1Y)
b93448b75fa4 fix bugs and some changes regarting the difficulty in desert02
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   107
	SpawnHealthCrate(healthX, health2Y)
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9645
diff changeset
   108
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   109
	SendHealthStatsOff()
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   110
	AddAnim(dialog01)
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   111
end
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   112
9645
da7b4d8c181e autoselect weapon in time challenges
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9642
diff changeset
   113
function onNewTurn()
10289
c3a77ff02a23 lua api: SetWeapon(ammoType)
sheepluva
parents: 9758
diff changeset
   114
	SetWeapon(amRope)
9645
da7b4d8c181e autoselect weapon in time challenges
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9642
diff changeset
   115
end
da7b4d8c181e autoselect weapon in time challenges
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9642
diff changeset
   116
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   117
function onGameTick()
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   118
	AnimUnWait()
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   119
	if ShowAnimation() == false then
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   120
		return
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   121
	end
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   122
	ExecuteAfterAnimations()
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   123
	CheckEvents()
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   124
end
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   125
12575
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12539
diff changeset
   126
function onGearAdd(gear)
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12539
diff changeset
   127
	if GetGearType(gear) == gtRope then
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12539
diff changeset
   128
		HideMission()
13839
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   129
	elseif GetGearType(gear) == gtCase then
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   130
		totalCrates = totalCrates + 1
12575
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12539
diff changeset
   131
	end
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12539
diff changeset
   132
end
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12539
diff changeset
   133
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   134
function onGearDelete(gear)
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   135
	if gear == hero.gear then
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   136
		hero.dead = true
13839
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   137
		damageTaken = true
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   138
	end
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   139
	-- Crate collected
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   140
	if GetGearType(gear) == gtCase and band(GetGearMessage(gear), gmDestroy) ~= 0 then
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   141
		cratesCollected = cratesCollected + 1
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   142
	end
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   143
end
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   144
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   145
function onGearDamage(gear)
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   146
	if gear == hero.gear then
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   147
		damageTaken = true
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   148
	end
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   149
end
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   150
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   151
function onPrecise()
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   152
	if GameTime > 3000 then
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9645
diff changeset
   153
		SetAnimSkip(true)
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   154
	end
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   155
end
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   156
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   157
-------------- EVENTS ------------------
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   158
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   159
function onHeroDeath(gear)
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   160
	if hero.dead then
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   161
		return true
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   162
	end
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   163
	return false
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   164
end
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   165
9469
6896f9298b80 event for win
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9467
diff changeset
   166
function onHeroSafe(gear)
9474
c255f6c46e33 stats and minor corrections, difficulty adjustment
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9471
diff changeset
   167
	if not hero.dead and GetY(hero.gear) < 170 and StoppedGear(hero.gear) then
9469
6896f9298b80 event for win
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9467
diff changeset
   168
		return true
6896f9298b80 event for win
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9467
diff changeset
   169
	end
6896f9298b80 event for win
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9467
diff changeset
   170
	return false
6896f9298b80 event for win
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9467
diff changeset
   171
end
6896f9298b80 event for win
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9467
diff changeset
   172
9639
6b2ae2eaf1b2 remove unnecessary comments
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9582
diff changeset
   173
-------------- ACTIONS ------------------
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   174
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   175
function heroDeath(gear)
14509
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 14422
diff changeset
   176
	SendStat(siGameResult, string.format(loc("%s lost, try again!"), hero.name))
11692
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 10289
diff changeset
   177
	SendStat(siCustomAchievement, loc("To win the game you have to go to the surface."))
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 10289
diff changeset
   178
	SendStat(siCustomAchievement, loc("Most mines are not active."))
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 10289
diff changeset
   179
	SendStat(siCustomAchievement, loc("From the second turn and beyond the water rises."))
12539
19192a3cb674 Use correct kill counts for the remaining ASA missions as well
Wuzzy <almikes@aol.com>
parents: 12514
diff changeset
   180
	sendSimpleTeamRankings({teamA.name})
9471
867f020b0621 seems ok, stats to be added
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9469
diff changeset
   181
	EndGame()
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   182
end
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   183
9469
6896f9298b80 event for win
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9467
diff changeset
   184
function heroSafe(gear)
9642
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9639
diff changeset
   185
	SendStat(siGameResult, loc("Congratulations, you won!"))
11692
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 10289
diff changeset
   186
	SendStat(siCustomAchievement, loc("You have escaped successfully."))
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 10289
diff changeset
   187
	SendStat(siCustomAchievement, string.format(loc("Your escape took you %d turns."), TotalRounds))
11890
712e20a3d895 Save some records in campaign vars: Hard flying, Running for survival
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   188
	local record = tonumber(GetCampaignVar("FastestMineEscape"))
712e20a3d895 Save some records in campaign vars: Hard flying, Running for survival
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   189
	if record ~= nil and TotalRounds >= record then
712e20a3d895 Save some records in campaign vars: Hard flying, Running for survival
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   190
		SendStat(siCustomAchievement, string.format(loc("Your fastest escape so far: %d turns"), record))
712e20a3d895 Save some records in campaign vars: Hard flying, Running for survival
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   191
	end
712e20a3d895 Save some records in campaign vars: Hard flying, Running for survival
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   192
	if record == nil or TotalRounds < record then
712e20a3d895 Save some records in campaign vars: Hard flying, Running for survival
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   193
		SaveCampaignVar("FastestMineEscape", tostring(TotalRounds))
712e20a3d895 Save some records in campaign vars: Hard flying, Running for survival
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   194
		if record ~= nil then
712e20a3d895 Save some records in campaign vars: Hard flying, Running for survival
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   195
			SendStat(siCustomAchievement, loc("This is a new personal best, congratulations!"))
712e20a3d895 Save some records in campaign vars: Hard flying, Running for survival
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   196
		end
712e20a3d895 Save some records in campaign vars: Hard flying, Running for survival
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   197
	end
13839
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   198
	-- Achievement awarded for escaping with all crates collected and no damage taken
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   199
	if (not damageTaken) and (cratesCollected >= totalCrates) then
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   200
		awardAchievement(loc("Better Safe Than Sorry"))
373813316812 ASA, desert02: Add achievement for escaping with all crates collected and no damage taken
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   201
	end
12539
19192a3cb674 Use correct kill counts for the remaining ASA missions as well
Wuzzy <almikes@aol.com>
parents: 12514
diff changeset
   202
	sendSimpleTeamRankings({teamA.name})
11952
63988f36debf Save mission success for A Space Adventure missions
Wuzzy <almikes@aol.com>
parents: 11890
diff changeset
   203
	SaveCampaignVar("Mission7Won", "true")
11965
72be38f6d0c0 Complete space campaign's spacetrip mission if all main+side missions are completed
Wuzzy <almikes@aol.com>
parents: 11952
diff changeset
   204
	checkAllMissionsCompleted()
9469
6896f9298b80 event for win
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9467
diff changeset
   205
	EndGame()
6896f9298b80 event for win
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9467
diff changeset
   206
end
6896f9298b80 event for win
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9467
diff changeset
   207
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   208
-------------- ANIMATIONS ------------------
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   209
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   210
function Skipanim(anim)
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   211
	if goals[anim] ~= nil then
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   212
		ShowMission(unpack(goals[anim]))
12575
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12539
diff changeset
   213
	end
9474
c255f6c46e33 stats and minor corrections, difficulty adjustment
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9471
diff changeset
   214
	challengeStart()
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   215
end
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   216
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   217
function AnimationSetup()
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   218
	-- DIALOG 01 - Start
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   219
	AddSkipFunction(dialog01, Skipanim, {dialog01})
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   220
	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 3000}})
11692
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 10289
diff changeset
   221
	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("Many meters below the surface ..."), 5000}})
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 10289
diff changeset
   222
	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("The tunnel is about to get flooded!"), SAY_THINK, 4000}})
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 10289
diff changeset
   223
	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("I have to reach the surface as quickly as I can."), SAY_THINK, 4000}})
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   224
	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 500}})
12575
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12539
diff changeset
   225
	table.insert(dialog01, {func = ShowMission, args = goals[dialog01]})
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   226
	table.insert(dialog01, {func = challengeStart, args = {hero.gear}})
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   227
end
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   228
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   229
------------------ Other Functions -------------------
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   230
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   231
function challengeStart()
9474
c255f6c46e33 stats and minor corrections, difficulty adjustment
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9471
diff changeset
   232
	startChallenge = true
12514
d89dabfd07ce Use EndTurn to replace TurnTimeLeft=0 in ASA campaign (fixes #225)
Wuzzy <almikes@aol.com>
parents: 12469
diff changeset
   233
	EndTurn(true)
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   234
end