author | Wuzzy <almikes@aol.com> |
Thu, 24 Nov 2016 05:41:50 +0100 | |
changeset 12067 | 3d03e9294633 |
parent 11987 | 6f4b96669f9d |
child 12096 | db5e12d623cc |
permissions | -rw-r--r-- |
11015 | 1 |
--------------------------------------------------------- |
11738
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
2 |
--- LE CONSTRUCTION MODE 0.7+ (badly adapted from Hedge Editor 0.5) |
11015 | 3 |
--------------------------------------------------------- |
4 |
-- a hedgewars gameplay mode by mikade |
|
5 |
-- special thanks to all who helped test and offered suggestions |
|
6 |
-- additional thanks to sheepluva/nemo for adding some extra hooks |
|
7 |
||
8 |
-- (to do) |
|
9 |
-- investigate loc not working on addcaptions |
|
10 |
-- check for parsecommands before porting to dev |
|
11 |
-- test onUpDown more extensively as it may need revision (check for amRubber etc) |
|
12 |
-- test localization of weapons and utils and stuff |
|
13 |
||
14 |
-- try posistion grenades in Harmer so it blows hogs away from the struc |
|
15 |
-- and don't explode too close to the struc |
|
16 |
||
17 |
-- additional/previous balance ideas |
|
18 |
-- based on your money? |
|
19 |
-- based on the number of strucs/gens you own? |
|
20 |
-- based on your existing arsenal? |
|
21 |
-- limit number of crates spawned per round perhaps (done) |
|
22 |
-- limit number of generators? |
|
23 |
||
24 |
------------------------------------------------------------------------------ |
|
11725
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
25 |
-- SCRIPT PARAMETER |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
26 |
------------------------------------------------------------------------------ |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
27 |
-- The script parameter can be used to configure the energy |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
28 |
-- of the game. It is a comma-seperated list of key=value pairs, where each |
11734
2d57eed66d41
Fix bad comment in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11733
diff
changeset
|
29 |
-- key is a word and each value is an integer between 0 and 4294967295. |
11725
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
30 |
-- |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
31 |
-- Possible keys: |
11726
8c1a30d4cbc8
Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents:
11725
diff
changeset
|
32 |
--- initialenergy: Amount of energy that each team starts with (default: 550) |
11987
6f4b96669f9d
Fix Construction Mode screwing up when initialenergy > maxenergy
Wuzzy <almikes@aol.com>
parents:
11986
diff
changeset
|
33 |
--- Note: Must be smaller than or equal to maxenergy |
11725
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
34 |
--- energyperround: Amount of energy that each team gets per round (default: 50) |
11734
2d57eed66d41
Fix bad comment in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11733
diff
changeset
|
35 |
--- maxenergy: Maximum amount of energy each team can hold (default: 1000) |
11725
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
36 |
|
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
37 |
-- Example: “initialenergy=750, maxenergy=2000” starts thee game with 750 energy |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
38 |
-- and sets the maximum energy to 2000 |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
39 |
|
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
40 |
------------------------------------------------------------------------------ |
11015 | 41 |
--version history |
42 |
------------------------------------------------------------------------------ |
|
43 |
--v0.1 |
|
44 |
-- concept test |
|
45 |
||
46 |
--v0.2 |
|
47 |
-- improved documentation (in script and in game) |
|
48 |
-- improved localisation (or is it? at any rate, crate placement should now say e.g. Bazooka and not amBazooka) |
|
49 |
-- added variable weapon costs (based on the values from Vatten's Consumerism script) |
|
50 |
||
51 |
-- added reflector shield (still needs work and balancing) |
|
52 |
-- added weapon-filter (probably ok) |
|
53 |
||
54 |
-- enabled super weapons like ballgun, rcplane, watermelon, hellish to test balance |
|
55 |
-- reduce max money to 1000 |
|
56 |
||
57 |
--v0.3 |
|
58 |
-- some /s removed |
|
59 |
||
60 |
--v0.4 |
|
61 |
-- added support for per hog ammo (hopefully) |
|
62 |
||
63 |
--v0.5 (dev) |
|
64 |
-- added somewhat horribly implemented support for different structure sprites |
|
65 |
-- added override pictures for ammo menu |
|
66 |
-- added override message on wep select to aid understanding |
|
67 |
-- split menu into/between weps/parts: struc, crates, gears |
|
68 |
-- add a limit on crates per turn |
|
69 |
-- add a limit on extra time per turn |
|
70 |
-- add a test level |
|
71 |
-- restored rubber placement |
|
72 |
-- cleaned up some of the code a bit and removed about 280 lines of code I didn't need, lol |
|
73 |
||
74 |
--v0.6 (dev) |
|
75 |
-- added magic dance |
|
76 |
||
11737 | 77 |
--v0.7 (pushed to repo) |
11015 | 78 |
-- added a cfg file |
79 |
-- removed another 903 lines of code we weren't using (lol) |
|
80 |
||
11738
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
81 |
--v0.7+ (merged in repo) |
11737 | 82 |
-- applied Wuzzy's patches: |
83 |
-- script parameters: initialenergy, energyperround, maxenergy |
|
84 |
-- fix crate costs |
|
85 |
-- various minor tweaks and fixes |
|
86 |
-- (see commits in official repo) |
|
11738
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
87 |
-- make Construction Mode play well together with fort mode (clan order = fort order) |
11737 | 88 |
|
11015 | 89 |
-------------------------------- |
90 |
-- STRUCTURES LIST / IDEAS |
|
91 |
-------------------------------- |
|
92 |
||
93 |
--Healing Station: heals hogs to 150 life |
|
94 |
--Teleportation Node: allows teleporting to any other teleporter nodes |
|
95 |
--Bio-filter: explodes enemy hogs |
|
96 |
--Respawner: if you have one of these, any slain hogs are resurrected here :D |
|
97 |
--Generator: generates energy (used to buy stuff, and possibly later other strucs might have upkeep costs) |
|
98 |
--Support Station: allows purchasing of weapons, utilities, and med-crates |
|
99 |
--Construction Station: allows purchasing of girders, rubber, mines, sticky mines, barrels |
|
100 |
--Reflector Shield: reflect projectiles |
|
101 |
--Weapon Filter: kill all equipement of enemy hogs passing through this area. |
|
102 |
||
103 |
||
104 |
--to make the grill more attractive make it vaporize flying saucers |
|
105 |
--and also rope, and maybe incoming gears |
|
106 |
||
107 |
-- make healing thing also cure poison |
|
108 |
-- maybe make poison more virulent and dangerous |
|
109 |
||
110 |
--(not implemented / abandoned ideas) |
|
111 |
-- Core: allows construction of other structures. |
|
112 |
-- Automated Turret (think red drones from space invasion) |
|
113 |
-- Canon (gives access to 3 fireballs per turn while near) |
|
114 |
-- something that allows control of wind/water |
|
115 |
-- Gravity Field generator : triggers world gravity change |
|
116 |
||
117 |
-- structures consume power over time and |
|
118 |
-- maybe you can turn structures OFF/ON, manually to save power. |
|
119 |
||
120 |
-- hacking |
|
121 |
-- allow hacking of structures, either being able to use enemy structures, |
|
122 |
-- or turning a team's structures against them. |
|
123 |
||
124 |
-- pylons |
|
125 |
-- allow hogs to put down a pylon-like gear which then allows the core |
|
126 |
-- to place other structures/objects within the pylon's sphere of influence |
|
127 |
-- this would allow aggressive structure advancement |
|
128 |
||
129 |
-- resouce mining? |
|
130 |
-- you could designate something like mines, that you could get close to, |
|
131 |
-- "pick up", and then "drop" back at a central location to simulate |
|
132 |
-- resource mining. bit complicated/meh, normal power generators probably easier |
|
133 |
||
134 |
-- it would be cool to have a red mask we could apply over girders |
|
135 |
-- that would indicate they were Indestructible |
|
136 |
||
137 |
HedgewarsScriptLoad("/Scripts/Locale.lua") |
|
138 |
HedgewarsScriptLoad("/Scripts/Tracker.lua") |
|
11725
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
139 |
HedgewarsScriptLoad("/Scripts/Params.lua") |
11015 | 140 |
|
141 |
---------------------------------------------- |
|
142 |
-- STRUC CRAP |
|
143 |
---------------------------------------------- |
|
144 |
||
145 |
strucID = {} |
|
146 |
strucGear = {} |
|
147 |
strucClan = {} |
|
148 |
strucType = {} |
|
149 |
strucCost = {} |
|
150 |
strucHealth = {} |
|
151 |
||
152 |
strucCirc = {} |
|
153 |
strucCircCol = {} |
|
154 |
strucCircRadius = {} |
|
155 |
strucCircType = {} |
|
156 |
strucAltDisplay = {} |
|
157 |
||
11738
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
158 |
fortMode = false |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
159 |
|
11015 | 160 |
placedExpense = 0 |
161 |
||
162 |
tempID = nil |
|
163 |
||
164 |
sUID = 0 |
|
165 |
||
166 |
colorRed = 0xff0000ff |
|
167 |
colorGreen = 0x00ff00ff |
|
168 |
||
169 |
clanBoundsSX = {} |
|
170 |
clanBoundsSY = {} |
|
171 |
clanBoundsEX = {} |
|
172 |
clanBoundsEY = {} |
|
173 |
||
174 |
clanPower = {} |
|
175 |
clanID = {} |
|
176 |
clanLStrucIndex = {} |
|
177 |
||
178 |
clanLWepIndex = {} -- for ease of use let's track this stuff |
|
179 |
clanLUtilIndex = {} |
|
180 |
clanLGearIndex = {} |
|
181 |
clanUsedExtraTime = {} |
|
182 |
clanCratesSpawned = {} |
|
11726
8c1a30d4cbc8
Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents:
11725
diff
changeset
|
183 |
clanFirstTurn = {} |
11015 | 184 |
|
185 |
effectTimer = 0 |
|
186 |
||
187 |
wallsVisible = false |
|
188 |
wX = {} |
|
189 |
wY = {} |
|
190 |
wWidth = {} |
|
191 |
wHeight = {} |
|
192 |
wCol = {} |
|
193 |
margin = 20 |
|
194 |
||
195 |
vTag = {} |
|
196 |
lastWep = nil |
|
197 |
||
11722
f35139700d22
Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents:
11721
diff
changeset
|
198 |
checkForSpecialWeaponsIn = -1 |
f35139700d22
Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents:
11721
diff
changeset
|
199 |
|
11725
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
200 |
-- Config variables (script parameter) |
11726
8c1a30d4cbc8
Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents:
11725
diff
changeset
|
201 |
conf_initialEnergy = 550 |
11725
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
202 |
conf_energyPerRound = 50 |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
203 |
conf_maxEnergy = 1000 |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
204 |
|
11015 | 205 |
function HideTags() |
206 |
||
207 |
for i = 0, 2 do |
|
208 |
SetVisualGearValues(vTag[i],0,0,0,0,0,1,0, 0, 240000, 0xffffff00) |
|
209 |
end |
|
210 |
||
211 |
end |
|
212 |
||
213 |
function DrawTag(i) |
|
214 |
||
215 |
zoomL = 1.3 |
|
216 |
||
217 |
xOffset = 40 |
|
218 |
||
219 |
if i == 0 then |
|
220 |
yOffset = 40 |
|
221 |
tCol = 0xffba00ff |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
222 |
tValue = 30 |
11015 | 223 |
elseif i == 1 then |
224 |
zoomL = 1.1 |
|
225 |
xOffset = 45 |
|
226 |
yOffset = 70 |
|
227 |
tCol = 0x00ff00ff |
|
228 |
tValue = clanPower[GetHogClan(CurrentHedgehog)] |
|
229 |
elseif i == 2 then |
|
230 |
zoomL = 1.1 |
|
231 |
xOffset = 60 + 35 |
|
232 |
yOffset = 70 |
|
233 |
tCol = 0xa800ffff |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
234 |
tValue = 10 |
11015 | 235 |
end |
236 |
||
237 |
DeleteVisualGear(vTag[i]) |
|
238 |
vTag[i] = AddVisualGear(0, 0, vgtHealthTag, 0, false) |
|
239 |
g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vTag[i]) |
|
240 |
SetVisualGearValues ( |
|
241 |
vTag[i], --id |
|
242 |
-div(ScreenWidth,2) + xOffset, --xoffset |
|
243 |
ScreenHeight - yOffset, --yoffset |
|
244 |
0, --dx |
|
245 |
0, --dy |
|
246 |
zoomL, --zoom |
|
247 |
1, --~= 0 means align to screen |
|
248 |
g7, --frameticks |
|
249 |
tValue, --value |
|
250 |
240000, --timer |
|
251 |
tCol --GetClanColor( GetHogClan(CurrentHedgehog) ) |
|
252 |
) |
|
253 |
||
254 |
end |
|
255 |
||
256 |
function onScreenResize() |
|
257 |
||
258 |
-- redraw Tags so that their screen locations are updated |
|
259 |
if (CurrentHedgehog ~= nil) then |
|
260 |
DrawTag(0) |
|
261 |
DrawTag(1) |
|
262 |
DrawTag(2) |
|
263 |
end |
|
264 |
||
265 |
end |
|
266 |
||
267 |
function XYisInRect(px, py, psx, psy, pex, pey) |
|
268 |
||
269 |
if (px > psx) and (px < pex) and (py > psy) and (py < pey) then |
|
270 |
return(true) |
|
271 |
else |
|
272 |
return(false) |
|
273 |
end |
|
274 |
||
275 |
end |
|
276 |
||
277 |
function AddWall(zXMin,zYMin, zWidth, zHeight, zCol) |
|
278 |
||
279 |
table.insert(wX, zXMin) |
|
280 |
table.insert(wY, zYMin) |
|
281 |
table.insert(wWidth, zWidth) |
|
282 |
table.insert(wHeight, zHeight) |
|
283 |
table.insert(wCol, zCol) |
|
284 |
||
285 |
end |
|
286 |
||
287 |
function BorderSpark(zXMin,zYMin, zWidth, zHeight, bCol) |
|
288 |
||
289 |
eX = zXMin + GetRandom(zWidth+10) |
|
290 |
eY = zYMin + GetRandom(zHeight+10) |
|
291 |
tempE = AddVisualGear(eX, eY, vgtDust, 0, false) |
|
292 |
if tempE ~= 0 then |
|
293 |
g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) |
|
294 |
SetVisualGearValues(tempE, eX, eY, g3, g4, g5, g6, g7, 1, g9, bCol ) |
|
295 |
end |
|
296 |
||
297 |
end |
|
298 |
||
299 |
function HandleBorderEffects() |
|
300 |
||
301 |
effectTimer = effectTimer + 1 |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
302 |
if effectTimer > 15 then |
11015 | 303 |
effectTimer = 1 |
304 |
for i = 1, #wX do |
|
305 |
BorderSpark(wX[i],wY[i],wWidth[i],wHeight[i], wCol[i]) |
|
306 |
end |
|
307 |
end |
|
308 |
||
309 |
end |
|
310 |
||
311 |
---- |
|
312 |
-- old reflecting stuff from like 3 years ago lol |
|
313 |
--- |
|
314 |
||
315 |
function gearCanBeDeflected(gear) |
|
316 |
||
317 |
if (GetGearType(gear) == gtShell) or |
|
318 |
(GetGearType(gear) == gtGrenade) or |
|
319 |
(GetGearType(gear) == gtAirBomb) or |
|
320 |
(GetGearType(gear) == gtClusterBomb) or |
|
321 |
(GetGearType(gear) == gtCluster) or |
|
322 |
(GetGearType(gear) == gtGasBomb) or |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
323 |
(GetGearType(gear) == gtMine) or |
11015 | 324 |
(GetGearType(gear) == gtMortar) or |
325 |
(GetGearType(gear) == gtHellishBomb) or |
|
326 |
(GetGearType(gear) == gtWatermelon) or |
|
327 |
(GetGearType(gear) == gtMelonPiece) or |
|
328 |
(GetGearType(gear) == gtEgg) or |
|
329 |
(GetGearType(gear) == gtDrill) or |
|
330 |
(GetGearType(gear) == gtBall) or |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
331 |
(GetGearType(gear) == gtExplosives) or |
11015 | 332 |
(GetGearType(gear) == gtFlame) or |
333 |
(GetGearType(gear) == gtPortal) or |
|
334 |
(GetGearType(gear) == gtDynamite) or |
|
335 |
(GetGearType(gear) == gtSMine) or |
|
336 |
(GetGearType(gear) == gtKnife) or |
|
337 |
(GetGearType(gear) == gtJetpack) or -- test this and birdy plz |
|
338 |
(GetGearType(gear) == gtBirdy) or -- test this and birdy plz |
|
339 |
(GetGearType(gear) == gtSnowball) or |
|
340 |
(GetGearType(gear) == gtMolotov) |
|
341 |
then |
|
342 |
return(true) |
|
343 |
else |
|
344 |
return(false) |
|
345 |
end |
|
346 |
||
347 |
end |
|
348 |
||
349 |
function getThreatDamage(gear) |
|
350 |
||
351 |
--- damage amounts for weapons |
|
352 |
if (GetGearType(gear) == gtGrenade) or |
|
353 |
(GetGearType(gear) == gtClusterBomb) or |
|
354 |
(GetGearType(gear) == gtGasBomb) or |
|
355 |
(GetGearType(gear) == gtKnife) or |
|
356 |
(GetGearType(gear) == gtEgg) or |
|
357 |
(GetGearType(gear) == gtMolotov) or |
|
358 |
(GetGearType(gear) == gtHellishBomb) or |
|
359 |
(GetGearType(gear) == gtWatermelon) or |
|
360 |
(GetGearType(gear) == gtSMine) |
|
361 |
then |
|
362 |
dmg = 30 |
|
363 |
||
364 |
elseif (GetGearType(gear) == gtMelonPiece) then |
|
365 |
dmg = 40 |
|
366 |
||
367 |
elseif (GetGearType(gear) == gtAirBomb) or |
|
368 |
(GetGearType(gear) == gtDrill) or |
|
369 |
(GetGearType(gear) == gtMine) or |
|
370 |
(GetGearType(gear) == gtCluster) then |
|
371 |
dmg = 20 |
|
372 |
||
373 |
elseif (GetGearType(gear) == gtFlame) or |
|
374 |
(GetGearType(gear) == gtPortal) or |
|
375 |
(GetGearType(gear) == gtDynamite) |
|
376 |
then |
|
377 |
dmg = 0 |
|
378 |
||
379 |
elseif (GetGearType(gear) == gtBall) then |
|
380 |
dmg = 1 |
|
381 |
||
382 |
else --normal shell, snowball etc |
|
383 |
dmg = 65 |
|
384 |
end |
|
385 |
||
386 |
return(dmg) |
|
387 |
||
388 |
end |
|
389 |
||
390 |
function setGearReflectionValues(gear) |
|
391 |
||
392 |
dmg = getThreatDamage(gear) |
|
393 |
setGearValue(gear,"damage",dmg) |
|
394 |
setGearValue(gear,"deflects",0) |
|
395 |
||
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
396 |
if (CurrentHedgehog ~= nil) then |
11015 | 397 |
setGearValue(gear,"owner",GetHogClan(CurrentHedgehog)) -- NEW NEEDS CHANGE? |
398 |
else |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
399 |
setGearValue(gear,"owner",10) |
11015 | 400 |
end |
401 |
||
402 |
end |
|
403 |
||
404 |
function AddStruc(pX,pY, pType, pClan) |
|
405 |
||
406 |
sUID = sUID + 1 |
|
407 |
||
408 |
tempG = AddGear(0, 0, gtTarget, 0, 0, 0, 0) |
|
409 |
SetGearPosition(tempG, pX, pY) |
|
410 |
setGearValue(tempG, "sUID", sUID) |
|
411 |
||
412 |
tempCirc = AddVisualGear(0,0,vgtCircle,0,true) |
|
413 |
||
414 |
SetVisualGearValues(tempCirc, 0, 0, 100, 255, 1, 100, 0, 500, 1, 0xFFFFFF00) |
|
415 |
||
416 |
table.insert(strucID, sUID) |
|
417 |
table.insert(strucType, pType) |
|
418 |
table.insert(strucGear,tempG) |
|
419 |
table.insert(strucClan,pClan) |
|
420 |
table.insert(strucCost,2) |
|
421 |
||
422 |
frameID = 0 |
|
423 |
visualSprite = sprTarget |
|
424 |
madness = AddVisualGear(GetX(tempG), GetY(tempG), vgtStraightShot, 1, true,1) |
|
425 |
g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(madness) --g9 |
|
426 |
||
427 |
||
428 |
if pType == loc("Reflector Shield") then |
|
429 |
table.insert(strucHealth,255) |
|
430 |
||
431 |
else |
|
432 |
table.insert(strucHealth,1) |
|
433 |
end |
|
434 |
||
435 |
table.insert(strucCirc,tempCirc) |
|
436 |
||
437 |
table.insert(strucCircType, 1) |
|
438 |
if pType == loc("Bio-Filter") then |
|
439 |
table.insert(strucCircCol,colorRed) |
|
440 |
table.insert(strucCircRadius,1000) |
|
441 |
frameID = 7 |
|
442 |
elseif pType == loc("Healing Station") then |
|
443 |
table.insert(strucCircCol,0xFF00FF00) |
|
444 |
table.insert(strucCircRadius,500) |
|
445 |
frameID = 3 |
|
446 |
elseif pType == loc("Respawner") then |
|
447 |
table.insert(strucCircCol,0xFF00FF00) |
|
448 |
table.insert(strucCircRadius,75) |
|
449 |
runOnHogs(EnableHogResurrectionForThisClan) |
|
450 |
frameID = 1 |
|
451 |
elseif pType == loc("Teleportation Node") then |
|
452 |
table.insert(strucCircCol,0x0000FFFF) |
|
453 |
table.insert(strucCircRadius,350) |
|
454 |
frameID = 6 |
|
455 |
elseif pType == loc("Generator") then |
|
456 |
table.insert(strucCircCol,0xFFFF00FF) |
|
457 |
table.insert(strucCircRadius,75) |
|
458 |
setGearValue(tempG, "power", 0) |
|
459 |
frameID = 2 |
|
460 |
elseif pType == loc("Support Station") then |
|
461 |
table.insert(strucCircCol,0xFFFF00FF) |
|
462 |
table.insert(strucCircRadius,500) |
|
463 |
frameID = 4 |
|
464 |
elseif pType == loc("Construction Station") then |
|
465 |
table.insert(strucCircCol,0xFFFFFFFF) |
|
466 |
table.insert(strucCircRadius,500) |
|
467 |
frameID = 8 |
|
468 |
elseif pType == loc("Reflector Shield") then |
|
469 |
table.insert(strucCircCol,0xffae00ff) |
|
470 |
table.insert(strucCircRadius,750) |
|
471 |
frameID = 9 |
|
472 |
elseif pType == loc("Weapon Filter") then |
|
473 |
table.insert(strucCircCol,0xa800ffff) |
|
474 |
table.insert(strucCircRadius,750) |
|
475 |
frameID = 5 |
|
476 |
end |
|
477 |
||
478 |
||
479 |
SetVisualGearValues(madness, g1, g2, 0, 0, g5, frameID, g7, visualSprite, g9, g10 ) |
|
480 |
SetState(tempG, bor(GetState(tempG),gstInvisible) ) |
|
481 |
table.insert(strucAltDisplay, madness) |
|
482 |
||
483 |
end |
|
484 |
||
485 |
-- this is basically onStructureDelete |
|
486 |
-- we may need to expand it for non-gear structures later |
|
487 |
function CheckGearForStructureLink(gear) |
|
488 |
||
489 |
respawnerDestroyed = false |
|
490 |
||
491 |
for i = 1, #strucID do |
|
492 |
if strucID[i] == getGearValue(gear,"sUID") then |
|
493 |
||
494 |
if strucType[i] == loc("Respawner") then |
|
495 |
respawnerDestroyed = true |
|
496 |
end |
|
497 |
||
498 |
table.remove(strucID,i) |
|
499 |
table.remove(strucGear,i) |
|
500 |
table.remove(strucClan,i) |
|
501 |
table.remove(strucType,i) |
|
502 |
table.remove(strucCost,i) |
|
503 |
table.remove(strucHealth,i) |
|
504 |
||
505 |
DeleteVisualGear(strucCirc[i]) |
|
506 |
table.remove(strucCirc,i) |
|
507 |
||
508 |
table.remove(strucCircCol,i) |
|
509 |
table.remove(strucCircRadius,i) |
|
510 |
table.remove(strucCircType,i) |
|
511 |
||
512 |
if strucAltDisplay[i] ~= 1 then |
|
513 |
DeleteVisualGear(strucAltDisplay[i]) |
|
514 |
end |
|
515 |
table.remove(strucAltDisplay,i) |
|
516 |
||
517 |
end |
|
518 |
end |
|
519 |
||
520 |
if respawnerDestroyed == true then |
|
521 |
runOnHogs(RecalibrateRespawn) |
|
522 |
end |
|
523 |
||
524 |
end |
|
525 |
||
526 |
-- called when we add a new respawner |
|
527 |
function EnableHogResurrectionForThisClan(gear) |
|
528 |
if GetHogClan(gear) == GetHogClan(CurrentHedgehog) then |
|
529 |
SetEffect(gear, heResurrectable, 1) |
|
530 |
end |
|
531 |
end |
|
532 |
||
533 |
-- this is called when a respawner blows up |
|
534 |
function RecalibrateRespawn(gear) |
|
535 |
||
536 |
respawnerList = {} |
|
537 |
for i = 1, #strucID do |
|
538 |
if (strucType[i] == loc("Respawner")) and (strucClan[i] == GetHogClan(gear)) then |
|
539 |
table.insert(respawnerList, i) |
|
540 |
end |
|
541 |
end |
|
542 |
||
543 |
if #respawnerList >= 1 then |
|
544 |
SetEffect(gear, heResurrectable, 1) |
|
545 |
else |
|
546 |
SetEffect(gear, heResurrectable, 0) |
|
547 |
end |
|
548 |
||
549 |
end |
|
550 |
||
551 |
--resposition dead hogs at a respawner if they own one |
|
552 |
function FindRespawner(gear) |
|
553 |
||
554 |
respawnerList = {} |
|
555 |
for i = 1, #strucID do |
|
556 |
if (strucType[i] == loc("Respawner")) and (strucClan[i] == GetHogClan(gear)) then |
|
557 |
table.insert(respawnerList, i) |
|
558 |
end |
|
559 |
end |
|
560 |
||
561 |
if #respawnerList >= 1 then |
|
562 |
i = GetRandom(#respawnerList)+1 |
|
563 |
SetGearPosition(gear,GetX(strucGear[respawnerList[i]]),GetY(strucGear[respawnerList[i]])-25) |
|
564 |
AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false) |
|
565 |
else -- (this should never happen, but just in case) |
|
566 |
SetEffect(gear, heResurrectable, 0) |
|
567 |
DeleteGear(gear) |
|
568 |
end |
|
569 |
||
570 |
end |
|
571 |
||
572 |
function onGearResurrect(gear) |
|
573 |
AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false) |
|
574 |
FindRespawner(gear) |
|
575 |
end |
|
576 |
||
577 |
||
578 |
function CheckTeleport(gear, tX, tY) |
|
579 |
||
580 |
teleportOriginSuccessful = false |
|
581 |
teleportDestinationSuccessful = false |
|
582 |
||
583 |
for i = 1, #strucID do |
|
584 |
||
585 |
if (strucType[i] == loc("Teleportation Node")) and (strucClan[i] == GetHogClan(CurrentHedgehog)) then |
|
586 |
||
587 |
dist = GetDistFromGearToXY(CurrentHedgehog,GetX(strucGear[i]), GetY(strucGear[i])) |
|
588 |
if strucCircType[i] == 0 then |
|
589 |
NR = strucCircRadius[i] |
|
590 |
else |
|
591 |
NR = (48/100*strucCircRadius[i])/2 |
|
592 |
end |
|
593 |
if dist <= NR*NR then |
|
594 |
teleportOriginSuccessful = true |
|
595 |
end |
|
596 |
||
597 |
dist = GetDistFromXYtoXY(tX,tY,GetX(strucGear[i]), GetY(strucGear[i])) |
|
598 |
if strucCircType[i] == 0 then |
|
599 |
NR = strucCircRadius[i] |
|
600 |
else |
|
601 |
NR = (48/100*strucCircRadius[i])/2 |
|
602 |
end |
|
603 |
if dist <= NR*NR then |
|
604 |
teleportDestinationSuccessful = true |
|
605 |
end |
|
606 |
||
607 |
end |
|
608 |
||
609 |
||
610 |
end |
|
611 |
||
612 |
if ((teleportDestinationSuccessful == false) or (teleportOriginSuccessful == false)) then |
|
613 |
AddCaption(loc("Teleport Unsuccessful. Please teleport within a clan teleporter's sphere of influence.")) |
|
614 |
SetGearTarget(gear, GetX(CurrentHedgehog), GetY(CurrentHedgehog)) |
|
615 |
end |
|
616 |
||
617 |
end |
|
618 |
||
619 |
--Check for proximity of gears to structures, and make structures behave accordingly |
|
620 |
function CheckProximity(gear) |
|
621 |
||
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
622 |
dist = GetDistFromGearToXY(gear, GetX(strucGear[tempID]), GetY(strucGear[tempID])) |
11015 | 623 |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
624 |
-- calculate my real radius if I am an aura |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
625 |
if strucCircType[tempID] == 0 then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
626 |
NR = strucCircRadius[tempID] |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
627 |
else |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
628 |
NR = (48/100*strucCircRadius[tempID])/2 |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
629 |
end |
11015 | 630 |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
631 |
-- we're in business |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
632 |
if dist <= NR*NR then |
11015 | 633 |
|
634 |
||
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
635 |
-- heal clan hogs |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
636 |
if strucType[tempID] == loc("Healing Station") then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
637 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
638 |
if GetGearType(gear) == gtHedgehog then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
639 |
if GetHogClan(gear) == strucClan[tempID] then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
640 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
641 |
hogLife = GetHealth(gear) + 1 |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
642 |
if hogLife > 150 then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
643 |
hogLife = 150 |
11015 | 644 |
end |
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
645 |
SetHealth(gear, hogLife) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
646 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
647 |
-- change this to the med kit sprite health ++++s later |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
648 |
tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
649 |
g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
650 |
SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, colorGreen ) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
651 |
|
11015 | 652 |
end |
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
653 |
end |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
654 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
655 |
-- explode enemy clan hogs |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
656 |
elseif strucType[tempID] == loc("Bio-Filter") then |
11015 | 657 |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
658 |
if GetGearType(gear) == gtHedgehog then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
659 |
if (GetHogClan(gear) ~= strucClan[tempID]) and (GetHealth(gear) > 0) then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
660 |
AddGear(GetX(gear), GetY(gear), gtGrenade, 0, 0, 0, 1) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
661 |
end |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
662 |
end |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
663 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
664 |
-- were those weapons in your pocket, or were you just happy to see me? |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
665 |
elseif strucType[tempID] == loc("Weapon Filter") then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
666 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
667 |
if GetGearType(gear) == gtHedgehog then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
668 |
if (GetHogClan(gear) ~= strucClan[tempID]) then |
11015 | 669 |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
670 |
for wpnIndex = 1, #atkArray do |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
671 |
AddAmmo(gear, atkArray[wpnIndex][1], 0) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
672 |
end |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
673 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
674 |
for wpnIndex = 1, #utilArray do |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
675 |
AddAmmo(gear, utilArray[wpnIndex][1], 0) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
676 |
end |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
677 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
678 |
AddAmmo(gear, amAirAttack, 100) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
679 |
AddAmmo(gear, amSwitch, 100) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
680 |
AddAmmo(gear, amSkip, 100) |
11015 | 681 |
|
682 |
end |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
683 |
end |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
684 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
685 |
-- BOUNCE! POGO! POGO! POGO! POGO! |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
686 |
elseif strucType[tempID] == loc("Reflector Shield") then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
687 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
688 |
-- add check for whose projectile it is |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
689 |
if gearCanBeDeflected(gear) == true then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
690 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
691 |
gOwner = getGearValue(gear,"owner") |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
692 |
gDeflects = getGearValue(gear,"deflects") |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
693 |
gDmg = getGearValue(gear,"damage") |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
694 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
695 |
if gDeflects >= 3 then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
696 |
DeleteGear(gear) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
697 |
AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
698 |
PlaySound(sndVaporize) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
699 |
elseif gOwner ~= strucClan[tempID] then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
700 |
--whether to vaporize gears or bounce them |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
701 |
if gDmg ~= 0 then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
702 |
dx, dy = GetGearVelocity(gear) |
11015 | 703 |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
704 |
if (dx == 0) and (dy == 0) then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
705 |
-- static mine, explosive, etc encountered |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
706 |
-- do nothing |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
707 |
else |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
708 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
709 |
--let's bounce something! |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
710 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
711 |
dx = dx*(-1) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
712 |
dy = dy*(-1) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
713 |
SetGearVelocity(gear,dx,dy) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
714 |
setGearValue(gear,"deflects",(gDeflects+1)) |
11015 | 715 |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
716 |
AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
717 |
PlaySound(sndExplosion) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
718 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
719 |
strucHealth[tempID] = strucHealth[tempID] - gDmg |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
720 |
strucCircCol[tempID] = strucCircCol[tempID] - gDmg |
11015 | 721 |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
722 |
if strucHealth[tempID] <= 0 then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
723 |
AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtExplosion, 0, false) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
724 |
DeleteGear(strucGear[tempID]) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
725 |
PlaySound(sndExplosion) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
726 |
end |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
727 |
|
11015 | 728 |
end |
729 |
||
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
730 |
else |
11015 | 731 |
DeleteGear(gear) |
732 |
AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false) |
|
733 |
PlaySound(sndVaporize) |
|
734 |
end |
|
735 |
end |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
736 |
end |
11015 | 737 |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
738 |
--mark as within range of a teleporter node |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
739 |
elseif strucType[tempID] == loc("Teleportation Node") then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
740 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
741 |
if GetGearType(gear) == gtHedgehog then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
742 |
if GetHogClan(gear) == strucClan[tempID] then |
11015 | 743 |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
744 |
for i = 1, #sProx do |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
745 |
if sProx[i][1] == loc("Teleportation Mode") then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
746 |
sProx[i][2] = true |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
747 |
end |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
748 |
end |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
749 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
750 |
end |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
751 |
end |
11015 | 752 |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
753 |
-- mark as within range of construction station |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
754 |
-- and thus allow menu access to placement modes |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
755 |
-- for girders, mines, sticky mines and barrels |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
756 |
elseif strucType[tempID] == loc("Construction Station") then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
757 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
758 |
if GetGearType(gear) == gtHedgehog then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
759 |
if GetHogClan(gear) == strucClan[tempID] then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
760 |
tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
761 |
|
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
762 |
for i = 1, #sProx do |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
763 |
if ((sProx[i][1] == loc("Girder Placement Mode")) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
764 |
or (sProx[i][1] == loc("Rubber Placement Mode")) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
765 |
or (sProx[i][1] == loc("Mine Placement Mode")) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
766 |
or (sProx[i][1] == loc("Sticky Mine Placement Mode")) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
767 |
or (sProx[i][1] == loc("Barrel Placement Mode"))) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
768 |
then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
769 |
sProx[i][2] = true |
11015 | 770 |
end |
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
771 |
end |
11015 | 772 |
|
773 |
||
774 |
end |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
775 |
end |
11015 | 776 |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
777 |
-- mark as within stupport station range |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
778 |
-- and thus allow menu access to placement modes |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
779 |
-- for weapon, utility, and med crates |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
780 |
elseif strucType[tempID] == loc("Support Station") then |
11015 | 781 |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
782 |
if GetGearType(gear) == gtHedgehog then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
783 |
if GetHogClan(gear) == strucClan[tempID] then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
784 |
tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true) |
11015 | 785 |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
786 |
for i = 1, #sProx do |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
787 |
if ((sProx[i][1] == loc("Health Crate Placement Mode")) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
788 |
or (sProx[i][1] == loc("Weapon Crate Placement Mode")) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
789 |
or (sProx[i][1] == loc("Utility Crate Placement Mode"))) |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
790 |
then |
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
791 |
sProx[i][2] = true |
11015 | 792 |
end |
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
793 |
end |
11015 | 794 |
|
795 |
||
796 |
end |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
797 |
end |
11015 | 798 |
end |
799 |
||
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
800 |
end |
11015 | 801 |
|
802 |
end |
|
803 |
||
804 |
-- used to check if we need to run through all hogs or just currenthedgehog |
|
805 |
function isAStructureThatAppliesToMultipleGears(pID) |
|
806 |
if strucType[pID] == loc("Healing Station") or |
|
807 |
strucType[pID] == loc("Reflector Shield") or |
|
808 |
strucType[pID] == loc("Weapon Filter") or |
|
809 |
strucType[pID] == loc("Bio-Filter") |
|
810 |
then |
|
811 |
return(true) |
|
812 |
else |
|
813 |
return(false) |
|
814 |
end |
|
815 |
end |
|
816 |
||
817 |
function HandleStructures() |
|
818 |
||
11729
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
819 |
if GameTime % 100 == 0 then |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
820 |
for i = 1, #sProx do |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
821 |
sProx[i][2] = false |
11015 | 822 |
|
11729
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
823 |
if sProx[i][1] == loc("Structure Placement Mode") then |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
824 |
sProx[i][2] = true |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
825 |
end |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
826 |
|
11015 | 827 |
end |
828 |
end |
|
829 |
||
830 |
for i = 1, #strucID do |
|
831 |
||
11728
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
832 |
SetVisualGearValues(strucCirc[i], GetX(strucGear[i]), GetY(strucGear[i]), nil, nil, nil, nil, nil, strucCircRadius[i], nil, strucCircCol[i]) |
11015 | 833 |
|
834 |
tempID = i |
|
835 |
||
11728
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
836 |
SetVisualGearValues(strucAltDisplay[i], GetX(strucGear[i]), GetY(strucGear[i]), 0, 0, nil, nil, 800000, sprTarget) |
11015 | 837 |
|
11728
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
838 |
if GameTime % 100 == 0 then |
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
839 |
-- Check For proximity of stuff to our structures |
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
840 |
if isAStructureThatAppliesToMultipleGears(i) then |
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
841 |
runOnGears(CheckProximity) |
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
842 |
else -- only check prox on CurrentHedgehog |
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
843 |
if CurrentHedgehog ~= nil then |
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
844 |
CheckProximity(CurrentHedgehog) |
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
845 |
end |
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
846 |
end |
11015 | 847 |
|
11728
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
848 |
if strucType[i] == loc("Generator") then |
11737 | 849 |
|
11728
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
850 |
for z = 0, ClansCount-1 do |
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
851 |
if z == strucClan[i] then |
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
852 |
increaseGearValue(strucGear[i],"power") |
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
853 |
if getGearValue(strucGear[i],"power") == 10 then |
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
854 |
setGearValue(strucGear[i],"power",0) |
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
855 |
clanPower[z] = clanPower[z] + 1 |
11733
373150be0356
Construction Mode: Sanity-check numbers from script parameter
Wuzzy <almikes@aol.com>
parents:
11732
diff
changeset
|
856 |
if conf_maxEnergy ~= "inf" and clanPower[z] > conf_maxEnergy then |
11728
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
857 |
clanPower[z] = conf_maxEnergy |
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
858 |
end |
11015 | 859 |
end |
11737 | 860 |
|
11015 | 861 |
end |
862 |
end |
|
863 |
end |
|
864 |
||
865 |
end |
|
866 |
||
867 |
end |
|
868 |
||
869 |
||
870 |
||
871 |
-- this is kinda messy and gross (even more than usual), fix it up at some point |
|
872 |
-- it just assumes that if you have access to girders, it works for rubbers |
|
873 |
-- as that is what the struc implemenation means due to construction station |
|
11732
1c09b8d050ce
Construction Mode: Fix timer issues
Wuzzy <almikes@aol.com>
parents:
11731
diff
changeset
|
874 |
if GameTime % 100 == 0 and CurrentHedgehog ~= nil then |
11729
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
875 |
anyUIProx = false |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
876 |
for i = 1, #sProx do |
11015 | 877 |
|
11729
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
878 |
if sProx[i][1] == loc("Girder Placement Mode") then |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
879 |
if sProx[i][2] == true then |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
880 |
AddAmmo(CurrentHedgehog, amGirder, 100) |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
881 |
AddAmmo(CurrentHedgehog, amRubber, 100) |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
882 |
AddAmmo(CurrentHedgehog, amDrillStrike, 100) |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
883 |
else |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
884 |
AddAmmo(CurrentHedgehog, amGirder, 0) |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
885 |
AddAmmo(CurrentHedgehog, amRubber, 0) |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
886 |
AddAmmo(CurrentHedgehog, amDrillStrike, 0) -- new |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
887 |
end |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
888 |
elseif sProx[i][1] == loc("Teleportation Mode") then |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
889 |
if sProx[i][2] == true then |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
890 |
AddAmmo(CurrentHedgehog, amTeleport, 100) |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
891 |
else |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
892 |
AddAmmo(CurrentHedgehog, amTeleport, 0) |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
893 |
end |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
894 |
elseif sProx[i][1] == loc("Weapon Crate Placement Mode") then |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
895 |
-- this is new stuff |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
896 |
if sProx[i][2] == true then |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
897 |
AddAmmo(CurrentHedgehog, amNapalm, 100) |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
898 |
else |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
899 |
AddAmmo(CurrentHedgehog, amNapalm, 0) |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
900 |
end |
11015 | 901 |
end |
11729
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
902 |
|
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
903 |
if (sProx[i][2] == true) then |
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
904 |
anyUIProx = true |
11015 | 905 |
end |
11729
cf4d61123440
Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents:
11728
diff
changeset
|
906 |
|
11015 | 907 |
end |
908 |
end |
|
909 |
||
910 |
end |
|
911 |
||
912 |
||
913 |
function checkForSpecialWeapons() |
|
914 |
||
11947
abdb24f0c2d9
Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents:
11886
diff
changeset
|
915 |
if (GetCurAmmoType() == amDrillStrike) then |
abdb24f0c2d9
Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents:
11886
diff
changeset
|
916 |
AddCaption(loc("Object Placer"),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmoinfo) |
11015 | 917 |
end |
918 |
||
919 |
lastWep = GetCurAmmoType() |
|
920 |
||
921 |
end |
|
922 |
||
923 |
---------------------------------------------------------- |
|
924 |
-- EXCERPTS OF ADAPTED HEDGE_EDITOR CODE FOLLOWS |
|
925 |
---------------------------------------------------------- |
|
926 |
-- experimental crap |
|
927 |
||
928 |
local landType = 0 |
|
929 |
----------------------------------------- |
|
930 |
-- tracking vars for save slash load purposes |
|
931 |
----------------------------------------- |
|
932 |
||
933 |
local hhs = {} |
|
934 |
||
935 |
--------------------------------- |
|
936 |
-- crates are made of this stuff |
|
937 |
--------------------------------- |
|
938 |
placeholder = 20 |
|
939 |
atkArray = |
|
940 |
{ |
|
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
941 |
{amBazooka, "amBazooka", 0, 2*placeholder}, |
11015 | 942 |
--{amBee, "amBee", 0, loc("Homing Bee"), 4*placeholder}, |
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
943 |
{amMortar, "amMortar", 0, 1*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
944 |
{amDrill, "amDrill", 0, 3*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
945 |
{amSnowball, "amSnowball", 0, 3*placeholder}, |
11015 | 946 |
|
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
947 |
{amGrenade, "amGrenade", 0, 2*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
948 |
{amClusterBomb, "amClusterBomb", 0, 3*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
949 |
{amWatermelon, "amWatermelon", 0, 25*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
950 |
{amHellishBomb, "amHellishBomb", 0, 25*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
951 |
{amMolotov, "amMolotov", 0, 3*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
952 |
{amGasBomb, "amGasBomb", 0, 3*placeholder}, |
11015 | 953 |
|
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
954 |
{amShotgun, "amShotgun", 0, 2*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
955 |
{amDEagle, "amDEagle", 0, 2*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
956 |
{amSniperRifle, "amSniperRifle", 0, 3*placeholder}, |
11714
cea5418c1af6
Construction Mode: Make weapon names match en.txt
Wuzzy <almikes@aol.com>
parents:
11713
diff
changeset
|
957 |
--{amSineGun, "amSineGun", 0, loc("Sine Gun"), 6*placeholder}, |
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
958 |
{amFlamethrower,"amFlamethrower", 0, 4*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
959 |
{amIceGun, "amIceGun", 0, 15*placeholder}, |
11015 | 960 |
|
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
961 |
{amFirePunch, "amFirePunch", 0, 3*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
962 |
{amWhip, "amWhip", 0, 1*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
963 |
{amBaseballBat, "amBaseballBat", 0, 7*placeholder}, |
11015 | 964 |
--{amKamikaze, "amKamikaze", 0, loc("Kamikaze"), 1*placeholder}, |
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
965 |
{amSeduction, "amSeduction", 0, 1*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
966 |
{amHammer, "amHammer", 0, 1*placeholder}, |
11015 | 967 |
|
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
968 |
{amMine, "amMine", 0, 1*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
969 |
{amDynamite, "amDynamite", 0, 9*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
970 |
{amCake, "amCake", 0, 25*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
971 |
{amBallgun, "amBallgun", 0, 40*placeholder}, |
11015 | 972 |
--{amRCPlane, "amRCPlane", 0, loc("RC Plane"), 25*placeholder}, |
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
973 |
{amSMine, "amSMine", 0, 5*placeholder}, |
11015 | 974 |
|
975 |
--{amAirAttack, "amAirAttack", 0, loc("Air Attack"), 10*placeholder}, |
|
976 |
--{amMineStrike, "amMineStrike", 0, loc("Mine Strike"), 15*placeholder}, |
|
977 |
--{amNapalm, "amNapalm", 0, loc("Napalm"), 15*placeholder}, |
|
978 |
--{amPiano, "amPiano", 0, loc("Piano Strike"), 40*placeholder}, |
|
11764
1e2ec1be5041
Construction Mode: Reorder weapon and utility list to parrallel weapon menu order
Wuzzy <almikes@aol.com>
parents:
11763
diff
changeset
|
979 |
--{amDrillStrike, "amDrillStrike", 0, loc("Drill Strike"), 15*placeholder}, |
11015 | 980 |
|
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
981 |
{amKnife, "amKnife", 0, 2*placeholder}, |
11015 | 982 |
|
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
983 |
{amBirdy, "amBirdy", 0, 7*placeholder} |
11015 | 984 |
|
985 |
} |
|
986 |
||
987 |
utilArray = |
|
988 |
{ |
|
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
989 |
{amPickHammer, "amPickHammer", 0, 2*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
990 |
{amBlowTorch, "amBlowTorch", 0, 4*placeholder}, |
11015 | 991 |
--{amGirder, "amGirder", 0, loc("Girder"), 4*placeholder}, |
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
992 |
{amLandGun, "amLandGun", 0, 5*placeholder}, |
11714
cea5418c1af6
Construction Mode: Make weapon names match en.txt
Wuzzy <almikes@aol.com>
parents:
11713
diff
changeset
|
993 |
--{amRubber, "amRubber", 0, loc("Rubber"), 5*placeholder}, |
11015 | 994 |
|
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
995 |
{amRope, "amRope", 0, 7*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
996 |
{amParachute, "amParachute", 0, 2*placeholder}, |
11015 | 997 |
--{amTeleport, "amTeleport", 0, loc("Teleport"), 6*placeholder}, |
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
998 |
{amJetpack, "amJetpack", 0, 8*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
999 |
{amPortalGun, "amPortalGun", 0, 15*placeholder}, |
11015 | 1000 |
|
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
1001 |
{amInvulnerable, "amInvulnerable", 0, 5*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
1002 |
{amLaserSight, "amLaserSight", 0, 2*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
1003 |
{amVampiric, "amVampiric", 0, 6*placeholder}, |
11764
1e2ec1be5041
Construction Mode: Reorder weapon and utility list to parrallel weapon menu order
Wuzzy <almikes@aol.com>
parents:
11763
diff
changeset
|
1004 |
--{amResurrector, "amResurrector", 0, loc("Resurrector"), 8*placeholder}, |
1e2ec1be5041
Construction Mode: Reorder weapon and utility list to parrallel weapon menu order
Wuzzy <almikes@aol.com>
parents:
11763
diff
changeset
|
1005 |
--{amTardis, "amTardis", 0, loc("Time Box"), 2*placeholder}, |
11015 | 1006 |
|
11764
1e2ec1be5041
Construction Mode: Reorder weapon and utility list to parrallel weapon menu order
Wuzzy <almikes@aol.com>
parents:
11763
diff
changeset
|
1007 |
--{amSwitch, "amSwitch", 0, loc("Switch Hog"), 4*placeholder} |
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
1008 |
{amLowGravity, "amLowGravity", 0, 4*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
1009 |
{amExtraDamage, "amExtraDamage", 0, 6*placeholder}, |
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
1010 |
{amExtraTime, "amExtraTime", 0, 8*placeholder} |
11015 | 1011 |
|
1012 |
} |
|
1013 |
||
1014 |
---------------------------- |
|
1015 |
-- placement shite |
|
1016 |
---------------------------- |
|
1017 |
||
1018 |
local cGear = nil -- detects placement of girders and objects (using airattack) |
|
1019 |
local curWep = amNothing |
|
1020 |
||
1021 |
-- primary placement categories |
|
1022 |
local cIndex = 1 -- category index |
|
1023 |
local cat = { |
|
1024 |
"Girder Placement Mode", |
|
1025 |
"Rubber Placement Mode", |
|
1026 |
"Mine Placement Mode", |
|
1027 |
"Sticky Mine Placement Mode", |
|
1028 |
"Barrel Placement Mode", |
|
1029 |
"Weapon Crate Placement Mode", |
|
1030 |
"Utility Crate Placement Mode", |
|
11766
25c6188084c2
Construction Mode: Make weapon crate mode be initial selection in crate tool
Wuzzy <almikes@aol.com>
parents:
11765
diff
changeset
|
1031 |
"Health Crate Placement Mode", |
11015 | 1032 |
"Structure Placement Mode" |
1033 |
} |
|
1034 |
||
1035 |
||
1036 |
sProx = { |
|
1037 |
{loc("Girder Placement Mode"),false}, |
|
1038 |
{loc("Rubber Placement Mode"),false}, |
|
1039 |
{loc("Mine Placement Mode"),false}, |
|
1040 |
{loc("Sticky Mine Placement Mode"),false}, |
|
1041 |
{loc("Barrel Placement Mode"),false}, |
|
1042 |
{loc("Weapon Crate Placement Mode"),false}, |
|
1043 |
{loc("Utility Crate Placement Mode"),false}, |
|
11766
25c6188084c2
Construction Mode: Make weapon crate mode be initial selection in crate tool
Wuzzy <almikes@aol.com>
parents:
11765
diff
changeset
|
1044 |
{loc("Health Crate Placement Mode"),false}, |
11015 | 1045 |
{loc("Structure Placement Mode"),false}, |
1046 |
{loc("Teleportation Mode"),false} |
|
1047 |
} |
|
1048 |
||
1049 |
||
1050 |
local pMode = {} -- pMode contains custom subsets of the main categories |
|
1051 |
local pIndex = 1 |
|
1052 |
||
1053 |
local CGR = 1 -- current girder rotation, we actually need this as HW remembers what rotation you last used |
|
1054 |
||
1055 |
local placedX = {} |
|
1056 |
local placedY = {} |
|
1057 |
local placedSpec = {} |
|
1058 |
local placedSuperSpec = {} |
|
1059 |
local placedType = {} |
|
1060 |
local placedCount = 0 |
|
1061 |
||
1062 |
local sCirc -- circle that appears around selected gears |
|
1063 |
local sGear = nil |
|
1064 |
local closestDist |
|
1065 |
local closestGear = nil |
|
1066 |
||
1067 |
local tCirc = {} -- array of circles that appear around tagged gears |
|
1068 |
||
1069 |
------------------------ |
|
1070 |
-- SOME GENERAL METHODS |
|
1071 |
------------------------ |
|
1072 |
||
1073 |
function GetDistFromGearToXY(gear, g2X, g2Y) |
|
1074 |
||
1075 |
g1X, g1Y = GetGearPosition(gear) |
|
1076 |
q = g1X - g2X |
|
1077 |
w = g1Y - g2Y |
|
1078 |
||
1079 |
return ( (q*q) + (w*w) ) |
|
1080 |
||
1081 |
end |
|
1082 |
||
1083 |
function GetDistFromXYtoXY(a, b, c, d) |
|
1084 |
q = a - c |
|
1085 |
w = b - d |
|
1086 |
return ( (q*q) + (w*w) ) |
|
1087 |
end |
|
1088 |
||
1089 |
function SelectGear(gear) |
|
1090 |
||
1091 |
d = GetDistFromGearToXY(gear, placedX[placedCount], placedY[placedCount]) |
|
1092 |
||
1093 |
if d < closestDist then |
|
1094 |
closestDist = d |
|
1095 |
closestGear = gear |
|
1096 |
end |
|
1097 |
||
1098 |
end |
|
1099 |
||
1100 |
-- essentially called when user clicks the mouse |
|
1101 |
-- with girders or an airattack |
|
1102 |
function PlaceObject(x,y) |
|
1103 |
||
1104 |
placedX[placedCount] = x |
|
1105 |
placedY[placedCount] = y |
|
1106 |
placedType[placedCount] = cat[cIndex] |
|
1107 |
placedSpec[placedCount] = pMode[pIndex] |
|
1108 |
||
1109 |
if (clanUsedExtraTime[GetHogClan(CurrentHedgehog)] == true) and (cat[cIndex] == "Utility Crate Placement Mode") and (utilArray[pIndex][1] == amExtraTime) then |
|
11727
fc4909039db8
Construction Mode: “spawn” extra time, not buying
Wuzzy <almikes@aol.com>
parents:
11726
diff
changeset
|
1110 |
AddCaption(loc("You may only spawn 1 Extra Time per turn."),0xffba00ff,capgrpVolume) |
11015 | 1111 |
PlaySound(sndDenied) |
1112 |
elseif (clanCratesSpawned[GetHogClan(CurrentHedgehog)] > 4) and ( (cat[cIndex] == "Health Crate Placement Mode") or (cat[cIndex] == "Utility Crate Placement Mode") or (cat[cIndex] == "Weapon Crate Placement Mode") ) then |
|
1113 |
AddCaption(loc("You may only spawn 5 crates per turn."),0xffba00ff,capgrpVolume) |
|
1114 |
PlaySound(sndDenied) |
|
1115 |
elseif (XYisInRect(x,y, clanBoundsSX[GetHogClan(CurrentHedgehog)],clanBoundsSY[GetHogClan(CurrentHedgehog)],clanBoundsEX[GetHogClan(CurrentHedgehog)],clanBoundsEY[GetHogClan(CurrentHedgehog)]) == true) |
|
1116 |
and (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) |
|
1117 |
then |
|
1118 |
||
1119 |
||
1120 |
||
1121 |
if cat[cIndex] == "Girder Placement Mode" then |
|
1122 |
PlaceGirder(x, y, CGR) |
|
1123 |
placedSpec[placedCount] = CGR |
|
1124 |
elseif cat[cIndex] == "Rubber Placement Mode" then |
|
1125 |
PlaceSprite(x,y, sprAmRubber, CGR, nil, nil, nil, nil, lfBouncy) |
|
1126 |
placedSpec[placedCount] = CGR |
|
1127 |
elseif cat[cIndex] == "Health Crate Placement Mode" then |
|
1128 |
gear = SpawnHealthCrate(x,y) |
|
1129 |
SetHealth(gear, pMode[pIndex]) |
|
1130 |
setGearValue(gear,"caseType","med") |
|
1131 |
clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1 |
|
1132 |
elseif cat[cIndex] == "Weapon Crate Placement Mode" then |
|
1133 |
gear = SpawnAmmoCrate(x, y, atkArray[pIndex][1]) |
|
1134 |
placedSpec[placedCount] = atkArray[pIndex][2] |
|
1135 |
setGearValue(gear,"caseType","ammo") |
|
1136 |
setGearValue(gear,"contents",atkArray[pIndex][2]) |
|
1137 |
clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1 |
|
1138 |
elseif cat[cIndex] == "Utility Crate Placement Mode" then |
|
1139 |
gear = SpawnUtilityCrate(x, y, utilArray[pIndex][1]) |
|
1140 |
placedSpec[placedCount] = utilArray[pIndex][2] |
|
1141 |
setGearValue(gear,"caseType","util") |
|
1142 |
setGearValue(gear,"contents",utilArray[pIndex][2]) |
|
1143 |
if utilArray[pIndex][1] == amExtraTime then |
|
1144 |
clanUsedExtraTime[GetHogClan(CurrentHedgehog)] = true |
|
1145 |
end |
|
1146 |
clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1 |
|
1147 |
elseif cat[cIndex] == "Barrel Placement Mode" then |
|
1148 |
gear = AddGear(x, y, gtExplosives, 0, 0, 0, 0) |
|
1149 |
SetHealth(gear, pMode[pIndex]) |
|
1150 |
elseif cat[cIndex] == "Mine Placement Mode" then |
|
1151 |
gear = AddGear(x, y, gtMine, 0, 0, 0, 0) |
|
1152 |
SetTimer(gear, pMode[pIndex]) |
|
1153 |
elseif cat[cIndex] == "Sticky Mine Placement Mode" then |
|
1154 |
gear = AddGear(x, y, gtSMine, 0, 0, 0, 0) |
|
1155 |
||
1156 |
elseif cat[cIndex] == "Structure Placement Mode" then |
|
1157 |
||
1158 |
AddStruc(x,y, pMode[pIndex],GetHogClan(CurrentHedgehog)) |
|
1159 |
||
1160 |
end |
|
1161 |
||
1162 |
clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] - placedExpense |
|
1163 |
placedCount = placedCount + 1 |
|
1164 |
||
1165 |
else |
|
1166 |
if (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) then |
|
1167 |
AddCaption(loc("Invalid Placement"),0xffba00ff,capgrpVolume) |
|
1168 |
else |
|
1169 |
AddCaption(loc("Insufficient Power"),0xffba00ff,capgrpVolume) |
|
1170 |
end |
|
1171 |
PlaySound(sndDenied) |
|
1172 |
end |
|
1173 |
||
1174 |
||
1175 |
end |
|
1176 |
||
1177 |
-- called when user changes primary selection |
|
1178 |
-- either via up/down keys |
|
1179 |
-- or selecting girder/airattack |
|
1180 |
function RedefineSubset() |
|
1181 |
||
1182 |
pIndex = 1 |
|
1183 |
pMode = {} |
|
1184 |
placedExpense = 1 |
|
1185 |
||
1186 |
if cat[cIndex] == "Girder Placement Mode" then |
|
1187 |
pIndex = CGR |
|
11717
0a33c3172e6d
Mark some forgotten Construction Mode strings for translation
Wuzzy <almikes@aol.com>
parents:
11716
diff
changeset
|
1188 |
pMode = {loc("Girder")} |
11015 | 1189 |
elseif cat[cIndex] == "Rubber Placement Mode" then |
1190 |
pIndex = CGR |
|
11717
0a33c3172e6d
Mark some forgotten Construction Mode strings for translation
Wuzzy <almikes@aol.com>
parents:
11716
diff
changeset
|
1191 |
pMode = {loc("Rubber")} |
11015 | 1192 |
placedExpense = 3 |
1193 |
elseif cat[cIndex] == "Barrel Placement Mode" then |
|
11718
106112bbacfa
Tweak barrel and mine defaults in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11717
diff
changeset
|
1194 |
pMode = {60} |
11015 | 1195 |
placedExpense = 10 |
1196 |
elseif cat[cIndex] == "Health Crate Placement Mode" then |
|
11731
4addfad422ab
Construction Mode: Recognize health case amount from game scheme
Wuzzy <almikes@aol.com>
parents:
11730
diff
changeset
|
1197 |
pMode = {HealthCaseAmount} |
11015 | 1198 |
placedExpense = 5 |
1199 |
elseif cat[cIndex] == "Weapon Crate Placement Mode" then |
|
1200 |
for i = 1, #atkArray do |
|
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
1201 |
pMode[i] = GetAmmoName(atkArray[i][1]) |
11015 | 1202 |
end |
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
1203 |
placedExpense = atkArray[pIndex][4] |
11015 | 1204 |
elseif cat[cIndex] == "Utility Crate Placement Mode" then |
1205 |
for i = 1, #utilArray do |
|
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
1206 |
pMode[i] = GetAmmoName(utilArray[i][1]) |
11015 | 1207 |
end |
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
1208 |
placedExpense = utilArray[pIndex][4] |
11015 | 1209 |
elseif cat[cIndex] == "Mine Placement Mode" then |
11718
106112bbacfa
Tweak barrel and mine defaults in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11717
diff
changeset
|
1210 |
pMode = {0,1000,2000,3000,4000,5000} |
11015 | 1211 |
placedExpense = 15 |
1212 |
elseif cat[cIndex] == "Sticky Mine Placement Mode" then |
|
11717
0a33c3172e6d
Mark some forgotten Construction Mode strings for translation
Wuzzy <almikes@aol.com>
parents:
11716
diff
changeset
|
1213 |
pMode = {loc("Sticky Mine")} |
11015 | 1214 |
placedExpense = 20 |
1215 |
elseif cat[cIndex] == "Structure Placement Mode" then |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
1216 |
pMode = {loc("Healing Station"), loc("Bio-Filter"), loc("Weapon Filter"), loc("Reflector Shield"), loc("Respawner"),loc("Teleportation Node"),loc("Generator"),loc("Construction Station"),loc("Support Station")} |
11015 | 1217 |
end |
1218 |
||
1219 |
||
1220 |
||
1221 |
||
1222 |
end |
|
1223 |
||
1224 |
-- called in onGameTick() |
|
1225 |
function HandleHedgeEditor() |
|
1226 |
||
11728
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
1227 |
HandleStructures() |
456f4e9f9dce
Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents:
11727
diff
changeset
|
1228 |
|
11015 | 1229 |
if CurrentHedgehog ~= nil then |
1230 |
||
1231 |
if wallsVisible == true then |
|
1232 |
HandleBorderEffects() |
|
1233 |
end |
|
1234 |
||
1235 |
if (CurrentHedgehog ~= nil) and (TurnTimeLeft ~= TurnTime) then |
|
1236 |
if (lastWep ~= GetCurAmmoType()) then |
|
1237 |
checkForSpecialWeapons() |
|
11722
f35139700d22
Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents:
11721
diff
changeset
|
1238 |
elseif checkForSpecialWeaponsIn == 0 then |
f35139700d22
Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents:
11721
diff
changeset
|
1239 |
checkForSpecialWeapons() |
f35139700d22
Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents:
11721
diff
changeset
|
1240 |
checkForSpecialWeaponsIn = -1 |
f35139700d22
Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents:
11721
diff
changeset
|
1241 |
else |
f35139700d22
Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents:
11721
diff
changeset
|
1242 |
checkForSpecialWeaponsIn = checkForSpecialWeaponsIn - 1 |
11015 | 1243 |
end |
1244 |
end |
|
1245 |
||
11732
1c09b8d050ce
Construction Mode: Fix timer issues
Wuzzy <almikes@aol.com>
parents:
11731
diff
changeset
|
1246 |
if GameTime % 100 == 0 then |
11015 | 1247 |
|
1248 |
DrawTag(1) |
|
1249 |
||
1250 |
curWep = GetCurAmmoType() |
|
1251 |
||
1252 |
-- change to girder mode on weapon swap |
|
1253 |
if (cIndex ~= 1) and (curWep == amGirder) then |
|
1254 |
cIndex = 1 |
|
1255 |
RedefineSubset() |
|
1256 |
elseif (cIndex ~=2) and (curWep == amRubber) then |
|
1257 |
cIndex = 2 |
|
1258 |
RedefineSubset() |
|
1259 |
-- change to generic mode if girder no longer selected |
|
1260 |
elseif (cIndex == 1) and (curWep ~= amGirder) then |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
1261 |
cIndex = 3 |
11015 | 1262 |
RedefineSubset() |
1263 |
elseif (cIndex == 2) and (curWep ~= amRubber) then |
|
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
1264 |
cIndex = 3 |
11015 | 1265 |
RedefineSubset() |
1266 |
||
1267 |
end |
|
1268 |
||
1269 |
-- update display selection criteria |
|
11765
001994046892
Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents:
11764
diff
changeset
|
1270 |
if ((curWep == amGirder) or (curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) or (curWep == amRubber)) |
001994046892
Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents:
11764
diff
changeset
|
1271 |
and (CurrentHedgehog ~= nil or band(GetState(CurrentHedgehog), gstHHDriven) ~= 0) then |
11015 | 1272 |
|
1273 |
---------------hooolllllyyyy fucking shit this |
|
1274 |
-- code is a broken mess now |
|
1275 |
-- it was redesigned and compromised three times |
|
1276 |
-- so now it is a mess trying to do what it was |
|
1277 |
-- never designed to do |
|
1278 |
-- needs to be rewritten badly sadface |
|
1279 |
-- this bit here catches the new 3 types of weapons |
|
1280 |
if ((sProx[cIndex][1] == loc("Structure Placement Mode") and (curWep ~= amAirAttack))) then |
|
1281 |
updatePlacementDisplay(1) |
|
1282 |
elseif (sProx[cIndex][1] == loc("Health Crate Placement Mode")) or |
|
1283 |
(sProx[cIndex][1] == loc("Weapon Crate Placement Mode")) or |
|
1284 |
(sProx[cIndex][1] == loc("Utility Crate Placement Mode")) then |
|
1285 |
if curWep ~= amNapalm then |
|
1286 |
updatePlacementDisplay(1) |
|
1287 |
end |
|
1288 |
||
1289 |
elseif (sProx[cIndex][1] == loc("Mine Placement Mode")) or |
|
1290 |
(sProx[cIndex][1] == loc("Sticky Mine Placement Mode")) or |
|
1291 |
(sProx[cIndex][1] == loc("Barrel Placement Mode")) then |
|
1292 |
if curWep ~= amDrillStrike then |
|
1293 |
updatePlacementDisplay(1) |
|
1294 |
end |
|
1295 |
||
1296 |
end |
|
1297 |
||
1298 |
--this is called when it happens that we have placement |
|
1299 |
--mode selected and we are looking at something |
|
1300 |
--we shouldn't be allowed to look at, as would be the case |
|
1301 |
--when you WERE allowed to look at it, but then maybe |
|
1302 |
--a bomb blows up the structure that was granting you |
|
1303 |
--that ability |
|
1304 |
if (sProx[cIndex][2] ~= true) then |
|
1305 |
updatePlacementDisplay(1) |
|
1306 |
else |
|
1307 |
updateCost() |
|
1308 |
end |
|
1309 |
||
1310 |
||
11301
fa18940f290d
- Rus localization for following game styles:
antonc27 <antonc27@mail.ru>
parents:
11015
diff
changeset
|
1311 |
AddCaption(loc(cat[cIndex]),0xffba00ff,capgrpMessage) |
11719
8575b8b76373
Construction Mode: Show mine timer in seconds
Wuzzy <almikes@aol.com>
parents:
11718
diff
changeset
|
1312 |
showModeMessage() |
11015 | 1313 |
wallsVisible = true |
1314 |
else |
|
1315 |
wallsVisible = false |
|
1316 |
end |
|
1317 |
||
1318 |
end |
|
1319 |
||
1320 |
end |
|
1321 |
||
1322 |
-- some kind of target detected, tell me your story |
|
1323 |
if cGear ~= nil then |
|
1324 |
||
1325 |
x,y = GetGearTarget(cGear) |
|
1326 |
||
1327 |
if GetGearType(cGear) == gtAirAttack then |
|
1328 |
DeleteGear(cGear) |
|
1329 |
PlaceObject(x, y) |
|
1330 |
elseif GetGearType(cGear) == gtTeleport then |
|
1331 |
||
1332 |
CheckTeleport(cGear, x, y) |
|
1333 |
cGear = nil |
|
1334 |
elseif GetGearType(cGear) == gtGirder then |
|
1335 |
||
1336 |
CGR = GetState(cGear) |
|
1337 |
||
11723
f699978eae19
Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents:
11722
diff
changeset
|
1338 |
PlaceObject(x, y) |
11015 | 1339 |
end |
1340 |
||
1341 |
end |
|
1342 |
||
1343 |
end |
|
1344 |
||
1345 |
--------------------------------------------------------------- |
|
1346 |
-- Cycle through selection subsets (by changing pIndex, pMode) |
|
1347 |
-- i.e health of barrels, medikits, |
|
1348 |
-- timer of mines |
|
1349 |
-- contents of crates |
|
1350 |
-- gears to reposition etc. |
|
1351 |
--------------------------------------------------------------- |
|
1352 |
||
1353 |
function updateCost() |
|
1354 |
||
11765
001994046892
Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents:
11764
diff
changeset
|
1355 |
if CurrentHedgehog == nil or band(GetState(CurrentHedgehog), gstHHDriven) == 0 then return end |
001994046892
Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents:
11764
diff
changeset
|
1356 |
|
11015 | 1357 |
if pMode[pIndex] == loc("Healing Station") then |
1358 |
placedExpense = 50 |
|
1359 |
elseif pMode[pIndex] == loc("Weapon Filter") then |
|
1360 |
placedExpense = 50 |
|
1361 |
elseif pMode[pIndex] == loc("Bio-Filter") then |
|
1362 |
placedExpense = 100 |
|
1363 |
elseif pMode[pIndex] == loc("Respawner") then |
|
1364 |
placedExpense = 300 |
|
1365 |
elseif pMode[pIndex] == loc("Teleportation Node") then |
|
1366 |
placedExpense = 30 |
|
1367 |
elseif pMode[pIndex] == loc("Support Station") then |
|
1368 |
placedExpense = 50 |
|
1369 |
elseif pMode[pIndex] == loc("Construction Station") then |
|
1370 |
placedExpense = 50 |
|
1371 |
elseif pMode[pIndex] == loc("Generator") then |
|
1372 |
placedExpense = 300 |
|
1373 |
elseif pMode[pIndex] == loc("Reflector Shield") then |
|
1374 |
placedExpense = 200 |
|
11713
d5d798172875
Fix crate costs in Construction Mode being all the same (fixes #15)
Wuzzy <almikes@aol.com>
parents:
11301
diff
changeset
|
1375 |
elseif cat[cIndex] == "Weapon Crate Placement Mode" then |
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
1376 |
placedExpense = atkArray[pIndex][4] |
11713
d5d798172875
Fix crate costs in Construction Mode being all the same (fixes #15)
Wuzzy <almikes@aol.com>
parents:
11301
diff
changeset
|
1377 |
elseif cat[cIndex] == "Utility Crate Placement Mode" then |
11986
acae870a66b9
Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents:
11947
diff
changeset
|
1378 |
placedExpense = utilArray[pIndex][4] |
11015 | 1379 |
end |
1380 |
||
1381 |
AddCaption(loc("Cost") .. ": " .. placedExpense,0xffba00ff,capgrpAmmostate) |
|
1382 |
||
1383 |
end |
|
1384 |
||
11722
f35139700d22
Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents:
11721
diff
changeset
|
1385 |
function onTimer(key) |
f35139700d22
Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents:
11721
diff
changeset
|
1386 |
|
f35139700d22
Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents:
11721
diff
changeset
|
1387 |
checkForSpecialWeaponsIn = 1 |
f35139700d22
Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents:
11721
diff
changeset
|
1388 |
|
f35139700d22
Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents:
11721
diff
changeset
|
1389 |
end |
f35139700d22
Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents:
11721
diff
changeset
|
1390 |
|
11015 | 1391 |
function onLeft() |
1392 |
||
1393 |
pIndex = pIndex - 1 |
|
1394 |
if pIndex == 0 then |
|
1395 |
pIndex = #pMode |
|
1396 |
end |
|
1397 |
||
1398 |
if (curWep == amGirder) or (curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) then |
|
11719
8575b8b76373
Construction Mode: Show mine timer in seconds
Wuzzy <almikes@aol.com>
parents:
11718
diff
changeset
|
1399 |
showModeMessage() |
11015 | 1400 |
updateCost() |
1401 |
end |
|
1402 |
||
1403 |
||
1404 |
end |
|
1405 |
||
1406 |
function onRight() |
|
1407 |
||
1408 |
pIndex = pIndex + 1 |
|
1409 |
if pIndex > #pMode then |
|
1410 |
pIndex = 1 |
|
1411 |
end |
|
1412 |
||
1413 |
if (curWep == amGirder) or (curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) then |
|
11719
8575b8b76373
Construction Mode: Show mine timer in seconds
Wuzzy <almikes@aol.com>
parents:
11718
diff
changeset
|
1414 |
showModeMessage() |
11015 | 1415 |
updateCost() |
1416 |
end |
|
1417 |
||
1418 |
end |
|
1419 |
||
11735
8cc9c8a43dcc
Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents:
11734
diff
changeset
|
1420 |
function showModeMessage() |
11765
001994046892
Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents:
11764
diff
changeset
|
1421 |
if CurrentHedgehog == nil or band(GetState(CurrentHedgehog), gstHHDriven) == 0 then return end |
11735
8cc9c8a43dcc
Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents:
11734
diff
changeset
|
1422 |
local val = pMode[pIndex] |
8cc9c8a43dcc
Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents:
11734
diff
changeset
|
1423 |
local str |
8cc9c8a43dcc
Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents:
11734
diff
changeset
|
1424 |
if cat[cIndex] == "Mine Placement Mode" then |
8cc9c8a43dcc
Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents:
11734
diff
changeset
|
1425 |
-- timer in seconds |
8cc9c8a43dcc
Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents:
11734
diff
changeset
|
1426 |
str = string.format(loc("%d sec"), div(val, 1000)) |
8cc9c8a43dcc
Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents:
11734
diff
changeset
|
1427 |
elseif cat[cIndex] == "Girder Placement Mode" then |
8cc9c8a43dcc
Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents:
11734
diff
changeset
|
1428 |
str = loc("Girder") |
8cc9c8a43dcc
Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents:
11734
diff
changeset
|
1429 |
elseif cat[cIndex] == "Rubber Placement Mode" then |
8cc9c8a43dcc
Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents:
11734
diff
changeset
|
1430 |
str = loc("Rubber") |
8cc9c8a43dcc
Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents:
11734
diff
changeset
|
1431 |
else |
8cc9c8a43dcc
Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents:
11734
diff
changeset
|
1432 |
str = tostring(val) |
8cc9c8a43dcc
Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents:
11734
diff
changeset
|
1433 |
end |
8cc9c8a43dcc
Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents:
11734
diff
changeset
|
1434 |
AddCaption(str,0xffba00ff,capgrpMessage2) |
8cc9c8a43dcc
Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents:
11734
diff
changeset
|
1435 |
end |
11015 | 1436 |
|
1437 |
function updatePlacementDisplay(pDir) |
|
1438 |
||
1439 |
foundMatch = false |
|
1440 |
while(foundMatch == false) do |
|
1441 |
cIndex = cIndex + pDir |
|
1442 |
||
1443 |
if (cIndex == 1) or (cIndex == 2) then --1 --we no longer hit girder by normal means |
|
1444 |
cIndex = #cat |
|
1445 |
elseif cIndex > #cat then |
|
1446 |
cIndex = 3 -- 2 ----we no longer hit girder by normal means |
|
1447 |
end |
|
1448 |
||
1449 |
if sProx[cIndex][2] == true then |
|
1450 |
if (GetCurAmmoType() == amNapalm) then |
|
1451 |
if (sProx[cIndex][1] == loc("Health Crate Placement Mode")) or |
|
1452 |
(sProx[cIndex][1] == loc("Weapon Crate Placement Mode")) or |
|
1453 |
(sProx[cIndex][1] == loc("Utility Crate Placement Mode")) |
|
1454 |
then |
|
1455 |
foundMatch = true |
|
1456 |
end |
|
1457 |
elseif (GetCurAmmoType() == amDrillStrike) then |
|
1458 |
if (sProx[cIndex][1] == loc("Mine Placement Mode")) or |
|
1459 |
(sProx[cIndex][1] == loc("Sticky Mine Placement Mode")) or |
|
1460 |
(sProx[cIndex][1] == loc("Barrel Placement Mode")) |
|
1461 |
then |
|
1462 |
foundMatch = true |
|
1463 |
end |
|
1464 |
elseif (GetCurAmmoType() == amAirAttack) then |
|
1465 |
if sProx[cIndex][1] == loc("Structure Placement Mode") then |
|
1466 |
foundMatch = true |
|
1467 |
end |
|
1468 |
end |
|
1469 |
end |
|
1470 |
||
1471 |
||
1472 |
if foundMatch == true then |
|
1473 |
RedefineSubset() |
|
1474 |
updateCost() |
|
1475 |
end |
|
1476 |
||
1477 |
end |
|
1478 |
||
1479 |
end |
|
1480 |
||
1481 |
--------------------------------------------------------- |
|
1482 |
-- Cycle through primary categories (by changing cIndex) |
|
1483 |
-- i.e mine, sticky mine, barrels |
|
1484 |
-- health/weapon/utility crate, placement of gears |
|
1485 |
--------------------------------------------------------- |
|
1486 |
function onUp() |
|
1487 |
||
11720
511d0f2aa9bf
Construction Mode: Disable up/down in building mode
Wuzzy <almikes@aol.com>
parents:
11719
diff
changeset
|
1488 |
if ( (curWep == amNapalm) or (curWep == amDrillStrike) ) then |
11765
001994046892
Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents:
11764
diff
changeset
|
1489 |
if CurrentHedgehog ~= nil or band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 then |
001994046892
Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents:
11764
diff
changeset
|
1490 |
updatePlacementDisplay(-1) |
001994046892
Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents:
11764
diff
changeset
|
1491 |
end |
11015 | 1492 |
end |
1493 |
||
1494 |
end |
|
1495 |
||
1496 |
function onDown() |
|
1497 |
||
11720
511d0f2aa9bf
Construction Mode: Disable up/down in building mode
Wuzzy <almikes@aol.com>
parents:
11719
diff
changeset
|
1498 |
if ( (curWep == amNapalm) or (curWep == amDrillStrike) ) then |
11765
001994046892
Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents:
11764
diff
changeset
|
1499 |
if CurrentHedgehog ~= nil or band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 then |
001994046892
Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents:
11764
diff
changeset
|
1500 |
updatePlacementDisplay(1) |
001994046892
Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents:
11764
diff
changeset
|
1501 |
end |
11015 | 1502 |
end |
1503 |
||
1504 |
end |
|
1505 |
||
1506 |
---------------------------- |
|
1507 |
-- standard event handlers |
|
1508 |
---------------------------- |
|
1509 |
||
11725
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1510 |
-- Parses a positive integer |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1511 |
function parseInt(str, default) |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1512 |
if str == nil then return default end |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1513 |
local s = string.match(str, "(%d*)") |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1514 |
if s ~= nil then |
11733
373150be0356
Construction Mode: Sanity-check numbers from script parameter
Wuzzy <almikes@aol.com>
parents:
11732
diff
changeset
|
1515 |
return math.min(4294967295, math.max(0, tonumber(s))) |
11725
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1516 |
else |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1517 |
return nil |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1518 |
end |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1519 |
end |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1520 |
|
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1521 |
-- Parse parameters |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1522 |
function onParameters() |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1523 |
parseParams() |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1524 |
conf_initialEnergy = parseInt(params["initialenergy"], conf_initialEnergy) |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1525 |
conf_energyPerRound = parseInt(params["energyperround"], conf_energyPerRound) |
11733
373150be0356
Construction Mode: Sanity-check numbers from script parameter
Wuzzy <almikes@aol.com>
parents:
11732
diff
changeset
|
1526 |
if params["maxenergy"] == "inf" then |
373150be0356
Construction Mode: Sanity-check numbers from script parameter
Wuzzy <almikes@aol.com>
parents:
11732
diff
changeset
|
1527 |
conf_maxEnergy = "inf" |
373150be0356
Construction Mode: Sanity-check numbers from script parameter
Wuzzy <almikes@aol.com>
parents:
11732
diff
changeset
|
1528 |
else |
373150be0356
Construction Mode: Sanity-check numbers from script parameter
Wuzzy <almikes@aol.com>
parents:
11732
diff
changeset
|
1529 |
conf_maxEnergy = parseInt(params["maxenergy"], conf_maxEnergy) |
373150be0356
Construction Mode: Sanity-check numbers from script parameter
Wuzzy <almikes@aol.com>
parents:
11732
diff
changeset
|
1530 |
end |
11725
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1531 |
end |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1532 |
|
11015 | 1533 |
function onGameInit() |
1534 |
||
1535 |
Explosives = 0 |
|
1536 |
MinesNum = 0 |
|
1537 |
||
1538 |
EnableGameFlags(gfInfAttack) |
|
1539 |
||
11886
34ede05e4d4f
Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents:
11767
diff
changeset
|
1540 |
fortMode = MapGen == mgForts |
11738
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1541 |
|
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1542 |
-- if there are forts, let engine place the hogs on them |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1543 |
if fortMode then |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1544 |
EnableGameFlags(gfDivideTeams) |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1545 |
end |
11015 | 1546 |
|
1547 |
RedefineSubset() |
|
1548 |
||
1549 |
end |
|
1550 |
||
1551 |
function initialSetup(gear) |
|
1552 |
||
11738
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1553 |
-- engine already placed hogs in fort mode |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1554 |
if not fortMode then |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1555 |
FindPlace(gear, false, clanBoundsSX[GetHogClan(gear)], clanBoundsEX[GetHogClan(gear)],true) |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1556 |
end |
11015 | 1557 |
|
1558 |
-- for now, everyone should have this stuff |
|
1559 |
AddAmmo(gear, amAirAttack, 100) |
|
1560 |
AddAmmo(gear, amSwitch, 100) |
|
1561 |
AddAmmo(gear, amSkip, 100) |
|
1562 |
||
1563 |
end |
|
1564 |
||
1565 |
function onGameStart() |
|
1566 |
||
1567 |
trackTeams() |
|
1568 |
||
1569 |
ShowMission ( |
|
1570 |
loc("CONSTRUCTION MODE"), |
|
1571 |
loc("a Hedgewars mini-game"), |
|
1572 |
loc("Build a fortress and destroy your enemy.") .. "|" .. |
|
1573 |
loc("There are a variety of structures available to aid you.") .. "|" .. |
|
11947
abdb24f0c2d9
Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents:
11886
diff
changeset
|
1574 |
loc("Use the structure placer to place structures.") |
11730
3444792e8ebe
Construction Mode: Remove 2 useless blank lines in mission panel
Wuzzy <almikes@aol.com>
parents:
11729
diff
changeset
|
1575 |
, 4, 5000 |
11015 | 1576 |
) |
1577 |
||
11947
abdb24f0c2d9
Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents:
11886
diff
changeset
|
1578 |
SetAmmoTexts(amAirAttack, loc("Structure Placer"), loc("Construction Mode tool"), loc("Build one of multiple different structures|to aid you in victory, at the cost of energy.") .. "| |" .. |
abdb24f0c2d9
Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents:
11886
diff
changeset
|
1579 |
loc("Healing Station: Heals nearby hogs.") .. "|" .. |
abdb24f0c2d9
Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents:
11886
diff
changeset
|
1580 |
loc("Bio-Filter: Aggressively removes enemies.") .. "|" .. |
abdb24f0c2d9
Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents:
11886
diff
changeset
|
1581 |
loc("Weapon Filter: Dematerializes all ammo| carried by enemies entering it.") .. "|" .. |
abdb24f0c2d9
Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents:
11886
diff
changeset
|
1582 |
loc("Reflector Shield: Reflects enemy projectiles.") .. "|" .. |
abdb24f0c2d9
Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents:
11886
diff
changeset
|
1583 |
loc("Generator: Generates energy.") .. "|" .. |
abdb24f0c2d9
Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents:
11886
diff
changeset
|
1584 |
loc("Respawner: Resurrects dead hogs.") .. "|" .. |
abdb24f0c2d9
Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents:
11886
diff
changeset
|
1585 |
loc("Teleportation Node: Allows teleportation| between other nodes.") .. "|" .. |
abdb24f0c2d9
Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents:
11886
diff
changeset
|
1586 |
loc("Construction Station: Allows placement of| girders, rubber, mines, sticky mines| and barrels.") .. "|" .. |
abdb24f0c2d9
Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents:
11886
diff
changeset
|
1587 |
loc("Support Station: Allows placement of crates.") .. "| |" .. |
abdb24f0c2d9
Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents:
11886
diff
changeset
|
1588 |
|
abdb24f0c2d9
Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents:
11886
diff
changeset
|
1589 |
loc("Left/right: Choose structure type|Cursor: Build structure")) |
abdb24f0c2d9
Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents:
11886
diff
changeset
|
1590 |
|
abdb24f0c2d9
Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents:
11886
diff
changeset
|
1591 |
SetAmmoTexts(amNapalm, loc("Crate Placer"), loc("Construction Mode tool"), loc("This allows you to create a crate anywhere|within your clan's area of influence,|at the cost of energy.|Up/down: Choose crate type|Left/right: Choose crate contents|Cursor: Place crate")) |
abdb24f0c2d9
Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents:
11886
diff
changeset
|
1592 |
SetAmmoTexts(amDrillStrike, loc("Object Placer"), loc("Construction Mode tool"), loc("This allows you to create and place mines,|sticky mines and barrels anywhere within your|clan's area of influence at the cost of energy.|Up/down: Choose object type|Left/right: Choose timer (for mines)|Cursor: Place object")) |
11015 | 1593 |
|
1594 |
sCirc = AddVisualGear(0,0,vgtCircle,0,true) |
|
1595 |
SetVisualGearValues(sCirc, 0, 0, 100, 255, 1, 10, 0, 40, 3, 0x00000000) |
|
1596 |
||
1597 |
for i = 0, ClansCount-1 do |
|
11987
6f4b96669f9d
Fix Construction Mode screwing up when initialenergy > maxenergy
Wuzzy <almikes@aol.com>
parents:
11986
diff
changeset
|
1598 |
clanPower[i] = math.min(conf_initialEnergy, conf_maxEnergy) |
11015 | 1599 |
clanLWepIndex[i] = 1 -- for ease of use let's track this stuff |
1600 |
clanLUtilIndex[i] = 1 |
|
1601 |
clanLGearIndex[i] = 1 |
|
1602 |
clanUsedExtraTime[i] = false |
|
1603 |
clanCratesSpawned[i] = 0 |
|
11726
8c1a30d4cbc8
Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents:
11725
diff
changeset
|
1604 |
clanFirstTurn[i] = true |
11015 | 1605 |
|
1606 |
end |
|
1607 |
||
1608 |
tMapWidth = RightX - LeftX |
|
1609 |
tMapHeight = WaterLine - TopY |
|
1610 |
clanInterval = div(tMapWidth,ClansCount) |
|
1611 |
||
11738
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1612 |
-- define construction areas for each clan |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1613 |
-- if there are forts-based spawn locations, adjust areas around them |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1614 |
for i = 0, ClansCount-1 do |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1615 |
local slot |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1616 |
if fortMode then |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1617 |
slot = div(GetX(getFirstHogOfClan(i))-LeftX,clanInterval) |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1618 |
else |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1619 |
slot = i |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1620 |
end |
11015 | 1621 |
|
11738
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1622 |
local color = GetClanColor(i) |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1623 |
|
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1624 |
clanBoundsSX[i] = LeftX+(clanInterval*slot)+20 |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1625 |
clanBoundsSY[i] = TopY |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1626 |
clanBoundsEX[i] = LeftX+(clanInterval*slot)+clanInterval-20 |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1627 |
clanBoundsEY[i] = WaterLine |
11015 | 1628 |
|
1629 |
--top and bottom |
|
11738
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1630 |
AddWall(LeftX+(clanInterval*slot),TopY,clanInterval,margin,color) |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1631 |
AddWall(LeftX+(clanInterval*slot),WaterLine-25,clanInterval,margin,color) |
11015 | 1632 |
|
1633 |
--add a wall to the left and right |
|
11738
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1634 |
AddWall(LeftX+(clanInterval*slot)+20,TopY,margin,WaterLine,color) |
67049c8dedd1
make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents:
11737
diff
changeset
|
1635 |
AddWall(LeftX+(clanInterval*slot)+clanInterval-20,TopY,margin,WaterLine,color) |
11015 | 1636 |
|
1637 |
end |
|
1638 |
||
1639 |
runOnHogs(initialSetup) |
|
1640 |
||
1641 |
end |
|
1642 |
||
1643 |
||
1644 |
function onNewTurn() |
|
1645 |
||
11725
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1646 |
local clan = GetHogClan(CurrentHedgehog) |
11726
8c1a30d4cbc8
Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents:
11725
diff
changeset
|
1647 |
if clanFirstTurn[clan] then |
8c1a30d4cbc8
Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents:
11725
diff
changeset
|
1648 |
clanFirstTurn[clan] = false |
8c1a30d4cbc8
Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents:
11725
diff
changeset
|
1649 |
else |
8c1a30d4cbc8
Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents:
11725
diff
changeset
|
1650 |
clanPower[clan] = clanPower[clan] + conf_energyPerRound |
11733
373150be0356
Construction Mode: Sanity-check numbers from script parameter
Wuzzy <almikes@aol.com>
parents:
11732
diff
changeset
|
1651 |
if conf_maxEnergy ~= "inf" and clanPower[clan] > conf_maxEnergy then |
11726
8c1a30d4cbc8
Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents:
11725
diff
changeset
|
1652 |
clanPower[clan] = conf_maxEnergy |
8c1a30d4cbc8
Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents:
11725
diff
changeset
|
1653 |
end |
11725
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1654 |
end |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1655 |
clanUsedExtraTime[clan] = false |
5cb2f245ee2f
Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents:
11724
diff
changeset
|
1656 |
clanCratesSpawned[clan] = 0 |
11015 | 1657 |
|
1658 |
end |
|
1659 |
||
1660 |
function onGameTick() |
|
1661 |
HandleHedgeEditor() |
|
1662 |
end |
|
1663 |
||
1664 |
function isATrackedGear(gear) |
|
1665 |
if (GetGearType(gear) == gtHedgehog) or |
|
1666 |
(GetGearType(gear) == gtTarget) or |
|
1667 |
(GetGearType(gear) == gtCase) |
|
1668 |
then |
|
1669 |
return(true) |
|
1670 |
else |
|
1671 |
return(false) |
|
1672 |
end |
|
1673 |
end |
|
1674 |
||
1675 |
-- track hedgehogs and placement gears |
|
1676 |
function onGearAdd(gear) |
|
1677 |
||
1678 |
if GetGearType(gear) == gtHedgehog then |
|
1679 |
elseif (GetGearType(gear) == gtAirAttack) or (GetGearType(gear) == gtTeleport) or (GetGearType(gear) == gtGirder) then |
|
1680 |
cGear = gear |
|
1681 |
||
1682 |
end |
|
1683 |
||
1684 |
if isATrackedGear(gear) then |
|
1685 |
trackGear(gear) |
|
1686 |
elseif gearCanBeDeflected(gear) then |
|
1687 |
trackGear(gear) |
|
1688 |
setGearReflectionValues(gear) |
|
1689 |
end |
|
1690 |
||
1691 |
end |
|
1692 |
||
1693 |
function onGearDelete(gear) |
|
1694 |
||
1695 |
if GetGearType(gear) == gtTarget then |
|
1696 |
CheckGearForStructureLink(gear) |
|
1697 |
end |
|
1698 |
||
1699 |
if (GetGearType(gear) == gtAirAttack) or (GetGearType(gear) == gtTeleport) or (GetGearType(gear) == gtGirder) then |
|
1700 |
cGear = nil |
|
1701 |
end |
|
1702 |
||
1703 |
if (isATrackedGear(gear) or gearCanBeDeflected(gear)) then |
|
1704 |
||
1705 |
if getGearValue(gear, "tCirc") ~= nil then |
|
1706 |
DeleteVisualGear(getGearValue(gear, "tCirc")) |
|
1707 |
end |
|
1708 |
||
1709 |
trackDeletion(gear) |
|
1710 |
||
1711 |
end |
|
1712 |
||
1713 |
end |