share/hedgewars/Data/Scripts/Multiplayer/Racer.lua
author Vatten
Sat, 22 Nov 2014 17:46:04 +0100
changeset 10527 285b428f391c
parent 10292 1c6639b49afc
child 10847 b68e35d6e376
permissions -rw-r--r--
desync fix for Continental Supplies
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10044
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
     1
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
     2
------------------------------------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
     3
-- RACER 0.6
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
     4
-- map-independant racing script
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
     5
-- by mikade
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
     6
-----------------------------------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
     7
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
     8
-----------------------------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
     9
--0.1: took all the code from crazy racer and scrapped most of it
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    10
-----------------------------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    11
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    12
-- Removed tumbler system
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    13
-- Removed extra adds like boosters etc
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    14
-- Added experimental waypoint placement system
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    15
-- More user feedback
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    16
-- Reduced race complexity limit to 5 waypoints
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    17
-- stop placement at complexity limit reached and end turn
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    18
-- guys dont keep racing after dying
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    19
-- invulnerable feasibility
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    20
-- reverted time keeping method
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    21
-- reduced feedback display time
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    22
-- colour-coded addcaptions
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    23
-- cleaned up code
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    24
-- support for more players properly added
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    25
-- tardis fix
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    26
-- remove airstrikes
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    27
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    28
-- i think the remainder 0 .456 sec of the tracktime isnt getting reset on newturn
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    29
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    30
-- update feedback
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    31
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    32
-------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    33
-- 0.2
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    34
-------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    35
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    36
-- allow gameflags
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    37
-- extend time to 90s
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    38
-- remove other air-attack based weps
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    39
-- turn off water rise for sd
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    40
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    41
-------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    42
-- 0.3
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    43
-------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    44
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    45
-- prevent WP being placed in land
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    46
-- prevent waypoints being placed outside border
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    47
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    48
-------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    49
-- 0.4
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    50
-------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    51
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    52
-- update user feedback
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    53
-- add more sounds
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    54
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    55
-------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    56
-- 0.5
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    57
-------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    58
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    59
-- fix ghost disappearing if hog falls in water or somehow dies
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    60
-- lengthen ghost tracking interval to improve performance on slower machines
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    61
-- increase waypoint limit to 8
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    62
-- allow for persistent showmission information
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    63
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    64
-------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    65
-- 0.6
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    66
-------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    67
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    68
-- remove hogs from racing area as per request
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    69
10292
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
    70
-------
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
    71
-- 0.7
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
    72
-------
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
    73
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
    74
-- switch to first available weapon if starting race with no weapon selected
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
    75
10044
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    76
-----------------------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    77
-- SCRIPT BEGINS
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    78
-----------------------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    79
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    80
HedgewarsScriptLoad("/Scripts/Locale.lua")
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    81
HedgewarsScriptLoad("/Scripts/OfficialChallenges.lua")
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    82
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    83
------------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    84
-- Got Variables?
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    85
------------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    86
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    87
local fMod = 1000000 -- 1
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    88
local roundLimit = 3
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    89
local roundNumber = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    90
local firstClan = 10
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    91
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    92
local fastX = {}
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    93
local fastY = {}
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    94
local fastCount = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    95
local fastIndex = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    96
local fastColour
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    97
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    98
local currX = {}
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
    99
local currY = {}
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   100
local currCount = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   101
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   102
local specialPointsX = {}
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   103
local specialPointsY = {}
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   104
local specialPointsCount = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   105
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   106
--------------------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   107
-- hog and team tracking variales
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   108
--------------------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   109
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   110
local numhhs = 0 -- store number of hedgehogs
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   111
local hhs = {} -- store hedgehog gears
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   112
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   113
local numTeams --  store the number of teams in the game
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   114
local teamNameArr = {}  -- store the list of teams
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   115
local teamClan = {}
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   116
local teamSize = {}     -- store how many hogs per team
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   117
local teamIndex = {} -- at what point in the hhs{} does each team begin
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   118
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   119
local teamComment = {}
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   120
local teamScore = {}
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   121
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   122
-------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   123
-- racer vars
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   124
--------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   125
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   126
local cGear = nil
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   127
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   128
local bestClan = nil
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   129
local bestTime = nil
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   130
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   131
local gameBegun = false
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   132
local gameOver = false
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   133
local racerActive = false
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   134
local trackTime = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   135
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   136
local wpCirc = {}
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   137
local wpX = {}
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   138
local wpY = {}
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   139
local wpCol = {}
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   140
local wpActive = {}
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   141
local wpRad = 450 --75
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   142
local wpCount = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   143
local wpLimit = 8
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   144
10228
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   145
local usedWeapons = {}
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   146
10044
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   147
local roundN
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   148
local lastRound
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   149
local RoundHasChanged
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   150
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   151
-------------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   152
-- general methods
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   153
-------------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   154
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   155
function RebuildTeamInfo()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   156
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   157
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   158
        -- make a list of individual team names
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   159
        for i = 0, (TeamsCount-1) do
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   160
                teamNameArr[i] = " " -- = i
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   161
                teamSize[i] = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   162
                teamIndex[i] = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   163
                teamScore[i] = 100000
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   164
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   165
        numTeams = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   166
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   167
        for i = 0, (numhhs-1) do
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   168
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   169
                z = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   170
                unfinished = true
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   171
                while(unfinished == true) do
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   172
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   173
                        newTeam = true
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   174
                        tempHogTeamName = GetHogTeamName(hhs[i]) -- this is the new name
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   175
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   176
                        if tempHogTeamName == teamNameArr[z] then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   177
                                newTeam = false
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   178
                                unfinished = false
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   179
                        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   180
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   181
                        z = z + 1
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   182
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   183
                        if z == TeamsCount then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   184
                                unfinished = false
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   185
                                if newTeam == true then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   186
                                        teamNameArr[numTeams] = tempHogTeamName
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   187
                                        numTeams = numTeams + 1
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   188
                                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   189
                        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   190
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   191
                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   192
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   193
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   194
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   195
        -- find out how many hogs per team, and the index of the first hog in hhs
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   196
        for i = 0, (numTeams-1) do
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   197
                for z = 0, (numhhs-1) do
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   198
                        if GetHogTeamName(hhs[z]) == teamNameArr[i] then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   199
                                teamClan[i] = GetHogClan(hhs[z])
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   200
                                if teamSize[i] == 0 then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   201
                                        teamIndex[i] = z -- should give starting index
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   202
                                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   203
                                teamSize[i] = teamSize[i] + 1
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   204
                                --add a pointer so this hog appears at i in hhs
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   205
                        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   206
                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   207
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   208
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   209
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   210
end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   211
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   212
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   213
-----------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   214
-- RACER METHODS
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   215
-----------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   216
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   217
function CheckWaypoints()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   218
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   219
        trackFinished = true
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   220
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   221
        for i = 0, (wpCount-1) do
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   222
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   223
                g1X, g1Y = GetGearPosition(CurrentHedgehog)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   224
                g2X, g2Y = wpX[i], wpY[i]
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   225
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   226
                g1X = g1X - g2X
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   227
                g1Y = g1Y - g2Y
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   228
                dist = (g1X*g1X) + (g1Y*g1Y)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   229
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   230
                --if i == 0 then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   231
                --      AddCaption(dist .. "/" .. (wpRad*wpRad) )
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   232
                --end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   233
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   234
                NR = (48/100*wpRad)/2
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   235
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   236
                if dist < (NR*NR) then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   237
                --if dist < (wpRad*wpRad) then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   238
                        --AddCaption("howdy")
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   239
                        wpActive[i] = true
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   240
                        wpCol[i] = GetClanColor(GetHogClan(CurrentHedgehog)) -- new                             --GetClanColor(1)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   241
                        SetVisualGearValues(wpCirc[i], wpX[i], wpY[i], 20, 100, 1, 10, 0, wpRad, 5, wpCol[i])
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   242
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   243
                        wpRem = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   244
                        for k = 0, (wpCount-1) do
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   245
                                if wpActive[k] == false then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   246
                                        wpRem = wpRem + 1
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   247
                                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   248
                        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   249
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   250
                        AddCaption(loc("Way-Points Remaining") .. ": " .. wpRem,0xffba00ff,capgrpAmmoinfo)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   251
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   252
                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   253
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   254
                if wpActive[i] == false then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   255
                        trackFinished = false
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   256
                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   257
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   258
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   259
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   260
        return(trackFinished)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   261
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   262
end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   263
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   264
function AdjustScores()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   265
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   266
        if bestTime == nil then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   267
                bestTime = 100000
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   268
                bestClan = 10
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   269
                bestTimeComment = "N/A"
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   270
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   271
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   272
        newScore = false
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   273
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   274
        -- update this clan's time if the new track is better
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   275
        for i = 0, (numTeams-1) do
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   276
                if teamClan[i] == GetHogClan(CurrentHedgehog) then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   277
                        if trackTime < teamScore[i] then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   278
                                teamScore[i] = trackTime
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   279
                                newScore = true
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   280
                        else
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   281
                                newScore = false
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   282
                        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   283
                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   284
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   285
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   286
        --bestTime = 100000
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   287
        --bestClan = 10
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   288
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   289
        -- find the best time out of those so far
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   290
        for i = 0, (numTeams-1) do
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   291
                if teamScore[i] < bestTime then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   292
                        bestTime = teamScore[i]
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   293
                        bestClan = teamClan[i]
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   294
                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   295
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   296
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   297
        if bestTime ~= 100000 then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   298
                bestTimeComment = (bestTime/1000) ..loc("s")
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   299
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   300
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   301
        if newScore == true then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   302
                if trackTime == bestTime then -- best time of the race
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   303
                        ShowMission(loc("RACER"),
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   304
                        loc("TRACK COMPLETED"),
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   305
                        loc("NEW RACE RECORD: ") .. (trackTime/1000) ..loc("s") .. "|" ..
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   306
                        loc("WINNING TIME: ") .. bestTimeComment, 0, 4000)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   307
                        PlaySound(sndHomerun)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   308
                else    -- best time for the clan
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   309
                        ShowMission(loc("RACER"),
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   310
                        loc("TRACK COMPLETED"),
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   311
                        loc("NEW CLAN RECORD: ") .. (trackTime/1000) ..loc("s") .. "|" ..
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   312
                        loc("WINNING TIME: ") .. bestTimeComment, 4, 4000)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   313
                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   314
        else -- not any kind of new score
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   315
                ShowMission(loc("RACER"),
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   316
                loc("TRACK COMPLETED"),
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   317
                loc("TIME: ") .. (trackTime/1000) ..loc("s") .. "|" ..
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   318
                loc("WINNING TIME: ") .. bestTimeComment, -amSkip, 4000)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   319
                PlaySound(sndHellish)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   320
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   321
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   322
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   323
        --------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   324
        --new
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   325
        --------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   326
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   327
        if bestTime == trackTime then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   328
                --AddCaption("wooooooooooooooooooooooooooooo")
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   329
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   330
                fastColour = GetClanColor(GetHogClan(CurrentHedgehog))
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   331
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   332
                for i = 0, (currCount-1) do
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   333
                        fastX[i] = currX[i]
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   334
                        fastY[i] = currY[i]
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   335
                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   336
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   337
                fastCount = currCount
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   338
                fastIndex = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   339
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   340
                --currCount = 0 -- is this needed?
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   341
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   342
        else
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   343
                currCount = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   344
                fastIndex = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   345
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   346
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   347
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   348
end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   349
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   350
function onNewRound()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   351
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   352
        roundNumber = roundNumber + 1
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   353
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   354
        totalComment = ""
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   355
        for i = 0, (TeamsCount-1) do
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   356
                        if teamNameArr[i] ~= " " then                           -- teamScore[teamClan[i]]
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   357
                                teamComment[i] = teamNameArr[i] .. ": " .. (teamScore[i]/1000) .. loc("s|")
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   358
                                totalComment = totalComment .. teamComment[i]
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   359
                        elseif teamNameArr[i] == " " then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   360
                                teamComment[i] = "|"
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   361
                        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   362
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   363
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   364
        ShowMission(    loc("RACER"),
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   365
                                        loc("STATUS UPDATE"),
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   366
                                        loc("Rounds Complete: ") .. roundNumber .. "/" .. roundLimit .. "|" .. " " .. "|" ..
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   367
                                        loc("Best Team Times: ") .. "|" .. totalComment, 0, 4000)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   368
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   369
        -- end game if its at round limit
10227
0b848d595f22 - Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents: 10044
diff changeset
   370
        if roundNumber >= roundLimit then
10044
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   371
                for i = 0, (numhhs-1) do
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   372
                        if GetHogClan(hhs[i]) ~= bestClan then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   373
                                SetEffect(hhs[i], heResurrectable, 0)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   374
                                SetHealth(hhs[i],0)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   375
                        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   376
                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   377
                gameOver = true
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   378
                TurnTimeLeft = 1
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   379
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   380
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   381
end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   382
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   383
function CheckForNewRound()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   384
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   385
        -------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   386
        ------ new
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   387
        -------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   388
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   389
        --[[turnN = turnN + 1
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   390
        if gameBegun == false then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   391
                if turnN == 2 then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   392
                        for i = 0, (numhhs-1) do
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   393
                                if hhs[i] ~= nil then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   394
                                        SetEffect(hhs[i], heResurrectable, 0)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   395
                                        SetHealth(hhs[i],0)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   396
                                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   397
                        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   398
                        gameOver = true
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   399
                        TurnTimeLeft = 1
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   400
                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   401
        else
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   402
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   403
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   404
        end]]
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   405
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   406
        --[[if roundBegun == true then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   407
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   408
                if RoundHasChanged == true then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   409
                        roundN = roundN + 1
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   410
                        RoundHasChanged = false
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   411
                        onNewRound()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   412
                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   413
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   414
                if lastRound ~= TotalRounds then -- new round, but not really
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   415
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   416
                        if RoundHasChanged == false then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   417
                                RoundHasChanged = true
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   418
                        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   419
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   420
                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   421
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   422
                AddCaption("RoundN:" .. roundN .. "; " .. "TR: " .. TotalRounds)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   423
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   424
                lastRound = TotalRounds
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   425
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   426
        end]]
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   427
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   428
        ------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   429
        ----- old
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   430
        ------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   431
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   432
        if GetHogClan(CurrentHedgehog) == firstClan then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   433
                onNewRound()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   434
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   435
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   436
end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   437
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   438
function DisableTumbler()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   439
        currCount = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   440
        fastIndex = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   441
        TurnTimeLeft = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   442
        racerActive = false -- newadd
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   443
end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   444
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   445
function HandleGhost()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   446
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   447
        -- get the current xy of the racer at this point
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   448
        currX[currCount] = GetX(CurrentHedgehog)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   449
        currY[currCount] = GetY(CurrentHedgehog)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   450
        currCount = currCount + 1
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   451
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   452
        -- draw a ping of smoke where the fastest player was at this point
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   453
        if (fastCount ~= 0) and (fastIndex < fastCount) then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   454
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   455
                fastIndex = fastIndex + 1
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   456
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   457
                tempE = AddVisualGear(fastX[fastIndex], fastY[fastIndex], vgtSmoke, 0, false)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   458
                g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   459
                SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, fastColour )
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   460
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   461
                --AddCaption("fC: " .. fastIndex .. " / " .. fastCount)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   462
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   463
        else
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   464
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   465
                --AddCaption("excep fC: " .. fastIndex .. " / " .. fastCount)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   466
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   467
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   468
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   469
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   470
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   471
end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   472
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   473
function TryRepositionHogs()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   474
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   475
	if MapHasBorder() == true then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   476
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   477
		for i = 0, (numhhs-1) do
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   478
			if hhs[i] ~= nil then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   479
				SetGearPosition(hhs[i],GetX(hhs[i]), TopY-10)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   480
			end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   481
		end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   482
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   483
	end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   484
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   485
end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   486
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   487
----------------------------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   488
-- GAME METHODS / EVENT HANDLERS
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   489
----------------------------------
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   490
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   491
function onGameInit()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   492
        EnableGameFlags(gfInfAttack, gfInvulnerable)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   493
        CaseFreq = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   494
        TurnTime = 90000
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   495
        WaterRise = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   496
end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   497
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   498
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   499
function onGameStart()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   500
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   501
        roundN = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   502
        lastRound = TotalRounds
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   503
        RoundHasChanged = false -- true
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   504
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   505
        for i = 0, (specialPointsCount-1) do
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   506
                PlaceWayPoint(specialPointsX[i], specialPointsY[i])
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   507
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   508
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   509
        RebuildTeamInfo()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   510
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   511
        ShowMission     (
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   512
                                loc("RACER"),
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   513
                                loc("a Hedgewars mini-game"),
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   514
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   515
                                loc("Build a track and race.") .. "|" ..
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   516
                                loc("Round Limit:") .. " " .. roundLimit .. "|" ..
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   517
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   518
                                "", 4, 4000
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   519
                                )
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   520
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   521
        TryRepositionHogs()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   522
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   523
end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   524
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   525
function PlaceWayPoint(x,y)
10227
0b848d595f22 - Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents: 10044
diff changeset
   526
    if not racerActive then
0b848d595f22 - Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents: 10044
diff changeset
   527
        if wpCount == 0 or wpX[wpCount - 1] ~= x or wpY[wpCount - 1] ~= y then
10044
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   528
10227
0b848d595f22 - Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents: 10044
diff changeset
   529
            wpX[wpCount] = x
0b848d595f22 - Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents: 10044
diff changeset
   530
            wpY[wpCount] = y
0b848d595f22 - Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents: 10044
diff changeset
   531
            wpCol[wpCount] = 0xffffffff
0b848d595f22 - Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents: 10044
diff changeset
   532
            wpCirc[wpCount] = AddVisualGear(wpX[wpCount],wpY[wpCount],vgtCircle,0,true)
0b848d595f22 - Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents: 10044
diff changeset
   533
                                                                                                                                            
0b848d595f22 - Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents: 10044
diff changeset
   534
            SetVisualGearValues(wpCirc[wpCount], wpX[wpCount], wpY[wpCount], 20, 100, 1, 10, 0, wpRad, 5, wpCol[wpCount])
10044
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   535
10227
0b848d595f22 - Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents: 10044
diff changeset
   536
            wpCount = wpCount + 1
10044
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   537
10227
0b848d595f22 - Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents: 10044
diff changeset
   538
            AddCaption(loc("Waypoint placed.") .. " " .. loc("Available points remaining: ") .. (wpLimit-wpCount))
10044
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   539
        end
10227
0b848d595f22 - Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents: 10044
diff changeset
   540
    end
10044
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   541
end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   542
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   543
function onSpecialPoint(x,y,flag)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   544
    specialPointsX[specialPointsCount] = x
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   545
    specialPointsY[specialPointsCount] = y
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   546
    specialPointsCount = specialPointsCount + 1
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   547
end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   548
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   549
function onNewTurn()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   550
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   551
        CheckForNewRound()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   552
        TryRepositionHogs()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   553
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   554
        racerActive = false
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   555
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   556
        trackTime = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   557
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   558
        currCount = 0 -- hopefully this solves problem
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   559
        AddAmmo(CurrentHedgehog, amAirAttack, 0)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   560
        gTimer = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   561
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   562
        -- Set the waypoints to unactive on new round
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   563
        for i = 0,(wpCount-1) do
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   564
                wpActive[i] = false
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   565
                wpCol[i] = 0xffffffff
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   566
                SetVisualGearValues(wpCirc[i], wpX[i], wpY[i], 20, 100, 1, 10, 0, wpRad, 5, wpCol[i])
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   567
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   568
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   569
        -- Handle Starting Stage of Game
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   570
        if (gameOver == false) and (gameBegun == false) then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   571
                if wpCount >= 3 then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   572
                        gameBegun = true
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   573
                        roundNumber = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   574
                        firstClan = GetHogClan(CurrentHedgehog)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   575
                        ShowMission(loc("RACER"),
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   576
                        loc("GAME BEGUN!!!"),
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   577
                        loc("Complete the track as fast as you can!"), 2, 4000)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   578
                else
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   579
                        ShowMission(loc("RACER"),
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   580
                        loc("NOT ENOUGH WAYPOINTS"),
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   581
                        loc("Place more waypoints using the 'Air Attack' weapon."), 2, 4000)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   582
                        AddAmmo(CurrentHedgehog, amAirAttack, 4000)
10292
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   583
                        SetWeapon(amAirAttack)
10044
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   584
                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   585
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   586
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   587
        if gameOver == true then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   588
                gameBegun = false
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   589
                racerActive = false -- newadd
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   590
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   591
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   592
        AddAmmo(CurrentHedgehog, amTardis, 0)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   593
        AddAmmo(CurrentHedgehog, amDrillStrike, 0)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   594
        AddAmmo(CurrentHedgehog, amMineStrike, 0)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   595
        AddAmmo(CurrentHedgehog, amNapalm, 0)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   596
        AddAmmo(CurrentHedgehog, amPiano, 0)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   597
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   598
end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   599
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   600
function onGameTick20()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   601
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   602
        -- airstrike detected, convert this into a potential waypoint spot
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   603
        if cGear ~= nil then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   604
                x,y = GetGearPosition(cGear)
10292
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   605
                if x > -9000 then
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   606
                        x,y = GetGearTarget(cGear)
10044
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   607
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   608
10292
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   609
                        if TestRectForObstacle(x-20, y-20, x+20, y+20, true) then
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   610
                                AddCaption(loc("Please place the way-point in the open, within the map boundaries."))
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   611
                                PlaySound(sndDenied)
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   612
                        elseif (y > WaterLine-50) then
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   613
                                AddCaption(loc("Please place the way-point further from the waterline."))
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   614
                                PlaySound(sndDenied)
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   615
                        else
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   616
                                PlaceWayPoint(x, y)
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   617
                                if wpCount == wpLimit then
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   618
                                        AddCaption(loc("Race complexity limit reached."))
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   619
                                        DisableTumbler()
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   620
                                end
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   621
                        end
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   622
                else
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   623
                        DeleteGear(cGear)
10044
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   624
                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   625
        SetGearPosition(cGear, -10000, 0)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   626
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   627
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   628
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   629
        -- start the player tumbling with a boom once their turn has actually begun
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   630
        if racerActive == false then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   631
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   632
                if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   633
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   634
                        -- if the gamehas started put the player in the middle of the first
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   635
                        --waypoint that was placed
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   636
                        if gameBegun == true then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   637
                                AddCaption(loc("Good to go!"))
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   638
                                racerActive = true
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   639
                                trackTime = 0
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   640
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   641
                                SetGearPosition(CurrentHedgehog, wpX[0], wpY[0])
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   642
                                AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   643
                                FollowGear(CurrentHedgehog)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   644
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   645
                                HideMission()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   646
10292
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   647
                                -- don't start empty-handed
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   648
                                if (GetCurAmmoType() == amNothing) then
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   649
                                        SetNextWeapon()
1c6639b49afc racer: if hog starts race without any weapon selected, select whatever is first
sheepluva
parents: 10289
diff changeset
   650
                                end
10044
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   651
                        else
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   652
                                -- still in placement mode
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   653
                        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   654
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   655
                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   656
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   657
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   658
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   659
        -- has the player started his tumbling spree?
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   660
        if (CurrentHedgehog ~= nil) then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   661
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   662
                --airstrike conversion used to be here
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   663
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   664
                -- if the RACE has started, show tracktimes and keep tabs on waypoints
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   665
                if (racerActive == true) and (gameBegun == true) then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   666
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   667
                        --ghost
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   668
                        if GameTime%40 == 0 then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   669
                                HandleGhost()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   670
                        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   671
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   672
                        trackTime = trackTime + 20
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   673
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   674
                        if GameTime%100 == 0 then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   675
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   676
                if trackTime%1000 == 0 then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   677
                    AddCaption((trackTime/1000)..'.0',GetClanColor(GetHogClan(CurrentHedgehog)),capgrpMessage2)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   678
                else
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   679
                    AddCaption(trackTime/1000,GetClanColor(GetHogClan(CurrentHedgehog)),capgrpMessage2)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   680
                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   681
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   682
                                if (CheckWaypoints() == true) then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   683
                                        AdjustScores()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   684
                                        DisableTumbler()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   685
                                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   686
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   687
                        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   688
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   689
                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   690
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   691
                -- if the player has expended his tunbling time, stop him tumbling
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   692
                if TurnTimeLeft <= 20 then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   693
                        DisableTumbler()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   694
                end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   695
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   696
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   697
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   698
end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   699
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   700
function onGearResurrect(gear)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   701
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   702
        AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   703
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   704
        if gear == CurrentHedgehog then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   705
                DisableTumbler()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   706
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   707
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   708
end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   709
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   710
function onGearAdd(gear)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   711
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   712
        if GetGearType(gear) == gtHedgehog then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   713
                hhs[numhhs] = gear
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   714
                numhhs = numhhs + 1
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   715
                SetEffect(gear, heResurrectable, 1)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   716
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   717
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   718
        if GetGearType(gear) == gtAirAttack then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   719
                cGear = gear
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   720
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   721
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   722
end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   723
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   724
function onGearDelete(gear)
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   725
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   726
        if GetGearType(gear) == gtAirAttack then
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   727
                cGear = nil
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   728
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   729
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   730
end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   731
10228
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   732
function onAttack()
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   733
    at = GetCurAmmoType()
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   734
    
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   735
    usedWeapons[at] = 0
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   736
end
10044
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   737
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   738
function onAchievementsDeclaration()
10228
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   739
    usedWeapons[amSkip] = nil
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   740
    
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   741
    usedRope = usedWeapons[amRope] ~= nil
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   742
    usedPortal = usedWeapons[amPortalGun] ~= nil
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   743
    usedSaucer = usedWeapons[amJetpack] ~= nil
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   744
    
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   745
    usedWeapons[amRope] = nil
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   746
    usedWeapons[amPortalGun] = nil
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   747
    usedWeapons[amJetpack] = nil
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   748
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   749
    usedOther = next(usedWeapons) ~= nil
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   750
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   751
    if usedOther then -- smth besides skip, rope, portal or saucer used
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   752
        raceType = "unknown race"
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   753
    elseif usedRope and not usedPortal and not usedSaucer then
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   754
        raceType = "rope race"
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   755
    elseif not usedRope and usedPortal and not usedSaucer then
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   756
        raceType = "portal race"
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   757
    elseif not usedRope and not usedPortal and usedSaucer then
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   758
        raceType = "saucer race"
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   759
    elseif (usedRope or usedPortal or usedSaucer or usedOther) == false then -- no weapons used at all?
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   760
        raceType = "no tools race"
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   761
    else -- at least two of rope, portal and saucer used
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   762
        raceType = "mixed race"
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   763
    end
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   764
10044
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   765
    map = detectMap()
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   766
    
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   767
    for i = 0, (numTeams-1) do
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   768
        if teamScore[i] < 100000 then
10228
947cadb40bc5 Add race type detection
unc0rr
parents: 10227
diff changeset
   769
            DeclareAchievement(raceType, teamNameArr[i], map, teamScore[i])
10044
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   770
        end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   771
    end
33e64afccd3b readd r3be36d2fdca6
koda
parents: 10017
diff changeset
   772
end