author | mikade |
Sun, 03 Jul 2011 22:47:57 +0200 | |
changeset 5382 | d5321b22aed2 |
parent 5362 | 5f0c46e78e50 |
child 5457 | 48fe8e03a9cf |
permissions | -rw-r--r-- |
5277 | 1 |
---------------------------------- |
5382 | 2 |
-- THE SPECIALISTS MODE 0.4 |
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 |
||
5277 | 32 |
-------------------- |
33 |
--TO DO |
|
34 |
-------------------- |
|
35 |
||
36 |
-- add proper gameflag checking, maybe |
|
37 |
-- set crate drops etc. |
|
5362
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
38 |
-- add alternative switch |
5277 | 39 |
|
40 |
loadfile(GetDataPath() .. "Scripts/Locale.lua")() |
|
41 |
||
5382 | 42 |
local numhhs = 0 |
43 |
local hhs = {} |
|
5277 | 44 |
|
5382 | 45 |
local currName |
5277 | 46 |
local lastName |
5362
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
47 |
local started = false |
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
48 |
local switchStage = 0 |
5277 | 49 |
|
50 |
function CreateTeam() |
|
51 |
||
5382 | 52 |
currTeam = "" |
53 |
lastTeam = "" |
|
54 |
z = 0 |
|
5277 | 55 |
|
5382 | 56 |
for i = 0, (numhhs-1) do |
5277 | 57 |
|
5382 | 58 |
currTeam = GetHogTeamName(hhs[i]) |
5277 | 59 |
|
5382 | 60 |
if currTeam == lastTeam then |
61 |
z = z + 1 |
|
62 |
else |
|
63 |
z = 1 |
|
64 |
end |
|
5277 | 65 |
|
5382 | 66 |
if z == 1 then |
5277 | 67 |
|
5382 | 68 |
SetHogName(hhs[i],"Soldier") |
69 |
SetHogHat(hhs[i], "Vega") |
|
70 |
SetHealth(hhs[i],200) |
|
5277 | 71 |
|
5382 | 72 |
elseif z == 2 then |
5277 | 73 |
|
5382 | 74 |
SetHogHat(hhs[i], "Glasses") |
75 |
SetHogName(hhs[i],"Engineer") |
|
5277 | 76 |
|
5382 | 77 |
elseif z == 3 then |
5277 | 78 |
|
5382 | 79 |
SetHogName(hhs[i],"Ninja") |
80 |
SetHogHat(hhs[i], "NinjaFull") |
|
81 |
SetHealth(hhs[i],80) |
|
5277 | 82 |
|
5382 | 83 |
elseif z == 4 then |
5277 | 84 |
|
5382 | 85 |
SetHogName(hhs[i],"Demo") |
86 |
SetHogHat(hhs[i], "Skull") |
|
87 |
SetHealth(hhs[i],200) |
|
5277 | 88 |
|
5382 | 89 |
elseif z == 5 then |
5277 | 90 |
|
5382 | 91 |
SetHogName(hhs[i],"Sniper") |
92 |
SetHogHat(hhs[i], "Sniper") |
|
93 |
SetHealth(hhs[i],120) |
|
5277 | 94 |
|
5382 | 95 |
elseif z == 6 then |
5277 | 96 |
|
5382 | 97 |
SetHogName(hhs[i],"Saint") |
98 |
SetHogHat(hhs[i], "angel") |
|
99 |
SetHealth(hhs[i],300) |
|
5277 | 100 |
|
5382 | 101 |
elseif z == 7 then |
102 |
||
103 |
SetHogName(hhs[i],"Pyro") |
|
104 |
SetHogHat(hhs[i], "Gasmask") |
|
105 |
SetHealth(hhs[i],150) |
|
106 |
||
107 |
elseif z == 8 then |
|
5277 | 108 |
|
5382 | 109 |
SetHogName(hhs[i],"Loon") |
110 |
SetHogHat(hhs[i], "clown") |
|
111 |
SetHealth(hhs[i],100) |
|
5277 | 112 |
|
5382 | 113 |
end |
5277 | 114 |
|
5382 | 115 |
lastTeam = GetHogTeamName(hhs[i]) |
5277 | 116 |
|
5382 | 117 |
end |
5277 | 118 |
|
119 |
end |
|
120 |
||
121 |
function ResetAllAmmo() |
|
122 |
||
5382 | 123 |
AddAmmo(CurrentHedgehog, amBazooka, 0) |
124 |
AddAmmo(CurrentHedgehog, amGrenade, 0) |
|
125 |
AddAmmo(CurrentHedgehog, amShotgun, 0) |
|
5277 | 126 |
|
5382 | 127 |
AddAmmo(CurrentHedgehog, amGirder, 0) |
128 |
AddAmmo(CurrentHedgehog, amBlowTorch, 0) |
|
129 |
AddAmmo(CurrentHedgehog, amPickHammer, 0) |
|
130 |
AddAmmo(CurrentHedgehog, amSwitch, 0) |
|
131 |
||
132 |
AddAmmo(CurrentHedgehog, amRope, 0) |
|
133 |
AddAmmo(CurrentHedgehog, amParachute, 0) |
|
134 |
AddAmmo(CurrentHedgehog, amFirePunch, 0) |
|
5277 | 135 |
|
5382 | 136 |
AddAmmo(CurrentHedgehog, amDynamite, 0) |
137 |
AddAmmo(CurrentHedgehog, amDrill, 0) |
|
138 |
AddAmmo(CurrentHedgehog, amMine, 0) |
|
5277 | 139 |
|
5382 | 140 |
AddAmmo(CurrentHedgehog, amSniperRifle, 0) |
141 |
AddAmmo(CurrentHedgehog, amDEagle, 0) |
|
142 |
AddAmmo(CurrentHedgehog, amPortalGun, 0) |
|
5277 | 143 |
|
5382 | 144 |
AddAmmo(CurrentHedgehog, amSeduction, 0) |
145 |
AddAmmo(CurrentHedgehog, amResurrector, 0) |
|
146 |
AddAmmo(CurrentHedgehog, amInvulnerable, 0) |
|
147 |
||
148 |
AddAmmo(CurrentHedgehog, amFlamethrower, 0) |
|
149 |
AddAmmo(CurrentHedgehog, amMolotov, 0) |
|
150 |
AddAmmo(CurrentHedgehog, amNapalm, 0) |
|
151 |
||
152 |
AddAmmo(CurrentHedgehog, amBaseballBat, 0) |
|
153 |
AddAmmo(CurrentHedgehog, amGasBomb, 0) |
|
154 |
AddAmmo(CurrentHedgehog, amKamikaze, 0) |
|
5277 | 155 |
|
156 |
end |
|
157 |
||
158 |
function AssignAmmo() |
|
159 |
||
5382 | 160 |
ResetAllAmmo() |
161 |
n = GetHogName(CurrentHedgehog) |
|
5277 | 162 |
|
5382 | 163 |
AddAmmo(CurrentHedgehog, amSkip,100) |
5277 | 164 |
|
5382 | 165 |
if n == "Soldier" then |
166 |
AddAmmo(CurrentHedgehog, amBazooka,1) |
|
167 |
AddAmmo(CurrentHedgehog, amGrenade,1) |
|
168 |
AddAmmo(CurrentHedgehog, amShotgun,1) |
|
169 |
elseif n == "Engineer" then |
|
170 |
AddAmmo(CurrentHedgehog, amGirder, 2) |
|
171 |
AddAmmo(CurrentHedgehog, amBlowTorch, 1) |
|
172 |
AddAmmo(CurrentHedgehog, amPickHammer, 1) |
|
173 |
elseif n == "Ninja" then |
|
174 |
AddAmmo(CurrentHedgehog, amRope, 100) |
|
175 |
AddAmmo(CurrentHedgehog, amParachute, 100) |
|
176 |
AddAmmo(CurrentHedgehog, amFirePunch, 1) |
|
177 |
elseif n == "Demo" then |
|
178 |
AddAmmo(CurrentHedgehog, amDynamite, 1) |
|
179 |
AddAmmo(CurrentHedgehog, amMine, 1) |
|
180 |
AddAmmo(CurrentHedgehog, amDrill, 1) |
|
181 |
elseif n == "Sniper" then |
|
182 |
AddAmmo(CurrentHedgehog, amSniperRifle, 1) |
|
183 |
AddAmmo(CurrentHedgehog, amDEagle, 1) |
|
184 |
AddAmmo(CurrentHedgehog, amPortalGun, 2) |
|
185 |
elseif n == "Saint" then |
|
186 |
AddAmmo(CurrentHedgehog, amSeduction, 100) |
|
187 |
AddAmmo(CurrentHedgehog, amResurrector, 1) |
|
188 |
AddAmmo(CurrentHedgehog, amInvulnerable, 1) |
|
189 |
elseif n == "Pyro" then |
|
190 |
AddAmmo(CurrentHedgehog, amFlamethrower, 1) |
|
191 |
AddAmmo(CurrentHedgehog, amMolotov, 1) |
|
192 |
AddAmmo(CurrentHedgehog, amNapalm, 1) |
|
193 |
elseif n == "Loon" then |
|
194 |
AddAmmo(CurrentHedgehog, amBaseballBat, 1) |
|
195 |
AddAmmo(CurrentHedgehog, amGasBomb, 1) |
|
196 |
AddAmmo(CurrentHedgehog, amKamikaze, 1) |
|
197 |
end |
|
5277 | 198 |
|
199 |
end |
|
200 |
||
201 |
function onGameInit() |
|
5382 | 202 |
GameFlags = gfRandomOrder + gfResetWeps + gfInfAttack + gfPlaceHog |
203 |
Delay = 10 |
|
5277 | 204 |
end |
205 |
||
206 |
function onGameStart() |
|
5382 | 207 |
|
208 |
CreateTeam() |
|
5277 | 209 |
|
5382 | 210 |
ShowMission ( |
211 |
loc("THE SPECIALISTS"), |
|
212 |
loc("a Hedgewars mini-game"), |
|
5277 | 213 |
|
5382 | 214 |
loc("Eliminate the enemy specialists.") .. "|" .. |
215 |
" " .. "|" .. |
|
5277 | 216 |
|
5382 | 217 |
loc("Game Modifiers: ") .. "|" .. |
218 |
loc("Per-Hog Ammo") .. "|" .. |
|
219 |
loc("Weapons Reset") .. "|" .. |
|
220 |
loc("Unlimited Attacks") .. "|" .. |
|
5277 | 221 |
|
5382 | 222 |
"", 4, 4000 |
223 |
) |
|
5277 | 224 |
|
225 |
end |
|
226 |
||
227 |
||
228 |
function onNewTurn() |
|
5382 | 229 |
currName = GetHogName(CurrentHedgehog) |
230 |
lastName = GetHogName(CurrentHedgehog) |
|
231 |
AssignAmmo() |
|
232 |
||
233 |
--------------- |
|
234 |
--switch |
|
235 |
started = false |
|
236 |
switchStage = 0 |
|
237 |
--AddAmmo(CurrentHedgehog, amSwitch, 1) |
|
5362
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
238 |
--------------- |
5382 | 239 |
|
5277 | 240 |
end |
241 |
||
242 |
function onGameTick() |
|
243 |
||
244 |
if (CurrentHedgehog ~= nil) then |
|
245 |
||
246 |
currName = GetHogName(CurrentHedgehog) |
|
247 |
||
5382 | 248 |
if (currName ~= lastName) and (switchStage > 100) then |
5277 | 249 |
AddCaption(loc("Switched to ") .. currName .. "!") |
250 |
AssignAmmo() |
|
251 |
end |
|
252 |
||
5362
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
253 |
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
|
254 |
|
5382 | 255 |
AddCaption(loc("Prepare yourself") .. ", " .. currName .. "!") |
256 |
||
5362
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
257 |
switchStage = switchStage + 1 |
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
258 |
|
5382 | 259 |
if switchStage == 1 then |
5362
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
260 |
AddAmmo(CurrentHedgehog, amSwitch, 1) |
5382 | 261 |
|
262 |
elseif switchStage == 2 then |
|
5362
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
263 |
ParseCommand("setweap " .. string.char(amSwitch)) |
5382 | 264 |
elseif switchStage == 3 then |
5362
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
265 |
SetGearMessage(CurrentHedgehog,gmAttack) |
5382 | 266 |
elseif switchStage == 4 then |
5362
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
267 |
switchStage = 110 |
5382 | 268 |
AddAmmo(CurrentHedgehog, amSwitch, 0) |
5362
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
269 |
end |
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
270 |
end |
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
271 |
|
5277 | 272 |
lastName = currName |
273 |
||
274 |
end |
|
275 |
||
276 |
end |
|
277 |
||
278 |
function onGearAdd(gear) |
|
5382 | 279 |
|
280 |
if GetGearType(gear) == gtHedgehog then |
|
281 |
hhs[numhhs] = gear |
|
282 |
numhhs = numhhs + 1 |
|
283 |
end |
|
5277 | 284 |
|
285 |
end |
|
286 |
||
287 |
function onGearDelete(gear) |
|
288 |
-- |
|
289 |
end |
|
290 |
||
291 |
function onAmmoStoreInit() |
|
5362
5f0c46e78e50
Enable autoswitch on turn start for The Specialists Mode.
mikade
parents:
5277
diff
changeset
|
292 |
-- |
5277 | 293 |
end |
294 |