share/hedgewars/Data/Maps/TrophyRace/map.lua
author Wuzzy <almikes@aol.com>
Sat, 30 Sep 2017 23:52:08 +0200
changeset 12627 07fdda8c13a2
parent 12393 0eb1457f7b94
child 12704 608db0fb90f0
permissions -rw-r--r--
TrophyRace: Fix game never eliminating any hogs after a hog skipped or ran out of time Warning: This commit _might_ invalidate past records, but I'm not sure if this is actually the case. Note that only the eliminiation part of the script is touched, not the actual race logic. Even if records are actually broken by this, I and sheepluva have decided that it's more imporant to fix this very, VERY stupid and old bug than to preserve records.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4506
37744d5c877e Finnished up the lua translations by adding training maps, campaign is ignored for now
Henek
parents: 4503
diff changeset
     1
-- Hedgewars - Roperace for 2+ Players
4188
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
     2
12393
0eb1457f7b94 Add big fat developer warning to all racing scripts about compability
Wuzzy <almikes@aol.com>
parents: 12292
diff changeset
     3
-- DEVELOPER WARNING - FOR OFFICIAL DEVELOPMENT --
0eb1457f7b94 Add big fat developer warning to all racing scripts about compability
Wuzzy <almikes@aol.com>
parents: 12292
diff changeset
     4
-- Be careful when editig this script, do not introduce changes lightly!
0eb1457f7b94 Add big fat developer warning to all racing scripts about compability
Wuzzy <almikes@aol.com>
parents: 12292
diff changeset
     5
-- This script is used for time records on the official Hedgewars server.
0eb1457f7b94 Add big fat developer warning to all racing scripts about compability
Wuzzy <almikes@aol.com>
parents: 12292
diff changeset
     6
-- Introducing breaking changes means we have to invalidate past time records!
0eb1457f7b94 Add big fat developer warning to all racing scripts about compability
Wuzzy <almikes@aol.com>
parents: 12292
diff changeset
     7
9093
4114ce5d885d fix locale load
nemo
parents: 8349
diff changeset
     8
HedgewarsScriptLoad("/Scripts/Locale.lua")
4188
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
     9
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    10
-- store number of hedgehogs
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    11
local numhhs = 0
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    12
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    13
-- store hedgehog gears
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    14
local hhs = {}
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    15
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    16
-- store best time per team
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    17
local clantimes = {}
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    18
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    19
-- store best times
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    20
local times = {}
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    21
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    22
-- in milisseconds
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    23
local maxtime = 99000
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    24
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    25
-- define start area (left, top, width, height)
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    26
local start_area = {1606, 498, 356, 80}
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    27
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    28
-- define goal area (left, top, width, height)
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    29
local goal_area = {2030, 300, 56, 280}
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    30
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    31
-- last active hog
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    32
local lasthog = nil
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    33
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    34
-- active hog reached the goal?
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    35
local reached = false
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    36
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    37
-- hog with worst time (per round)
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    38
local worsthog = nil
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    39
9664
1e528c58e41d ok. this should avoid calling switch inappropriately. also, add skip to trophyrace and add the per-team achievement reporting.
nemo
parents: 9659
diff changeset
    40
local besthog = nil
11205
9301550d2566 TrophyRace: fix nil error warning, caused by needlessly re-retrieving the name of the best hedgehog (which could be dead at that point)
sheepluva
parents: 11184
diff changeset
    41
local besthogname = ''
9664
1e528c58e41d ok. this should avoid calling switch inappropriately. also, add skip to trophyrace and add the per-team achievement reporting.
nemo
parents: 9659
diff changeset
    42
4188
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    43
-- best time
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    44
local besttime = maxtime + 1
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    45
9664
1e528c58e41d ok. this should avoid calling switch inappropriately. also, add skip to trophyrace and add the per-team achievement reporting.
nemo
parents: 9659
diff changeset
    46
-- best time per team
1e528c58e41d ok. this should avoid calling switch inappropriately. also, add skip to trophyrace and add the per-team achievement reporting.
nemo
parents: 9659
diff changeset
    47
local bestTimes = {}
1e528c58e41d ok. this should avoid calling switch inappropriately. also, add skip to trophyrace and add the per-team achievement reporting.
nemo
parents: 9659
diff changeset
    48
4188
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    49
-- worst time (per round)
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    50
local worsttime = 0
9657
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
    51
local startTime = 0;
4188
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    52
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    53
function onGameInit()
9657
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
    54
    GameFlags = gfSolidLand + gfInvulnerable
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
    55
    TurnTime = maxtime
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
    56
    CaseFreq = 0
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
    57
    MinesNum = 0
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
    58
    Explosives = 0
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
    59
    Delay = 500
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
    60
    Theme = 'Olympics'
12084
8f222872d432 Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents: 12082
diff changeset
    61
    -- Disable Sudden Death
8f222872d432 Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents: 12082
diff changeset
    62
    WaterRise = 0
8f222872d432 Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents: 12082
diff changeset
    63
    HealthDecrease = 0
4188
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    64
end
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    65
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    66
function onGameStart()
12082
ce3860c82c8b Rewrite 2nd line of mission panel of most missions for consistency
Wuzzy <almikes@aol.com>
parents: 11205
diff changeset
    67
    ShowMission(loc("TrophyRace"), loc("Race"), loc("Use your rope to get from start to finish as fast as you can!"), -amRope, 0)
9657
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
    68
    started = true
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
    69
    p=1820
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
    70
    for i = 0, numhhs - 1 do
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
    71
    p = p + 50    
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
    72
    SetGearPosition(hhs[i], p, 0)
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
    73
    end
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
    74
    
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
    75
    for i=0, ClansCount-1 do
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
    76
        clantimes[i] = 0
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
    77
    end
4188
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    78
end
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    79
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    80
function onAmmoStoreInit()
9664
1e528c58e41d ok. this should avoid calling switch inappropriately. also, add skip to trophyrace and add the per-team achievement reporting.
nemo
parents: 9659
diff changeset
    81
    SetAmmo(amRope, 9, 1, 0)
1e528c58e41d ok. this should avoid calling switch inappropriately. also, add skip to trophyrace and add the per-team achievement reporting.
nemo
parents: 9659
diff changeset
    82
    SetAmmo(amSkip, 9, 1, 0)
4188
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    83
end
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
    84
9685
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
    85
function killHog()
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
    86
        SetHealth(CurrentHedgehog, 0)
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
    87
        SetEffect(CurrentHedgehog, heInvulnerable, 0)
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
    88
        x, y = GetGearPosition(CurrentHedgehog)
11184
1750a1ce7131 speed up TrophyRace deaths
sheepluva
parents: 10289
diff changeset
    89
        AddGear(x, y-2, gtGrenade, 0, 0, 0, 2)
1750a1ce7131 speed up TrophyRace deaths
sheepluva
parents: 10289
diff changeset
    90
        SetGearVelocity(CurrentHedgehog, 0, 0)
9685
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
    91
        worsttime = 99999
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
    92
        worsthog = nil
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
    93
        lasthog = nil
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
    94
end
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
    95
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
    96
function onHogAttack()
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
    97
    if TurnTimeLeft == 0 then
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
    98
        killHog()
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
    99
    end
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   100
end
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   101
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   102
function onNewTurn()
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   103
    if lasthog ~= nil then 
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   104
        SetGearPosition(lasthog, p , 0)
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   105
        if not reached then
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   106
        end
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   107
    end
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   108
    startTime = 0
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   109
    reached = false
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   110
    if CurrentHedgehog ~= nil then
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   111
        SetGearVelocity(CurrentHedgehog, 1, 0)
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   112
        SetGearPosition(CurrentHedgehog, start_area[1] + start_area[3] / 2, start_area[2] + start_area[4] / 2)
10289
c3a77ff02a23 lua api: SetWeapon(ammoType)
sheepluva
parents: 9685
diff changeset
   113
        SetWeapon(amRope)
9685
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   114
        lasthog = CurrentHedgehog
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   115
    end
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   116
end
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   117
9659
e9c00dd31b07 drop onGameTick20 - it has some savings on cpu, but racers demand millisecond precision not 20 millisecond, apparently
nemo
parents: 9658
diff changeset
   118
function onGameTick()
9658
c97e8ecc7457 this isn't pascal
nemo
parents: 9657
diff changeset
   119
    if startTime == 0 and TurnTimeLeft < maxtime then
9657
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   120
        startTime = GameTime
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   121
    end
9664
1e528c58e41d ok. this should avoid calling switch inappropriately. also, add skip to trophyrace and add the per-team achievement reporting.
nemo
parents: 9659
diff changeset
   122
    if CurrentHedgehog ~= nil and TurnTimeLeft == 1 then
9685
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   123
        killHog()
9657
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   124
    elseif CurrentHedgehog ~= nil then
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   125
        x, y = GetGearPosition(CurrentHedgehog)
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   126
        if not reached and x > goal_area[1] and x < goal_area[1] + goal_area[3] and y > goal_area[2] and y < goal_area[2] + goal_area[4] then -- hog is within goal rectangle
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   127
            reached = true
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   128
            local ttime = GameTime-startTime
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   129
            --give it a sound;)
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   130
            if ttime < besttime then
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   131
                PlaySound (sndHomerun)
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   132
            else
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   133
                PlaySound (sndHellish)
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   134
            end
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   135
            for i = 0, numhhs - 1 do
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   136
                if hhs[i] == CurrentHedgehog then
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   137
                    times[numhhs] = ttime
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   138
                end
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   139
            end
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   140
                
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   141
            local hscore = "| |"
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   142
            local clan = GetHogClan(CurrentHedgehog)
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   143
            if ttime < clantimes[clan] or clantimes[clan] == 0 then
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   144
                clantimes[clan] = ttime
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   145
            end
9664
1e528c58e41d ok. this should avoid calling switch inappropriately. also, add skip to trophyrace and add the per-team achievement reporting.
nemo
parents: 9659
diff changeset
   146
            local teamname = GetHogTeamName(CurrentHedgehog)
1e528c58e41d ok. this should avoid calling switch inappropriately. also, add skip to trophyrace and add the per-team achievement reporting.
nemo
parents: 9659
diff changeset
   147
            if bestTimes[teamname] == nil or bestTimes[teamname] > ttime then
1e528c58e41d ok. this should avoid calling switch inappropriately. also, add skip to trophyrace and add the per-team achievement reporting.
nemo
parents: 9659
diff changeset
   148
                bestTimes[teamname] = ttime
1e528c58e41d ok. this should avoid calling switch inappropriately. also, add skip to trophyrace and add the per-team achievement reporting.
nemo
parents: 9659
diff changeset
   149
            end
9657
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   150
            if ttime < besttime then
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   151
                besttime = ttime
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   152
                besthog = CurrentHedgehog
11205
9301550d2566 TrophyRace: fix nil error warning, caused by needlessly re-retrieving the name of the best hedgehog (which could be dead at that point)
sheepluva
parents: 11184
diff changeset
   153
                besthogname = GetHogName(besthog)
9657
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   154
                hscore = hscore .. loc("NEW fastest lap: ")
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   155
            else
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   156
                hscore = hscore .. loc("Fastest lap: ")
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   157
            end
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   158
            if ttime > worsttime then
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   159
                worsttime = ttime
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   160
                worsthog = CurrentHedgehog
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   161
            end
11205
9301550d2566 TrophyRace: fix nil error warning, caused by needlessly re-retrieving the name of the best hedgehog (which could be dead at that point)
sheepluva
parents: 11184
diff changeset
   162
            hscore = hscore .. besthogname .. " - " .. (besttime / 1000) .. " s | |" .. loc("Best laps per team: ")
9657
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   163
            
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   164
            if clan == ClansCount -1 then
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   165
                -- Time for elimination - worst hog is out and the worst hog vars are reset.
9685
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   166
                if worsthog ~= nil then
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   167
                    SetHealth(worsthog, 0)
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   168
                    --Place a grenade to make inactive slowest hog active
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   169
                    x, y = GetGearPosition(worsthog)
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   170
                    AddGear(x, y, gtShell, 0, 0, 0, 0)
9657
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   171
                end
12627
07fdda8c13a2 TrophyRace: Fix game never eliminating any hogs after a hog skipped or ran out of time
Wuzzy <almikes@aol.com>
parents: 12393
diff changeset
   172
                worsttime = 0
07fdda8c13a2 TrophyRace: Fix game never eliminating any hogs after a hog skipped or ran out of time
Wuzzy <almikes@aol.com>
parents: 12393
diff changeset
   173
                worsthog = nil
9685
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   174
            end
9657
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   175
            
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   176
            for i=0, ClansCount -1 do
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   177
                local tt = "" .. (clantimes[i] / 1000) .. " s"
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   178
                if clantimes[i] == 0 then
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   179
                    tt = "--"
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   180
                end
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   181
                hscore = hscore .. "|" .. string.format(loc("Team %d: "), i+1) .. tt
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   182
            end
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   183
            
12082
ce3860c82c8b Rewrite 2nd line of mission panel of most missions for consistency
Wuzzy <almikes@aol.com>
parents: 11205
diff changeset
   184
            ShowMission(loc("TrophyRace"), loc("Race"), loc("You've reached the goal!| |Time: ") .. (ttime / 1000) .. " s" .. hscore, 0, 0)
12292
faf1b93422ba Use new EndTurn in a couple of scripts, esp. to fix timeout taunts in Racer
Wuzzy <almikes@aol.com>
parents: 12084
diff changeset
   185
            EndTurn(true)
9657
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   186
        end
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   187
    end
4188
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
   188
end
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
   189
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
   190
function onGearAdd(gear)
9657
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   191
    if GetGearType(gear) == gtHedgehog then
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   192
        hhs[numhhs] = gear
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   193
        times[numhhs] = 0
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   194
        numhhs = numhhs + 1
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   195
    end
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   196
--    elseif GetGearType(gear) == gtRope then -- rope is shot
4188
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
   197
end
e1bf1b5a301e pt_BR, the return. also fix line ending screwups
arrom
parents: 4174
diff changeset
   198
7771
ce6d4dd0c780 fix trophyrace. also tweak it a little
nemo
parents: 4506
diff changeset
   199
--function onGearDelete(gear)
9657
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   200
--    if GetGearType(gear) == gtRope then -- rope deletion - hog didn't manage to rerope
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   201
--        --TurnTimeLeft = 0 -- end turn or not? hm...
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   202
--        lasthog = CurrentHedgehog
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   203
--        
2d8cae3c0855 use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents: 9411
diff changeset
   204
--    end
7771
ce6d4dd0c780 fix trophyrace. also tweak it a little
nemo
parents: 4506
diff changeset
   205
--end
9397
7b7ee65f82ad Declare achievements in console statistics output
unc0rr
parents: 9093
diff changeset
   206
7b7ee65f82ad Declare achievements in console statistics output
unc0rr
parents: 9093
diff changeset
   207
function onAchievementsDeclaration()
9685
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   208
    for team,time in pairs(bestTimes) do
7d925e82e572 Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents: 9664
diff changeset
   209
        DeclareAchievement("rope race", team, "TrophyRace", time)
9397
7b7ee65f82ad Declare achievements in console statistics output
unc0rr
parents: 9093
diff changeset
   210
    end
7b7ee65f82ad Declare achievements in console statistics output
unc0rr
parents: 9093
diff changeset
   211
end