share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua
author Wuzzy <Wuzzy2@mail.ru>
Mon, 14 Jan 2019 06:17:35 +0100
changeset 14598 221380cdee7e
parent 14597 2087e50e03e2
child 14599 50f511588635
permissions -rw-r--r--
ASA moon02: Add finishing times in ranking
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     1
------------------- ABOUT ----------------------
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     2
--
14509
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13742
diff changeset
     3
-- The hero has to catch the other hog in order
9614
7fa70d381c75 added custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9613
diff changeset
     4
-- to get informations about the origin of Pr. Hogevil
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     5
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     6
HedgewarsScriptLoad("/Scripts/Locale.lua")
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     7
HedgewarsScriptLoad("/Scripts/Animate.lua")
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     8
HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua")
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     9
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    10
----------------- VARIABLES --------------------
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    11
-- globals
9615
86b82816b222 image and description
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9614
diff changeset
    12
local missionName = loc("Chasing the blue hog")
9757
9be28be004d4 string tweaks and whitespace fixes
sheepluva
parents: 9645
diff changeset
    13
local challengeObjectives = loc("Use the rope in order to catch the blue hedgehog").."|"..
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    14
	loc("You have to stand very close to him")
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    15
local currentPosition = 1
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    16
local previousTimeLeft = 0
9772
30a9e740ec09 moon02 fixes: bug that didn't called win(), changed map so blue hog not placed on edges, teleport animations, removed amSkip, also error when drow hero and enemy seems fixed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9758
diff changeset
    17
local startChallenge = false
11891
d79621bcb709 Save record time for Chasing the blue hog mission
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
    18
local winningTime = nil
14597
2087e50e03e2 ASA: Show current time and personal best in moon02
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
    19
local currentTime = 0
2087e50e03e2 ASA: Show current time and personal best in moon02
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
    20
local runnerTime = 0
2087e50e03e2 ASA: Show current time and personal best in moon02
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
    21
local record
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    22
-- dialogs
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    23
local dialog01 = {}
9613
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
    24
local dialog02 = {}
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    25
-- mission objectives
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    26
local goals = {
12575
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12538
diff changeset
    27
	[dialog01] = {missionName, loc("Challenge objectives"), challengeObjectives, 1, 0},
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    28
}
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    29
-- hogs
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    30
local hero = {
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    31
	name = loc("Hog Solo"),
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    32
	x = 1300,
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    33
	y = 850
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    34
}
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    35
local runner = {
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    36
	name = loc("Crazy Runner"),
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    37
	places = {
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    38
		{x = 1400,y = 850, turnTime = 0},
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    39
		{x = 3880,y = 33, turnTime = 30000},
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    40
		{x = 250,y = 1780, turnTime = 25000},
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    41
		{x = 3850,y = 1940, turnTime = 20000},
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    42
	}
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    43
}
14598
221380cdee7e ASA moon02: Add finishing times in ranking
Wuzzy <Wuzzy2@mail.ru>
parents: 14597
diff changeset
    44
local runnerTimeTotal = 0
221380cdee7e ASA moon02: Add finishing times in ranking
Wuzzy <Wuzzy2@mail.ru>
parents: 14597
diff changeset
    45
for i=1, #runner.places do
221380cdee7e ASA moon02: Add finishing times in ranking
Wuzzy <Wuzzy2@mail.ru>
parents: 14597
diff changeset
    46
	runnerTimeTotal = runnerTimeTotal + runner.places[i].turnTime
221380cdee7e ASA moon02: Add finishing times in ranking
Wuzzy <Wuzzy2@mail.ru>
parents: 14597
diff changeset
    47
end
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    48
-- teams
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    49
local teamA = {
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    50
	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
    51
	color = -6
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    52
}
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    53
local teamB = {
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    54
	name = loc("Crazy Runner"),
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
    55
	color = -2
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    56
}
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    57
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    58
-------------- LuaAPI EVENT HANDLERS ------------------
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    59
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    60
function onGameInit()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    61
	GameFlags = gfDisableWind
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    62
	Seed = 1
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    63
	TurnTime = 25000
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    64
	CaseFreq = 0
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    65
	MinesNum = 0
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    66
	Explosives = 0
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    67
	Map = "moon02_map"
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    68
	Theme = "Cheese"
12468
d652c6f5d5f1 Disable Sudden Death for a couple of ASA missions
Wuzzy <almikes@aol.com>
parents: 12467
diff changeset
    69
	-- Disable Sudden Death
d652c6f5d5f1 Disable Sudden Death for a couple of ASA missions
Wuzzy <almikes@aol.com>
parents: 12467
diff changeset
    70
	WaterRise = 0
d652c6f5d5f1 Disable Sudden Death for a couple of ASA missions
Wuzzy <almikes@aol.com>
parents: 12467
diff changeset
    71
	HealthDecrease = 0
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9757
diff changeset
    72
14509
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13742
diff changeset
    73
	-- Hero
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13742
diff changeset
    74
	teamA.name = AddMissionTeam(teamA.color)
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13742
diff changeset
    75
	hero.gear = AddMissionHog(1)
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13742
diff changeset
    76
	hero.name = GetHogName(hero.gear)
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    77
	AnimSetGearPosition(hero.gear, hero.x, hero.y)
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    78
	-- Crazy Runner
14509
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13742
diff changeset
    79
	teamB.name = AddTeam(teamB.name, teamB.color, "ring", "Island", "Default", "cm_sonic")
9615
86b82816b222 image and description
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9614
diff changeset
    80
	runner.gear = AddHog(runner.name, 0, 100, "sth_Sonic")
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    81
	AnimSetGearPosition(runner.gear, runner.places[1].x, runner.places[1].y)
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    82
	HogTurnLeft(runner.gear, true)
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9757
diff changeset
    83
14597
2087e50e03e2 ASA: Show current time and personal best in moon02
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
    84
	record = tonumber(GetCampaignVar("FastestBlueHogCatch"))
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    85
	initCheckpoint("moon02")
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9757
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)
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    88
	AnimationSetup()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    89
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    90
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    91
function onGameStart()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    92
	AnimWait(hero.gear, 3000)
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    93
	FollowGear(hero.gear)
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9757
diff changeset
    94
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    95
	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9757
diff changeset
    96
14597
2087e50e03e2 ASA: Show current time and personal best in moon02
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
    97
	if record ~= nil then
2087e50e03e2 ASA: Show current time and personal best in moon02
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
    98
		goals[dialog01][3] = goals[dialog01][3] .. "|" .. string.format(loc("Personal best: %.3f seconds"), record/1000)
2087e50e03e2 ASA: Show current time and personal best in moon02
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
    99
	end
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   100
	AddAmmo(hero.gear, amRope, 1)
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9757
diff changeset
   101
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   102
	SendHealthStatsOff()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   103
	hogTurn = runner.gear
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   104
	AddAnim(dialog01)
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   105
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   106
12577
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12575
diff changeset
   107
-- Hide mission panel when jumping or shooting rope
12575
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12538
diff changeset
   108
function onGearAdd(gear)
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12538
diff changeset
   109
	if GetGearType(gear) == gtRope then
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12538
diff changeset
   110
		HideMission()
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12538
diff changeset
   111
	end
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12538
diff changeset
   112
end
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12538
diff changeset
   113
12577
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12575
diff changeset
   114
function onLJump()
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12575
diff changeset
   115
	if startChallenge then
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12575
diff changeset
   116
		HideMission()
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12575
diff changeset
   117
	end
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12575
diff changeset
   118
end
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12575
diff changeset
   119
onHJump = onLJump
e2b5c6e805e8 A Space Adventure: Remove or shorten intro sequences of side missions
Wuzzy <almikes@aol.com>
parents: 12575
diff changeset
   120
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   121
function onNewTurn()
9772
30a9e740ec09 moon02 fixes: bug that didn't called win(), changed map so blue hog not placed on edges, teleport animations, removed amSkip, also error when drow hero and enemy seems fixed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9758
diff changeset
   122
	if startChallenge and currentPosition < 5 then
9612
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   123
		if CurrentHedgehog ~= hero.gear then
12467
de69155f976b Use new turn ending method in moon02.lua
Wuzzy <almikes@aol.com>
parents: 12088
diff changeset
   124
			EndTurn(true)
14597
2087e50e03e2 ASA: Show current time and personal best in moon02
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
   125
			runnerTime = runnerTime + runner.places[currentPosition].turnTime
2087e50e03e2 ASA: Show current time and personal best in moon02
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
   126
			SetTeamLabel(teamB.name, string.format(loc("%.1fs"), runnerTime/1000))
9612
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   127
		else
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   128
			if GetAmmoCount(hero.gear, amRope) == 0  then
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   129
				lose()
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   130
			end
10289
c3a77ff02a23 lua api: SetWeapon(ammoType)
sheepluva
parents: 9772
diff changeset
   131
			SetWeapon(amRope)
13742
2bb7141496a9 Use SetTurnTimeLeft and SetReadyTimeLeft in all scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13583
diff changeset
   132
			SetTurnTimeLeft(runner.places[currentPosition].turnTime + previousTimeLeft)
9612
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   133
			previousTimeLeft = 0
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   134
		end
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   135
	end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   136
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   137
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   138
function onGameTick()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   139
	AnimUnWait()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   140
	if ShowAnimation() == false then
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   141
		return
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   142
	end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   143
	ExecuteAfterAnimations()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   144
	CheckEvents()
14597
2087e50e03e2 ASA: Show current time and personal best in moon02
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
   145
	if GetHealth(hero.gear) and CurrentHedgehog == hero.gear and startChallenge and currentPosition < 5 and currentPosition > 1 and ReadyTimeLeft == 0 and band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 then
2087e50e03e2 ASA: Show current time and personal best in moon02
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
   146
		currentTime = currentTime + 1
2087e50e03e2 ASA: Show current time and personal best in moon02
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
   147
	end
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   148
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   149
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   150
function onGameTick20()
14597
2087e50e03e2 ASA: Show current time and personal best in moon02
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
   151
	if startChallenge and currentPosition < 5 and currentPosition > 1 and CurrentHedgehog == hero.gear and ReadyTimeLeft == 0 and band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 then
2087e50e03e2 ASA: Show current time and personal best in moon02
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
   152
		SetTeamLabel(teamA.name, string.format(loc("%.1fs"), currentTime/1000))
2087e50e03e2 ASA: Show current time and personal best in moon02
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
   153
	end
9772
30a9e740ec09 moon02 fixes: bug that didn't called win(), changed map so blue hog not placed on edges, teleport animations, removed amSkip, also error when drow hero and enemy seems fixed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9758
diff changeset
   154
	if GetHealth(hero.gear) and startChallenge and isHeroNextToRunner() and currentPosition < 5 then
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   155
		moveRunner()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   156
	end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   157
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   158
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   159
function onPrecise()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   160
	if GameTime > 3000 then
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9757
diff changeset
   161
		SetAnimSkip(true)
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   162
	end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   163
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   164
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   165
-------------- EVENTS ------------------
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   166
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   167
function onHeroDeath(gear)
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   168
	if not GetHealth(hero.gear) then
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   169
		return true
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   170
	end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   171
	return false
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   172
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   173
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   174
-------------- ACTIONS ------------------
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   175
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   176
function heroDeath(gear)
9614
7fa70d381c75 added custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9613
diff changeset
   177
	lose()
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   178
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   179
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   180
-------------- ANIMATIONS ------------------
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   181
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   182
function Skipanim(anim)
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   183
	if goals[anim] ~= nil then
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   184
		ShowMission(unpack(goals[anim]))
12575
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12538
diff changeset
   185
	end
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12538
diff changeset
   186
    	if anim == dialog01 then
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   187
		moveRunner()
9772
30a9e740ec09 moon02 fixes: bug that didn't called win(), changed map so blue hog not placed on edges, teleport animations, removed amSkip, also error when drow hero and enemy seems fixed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9758
diff changeset
   188
	elseif anim == dialog02 then
30a9e740ec09 moon02 fixes: bug that didn't called win(), changed map so blue hog not placed on edges, teleport animations, removed amSkip, also error when drow hero and enemy seems fixed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9758
diff changeset
   189
		win()
12575
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12538
diff changeset
   190
	end
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   191
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   192
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   193
function AnimationSetup()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   194
	-- DIALOG 01 - Start, game instructions
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   195
	AddSkipFunction(dialog01, Skipanim, {dialog01})
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   196
	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 3200}})
11692
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   197
	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("On the other side of the moon ..."), 5000}})
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   198
	table.insert(dialog01, {func = AnimSay, args = {runner.gear, loc("So you are interested in Professor Hogevil, huh?"), SAY_SAY, 3000}})
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   199
	table.insert(dialog01, {func = AnimSay, args = {runner.gear, loc("We'll play a game first."), SAY_SAY, 3000}})
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   200
	table.insert(dialog01, {func = AnimSay, args = {runner.gear, loc("I'll let you know whatever I know about him if you manage to catch me 3 times."), SAY_SAY, 4000}})
9758
3b8058b251b8 some more campaign string tweaks
sheepluva
parents: 9757
diff changeset
   201
	table.insert(dialog01, {func = AnimSay, args = {runner.gear, loc("Let's go!"), SAY_SAY, 2000}})
12575
0c5ce463949b ASA: Improve displaying of mission panels all over the place
Wuzzy <almikes@aol.com>
parents: 12538
diff changeset
   202
	table.insert(dialog01, {func = ShowMission, args = goals[dialog01]})
9613
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   203
	table.insert(dialog01, {func = moveRunner, args = {}})
14509
7bb7e5e54f70 Update ASA campaign to use player chosen team identity
Wuzzy <Wuzzy2@mail.ru>
parents: 13742
diff changeset
   204
	-- DIALOG 02 - Professor Hogevil story
9613
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   205
	AddSkipFunction(dialog02, Skipanim, {dialog02})
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   206
	table.insert(dialog02, {func = AnimWait, args = {hero.gear, 3200}})
9757
9be28be004d4 string tweaks and whitespace fixes
sheepluva
parents: 9645
diff changeset
   207
	table.insert(dialog02, {func = AnimCaption, args = {hero.gear, loc("The truth about Professor Hogevil"), 5000}})
9be28be004d4 string tweaks and whitespace fixes
sheepluva
parents: 9645
diff changeset
   208
	table.insert(dialog02, {func = AnimSay, args = {runner.gear, loc("Amazing! I was never beaten in a race before!"), SAY_SAY, 4000}})
11692
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   209
	table.insert(dialog02, {func = AnimSay, args = {runner.gear, loc("So, let me tell you what I know about Professor Hogevil."), SAY_SAY, 4000}})
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   210
	table.insert(dialog02, {func = AnimSay, args = {runner.gear, loc("Professor Hogevil, then known as James Hogus, worked for PAotH back in my time."), SAY_SAY, 4000}})
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   211
	table.insert(dialog02, {func = AnimSay, args = {runner.gear, loc("He was the lab assistant of Dr. Goodhogan, the inventor of the anti-gravity device."), SAY_SAY, 5000}})
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   212
	table.insert(dialog02, {func = AnimSay, args = {runner.gear, loc("During the final testing of the device an accident happened."), SAY_SAY, 5000}})
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   213
	table.insert(dialog02, {func = AnimSay, args = {runner.gear, loc("In this accident, Professor Hogevil lost all his spines on his head!"), SAY_SAY, 5000}})
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   214
	table.insert(dialog02, {func = AnimSay, args = {runner.gear, loc("That's why he always wears a hat since then."), SAY_SAY, 4000}})
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   215
	table.insert(dialog02, {func = AnimSay, args = {runner.gear, loc("After that incident he went underground and started working on his plan to steal the device."), SAY_SAY, 5000}})
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   216
	table.insert(dialog02, {func = AnimSay, args = {runner.gear, loc("He is a very tough and very determined hedgehog. I would be extremely careful if I were you."), SAY_SAY, 5000}})
9613
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   217
	table.insert(dialog02, {func = AnimSay, args = {runner.gear, loc("I should go now, goodbye!"), SAY_SAY, 3000}})
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   218
	table.insert(dialog02, {func = win, args = {}})
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   219
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   220
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   221
------------- other functions ---------------
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   222
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   223
function isHeroNextToRunner()
11492
806da449d355 Fix Lua error spam in "Chasing the blue hog" after drowning both Crazy Runner and Hog Solo
Wuzzy <almikes@aol.com>
parents: 10289
diff changeset
   224
	if GetGearType(hero.gear) == gtHedgehog and GetGearType(runner.gear) == gtHedgehog and
806da449d355 Fix Lua error spam in "Chasing the blue hog" after drowning both Crazy Runner and Hog Solo
Wuzzy <almikes@aol.com>
parents: 10289
diff changeset
   225
			math.abs(GetX(hero.gear) - GetX(runner.gear)) < 75 and
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   226
			math.abs(GetY(hero.gear) - GetY(runner.gear)) < 75 and StoppedGear(hero.gear) then
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   227
		return true
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   228
	end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   229
	return false
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   230
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   231
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   232
function moveRunner()
9772
30a9e740ec09 moon02 fixes: bug that didn't called win(), changed map so blue hog not placed on edges, teleport animations, removed amSkip, also error when drow hero and enemy seems fixed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9758
diff changeset
   233
	if currentPosition == 4 then
30a9e740ec09 moon02 fixes: bug that didn't called win(), changed map so blue hog not placed on edges, teleport animations, removed amSkip, also error when drow hero and enemy seems fixed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9758
diff changeset
   234
		currentPosition = currentPosition + 1
9613
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   235
		if GetX(hero.gear) > GetX(runner.gear) then
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   236
			HogTurnLeft(runner.gear, false)
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   237
		end
9772
30a9e740ec09 moon02 fixes: bug that didn't called win(), changed map so blue hog not placed on edges, teleport animations, removed amSkip, also error when drow hero and enemy seems fixed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9758
diff changeset
   238
		AddAnim(dialog02)
11891
d79621bcb709 Save record time for Chasing the blue hog mission
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   239
d79621bcb709 Save record time for Chasing the blue hog mission
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   240
		-- Update time record
14598
221380cdee7e ASA moon02: Add finishing times in ranking
Wuzzy <Wuzzy2@mail.ru>
parents: 14597
diff changeset
   241
		winningTime = runnerTimeTotal - TurnTimeLeft
14597
2087e50e03e2 ASA: Show current time and personal best in moon02
Wuzzy <Wuzzy2@mail.ru>
parents: 14509
diff changeset
   242
		SetTeamLabel(teamA.name, string.format(loc("%.3fs"), winningTime/1000))
11891
d79621bcb709 Save record time for Chasing the blue hog mission
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   243
		SendStat(siCustomAchievement, string.format(loc("You have managed to catch the blue hedgehog in %.3f seconds."), winningTime/1000))
d79621bcb709 Save record time for Chasing the blue hog mission
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   244
		if record ~= nil and winningTime >= record then
d79621bcb709 Save record time for Chasing the blue hog mission
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   245
			SendStat(siCustomAchievement, string.format(loc("Your personal best time so far: %.3f seconds"), record/1000))
d79621bcb709 Save record time for Chasing the blue hog mission
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   246
		end
d79621bcb709 Save record time for Chasing the blue hog mission
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   247
		if record == nil or winningTime < record then
d79621bcb709 Save record time for Chasing the blue hog mission
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   248
			SaveCampaignVar("FastestBlueHogCatch", tostring(winningTime))
d79621bcb709 Save record time for Chasing the blue hog mission
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   249
			if record ~= nil then
d79621bcb709 Save record time for Chasing the blue hog mission
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   250
				SendStat(siCustomAchievement, loc("This is a new personal best time, congratulations!"))
d79621bcb709 Save record time for Chasing the blue hog mission
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   251
			end
d79621bcb709 Save record time for Chasing the blue hog mission
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   252
		end
d79621bcb709 Save record time for Chasing the blue hog mission
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   253
12467
de69155f976b Use new turn ending method in moon02.lua
Wuzzy <almikes@aol.com>
parents: 12088
diff changeset
   254
		EndTurn(true)
9772
30a9e740ec09 moon02 fixes: bug that didn't called win(), changed map so blue hog not placed on edges, teleport animations, removed amSkip, also error when drow hero and enemy seems fixed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9758
diff changeset
   255
	elseif currentPosition < 4 then
9613
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   256
		if not startChallenge then
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   257
			startChallenge = true
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   258
		end
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   259
		AddAmmo(hero.gear, amRope, 1)
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   260
		if currentPosition ~= 1 then
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   261
			PlaySound(sndVictory)
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   262
			if currentPosition > 1 and currentPosition < 4 then
11692
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   263
				AnimCaption(hero.gear, loc("Go, get him again!"), 3000)
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   264
				AnimSay(runner.gear, loc("You got me!"), SAY_SAY, 3000)
9613
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   265
			end
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   266
			previousTimeLeft = TurnTimeLeft
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   267
		end
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   268
		currentPosition = currentPosition + 1
9772
30a9e740ec09 moon02 fixes: bug that didn't called win(), changed map so blue hog not placed on edges, teleport animations, removed amSkip, also error when drow hero and enemy seems fixed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9758
diff changeset
   269
		AddVisualGear(GetX(runner.gear), GetY(runner.gear), vgtExplosion, 0, false) 
9613
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   270
		SetGearPosition(runner.gear, runner.places[currentPosition].x, runner.places[currentPosition].y)
12467
de69155f976b Use new turn ending method in moon02.lua
Wuzzy <almikes@aol.com>
parents: 12088
diff changeset
   271
		EndTurn(true)
9612
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   272
	end
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   273
end
9612
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   274
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   275
function lose()
11692
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   276
	SendStat(siGameResult, loc("Too slow! Try again ..."))
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   277
	SendStat(siCustomAchievement, loc("You have to catch the other hog 3 times."))
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   278
	SendStat(siCustomAchievement, loc("The time that you have left when you reach the blue hedgehog will be added to the next turn."))
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   279
	SendStat(siCustomAchievement, loc("Each turn you'll have only one rope to use."))
68eddcdc9f26 Typo fixes for A Space Adventure campaign
Wuzzy <almikes@aol.com>
parents: 11492
diff changeset
   280
	SendStat(siCustomAchievement, loc("You'll lose if you die or if your time is up."))
14598
221380cdee7e ASA moon02: Add finishing times in ranking
Wuzzy <Wuzzy2@mail.ru>
parents: 14597
diff changeset
   281
	SendStat(siPointType, loc("milliseconds"))
221380cdee7e ASA moon02: Add finishing times in ranking
Wuzzy <Wuzzy2@mail.ru>
parents: 14597
diff changeset
   282
	SendStat(siPlayerKills, tostring(runnerTimeTotal), teamB.name)
221380cdee7e ASA moon02: Add finishing times in ranking
Wuzzy <Wuzzy2@mail.ru>
parents: 14597
diff changeset
   283
	SendStat(siPlayerKills, tostring(GetTeamStats(teamA.name).Kills), teamA.name)
9612
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   284
	EndGame()
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   285
end
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   286
9613
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   287
function win()
9642
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9615
diff changeset
   288
	SendStat(siGameResult, loc("Congratulations, you are the fastest!"))
11891
d79621bcb709 Save record time for Chasing the blue hog mission
Wuzzy <almikes@aol.com>
parents: 11692
diff changeset
   289
	-- siCustomAchievements were added earlier
14598
221380cdee7e ASA moon02: Add finishing times in ranking
Wuzzy <Wuzzy2@mail.ru>
parents: 14597
diff changeset
   290
	SendStat(siPointType, loc("milliseconds"))
221380cdee7e ASA moon02: Add finishing times in ranking
Wuzzy <Wuzzy2@mail.ru>
parents: 14597
diff changeset
   291
	SendStat(siPlayerKills, tostring(winningTime), teamA.name)
221380cdee7e ASA moon02: Add finishing times in ranking
Wuzzy <Wuzzy2@mail.ru>
parents: 14597
diff changeset
   292
	SendStat(siPointType, loc("milliseconds"))
221380cdee7e ASA moon02: Add finishing times in ranking
Wuzzy <Wuzzy2@mail.ru>
parents: 14597
diff changeset
   293
	SendStat(siPlayerKills, tostring(runnerTimeTotal), teamB.name)
11952
63988f36debf Save mission success for A Space Adventure missions
Wuzzy <almikes@aol.com>
parents: 11891
diff changeset
   294
	SaveCampaignVar("Mission13Won", "true")
11965
72be38f6d0c0 Complete space campaign's spacetrip mission if all main+side missions are completed
Wuzzy <almikes@aol.com>
parents: 11952
diff changeset
   295
	checkAllMissionsCompleted()
9613
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   296
	EndGame()
9612
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   297
end