share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua
author Periklis Ntanasis <pntanasis@gmail.com>
Sat, 24 Aug 2013 06:36:02 +0300
branchspacecampaign
changeset 9574 da3d39667881
parent 9572 278cff2a965f
child 9578 16139270448f
permissions -rw-r--r--
strings checked, all ok except ice02 that will be probably changed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     1
------------------- ABOUT ----------------------
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     2
--
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     3
-- This map works as a menu for the hero hog to
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     4
-- navigate through planets. It portrays the hogs
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     5
-- planet and above the planets that he'll later
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     6
-- visit.
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     7
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     8
-- TODO
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
     9
-- Save and Load All Check Points
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    10
-- Save hero health
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    11
-- Decide and implement if hero will use gas bombs...
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
    12
-- ofc add custom stats page
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
    13
-- PROBLEM : What if one makes a bad choice and wants to replay it map, how to reset?
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
    14
-- POSSIBLE SOLUTIONS: In game function keys, frontend button...
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    15
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    16
HedgewarsScriptLoad("/Scripts/Locale.lua")
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    17
HedgewarsScriptLoad("/Scripts/Animate.lua")
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    18
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    19
----------------- VARIABLES --------------------
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    20
-- globals
9574
da3d39667881 strings checked, all ok except ice02 that will be probably changed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9572
diff changeset
    21
local missionName = loc("Spacetrip")
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    22
local timeForGuard1ToTurn = 1000 * 5 -- 5 sec
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    23
local timeForGuard1ToTurnLeft = timeForGuard1ToTurn
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    24
local saucerAcquired = false
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    25
local checkPointReached = 1 -- 1 is start of the game
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    26
-- dialogs
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    27
local dialog01 = {}
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    28
local dialog02 = {}
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    29
local dialog03 = {}
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    30
local dialog04 = {}
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
    31
local dialog05 = {}
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
    32
local dialog06 = {}
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    33
-- mission objectives
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    34
local goals = {
9574
da3d39667881 strings checked, all ok except ice02 that will be probably changed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9572
diff changeset
    35
	[dialog01] = {missionName, loc("Getting ready"), loc("Go and collect the crate").."|"..loc("Try not to get spotted by the guards!"), 1, 4500},
da3d39667881 strings checked, all ok except ice02 that will be probably changed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9572
diff changeset
    36
	[dialog02] = {missionName, loc("The adventure begins!"), loc("Use the saucer and fly to the moon").."|"..loc("Travel carefully as your fuels are limited"), 1, 4500},
da3d39667881 strings checked, all ok except ice02 that will be probably changed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9572
diff changeset
    37
	[dialog03] = {missionName, loc("An unexpected event!"), loc("Use the saucer and fly away").."|"..loc("Beware, any damage taken will stay until you complete the moon mission"), 1, 7000}
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    38
}
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    39
-- crates
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    40
local saucerX = 3270
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    41
local saucerY = 1500
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    42
-- hogs
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    43
local hero = {}
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    44
local director = {}
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    45
local doctor = {}
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    46
local guard1 = {}
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    47
local guard2 = {}
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    48
-- teams
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    49
local teamA = {}
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    50
local teamB = {}
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    51
local teamC = {}
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    52
-- hedgehogs values
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    53
hero.name = loc("Hog Solo")
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    54
hero.x = 1450
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    55
hero.y = 1550
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    56
director.name = loc("H")
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    57
director.x = 1350
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    58
director.y = 1550
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    59
doctor.name = loc("Dr.Cornelius")
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    60
doctor.x = 1300
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    61
doctor.y = 1550
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    62
guard1.name = loc("Bob")
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    63
guard1.x = 3350
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    64
guard1.y = 1800
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    65
guard1.turn = false
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    66
guard1.keepTurning = true
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    67
guard2.name = loc("Sam")
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    68
guard2.x = 3400
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    69
guard2.y = 1800
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    70
teamA.name = loc("PAoTH")
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    71
teamA.color = tonumber("FF0000",16) -- red
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    72
teamB.name = loc("Guards")
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    73
teamB.color = tonumber("0033FF",16) -- blue
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    74
teamC.name = loc("Hog Solo")
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    75
teamC.color = tonumber("38D61C",16) -- green
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    76
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    77
-------------- LuaAPI EVENT HANDLERS ------------------
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    78
function onGameInit()
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    79
	Seed = 35
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    80
	GameFlags = gfSolidLand + gfDisableWind
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    81
	TurnTime = 40000
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    82
	CaseFreq = 0
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    83
	MinesNum = 0
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    84
	Explosives = 0
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    85
	Delay = 5
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    86
	Map = "cosmos_map" -- custom map included in file
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    87
	Theme = "Nature"
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    88
	-- I had originally hero in PAoTH team and changed it, may reconsider though
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    89
	-- PAoTH
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    90
	AddTeam(teamC.name, teamC.color, "Bone", "Island", "HillBilly", "cm_birdy")	
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    91
	hero.gear = AddHog(hero.name, 0, 100, "war_desertgrenadier1")
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    92
	AnimSetGearPosition(hero.gear, hero.x, hero.y)	
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    93
	HogTurnLeft(hero.gear, true)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    94
	AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy")	
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    95
	director.gear = AddHog(director.name, 0, 100, "hair_yellow")
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    96
	AnimSetGearPosition(director.gear, director.x, director.y)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    97
	doctor.gear = AddHog(doctor.name, 0, 100, "Glasses")
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    98
	AnimSetGearPosition(doctor.gear, doctor.x, doctor.y)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
    99
	-- Guards
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   100
	AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "cm_birdy")
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   101
	guard1.gear = AddHog(guard1.name, 1, 100, "policecap")
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   102
	AnimSetGearPosition(guard1.gear, guard1.x, guard1.y)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   103
	guard2.gear = AddHog(guard2.name, 1, 100, "policecap")
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   104
	AnimSetGearPosition(guard2.gear, guard2.x, guard2.y)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   105
	
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   106
	-- get the check point
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   107
	if tonumber(GetCampaignVar("CosmosCheckPoint")) then
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   108
		checkPointReached = tonumber(GetCampaignVar("CosmosCheckPoint"))
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   109
	end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   110
	-- do checkpoint stuff needed before game starts
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   111
	if checkPointReached == 1 then
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   112
		-- Start of the game
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   113
	elseif checkPointReached == 2 then
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   114
		-- Hero on the column, just took space ship unnoticed
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   115
		AnimSetGearPosition(hero.gear, saucerX, saucerY)
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   116
	elseif checkPointReached == 3 then
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   117
		-- Hero near column, without space ship unnoticed
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   118
	elseif checkPointReached == 4 then
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   119
		-- Hero visited moon for fuels
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   120
		AnimSetGearPosition(hero.gear, 1110, 850)
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   121
	elseif checkPointReached == 5 then
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   122
		-- Hero has visited a planet, he has plenty of fuels and can change planet
9342
51b5fffe3892 changes about displaying the ice planet mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9328
diff changeset
   123
		if GetCampaignVar("Planet") == "moon" then
51b5fffe3892 changes about displaying the ice planet mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9328
diff changeset
   124
			AnimSetGearPosition(hero.gear, 1110, 850)
51b5fffe3892 changes about displaying the ice planet mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9328
diff changeset
   125
		elseif GetCampaignVar("Planet") == "desertPlanet" then
51b5fffe3892 changes about displaying the ice planet mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9328
diff changeset
   126
			AnimSetGearPosition(hero.gear, 3670, 270)
51b5fffe3892 changes about displaying the ice planet mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9328
diff changeset
   127
		elseif GetCampaignVar("Planet") == "fruitPlanet" then
51b5fffe3892 changes about displaying the ice planet mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9328
diff changeset
   128
			AnimSetGearPosition(hero.gear, 2400, 375)
51b5fffe3892 changes about displaying the ice planet mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9328
diff changeset
   129
		elseif GetCampaignVar("Planet") == "icePlanet" then
51b5fffe3892 changes about displaying the ice planet mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9328
diff changeset
   130
			AnimSetGearPosition(hero.gear, 1440, 260)
51b5fffe3892 changes about displaying the ice planet mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9328
diff changeset
   131
		end
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   132
	end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   133
	
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   134
	AnimInit()
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   135
	AnimationSetup()
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   136
end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   137
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   138
function onGameStart()
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   139
	-- wait for the first turn to start
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   140
	AnimWait(hero.gear, 3000)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   141
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   142
	FollowGear(hero.gear)
9574
da3d39667881 strings checked, all ok except ice02 that will be probably changed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9572
diff changeset
   143
	ShowMission(loc("Spacetrip"), loc("Getting ready"), loc("Help Hog Solo to find all the parts of the anti-gravity device.")..
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   144
	"|"..loc("Travel to all the neighbor planets and collect all the pieces"), -amSkip, 0)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   145
	
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   146
	-- do checkpoint stuff needed after game starts
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   147
	if checkPointReached == 1 then	
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   148
		AddAnim(dialog01)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   149
		AddAmmo(hero.gear, amGasBomb, 5)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   150
		AddAmmo(hero.gear, amRope, 2)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   151
		-- Added for dev/debug purposes, remove before release
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   152
		AddAmmo(hero.gear, amJetpack, 2)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   153
		AddAmmo(guard1.gear, amDEagle, 2)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   154
		AddAmmo(guard2.gear, amDEagle, 2)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   155
		SpawnAmmoCrate(saucerX, saucerY, amJetpack)	
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   156
		-- EVENT HANDLERS
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   157
		AddEvent(onHeroBeforeTreePosition, {hero.gear}, heroBeforeTreePosition, {hero.gear}, 0)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   158
		AddEvent(onHeroAtSaucerPosition, {hero.gear}, heroAtSaucerPosition, {hero.gear}, 0)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   159
		AddEvent(onHeroOutOfGuardSight, {hero.gear}, heroOutOfGuardSight, {hero.gear}, 0)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   160
	elseif checkPointReached == 2 then
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   161
		AddAmmo(hero.gear, amJetpack, 1)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   162
		AddAnim(dialog02)
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   163
	elseif checkPointReached == 3 then
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   164
		-- Hero near column, without space ship unnoticed
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   165
	elseif checkPointReached == 4 then
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   166
		-- Hero visited moon for fuels
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   167
		AddAnim(dialog05)
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   168
	elseif checkPointReached == 5 then
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   169
		-- Hero has visited a planet, he has plenty of fuels and can change planet
9342
51b5fffe3892 changes about displaying the ice planet mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9328
diff changeset
   170
		AddAmmo(hero.gear, amJetpack, 99)
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   171
	end
9328
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   172
	
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   173
	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   174
	AddEvent(onNoFuelAtLand, {hero.gear}, noFuelAtLand, {hero.gear}, 0)
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   175
	-- always check for landings
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   176
	if GetCampaignVar("Planet") ~= "moon" then
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   177
		AddEvent(onMoonLanding, {hero.gear}, moonLanding, {hero.gear}, 0)
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   178
	end
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   179
	if GetCampaignVar("Planet") ~= "desertPlanet" then
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   180
		AddEvent(onDesertPlanetLanding, {hero.gear}, desertPlanetLanding, {hero.gear}, 0)
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   181
	end	
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   182
	if GetCampaignVar("Planet") ~= "fruitPlanet" then
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   183
		AddEvent(onFruitPlanetLanding, {hero.gear}, fruitPlanetLanding, {hero.gear}, 0)
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   184
	end
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   185
	if GetCampaignVar("Planet") ~= "icePlanet" then
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   186
		AddEvent(onIcePlanetLanding, {hero.gear}, icePlanetLanding, {hero.gear}, 0)
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   187
	end
9572
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   188
	if GetCampaignVar("Planet") ~= "deathPlanet" then
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   189
		AddEvent(onDeathPlanetLanding, {hero.gear}, deathPlanetLanding, {hero.gear}, 0)
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   190
	end
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   191
end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   192
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   193
function onGameTick()
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   194
	-- maybe alert this to avoid timeForGuard1ToTurnLeft overflow
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   195
	if timeForGuard1ToTurnLeft == 0 and guard1.keepTurning then
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   196
		guard1.turn = not guard1.turn
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   197
		HogTurnLeft(guard1.gear, guard1.turn)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   198
		timeForGuard1ToTurnLeft = timeForGuard1ToTurn
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   199
	end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   200
	timeForGuard1ToTurnLeft = timeForGuard1ToTurnLeft - 1
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   201
	AnimUnWait()
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   202
	if ShowAnimation() == false then
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   203
		return
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   204
	end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   205
	ExecuteAfterAnimations()
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   206
	CheckEvents()
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   207
end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   208
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   209
function onPrecise()
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   210
	if GameTime > 3000 then
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   211
		SetAnimSkip(true)   
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   212
	end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   213
end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   214
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   215
function onAmmoStoreInit()
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   216
	SetAmmo(amJetpack, 0, 0, 0, 1)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   217
end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   218
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   219
function onNewTurn()
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   220
	if CurrentHedgehog == director.gear or CurrentHedgehog == doctor.gear then
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   221
		TurnTimeLeft = 0
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   222
	end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   223
	if guard1.keepTurning then
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   224
		AnimSwitchHog(hero.gear)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   225
		TurnTimeLeft = -1
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   226
	end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   227
end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   228
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   229
-------------- EVENTS ------------------
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   230
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   231
function onHeroBeforeTreePosition(gear)
9328
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   232
	if GetHealth(hero.gear) and GetX(gear) > 2350 then
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   233
		return true
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   234
	end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   235
	return false
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   236
end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   237
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   238
function onHeroAtSaucerPosition(gear)
9328
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   239
	if GetHealth(hero.gear) and GetX(gear) >= saucerX-25 and GetX(gear) <= saucerX+32 and GetY(gear) >= saucerY-32 and GetY(gear) <= saucerY+32 then
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   240
		saucerAcquired = true
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   241
	end
9328
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   242
	if saucerAcquired and GetHealth(hero.gear) and StoppedGear(gear) then
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   243
		return true
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   244
	end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   245
	return false
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   246
end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   247
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   248
function onHeroOutOfGuardSight(gear)
9328
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   249
	if GetHealth(hero.gear) and GetX(gear) < 3100 and GetY(gear) > saucerY-25 and StoppedGear(gear) and not guard1.keepTurning then
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   250
		return true
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   251
	end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   252
	return false
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   253
end
9328
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   254
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   255
-- TODO somehow make it to count fall damage
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   256
function onMoonLanding(gear)
9328
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   257
	if GetHealth(hero.gear) and GetX(gear) > 1010 and GetX(gear) < 1220  and GetY(gear) < 1300 and GetY(gear) > 750 and StoppedGear(gear) then
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   258
		return true
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   259
	end
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   260
	return false
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   261
end
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   262
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   263
function onFruitPlanetLanding(gear)
9328
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   264
	if GetHealth(hero.gear) and GetX(gear) > 2240 and GetX(gear) < 2540  and GetY(gear) < 1100 and StoppedGear(gear) then
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   265
		return true
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   266
	end
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   267
	return false
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   268
end
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   269
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   270
function onDesertPlanetLanding(gear)
9328
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   271
	if GetHealth(hero.gear) and GetX(gear) > 3568 and GetX(gear) < 4052  and GetY(gear) < 500 and StoppedGear(gear) then
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   272
		return true
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   273
	end
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   274
	return false
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   275
end
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   276
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   277
function onIcePlanetLanding(gear)
9328
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   278
	if GetHealth(hero.gear) and GetX(gear) > 1330 and GetX(gear) < 1650  and GetY(gear) < 500 and StoppedGear(gear) then
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   279
		return true
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   280
	end
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   281
	return false
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   282
end
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   283
9572
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   284
function onDeathPlanetLanding(gear)
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   285
	if GetHealth(hero.gear) and GetX(gear) > 310 and GetX(gear) < 675  and GetY(gear) < 400 and StoppedGear(gear) then
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   286
		return true
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   287
	end
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   288
	return false
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   289
end
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   290
9328
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   291
function onNoFuelAtLand(gear)
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   292
	if GetHealth(hero.gear) and GetY(gear) > 1400 and GetAmmoCount(gear, amJetpack) == 0 and StoppedGear(gear) then
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   293
		return true
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   294
	end
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   295
	return false
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   296
end
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   297
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   298
function onHeroDeath(gear)
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   299
	if not GetHealth(gear) then
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   300
		return true
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   301
	end
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   302
	return false
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   303
end
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   304
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   305
-------------- OUTCOMES ------------------
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   306
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   307
function heroBeforeTreePosition(gear)
9574
da3d39667881 strings checked, all ok except ice02 that will be probably changed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9572
diff changeset
   308
	AnimSay(gear,loc("Now I have to climb these trees"), SAY_SAY, 4000)
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   309
	AnimCaption(hero.gear, loc("Use the rope to get to the crate"),  4000)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   310
end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   311
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   312
function heroAtSaucerPosition(gear)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   313
	TurnTimeLeft = 0
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   314
	-- save check point	
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   315
	SaveCampaignVar("CosmosCheckPoint", "2")
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   316
	AddAnim(dialog02)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   317
	-- check if he was spotted by the guard
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   318
	if guard1.turn then
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   319
		guard1.keepTurning = false
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   320
		AddAnim(dialog03)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   321
	end	
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   322
end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   323
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   324
function heroOutOfGuardSight(gear)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   325
	guard1.keepTurning = true
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   326
	AddAnim(dialog04)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   327
end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   328
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   329
function moonLanding(gear)
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   330
	AnimCaption(hero.gear,loc("Welcome to the moon!"))
9342
51b5fffe3892 changes about displaying the ice planet mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9328
diff changeset
   331
	SaveCampaignVar("Planet", "moon")
9326
689f591aa226 added saved hero health between missions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9310
diff changeset
   332
	if checkPointReached ~= 5 then
689f591aa226 added saved hero health between missions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9310
diff changeset
   333
		SaveCampaignVar("CosmosCheckPoint", "4")
689f591aa226 added saved hero health between missions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9310
diff changeset
   334
		SaveCampaignVar("HeroHealth",GetHealth(hero.gear))
689f591aa226 added saved hero health between missions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9310
diff changeset
   335
	end
689f591aa226 added saved hero health between missions
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9310
diff changeset
   336
	SaveCampaignVar("UnlockedMissions", "2")
9310
1469147c110f moon01 stab and finally moon01 map
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9308
diff changeset
   337
	SaveCampaignVar("Mission1", "2")
1469147c110f moon01 stab and finally moon01 map
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9308
diff changeset
   338
	SaveCampaignVar("Mission2", "1")
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   339
	EndGame()
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   340
end
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   341
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   342
function fruitPlanetLanding(gear)
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   343
	if checkPointReached < 5 then
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   344
		AddAnim(dialog06)
9484
a63307092bc6 fruit planet main mission first commit
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9467
diff changeset
   345
	else		
9574
da3d39667881 strings checked, all ok except ice02 that will be probably changed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9572
diff changeset
   346
		AnimCaption(hero.gear,loc("Welcome to the Fruit Planet!"))
9484
a63307092bc6 fruit planet main mission first commit
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9467
diff changeset
   347
		SaveCampaignVar("Planet", "fruitPlanet")
a63307092bc6 fruit planet main mission first commit
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9467
diff changeset
   348
		SaveCampaignVar("UnlockedMissions", "2")
a63307092bc6 fruit planet main mission first commit
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9467
diff changeset
   349
		SaveCampaignVar("Mission1", "3")
a63307092bc6 fruit planet main mission first commit
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9467
diff changeset
   350
		SaveCampaignVar("Mission2", "1")
a63307092bc6 fruit planet main mission first commit
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9467
diff changeset
   351
		EndGame()
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   352
	end
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   353
end
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   354
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   355
function desertPlanetLanding(gear)
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   356
	if checkPointReached < 5 then
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   357
		AddAnim(dialog06)
9404
4ae9b399fa73 desert planet main mission addition - hwp will be added when fully finished
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9342
diff changeset
   358
	else		
9574
da3d39667881 strings checked, all ok except ice02 that will be probably changed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9572
diff changeset
   359
		AnimCaption(hero.gear,loc("Welcome to the Desert Planet!"))
9404
4ae9b399fa73 desert planet main mission addition - hwp will be added when fully finished
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9342
diff changeset
   360
		SaveCampaignVar("Planet", "desertPlanet")
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9457
diff changeset
   361
		SaveCampaignVar("UnlockedMissions", "3")
9404
4ae9b399fa73 desert planet main mission addition - hwp will be added when fully finished
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9342
diff changeset
   362
		SaveCampaignVar("Mission1", "4")
9467
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9457
diff changeset
   363
		SaveCampaignVar("Mission2", "7")
483a73697535 desert sidwquest map and basic script
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9457
diff changeset
   364
		SaveCampaignVar("Mission3", "1")
9404
4ae9b399fa73 desert planet main mission addition - hwp will be added when fully finished
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9342
diff changeset
   365
		EndGame()
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   366
	end
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   367
end
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   368
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   369
function icePlanetLanding(gear)
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   370
	if checkPointReached < 5 then
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   371
		AddAnim(dialog06)
9342
51b5fffe3892 changes about displaying the ice planet mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9328
diff changeset
   372
	else
9574
da3d39667881 strings checked, all ok except ice02 that will be probably changed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9572
diff changeset
   373
		AnimCaption(hero.gear,loc("Welcome to the Planet of Ice!"))
9342
51b5fffe3892 changes about displaying the ice planet mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9328
diff changeset
   374
		SaveCampaignVar("Planet", "icePlanet")
9457
934f4d8370f1 finally most of the mission mechanics seems ok
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9455
diff changeset
   375
		SaveCampaignVar("UnlockedMissions", "3")
9342
51b5fffe3892 changes about displaying the ice planet mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9328
diff changeset
   376
		SaveCampaignVar("Mission1", "5")
9455
4bf3fac0e49d added iceplanet sidequest map and stub lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9404
diff changeset
   377
		SaveCampaignVar("Mission2", "6")
4bf3fac0e49d added iceplanet sidequest map and stub lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9404
diff changeset
   378
		SaveCampaignVar("Mission3", "1")
9342
51b5fffe3892 changes about displaying the ice planet mission
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9328
diff changeset
   379
		EndGame()
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   380
	end
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   381
end
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   382
9572
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   383
function deathPlanetLanding(gear)
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   384
	if checkPointReached < 5 then
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   385
		AddAnim(dialog06)
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   386
	else
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   387
		AnimCaption(hero.gear,loc("Welcome to the Death Planet!"))
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   388
		SaveCampaignVar("Planet", "deathPlanet")
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   389
		SaveCampaignVar("UnlockedMissions", "2")
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   390
		SaveCampaignVar("Mission1", "9")
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   391
		SaveCampaignVar("Mission2", "1")
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   392
		EndGame()
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   393
	end
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   394
end
278cff2a965f added death planet in cosmos without the order restriction yet
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9484
diff changeset
   395
9328
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   396
function noFuelAtLand(gear)
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   397
	AddAnim(dialog06)
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   398
end
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   399
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   400
function heroDeath(gear)
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   401
	EndGame()
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   402
end
811574013fed more events in cosmos about GameEnd
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9326
diff changeset
   403
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   404
-------------- ANIMATIONS ------------------
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   405
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   406
function Skipanim(anim)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   407
	if goals[anim] ~= nil then
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   408
		ShowMission(unpack(goals[anim]))
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   409
    end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   410
    if CurrentHedgehog ~= hero.gear and anim ~= dialog03 then
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   411
		AnimSwitchHog(hero.gear)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   412
	elseif anim == dialog03 then
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   413
		startCombat()
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   414
	elseif anim == dialog05 or anim == dialog06 then
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   415
		EndGame()
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   416
	end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   417
end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   418
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   419
function AnimationSetup()
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   420
	-- DIALOG 01 - Start
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   421
	AddSkipFunction(dialog01, Skipanim, {dialog01})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   422
	table.insert(dialog01, {func = AnimWait, args = {doctor.gear, 3000}})
9574
da3d39667881 strings checked, all ok except ice02 that will be probably changed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9572
diff changeset
   423
	table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("Near secret base 17 of PAotH in the rural Hogland..."),  4000}})
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   424
	table.insert(dialog01, {func = AnimSay, args = {director.gear, loc("So Hog Solo, here we are..."), SAY_SAY, 2000}})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   425
	table.insert(dialog01, {func = AnimSay, args = {director.gear, loc("Behind these trees on the East there is secret base 17"), SAY_SAY, 4000}})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   426
	table.insert(dialog01, {func = AnimSay, args = {director.gear, loc("You have to continue alone from now on."), SAY_SAY, 3000}})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   427
	table.insert(dialog01, {func = AnimSay, args = {director.gear, loc("Be careful, the future of Hogera is in your hands!"), SAY_SAY, 7200}})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   428
	table.insert(dialog01, {func = AnimSay, args = {doctor.gear, loc("We'll use our communicators to contact you"), SAY_SAY, 2600}})
9574
da3d39667881 strings checked, all ok except ice02 that will be probably changed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9572
diff changeset
   429
	table.insert(dialog01, {func = AnimSay, args = {doctor.gear, loc("In am also entrusting you with some rope"), SAY_SAY, 5000}})
da3d39667881 strings checked, all ok except ice02 that will be probably changed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9572
diff changeset
   430
	table.insert(dialog01, {func = AnimSay, args = {doctor.gear, loc("You may find it handy"), SAY_SAY, 2300}})
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   431
	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Thank you Dr.Cornelius"), SAY_SAY, 1600}})
9574
da3d39667881 strings checked, all ok except ice02 that will be probably changed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9572
diff changeset
   432
	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("I'll make good use of it"), SAY_SAY, 4500}})
da3d39667881 strings checked, all ok except ice02 that will be probably changed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9572
diff changeset
   433
	table.insert(dialog01, {func = AnimSay, args = {director.gear, loc("It would be wiser to steal the space ship while PAotH guards are taking a brake!"), SAY_SAY, 7000}})
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   434
	table.insert(dialog01, {func = AnimSay, args = {director.gear, loc("Remember! Many will seek the anti-gravity device! Now go, hurry up!"), SAY_SAY, 4000}})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   435
	table.insert(dialog01, {func = AnimSwitchHog, args = {hero.gear}})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   436
	-- DIALOG 02 - Hero got the saucer
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   437
	AddSkipFunction(dialog02, Skipanim, {dialog02})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   438
	table.insert(dialog02, {func = AnimWait, args = {hero.gear, 500}})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   439
	table.insert(dialog02, {func = AnimCaption, args = {hero.gear, loc("CheckPoint reached!"),  4000}})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   440
	table.insert(dialog02, {func = AnimSay, args = {hero.gear, loc("Got the saucer!"), SAY_SHOUT, 2000}})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   441
	table.insert(dialog02, {func = AnimSay, args = {director.gear, loc("Nice!"), SAY_SHOUT, 1000}})
9574
da3d39667881 strings checked, all ok except ice02 that will be probably changed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9572
diff changeset
   442
	table.insert(dialog02, {func = AnimSay, args = {director.gear, loc("Now use it and go to the moon PAotH station to get more fuels!"), SAY_SHOUT, 5000}})
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   443
    table.insert(dialog02, {func = AnimGearWait, args = {hero.gear, 500}})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   444
    -- DIALOG 03 - Hero got spotted by guard
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   445
	AddSkipFunction(dialog03, Skipanim, {dialog03})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   446
	table.insert(dialog03, {func = AnimWait, args = {guard1.gear, 4000}})
9574
da3d39667881 strings checked, all ok except ice02 that will be probably changed
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9572
diff changeset
   447
	table.insert(dialog03, {func = AnimCaption, args = {guard1.gear, loc("Prepare to flee!"),  4000}})	
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   448
	table.insert(dialog03, {func = AnimSay, args = {guard1.gear, loc("Hey").." "..guard2.name.."! "..loc("Look, someone is stealing the saucer!"), SAY_SHOUT, 4000}})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   449
	table.insert(dialog03, {func = AnimSay, args = {guard2.gear, loc("I'll get him!"), SAY_SAY, 4000}})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   450
	table.insert(dialog03, {func = startCombat, args = {guard1.gear}})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   451
	-- DIALOG 04 - Hero out of sight
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   452
	AddSkipFunction(dialog04, Skipanim, {dialog04})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   453
	table.insert(dialog04, {func = AnimCaption, args = {guard1.gear, loc("You are out of danger, time to go to the moon!"),  4000}})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   454
	table.insert(dialog04, {func = AnimSay, args = {guard1.gear, loc("I guess we lost him!"), SAY_SAY, 3000}})
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   455
	table.insert(dialog04, {func = AnimSay, args = {guard2.gear, loc("We should better report this and continue our watch!"), SAY_SAY, 5000}})
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   456
	table.insert(dialog04, {func = AnimSwitchHog, args = {hero.gear}})
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   457
	-- DIALOG 05 - Hero returned from moon without fuels
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   458
	AddSkipFunction(dialog05, Skipanim, {dialog05})
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   459
	table.insert(dialog05, {func = AnimSay, args = {hero.gear, loc("I guess I can't go far without fuels!"), SAY_THINK, 6000}})
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   460
	table.insert(dialog05, {func = AnimSay, args = {hero.gear, loc("Go to go back"), SAY_THINK, 2000}})
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   461
	table.insert(dialog05, {func = EndGame, args = {hero.gear}})
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   462
	-- DIALOG 06 - Landing on wrong planet or on earth if not enough fuels
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   463
	AddSkipFunction(dialog06, Skipanim, {dialog06})
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   464
	table.insert(dialog06, {func = AnimCaption, args = {hero.gear, loc("You have to try again!"),  5000}})
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   465
	table.insert(dialog06, {func = AnimSay, args = {hero.gear, loc("Hm... Now I run out of fuels..."), SAY_THINK, 3000}})
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   466
	table.insert(dialog06, {func = EndGame, args = {hero.gear}})
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   467
end
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   468
9266
199c1f066aad added landing event handlers for cosmos.lua
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9258
diff changeset
   469
------------------- custom "animation" functions --------------------------
9258
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   470
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   471
function startCombat()
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   472
	-- use this so guard2 will gain control
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   473
	AnimSwitchHog(hero.gear)
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   474
	TurnTimeLeft = 0
5c760ed50b3d first commit, added cosmos(menu) map and lua script with some functionality
Periklis Ntanasis <pntanasis@gmail.com>
parents:
diff changeset
   475
end