author | Wuzzy <Wuzzy2@mail.ru> |
Thu, 15 Feb 2018 21:39:10 +0100 | |
changeset 13017 | d82fec121f31 |
parent 13016 | c819675d4f4f |
child 13648 | 690cc84e9fd6 |
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 |
|
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 | 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 |
||
13017
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
16 |
-- count how many hogs each clan has |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
17 |
local hogsByClan = {} |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
18 |
|
4188 | 19 |
-- store best time per team |
20 |
local clantimes = {} |
|
21 |
||
22 |
-- store best times |
|
23 |
local times = {} |
|
24 |
||
25 |
-- in milisseconds |
|
26 |
local maxtime = 99000 |
|
27 |
||
28 |
-- define start area (left, top, width, height) |
|
29 |
local start_area = {1606, 498, 356, 80} |
|
30 |
||
31 |
-- define goal area (left, top, width, height) |
|
32 |
local goal_area = {2030, 300, 56, 280} |
|
33 |
||
34 |
-- last active hog |
|
35 |
local lasthog = nil |
|
36 |
||
37 |
-- active hog reached the goal? |
|
38 |
local reached = false |
|
39 |
||
40 |
-- hog with worst time (per round) |
|
41 |
local worsthog = nil |
|
42 |
||
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
|
43 |
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
|
44 |
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
|
45 |
|
4188 | 46 |
-- best time |
47 |
local besttime = maxtime + 1 |
|
48 |
||
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
|
49 |
-- 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
|
50 |
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
|
51 |
|
4188 | 52 |
-- worst time (per round) |
53 |
local worsttime = 0 |
|
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
54 |
local startTime = 0; |
4188 | 55 |
|
56 |
function onGameInit() |
|
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
57 |
GameFlags = gfSolidLand + gfInvulnerable |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
58 |
TurnTime = maxtime |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
59 |
CaseFreq = 0 |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
60 |
MinesNum = 0 |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
61 |
Explosives = 0 |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
62 |
Delay = 500 |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
63 |
Theme = 'Olympics' |
12084
8f222872d432
Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents:
12082
diff
changeset
|
64 |
-- Disable Sudden Death |
8f222872d432
Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents:
12082
diff
changeset
|
65 |
WaterRise = 0 |
8f222872d432
Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents:
12082
diff
changeset
|
66 |
HealthDecrease = 0 |
4188 | 67 |
end |
68 |
||
69 |
function onGameStart() |
|
12704
608db0fb90f0
Explain TropyRace's knockout rule in the mission panel
Wuzzy <almikes@aol.com>
parents:
12627
diff
changeset
|
70 |
ShowMission(loc("TrophyRace"), loc("Race"), |
608db0fb90f0
Explain TropyRace's knockout rule in the mission panel
Wuzzy <almikes@aol.com>
parents:
12627
diff
changeset
|
71 |
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:
12627
diff
changeset
|
72 |
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:
12627
diff
changeset
|
73 |
loc("The last surviving clan wins."), |
608db0fb90f0
Explain TropyRace's knockout rule in the mission panel
Wuzzy <almikes@aol.com>
parents:
12627
diff
changeset
|
74 |
-amRope, 0) |
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
75 |
started = true |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
76 |
p=1820 |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
77 |
for i = 0, numhhs - 1 do |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
78 |
p = p + 50 |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
79 |
SetGearPosition(hhs[i], p, 0) |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
80 |
end |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
81 |
|
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
82 |
for i=0, ClansCount-1 do |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
83 |
clantimes[i] = 0 |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
84 |
end |
13017
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
85 |
SendAchievementsStatsOff() |
4188 | 86 |
end |
87 |
||
88 |
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
|
89 |
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
|
90 |
SetAmmo(amSkip, 9, 1, 0) |
4188 | 91 |
end |
92 |
||
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
|
93 |
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
|
94 |
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
|
95 |
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
|
96 |
x, y = GetGearPosition(CurrentHedgehog) |
11184 | 97 |
AddGear(x, y-2, gtGrenade, 0, 0, 0, 2) |
98 |
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
|
99 |
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
|
100 |
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
|
101 |
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
|
102 |
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
|
103 |
|
13016
c819675d4f4f
TrophyRace: Hide mission panel when player shoots rope
Wuzzy <Wuzzy2@mail.ru>
parents:
13015
diff
changeset
|
104 |
function onHogAttack(ammoType) |
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
|
105 |
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
|
106 |
killHog() |
13016
c819675d4f4f
TrophyRace: Hide mission panel when player shoots rope
Wuzzy <Wuzzy2@mail.ru>
parents:
13015
diff
changeset
|
107 |
elseif ammoType == amRope then |
c819675d4f4f
TrophyRace: Hide mission panel when player shoots rope
Wuzzy <Wuzzy2@mail.ru>
parents:
13015
diff
changeset
|
108 |
HideMission() |
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
|
109 |
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
|
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 |
|
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 |
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
|
113 |
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
|
114 |
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
|
115 |
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
|
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 |
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
|
118 |
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
|
119 |
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
|
120 |
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
|
121 |
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
|
122 |
SetGearPosition(CurrentHedgehog, start_area[1] + start_area[3] / 2, start_area[2] + start_area[4] / 2) |
10289 | 123 |
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
|
124 |
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
|
125 |
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
|
126 |
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
|
127 |
|
9659
e9c00dd31b07
drop onGameTick20 - it has some savings on cpu, but racers demand millisecond precision not 20 millisecond, apparently
nemo
parents:
9658
diff
changeset
|
128 |
function onGameTick() |
9658 | 129 |
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
|
130 |
startTime = GameTime |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
131 |
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
|
132 |
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
|
133 |
killHog() |
13013
99ff8f4810f4
TrophyRace: Show current racing time at top
Wuzzy <Wuzzy2@mail.ru>
parents:
12704
diff
changeset
|
134 |
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
|
135 |
elseif CurrentHedgehog ~= nil then |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
136 |
x, y = GetGearPosition(CurrentHedgehog) |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
137 |
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
|
138 |
reached = true |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
139 |
local ttime = GameTime-startTime |
13016
c819675d4f4f
TrophyRace: Hide mission panel when player shoots rope
Wuzzy <Wuzzy2@mail.ru>
parents:
13015
diff
changeset
|
140 |
-- give it a sound ;) |
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
141 |
if ttime < besttime then |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
142 |
PlaySound (sndHomerun) |
13016
c819675d4f4f
TrophyRace: Hide mission panel when player shoots rope
Wuzzy <Wuzzy2@mail.ru>
parents:
13015
diff
changeset
|
143 |
elseif ttime > worsttime then |
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
144 |
PlaySound (sndHellish) |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
145 |
end |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
146 |
for i = 0, numhhs - 1 do |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
147 |
if hhs[i] == CurrentHedgehog then |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
148 |
times[numhhs] = ttime |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
149 |
end |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
150 |
end |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
151 |
|
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
152 |
local hscore = "| |" |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
153 |
local clan = GetHogClan(CurrentHedgehog) |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
154 |
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
|
155 |
clantimes[clan] = ttime |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
156 |
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
|
157 |
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
|
158 |
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
|
159 |
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
|
160 |
end |
13014
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13013
diff
changeset
|
161 |
local fastestStr |
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
162 |
if ttime < besttime then |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
163 |
besttime = ttime |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
164 |
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
|
165 |
besthogname = GetHogName(besthog) |
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
166 |
else |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
167 |
end |
13015
d92c364f004d
Simplify the status update panel in Trophy Race a lot
Wuzzy <Wuzzy2@mail.ru>
parents:
13014
diff
changeset
|
168 |
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
|
169 |
if ttime > worsttime then |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
170 |
worsttime = ttime |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
171 |
worsthog = CurrentHedgehog |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
172 |
end |
13015
d92c364f004d
Simplify the status update panel in Trophy Race a lot
Wuzzy <Wuzzy2@mail.ru>
parents:
13014
diff
changeset
|
173 |
|
d92c364f004d
Simplify the status update panel in Trophy Race a lot
Wuzzy <Wuzzy2@mail.ru>
parents:
13014
diff
changeset
|
174 |
if worsthog then |
d92c364f004d
Simplify the status update panel in Trophy Race a lot
Wuzzy <Wuzzy2@mail.ru>
parents:
13014
diff
changeset
|
175 |
hscore = hscore .. string.format(loc("Round's slowest lap: %.3fs by %s"), (worsttime / 1000), GetHogName(worsthog)) |
d92c364f004d
Simplify the status update panel in Trophy Race a lot
Wuzzy <Wuzzy2@mail.ru>
parents:
13014
diff
changeset
|
176 |
end |
d92c364f004d
Simplify the status update panel in Trophy Race a lot
Wuzzy <Wuzzy2@mail.ru>
parents:
13014
diff
changeset
|
177 |
|
d92c364f004d
Simplify the status update panel in Trophy Race a lot
Wuzzy <Wuzzy2@mail.ru>
parents:
13014
diff
changeset
|
178 |
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
|
179 |
|
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
180 |
if clan == ClansCount -1 then |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
181 |
-- 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
|
182 |
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
|
183 |
SetHealth(worsthog, 0) |
13014
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13013
diff
changeset
|
184 |
-- 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
|
185 |
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
|
186 |
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
|
187 |
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
|
188 |
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
|
189 |
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
|
190 |
end |
13014
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13013
diff
changeset
|
191 |
|
13015
d92c364f004d
Simplify the status update panel in Trophy Race a lot
Wuzzy <Wuzzy2@mail.ru>
parents:
13014
diff
changeset
|
192 |
ShowMission(loc("TrophyRace"), loc("Status update"), |
d92c364f004d
Simplify the status update panel in Trophy Race a lot
Wuzzy <Wuzzy2@mail.ru>
parents:
13014
diff
changeset
|
193 |
string.format(loc("Time: %.3fs by %s"), (ttime/1000), GetHogName(CurrentHedgehog)) |
d92c364f004d
Simplify the status update panel in Trophy Race a lot
Wuzzy <Wuzzy2@mail.ru>
parents:
13014
diff
changeset
|
194 |
.. hscore, |
d92c364f004d
Simplify the status update panel in Trophy Race a lot
Wuzzy <Wuzzy2@mail.ru>
parents:
13014
diff
changeset
|
195 |
0, 0) |
d92c364f004d
Simplify the status update panel in Trophy Race a lot
Wuzzy <Wuzzy2@mail.ru>
parents:
13014
diff
changeset
|
196 |
AddCaption(string.format(loc("Time: %.3fs"), (ttime/1000)), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage2) |
13014
67cc3cac4c8e
TrophyRace: Show fastest team times (instead of clan times)
Wuzzy <Wuzzy2@mail.ru>
parents:
13013
diff
changeset
|
197 |
AddCaption(loc("Track completed!"), 0xFFFFFFFF, capgrpGameState) |
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
|
198 |
EndTurn(true) |
13013
99ff8f4810f4
TrophyRace: Show current racing time at top
Wuzzy <Wuzzy2@mail.ru>
parents:
12704
diff
changeset
|
199 |
else |
99ff8f4810f4
TrophyRace: Show current racing time at top
Wuzzy <Wuzzy2@mail.ru>
parents:
12704
diff
changeset
|
200 |
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:
12704
diff
changeset
|
201 |
local ttime = GameTime-startTime |
99ff8f4810f4
TrophyRace: Show current racing time at top
Wuzzy <Wuzzy2@mail.ru>
parents:
12704
diff
changeset
|
202 |
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:
12704
diff
changeset
|
203 |
end |
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
204 |
end |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
205 |
end |
4188 | 206 |
end |
207 |
||
13017
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
208 |
function WriteStats() |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
209 |
if besthog then |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
210 |
SendStat(siCustomAchievement, string.format(loc("The fastest hedgehog was %s from %s with a time of %.3fs."), besthogname, GetHogTeamName(besthog), besttime/1000)) |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
211 |
else |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
212 |
SendStat(siCustomAchievement, loc("Nobody managed to finish the race. What a shame!")) |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
213 |
end |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
214 |
|
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
215 |
-- Write most skips |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
216 |
local mostSkips = 2 -- a minimum skip threshold is required |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
217 |
local mostSkipsTeam = nil |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
218 |
for i=0, TeamsCount-1 do |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
219 |
local teamName = GetTeamName(i) |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
220 |
local stats = GetTeamStats(teamName) |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
221 |
if stats.TurnSkips > mostSkips then |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
222 |
mostSkips = stats.TurnSkips |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
223 |
mostSkipsTeam = teamName |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
224 |
end |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
225 |
end |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
226 |
if mostSkipsTeam then |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
227 |
SendStat(siMaxTurnSkips, tostring(mostSkips) .. " " .. mostSkipsTeam) |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
228 |
end |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
229 |
end |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
230 |
|
4188 | 231 |
function onGearAdd(gear) |
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
232 |
if GetGearType(gear) == gtHedgehog then |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
233 |
hhs[numhhs] = gear |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
234 |
times[numhhs] = 0 |
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
235 |
numhhs = numhhs + 1 |
13017
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
236 |
local clan = GetHogClan(gear) |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
237 |
if not hogsByClan[clan] then |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
238 |
hogsByClan[clan] = 0 |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
239 |
end |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
240 |
hogsByClan[clan] = hogsByClan[clan] + 1 |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
241 |
end |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
242 |
end |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
243 |
|
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
244 |
function areTwoOrMoreClansLeft() |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
245 |
local clans = 0 |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
246 |
for i=0, ClansCount-1 do |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
247 |
if hogsByClan[i] >= 1 then |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
248 |
clans = clans + 1 |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
249 |
end |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
250 |
if clans >= 2 then |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
251 |
return true |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
252 |
end |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
253 |
end |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
254 |
return false |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
255 |
end |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
256 |
|
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
257 |
function onGearDelete(gear) |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
258 |
if GetGearType(gear) == gtHedgehog then |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
259 |
local clan = GetHogClan(gear) |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
260 |
|
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
261 |
hogsByClan[clan] = hogsByClan[clan] - 1 |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
262 |
if not areTwoOrMoreClansLeft() then |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
263 |
WriteStats() |
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
264 |
end |
9657
2d8cae3c0855
use gameticks instead of turn timer. untested. also replaced tabs with spaces
nemo
parents:
9411
diff
changeset
|
265 |
end |
4188 | 266 |
end |
267 |
||
9397 | 268 |
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
|
269 |
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
|
270 |
DeclareAchievement("rope race", team, "TrophyRace", time) |
9397 | 271 |
end |
272 |
end |
|
13017
d82fec121f31
Implement very basic stats screen for TropyRace
Wuzzy <Wuzzy2@mail.ru>
parents:
13016
diff
changeset
|
273 |