share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua
author Periklis Ntanasis <pntanasis@gmail.com>
Thu, 19 Sep 2013 03:49:29 +0300
branchspacecampaign
changeset 9642 8a691e0f117a
parent 9615 86b82816b222
child 9645 da7b4d8c181e
permissions -rw-r--r--
use consts for TStatInfo enum
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
--
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     3
-- Hog Solo 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")
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    13
local challengeObjectives = loc("Use your available weapons in order to catch the other hog").."|"..
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
9612
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
    17
local startChallenge = false
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    18
-- dialogs
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    19
local dialog01 = {}
9613
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
    20
local dialog02 = {}
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    21
-- mission objectives
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    22
local goals = {
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    23
	[dialog01] = {missionName, loc("Challenge Objectives"), challengeObjectives, 1, 4500},
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    24
}
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    25
-- hogs
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    26
local hero = {
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    27
	name = loc("Hog Solo"),
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    28
	x = 1300,
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    29
	y = 850
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    30
}
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    31
local runner = {
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    32
	name = loc("Crazy Runner"),
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    33
	places = {
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    34
		{x = 1400,y = 850, turnTime = 0},
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    35
		{x = 3880,y = 33, turnTime = 30000},
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    36
		{x = 250,y = 1780, turnTime = 25000},
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    37
		{x = 3850,y = 1940, turnTime = 20000},
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    38
	}
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    39
}
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    40
-- teams
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    41
local teamA = {
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    42
	name = loc("Hog Solo"),
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    43
	color = tonumber("38D61C",16) -- green
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    44
}
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    45
local teamB = {
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    46
	name = loc("Crazy Runner"),
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    47
	color = tonumber("FF0000",16) -- red
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    48
}
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    49
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    50
-------------- LuaAPI EVENT HANDLERS ------------------
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    51
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    52
function onGameInit()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    53
	GameFlags = gfDisableWind
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    54
	Seed = 1
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    55
	TurnTime = 25000
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    56
	CaseFreq = 0
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    57
	MinesNum = 0
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    58
	MinesTime = 1
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    59
	Explosives = 0
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    60
	Map = "moon02_map"
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    61
	Theme = "Cheese"
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    62
	
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    63
	-- Hog Solo
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    64
	AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy")
9612
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
    65
	hero.gear = AddHog(hero.name, 0, 1, "war_desertgrenadier1")
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    66
	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
    67
	-- Crazy Runner
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    68
	AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "cm_birdy")
9615
86b82816b222 image and description
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9614
diff changeset
    69
	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
    70
	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
    71
	HogTurnLeft(runner.gear, true)
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    72
	
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    73
	initCheckpoint("moon02")
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    74
	
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    75
	AnimInit()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    76
	AnimationSetup()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    77
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    78
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    79
function onGameStart()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    80
	AnimWait(hero.gear, 3000)
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    81
	FollowGear(hero.gear)
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    82
	ShowMission(missionName, loc("Challenge Objectives"), challengeObjectives, -amSkip, 0)
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    83
	
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    84
	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    85
	
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    86
	AddAmmo(hero.gear, amRope, 1)
9612
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
    87
	AddAmmo(hero.gear, amSkip, 1)
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    88
	
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    89
	SendHealthStatsOff()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    90
	hogTurn = runner.gear
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    91
	AddAnim(dialog01)
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    92
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    93
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    94
function onNewTurn()
9612
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
    95
	if startChallenge then
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
    96
		if CurrentHedgehog ~= hero.gear then
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
    97
			TurnTimeLeft = 0
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
    98
		else
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
    99
			if GetAmmoCount(hero.gear, amRope) == 0  then
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   100
				lose()
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   101
			end
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   102
			TurnTimeLeft = runner.places[currentPosition].turnTime + previousTimeLeft
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   103
			previousTimeLeft = 0
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   104
		end
9611
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
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   107
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   108
function onGameTick()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   109
	AnimUnWait()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   110
	if ShowAnimation() == false then
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   111
		return
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   112
	end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   113
	ExecuteAfterAnimations()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   114
	CheckEvents()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   115
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   116
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   117
function onGameTick20()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   118
	if isHeroNextToRunner() then
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   119
		moveRunner()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   120
	end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   121
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   122
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   123
function onPrecise()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   124
	if GameTime > 3000 then
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   125
		SetAnimSkip(true)   
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   126
	end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   127
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   128
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   129
-------------- EVENTS ------------------
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   130
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   131
function onHeroDeath(gear)
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   132
	if not GetHealth(hero.gear) then
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   133
		return true
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   134
	end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   135
	return false
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
-------------- ACTIONS ------------------
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   139
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   140
function heroDeath(gear)
9614
7fa70d381c75 added custom stats
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9613
diff changeset
   141
	lose()
9611
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
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   144
-------------- ANIMATIONS ------------------
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   145
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   146
function Skipanim(anim)
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   147
	if goals[anim] ~= nil then
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   148
		ShowMission(unpack(goals[anim]))
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   149
    end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   150
    if anim == dialog01 then
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   151
		moveRunner()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   152
    end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   153
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   154
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   155
function AnimationSetup()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   156
	-- DIALOG 01 - Start, game instructions
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   157
	AddSkipFunction(dialog01, Skipanim, {dialog01})
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   158
	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 3200}})
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   159
	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("In the other side of the moon..."), 5000}})
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   160
	table.insert(dialog01, {func = AnimSay, args = {runner.gear, loc("So you are interested in Pr. Hogevil"), SAY_SAY, 3000}})
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   161
	table.insert(dialog01, {func = AnimSay, args = {runner.gear, loc("We'll play a game first"), SAY_SAY, 3000}})
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   162
	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}})
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   163
	table.insert(dialog01, {func = AnimSay, args = {runner.gear, loc("Let's go!"), SAY_SAY, 2000}})	
9613
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   164
	table.insert(dialog01, {func = moveRunner, args = {}})
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   165
	-- DIALOG 02 - Hog Solo story    
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   166
	AddSkipFunction(dialog02, Skipanim, {dialog02})
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   167
	table.insert(dialog02, {func = AnimWait, args = {hero.gear, 3200}})
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   168
	table.insert(dialog02, {func = AnimCaption, args = {hero.gear, loc("The truth about Pr. Hogevil"), 5000}})
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   169
	table.insert(dialog02, {func = AnimSay, args = {runner.gear, loc("Amazing! I was never beaten in running before!"), SAY_SAY, 4000}})
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   170
	table.insert(dialog02, {func = AnimSay, args = {runner.gear, loc("So, let me tell you what I know about Pr. Hogevil..."), SAY_SAY, 4000}})
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   171
	table.insert(dialog02, {func = AnimSay, args = {runner.gear, loc("Pr. Hogevil, then known as James Hogus, worked for PAotH back in my time"), SAY_SAY, 4000}})
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   172
	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}})
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   173
	table.insert(dialog02, {func = AnimSay, args = {runner.gear, loc("In one of the last tests during the construction of the device an accident happpened"), SAY_SAY, 5000}})
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   174
	table.insert(dialog02, {func = AnimSay, args = {runner.gear, loc("In this accident Pr. Hogevil lost all his nails from his head!"), SAY_SAY, 5000}})
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   175
	table.insert(dialog02, {func = AnimSay, args = {runner.gear, loc("That's why he always wears a hat since then"), SAY_SAY, 4000}})
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   176
	table.insert(dialog02, {func = AnimSay, args = {runner.gear, loc("After that incident he got underground and start working his plan to steal the device"), SAY_SAY, 5000}})
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   177
	table.insert(dialog02, {func = AnimSay, args = {runner.gear, loc("He is a very taugh and very determined hedgehog. I would be extremely careful if I were you"), SAY_SAY, 5000}})
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   178
	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
   179
	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
   180
end
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
------------- other functions ---------------
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   183
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   184
function isHeroNextToRunner()
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   185
	if GetHealth(hero.gear) and math.abs(GetX(hero.gear) - GetX(runner.gear)) < 75 and
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   186
			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
   187
		return true
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   188
	end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   189
	return false
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   190
end
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   191
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   192
function moveRunner()
9613
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   193
	if currentPosition > 3 then
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   194
		if GetX(hero.gear) > GetX(runner.gear) then
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   195
			HogTurnLeft(runner.gear, false)
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   196
		end
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   197
		TurnTimeLeft = 0
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   198
		AddAnim(dialog02)
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   199
	else
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   200
		if not startChallenge then
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   201
			startChallenge = true
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   202
		end
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   203
		AddAmmo(hero.gear, amRope, 1)
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   204
		if currentPosition ~= 1 then
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   205
			PlaySound(sndVictory)
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   206
			if currentPosition > 1 and currentPosition < 4 then
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   207
				AnimCaption(hero.gear, loc("Go get him again"), 3000)
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   208
				AnimSay(runner.gear, loc("You got me"), SAY_SAY, 3000)
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   209
			end
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   210
			previousTimeLeft = TurnTimeLeft
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   211
		end
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   212
		currentPosition = currentPosition + 1
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   213
		SetGearPosition(runner.gear, runner.places[currentPosition].x, runner.places[currentPosition].y)
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   214
		TurnTimeLeft = 0
9612
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   215
	end
9611
ef374528a9fb moon side mission map and most of the logic
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   216
end
9612
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   217
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   218
function lose()
9642
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9615
diff changeset
   219
	SendStat(siGameResult, loc("Too slow! Try again..."))
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9615
diff changeset
   220
	SendStat(siCustomAchievement, loc("You have to caught the other hog 3 times"))
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9615
diff changeset
   221
	SendStat(siCustomAchievement, loc("The time that you'll have left when you reach the hog will be added to the next turn"))
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9615
diff changeset
   222
	SendStat(siCustomAchievement, loc("Each turn you'll have only one rope to use"))
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9615
diff changeset
   223
	SendStat(siCustomAchievement, loc("You'll lose if you die or if your time is up"))
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9615
diff changeset
   224
	SendStat(siPlayerKills,'0',teamA.name)
9612
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   225
	EndGame()
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   226
end
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   227
9613
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   228
function win()
9642
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9615
diff changeset
   229
	SendStat(siGameResult, loc("Congratulations, you are the fastest!"))
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9615
diff changeset
   230
	SendStat(siCustomAchievement, loc("You have managed to caught the other hog in time"))
8a691e0f117a use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9615
diff changeset
   231
	SendStat(siPlayerKills,'1',teamA.name)
9613
142ba1d08205 cleanup - removed debug prints
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9612
diff changeset
   232
	EndGame()
9612
825856c67563 many corrections
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9611
diff changeset
   233
end