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