4188
|
1 |
-- Hedgewars - Roperace for 2+ Players
|
|
2 |
|
|
3 |
local caption = {
|
|
4 |
["en"] = "TrophyRace",
|
|
5 |
["sv"] = "TrophyRace",
|
|
6 |
["pt_PT"] = "TrophyRace",
|
|
7 |
["pl"] = "TrophyRace",
|
|
8 |
["es"] = "TrophyRace",
|
4350
|
9 |
["pt_BR"] = "TrophyRace",
|
|
10 |
["sk"] = "Preteky o trofej"
|
4188
|
11 |
}
|
|
12 |
|
|
13 |
local goal = {
|
|
14 |
["en"] = "Use your rope to get from start to finish as fast as you can!",
|
|
15 |
["sv"] = "Använd ditt rep för att ta dig från start till mål så fort som möjligt!",
|
|
16 |
["pt_PT"] = "Utilizando a corda, percorre o percurso do inicio ao fim o mais rápido que conseguires!",
|
|
17 |
["pl"] = "Użyj liny by jak najszybciej dotrzec od startu do mety",
|
|
18 |
["es"] = "¡Usa tu cuerda para llegar a la salida lo más rápido que puedas!",
|
4350
|
19 |
["pt_BR"] = "Use sua corda para ir do início ao fim o mais rápido que você puder!",
|
|
20 |
["sk"] = "Použite lano na presun zo štartovnej pozície do cieľa tak rýchlo, ako to len viete!"
|
4188
|
21 |
}
|
|
22 |
|
|
23 |
local done = {
|
|
24 |
["en"] = "You've reached the goal!| |Time: ",
|
|
25 |
["sv"] = "Du har nått målet!| |Tid: ",
|
|
26 |
["pt_PT"] = "Chegaste ao fim!| |Tempo: ",
|
|
27 |
["pl"] = "Dotarłeś do celu!| |Czas: ",
|
|
28 |
["es"] = "¡Has llegado a la meta!| |Tiempo: ",
|
4350
|
29 |
["pt_BR"] = "Você alcançou o objetivo!| |Tempo: ",
|
|
30 |
["sk"] = "Dosiahli ste cieľ!| |Čas: "
|
4188
|
31 |
}
|
|
32 |
|
|
33 |
local eliminated = {
|
|
34 |
["en"] = "Eliminating worst hedgehog this round...| |%s is OUT!",
|
|
35 |
["sv"] = "Eliminerar sämsta igelkott den här rundan...| |%s är UTE!",
|
|
36 |
["pt_PT"] = "A eliminar o pior ouriço da ronda...| |% está FORA!",
|
|
37 |
["pl"] = "Eliminujemy najgorszego jeża tej rundy...| |%s ODPADŁ!",
|
|
38 |
["es"] = "Eliminando al peor erizo de esta ronda...| |¡%s está FUERA!",
|
4350
|
39 |
["pt_BR"] = "Eliminando o ouriço mais lento...| |%s vai para o chuveiro!",
|
|
40 |
["sk"] = "Eliminujem najhoršieho ježka tohto kola...| |%s je mimo hru!"
|
4188
|
41 |
}
|
|
42 |
|
|
43 |
local newbesttime = {
|
|
44 |
["en"] = "NEW fastest lap: ",
|
|
45 |
["sv"] = "NYTT snabbast varv: ",
|
|
46 |
["pt_PT"] = "NOVA volta recorde: ",
|
|
47 |
["pl"] = "NOWE najszybsze okrążenie: ",
|
|
48 |
["es"] = "NUEVA vuelta rápida: ",
|
4350
|
49 |
["pt_BR"] = "NOVA volta mais rápida: ",
|
|
50 |
["sk"] = "NOVÉ najrýchlejšie kolo: "
|
4188
|
51 |
}
|
|
52 |
|
|
53 |
local oldbesttime = {
|
|
54 |
["en"] = "Fastest lap: ",
|
|
55 |
["sv"] = "Snabbast varv: ",
|
|
56 |
["pt_PT"] = "Volta mais rápida: ",
|
|
57 |
["pl"] = "Najszybsze okrążenie: ",
|
|
58 |
["es"] = "Vuelta rápida: ",
|
4350
|
59 |
["pt_BR"] = "Volta mais rápida: ",
|
|
60 |
["sk"] = "Najrýchlejšie kolo: "
|
4188
|
61 |
}
|
|
62 |
|
|
63 |
local bestclantimes = {
|
|
64 |
["en"] = "Best laps per team: ",
|
|
65 |
["sv"] = "Bästa varv per lag: ",
|
|
66 |
["pt_PT"] = "Melhores voltas por equipa: ",
|
|
67 |
["pl"] = "Najszybsze okrążenie drużyny: ",
|
|
68 |
["es"] = "Mejores tiempos por equipo: ",
|
4350
|
69 |
["pt_BR"] = "Melhor volta por equipe: ",
|
|
70 |
["sk"] = "Najrýchlejšie kolá podľa tímov: "
|
4188
|
71 |
}
|
|
72 |
|
|
73 |
local clantime = {
|
|
74 |
["en"] = "Team %d: ",
|
|
75 |
["sv"] = "Lag %d: ",
|
|
76 |
["pt_PT"] = "Equipa %d: ",
|
|
77 |
["pl"] = "Drużyna %d: ",
|
|
78 |
["es"] = "Equipo %d",
|
4350
|
79 |
["pt_BR"] = "Equipe %d: ",
|
|
80 |
["sk"] = "Tím %d: "
|
4188
|
81 |
}
|
|
82 |
|
|
83 |
local function loc(text)
|
|
84 |
if text == nil then return "**missing**"
|
|
85 |
elseif text[L] == nil then return text["en"]
|
|
86 |
else return text[L]
|
|
87 |
end
|
|
88 |
end
|
|
89 |
|
|
90 |
---------------------------------------------------------------
|
|
91 |
|
|
92 |
-- store number of hedgehogs
|
|
93 |
local numhhs = 0
|
|
94 |
|
|
95 |
-- store hedgehog gears
|
|
96 |
local hhs = {}
|
|
97 |
|
|
98 |
-- store best time per team
|
|
99 |
local clantimes = {}
|
|
100 |
|
|
101 |
-- store best times
|
|
102 |
local times = {}
|
|
103 |
|
|
104 |
-- in milisseconds
|
|
105 |
local maxtime = 99000
|
|
106 |
|
|
107 |
-- define start area (left, top, width, height)
|
|
108 |
local start_area = {1606, 498, 356, 80}
|
|
109 |
|
|
110 |
-- define goal area (left, top, width, height)
|
|
111 |
local goal_area = {2030, 300, 56, 280}
|
|
112 |
|
|
113 |
-- last active hog
|
|
114 |
local lasthog = nil
|
|
115 |
|
|
116 |
-- active hog reached the goal?
|
|
117 |
local reached = false
|
|
118 |
|
|
119 |
-- hog with best time
|
|
120 |
local besthog = nil
|
|
121 |
|
|
122 |
-- hog with worst time (per round)
|
|
123 |
local worsthog = nil
|
|
124 |
|
|
125 |
-- best time
|
|
126 |
local besttime = maxtime + 1
|
|
127 |
|
|
128 |
-- worst time (per round)
|
|
129 |
local worsttime = 0
|
|
130 |
|
|
131 |
function onGameInit()
|
|
132 |
GameFlags = gfSolidLand + gfInvulnerable
|
|
133 |
TurnTime = maxtime
|
|
134 |
CaseFreq = 0
|
|
135 |
MinesNum = 0
|
|
136 |
Explosives = 0
|
|
137 |
Delay = 500
|
|
138 |
SuddenDeathTurns = 99999 -- "disable" sudden death
|
|
139 |
Theme = 'Olympics'
|
|
140 |
end
|
|
141 |
|
|
142 |
function onGameStart()
|
|
143 |
ShowMission(loc(caption), "", loc(goal), -amRope, 0)
|
|
144 |
started = true
|
|
145 |
p=1820
|
|
146 |
for i = 0, numhhs - 1 do
|
|
147 |
p = p + 50
|
|
148 |
SetGearPosition(hhs[i], p, 0)
|
|
149 |
end
|
|
150 |
|
|
151 |
for i=0, ClansCount-1 do
|
|
152 |
clantimes[i] = 0
|
|
153 |
end
|
|
154 |
end
|
|
155 |
|
|
156 |
function onAmmoStoreInit()
|
|
157 |
SetAmmo(amRope, 9, 2, 0)
|
|
158 |
end
|
|
159 |
|
|
160 |
function onGameTick()
|
|
161 |
if TurnTimeLeft == 1 and CurrentHedgehog ~= nil then
|
|
162 |
SetHealth(CurrentHedgehog, 0)
|
|
163 |
x, y = GetGearPosition(CurrentHedgehog)
|
|
164 |
AddGear(x, y, gtAmmo_Grenade, 0, 0, 0, 0)
|
|
165 |
worsttime = 99999
|
|
166 |
worsthog = nil
|
|
167 |
elseif TurnTimeLeft == maxtime - 1 and CurrentHedgehog ~= nil then
|
|
168 |
if lasthog ~= nil then
|
|
169 |
SetGearPosition(lasthog, p , 0)
|
|
170 |
end
|
|
171 |
reached = false
|
|
172 |
SetGearPosition(CurrentHedgehog, start_area[1] + start_area[3] / 2, start_area[2] + start_area[4] / 2)
|
|
173 |
elseif CurrentHedgehog ~= nil then
|
|
174 |
x, y = GetGearPosition(CurrentHedgehog)
|
|
175 |
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
|
|
176 |
reached = true
|
|
177 |
local ttime = maxtime - TurnTimeLeft
|
|
178 |
--give it a sound;)
|
|
179 |
if ttime < besttime then
|
|
180 |
PlaySound (sndHomerun)
|
|
181 |
else
|
|
182 |
PlaySound (sndHellish)
|
|
183 |
end
|
|
184 |
for i = 0, numhhs - 1 do
|
|
185 |
if hhs[i] == CurrentHedgehog then
|
|
186 |
times[numhhs] = ttime
|
|
187 |
end
|
|
188 |
end
|
|
189 |
|
|
190 |
local hscore = "| |"
|
|
191 |
local clan = GetHogClan(CurrentHedgehog)
|
|
192 |
if ttime < clantimes[clan] or clantimes[clan] == 0 then
|
|
193 |
clantimes[clan] = ttime
|
|
194 |
end
|
|
195 |
|
|
196 |
if ttime < besttime then
|
|
197 |
besttime = ttime
|
|
198 |
besthog = CurrentHedgehog
|
|
199 |
hscore = hscore .. loc(newbesttime)
|
|
200 |
else
|
|
201 |
hscore = hscore .. loc(oldbesttime)
|
|
202 |
end
|
|
203 |
if ttime > worsttime then
|
|
204 |
worsttime = ttime
|
|
205 |
worsthog = CurrentHedgehog
|
|
206 |
end
|
|
207 |
hscore = hscore .. GetHogName(besthog) .. " - " .. (besttime / 1000) .. " s | |" .. loc(bestclantimes)
|
|
208 |
|
|
209 |
if clan == ClansCount -1 then
|
|
210 |
-- Time for elimination - worst hog is out and the worst hog vars are reset.
|
|
211 |
SetHealth(worsthog, 0)
|
|
212 |
--Place a grenade to make inactive slowest hog active
|
|
213 |
x, y = GetGearPosition(worsthog)
|
|
214 |
AddGear(x, y, gtShell, 0, 0, 0, 0)
|
|
215 |
worsttime = 0
|
|
216 |
worsthog = nil
|
|
217 |
end
|
|
218 |
|
|
219 |
for i=0, ClansCount -1 do
|
|
220 |
local tt = "" .. (clantimes[i] / 1000) .. " s"
|
|
221 |
if clantimes[i] == 0 then
|
|
222 |
tt = "--"
|
|
223 |
end
|
|
224 |
hscore = hscore .. "|" .. string.format(loc(clantime), i+1) .. tt
|
|
225 |
end
|
|
226 |
|
|
227 |
ShowMission(loc(caption), "", loc(done) .. (ttime / 1000) .. " s" .. hscore, 0, 0)
|
|
228 |
TurnTimeLeft = 0
|
|
229 |
end
|
|
230 |
end
|
|
231 |
end
|
|
232 |
|
|
233 |
function onGearAdd(gear)
|
|
234 |
if GetGearType(gear) == gtHedgehog then
|
|
235 |
hhs[numhhs] = gear
|
|
236 |
times[numhhs] = 0
|
|
237 |
numhhs = numhhs + 1
|
|
238 |
elseif GetGearType(gear) == gtRope then -- rope is shot
|
|
239 |
|
|
240 |
end
|
|
241 |
end
|
|
242 |
|
|
243 |
function onGearDelete(gear)
|
|
244 |
if GetGearType(gear) == gtRope then -- rope deletion - hog didn't manage to rerope
|
|
245 |
--TurnTimeLeft = 0 -- end turn or not? hm...
|
|
246 |
lasthog = CurrentHedgehog
|
|
247 |
|
|
248 |
end
|
|
249 |
end
|