share/hedgewars/Data/Scripts/Multiplayer/Racer.lua
author Wuzzy <Wuzzy@disroot.org>
Wed, 28 Jun 2023 23:41:38 +0200
changeset 15970 a803428704fd
parent 15964 d18261ddac4a
permissions -rw-r--r--
Make use of GetEngineString in Lua scripts
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15396
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
     1
--[[
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
     2
RACER
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
     3
map-independant racing script
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
     4
originally by mikade, edited heavily by others
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
     5
15396
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
     6
-----------------------------------------
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
     7
Script parameters:
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
     8
rounds=N
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
     9
--> The game will be played with N rounds (default: 3)
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
    10
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
    11
waypointradius=N
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
    12
--> The waypoints have a radius of N pixels (default: 450)
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
    13
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
    14
maxwaypoints=N
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
    15
--> The maximum number of waypoints to be placed (default: 8)
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
    16
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
    17
teamrope=true
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
    18
--> The team will be colored in the color of the team.
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    19
-----------------------------------------
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    20
15396
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
    21
DEVELOPER WARNING - FOR OFFICIAL DEVELOPMENT --
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
    22
Be careful when editig this script, do not introduce changes lightly!
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
    23
This script is used for time records on the official Hedgewars server.
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
    24
Introducing breaking changes means we have to invalidate past time records!
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    25
15396
1c71406fc281 Racer: Clean up comments
Wuzzy <Wuzzy2@mail.ru>
parents: 15385
diff changeset
    26
]]
11647
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
    27
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    28
-----------------------------
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    29
-- SCRIPT BEGINS
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    30
-----------------------------
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    31
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    32
HedgewarsScriptLoad("/Scripts/Locale.lua")
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    33
HedgewarsScriptLoad("/Scripts/OfficialChallenges.lua")
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    34
HedgewarsScriptLoad("/Scripts/Params.lua")
15970
a803428704fd Make use of GetEngineString in Lua scripts
Wuzzy <Wuzzy@disroot.org>
parents: 15964
diff changeset
    35
HedgewarsScriptLoad("/Scripts/Utils.lua")
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    36
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    37
------------------
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    38
-- Got Variables?
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    39
------------------
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    40
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    41
local roundLimit = 3
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    42
local roundNumber = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    43
local firstClan = 10
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    44
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    45
local fastX = {}
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    46
local fastY = {}
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    47
local fastCount = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    48
local fastIndex = 0
11581
fd02a080d962 - Fix room config being sent unmodified
unc0rr
parents: 11569
diff changeset
    49
local fastColour = 0xffffffff
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    50
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    51
local currX = {}
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    52
local currY = {}
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    53
local currCount = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    54
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    55
local specialPointsX = {}
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    56
local specialPointsY = {}
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    57
local specialPointsCount = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    58
15488
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
    59
local landObjectPoints = {}
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
    60
local landObjects = {}
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
    61
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    62
local TeamRope = false
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    63
13129
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
    64
local waypointCursor = false
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
    65
local waypointPreview = nil
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
    66
14070
a5be3ef4bbbe Update official challenge hashes, improve console logging (warning: racer #17 is missing!)
Wuzzy <Wuzzy2@mail.ru>
parents: 13841
diff changeset
    67
local officialChallenge
a5be3ef4bbbe Update official challenge hashes, improve console logging (warning: racer #17 is missing!)
Wuzzy <Wuzzy2@mail.ru>
parents: 13841
diff changeset
    68
15403
e347c3508f95 Racer: Fix ammo delay confusion if gfKing or gfPlaceHog were set
Wuzzy <Wuzzy2@mail.ru>
parents: 15402
diff changeset
    69
local ammoDelays
15398
09b63f9032f4 Racer: Disable other ammos in waypoint placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 15397
diff changeset
    70
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    71
--------------------------
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    72
-- hog and team tracking variales
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    73
--------------------------
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    74
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    75
local numhhs = 0 -- store number of hedgehogs
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    76
local hhs = {} -- store hedgehog gears
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    77
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    78
local numTeams --  store the number of teams in the game
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    79
local teamNameArr = {}  -- store the list of teams
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    80
local teamClan = {}
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    81
local teamSize = {}     -- store how many hogs per team
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    82
local teamIndex = {} -- at what point in the hhs{} does each team begin
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    83
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    84
local teamComment = {}
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    85
local teamScore = {}
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    86
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    87
-------
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    88
-- racer vars
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    89
--------
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    90
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    91
local cGear = nil
13024
a568bc16a99a Racer and TechRacer: Move cameera to first waypoint in Ready phase
Wuzzy <Wuzzy2@mail.ru>
parents: 12967
diff changeset
    92
local cameraGear = nil -- gear created to center the cameera on
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    93
11930
4ed643879c0f Racer: Clean up “did not finish” mess
Wuzzy <almikes@aol.com>
parents: 11929
diff changeset
    94
local bestClan = 10
13839
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
    95
local bestTime = MAX_TURN_TIME
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    96
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    97
local gameBegun = false
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    98
local gameOver = false
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
    99
local racerActive = false
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   100
local trackTime = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   101
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   102
local wpCirc = {}
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   103
local wpX = {}
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   104
local wpY = {}
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   105
local wpCol = {}
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   106
local wpActive = {}
11929
167de692f2d7 Add new Racer script parameter: waypointradius
Wuzzy <almikes@aol.com>
parents: 11928
diff changeset
   107
local wpRad = 450
15483
70aba717485a Racer: Reposition and resize predefined waypoints in scaled drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents: 15413
diff changeset
   108
local WAYPOINT_RADIUS_MIN = 40
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   109
local wpCount = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   110
local wpLimit = 8
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   111
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   112
local usedWeapons = {}
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   113
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   114
local roundN
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   115
local lastRound
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   116
local RoundHasChanged
12407
8cc070640fd1 Fix skipping in Racer causing the next team to be skipped, too
Wuzzy <almikes@aol.com>
parents: 12406
diff changeset
   117
local turnSkipped = false
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   118
11647
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   119
local boostX = 0
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   120
local boostY = 0
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   121
local boostValue = 1
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   122
12967
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   123
-- themes with bright background
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   124
local brightThemes = {
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   125
	Bath = true,
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   126
	Bamboo = true,
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   127
	Beach = true,
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   128
	Blox = true,
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   129
	Compost = true,
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   130
	Desert = true,
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   131
	Fruit = true,
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   132
	Golf = true,
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   133
	Hoggywood = true,
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   134
	Jungle = true,
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   135
	Olympics = true,
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   136
	Sheep = true,
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   137
}
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   138
-- themes with medium or heavily mixed brightness.
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   139
-- only add themes here if both bright and dark waypoint
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   140
-- colors fail otherwise.
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   141
local mediumThemes = {
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   142
	Halloween = true,
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   143
}
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   144
-- All themes not explicitly listed above are assumed to
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   145
-- be "dark" and work with the default bright waypoints.
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   146
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   147
-- Waypoint colors in 3 color themes!
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   148
-- We do this so the waypoints are easy on the eyes,
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   149
-- at least in each of the default themes.
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   150
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   151
-- Bright waypoints (default)
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   152
local waypointColourBright = 0xFFFFFFFF -- Primary colour of inactive waypoints
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   153
local waypointColourBrightAtPlacement = 0xAAAAAAFF -- Colour of non-highlighted waypoints while placing
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   154
-- Medium bright waypoints
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   155
local waypointColourMedium = 0x606060FF
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   156
local waypointColourMediumAtPlacement = 0x404040FF
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   157
-- Dark waypoints
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   158
local waypointColourDark = 0x000000FF
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   159
local waypointColourDarkAtPlacement = 0x303030FF
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   160
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   161
-- Waypoints touched by the players assume the clan color, which is unchanged.
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   162
-- Touched waypoints are not important to be visible.
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   163
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   164
-- Default waypoint colors (only use these color variables in the code below)
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   165
local waypointColour = waypointColourBright
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   166
local waypointColourAtPlacement = waypointColourBrightAtPlacement
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   167
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   168
-------------------
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   169
-- general methods
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   170
-------------------
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   171
12967
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   172
-- Returns brightness level of background from 1-3.
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   173
-- 1 = brightest
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   174
function GetBackgroundBrightness()
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   175
	-- This just looks at the theme names above.
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   176
	-- This code will fail for bright unofficial themes.
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   177
	-- TODO: Change how this thing works.
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   178
	-- Consider adding a function into the Lua API which looks
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   179
	-- up the theme's sky color, so we could use thit instead.
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   180
	if brightThemes[Theme] then
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   181
		return 1
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   182
	elseif mediumThemes[Theme] then
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   183
		return 2
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   184
	else
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   185
		return 3
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   186
	end
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   187
end
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   188
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   189
function onParameters()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   190
    parseParams()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   191
    if params["teamrope"] ~= nil then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   192
        TeamRope = true
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   193
    end
11926
ace20b1d8d53 Add “rounds” script parameter for Racer
Wuzzy <almikes@aol.com>
parents: 11925
diff changeset
   194
    if params["rounds"] ~= nil then
15964
d18261ddac4a Fix errors if passing bad script param to [Tech]Racer
Wuzzy <Wuzzy@disroot.org>
parents: 15788
diff changeset
   195
        roundLimit = tonumber(params["rounds"])
11926
ace20b1d8d53 Add “rounds” script parameter for Racer
Wuzzy <almikes@aol.com>
parents: 11925
diff changeset
   196
        if type(roundLimit) ~= "number" then
ace20b1d8d53 Add “rounds” script parameter for Racer
Wuzzy <almikes@aol.com>
parents: 11925
diff changeset
   197
             roundLimit = 3
ace20b1d8d53 Add “rounds” script parameter for Racer
Wuzzy <almikes@aol.com>
parents: 11925
diff changeset
   198
        end
15964
d18261ddac4a Fix errors if passing bad script param to [Tech]Racer
Wuzzy <Wuzzy@disroot.org>
parents: 15788
diff changeset
   199
        roundLimit = math.max(1, math.floor(roundLimit))
11926
ace20b1d8d53 Add “rounds” script parameter for Racer
Wuzzy <almikes@aol.com>
parents: 11925
diff changeset
   200
    end
11929
167de692f2d7 Add new Racer script parameter: waypointradius
Wuzzy <almikes@aol.com>
parents: 11928
diff changeset
   201
    if params["waypointradius"] ~= nil then
15964
d18261ddac4a Fix errors if passing bad script param to [Tech]Racer
Wuzzy <Wuzzy@disroot.org>
parents: 15788
diff changeset
   202
        wpRad = tonumber(params["waypointradius"])
11985
b2783dd12f30 Fix incorrect type check of wpRad in Racer
Wuzzy <almikes@aol.com>
parents: 11984
diff changeset
   203
        if type(wpRad) ~= "number" then
11929
167de692f2d7 Add new Racer script parameter: waypointradius
Wuzzy <almikes@aol.com>
parents: 11928
diff changeset
   204
             wpRad = 450
167de692f2d7 Add new Racer script parameter: waypointradius
Wuzzy <almikes@aol.com>
parents: 11928
diff changeset
   205
        end
15964
d18261ddac4a Fix errors if passing bad script param to [Tech]Racer
Wuzzy <Wuzzy@disroot.org>
parents: 15788
diff changeset
   206
        wpRad = math.max(WAYPOINT_RADIUS_MIN, math.floor(wpRad))
11929
167de692f2d7 Add new Racer script parameter: waypointradius
Wuzzy <almikes@aol.com>
parents: 11928
diff changeset
   207
    end
11986
f97b1c7fa053 Allow to set Racer waypoint limit with script parameter “maxwaypoints”
Wuzzy <almikes@aol.com>
parents: 11985
diff changeset
   208
    if params["maxwaypoints"] ~= nil then
15964
d18261ddac4a Fix errors if passing bad script param to [Tech]Racer
Wuzzy <Wuzzy@disroot.org>
parents: 15788
diff changeset
   209
        wpLimit = tonumber(params["maxwaypoints"])
11986
f97b1c7fa053 Allow to set Racer waypoint limit with script parameter “maxwaypoints”
Wuzzy <almikes@aol.com>
parents: 11985
diff changeset
   210
        if type(wpLimit) ~= "number" then
f97b1c7fa053 Allow to set Racer waypoint limit with script parameter “maxwaypoints”
Wuzzy <almikes@aol.com>
parents: 11985
diff changeset
   211
             wpLimit = 8
f97b1c7fa053 Allow to set Racer waypoint limit with script parameter “maxwaypoints”
Wuzzy <almikes@aol.com>
parents: 11985
diff changeset
   212
        end
15964
d18261ddac4a Fix errors if passing bad script param to [Tech]Racer
Wuzzy <Wuzzy@disroot.org>
parents: 15788
diff changeset
   213
        wpLimit = math.max(2, math.floor(wpLimit))
11986
f97b1c7fa053 Allow to set Racer waypoint limit with script parameter “maxwaypoints”
Wuzzy <almikes@aol.com>
parents: 11985
diff changeset
   214
    end
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   215
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   216
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   217
function RebuildTeamInfo()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   218
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   219
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   220
        -- make a list of individual team names
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   221
        for i = 0, (TeamsCount-1) do
11928
42e90b244e11 Racer: Dump old commented-out code
Wuzzy <almikes@aol.com>
parents: 11927
diff changeset
   222
                teamNameArr[i] = " "
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   223
                teamSize[i] = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   224
                teamIndex[i] = 0
13839
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   225
                teamScore[i] = MAX_TURN_TIME
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   226
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   227
        numTeams = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   228
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   229
        for i = 0, (numhhs-1) do
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   230
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   231
                z = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   232
                unfinished = true
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   233
                while(unfinished == true) do
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   234
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   235
                        newTeam = true
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   236
                        tempHogTeamName = GetHogTeamName(hhs[i]) -- this is the new name
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   237
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   238
                        if tempHogTeamName == teamNameArr[z] then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   239
                                newTeam = false
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   240
                                unfinished = false
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   241
                        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   242
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   243
                        z = z + 1
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   244
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   245
                        if z == TeamsCount then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   246
                                unfinished = false
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   247
                                if newTeam == true then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   248
                                        teamNameArr[numTeams] = tempHogTeamName
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   249
                                        numTeams = numTeams + 1
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   250
                                end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   251
                        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   252
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   253
                end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   254
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   255
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   256
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   257
        -- find out how many hogs per team, and the index of the first hog in hhs
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   258
        for i = 0, (numTeams-1) do
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   259
                for z = 0, (numhhs-1) do
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   260
                        if GetHogTeamName(hhs[z]) == teamNameArr[i] then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   261
                                teamClan[i] = GetHogClan(hhs[z])
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   262
                                if teamSize[i] == 0 then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   263
                                        teamIndex[i] = z -- should give starting index
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   264
                                end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   265
                                teamSize[i] = teamSize[i] + 1
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   266
                                --add a pointer so this hog appears at i in hhs
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   267
                        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   268
                end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   269
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   270
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   271
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   272
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   273
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   274
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   275
-----------------
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   276
-- RACER METHODS
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   277
-----------------
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   278
11647
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   279
function onLeft()
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   280
	boostX = boostX +boostValue
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   281
end
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   282
function onLeftUp()
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   283
	boostX = boostX -boostValue
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   284
end
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   285
function onRight()
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   286
	boostX = boostX -boostValue
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   287
end
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   288
function onRightUp()
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   289
	boostX = boostX +boostValue
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   290
end
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   291
function onUp()
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   292
	boostY = boostY +boostValue
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   293
end
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   294
function onUpUp()
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   295
	boostY = boostY -boostValue
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   296
end
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   297
function onDown()
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   298
	boostY = boostY -boostValue
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   299
end
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   300
function onDownUp()
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   301
	boostY = boostY +boostValue
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   302
end
b4d621700bbb Allow variable boost directions in Racer
mikade <redgrinner@gmail.com>
parents: 11585
diff changeset
   303
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   304
function CheckWaypoints()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   305
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   306
        trackFinished = true
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   307
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   308
        for i = 0, (wpCount-1) do
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   309
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   310
                g1X, g1Y = GetGearPosition(CurrentHedgehog)
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   311
                g2X, g2Y = wpX[i], wpY[i]
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   312
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   313
                g1X = g1X - g2X
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   314
                g1Y = g1Y - g2Y
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   315
                dist = (g1X*g1X) + (g1Y*g1Y)
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   316
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   317
                NR = (48/100*wpRad)/2
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   318
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   319
                if dist < (NR*NR) then
11928
42e90b244e11 Racer: Dump old commented-out code
Wuzzy <almikes@aol.com>
parents: 11927
diff changeset
   320
                        wpCol[i] = GetClanColor(GetHogClan(CurrentHedgehog))
12962
52c12029c7bd Increase opacity of Racer/TechRacer waypoints
Wuzzy <Wuzzy2@mail.ru>
parents: 12407
diff changeset
   321
                        SetVisualGearValues(wpCirc[i], wpX[i], wpY[i], 64, 64, 1, 10, 0, wpRad, 5, wpCol[i])
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   322
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   323
                        wpRem = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   324
                        for k = 0, (wpCount-1) do
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   325
                                if wpActive[k] == false then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   326
                                        wpRem = wpRem + 1
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   327
                                end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   328
                        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   329
11925
7123bfc9643c Racer: Don't mess with ammo display when touching waypoint
Wuzzy <almikes@aol.com>
parents: 11924
diff changeset
   330
                        if wpActive[i] == false then
11927
72593678e8d6 Racer: Show “Track completed!” message
Wuzzy <almikes@aol.com>
parents: 11926
diff changeset
   331
                                local wpMessage = ""
72593678e8d6 Racer: Show “Track completed!” message
Wuzzy <almikes@aol.com>
parents: 11926
diff changeset
   332
                                if wpRem-1 == 0 then
72593678e8d6 Racer: Show “Track completed!” message
Wuzzy <almikes@aol.com>
parents: 11926
diff changeset
   333
                                         wpMessage = loc("Track completed!")
72593678e8d6 Racer: Show “Track completed!” message
Wuzzy <almikes@aol.com>
parents: 11926
diff changeset
   334
                                else
72593678e8d6 Racer: Show “Track completed!” message
Wuzzy <almikes@aol.com>
parents: 11926
diff changeset
   335
                                         wpMessage = string.format(loc("Waypoints remaining: %d"), wpRem-1)
72593678e8d6 Racer: Show “Track completed!” message
Wuzzy <almikes@aol.com>
parents: 11926
diff changeset
   336
                                end
72593678e8d6 Racer: Show “Track completed!” message
Wuzzy <almikes@aol.com>
parents: 11926
diff changeset
   337
                                AddCaption(wpMessage, 0xffba00ff, capgrpGameState)
11925
7123bfc9643c Racer: Don't mess with ammo display when touching waypoint
Wuzzy <almikes@aol.com>
parents: 11924
diff changeset
   338
                        end
7123bfc9643c Racer: Don't mess with ammo display when touching waypoint
Wuzzy <almikes@aol.com>
parents: 11924
diff changeset
   339
                        wpActive[i] = true
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   340
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   341
                end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   342
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   343
                if wpActive[i] == false then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   344
                        trackFinished = false
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   345
                end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   346
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   347
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   348
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   349
        return(trackFinished)
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   350
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   351
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   352
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   353
function AdjustScores()
11930
4ed643879c0f Racer: Clean up “did not finish” mess
Wuzzy <almikes@aol.com>
parents: 11929
diff changeset
   354
	bestTimeComment = loc("Did not finish")
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   355
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   356
        newScore = false
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   357
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   358
        -- update this clan's time if the new track is better
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   359
        for i = 0, (numTeams-1) do
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   360
                if teamClan[i] == GetHogClan(CurrentHedgehog) then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   361
                        if trackTime < teamScore[i] then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   362
                                teamScore[i] = trackTime
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   363
                                newScore = true
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   364
                        else
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   365
                                newScore = false
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   366
                        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   367
                end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   368
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   369
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   370
        -- find the best time out of those so far
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   371
        for i = 0, (numTeams-1) do
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   372
                if teamScore[i] < bestTime then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   373
                        bestTime = teamScore[i]
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   374
                        bestClan = teamClan[i]
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   375
                end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   376
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   377
13839
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   378
        if bestTime ~= MAX_TURN_TIME then
11924
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   379
                bestTimeComment = string.format(loc("%.1fs"), (bestTime/1000))
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   380
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   381
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   382
        if newScore == true then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   383
                if trackTime == bestTime then -- best time of the race
11924
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   384
                        ShowMission(loc("Racer"),
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   385
                        loc("Track completed!"),
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   386
                        string.format(loc("New race record: %.1fs"), (trackTime/1000)) .. "|" ..
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   387
                        string.format(loc("Winning time: %s"), bestTimeComment), 0, 4000)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   388
                        PlaySound(sndHomerun)
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   389
                else    -- best time for the clan
11924
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   390
                        ShowMission(loc("Racer"),
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   391
                        loc("Track completed!"),
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   392
                        string.format(loc("New clan record: %.1fs"), (trackTime/1000)) .. "|" ..
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   393
                        string.format(loc("Winning time: %s"), bestTimeComment), 4, 4000)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   394
                end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   395
        else -- not any kind of new score
11924
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   396
                ShowMission(loc("Racer"),
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   397
                loc("Track completed!"),
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   398
                string.format(loc("Time: %.1fs"), (trackTime/1000)) .. "|" ..
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   399
                string.format(loc("Winning time: %s"), bestTimeComment), -amSkip, 4000)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   400
                PlaySound(sndHellish)
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   401
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   402
13027
625d5a45f267 Racer/TechRacer: Show best times next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents: 13024
diff changeset
   403
        for i = 0, (TeamsCount-1) do
13839
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   404
                if teamNameArr[i] ~= " " and teamScore[i] ~= MAX_TURN_TIME then
13027
625d5a45f267 Racer/TechRacer: Show best times next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents: 13024
diff changeset
   405
                        SetTeamLabel(teamNameArr[i], string.format(loc("%.1fs"), teamScore[i]/1000))
625d5a45f267 Racer/TechRacer: Show best times next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents: 13024
diff changeset
   406
                end
625d5a45f267 Racer/TechRacer: Show best times next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents: 13024
diff changeset
   407
        end
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   408
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   409
        if bestTime == trackTime then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   410
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   411
                fastColour = GetClanColor(GetHogClan(CurrentHedgehog))
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   412
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   413
                for i = 0, (currCount-1) do
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   414
                        fastX[i] = currX[i]
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   415
                        fastY[i] = currY[i]
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   416
                end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   417
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   418
                fastCount = currCount
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   419
                fastIndex = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   420
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   421
        else
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   422
                currCount = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   423
                fastIndex = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   424
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   425
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   426
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   427
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   428
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   429
function onNewRound()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   430
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   431
        roundNumber = roundNumber + 1
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   432
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   433
        totalComment = ""
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   434
        for i = 0, (TeamsCount-1) do
13839
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   435
                        if teamNameArr[i] ~= " " and teamScore[i] ~= MAX_TURN_TIME then
11923
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   436
                                teamComment[i] = string.format(loc("%s: %.1fs"), teamNameArr[i], (teamScore[i]/1000)) .. "|"
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   437
                        else
11930
4ed643879c0f Racer: Clean up “did not finish” mess
Wuzzy <almikes@aol.com>
parents: 11929
diff changeset
   438
                                teamComment[i] = string.format(loc("%s: Did not finish"), teamNameArr[i]) .. "|"
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   439
                        end
11923
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   440
                        totalComment = totalComment .. teamComment[i]
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   441
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   442
15069
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 15068
diff changeset
   443
        local icon
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 15068
diff changeset
   444
        if roundNumber >= roundLimit then
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 15068
diff changeset
   445
                icon = 0
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 15068
diff changeset
   446
        else
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 15068
diff changeset
   447
                icon = 2
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 15068
diff changeset
   448
        end
11924
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   449
        ShowMission(    loc("Racer"),
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   450
                                        loc("Status update"),
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   451
                                        string.format(loc("Rounds complete: %d/%d"), roundNumber, roundLimit) .. "|" .. " " .. "|" ..
15069
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 15068
diff changeset
   452
                                        loc("Best team times: ") .. "|" .. totalComment, icon, 4000)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   453
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   454
        -- end game if its at round limit
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   455
        if roundNumber >= roundLimit then
11923
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   456
                -- Sort the scores for the ranking list
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   457
                local unfinishedArray = {}
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   458
                local sortedTeams = {}
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   459
                local k = 1
13839
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   460
                local c = 1
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   461
                local clanScores = {}
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   462
                local previousClan
11923
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   463
                for i = 0, TeamsCount-1 do
13839
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   464
                        local clan = GetTeamClan(teamNameArr[i])
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   465
                        if not clanScores[clan+1] then
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   466
	                       clanScores[clan+1] = {}
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   467
	                       clanScores[clan+1].index = clan
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   468
	                       clanScores[clan+1].score = teamScore[i]
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   469
                        end
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   470
                        if teamScore[i] ~= MAX_TURN_TIME and teamNameArr[i] ~= " " then
11923
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   471
                               sortedTeams[k] = {}
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   472
                               sortedTeams[k].name = teamNameArr[i]
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   473
                               sortedTeams[k].score = teamScore[i]
13839
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   474
	                       sortedTeams[k].clan = clan
11923
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   475
                               k = k + 1
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   476
                        else
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   477
                               table.insert(unfinishedArray, string.format(loc("%s did not finish the race."), teamNameArr[i]))
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   478
                        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   479
                end
13839
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   480
                table.sort(sortedTeams, function(team1, team2)
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   481
                        if team1.score == team2.score then
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   482
                                return team1.clan < team2.clan
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   483
                        else
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   484
                                return team1.score < team2.score
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   485
                        end
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   486
                end)
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   487
                table.sort(clanScores, function(clan1, clan2) return clan1.score < clan2.score end)
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   488
                local rank = 0
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   489
                local rankPlus = 0
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   490
                local prevScore
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   491
                local clanRanks = {}
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   492
                for c = 1, #clanScores do
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   493
                        rankPlus = rankPlus + 1
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   494
                        if clanScores[c].score ~= prevScore then
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   495
                                rank = rank + rankPlus
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   496
                                rankPlus = 0
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   497
                        end
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   498
                        prevScore = clanScores[c].score
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   499
                        clanRanks[clanScores[c].index] = rank
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   500
                end
11923
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   501
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   502
                -- Write all the stats!
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   503
                for i = 1, #sortedTeams do
14578
50f511588635 Outsource commonly used words in siPointType to QTfrontend
Wuzzy <Wuzzy2@mail.ru>
parents: 14548
diff changeset
   504
                        SendStat(siPointType, "!TIME")
13839
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   505
			SendStat(siTeamRank, tostring(clanRanks[GetTeamClan(sortedTeams[i].name)]))
11923
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   506
                        SendStat(siPlayerKills, sortedTeams[i].score, sortedTeams[i].name)
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   507
                end
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   508
13839
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   509
		local roundDraw = false
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   510
		if #clanScores >= 2 and clanScores[1].score == clanScores[2].score and clanScores[1].score ~= MAX_TURN_TIME then
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   511
			roundDraw = true
15970
a803428704fd Make use of GetEngineString in Lua scripts
Wuzzy <Wuzzy@disroot.org>
parents: 15964
diff changeset
   512
                        SendStat(siGameResult, GetEngineString("TMsgStrId", sidDraw))
13839
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   513
                        SendStat(siCustomAchievement, loc("The teams are tied for the fastest time."))
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   514
                elseif #sortedTeams >= 1 then
15970
a803428704fd Make use of GetEngineString in Lua scripts
Wuzzy <Wuzzy@disroot.org>
parents: 15964
diff changeset
   515
                        SendStat(siGameResult, formatEngineString(GetEngineString("TMsgStrId", sidWinner), sortedTeams[1].name))
11923
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   516
                        SendStat(siCustomAchievement, string.format(loc("%s wins with a best time of %.1fs."), sortedTeams[1].name, (sortedTeams[1].score/1000)))
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   517
                        for i=1,#unfinishedArray do
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   518
                                 SendStat(siCustomAchievement, unfinishedArray[i])
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   519
                        end
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   520
                else
13839
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   521
			roundDraw = true
15970
a803428704fd Make use of GetEngineString in Lua scripts
Wuzzy <Wuzzy@disroot.org>
parents: 15964
diff changeset
   522
                        SendStat(siGameResult, GetEngineString("TMsgStrId", sidDraw))
11923
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   523
                        SendStat(siCustomAchievement, loc("Nobody managed to finish the race. What a shame!"))
12406
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   524
                        if specialPointsCount > 0 then
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   525
                                SendStat(siCustomAchievement, loc("Maybe you should try an easier map next time."))
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   526
                        else
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   527
                                SendStat(siCustomAchievement, loc("Maybe you should try easier waypoints next time."))
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   528
                        end
11923
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   529
                end
85cbb2368269 Implement stats screen for Racer
Wuzzy <almikes@aol.com>
parents: 11648
diff changeset
   530
12333
6bdabf67a012 Add back the missing winning animation for Racer and TechRecer
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   531
		-- Kill all the losers
6bdabf67a012 Add back the missing winning animation for Racer and TechRecer
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   532
		for i = 0, (numhhs-1) do
13839
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   533
			if GetHogClan(hhs[i]) ~= bestClan or roundDraw then
12333
6bdabf67a012 Add back the missing winning animation for Racer and TechRecer
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   534
				SetEffect(hhs[i], heResurrectable, 0)
6bdabf67a012 Add back the missing winning animation for Racer and TechRecer
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   535
				SetHealth(hhs[i],0)
15400
06524f2e9a74 Racer: Make winners invulnerable
Wuzzy <Wuzzy2@mail.ru>
parents: 15399
diff changeset
   536
			elseif not roundDraw then
06524f2e9a74 Racer: Make winners invulnerable
Wuzzy <Wuzzy2@mail.ru>
parents: 15399
diff changeset
   537
				SetEffect(hhs[i], heInvulnerable, 1)
12333
6bdabf67a012 Add back the missing winning animation for Racer and TechRecer
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   538
			end
6bdabf67a012 Add back the missing winning animation for Racer and TechRecer
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   539
		end
6bdabf67a012 Add back the missing winning animation for Racer and TechRecer
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   540
6bdabf67a012 Add back the missing winning animation for Racer and TechRecer
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   541
		gameOver = true
12964
a5c5fe878a4e Racer, TechRacer: Fade out waypoints at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 12963
diff changeset
   542
                for i=0, wpCount-1 do
a5c5fe878a4e Racer, TechRacer: Fade out waypoints at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 12963
diff changeset
   543
                         -- Fade out waypoints
a5c5fe878a4e Racer, TechRacer: Fade out waypoints at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 12963
diff changeset
   544
                         SetVisualGearValues(wpCirc[i], nil, nil, 0, 0, nil, 6)
a5c5fe878a4e Racer, TechRacer: Fade out waypoints at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 12963
diff changeset
   545
                end
12333
6bdabf67a012 Add back the missing winning animation for Racer and TechRecer
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   546
		EndTurn(true)
6bdabf67a012 Add back the missing winning animation for Racer and TechRecer
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   547
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   548
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   549
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   550
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   551
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   552
function CheckForNewRound()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   553
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   554
        if GetHogClan(CurrentHedgehog) == firstClan then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   555
                onNewRound()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   556
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   557
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   558
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   559
12287
faf1b93422ba Use new EndTurn in a couple of scripts, esp. to fix timeout taunts in Racer
Wuzzy <almikes@aol.com>
parents: 12079
diff changeset
   560
function DisableTumbler(endTurn)
faf1b93422ba Use new EndTurn in a couple of scripts, esp. to fix timeout taunts in Racer
Wuzzy <almikes@aol.com>
parents: 12079
diff changeset
   561
        if endTurn == nil then endTurn = true end
faf1b93422ba Use new EndTurn in a couple of scripts, esp. to fix timeout taunts in Racer
Wuzzy <almikes@aol.com>
parents: 12079
diff changeset
   562
        if racerActive then
faf1b93422ba Use new EndTurn in a couple of scripts, esp. to fix timeout taunts in Racer
Wuzzy <almikes@aol.com>
parents: 12079
diff changeset
   563
                currCount = 0
faf1b93422ba Use new EndTurn in a couple of scripts, esp. to fix timeout taunts in Racer
Wuzzy <almikes@aol.com>
parents: 12079
diff changeset
   564
                fastIndex = 0
faf1b93422ba Use new EndTurn in a couple of scripts, esp. to fix timeout taunts in Racer
Wuzzy <almikes@aol.com>
parents: 12079
diff changeset
   565
                if endTurn then
faf1b93422ba Use new EndTurn in a couple of scripts, esp. to fix timeout taunts in Racer
Wuzzy <almikes@aol.com>
parents: 12079
diff changeset
   566
                        EndTurn(true)
faf1b93422ba Use new EndTurn in a couple of scripts, esp. to fix timeout taunts in Racer
Wuzzy <almikes@aol.com>
parents: 12079
diff changeset
   567
                end
faf1b93422ba Use new EndTurn in a couple of scripts, esp. to fix timeout taunts in Racer
Wuzzy <almikes@aol.com>
parents: 12079
diff changeset
   568
                racerActive = false -- newadd
12963
544c4302efe4 Racer, TechRacer: Change waypoint opacity on victory or failure
Wuzzy <Wuzzy2@mail.ru>
parents: 12962
diff changeset
   569
12964
a5c5fe878a4e Racer, TechRacer: Fade out waypoints at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 12963
diff changeset
   570
		if trackFinished and not gameOver then
12963
544c4302efe4 Racer, TechRacer: Change waypoint opacity on victory or failure
Wuzzy <Wuzzy2@mail.ru>
parents: 12962
diff changeset
   571
                         for i=0, wpCount-1 do
544c4302efe4 Racer, TechRacer: Change waypoint opacity on victory or failure
Wuzzy <Wuzzy2@mail.ru>
parents: 12962
diff changeset
   572
                       	         SetVisualGearValues(wpCirc[i], nil, nil, 255, 255, nil, 2)
544c4302efe4 Racer, TechRacer: Change waypoint opacity on victory or failure
Wuzzy <Wuzzy2@mail.ru>
parents: 12962
diff changeset
   573
                         end
12964
a5c5fe878a4e Racer, TechRacer: Fade out waypoints at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 12963
diff changeset
   574
                elseif not gameOver then
12963
544c4302efe4 Racer, TechRacer: Change waypoint opacity on victory or failure
Wuzzy <Wuzzy2@mail.ru>
parents: 12962
diff changeset
   575
                         for i=0, wpCount-1 do
544c4302efe4 Racer, TechRacer: Change waypoint opacity on victory or failure
Wuzzy <Wuzzy2@mail.ru>
parents: 12962
diff changeset
   576
                       	         SetVisualGearValues(wpCirc[i], nil, nil, 32, 32, nil, 1)
544c4302efe4 Racer, TechRacer: Change waypoint opacity on victory or failure
Wuzzy <Wuzzy2@mail.ru>
parents: 12962
diff changeset
   577
                         end
544c4302efe4 Racer, TechRacer: Change waypoint opacity on victory or failure
Wuzzy <Wuzzy2@mail.ru>
parents: 12962
diff changeset
   578
                end
12287
faf1b93422ba Use new EndTurn in a couple of scripts, esp. to fix timeout taunts in Racer
Wuzzy <almikes@aol.com>
parents: 12079
diff changeset
   579
        end
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   580
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   581
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   582
function HandleGhost()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   583
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   584
        -- get the current xy of the racer at this point
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   585
        currX[currCount] = GetX(CurrentHedgehog)
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   586
        currY[currCount] = GetY(CurrentHedgehog)
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   587
        currCount = currCount + 1
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   588
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   589
        -- draw a ping of smoke where the fastest player was at this point
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   590
        if (fastCount ~= 0) and (fastIndex < fastCount) then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   591
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   592
                fastIndex = fastIndex + 1
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   593
13685
09ea1faf97ca Remove calls to GetVisualGearValues where it's not needed
Wuzzy <Wuzzy2@mail.ru>
parents: 13630
diff changeset
   594
                local tempE = AddVisualGear(fastX[fastIndex], fastY[fastIndex], vgtSmoke, 0, false)
09ea1faf97ca Remove calls to GetVisualGearValues where it's not needed
Wuzzy <Wuzzy2@mail.ru>
parents: 13630
diff changeset
   595
                SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, fastColour )
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   596
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   597
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   598
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   599
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   600
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   601
function TryRepositionHogs()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   602
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   603
	if MapHasBorder() == true then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   604
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   605
		for i = 0, (numhhs-1) do
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   606
			if hhs[i] ~= nil then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   607
				SetGearPosition(hhs[i],GetX(hhs[i]), TopY-10)
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   608
			end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   609
		end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   610
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   611
	end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   612
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   613
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   614
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   615
----------------------------------
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   616
-- GAME METHODS / EVENT HANDLERS
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   617
----------------------------------
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   618
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   619
function onGameInit()
15489
3c0a3c824c49 Racer: Force-enable solid land
Wuzzy <Wuzzy2@mail.ru>
parents: 15488
diff changeset
   620
        EnableGameFlags(gfInfAttack, gfSolidLand)
15402
1028f5606b5f Racer, TechRacer: Force-disable several bad game flags
Wuzzy <Wuzzy2@mail.ru>
parents: 15400
diff changeset
   621
        -- Force-disable various game flags that would break the script
1028f5606b5f Racer, TechRacer: Force-disable several bad game flags
Wuzzy <Wuzzy2@mail.ru>
parents: 15400
diff changeset
   622
        DisableGameFlags(gfKing, gfSwitchHog, gfAISurvival, gfPlaceHog, gfTagTeam)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   623
        CaseFreq = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   624
        WaterRise = 0
12079
8f222872d432 Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents: 11986
diff changeset
   625
        HealthDecrease = 0
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   626
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   627
12406
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   628
function InstructionsBuild()
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   629
        ShowMission(
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   630
                loc("Racer"),
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   631
                loc("A Hedgewars mini-game"),
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   632
                loc("Build a track and race.") .. "|" ..
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   633
                string.format(loc("Round limit: %d"), roundLimit),
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   634
                4, 4000)
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   635
end
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   636
12407
8cc070640fd1 Fix skipping in Racer causing the next team to be skipped, too
Wuzzy <almikes@aol.com>
parents: 12406
diff changeset
   637
function InstructionsRace()
12406
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   638
        ShowMission(loc("Racer"),
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   639
        	loc("A Hedgewars mini-game"),
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   640
        	loc("Touch all waypoints as fast as you can!"),
15068
6f51c75994a4 Semi-standardize usage of icons in many mission panels
Wuzzy <Wuzzy2@mail.ru>
parents: 14578
diff changeset
   641
		1, 4000)
12406
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   642
end
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   643
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   644
function onGameStart()
15483
70aba717485a Racer: Reposition and resize predefined waypoints in scaled drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents: 15413
diff changeset
   645
70aba717485a Racer: Reposition and resize predefined waypoints in scaled drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents: 15413
diff changeset
   646
	-- Adjust pre-defined waypoints in scaled drawn maps
70aba717485a Racer: Reposition and resize predefined waypoints in scaled drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents: 15413
diff changeset
   647
	if MapGen == mgDrawn and MapFeatureSize ~= 12 and specialPointsCount > 0 then
70aba717485a Racer: Reposition and resize predefined waypoints in scaled drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents: 15413
diff changeset
   648
		local landW = RightX - LeftX + 1
70aba717485a Racer: Reposition and resize predefined waypoints in scaled drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents: 15413
diff changeset
   649
		local landH = LAND_HEIGHT - TopY
70aba717485a Racer: Reposition and resize predefined waypoints in scaled drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents: 15413
diff changeset
   650
		-- Reposition pre-defined waypoints
70aba717485a Racer: Reposition and resize predefined waypoints in scaled drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents: 15413
diff changeset
   651
        	for i = 0, (specialPointsCount-1) do
70aba717485a Racer: Reposition and resize predefined waypoints in scaled drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents: 15413
diff changeset
   652
        		specialPointsX[i] = LeftX + div(specialPointsX[i] * landW, 4096)
70aba717485a Racer: Reposition and resize predefined waypoints in scaled drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents: 15413
diff changeset
   653
        		specialPointsY[i] = TopY + div(specialPointsY[i] * landH, 2048)
70aba717485a Racer: Reposition and resize predefined waypoints in scaled drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents: 15413
diff changeset
   654
		end
70aba717485a Racer: Reposition and resize predefined waypoints in scaled drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents: 15413
diff changeset
   655
		-- Scale waypoint size
70aba717485a Racer: Reposition and resize predefined waypoints in scaled drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents: 15413
diff changeset
   656
		wpRad = math.max(WAYPOINT_RADIUS_MIN, div(wpRad * landW, 4096))
70aba717485a Racer: Reposition and resize predefined waypoints in scaled drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents: 15413
diff changeset
   657
	end
70aba717485a Racer: Reposition and resize predefined waypoints in scaled drawn maps
Wuzzy <Wuzzy2@mail.ru>
parents: 15413
diff changeset
   658
13769
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   659
	if ClansCount >= 2 then
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   660
		SendGameResultOff()
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   661
		SendRankingStatsOff()
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   662
        	SendHealthStatsOff()
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   663
		SendAchievementsStatsOff()
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   664
	end
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   665
15488
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
   666
        -- Keep track of land objects that got placed by the scheme (mines, air mines, barrels)
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
   667
        for id, _ in pairs(landObjects) do
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
   668
                table.insert(landObjectPoints, { type = GetGearType(id), x = GetX(id), y = GetY(id) })
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
   669
        end
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
   670
13124
991db8fc45eb Racer: No longer play Incoming or Missed sound
Wuzzy <Wuzzy2@mail.ru>
parents: 13103
diff changeset
   671
        SetSoundMask(sndIncoming, true)
991db8fc45eb Racer: No longer play Incoming or Missed sound
Wuzzy <Wuzzy2@mail.ru>
parents: 13103
diff changeset
   672
        SetSoundMask(sndMissed, true)
991db8fc45eb Racer: No longer play Incoming or Missed sound
Wuzzy <Wuzzy2@mail.ru>
parents: 13103
diff changeset
   673
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   674
        roundN = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   675
        lastRound = TotalRounds
11928
42e90b244e11 Racer: Dump old commented-out code
Wuzzy <almikes@aol.com>
parents: 11927
diff changeset
   676
        RoundHasChanged = false
14070
a5be3ef4bbbe Update official challenge hashes, improve console logging (warning: racer #17 is missing!)
Wuzzy <Wuzzy2@mail.ru>
parents: 13841
diff changeset
   677
        officialChallenge = detectMapWithDigest()
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   678
12967
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   679
	if GetBackgroundBrightness() == 1 then
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   680
		-- Dark waypoint colour theme
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   681
		waypointColour = waypointColourDark
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   682
		waypointColourAtPlacement = waypointColourDarkAtPlacement
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   683
	elseif GetBackgroundBrightness() == 2 then
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   684
		-- Medium waypoint colour theme
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   685
		waypointColour = waypointColourMedium
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   686
		waypointColourAtPlacement = waypointColourMediumAtPlacement
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   687
	end
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   688
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   689
        for i = 0, (specialPointsCount-1) do
12406
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   690
                PlaceWayPoint(specialPointsX[i], specialPointsY[i], false)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   691
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   692
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   693
        RebuildTeamInfo()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   694
12406
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   695
        if specialPointsCount > 0 then
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   696
                InstructionsRace()
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   697
        else
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   698
                InstructionsBuild()
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   699
        end
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   700
11946
65e61f495129 Overwrite special ammo descriptions in Racer script
Wuzzy <almikes@aol.com>
parents: 11931
diff changeset
   701
        SetAmmoTexts(amAirAttack, loc("Place waypoint"), loc("Racer tool"),
65e61f495129 Overwrite special ammo descriptions in Racer script
Wuzzy <almikes@aol.com>
parents: 11931
diff changeset
   702
                loc("Build an awesome race track by placing|waypoints which the hedgehogs have to|touch in any order to finish a round.") .. "|" ..
65e61f495129 Overwrite special ammo descriptions in Racer script
Wuzzy <almikes@aol.com>
parents: 11931
diff changeset
   703
		loc("Hedgehogs will start in the first waypoint.") .. "|" ..
11983
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   704
 		loc("Cursor: Place waypoint") .. "|" ..
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   705
 		loc("Precise: Remove previous waypoint"))
11946
65e61f495129 Overwrite special ammo descriptions in Racer script
Wuzzy <almikes@aol.com>
parents: 11931
diff changeset
   706
65e61f495129 Overwrite special ammo descriptions in Racer script
Wuzzy <almikes@aol.com>
parents: 11931
diff changeset
   707
        SetAmmoTexts(amSkip, loc("Finish waypoint placement"), loc("Racer tool"),
65e61f495129 Overwrite special ammo descriptions in Racer script
Wuzzy <almikes@aol.com>
parents: 11931
diff changeset
   708
                loc("Happy with your race track?|Then stop building and start racing!") .. "|" ..
65e61f495129 Overwrite special ammo descriptions in Racer script
Wuzzy <almikes@aol.com>
parents: 11931
diff changeset
   709
                loc("Or let the next player place waypoints|if less than 2 waypoints have been placed.") .. "|" ..
65e61f495129 Overwrite special ammo descriptions in Racer script
Wuzzy <almikes@aol.com>
parents: 11931
diff changeset
   710
                loc("Attack: Activate"))
65e61f495129 Overwrite special ammo descriptions in Racer script
Wuzzy <almikes@aol.com>
parents: 11931
diff changeset
   711
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   712
        TryRepositionHogs()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   713
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   714
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   715
12406
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   716
function PlaceWayPoint(x,y,placedByUser)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   717
    if not racerActive then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   718
        if wpCount == 0 or wpX[wpCount - 1] ~= x or wpY[wpCount - 1] ~= y then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   719
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   720
            wpX[wpCount] = x
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   721
            wpY[wpCount] = y
12967
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   722
            wpCol[wpCount] = waypointColour
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   723
            wpCirc[wpCount] = AddVisualGear(wpX[wpCount],wpY[wpCount],vgtCircle,0,true)
11563
7e5d6ce6fe14 Treat #99 point type as a ghost trace
unc0rr
parents: 11545
diff changeset
   724
12965
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   725
            local flashing, minO, maxO
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   726
            if wpCount == 0 then
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   727
                -- First waypoint flashes. Useful to know since this is the spawn position.
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   728
                minO, maxO = 164, 255
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   729
                flashing = 5
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   730
            else
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   731
                -- Other waypoints are not animated (before the race starts)
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   732
                minO, maxO = 255, 255
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   733
                flashing = 0
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   734
            end
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   735
            SetVisualGearValues(wpCirc[wpCount], wpX[wpCount], wpY[wpCount], minO, maxO, 1, flashing, 0, wpRad, 5, wpCol[wpCount])
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   736
12967
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   737
            -- Use alternate waypoint color for all waypoints but the last one. This gives a subtle “highlighting” effect.
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   738
            SetVisualGearValues(wpCirc[wpCount-1], nil, nil, nil, nil, nil, nil, nil, nil, nil, waypointColourAtPlacement)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   739
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   740
            wpCount = wpCount + 1
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   741
12406
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   742
            if placedByUser then
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   743
                AddCaption(string.format(loc("Waypoint placed. Available points remaining: %d"), wpLimit-wpCount))
13124
991db8fc45eb Racer: No longer play Incoming or Missed sound
Wuzzy <Wuzzy2@mail.ru>
parents: 13103
diff changeset
   744
                PlaySound(sndPlaced)
12406
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   745
            end
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   746
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   747
    end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   748
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   749
11983
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   750
function onPrecise()
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   751
    if not racerActive and CurrentHedgehog ~= nil and GetCurAmmoType() == amAirAttack then
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   752
        DeletePreviousWayPoint()
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   753
    end
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   754
end
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   755
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   756
function DeletePreviousWayPoint()
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   757
    if wpCount > 0 then
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   758
        wpCount = wpCount - 1
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   759
        wpX[wpCount] = nil
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   760
        wpY[wpCount] = nil
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   761
        wpCol[wpCount] = nil
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   762
        DeleteVisualGear(wpCirc[wpCount])
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   763
        wpCirc[wpCount] = nil
12967
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   764
        SetVisualGearValues(wpCirc[wpCount-1], nil, nil, nil, nil, nil, nil, nil, nil, nil, waypointColour)
11983
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   765
        AddCaption(string.format(loc("Waypoint removed. Available points: %d"), wpLimit-wpCount))
13129
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
   766
        PlaySound(sndBump)
11983
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   767
    else
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   768
        PlaySound(sndDenied)
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   769
        AddCaption(loc("No waypoint to be removed!"))
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   770
    end
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   771
end
9e57915f5365 Allow to remove waypoints in Racer with precise key
Wuzzy <almikes@aol.com>
parents: 11946
diff changeset
   772
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   773
function onSpecialPoint(x,y,flag)
11563
7e5d6ce6fe14 Treat #99 point type as a ghost trace
unc0rr
parents: 11545
diff changeset
   774
    if flag == 99 then
7e5d6ce6fe14 Treat #99 point type as a ghost trace
unc0rr
parents: 11545
diff changeset
   775
        fastX[fastCount] = x
7e5d6ce6fe14 Treat #99 point type as a ghost trace
unc0rr
parents: 11545
diff changeset
   776
        fastY[fastCount] = y
7e5d6ce6fe14 Treat #99 point type as a ghost trace
unc0rr
parents: 11545
diff changeset
   777
        fastCount = fastCount + 1
7e5d6ce6fe14 Treat #99 point type as a ghost trace
unc0rr
parents: 11545
diff changeset
   778
    else
7e5d6ce6fe14 Treat #99 point type as a ghost trace
unc0rr
parents: 11545
diff changeset
   779
        addHashData(x)
7e5d6ce6fe14 Treat #99 point type as a ghost trace
unc0rr
parents: 11545
diff changeset
   780
        addHashData(y)
7e5d6ce6fe14 Treat #99 point type as a ghost trace
unc0rr
parents: 11545
diff changeset
   781
        addHashData(flag)
7e5d6ce6fe14 Treat #99 point type as a ghost trace
unc0rr
parents: 11545
diff changeset
   782
        specialPointsX[specialPointsCount] = x
7e5d6ce6fe14 Treat #99 point type as a ghost trace
unc0rr
parents: 11545
diff changeset
   783
        specialPointsY[specialPointsCount] = y
7e5d6ce6fe14 Treat #99 point type as a ghost trace
unc0rr
parents: 11545
diff changeset
   784
        specialPointsCount = specialPointsCount + 1
7e5d6ce6fe14 Treat #99 point type as a ghost trace
unc0rr
parents: 11545
diff changeset
   785
    end
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   786
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   787
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   788
function onNewTurn()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   789
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   790
        CheckForNewRound()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   791
        TryRepositionHogs()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   792
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   793
        racerActive = false
12407
8cc070640fd1 Fix skipping in Racer causing the next team to be skipped, too
Wuzzy <almikes@aol.com>
parents: 12406
diff changeset
   794
        turnSkipped = false
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   795
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   796
        trackTime = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   797
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   798
        currCount = 0 -- hopefully this solves problem
14548
c572eb57dd2d Fix Racer ghost not resetting properly after a skip (bug 565)
Wuzzy <Wuzzy2@mail.ru>
parents: 14252
diff changeset
   799
        fastIndex = 0
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   800
        AddAmmo(CurrentHedgehog, amAirAttack, 0)
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   801
        gTimer = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   802
15404
0e3bf53dfe47 Racer, TechRacer: Mask taunts like Stupid when track was completed successfully
Wuzzy <Wuzzy2@mail.ru>
parents: 15403
diff changeset
   803
        SetSoundMask(sndStupid, false)
0e3bf53dfe47 Racer, TechRacer: Mask taunts like Stupid when track was completed successfully
Wuzzy <Wuzzy2@mail.ru>
parents: 15403
diff changeset
   804
        SetSoundMask(sndBugger, false)
0e3bf53dfe47 Racer, TechRacer: Mask taunts like Stupid when track was completed successfully
Wuzzy <Wuzzy2@mail.ru>
parents: 15403
diff changeset
   805
        SetSoundMask(sndDrat, false)
0e3bf53dfe47 Racer, TechRacer: Mask taunts like Stupid when track was completed successfully
Wuzzy <Wuzzy2@mail.ru>
parents: 15403
diff changeset
   806
15403
e347c3508f95 Racer: Fix ammo delay confusion if gfKing or gfPlaceHog were set
Wuzzy <Wuzzy2@mail.ru>
parents: 15402
diff changeset
   807
        -- Remember ammo delays for later
e347c3508f95 Racer: Fix ammo delay confusion if gfKing or gfPlaceHog were set
Wuzzy <Wuzzy2@mail.ru>
parents: 15402
diff changeset
   808
        if ammoDelays == nil then
e347c3508f95 Racer: Fix ammo delay confusion if gfKing or gfPlaceHog were set
Wuzzy <Wuzzy2@mail.ru>
parents: 15402
diff changeset
   809
                ammoDelays = {}
e347c3508f95 Racer: Fix ammo delay confusion if gfKing or gfPlaceHog were set
Wuzzy <Wuzzy2@mail.ru>
parents: 15402
diff changeset
   810
                for a=0, AmmoTypeMax do
15411
2cde69c1c680 Racer: Really fix delay confusion when attempting to force-disable gfKing/gfPlaceHog
Wuzzy <Wuzzy2@mail.ru>
parents: 15410
diff changeset
   811
                        local _, _, delay = GetAmmo(a)
2cde69c1c680 Racer: Really fix delay confusion when attempting to force-disable gfKing/gfPlaceHog
Wuzzy <Wuzzy2@mail.ru>
parents: 15410
diff changeset
   812
                        -- delay >= 10000 is special value used in hog placement phase.
2cde69c1c680 Racer: Really fix delay confusion when attempting to force-disable gfKing/gfPlaceHog
Wuzzy <Wuzzy2@mail.ru>
parents: 15410
diff changeset
   813
                        -- This extracts the "true" delay
2cde69c1c680 Racer: Really fix delay confusion when attempting to force-disable gfKing/gfPlaceHog
Wuzzy <Wuzzy2@mail.ru>
parents: 15410
diff changeset
   814
                        if delay >= 10000 then
2cde69c1c680 Racer: Really fix delay confusion when attempting to force-disable gfKing/gfPlaceHog
Wuzzy <Wuzzy2@mail.ru>
parents: 15410
diff changeset
   815
                                delay = delay - 10000
2cde69c1c680 Racer: Really fix delay confusion when attempting to force-disable gfKing/gfPlaceHog
Wuzzy <Wuzzy2@mail.ru>
parents: 15410
diff changeset
   816
                        end
15403
e347c3508f95 Racer: Fix ammo delay confusion if gfKing or gfPlaceHog were set
Wuzzy <Wuzzy2@mail.ru>
parents: 15402
diff changeset
   817
                        ammoDelays[a] = delay
e347c3508f95 Racer: Fix ammo delay confusion if gfKing or gfPlaceHog were set
Wuzzy <Wuzzy2@mail.ru>
parents: 15402
diff changeset
   818
                end
e347c3508f95 Racer: Fix ammo delay confusion if gfKing or gfPlaceHog were set
Wuzzy <Wuzzy2@mail.ru>
parents: 15402
diff changeset
   819
        end
e347c3508f95 Racer: Fix ammo delay confusion if gfKing or gfPlaceHog were set
Wuzzy <Wuzzy2@mail.ru>
parents: 15402
diff changeset
   820
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   821
        -- Handle Starting Stage of Game
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   822
        if (gameOver == false) and (gameBegun == false) then
11931
a01a890093f3 Racer: Reduce minimum number of waypoints to 2, tweak descriptions
Wuzzy <almikes@aol.com>
parents: 11930
diff changeset
   823
                if wpCount >= 2 then
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   824
                        gameBegun = true
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   825
                        roundNumber = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   826
                        firstClan = GetHogClan(CurrentHedgehog)
12406
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   827
                        if specialPointsCount == 0 then
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   828
                                InstructionsRace()
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   829
                        end
11946
65e61f495129 Overwrite special ammo descriptions in Racer script
Wuzzy <almikes@aol.com>
parents: 11931
diff changeset
   830
15398
09b63f9032f4 Racer: Disable other ammos in waypoint placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 15397
diff changeset
   831
                        -- Restore old ammo delays
09b63f9032f4 Racer: Disable other ammos in waypoint placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 15397
diff changeset
   832
                        for a=0, AmmoTypeMax do
09b63f9032f4 Racer: Disable other ammos in waypoint placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 15397
diff changeset
   833
                                if a ~= amAirAttack and a ~= amSkip then
09b63f9032f4 Racer: Disable other ammos in waypoint placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 15397
diff changeset
   834
                                        SetAmmoDelay(a, ammoDelays[a])
09b63f9032f4 Racer: Disable other ammos in waypoint placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 15397
diff changeset
   835
                                end
09b63f9032f4 Racer: Disable other ammos in waypoint placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 15397
diff changeset
   836
                        end
09b63f9032f4 Racer: Disable other ammos in waypoint placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 15397
diff changeset
   837
11946
65e61f495129 Overwrite special ammo descriptions in Racer script
Wuzzy <almikes@aol.com>
parents: 11931
diff changeset
   838
                        SetAmmoTexts(amSkip, nil, nil, nil)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   839
                else
11986
f97b1c7fa053 Allow to set Racer waypoint limit with script parameter “maxwaypoints”
Wuzzy <almikes@aol.com>
parents: 11985
diff changeset
   840
                        local infoString
f97b1c7fa053 Allow to set Racer waypoint limit with script parameter “maxwaypoints”
Wuzzy <almikes@aol.com>
parents: 11985
diff changeset
   841
                        if wpLimit > 2 then
f97b1c7fa053 Allow to set Racer waypoint limit with script parameter “maxwaypoints”
Wuzzy <almikes@aol.com>
parents: 11985
diff changeset
   842
                                infoString = string.format(loc("Place 2-%d waypoints using the waypoint placement tool."), wpLimit)
f97b1c7fa053 Allow to set Racer waypoint limit with script parameter “maxwaypoints”
Wuzzy <almikes@aol.com>
parents: 11985
diff changeset
   843
                        else
f97b1c7fa053 Allow to set Racer waypoint limit with script parameter “maxwaypoints”
Wuzzy <almikes@aol.com>
parents: 11985
diff changeset
   844
                                infoString = loc("Place 2 waypoints using the waypoint placement tool.")
f97b1c7fa053 Allow to set Racer waypoint limit with script parameter “maxwaypoints”
Wuzzy <almikes@aol.com>
parents: 11985
diff changeset
   845
                        end
11924
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   846
                        ShowMission(loc("Racer"),
15069
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 15068
diff changeset
   847
                        loc("Waypoint placement phase"), infoString, -amAirAttack, 4000)
15397
b186e1f4c5ed Racer: Make sure the waypoint placer always has 0 delay
Wuzzy <Wuzzy2@mail.ru>
parents: 15396
diff changeset
   848
                        AddAmmo(CurrentHedgehog, amAirAttack, AMMO_INFINITE)
15398
09b63f9032f4 Racer: Disable other ammos in waypoint placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 15397
diff changeset
   849
                        for a=0, AmmoTypeMax do
09b63f9032f4 Racer: Disable other ammos in waypoint placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 15397
diff changeset
   850
                                if a ~= amAirAttack and a ~= amSkip then
09b63f9032f4 Racer: Disable other ammos in waypoint placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 15397
diff changeset
   851
                                        SetAmmoDelay(a, 9999)
09b63f9032f4 Racer: Disable other ammos in waypoint placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 15397
diff changeset
   852
                                end
09b63f9032f4 Racer: Disable other ammos in waypoint placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 15397
diff changeset
   853
                        end
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   854
                        SetWeapon(amAirAttack)
15137
651c1737be2a WxW, Racer: Make bots skip/auto-confirm setup phase
Wuzzy <Wuzzy2@mail.ru>
parents: 15069
diff changeset
   855
                        -- Bots skip waypoint placement
651c1737be2a WxW, Racer: Make bots skip/auto-confirm setup phase
Wuzzy <Wuzzy2@mail.ru>
parents: 15069
diff changeset
   856
                        if GetHogLevel(CurrentHedgehog) ~= 0 then
651c1737be2a WxW, Racer: Make bots skip/auto-confirm setup phase
Wuzzy <Wuzzy2@mail.ru>
parents: 15069
diff changeset
   857
                                SkipTurn()
651c1737be2a WxW, Racer: Make bots skip/auto-confirm setup phase
Wuzzy <Wuzzy2@mail.ru>
parents: 15069
diff changeset
   858
                        end
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   859
                end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   860
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   861
12965
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   862
        if gameBegun and not gameOver then
15488
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
   863
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
   864
                -- Reset land objects so each player starts with same racing conditions
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
   865
                for id,_ in pairs(landObjects) do
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
   866
                        DeleteGear(id)
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
   867
                end
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
   868
                for i=1, #landObjectPoints do
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
   869
                        AddGear(landObjectPoints[i].x, landObjectPoints[i].y, landObjectPoints[i].type, 0, 0, 0, 0)
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
   870
                end
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
   871
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
   872
                -- Set the waypoints to unactive
12965
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   873
                for i = 0,(wpCount-1) do
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   874
                        wpActive[i] = false
12967
e32fff07b8d7 Racer: Make waypoints dark in bright themes like Bath
Wuzzy <Wuzzy2@mail.ru>
parents: 12965
diff changeset
   875
                        wpCol[i] = waypointColour
12965
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   876
                        local flashing, minO, maxO
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   877
                        if i == 0 then
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   878
                            -- Make first waypoint flash very noticably
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   879
                            minO, maxO = 92, 255
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   880
                            flashing = 2
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   881
                        else
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   882
                            minO, maxO = 164, 224
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   883
                            flashing = 10
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   884
                        end
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   885
                        SetVisualGearValues(wpCirc[i], nil, nil, minO, maxO, nil, flashing, nil, nil, nil, wpCol[i])
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   886
                end
13024
a568bc16a99a Racer and TechRacer: Move cameera to first waypoint in Ready phase
Wuzzy <Wuzzy2@mail.ru>
parents: 12967
diff changeset
   887
a568bc16a99a Racer and TechRacer: Move cameera to first waypoint in Ready phase
Wuzzy <Wuzzy2@mail.ru>
parents: 12967
diff changeset
   888
                if cameraGear then
a568bc16a99a Racer and TechRacer: Move cameera to first waypoint in Ready phase
Wuzzy <Wuzzy2@mail.ru>
parents: 12967
diff changeset
   889
                        DeleteGear(cameraGear)
a568bc16a99a Racer and TechRacer: Move cameera to first waypoint in Ready phase
Wuzzy <Wuzzy2@mail.ru>
parents: 12967
diff changeset
   890
                end
a568bc16a99a Racer and TechRacer: Move cameera to first waypoint in Ready phase
Wuzzy <Wuzzy2@mail.ru>
parents: 12967
diff changeset
   891
                -- Move camera to first waypoint
a568bc16a99a Racer and TechRacer: Move cameera to first waypoint in Ready phase
Wuzzy <Wuzzy2@mail.ru>
parents: 12967
diff changeset
   892
		-- We use a dummy gear to feed FollowGear. It does not affect the race.
a568bc16a99a Racer and TechRacer: Move cameera to first waypoint in Ready phase
Wuzzy <Wuzzy2@mail.ru>
parents: 12967
diff changeset
   893
                cameraGear = AddGear(wpX[0], wpY[0], gtGenericFaller, 0, 0, 0, 5000)
a568bc16a99a Racer and TechRacer: Move cameera to first waypoint in Ready phase
Wuzzy <Wuzzy2@mail.ru>
parents: 12967
diff changeset
   894
                SetState(cameraGear, bor(GetState(cameraGear), gstNoGravity+gstInvisible))
a568bc16a99a Racer and TechRacer: Move cameera to first waypoint in Ready phase
Wuzzy <Wuzzy2@mail.ru>
parents: 12967
diff changeset
   895
                FollowGear(cameraGear)
12965
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   896
        end
21eda4fe383c Racer: Make first waypoint flash and highlight last waypoint while placing
Wuzzy <Wuzzy2@mail.ru>
parents: 12964
diff changeset
   897
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   898
        if gameOver == true then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   899
                gameBegun = false
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   900
                racerActive = false -- newadd
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   901
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   902
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   903
        AddAmmo(CurrentHedgehog, amTardis, 0)
13103
cf2a58dccc4a CTF: Remove tardis and resurrector
Wuzzy <Wuzzy2@mail.ru>
parents: 13027
diff changeset
   904
        AddAmmo(CurrentHedgehog, amResurrector, 0)
cf2a58dccc4a CTF: Remove tardis and resurrector
Wuzzy <Wuzzy2@mail.ru>
parents: 13027
diff changeset
   905
        AddAmmo(CurrentHedgehog, amInvulnerable, 0)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   906
        AddAmmo(CurrentHedgehog, amDrillStrike, 0)
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   907
        AddAmmo(CurrentHedgehog, amMineStrike, 0)
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   908
        AddAmmo(CurrentHedgehog, amNapalm, 0)
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   909
        AddAmmo(CurrentHedgehog, amPiano, 0)
15413
ca8896b9c7c6 Racer: Remove a few ammo types that could break the gameplay
Wuzzy <Wuzzy2@mail.ru>
parents: 15411
diff changeset
   910
        AddAmmo(CurrentHedgehog, amSwitch, 0)
ca8896b9c7c6 Racer: Remove a few ammo types that could break the gameplay
Wuzzy <Wuzzy2@mail.ru>
parents: 15411
diff changeset
   911
        AddAmmo(CurrentHedgehog, amKamikaze, 0)
ca8896b9c7c6 Racer: Remove a few ammo types that could break the gameplay
Wuzzy <Wuzzy2@mail.ru>
parents: 15411
diff changeset
   912
        AddAmmo(CurrentHedgehog, amIceGun, 0)
15397
b186e1f4c5ed Racer: Make sure the waypoint placer always has 0 delay
Wuzzy <Wuzzy2@mail.ru>
parents: 15396
diff changeset
   913
        SetAmmoDelay(amAirAttack, 0)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   914
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   915
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   916
function onGameTick20()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   917
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   918
        -- airstrike detected, convert this into a potential waypoint spot
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   919
        if cGear ~= nil then
15410
8504fee3b601 Racer: Fix weird water splashes after waypoint placement
Wuzzy <Wuzzy2@mail.ru>
parents: 15404
diff changeset
   920
                local x,y = GetGearPosition(cGear)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   921
                if x > -9000 then
15410
8504fee3b601 Racer: Fix weird water splashes after waypoint placement
Wuzzy <Wuzzy2@mail.ru>
parents: 15404
diff changeset
   922
                        local x,y = GetGearTarget(cGear)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   923
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   924
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   925
                        if TestRectForObstacle(x-20, y-20, x+20, y+20, true) then
11924
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   926
                                AddCaption(loc("Please place the waypoint in the air, within the map boundaries"))
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   927
                                PlaySound(sndDenied)
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   928
                        elseif (y > WaterLine-50) then
11924
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   929
                                AddCaption(loc("Please place the waypoint further away from the waterline"))
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   930
                                PlaySound(sndDenied)
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   931
                        else
12406
cd53f1bf52ff Stop telling the player to build a track in Racer when it is already built
Wuzzy <almikes@aol.com>
parents: 12388
diff changeset
   932
                                PlaceWayPoint(x, y, true)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   933
                                if wpCount == wpLimit then
11924
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
   934
                                        AddCaption(loc("Race complexity limit reached"))
12287
faf1b93422ba Use new EndTurn in a couple of scripts, esp. to fix timeout taunts in Racer
Wuzzy <almikes@aol.com>
parents: 12079
diff changeset
   935
                                        EndTurn(true)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   936
                                end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   937
                        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   938
                else
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   939
                        DeleteGear(cGear)
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   940
                end
15410
8504fee3b601 Racer: Fix weird water splashes after waypoint placement
Wuzzy <Wuzzy2@mail.ru>
parents: 15404
diff changeset
   941
        	SetGearPosition(cGear, -10000, y)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   942
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   943
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   944
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   945
        -- start the player tumbling with a boom once their turn has actually begun
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   946
        if racerActive == false then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   947
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   948
                if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   949
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   950
                        -- if the gamehas started put the player in the middle of the first
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   951
                        --waypoint that was placed
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   952
                        if gameBegun == true then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   953
                                AddCaption(loc("Good to go!"))
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   954
                                racerActive = true
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   955
                                trackTime = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   956
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   957
                                SetGearPosition(CurrentHedgehog, wpX[0], wpY[0])
15385
c35c5a9b878c Allow playing Racer without invulnerability
S-D-
parents: 15245
diff changeset
   958
                                Explode(GetX(CurrentHedgehog)+boostX,
c35c5a9b878c Allow playing Racer without invulnerability
S-D-
parents: 15245
diff changeset
   959
                                        GetY(CurrentHedgehog)+boostY,
c35c5a9b878c Allow playing Racer without invulnerability
S-D-
parents: 15245
diff changeset
   960
                                        50,
c35c5a9b878c Allow playing Racer without invulnerability
S-D-
parents: 15245
diff changeset
   961
                                        EXPLNoDamage + EXPLAutoSound)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   962
                                FollowGear(CurrentHedgehog)
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   963
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   964
                                HideMission()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   965
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   966
                                -- don't start empty-handed
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   967
                                if (GetCurAmmoType() == amNothing) then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   968
                                        SetNextWeapon()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   969
                                end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   970
                        else
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   971
                                -- still in placement mode
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   972
                        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   973
13129
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
   974
        	end
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
   975
		if not racerActive and not gameBegun and GetCurAmmoType() == amAirAttack then
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
   976
			waypointCursor = true
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
   977
		else
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
   978
			waypointCursor = false
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
   979
		end
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
   980
	else
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
   981
		waypointCursor = false
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
   982
	end
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   983
15788
acf70c44065b Use the singular 'they' in code comments, where it makes sense
Wuzzy <Wuzzy2@mail.ru>
parents: 15489
diff changeset
   984
        -- has the player started?
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   985
        if (CurrentHedgehog ~= nil) then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   986
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   987
                --airstrike conversion used to be here
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   988
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   989
                -- if the RACE has started, show tracktimes and keep tabs on waypoints
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   990
                if (racerActive == true) and (gameBegun == true) then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   991
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   992
                        --ghost
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   993
                        if GameTime%40 == 0 then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   994
                                HandleGhost()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   995
                        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   996
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   997
                        trackTime = trackTime + 20
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   998
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
   999
                        if GameTime%100 == 0 then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1000
11924
ce277e51b603 Racer: Clean up strings
Wuzzy <almikes@aol.com>
parents: 11923
diff changeset
  1001
                                AddCaption(string.format(loc("Time: %.1fs"), (trackTime/1000)),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpMessage2)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1002
15404
0e3bf53dfe47 Racer, TechRacer: Mask taunts like Stupid when track was completed successfully
Wuzzy <Wuzzy2@mail.ru>
parents: 15403
diff changeset
  1003
				-- Track completed, all waypoints touched
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1004
                                if (CheckWaypoints() == true) then
15404
0e3bf53dfe47 Racer, TechRacer: Mask taunts like Stupid when track was completed successfully
Wuzzy <Wuzzy2@mail.ru>
parents: 15403
diff changeset
  1005
                                        SetSoundMask(sndStupid, true)
0e3bf53dfe47 Racer, TechRacer: Mask taunts like Stupid when track was completed successfully
Wuzzy <Wuzzy2@mail.ru>
parents: 15403
diff changeset
  1006
                                        SetSoundMask(sndBugger, true)
0e3bf53dfe47 Racer, TechRacer: Mask taunts like Stupid when track was completed successfully
Wuzzy <Wuzzy2@mail.ru>
parents: 15403
diff changeset
  1007
                                        SetSoundMask(sndDrat, true)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1008
                                        AdjustScores()
15400
06524f2e9a74 Racer: Make winners invulnerable
Wuzzy <Wuzzy2@mail.ru>
parents: 15399
diff changeset
  1009
                                        SetEffect(CurrentHedgehog, heInvulnerable, 1)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1010
                                        DisableTumbler()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1011
                                end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1012
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1013
                        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1014
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1015
                end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1016
15788
acf70c44065b Use the singular 'they' in code comments, where it makes sense
Wuzzy <Wuzzy2@mail.ru>
parents: 15489
diff changeset
  1017
                -- if the player has expended their time, stop
12407
8cc070640fd1 Fix skipping in Racer causing the next team to be skipped, too
Wuzzy <almikes@aol.com>
parents: 12406
diff changeset
  1018
                if TurnTimeLeft <= 20 and not turnSkipped then
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1019
                        DisableTumbler()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1020
                end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1021
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1022
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1023
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1024
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1025
13129
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
  1026
function onGameTick()
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
  1027
	if waypointCursor then
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
  1028
		if not waypointPreview then
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
  1029
			waypointPreview = AddVisualGear(CursorX, CursorY, vgtCircle, 0, true)
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
  1030
		end
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
  1031
		SetVisualGearValues(waypointPreview, CursorX, CursorY, 200, 200, 0, 0, 0, div(wpRad, 5), 5, waypointColourAtPlacement)
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
  1032
	else
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
  1033
		if waypointPreview then
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
  1034
			DeleteVisualGear(waypointPreview)
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
  1035
			waypointPreview = nil
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
  1036
		end
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
  1037
	end
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
  1038
end
9a328734e469 Racer: Draw waypoint outline around cursor while in placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13124
diff changeset
  1039
15399
4b792051c159 Racer: Fix hog taking damage skipping turn of next team
Wuzzy <Wuzzy2@mail.ru>
parents: 15398
diff changeset
  1040
function onGearDamage(gear)
4b792051c159 Racer: Fix hog taking damage skipping turn of next team
Wuzzy <Wuzzy2@mail.ru>
parents: 15398
diff changeset
  1041
4b792051c159 Racer: Fix hog taking damage skipping turn of next team
Wuzzy <Wuzzy2@mail.ru>
parents: 15398
diff changeset
  1042
        if gear == CurrentHedgehog then
4b792051c159 Racer: Fix hog taking damage skipping turn of next team
Wuzzy <Wuzzy2@mail.ru>
parents: 15398
diff changeset
  1043
                DisableTumbler(false)
4b792051c159 Racer: Fix hog taking damage skipping turn of next team
Wuzzy <Wuzzy2@mail.ru>
parents: 15398
diff changeset
  1044
        end
4b792051c159 Racer: Fix hog taking damage skipping turn of next team
Wuzzy <Wuzzy2@mail.ru>
parents: 15398
diff changeset
  1045
4b792051c159 Racer: Fix hog taking damage skipping turn of next team
Wuzzy <Wuzzy2@mail.ru>
parents: 15398
diff changeset
  1046
end
4b792051c159 Racer: Fix hog taking damage skipping turn of next team
Wuzzy <Wuzzy2@mail.ru>
parents: 15398
diff changeset
  1047
13630
fe7d2bbf5f3f Fix resurrection animation appearing at wrong position for some missions and styles
Wuzzy <Wuzzy2@mail.ru>
parents: 13129
diff changeset
  1048
function onGearResurrect(gear, vGear)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1049
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1050
        if gear == CurrentHedgehog then
12287
faf1b93422ba Use new EndTurn in a couple of scripts, esp. to fix timeout taunts in Racer
Wuzzy <almikes@aol.com>
parents: 12079
diff changeset
  1051
                DisableTumbler(false)
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1052
        end
13630
fe7d2bbf5f3f Fix resurrection animation appearing at wrong position for some missions and styles
Wuzzy <Wuzzy2@mail.ru>
parents: 13129
diff changeset
  1053
        if vGear then
fe7d2bbf5f3f Fix resurrection animation appearing at wrong position for some missions and styles
Wuzzy <Wuzzy2@mail.ru>
parents: 13129
diff changeset
  1054
                DeleteVisualGear(vGear)
fe7d2bbf5f3f Fix resurrection animation appearing at wrong position for some missions and styles
Wuzzy <Wuzzy2@mail.ru>
parents: 13129
diff changeset
  1055
        end
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1056
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1057
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1058
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1059
function onGearAdd(gear)
15488
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
  1060
        local gt = GetGearType(gear)
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
  1061
        if gt == gtHedgehog then
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1062
                hhs[numhhs] = gear
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1063
                numhhs = numhhs + 1
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1064
                SetEffect(gear, heResurrectable, 1)
15488
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
  1065
        elseif gt == gtAirAttack then
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1066
                cGear = gear
15410
8504fee3b601 Racer: Fix weird water splashes after waypoint placement
Wuzzy <Wuzzy2@mail.ru>
parents: 15404
diff changeset
  1067
		local x,y = GetGearPosition(cGear)
8504fee3b601 Racer: Fix weird water splashes after waypoint placement
Wuzzy <Wuzzy2@mail.ru>
parents: 15404
diff changeset
  1068
        	SetGearPosition(cGear, 10000, y)
15488
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
  1069
        elseif (gt == gtMine or gt == gtAirMine or gt == gtExplosives) then
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
  1070
                landObjects[gear] = true
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
  1071
        elseif (not gameBegun) and gt == gtAirBomb then
15410
8504fee3b601 Racer: Fix weird water splashes after waypoint placement
Wuzzy <Wuzzy2@mail.ru>
parents: 15404
diff changeset
  1072
		DeleteGear(gear)
15488
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
  1073
        elseif gt == gtRope and TeamRope then
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1074
            SetTag(gear,1)
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1075
            SetGearValues(gear,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,GetClanColor(GetHogClan(CurrentHedgehog)))
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1076
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1077
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1078
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1079
function onGearDelete(gear)
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1080
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1081
        if GetGearType(gear) == gtAirAttack then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1082
                cGear = nil
15488
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
  1083
        elseif landObjects[gear] == true then
04b63bcdb2ab Racer: Reset mines, air mines, barrels after each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15485
diff changeset
  1084
                landObjects[gear] = nil
13024
a568bc16a99a Racer and TechRacer: Move cameera to first waypoint in Ready phase
Wuzzy <Wuzzy2@mail.ru>
parents: 12967
diff changeset
  1085
        elseif gear == cameraGear then
a568bc16a99a Racer and TechRacer: Move cameera to first waypoint in Ready phase
Wuzzy <Wuzzy2@mail.ru>
parents: 12967
diff changeset
  1086
                cameraGear = nil
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1087
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1088
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1089
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1090
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1091
function onAttack()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1092
    at = GetCurAmmoType()
11563
7e5d6ce6fe14 Treat #99 point type as a ghost trace
unc0rr
parents: 11545
diff changeset
  1093
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1094
    usedWeapons[at] = 0
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1095
end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1096
12407
8cc070640fd1 Fix skipping in Racer causing the next team to be skipped, too
Wuzzy <almikes@aol.com>
parents: 12406
diff changeset
  1097
function onHogAttack(ammoType)
8cc070640fd1 Fix skipping in Racer causing the next team to be skipped, too
Wuzzy <almikes@aol.com>
parents: 12406
diff changeset
  1098
    if ammoType == amSkip then
8cc070640fd1 Fix skipping in Racer causing the next team to be skipped, too
Wuzzy <almikes@aol.com>
parents: 12406
diff changeset
  1099
        turnSkipped = true
8cc070640fd1 Fix skipping in Racer causing the next team to be skipped, too
Wuzzy <almikes@aol.com>
parents: 12406
diff changeset
  1100
    end
8cc070640fd1 Fix skipping in Racer causing the next team to be skipped, too
Wuzzy <almikes@aol.com>
parents: 12406
diff changeset
  1101
end
8cc070640fd1 Fix skipping in Racer causing the next team to be skipped, too
Wuzzy <almikes@aol.com>
parents: 12406
diff changeset
  1102
15245
395563ffc8b5 Racer: Count turn as skipped when computer skipped
Wuzzy <Wuzzy2@mail.ru>
parents: 15137
diff changeset
  1103
function onSkipTurn()
395563ffc8b5 Racer: Count turn as skipped when computer skipped
Wuzzy <Wuzzy2@mail.ru>
parents: 15137
diff changeset
  1104
    turnSkipped = true
395563ffc8b5 Racer: Count turn as skipped when computer skipped
Wuzzy <Wuzzy2@mail.ru>
parents: 15137
diff changeset
  1105
end
395563ffc8b5 Racer: Count turn as skipped when computer skipped
Wuzzy <Wuzzy2@mail.ru>
parents: 15137
diff changeset
  1106
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1107
function onAchievementsDeclaration()
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1108
    usedWeapons[amSkip] = nil
11563
7e5d6ce6fe14 Treat #99 point type as a ghost trace
unc0rr
parents: 11545
diff changeset
  1109
    usedWeapons[amExtraTime] = nil
7e5d6ce6fe14 Treat #99 point type as a ghost trace
unc0rr
parents: 11545
diff changeset
  1110
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1111
    usedRope = usedWeapons[amRope] ~= nil
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1112
    usedPortal = usedWeapons[amPortalGun] ~= nil
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1113
    usedSaucer = usedWeapons[amJetpack] ~= nil
11563
7e5d6ce6fe14 Treat #99 point type as a ghost trace
unc0rr
parents: 11545
diff changeset
  1114
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1115
    usedWeapons[amNothing] = nil
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1116
    usedWeapons[amRope] = nil
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1117
    usedWeapons[amPortalGun] = nil
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1118
    usedWeapons[amJetpack] = nil
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1119
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1120
    usedOther = next(usedWeapons) ~= nil
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1121
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1122
    if usedOther then -- smth besides nothing, skip, rope, portal or saucer used
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1123
        raceType = "unknown race"
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1124
    elseif usedRope and not usedPortal and not usedSaucer then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1125
        raceType = "rope race"
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1126
    elseif not usedRope and usedPortal and not usedSaucer then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1127
        raceType = "portal race"
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1128
    elseif not usedRope and not usedPortal and usedSaucer then
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1129
        raceType = "saucer race"
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1130
    elseif (usedRope or usedPortal or usedSaucer or usedOther) == false then -- no weapons used at all?
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1131
        raceType = "no tools race"
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1132
    else -- at least two of rope, portal and saucer used
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1133
        raceType = "mixed race"
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1134
    end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1135
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1136
    for i = 0, (numTeams-1) do
13839
2fceeea62b10 Add tie handling for Racer and TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
  1137
        if teamScore[i] < MAX_TURN_TIME then
14070
a5be3ef4bbbe Update official challenge hashes, improve console logging (warning: racer #17 is missing!)
Wuzzy <Wuzzy2@mail.ru>
parents: 13841
diff changeset
  1138
            DeclareAchievement(raceType, teamNameArr[i], officialChallenge, teamScore[i])
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1139
        end
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1140
    end
11569
294ce0fa65d0 Dump best time ghost on console
unc0rr
parents: 11563
diff changeset
  1141
14070
a5be3ef4bbbe Update official challenge hashes, improve console logging (warning: racer #17 is missing!)
Wuzzy <Wuzzy2@mail.ru>
parents: 13841
diff changeset
  1142
    if officialChallenge ~= nil and fastCount > 0 then
11569
294ce0fa65d0 Dump best time ghost on console
unc0rr
parents: 11563
diff changeset
  1143
        StartGhostPoints(fastCount)
294ce0fa65d0 Dump best time ghost on console
unc0rr
parents: 11563
diff changeset
  1144
294ce0fa65d0 Dump best time ghost on console
unc0rr
parents: 11563
diff changeset
  1145
        for i = 0, (fastCount - 1) do
294ce0fa65d0 Dump best time ghost on console
unc0rr
parents: 11563
diff changeset
  1146
            DumpPoint(fastX[i], fastY[i])
294ce0fa65d0 Dump best time ghost on console
unc0rr
parents: 11563
diff changeset
  1147
        end
294ce0fa65d0 Dump best time ghost on console
unc0rr
parents: 11563
diff changeset
  1148
    end
10856
d080b8d4c114 team coloured, just for the heck of it, based on a param. also del airmine, 'cause, probably not fun here. you're invuln anyway.
nemo
parents: 10847
diff changeset
  1149
end