share/hedgewars/Data/Missions/Training/Basic_Training_-_Rope.lua
author Periklis Ntanasis <pntanasis@gmail.com>
Thu, 19 Sep 2013 02:33:23 +0300
branchspacecampaign
changeset 9641 b08c8bde57e3
parent 8043 da083f8d95e6
child 10290 42efccba0711
permissions -rw-r--r--
fixes bug that doesn't display mission name in drop down list
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
     1
--Created by Patrick Nielsen
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
     2
--It's been so fun to create this, your welcome to contact me at Trivkz@gmail.com
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
     3
--
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
     4
--I've tried to keep the code as clear as possible and with comments.
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
     5
--But as English is not my first language there may be spelling / grammar mistakes.
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
     6
--
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
     7
--I know there need to be more "tutorial" specefic messages, but I had a hard timer figuring out what to type / what would be the best technical description.
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
     8
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
     9
8043
da083f8d95e6 We need custom script loading function in lua now
unc0rr
parents: 7838
diff changeset
    10
HedgewarsScriptLoad("/Scripts/Locale.lua")
da083f8d95e6 We need custom script loading function in lua now
unc0rr
parents: 7838
diff changeset
    11
HedgewarsScriptLoad("/Scripts/Utils.lua") -- For the gearIsInBox function, wrote my own, but decided it was a waste to include it
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    12
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    13
local Player = nil -- Pointer to hog created in: onGameInit
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    14
local Target = nil -- Pointer to target hog
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    15
local GameLost = false -- You lost the game
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    16
local Objective = false -- Get to the target
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    17
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    18
local WaitTime = 10000 -- Wait 10sec before quit
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    19
local FollowTime = 1500 -- For use with FollowGear
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    20
local FollowingGear = false
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    21
local BaseballIntro = false -- Fail safe for ticker
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    22
local TargetNumber = 0 -- The current target number
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    23
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    24
local TargetPos = {} -- Tabel of targets
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    25
local Timers = {}
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    26
local GetTime = 0
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    27
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    28
TargetPos[ 1 ] = { X = 1100, Y = 1100, Message = loc("Now find the next target! |Tip: Normally you lose health by falling down, so be careful!") }
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    29
TargetPos[ 2 ] = { X = 1500, Y = 1490, Message = loc("You're getting pretty good! |Tip: When you shorten you rope you move faster! |and when you lengthen it you move slower") }
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    30
TargetPos[ 3 ] = { X = 2200, Y = 800, Message = loc("The next one is pretty hard! |Tip: You have to do multiple swings!") }
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    31
TargetPos[ 4 ] = { X = 2870, Y = 400, Message = loc("I don't know how you did that.. But good work! |The next one should be easy as cake for you!") }
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    32
TargetPos[ 5 ] = { X = 4000, Y = 1750, Message = "" }
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    33
TargetPos[ 6 ] = { Modifier = true, Func = function() -- Last target is ALWAYS the "winning" target!
7827
353d90ddc188 Fix bad loc calls in campaign, rope training. Regenerate lua. Untested.
nemo
parents: 7165
diff changeset
    34
	Info( loc("Congratulations"), loc("Congratulations! You've completed the Rope tutorial! |- Tutorial ends in 10 seconds!"), 0 ) -- Congrats
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    35
	HogSay( Player, loc("Victory!"), SAY_SHOUT) -- You win!
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    36
	PlaySound( sndVictory )
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    37
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    38
	if TurnTimeLeft >= 250000 then -- If you very fast, unlock the ahievement "Rope Master!"
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    39
		AddCaption( loc( "Achievement Unlocked" ) .. ": " .. loc( "Rope Master!" ),0xffba00ff,capgrpAmmoinfo )
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    40
		PlaySound( sndHomerun )
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    41
	end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    42
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    43
	Objective = true
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    44
end }
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    45
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    46
function Info( Title, Text, Icon ) -- I made a small wrapper to ease the process
7827
353d90ddc188 Fix bad loc calls in campaign, rope training. Regenerate lua. Untested.
nemo
parents: 7165
diff changeset
    47
	ShowMission( loc("Rope Training"), Title, Text, Icon, 0 )
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    48
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    49
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    50
function NewFollowGear( Gear )
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    51
	FollowingGear = true
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    52
	FollowGear( Gear )
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    53
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    54
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    55
function SpawnTarget( PosX, PosY )
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    56
	Target = AddGear( 0, 0, gtTarget, 0, 0, 0, 0 ) -- Create a new target
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    57
	SetGearPosition( Target, PosX, PosY ) -- Set the position of the target
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    58
	NewFollowGear( Target )
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    59
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    60
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    61
function AutoSpawn() -- Auto spawn the next target after you've killed the current target!
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    62
	TargetNumber = TargetNumber + 1
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    63
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    64
	if TargetPos[ TargetNumber ].Modifier then -- If there is a modifier, run the function, only used in the winning target!
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    65
		TargetPos[ TargetNumber ].Func()
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    66
		return true
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    67
	end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    68
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    69
	if TargetNumber > 1 then
7827
353d90ddc188 Fix bad loc calls in campaign, rope training. Regenerate lua. Untested.
nemo
parents: 7165
diff changeset
    70
		Info(loc("Aiming Practice"), TargetPos[ TargetNumber - 1 ].Message, -amRope )
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    71
	end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    72
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    73
	SpawnTarget( TargetPos[ TargetNumber ].X, TargetPos[ TargetNumber ].Y ) -- Spawn target on the next position
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    74
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    75
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    76
function InRange( Gear, PosX, PosY, Distance ) -- Fix as the default function didn't do quite what I needed
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    77
	GearX, GearY = GetGearPosition( Gear )
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    78
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    79
    return GearX >= PosX - Distance and GearX <= PosX + Distance and GearY >= PosY and GearY - Distance <= PosY + Distance
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    80
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    81
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    82
function CheckPosition( Hog, Distance ) -- Show a message when you get close to the current target!
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    83
	if (not BaseballIntro and not Objective) and (CurrentHedgehog ~= nil) then --Fail safe check
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    84
		if InRange( Hog, 1100, 1100, Distance ) then -- Check if the player is within predefined position of the first target
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    85
			BaseballIntro = true
7827
353d90ddc188 Fix bad loc calls in campaign, rope training. Regenerate lua. Untested.
nemo
parents: 7165
diff changeset
    86
			Info(loc("Aiming Practice"), loc("Great work! Now hit it with your Baseball Bat! |Tip: You can change weapon with 'Right Click'!"), -amRope ) -- Guide them
353d90ddc188 Fix bad loc calls in campaign, rope training. Regenerate lua. Untested.
nemo
parents: 7165
diff changeset
    87
			Timer( 10000, loc("Remember: The rope only bend around objects, |if it doesn't hit anything it's always stright!"))
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    88
		end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    89
	end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    90
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    91
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    92
function Timer( Delay, Message )
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    93
	local Timer = {}
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    94
	Timer.End = GetTime + Delay
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    95
	Timer.Message = Message
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    96
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    97
	table.insert( Timers, Timer )
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    98
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    99
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   100
function onGameInit() -- Called when the game loads
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   101
	Seed = 1 -- The base number for the random number generator
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   102
	GameFlags = gfInfAttack + gfOneClanMode + gfSolidLand + gfInvulnerable + gfBorder -- Game settings and rules, going with a border to make it easier
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   103
	TurnTime = 300000 -- Player can move for 5min each round
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   104
	CaseFreq = 0 -- No random crate drops
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   105
	MinesNum = 0 -- Never place any mines on the map
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   106
	Explosives = 0 -- Never place any explosives
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   107
	Delay = 1 -- We don't wont to wait between each round ( as the only is one )
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   108
	Map = "Ropes" -- Map name
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   109
	Theme = "Nature" -- Map theme
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   110
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   111
	AddTeam( loc( "Rope Team" ), 14483456, "Simple", "Island", "Default" ) -- Lets make the team
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   112
	Player = AddHog( loc( "Hunter" ), 0, 1, "StrawHat" ) -- Add a hog for it, and name it "Hunter"
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   113
	SetGearPosition( Player, 420, 1750 ) -- Set player position
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   114
7838
5c2337f8dbb2 Issue #443 - change in syntax for effects
nemo
parents: 7827
diff changeset
   115
	SetEffect( Player, heResurrectable, 1 ) -- By Suggestion :)
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   116
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   117
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   118
function onGameStart() -- Called when the game starts
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   119
	AutoSpawn() -- Spawn our 1st target using the wrapper function
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   120
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   121
	SetHealth( Player, 100 ) -- Give the player 100 Health points
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   122
7827
353d90ddc188 Fix bad loc calls in campaign, rope training. Regenerate lua. Untested.
nemo
parents: 7165
diff changeset
   123
	Info(loc("Aiming Practice"), loc("Get to the target using your rope! |Controls: Left & Right to swing the rope - Up & Down to Contract and Expand!"), -amRope ) -- Short intro to tell the player what to do
353d90ddc188 Fix bad loc calls in campaign, rope training. Regenerate lua. Untested.
nemo
parents: 7165
diff changeset
   124
	Timer( 10000, loc("Tip: The rope physics are different than in the real world, |use it to your advantage!") ) -- After 15 sec, give them more help
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   125
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   126
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   127
function onNewTurn()
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   128
	ParseCommand( "setweap " .. string.char( amRope ) ) -- Set the default weapon to Rope
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   129
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   130
7165
aad1aea05f1e add onGameTick20 to basic training, extend laser sight out way more (it was visible at top when completely zoomed out), move call of new turn to after AfterSwitchHedgehog to avoid lua issues in onNewTurn - if this causes problems, lua can do delayed actions in onGameTick
nemo
parents: 6501
diff changeset
   131
function onGameTick20()
aad1aea05f1e add onGameTick20 to basic training, extend laser sight out way more (it was visible at top when completely zoomed out), move call of new turn to after AfterSwitchHedgehog to avoid lua issues in onNewTurn - if this causes problems, lua can do delayed actions in onGameTick
nemo
parents: 6501
diff changeset
   132
	if TurnTimeLeft < 40 and TurnTimeLeft > 0 then -- Round starts at 0, so we check if the round is finished by using 1
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   133
		GameLost = true -- You lost the game
7827
353d90ddc188 Fix bad loc calls in campaign, rope training. Regenerate lua. Untested.
nemo
parents: 7165
diff changeset
   134
		Info(loc("Aiming Practice"), loc("You did not make it in time, try again!"), -amSkip )
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   135
		SetHealth( Player, 0 ) -- Kill the player so he can't keep moving!
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   136
7838
5c2337f8dbb2 Issue #443 - change in syntax for effects
nemo
parents: 7827
diff changeset
   137
		SetEffect( Player, heResurrectable, 0 )
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   138
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   139
	end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   140
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   141
	-- If the player gets to the last target, they win OR
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   142
	-- If round is finished and your not at the target you lose
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   143
	-- in either case, end the game
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   144
	if (Objective == true) or (GameLost == true) then
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   145
		if (WaitTime == 0) then
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   146
			ParseCommand("teamgone " .. loc( "Rope Team" ))
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   147
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   148
			--SetHealth( Player, 0 ) -- Kill the player so he can't keep moving!
7838
5c2337f8dbb2 Issue #443 - change in syntax for effects
nemo
parents: 7827
diff changeset
   149
			--SetEffect( Player, heResurrectable, 0 )
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   150
			TurnTimeLeft = 1
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   151
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   152
			WaitTime = -1
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   153
		else
7165
aad1aea05f1e add onGameTick20 to basic training, extend laser sight out way more (it was visible at top when completely zoomed out), move call of new turn to after AfterSwitchHedgehog to avoid lua issues in onNewTurn - if this causes problems, lua can do delayed actions in onGameTick
nemo
parents: 6501
diff changeset
   154
			WaitTime = WaitTime - 20
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   155
		end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   156
	end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   157
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   158
	if FollowingGear == true then
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   159
		if FollowTime == 0 then
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   160
			FollowingGear = false
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   161
			FollowTime = 1500
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   162
			FollowGear( Player )
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   163
		else
7165
aad1aea05f1e add onGameTick20 to basic training, extend laser sight out way more (it was visible at top when completely zoomed out), move call of new turn to after AfterSwitchHedgehog to avoid lua issues in onNewTurn - if this causes problems, lua can do delayed actions in onGameTick
nemo
parents: 6501
diff changeset
   164
			FollowTime = FollowTime - 20
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   165
		end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   166
	end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   167
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   168
	for k, v in pairs( Timers ) do
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   169
		if v.End <= GetTime then
7827
353d90ddc188 Fix bad loc calls in campaign, rope training. Regenerate lua. Untested.
nemo
parents: 7165
diff changeset
   170
			Info(loc("Aiming Practice"), v.Message, -amRope )
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   171
			Timers[ k ] = nil
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   172
		end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   173
	end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   174
7165
aad1aea05f1e add onGameTick20 to basic training, extend laser sight out way more (it was visible at top when completely zoomed out), move call of new turn to after AfterSwitchHedgehog to avoid lua issues in onNewTurn - if this causes problems, lua can do delayed actions in onGameTick
nemo
parents: 6501
diff changeset
   175
	GetTime = GetTime + 20
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   176
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   177
	CheckPosition( Player, 70 ) -- Run the CheckPosition function to check if the player is close to a target
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   178
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   179
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   180
function onAmmoStoreInit()
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   181
	SetAmmo( amRope, 9, 2, 0, 0 ) -- Player ammo, Rope
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   182
	SetAmmo( amBaseballBat, 9, 2, 0, 0 ) --Baseball bat
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   183
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   184
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   185
function onGearResurrect( Gear )
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   186
	if TargetNumber > 1 then
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   187
		SetGearPosition( Player, TargetPos[ TargetNumber - 1 ].X, TargetPos[ TargetNumber - 1 ].Y ) -- If the player dies spawn him where he last killed a target
7827
353d90ddc188 Fix bad loc calls in campaign, rope training. Regenerate lua. Untested.
nemo
parents: 7165
diff changeset
   188
		Info(loc("Aiming Practice"), loc("You have been respawned, at your last checkpoint!"), -amRope )
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   189
	else
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   190
		SetGearPosition( Player, 420, 1750 ) -- If the player dies and didn't kill a target just spawn him at the default spawn
7827
353d90ddc188 Fix bad loc calls in campaign, rope training. Regenerate lua. Untested.
nemo
parents: 7165
diff changeset
   191
		Info(loc("Aiming Practice"), loc("You have been respawned, be more carefull next time!"), -amRope )
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   192
	end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   193
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   194
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   195
function onGearDelete( Gear )
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   196
	if GetGearType( Gear ) == gtTarget then
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   197
		AutoSpawn() -- When a target is deleted / destroyed, spawn a new one!
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   198
	end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   199
end