author | mikade |
Thu, 01 Sep 2011 00:28:38 +0200 | |
changeset 5720 | a962d0823f49 |
parent 5457 | 48fe8e03a9cf |
child 5797 | d61cd92865c2 |
permissions | -rw-r--r-- |
5277 | 1 |
---------------------------------- |
5457 | 2 |
-- THE SPECIALISTS MODE 0.5 |
5277 | 3 |
-- by mikade |
4 |
---------------------------------- |
|
5 |
||
6 |
-- version history |
|
7 |
----------------- |
|
8 |
-- version 0.1 |
|
9 |
----------------- |
|
10 |
-- concept test |
|
11 |
||
12 |
---------------- |
|
13 |
-- version 0.2 |
|
14 |
---------------- |
|
15 |
-- added gfRandomOrder to gameflags |
|
16 |
-- removed some deprecated variables/methods |
|
17 |
-- fixed lack of portal reset |
|
18 |
||
5362
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
19 |
---------------- |
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
20 |
-- version 0.3 |
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
21 |
---------------- |
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
22 |
-- added switching on start |
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
23 |
-- removed switch from engineer weaponset |
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
24 |
|
5382 | 25 |
---------------- |
26 |
-- version 0.4 |
|
27 |
---------------- |
|
28 |
-- Attempted to: |
|
29 |
-- fix potential switch explit |
|
30 |
-- improve user feedback on start |
|
31 |
||
5457 | 32 |
---------------- |
33 |
-- version 0.5 |
|
34 |
---------------- |
|
35 |
-- provision for variable minetimer / demo mines set to 5000ms |
|
36 |
-- don't autoswitch if player only has 1 hog on his team |
|
37 |
||
5277 | 38 |
-------------------- |
39 |
--TO DO |
|
40 |
-------------------- |
|
41 |
||
5457 | 42 |
-- balance hog health, maybe |
43 |
-- add proper gameflag checking, maybe (so that we can throw in a .cfg and let the users break everything) |
|
44 |
-- set crate drops etc. (super crate for each class? or will this ruin the mode's simplicity?) |
|
5277 | 45 |
|
46 |
loadfile(GetDataPath() .. "Scripts/Locale.lua")() |
|
5457 | 47 |
loadfile(GetDataPath() .. "Scripts/Tracker.lua")() |
5277 | 48 |
|
5382 | 49 |
local numhhs = 0 |
50 |
local hhs = {} |
|
5277 | 51 |
|
5382 | 52 |
local currName |
5277 | 53 |
local lastName |
5362
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
54 |
local started = false |
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
55 |
local switchStage = 0 |
5277 | 56 |
|
5457 | 57 |
local hogCounter |
58 |
||
59 |
function CountHog(gear) |
|
60 |
hogCounter = hogCounter +1 |
|
61 |
end |
|
62 |
||
5277 | 63 |
function CreateTeam() |
64 |
||
5382 | 65 |
currTeam = "" |
66 |
lastTeam = "" |
|
67 |
z = 0 |
|
5277 | 68 |
|
5382 | 69 |
for i = 0, (numhhs-1) do |
5277 | 70 |
|
5382 | 71 |
currTeam = GetHogTeamName(hhs[i]) |
5277 | 72 |
|
5382 | 73 |
if currTeam == lastTeam then |
74 |
z = z + 1 |
|
75 |
else |
|
76 |
z = 1 |
|
77 |
end |
|
5277 | 78 |
|
5382 | 79 |
if z == 1 then |
5277 | 80 |
|
5382 | 81 |
SetHogName(hhs[i],"Soldier") |
82 |
SetHogHat(hhs[i], "Vega") |
|
83 |
SetHealth(hhs[i],200) |
|
5277 | 84 |
|
5382 | 85 |
elseif z == 2 then |
5277 | 86 |
|
5382 | 87 |
SetHogHat(hhs[i], "Glasses") |
88 |
SetHogName(hhs[i],"Engineer") |
|
5277 | 89 |
|
5382 | 90 |
elseif z == 3 then |
5277 | 91 |
|
5382 | 92 |
SetHogName(hhs[i],"Ninja") |
93 |
SetHogHat(hhs[i], "NinjaFull") |
|
94 |
SetHealth(hhs[i],80) |
|
5277 | 95 |
|
5382 | 96 |
elseif z == 4 then |
5277 | 97 |
|
5382 | 98 |
SetHogName(hhs[i],"Demo") |
99 |
SetHogHat(hhs[i], "Skull") |
|
100 |
SetHealth(hhs[i],200) |
|
5277 | 101 |
|
5382 | 102 |
elseif z == 5 then |
5277 | 103 |
|
5382 | 104 |
SetHogName(hhs[i],"Sniper") |
105 |
SetHogHat(hhs[i], "Sniper") |
|
106 |
SetHealth(hhs[i],120) |
|
5277 | 107 |
|
5382 | 108 |
elseif z == 6 then |
5277 | 109 |
|
5382 | 110 |
SetHogName(hhs[i],"Saint") |
111 |
SetHogHat(hhs[i], "angel") |
|
112 |
SetHealth(hhs[i],300) |
|
5277 | 113 |
|
5382 | 114 |
elseif z == 7 then |
115 |
||
116 |
SetHogName(hhs[i],"Pyro") |
|
117 |
SetHogHat(hhs[i], "Gasmask") |
|
118 |
SetHealth(hhs[i],150) |
|
119 |
||
120 |
elseif z == 8 then |
|
5277 | 121 |
|
5382 | 122 |
SetHogName(hhs[i],"Loon") |
123 |
SetHogHat(hhs[i], "clown") |
|
124 |
SetHealth(hhs[i],100) |
|
5277 | 125 |
|
5382 | 126 |
end |
5277 | 127 |
|
5382 | 128 |
lastTeam = GetHogTeamName(hhs[i]) |
5277 | 129 |
|
5382 | 130 |
end |
5277 | 131 |
|
132 |
end |
|
133 |
||
134 |
function ResetAllAmmo() |
|
135 |
||
5382 | 136 |
AddAmmo(CurrentHedgehog, amBazooka, 0) |
137 |
AddAmmo(CurrentHedgehog, amGrenade, 0) |
|
138 |
AddAmmo(CurrentHedgehog, amShotgun, 0) |
|
5277 | 139 |
|
5382 | 140 |
AddAmmo(CurrentHedgehog, amGirder, 0) |
141 |
AddAmmo(CurrentHedgehog, amBlowTorch, 0) |
|
142 |
AddAmmo(CurrentHedgehog, amPickHammer, 0) |
|
143 |
AddAmmo(CurrentHedgehog, amSwitch, 0) |
|
144 |
||
145 |
AddAmmo(CurrentHedgehog, amRope, 0) |
|
146 |
AddAmmo(CurrentHedgehog, amParachute, 0) |
|
147 |
AddAmmo(CurrentHedgehog, amFirePunch, 0) |
|
5277 | 148 |
|
5382 | 149 |
AddAmmo(CurrentHedgehog, amDynamite, 0) |
150 |
AddAmmo(CurrentHedgehog, amDrill, 0) |
|
151 |
AddAmmo(CurrentHedgehog, amMine, 0) |
|
5277 | 152 |
|
5382 | 153 |
AddAmmo(CurrentHedgehog, amSniperRifle, 0) |
154 |
AddAmmo(CurrentHedgehog, amDEagle, 0) |
|
155 |
AddAmmo(CurrentHedgehog, amPortalGun, 0) |
|
5277 | 156 |
|
5382 | 157 |
AddAmmo(CurrentHedgehog, amSeduction, 0) |
158 |
AddAmmo(CurrentHedgehog, amResurrector, 0) |
|
159 |
AddAmmo(CurrentHedgehog, amInvulnerable, 0) |
|
160 |
||
161 |
AddAmmo(CurrentHedgehog, amFlamethrower, 0) |
|
162 |
AddAmmo(CurrentHedgehog, amMolotov, 0) |
|
163 |
AddAmmo(CurrentHedgehog, amNapalm, 0) |
|
164 |
||
165 |
AddAmmo(CurrentHedgehog, amBaseballBat, 0) |
|
166 |
AddAmmo(CurrentHedgehog, amGasBomb, 0) |
|
167 |
AddAmmo(CurrentHedgehog, amKamikaze, 0) |
|
5277 | 168 |
|
169 |
end |
|
170 |
||
171 |
function AssignAmmo() |
|
172 |
||
5382 | 173 |
ResetAllAmmo() |
174 |
n = GetHogName(CurrentHedgehog) |
|
5277 | 175 |
|
5382 | 176 |
AddAmmo(CurrentHedgehog, amSkip,100) |
5277 | 177 |
|
5382 | 178 |
if n == "Soldier" then |
179 |
AddAmmo(CurrentHedgehog, amBazooka,1) |
|
180 |
AddAmmo(CurrentHedgehog, amGrenade,1) |
|
181 |
AddAmmo(CurrentHedgehog, amShotgun,1) |
|
182 |
elseif n == "Engineer" then |
|
183 |
AddAmmo(CurrentHedgehog, amGirder, 2) |
|
184 |
AddAmmo(CurrentHedgehog, amBlowTorch, 1) |
|
185 |
AddAmmo(CurrentHedgehog, amPickHammer, 1) |
|
186 |
elseif n == "Ninja" then |
|
187 |
AddAmmo(CurrentHedgehog, amRope, 100) |
|
188 |
AddAmmo(CurrentHedgehog, amParachute, 100) |
|
189 |
AddAmmo(CurrentHedgehog, amFirePunch, 1) |
|
190 |
elseif n == "Demo" then |
|
191 |
AddAmmo(CurrentHedgehog, amDynamite, 1) |
|
192 |
AddAmmo(CurrentHedgehog, amMine, 1) |
|
193 |
AddAmmo(CurrentHedgehog, amDrill, 1) |
|
194 |
elseif n == "Sniper" then |
|
195 |
AddAmmo(CurrentHedgehog, amSniperRifle, 1) |
|
196 |
AddAmmo(CurrentHedgehog, amDEagle, 1) |
|
197 |
AddAmmo(CurrentHedgehog, amPortalGun, 2) |
|
198 |
elseif n == "Saint" then |
|
199 |
AddAmmo(CurrentHedgehog, amSeduction, 100) |
|
200 |
AddAmmo(CurrentHedgehog, amResurrector, 1) |
|
201 |
AddAmmo(CurrentHedgehog, amInvulnerable, 1) |
|
202 |
elseif n == "Pyro" then |
|
203 |
AddAmmo(CurrentHedgehog, amFlamethrower, 1) |
|
204 |
AddAmmo(CurrentHedgehog, amMolotov, 1) |
|
205 |
AddAmmo(CurrentHedgehog, amNapalm, 1) |
|
206 |
elseif n == "Loon" then |
|
207 |
AddAmmo(CurrentHedgehog, amBaseballBat, 1) |
|
208 |
AddAmmo(CurrentHedgehog, amGasBomb, 1) |
|
209 |
AddAmmo(CurrentHedgehog, amKamikaze, 1) |
|
210 |
end |
|
5277 | 211 |
|
212 |
end |
|
213 |
||
214 |
function onGameInit() |
|
5382 | 215 |
GameFlags = gfRandomOrder + gfResetWeps + gfInfAttack + gfPlaceHog |
216 |
Delay = 10 |
|
5277 | 217 |
end |
218 |
||
219 |
function onGameStart() |
|
5382 | 220 |
|
221 |
CreateTeam() |
|
5277 | 222 |
|
5382 | 223 |
ShowMission ( |
224 |
loc("THE SPECIALISTS"), |
|
225 |
loc("a Hedgewars mini-game"), |
|
5277 | 226 |
|
5382 | 227 |
loc("Eliminate the enemy specialists.") .. "|" .. |
228 |
" " .. "|" .. |
|
5277 | 229 |
|
5382 | 230 |
loc("Game Modifiers: ") .. "|" .. |
231 |
loc("Per-Hog Ammo") .. "|" .. |
|
232 |
loc("Weapons Reset") .. "|" .. |
|
233 |
loc("Unlimited Attacks") .. "|" .. |
|
5277 | 234 |
|
5382 | 235 |
"", 4, 4000 |
236 |
) |
|
5277 | 237 |
|
5457 | 238 |
trackTeams() |
239 |
||
5277 | 240 |
end |
241 |
||
242 |
||
243 |
function onNewTurn() |
|
5382 | 244 |
currName = GetHogName(CurrentHedgehog) |
245 |
lastName = GetHogName(CurrentHedgehog) |
|
246 |
AssignAmmo() |
|
5457 | 247 |
started = true |
5382 | 248 |
switchStage = 0 |
5277 | 249 |
end |
250 |
||
251 |
function onGameTick() |
|
252 |
||
253 |
if (CurrentHedgehog ~= nil) then |
|
254 |
||
255 |
currName = GetHogName(CurrentHedgehog) |
|
256 |
||
5382 | 257 |
if (currName ~= lastName) and (switchStage > 100) then |
5277 | 258 |
AddCaption(loc("Switched to ") .. currName .. "!") |
259 |
AssignAmmo() |
|
260 |
end |
|
261 |
||
5362
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
262 |
if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) and (switchStage < 100) then |
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
263 |
|
5382 | 264 |
AddCaption(loc("Prepare yourself") .. ", " .. currName .. "!") |
265 |
||
5457 | 266 |
hogCounter = 0 |
267 |
runOnHogsInTeam(CountHog, GetHogTeamName(CurrentHedgehog) ) |
|
268 |
||
269 |
if hogCounter > 1 then |
|
270 |
||
271 |
switchStage = switchStage + 1 |
|
5362
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
272 |
|
5457 | 273 |
if switchStage == 1 then |
274 |
AddAmmo(CurrentHedgehog, amSwitch, 1) |
|
5382 | 275 |
|
5457 | 276 |
elseif switchStage == 2 then |
277 |
ParseCommand("setweap " .. string.char(amSwitch)) |
|
278 |
elseif switchStage == 3 then |
|
279 |
SetGearMessage(CurrentHedgehog,gmAttack) |
|
280 |
elseif switchStage == 4 then |
|
281 |
switchStage = 110 |
|
282 |
AddAmmo(CurrentHedgehog, amSwitch, 0) |
|
283 |
end |
|
284 |
||
285 |
else |
|
5362
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
286 |
switchStage = 110 |
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
287 |
end |
5457 | 288 |
|
289 |
||
5362
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
290 |
end |
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
291 |
|
5277 | 292 |
lastName = currName |
293 |
||
294 |
end |
|
295 |
||
296 |
end |
|
297 |
||
298 |
function onGearAdd(gear) |
|
5382 | 299 |
|
300 |
if GetGearType(gear) == gtHedgehog then |
|
301 |
hhs[numhhs] = gear |
|
302 |
numhhs = numhhs + 1 |
|
5457 | 303 |
elseif (GetGearType(gear) == gtMine) and (started == true) then |
304 |
SetTimer(gear,5000) |
|
305 |
end |
|
306 |
||
307 |
if (GetGearType(gear) == gtHedgehog) or (GetGearType(gear) == gtResurrector) then |
|
308 |
trackGear(gear) |
|
309 |
end |
|
310 |
||
5277 | 311 |
|
312 |
end |
|
313 |
||
314 |
function onGearDelete(gear) |
|
5457 | 315 |
if (GetGearType(gear) == gtHedgehog) or (GetGearType(gear) == gtResurrector) then |
316 |
trackDeletion(gear) |
|
317 |
end |
|
5277 | 318 |
end |
319 |
||
320 |
function onAmmoStoreInit() |
|
5362
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
321 |
-- |
5277 | 322 |
end |
323 |