author | Wuzzy <Wuzzy2@mail.ru> |
Thu, 15 Feb 2018 18:32:28 +0100 | |
changeset 13009 | 67cc3cac4c8e |
parent 13008 | 99ff8f4810f4 |
child 13010 | d92c364f004d |
permissions | -rw-r--r-- |
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 | 2 |
|
12388
0eb1457f7b94
Add big fat developer warning to all racing scripts about compability
Wuzzy <almikes@aol.com>
parents:
12287
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:
12287
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:
12287
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:
12287
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:
12287
diff
changeset
|
7 |
|
9093 | 8 |
HedgewarsScriptLoad("/Scripts/Locale.lua") |
4188 | 9 |
|
10 |
-- store number of hedgehogs |
|
11 |
local numhhs = 0 |
|
12 |
||
13 |
-- store hedgehog gears |
|
14 |
local hhs = {} |
|
15 |
||
16 |
-- store best time per team |
|
17 |
local clantimes = {} |
|
18 |
||
19 |
-- store best times |
|
20 |
local times = {} |
|
21 |
||
22 |
-- in milisseconds |
|
23 |
local maxtime = 99000 |
|
24 |
||
25 |
-- define start area (left, top, width, height) |
|
26 |
local start_area = {1606, 498, 356, 80} |
|
27 |
||
28 |
-- define goal area (left, top, width, height) |
|
29 |
local goal_area = {2030, 300, 56, 280} |
|
30 |
||
31 |
-- last active hog |
|
32 |
local lasthog = nil |
|
33 |
||
34 |
-- active hog reached the goal? |
|
35 |
local reached = false |
|
36 |
||
37 |
-- hog with worst time (per round) |
|
38 |
local worsthog = nil |
|
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 |
11201
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:
11180
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 | 43 |
-- best time |
44 |
local besttime = maxtime + 1 |
|
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 | 49 |
-- worst time (per round) |
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 | 52 |
|
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' |
12079
8f222872d432
Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents:
12077
diff
changeset
|
61 |
-- Disable Sudden Death |
8f222872d432
Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents:
12077
diff
changeset
|
62 |
WaterRise = 0 |
8f222872d432
Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents:
12077
diff
changeset
|
63 |
HealthDecrease = 0 |
4188 | 64 |
end |
65 |
||
66 |
function onGameStart() |
|
12699
608db0fb90f0
Explain TropyRace's knockout rule in the mission panel
Wuzzy <almikes@aol.com>
parents:
12622
diff
changeset
|
67 |
ShowMission(loc("TrophyRace"), loc("Race"), |
608db0fb90f0
Explain TropyRace's knockout rule in the mission panel
Wuzzy <almikes@aol.com>
parents:
12622
diff
changeset
|
68 |
loc("Use your rope to get from start to finish as fast as you can!") .. "|" .. |
608db0fb90f0
Explain TropyRace's knockout rule in the mission panel
Wuzzy <almikes@aol.com>
parents:
12622
diff
changeset
|
69 |
loc("In each round, the worst hedgehog of the round is eliminated.") .. "|" .. |
608db0fb90f0
Explain TropyRace's knockout rule in the mission panel
Wuzzy <almikes@aol.com>
parents:
12622
diff
changeset
|
70 |
loc("The last surviving clan wins."), |
608db0fb90f0
Explain TropyRace's knockout rule in the mission panel
Wuzzy <almikes@aol.com>
parents:
12622
diff
changeset
|
71 |
-amRope, 0) |
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
72 |
started = true |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
73 |
p=1820 |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
74 |
for i = 0, numhhs - 1 do |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
75 |
p = p + 50 |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
76 |
SetGearPosition(hhs[i], p, 0) |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
77 |
end |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
78 |
|
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
79 |
for i=0, ClansCount-1 do |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
80 |
clantimes[i] = 0 |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
81 |
end |
4188 | 82 |
end |
83 |
||
84 |
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
|
85 |
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
|
86 |
SetAmmo(amSkip, 9, 1, 0) |
4188 | 87 |
end |
88 |
||
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
|
89 |
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
|
90 |
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
|
91 |
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
|
92 |
x, y = GetGearPosition(CurrentHedgehog) |
11180 | 93 |
AddGear(x, y-2, gtGrenade, 0, 0, 0, 2) |
94 |
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
|
95 |
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
|
96 |
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
|
97 |
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
|
98 |
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
|
99 |
|
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 |
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
|
101 |
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
|
102 |
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
|
103 |
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
|
104 |
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
|
105 |
|
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 |
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
|
107 |
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
|
108 |
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
|
109 |
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
|
110 |
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
|
111 |
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
|
112 |
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
|
113 |
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
|
114 |
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
|
115 |
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
|
116 |
SetGearPosition(CurrentHedgehog, start_area[1] + start_area[3] / 2, start_area[2] + start_area[4] / 2) |
10289 | 117 |
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
|
118 |
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
|
119 |
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
|
120 |
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
|
121 |
|
9659
e9c00dd31b07
drop onGameTick20 - it has some savings on cpu, but racers demand millisecond precision not 20 millisecond, apparently
nemo
parents:
9658
diff
changeset
|
122 |
function onGameTick() |
9658 | 123 |
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
|
124 |
startTime = GameTime |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
125 |
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
|
126 |
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
|
127 |
killHog() |
13008
99ff8f4810f4
TrophyRace: Show current racing time at top
Wuzzy <Wuzzy2@mail.ru>
parents:
12699
diff
changeset
|
128 |
AddCaption(loc("Time's up!"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage2) |
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
129 |
elseif CurrentHedgehog ~= nil then |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
130 |
x, y = GetGearPosition(CurrentHedgehog) |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
131 |
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
|
132 |
reached = true |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
133 |
local ttime = GameTime-startTime |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
134 |
--give it a sound;) |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
135 |
if ttime < besttime then |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
136 |
PlaySound (sndHomerun) |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
137 |
else |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
138 |
PlaySound (sndHellish) |
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 |
for i = 0, numhhs - 1 do |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
141 |
if hhs[i] == CurrentHedgehog then |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
142 |
times[numhhs] = ttime |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
143 |
end |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
144 |
end |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
145 |
|
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
146 |
local hscore = "| |" |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
147 |
local clan = GetHogClan(CurrentHedgehog) |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
148 |
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
|
149 |
clantimes[clan] = ttime |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
150 |
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
|
151 |
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
|
152 |
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
|
153 |
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
|
154 |
end |
13009
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13008
diff
changeset
|
155 |
local fastestStr |
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
156 |
if ttime < besttime then |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
157 |
besttime = ttime |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
158 |
besthog = CurrentHedgehog |
11201
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:
11180
diff
changeset
|
159 |
besthogname = GetHogName(besthog) |
13009
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13008
diff
changeset
|
160 |
fastestStr = loc("NEW fastest lap: %.3fs by %s") |
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
161 |
else |
13009
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13008
diff
changeset
|
162 |
fastestStr = loc("Fastest lap: %.3fs by %s") |
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
163 |
end |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
164 |
if ttime > worsttime then |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
165 |
worsttime = ttime |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
166 |
worsthog = CurrentHedgehog |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
167 |
end |
13009
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13008
diff
changeset
|
168 |
hscore = hscore .. string.format(fastestStr, (besttime / 1000), besthogname) |
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
169 |
|
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
170 |
if clan == ClansCount -1 then |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
171 |
-- 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
|
172 |
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
|
173 |
SetHealth(worsthog, 0) |
13009
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13008
diff
changeset
|
174 |
-- Drop a bazooka to make inactive slowest hog active. |
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
|
175 |
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
|
176 |
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
|
177 |
end |
12622
07fdda8c13a2
TrophyRace: Fix game never eliminating any hogs after a hog skipped or ran out of time
Wuzzy <almikes@aol.com>
parents:
12388
diff
changeset
|
178 |
worsttime = 0 |
07fdda8c13a2
TrophyRace: Fix game never eliminating any hogs after a hog skipped or ran out of time
Wuzzy <almikes@aol.com>
parents:
12388
diff
changeset
|
179 |
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
|
180 |
end |
13009
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13008
diff
changeset
|
181 |
|
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13008
diff
changeset
|
182 |
-- print list of best team times |
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13008
diff
changeset
|
183 |
hscore = hscore .. "| |" .. loc("Best laps per team: ") .. "|" |
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13008
diff
changeset
|
184 |
for teamName, teamTime in pairs(bestTimes) do |
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13008
diff
changeset
|
185 |
if teamTime ~= 0 and teamTime ~= nil then |
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13008
diff
changeset
|
186 |
-- <Team name>: <best team time in seconds> |
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13008
diff
changeset
|
187 |
hscore = hscore .. "|" .. string.format(loc("%s: %.3fs"), teamName, (teamTime / 1000)) |
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
188 |
end |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
189 |
end |
13009
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13008
diff
changeset
|
190 |
|
13008
99ff8f4810f4
TrophyRace: Show current racing time at top
Wuzzy <Wuzzy2@mail.ru>
parents:
12699
diff
changeset
|
191 |
local strtime = string.format(loc("Time: %.3fs"), (ttime/1000)) |
13009
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13008
diff
changeset
|
192 |
ShowMission(loc("TrophyRace"), loc("Status update"), strtime .. hscore, 0, 0) |
13008
99ff8f4810f4
TrophyRace: Show current racing time at top
Wuzzy <Wuzzy2@mail.ru>
parents:
12699
diff
changeset
|
193 |
AddCaption(strtime, GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage2) |
13009
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13008
diff
changeset
|
194 |
AddCaption(loc("Track completed!"), 0xFFFFFFFF, capgrpGameState) |
12287
faf1b93422ba
Use new EndTurn in a couple of scripts, esp. to fix timeout taunts in Racer
Wuzzy <almikes@aol.com>
parents:
12079
diff
changeset
|
195 |
EndTurn(true) |
13008
99ff8f4810f4
TrophyRace: Show current racing time at top
Wuzzy <Wuzzy2@mail.ru>
parents:
12699
diff
changeset
|
196 |
else |
99ff8f4810f4
TrophyRace: Show current racing time at top
Wuzzy <Wuzzy2@mail.ru>
parents:
12699
diff
changeset
|
197 |
if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) and CurrentHedgehog ~= nil and GetHealth(CurrentHedgehog) > 0 and (not reached) and GameTime%100 == 0 then |
99ff8f4810f4
TrophyRace: Show current racing time at top
Wuzzy <Wuzzy2@mail.ru>
parents:
12699
diff
changeset
|
198 |
local ttime = GameTime-startTime |
99ff8f4810f4
TrophyRace: Show current racing time at top
Wuzzy <Wuzzy2@mail.ru>
parents:
12699
diff
changeset
|
199 |
AddCaption(string.format(loc("Time: %.1fs"), (ttime/1000)), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage2) |
99ff8f4810f4
TrophyRace: Show current racing time at top
Wuzzy <Wuzzy2@mail.ru>
parents:
12699
diff
changeset
|
200 |
end |
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
201 |
end |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
202 |
end |
4188 | 203 |
end |
204 |
||
205 |
function onGearAdd(gear) |
|
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
206 |
if GetGearType(gear) == gtHedgehog then |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
207 |
hhs[numhhs] = gear |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
208 |
times[numhhs] = 0 |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
209 |
numhhs = numhhs + 1 |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
210 |
end |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
211 |
-- elseif GetGearType(gear) == gtRope then -- rope is shot |
4188 | 212 |
end |
213 |
||
7771 | 214 |
--function onGearDelete(gear) |
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
215 |
-- 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
|
216 |
-- --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
|
217 |
-- lasthog = CurrentHedgehog |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
218 |
-- |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
219 |
-- end |
7771 | 220 |
--end |
9397 | 221 |
|
222 |
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
|
223 |
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
|
224 |
DeclareAchievement("rope race", team, "TrophyRace", time) |
9397 | 225 |
end |
226 |
end |