|
1 --------------------------------------------------------- |
|
2 --- LE CONSTRUCTION MODE 0.7 (badly adapted from Hedge Editor 0.5) |
|
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 ------------------------------------------------------------------------------ |
|
25 --version history |
|
26 ------------------------------------------------------------------------------ |
|
27 --v0.1 |
|
28 -- concept test |
|
29 |
|
30 --v0.2 |
|
31 -- improved documentation (in script and in game) |
|
32 -- improved localisation (or is it? at any rate, crate placement should now say e.g. Bazooka and not amBazooka) |
|
33 -- added variable weapon costs (based on the values from Vatten's Consumerism script) |
|
34 |
|
35 -- added reflector shield (still needs work and balancing) |
|
36 -- added weapon-filter (probably ok) |
|
37 |
|
38 -- enabled super weapons like ballgun, rcplane, watermelon, hellish to test balance |
|
39 -- reduce max money to 1000 |
|
40 |
|
41 --v0.3 |
|
42 -- some /s removed |
|
43 |
|
44 --v0.4 |
|
45 -- added support for per hog ammo (hopefully) |
|
46 |
|
47 --v0.5 (dev) |
|
48 -- added somewhat horribly implemented support for different structure sprites |
|
49 -- added override pictures for ammo menu |
|
50 -- added override message on wep select to aid understanding |
|
51 -- split menu into/between weps/parts: struc, crates, gears |
|
52 -- add a limit on crates per turn |
|
53 -- add a limit on extra time per turn |
|
54 -- add a test level |
|
55 -- restored rubber placement |
|
56 -- cleaned up some of the code a bit and removed about 280 lines of code I didn't need, lol |
|
57 |
|
58 --v0.6 (dev) |
|
59 -- added magic dance |
|
60 |
|
61 --v.07 (pushed to repo) |
|
62 -- added a cfg file |
|
63 -- removed another 903 lines of code we weren't using (lol) |
|
64 |
|
65 -------------------------------- |
|
66 -- STRUCTURES LIST / IDEAS |
|
67 -------------------------------- |
|
68 |
|
69 --Healing Station: heals hogs to 150 life |
|
70 --Teleportation Node: allows teleporting to any other teleporter nodes |
|
71 --Bio-filter: explodes enemy hogs |
|
72 --Respawner: if you have one of these, any slain hogs are resurrected here :D |
|
73 --Generator: generates energy (used to buy stuff, and possibly later other strucs might have upkeep costs) |
|
74 --Support Station: allows purchasing of weapons, utilities, and med-crates |
|
75 --Construction Station: allows purchasing of girders, rubber, mines, sticky mines, barrels |
|
76 --Reflector Shield: reflect projectiles |
|
77 --Weapon Filter: kill all equipement of enemy hogs passing through this area. |
|
78 |
|
79 |
|
80 --to make the grill more attractive make it vaporize flying saucers |
|
81 --and also rope, and maybe incoming gears |
|
82 |
|
83 -- make healing thing also cure poison |
|
84 -- maybe make poison more virulent and dangerous |
|
85 |
|
86 --(not implemented / abandoned ideas) |
|
87 -- Core: allows construction of other structures. |
|
88 -- Automated Turret (think red drones from space invasion) |
|
89 -- Canon (gives access to 3 fireballs per turn while near) |
|
90 -- something that allows control of wind/water |
|
91 -- Gravity Field generator : triggers world gravity change |
|
92 |
|
93 -- structures consume power over time and |
|
94 -- maybe you can turn structures OFF/ON, manually to save power. |
|
95 |
|
96 -- hacking |
|
97 -- allow hacking of structures, either being able to use enemy structures, |
|
98 -- or turning a team's structures against them. |
|
99 |
|
100 -- pylons |
|
101 -- allow hogs to put down a pylon-like gear which then allows the core |
|
102 -- to place other structures/objects within the pylon's sphere of influence |
|
103 -- this would allow aggressive structure advancement |
|
104 |
|
105 -- resouce mining? |
|
106 -- you could designate something like mines, that you could get close to, |
|
107 -- "pick up", and then "drop" back at a central location to simulate |
|
108 -- resource mining. bit complicated/meh, normal power generators probably easier |
|
109 |
|
110 -- it would be cool to have a red mask we could apply over girders |
|
111 -- that would indicate they were Indestructible |
|
112 |
|
113 HedgewarsScriptLoad("/Scripts/Locale.lua") |
|
114 HedgewarsScriptLoad("/Scripts/Tracker.lua") |
|
115 |
|
116 ---------------------------------------------- |
|
117 -- STRUC CRAP |
|
118 ---------------------------------------------- |
|
119 |
|
120 strucID = {} |
|
121 strucGear = {} |
|
122 strucClan = {} |
|
123 strucType = {} |
|
124 strucCost = {} |
|
125 strucHealth = {} |
|
126 |
|
127 strucCirc = {} |
|
128 strucCircCol = {} |
|
129 strucCircRadius = {} |
|
130 strucCircType = {} |
|
131 strucAltDisplay = {} |
|
132 |
|
133 placedExpense = 0 |
|
134 |
|
135 tempID = nil |
|
136 |
|
137 sUID = 0 |
|
138 |
|
139 colorRed = 0xff0000ff |
|
140 colorGreen = 0x00ff00ff |
|
141 |
|
142 clanBoundsSX = {} |
|
143 clanBoundsSY = {} |
|
144 clanBoundsEX = {} |
|
145 clanBoundsEY = {} |
|
146 |
|
147 clanPower = {} |
|
148 clanBoon = {} |
|
149 clanID = {} |
|
150 clanLStrucIndex = {} |
|
151 |
|
152 clanLWepIndex = {} -- for ease of use let's track this stuff |
|
153 clanLUtilIndex = {} |
|
154 clanLGearIndex = {} |
|
155 clanUsedExtraTime = {} |
|
156 clanCratesSpawned = {} |
|
157 |
|
158 effectTimer = 0 |
|
159 |
|
160 wallsVisible = false |
|
161 wX = {} |
|
162 wY = {} |
|
163 wWidth = {} |
|
164 wHeight = {} |
|
165 wCol = {} |
|
166 margin = 20 |
|
167 |
|
168 tauntString = "" |
|
169 |
|
170 vTag = {} |
|
171 lastWep = nil |
|
172 |
|
173 function HideTags() |
|
174 |
|
175 for i = 0, 2 do |
|
176 SetVisualGearValues(vTag[i],0,0,0,0,0,1,0, 0, 240000, 0xffffff00) |
|
177 end |
|
178 |
|
179 end |
|
180 |
|
181 function DrawTag(i) |
|
182 |
|
183 zoomL = 1.3 |
|
184 |
|
185 xOffset = 40 |
|
186 |
|
187 if i == 0 then |
|
188 yOffset = 40 |
|
189 tCol = 0xffba00ff |
|
190 tValue = 30--TimeLeft |
|
191 elseif i == 1 then |
|
192 zoomL = 1.1 |
|
193 xOffset = 45 |
|
194 yOffset = 70 |
|
195 tCol = 0x00ff00ff |
|
196 tValue = clanPower[GetHogClan(CurrentHedgehog)] |
|
197 elseif i == 2 then |
|
198 zoomL = 1.1 |
|
199 xOffset = 60 + 35 |
|
200 yOffset = 70 |
|
201 tCol = 0xa800ffff |
|
202 tValue = 10--shieldHealth - 80 |
|
203 end |
|
204 |
|
205 DeleteVisualGear(vTag[i]) |
|
206 vTag[i] = AddVisualGear(0, 0, vgtHealthTag, 0, false) |
|
207 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vTag[i]) |
|
208 SetVisualGearValues ( |
|
209 vTag[i], --id |
|
210 -div(ScreenWidth,2) + xOffset, --xoffset |
|
211 ScreenHeight - yOffset, --yoffset |
|
212 0, --dx |
|
213 0, --dy |
|
214 zoomL, --zoom |
|
215 1, --~= 0 means align to screen |
|
216 g7, --frameticks |
|
217 tValue, --value |
|
218 240000, --timer |
|
219 tCol --GetClanColor( GetHogClan(CurrentHedgehog) ) |
|
220 ) |
|
221 |
|
222 end |
|
223 |
|
224 function onScreenResize() |
|
225 |
|
226 -- redraw Tags so that their screen locations are updated |
|
227 if (CurrentHedgehog ~= nil) then |
|
228 DrawTag(0) |
|
229 DrawTag(1) |
|
230 DrawTag(2) |
|
231 end |
|
232 |
|
233 end |
|
234 |
|
235 function XYisInRect(px, py, psx, psy, pex, pey) |
|
236 |
|
237 if (px > psx) and (px < pex) and (py > psy) and (py < pey) then |
|
238 return(true) |
|
239 else |
|
240 return(false) |
|
241 end |
|
242 |
|
243 end |
|
244 |
|
245 function AddWall(zXMin,zYMin, zWidth, zHeight, zCol) |
|
246 |
|
247 table.insert(wX, zXMin) |
|
248 table.insert(wY, zYMin) |
|
249 table.insert(wWidth, zWidth) |
|
250 table.insert(wHeight, zHeight) |
|
251 table.insert(wCol, zCol) |
|
252 |
|
253 end |
|
254 |
|
255 function BorderSpark(zXMin,zYMin, zWidth, zHeight, bCol) |
|
256 |
|
257 eX = zXMin + GetRandom(zWidth+10) |
|
258 eY = zYMin + GetRandom(zHeight+10) |
|
259 tempE = AddVisualGear(eX, eY, vgtDust, 0, false) |
|
260 if tempE ~= 0 then |
|
261 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) |
|
262 SetVisualGearValues(tempE, eX, eY, g3, g4, g5, g6, g7, 1, g9, bCol ) |
|
263 end |
|
264 |
|
265 end |
|
266 |
|
267 function HandleBorderEffects() |
|
268 |
|
269 effectTimer = effectTimer + 1 |
|
270 if effectTimer > 15 then --25 |
|
271 effectTimer = 1 |
|
272 for i = 1, #wX do |
|
273 BorderSpark(wX[i],wY[i],wWidth[i],wHeight[i], wCol[i]) |
|
274 end |
|
275 end |
|
276 |
|
277 end |
|
278 |
|
279 ---- |
|
280 -- old reflecting stuff from like 3 years ago lol |
|
281 --- |
|
282 |
|
283 function gearCanBeDeflected(gear) |
|
284 |
|
285 if (GetGearType(gear) == gtShell) or |
|
286 --(GetGearType(gear) == gtBee) or |
|
287 (GetGearType(gear) == gtGrenade) or |
|
288 (GetGearType(gear) == gtAirBomb) or |
|
289 --(GetGearType(gear) == gtRCPlane) or |
|
290 --(GetGearType(gear) == gtRope) or |
|
291 (GetGearType(gear) == gtClusterBomb) or |
|
292 (GetGearType(gear) == gtCluster) or |
|
293 (GetGearType(gear) == gtGasBomb) or |
|
294 --(GetGearType(gear) == gtSeduction) or |
|
295 (GetGearType(gear) == gtMine) or ------- |
|
296 (GetGearType(gear) == gtMortar) or |
|
297 (GetGearType(gear) == gtHellishBomb) or |
|
298 (GetGearType(gear) == gtWatermelon) or |
|
299 (GetGearType(gear) == gtMelonPiece) or |
|
300 (GetGearType(gear) == gtEgg) or |
|
301 (GetGearType(gear) == gtDrill) or |
|
302 (GetGearType(gear) == gtBall) or |
|
303 (GetGearType(gear) == gtExplosives) or ------ |
|
304 (GetGearType(gear) == gtFlame) or |
|
305 (GetGearType(gear) == gtPortal) or |
|
306 (GetGearType(gear) == gtDynamite) or |
|
307 (GetGearType(gear) == gtSMine) or |
|
308 --(GetGearType(gear) == gtKamikaze) or |
|
309 --(GetGearType(gear) == gtRCPlane) or |
|
310 --(GetGearType(gear) == gtCake) or |
|
311 --(GetGearType(gear) == gtHedgehog) or ------ |
|
312 (GetGearType(gear) == gtKnife) or |
|
313 (GetGearType(gear) == gtJetpack) or -- test this and birdy plz |
|
314 (GetGearType(gear) == gtBirdy) or -- test this and birdy plz |
|
315 (GetGearType(gear) == gtSnowball) or |
|
316 (GetGearType(gear) == gtMolotov) |
|
317 then |
|
318 return(true) |
|
319 else |
|
320 return(false) |
|
321 end |
|
322 |
|
323 end |
|
324 |
|
325 function getThreatDamage(gear) |
|
326 |
|
327 --- damage amounts for weapons |
|
328 if (GetGearType(gear) == gtGrenade) or |
|
329 (GetGearType(gear) == gtClusterBomb) or |
|
330 (GetGearType(gear) == gtGasBomb) or |
|
331 (GetGearType(gear) == gtKnife) or |
|
332 (GetGearType(gear) == gtEgg) or |
|
333 (GetGearType(gear) == gtMolotov) or |
|
334 (GetGearType(gear) == gtHellishBomb) or |
|
335 (GetGearType(gear) == gtWatermelon) or |
|
336 (GetGearType(gear) == gtSMine) |
|
337 then |
|
338 dmg = 30 |
|
339 |
|
340 elseif (GetGearType(gear) == gtMelonPiece) then |
|
341 dmg = 40 |
|
342 |
|
343 elseif (GetGearType(gear) == gtAirBomb) or |
|
344 (GetGearType(gear) == gtDrill) or |
|
345 (GetGearType(gear) == gtMine) or |
|
346 (GetGearType(gear) == gtCluster) then |
|
347 dmg = 20 |
|
348 |
|
349 elseif (GetGearType(gear) == gtFlame) or |
|
350 (GetGearType(gear) == gtPortal) or |
|
351 (GetGearType(gear) == gtDynamite) |
|
352 --(GetGearType(gear) == gtKamikaze) or |
|
353 --(GetGearType(gear) == gtRCPlane) or |
|
354 |
|
355 --(GetGearType(gear) == gtCake) |
|
356 then |
|
357 dmg = 0 |
|
358 |
|
359 elseif (GetGearType(gear) == gtBall) then |
|
360 dmg = 1 |
|
361 |
|
362 else --normal shell, snowball etc |
|
363 dmg = 65 |
|
364 end |
|
365 |
|
366 return(dmg) |
|
367 |
|
368 end |
|
369 |
|
370 function setGearReflectionValues(gear) |
|
371 |
|
372 dmg = getThreatDamage(gear) |
|
373 setGearValue(gear,"damage",dmg) |
|
374 setGearValue(gear,"deflects",0) |
|
375 |
|
376 if (CurrentHedgehog ~= nil) then --and (gameStarted == true) then |
|
377 setGearValue(gear,"owner",GetHogClan(CurrentHedgehog)) -- NEW NEEDS CHANGE? |
|
378 else |
|
379 setGearValue(gear,"owner",10) -- nil |
|
380 end |
|
381 |
|
382 end |
|
383 |
|
384 function AddStruc(pX,pY, pType, pClan) |
|
385 |
|
386 sUID = sUID + 1 |
|
387 |
|
388 tempG = AddGear(0, 0, gtTarget, 0, 0, 0, 0) |
|
389 SetGearPosition(tempG, pX, pY) |
|
390 setGearValue(tempG, "sUID", sUID) |
|
391 |
|
392 tempCirc = AddVisualGear(0,0,vgtCircle,0,true) |
|
393 |
|
394 SetVisualGearValues(tempCirc, 0, 0, 100, 255, 1, 100, 0, 500, 1, 0xFFFFFF00) |
|
395 |
|
396 table.insert(strucID, sUID) |
|
397 table.insert(strucType, pType) |
|
398 table.insert(strucGear,tempG) |
|
399 table.insert(strucClan,pClan) |
|
400 table.insert(strucCost,2) |
|
401 |
|
402 frameID = 0 |
|
403 visualSprite = sprTarget |
|
404 madness = AddVisualGear(GetX(tempG), GetY(tempG), vgtStraightShot, 1, true,1) |
|
405 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(madness) --g9 |
|
406 |
|
407 |
|
408 if pType == loc("Reflector Shield") then |
|
409 table.insert(strucHealth,255) |
|
410 |
|
411 --SetVisualGearValues(madness, g1, g2, 0, 0, g5, frameID, g7, visualSprite, g9, g10 ) |
|
412 --SetState(tempG, bor(GetState(tempG),gstInvisible) ) |
|
413 --table.insert(strucAltDisplay, madness) |
|
414 |
|
415 else |
|
416 table.insert(strucHealth,1) |
|
417 --table.insert(strucAltDisplay, 1) |
|
418 end |
|
419 |
|
420 table.insert(strucCirc,tempCirc) |
|
421 |
|
422 table.insert(strucCircType, 1) |
|
423 if pType == loc("Bio-Filter") then |
|
424 table.insert(strucCircCol,colorRed) |
|
425 table.insert(strucCircRadius,1000) |
|
426 frameID = 7 |
|
427 elseif pType == loc("Healing Station") then |
|
428 table.insert(strucCircCol,0xFF00FF00) |
|
429 --table.insert(strucCircCol,colorGreen) |
|
430 table.insert(strucCircRadius,500) |
|
431 frameID = 3 |
|
432 elseif pType == loc("Respawner") then |
|
433 table.insert(strucCircCol,0xFF00FF00) |
|
434 --table.insert(strucCircCol,0xFF00FFFF) |
|
435 table.insert(strucCircRadius,75) |
|
436 runOnHogs(EnableHogResurrectionForThisClan) |
|
437 frameID = 1 |
|
438 elseif pType == loc("Teleportation Node") then |
|
439 table.insert(strucCircCol,0x0000FFFF) |
|
440 table.insert(strucCircRadius,350) |
|
441 frameID = 6 |
|
442 elseif pType == loc("Core") then |
|
443 table.insert(strucCircCol,0xFFFFFFFF) |
|
444 table.insert(strucCircRadius,350) |
|
445 elseif pType == loc("Generator") then |
|
446 table.insert(strucCircCol,0xFFFF00FF) |
|
447 table.insert(strucCircRadius,75) |
|
448 setGearValue(tempG, "power", 0) |
|
449 frameID = 2 |
|
450 elseif pType == loc("Support Station") then |
|
451 table.insert(strucCircCol,0xFFFF00FF) |
|
452 table.insert(strucCircRadius,500) |
|
453 frameID = 4 |
|
454 elseif pType == loc("Construction Station") then |
|
455 table.insert(strucCircCol,0xFFFFFFFF) |
|
456 table.insert(strucCircRadius,500) |
|
457 frameID = 8 |
|
458 elseif pType == loc("Reflector Shield") then |
|
459 table.insert(strucCircCol,0xffae00ff) |
|
460 table.insert(strucCircRadius,750) |
|
461 frameID = 9 |
|
462 elseif pType == loc("Weapon Filter") then |
|
463 table.insert(strucCircCol,0xa800ffff) |
|
464 table.insert(strucCircRadius,750) |
|
465 frameID = 5 |
|
466 end |
|
467 |
|
468 |
|
469 SetVisualGearValues(madness, g1, g2, 0, 0, g5, frameID, g7, visualSprite, g9, g10 ) |
|
470 SetState(tempG, bor(GetState(tempG),gstInvisible) ) |
|
471 table.insert(strucAltDisplay, madness) |
|
472 |
|
473 -- may be needed for non gear-based structures |
|
474 --table.insert(strucX, GetX(tempG)) |
|
475 --table.insert(strucY, GetY(tempG)) |
|
476 |
|
477 end |
|
478 |
|
479 -- this is basically onStructureDelete |
|
480 -- we may need to expand it for non-gear structures later |
|
481 function CheckGearForStructureLink(gear) |
|
482 |
|
483 respawnerDestroyed = false |
|
484 |
|
485 for i = 1, #strucID do |
|
486 if strucID[i] == getGearValue(gear,"sUID") then |
|
487 |
|
488 if strucType[i] == loc("Respawner") then |
|
489 respawnerDestroyed = true |
|
490 end |
|
491 |
|
492 table.remove(strucID,i) |
|
493 table.remove(strucGear,i) |
|
494 table.remove(strucClan,i) |
|
495 table.remove(strucType,i) |
|
496 table.remove(strucCost,i) |
|
497 table.remove(strucHealth,i) |
|
498 |
|
499 DeleteVisualGear(strucCirc[i]) |
|
500 table.remove(strucCirc,i) |
|
501 |
|
502 table.remove(strucCircCol,i) |
|
503 table.remove(strucCircRadius,i) |
|
504 table.remove(strucCircType,i) |
|
505 |
|
506 if strucAltDisplay[i] ~= 1 then |
|
507 DeleteVisualGear(strucAltDisplay[i]) |
|
508 end |
|
509 table.remove(strucAltDisplay,i) |
|
510 |
|
511 end |
|
512 end |
|
513 |
|
514 if respawnerDestroyed == true then |
|
515 runOnHogs(RecalibrateRespawn) |
|
516 end |
|
517 |
|
518 end |
|
519 |
|
520 -- called when we add a new respawner |
|
521 function EnableHogResurrectionForThisClan(gear) |
|
522 if GetHogClan(gear) == GetHogClan(CurrentHedgehog) then |
|
523 SetEffect(gear, heResurrectable, 1) |
|
524 end |
|
525 end |
|
526 |
|
527 -- this is called when a respawner blows up |
|
528 function RecalibrateRespawn(gear) |
|
529 |
|
530 respawnerList = {} |
|
531 for i = 1, #strucID do |
|
532 if (strucType[i] == loc("Respawner")) and (strucClan[i] == GetHogClan(gear)) then |
|
533 table.insert(respawnerList, i) |
|
534 end |
|
535 end |
|
536 |
|
537 if #respawnerList >= 1 then |
|
538 SetEffect(gear, heResurrectable, 1) |
|
539 else |
|
540 SetEffect(gear, heResurrectable, 0) |
|
541 end |
|
542 |
|
543 end |
|
544 |
|
545 --resposition dead hogs at a respawner if they own one |
|
546 function FindRespawner(gear) |
|
547 |
|
548 respawnerList = {} |
|
549 for i = 1, #strucID do |
|
550 if (strucType[i] == loc("Respawner")) and (strucClan[i] == GetHogClan(gear)) then |
|
551 table.insert(respawnerList, i) |
|
552 end |
|
553 end |
|
554 |
|
555 if #respawnerList >= 1 then |
|
556 i = GetRandom(#respawnerList)+1 |
|
557 SetGearPosition(gear,GetX(strucGear[respawnerList[i]]),GetY(strucGear[respawnerList[i]])-25) |
|
558 AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false) |
|
559 else -- (this should never happen, but just in case) |
|
560 SetEffect(gear, heResurrectable, 0) |
|
561 DeleteGear(gear) |
|
562 end |
|
563 |
|
564 end |
|
565 |
|
566 function onGearResurrect(gear) |
|
567 AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false) |
|
568 FindRespawner(gear) |
|
569 end |
|
570 |
|
571 |
|
572 function CheckTeleport(gear, tX, tY) |
|
573 |
|
574 teleportOriginSuccessful = false |
|
575 teleportDestinationSuccessful = false |
|
576 |
|
577 for i = 1, #strucID do |
|
578 |
|
579 if (strucType[i] == loc("Teleportation Node")) and (strucClan[i] == GetHogClan(CurrentHedgehog)) then |
|
580 |
|
581 dist = GetDistFromGearToXY(CurrentHedgehog,GetX(strucGear[i]), GetY(strucGear[i])) |
|
582 if strucCircType[i] == 0 then |
|
583 NR = strucCircRadius[i] |
|
584 else |
|
585 NR = (48/100*strucCircRadius[i])/2 |
|
586 --NR = div((div(48,100) * strucCircRadius[tempID]),2) |
|
587 end |
|
588 if dist <= NR*NR then |
|
589 teleportOriginSuccessful = true |
|
590 end |
|
591 |
|
592 dist = GetDistFromXYtoXY(tX,tY,GetX(strucGear[i]), GetY(strucGear[i])) |
|
593 if strucCircType[i] == 0 then |
|
594 NR = strucCircRadius[i] |
|
595 else |
|
596 NR = (48/100*strucCircRadius[i])/2 |
|
597 --NR = div((div(48,100) * strucCircRadius[tempID]),2) |
|
598 end |
|
599 if dist <= NR*NR then |
|
600 teleportDestinationSuccessful = true |
|
601 end |
|
602 |
|
603 end |
|
604 |
|
605 |
|
606 end |
|
607 |
|
608 if ((teleportDestinationSuccessful == false) or (teleportOriginSuccessful == false)) then |
|
609 AddCaption(loc("Teleport Unsuccessful. Please teleport within a clan teleporter's sphere of influence.")) |
|
610 SetGearTarget(gear, GetX(CurrentHedgehog), GetY(CurrentHedgehog)) |
|
611 end |
|
612 |
|
613 end |
|
614 |
|
615 --Check for proximity of gears to structures, and make structures behave accordingly |
|
616 function CheckProximity(gear) |
|
617 |
|
618 --if isAStructureEffectingGear(gear) then |
|
619 |
|
620 dist = GetDistFromGearToXY(gear, GetX(strucGear[tempID]), GetY(strucGear[tempID])) |
|
621 |
|
622 -- calculate my real radius if I am an aura |
|
623 if strucCircType[tempID] == 0 then |
|
624 NR = strucCircRadius[tempID] |
|
625 else |
|
626 NR = (48/100*strucCircRadius[tempID])/2 |
|
627 --NR = div((div(48,100) * strucCircRadius[tempID]),2) -- doesn't work ffff |
|
628 --NR = div((48/100*strucCircRadius[tempID]),2) -- still works |
|
629 |
|
630 end |
|
631 |
|
632 -- we're in business |
|
633 if dist <= NR*NR then |
|
634 |
|
635 |
|
636 -- heal clan hogs |
|
637 if strucType[tempID] == loc("Healing Station") then |
|
638 |
|
639 if GetGearType(gear) == gtHedgehog then |
|
640 if GetHogClan(gear) == strucClan[tempID] then |
|
641 |
|
642 hogLife = GetHealth(gear) + 1 |
|
643 if hogLife > 150 then |
|
644 hogLife = 150 |
|
645 end |
|
646 SetHealth(gear, hogLife) |
|
647 |
|
648 -- change this to the med kit sprite health ++++s later |
|
649 tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true) |
|
650 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) |
|
651 SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, colorGreen ) |
|
652 |
|
653 |
|
654 end |
|
655 end |
|
656 |
|
657 -- explode enemy clan hogs |
|
658 elseif strucType[tempID] == loc("Bio-Filter") then |
|
659 |
|
660 --tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true) |
|
661 --g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) |
|
662 --SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, colorRed ) |
|
663 |
|
664 if GetGearType(gear) == gtHedgehog then |
|
665 if (GetHogClan(gear) ~= strucClan[tempID]) and (GetHealth(gear) > 0) then |
|
666 AddGear(GetX(gear), GetY(gear), gtGrenade, 0, 0, 0, 1) |
|
667 end |
|
668 end |
|
669 |
|
670 -- were those weapons in your pocket, or were you just happy to see me? |
|
671 elseif strucType[tempID] == loc("Weapon Filter") then |
|
672 |
|
673 if GetGearType(gear) == gtHedgehog then |
|
674 if (GetHogClan(gear) ~= strucClan[tempID]) then |
|
675 |
|
676 for wpnIndex = 1, #atkArray do |
|
677 AddAmmo(gear, atkArray[wpnIndex][1], 0) |
|
678 end |
|
679 |
|
680 for wpnIndex = 1, #utilArray do |
|
681 AddAmmo(gear, utilArray[wpnIndex][1], 0) |
|
682 end |
|
683 |
|
684 AddAmmo(gear, amAirAttack, 100) |
|
685 AddAmmo(gear, amSwitch, 100) |
|
686 AddAmmo(gear, amSkip, 100) |
|
687 |
|
688 end |
|
689 end |
|
690 |
|
691 -- BOUNCE! POGO! POGO! POGO! POGO! |
|
692 elseif strucType[tempID] == loc("Reflector Shield") then |
|
693 |
|
694 -- add check for whose projectile it is |
|
695 if gearCanBeDeflected(gear) == true then |
|
696 |
|
697 gOwner = getGearValue(gear,"owner") |
|
698 gDeflects = getGearValue(gear,"deflects") |
|
699 gDmg = getGearValue(gear,"damage") |
|
700 |
|
701 if gDeflects >= 3 then |
|
702 DeleteGear(gear) |
|
703 AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false) |
|
704 PlaySound(sndVaporize) |
|
705 elseif gOwner ~= strucClan[tempID] then |
|
706 --whether to vaporize gears or bounce them |
|
707 if gDmg ~= 0 then |
|
708 dx, dy = GetGearVelocity(gear) |
|
709 |
|
710 if (dx == 0) and (dy == 0) then |
|
711 -- static mine, explosive, etc encountered |
|
712 -- do nothing |
|
713 else |
|
714 |
|
715 --let's bounce something! |
|
716 |
|
717 --if dx == 0 then |
|
718 -- bounce away eggs |
|
719 -- dx = 0.5 |
|
720 --end |
|
721 |
|
722 dx = dx*(-1) |
|
723 dy = dy*(-1) |
|
724 SetGearVelocity(gear,dx,dy) |
|
725 setGearValue(gear,"deflects",(gDeflects+1)) |
|
726 |
|
727 AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false) |
|
728 PlaySound(sndExplosion) |
|
729 |
|
730 strucHealth[tempID] = strucHealth[tempID] - gDmg |
|
731 strucCircCol[tempID] = strucCircCol[tempID] - gDmg |
|
732 |
|
733 if strucHealth[tempID] <= 0 then |
|
734 AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtExplosion, 0, false) |
|
735 DeleteGear(strucGear[tempID]) |
|
736 PlaySound(sndExplosion) |
|
737 end |
|
738 |
|
739 end |
|
740 |
|
741 else |
|
742 DeleteGear(gear) |
|
743 AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false) |
|
744 PlaySound(sndVaporize) |
|
745 end |
|
746 end |
|
747 end |
|
748 |
|
749 --mark as within range of a teleporter node |
|
750 elseif strucType[tempID] == loc("Teleportation Node") then |
|
751 |
|
752 if GetGearType(gear) == gtHedgehog then |
|
753 if GetHogClan(gear) == strucClan[tempID] then |
|
754 --tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true) |
|
755 |
|
756 for i = 1, #sProx do |
|
757 if sProx[i][1] == loc("Teleportation Mode") then |
|
758 sProx[i][2] = true |
|
759 end |
|
760 end |
|
761 |
|
762 end |
|
763 end |
|
764 |
|
765 -- mark as within range of construction station |
|
766 -- and thus allow menu access to placement modes |
|
767 -- for girders, mines, sticky mines and barrels |
|
768 elseif strucType[tempID] == loc("Construction Station") then |
|
769 |
|
770 if GetGearType(gear) == gtHedgehog then |
|
771 if GetHogClan(gear) == strucClan[tempID] then |
|
772 tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true) |
|
773 |
|
774 for i = 1, #sProx do |
|
775 if ((sProx[i][1] == loc("Girder Placement Mode")) |
|
776 or (sProx[i][1] == loc("Rubber Placement Mode")) |
|
777 or (sProx[i][1] == loc("Mine Placement Mode")) |
|
778 or (sProx[i][1] == loc("Sticky Mine Placement Mode")) |
|
779 or (sProx[i][1] == loc("Barrel Placement Mode"))) |
|
780 then |
|
781 sProx[i][2] = true |
|
782 end |
|
783 end |
|
784 |
|
785 |
|
786 end |
|
787 end |
|
788 |
|
789 -- mark as within stupport station range |
|
790 -- and thus allow menu access to placement modes |
|
791 -- for weapon, utility, and med crates |
|
792 elseif strucType[tempID] == loc("Support Station") then |
|
793 |
|
794 if GetGearType(gear) == gtHedgehog then |
|
795 if GetHogClan(gear) == strucClan[tempID] then |
|
796 tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true) |
|
797 |
|
798 for i = 1, #sProx do |
|
799 if ((sProx[i][1] == loc("Health Crate Placement Mode")) |
|
800 or (sProx[i][1] == loc("Weapon Crate Placement Mode")) |
|
801 or (sProx[i][1] == loc("Utility Crate Placement Mode"))) |
|
802 then |
|
803 sProx[i][2] = true |
|
804 --AddCaption("wahey in a support station") |
|
805 end |
|
806 end |
|
807 |
|
808 |
|
809 end |
|
810 end |
|
811 |
|
812 -- doesn't do shit |
|
813 elseif strucType[tempID] == loc("Core") then |
|
814 |
|
815 if GetGearType(gear) == gtHedgehog then |
|
816 if GetHogClan(gear) == strucClan[tempID] then |
|
817 |
|
818 tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true) |
|
819 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) |
|
820 SetVisualGearValues(tempE, g1+20, g2, g3, g4, g5, g6, g7, g8, g9, GetClanColor(strucClan[tempID]) ) |
|
821 |
|
822 tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true) |
|
823 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) |
|
824 SetVisualGearValues(tempE, g1-20, g2, g3, g4, g5, g6, g7, g8, g9, GetClanColor(strucClan[tempID]) ) |
|
825 |
|
826 end |
|
827 end |
|
828 |
|
829 end |
|
830 |
|
831 end |
|
832 |
|
833 --end |
|
834 |
|
835 end |
|
836 |
|
837 -- used to check if we need to run through all hogs or just currenthedgehog |
|
838 function isAStructureThatAppliesToMultipleGears(pID) |
|
839 if strucType[pID] == loc("Healing Station") or |
|
840 strucType[pID] == loc("Reflector Shield") or |
|
841 strucType[pID] == loc("Weapon Filter") or |
|
842 strucType[pID] == loc("Bio-Filter") |
|
843 then |
|
844 return(true) |
|
845 else |
|
846 return(false) |
|
847 end |
|
848 end |
|
849 |
|
850 function HandleStructures() |
|
851 |
|
852 for i = 1, #sProx do |
|
853 sProx[i][2] = false |
|
854 |
|
855 if sProx[i][1] == loc("Structure Placement Mode") then |
|
856 sProx[i][2] = true |
|
857 end |
|
858 |
|
859 end |
|
860 |
|
861 for i = 1, #strucID do |
|
862 |
|
863 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(strucCirc[i]) |
|
864 SetVisualGearValues(strucCirc[i], GetX(strucGear[i]), GetY(strucGear[i]), g3, g4, g5, g6, g7, strucCircRadius[i], g9, strucCircCol[i]) |
|
865 |
|
866 tempID = i |
|
867 |
|
868 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(strucAltDisplay[i]) --8000 |
|
869 SetVisualGearValues(strucAltDisplay[i], GetX(strucGear[i]), GetY(strucGear[i]), 0, 0, g5, g6, 800000, sprTarget, g9, g10 ) |
|
870 |
|
871 |
|
872 |
|
873 -- Check For proximity of stuff to our structures |
|
874 if isAStructureThatAppliesToMultipleGears(i) then |
|
875 runOnGears(CheckProximity) |
|
876 else -- only check prox on CurrentHedgehog |
|
877 CheckProximity(CurrentHedgehog) |
|
878 end |
|
879 |
|
880 if strucType[i] == loc("Core") then |
|
881 tempE = AddVisualGear(GetX(strucGear[i]), GetY(strucGear[i]), vgtSmoke, 0, true) |
|
882 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) |
|
883 SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, GetClanColor(strucClan[i]) ) |
|
884 elseif strucType[i] == loc("Reflector Shield") then |
|
885 |
|
886 |
|
887 |
|
888 --frameID = 1 |
|
889 --visualSprite = sprTarget |
|
890 --g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(strucAltDisplay[i]) --frameID / g6 |
|
891 --SetVisualGearValues(strucAltDisplay[i], GetX(strucGear[i]), GetY(strucGear[i]), 0, 0, g5, g6, 8000, visualSprite, g9, g10 ) |
|
892 |
|
893 elseif strucType[i] == loc("Generator") then |
|
894 |
|
895 --frameID = 1 |
|
896 --visualSprite = sprTarget |
|
897 --layer |
|
898 --tempE = AddVisualGear(GetX(strucGear[i]), GetY(strucGear[i]), vgtStraightShot, 1, true,1) |
|
899 --g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) --g9 |
|
900 --SetVisualGearValues(tempE, g1, g2, 0, 0, g5, frameID, g7, visualSprite, g9, g10 ) |
|
901 --SetState(strucGear[i], bor(GetState(strucGear[i]),gstInvisible) ) |
|
902 |
|
903 --currently generate power for all clans. |
|
904 -- or should power only be generated for current clan? |
|
905 for z = 0, ClansCount-1 do |
|
906 if z == strucClan[i] then |
|
907 increaseGearValue(strucGear[i],"power") |
|
908 if getGearValue(strucGear[i],"power") == 10 then |
|
909 setGearValue(strucGear[i],"power",0) |
|
910 clanPower[z] = clanPower[z] + 1 |
|
911 if clanPower[z] > 1000 then |
|
912 clanPower[z] = 1000 |
|
913 end |
|
914 end |
|
915 |
|
916 end |
|
917 end |
|
918 |
|
919 end |
|
920 |
|
921 end |
|
922 |
|
923 |
|
924 |
|
925 -- this is kinda messy and gross (even more than usual), fix it up at some point |
|
926 -- it just assumes that if you have access to girders, it works for rubbers |
|
927 -- as that is what the struc implemenation means due to construction station |
|
928 anyUIProx = false |
|
929 for i = 1, #sProx do |
|
930 |
|
931 if sProx[i][1] == loc("Girder Placement Mode") then |
|
932 if sProx[i][2] == true then |
|
933 AddAmmo(CurrentHedgehog, amGirder, 100) |
|
934 AddAmmo(CurrentHedgehog, amRubber, 100) |
|
935 AddAmmo(CurrentHedgehog, amDrillStrike, 100) |
|
936 else |
|
937 AddAmmo(CurrentHedgehog, amGirder, 0) |
|
938 AddAmmo(CurrentHedgehog, amRubber, 0) |
|
939 AddAmmo(CurrentHedgehog, amDrillStrike, 0) -- new |
|
940 end |
|
941 elseif sProx[i][1] == loc("Teleportation Mode") then |
|
942 if sProx[i][2] == true then |
|
943 AddAmmo(CurrentHedgehog, amTeleport, 100) |
|
944 else |
|
945 AddAmmo(CurrentHedgehog, amTeleport, 0) |
|
946 end |
|
947 elseif sProx[i][1] == loc("Weapon Crate Placement Mode") then |
|
948 -- this is new stuff |
|
949 if sProx[i][2] == true then |
|
950 AddAmmo(CurrentHedgehog, amNapalm, 100) |
|
951 else |
|
952 AddAmmo(CurrentHedgehog, amNapalm, 0) |
|
953 end |
|
954 end |
|
955 |
|
956 if (sProx[i][2] == true) then |
|
957 anyUIProx = true |
|
958 end |
|
959 |
|
960 end |
|
961 |
|
962 -- doesn't do shit atm, maybe later when we add cores we can use this |
|
963 --if anyUIProx == true then --(and core is placed) |
|
964 -- AddAmmo(CurrentHedgehog, amAirAttack, 100) |
|
965 --else |
|
966 -- AddAmmo(CurrentHedgehog, amAirAttack, 0) |
|
967 --end |
|
968 |
|
969 |
|
970 end |
|
971 |
|
972 |
|
973 function checkForSpecialWeapons() |
|
974 |
|
975 |
|
976 |
|
977 if (GetCurAmmoType() == amAirAttack) then |
|
978 AddCaption(loc("Structure Placement Tool"),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmoinfo) |
|
979 elseif (GetCurAmmoType() == amDrillStrike) then |
|
980 AddCaption(loc("Object Placement Tool"),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmoinfo) |
|
981 elseif (GetCurAmmoType() == amNapalm) then |
|
982 AddCaption(loc("Crate Placement Tool"),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmoinfo) |
|
983 end |
|
984 |
|
985 lastWep = GetCurAmmoType() |
|
986 |
|
987 end |
|
988 |
|
989 ---------------------------------------------------------- |
|
990 -- EXCERPTS OF ADAPTED HEDGE_EDITOR CODE FOLLOWS |
|
991 ---------------------------------------------------------- |
|
992 -- experimental crap |
|
993 |
|
994 local landType = 0 |
|
995 ----------------------------------------- |
|
996 -- tracking vars for save slash load purposes |
|
997 ----------------------------------------- |
|
998 |
|
999 local hhs = {} |
|
1000 |
|
1001 --------------------------------- |
|
1002 -- crates are made of this stuff |
|
1003 --------------------------------- |
|
1004 placeholder = 20 |
|
1005 atkArray = |
|
1006 { |
|
1007 {amBazooka, "amBazooka", 0, loc("Bazooka"), 2*placeholder}, |
|
1008 --{amBee, "amBee", 0, loc("Homing Bee"), 4*placeholder}, |
|
1009 {amMortar, "amMortar", 0, loc("Mortar"), 1*placeholder}, |
|
1010 {amDrill, "amDrill", 0, loc("Drill Rocket"), 3*placeholder}, |
|
1011 {amSnowball, "amSnowball", 0, loc("Mudball"), 3*placeholder}, |
|
1012 |
|
1013 {amGrenade, "amGrenade", 0, loc("Grenade"), 2*placeholder}, |
|
1014 {amClusterBomb, "amClusterBomb", 0, loc("Cluster Bomb"), 3*placeholder}, |
|
1015 {amMolotov, "amMolotov", 0, loc("Molotov Cocktail"), 3*placeholder}, |
|
1016 {amWatermelon, "amWatermelon", 0, loc("Watermelon Bomb"), 25*placeholder}, |
|
1017 {amHellishBomb, "amHellishBomb", 0, loc("Hellish Handgrenade"), 25*placeholder}, |
|
1018 {amGasBomb, "amGasBomb", 0, loc("Limburger"), 3*placeholder}, |
|
1019 |
|
1020 {amShotgun, "amShotgun", 0, loc("Shotgun"), 2*placeholder}, |
|
1021 {amDEagle, "amDEagle", 0, loc("Desert Eagle"), 2*placeholder}, |
|
1022 {amFlamethrower,"amFlamethrower", 0, loc("Flamethrower"), 4*placeholder}, |
|
1023 {amSniperRifle, "amSniperRifle", 0, loc("Sniper Rifle"), 3*placeholder}, |
|
1024 --{amSineGun, "amSineGun", 0, loc("SineGun"), 6*placeholder}, |
|
1025 {amIceGun, "amIceGun", 0, loc("Freezer"), 15*placeholder}, |
|
1026 {amLandGun, "amLandGun", 0, loc("Land Sprayer"), 5*placeholder}, |
|
1027 |
|
1028 {amFirePunch, "amFirePunch", 0, loc("Shoryuken"), 3*placeholder}, |
|
1029 {amWhip, "amWhip", 0, loc("Whip"), 1*placeholder}, |
|
1030 {amBaseballBat, "amBaseballBat", 0, loc("Baseball Bat"), 7*placeholder}, |
|
1031 --{amKamikaze, "amKamikaze", 0, loc("Kamikaze"), 1*placeholder}, |
|
1032 {amSeduction, "amSeduction", 0, loc("Seduction"), 1*placeholder}, |
|
1033 {amHammer, "amHammer", 0, loc("Hammer"), 1*placeholder}, |
|
1034 |
|
1035 {amMine, "amMine", 0, loc("Mine"), 1*placeholder}, |
|
1036 {amDynamite, "amDynamite", 0, loc("Dynamite"), 9*placeholder}, |
|
1037 {amCake, "amCake", 0, loc("Cake"), 25*placeholder}, |
|
1038 {amBallgun, "amBallgun", 0, loc("Ballgun"), 40*placeholder}, |
|
1039 --{amRCPlane, "amRCPlane", 0, loc("RC Plane"), 25*placeholder}, |
|
1040 {amSMine, "amSMine", 0, loc("Sticky Mine"), 5*placeholder}, |
|
1041 |
|
1042 --{amAirAttack, "amAirAttack", 0, loc("Air Attack"), 10*placeholder}, |
|
1043 --{amMineStrike, "amMineStrike", 0, loc("Mine Strike"), 15*placeholder}, |
|
1044 --{amDrillStrike, "amDrillStrike", 0, loc("Drill Strike"), 15*placeholder}, |
|
1045 --{amNapalm, "amNapalm", 0, loc("Napalm"), 15*placeholder}, |
|
1046 --{amPiano, "amPiano", 0, loc("Piano Strike"), 40*placeholder}, |
|
1047 |
|
1048 {amKnife, "amKnife", 0, loc("Cleaver"), 2*placeholder}, |
|
1049 |
|
1050 {amBirdy, "amBirdy", 0, loc("Birdy"), 7*placeholder} |
|
1051 |
|
1052 } |
|
1053 |
|
1054 utilArray = |
|
1055 { |
|
1056 {amBlowTorch, "amBlowTorch", 0, loc("Blowtorch"), 4*placeholder}, |
|
1057 {amPickHammer, "amPickHammer", 0, loc("Pickhammer"), 2*placeholder}, |
|
1058 --{amGirder, "amGirder", 0, loc("Girder"), 4*placeholder}, |
|
1059 --{amRubber, "amRubber", 0, loc("Rubber Band"), 5*placeholder}, |
|
1060 {amPortalGun, "amPortalGun", 0, loc("Personal Portal Device"), 15*placeholder}, |
|
1061 |
|
1062 {amRope, "amRope", 0, loc("Rope"), 7*placeholder}, |
|
1063 {amParachute, "amParachute", 0, loc("Parachute"), 2*placeholder}, |
|
1064 --{amTeleport, "amTeleport", 0, loc("Teleport"), 6*placeholder}, |
|
1065 {amJetpack, "amJetpack", 0, loc("Flying Saucer"), 8*placeholder}, |
|
1066 |
|
1067 {amInvulnerable, "amInvulnerable", 0, loc("Invulnerable"), 5*placeholder}, |
|
1068 {amLaserSight, "amLaserSight", 0, loc("Laser Sight"), 2*placeholder}, |
|
1069 {amVampiric, "amVampiric", 0, loc("Vampirism"), 6*placeholder}, |
|
1070 |
|
1071 {amLowGravity, "amLowGravity", 0, loc("Low Gravity"), 4*placeholder}, |
|
1072 {amExtraDamage, "amExtraDamage", 0, loc("Extra Damage"), 6*placeholder}, |
|
1073 {amExtraTime, "amExtraTime", 0, loc("Extra Time"), 8*placeholder}, |
|
1074 |
|
1075 {amResurrector, "amResurrector", 0, loc("Resurrector"), 8*placeholder}, |
|
1076 {amTardis, "amTardis", 0, loc("Tardis"), 2*placeholder}, |
|
1077 |
|
1078 {amSwitch, "amSwitch", 0, loc("Switch Hog"), 4*placeholder} |
|
1079 } |
|
1080 |
|
1081 ---------------------------- |
|
1082 -- hog and map editting junk |
|
1083 ---------------------------- |
|
1084 |
|
1085 local reducedSpriteIDArray = { |
|
1086 sprBigDigit, sprKowtow, sprBee, sprExplosion50, sprGirder |
|
1087 } |
|
1088 |
|
1089 local reducedSpriteTextArray = { |
|
1090 "sprBigDigit", "sprKowtow", "sprBee", "sprExplosion50", "sprGirder" |
|
1091 } |
|
1092 |
|
1093 ---------------------------- |
|
1094 -- placement shite |
|
1095 ---------------------------- |
|
1096 |
|
1097 local cGear = nil -- detects placement of girders and objects (using airattack) |
|
1098 local curWep = amNothing |
|
1099 |
|
1100 -- primary placement categories |
|
1101 local cIndex = 1 -- category index |
|
1102 local cat = { |
|
1103 "Girder Placement Mode", |
|
1104 "Rubber Placement Mode", |
|
1105 "Mine Placement Mode", |
|
1106 "Sticky Mine Placement Mode", |
|
1107 "Barrel Placement Mode", |
|
1108 "Health Crate Placement Mode", |
|
1109 "Weapon Crate Placement Mode", |
|
1110 "Utility Crate Placement Mode", |
|
1111 --"Target Placement Mode", |
|
1112 --"Cleaver Placement Mode", |
|
1113 |
|
1114 --"Advanced Repositioning Mode", |
|
1115 --"Tagging Mode", |
|
1116 --"Sprite Testing Mode", |
|
1117 --"Sprite Placement Mode", |
|
1118 "Structure Placement Mode" |
|
1119 } |
|
1120 |
|
1121 |
|
1122 sProx = { |
|
1123 {loc("Girder Placement Mode"),false}, |
|
1124 {loc("Rubber Placement Mode"),false}, |
|
1125 {loc("Mine Placement Mode"),false}, |
|
1126 {loc("Sticky Mine Placement Mode"),false}, |
|
1127 {loc("Barrel Placement Mode"),false}, |
|
1128 {loc("Health Crate Placement Mode"),false}, |
|
1129 {loc("Weapon Crate Placement Mode"),false}, |
|
1130 {loc("Utility Crate Placement Mode"),false}, |
|
1131 --{loc("Target Placement Mode"),false}, |
|
1132 --{loc("Cleaver Placement Mode"),false}, |
|
1133 |
|
1134 --{loc("Advanced Repositioning Mode"),false}, |
|
1135 --{loc("Tagging Mode"),false}, |
|
1136 --{loc("Sprite Testing Mode"),false}, |
|
1137 --{loc("Sprite Placement Mode"),false}, |
|
1138 {loc("Structure Placement Mode"),false}, |
|
1139 {loc("Teleportation Mode"),false} |
|
1140 } |
|
1141 |
|
1142 |
|
1143 local pMode = {} -- pMode contains custom subsets of the main categories |
|
1144 local pIndex = 1 |
|
1145 |
|
1146 local genTimer = 0 |
|
1147 |
|
1148 local CGR = 1 -- current girder rotation, we actually need this as HW remembers what rotation you last used |
|
1149 |
|
1150 local placedX = {} |
|
1151 local placedY = {} |
|
1152 local placedSpec = {} |
|
1153 local placedSuperSpec = {} |
|
1154 local placedType = {} |
|
1155 local placedCount = 0 |
|
1156 |
|
1157 local sCirc -- circle that appears around selected gears |
|
1158 local sGear = nil |
|
1159 local closestDist |
|
1160 local closestGear = nil |
|
1161 |
|
1162 local tCirc = {} -- array of circles that appear around tagged gears |
|
1163 |
|
1164 ------------------------ |
|
1165 -- SOME GENERAL METHODS |
|
1166 ------------------------ |
|
1167 |
|
1168 function GetDistFromGearToXY(gear, g2X, g2Y) |
|
1169 |
|
1170 g1X, g1Y = GetGearPosition(gear) |
|
1171 q = g1X - g2X |
|
1172 w = g1Y - g2Y |
|
1173 |
|
1174 return ( (q*q) + (w*w) ) |
|
1175 |
|
1176 end |
|
1177 |
|
1178 function GetDistFromXYtoXY(a, b, c, d) |
|
1179 q = a - c |
|
1180 w = b - d |
|
1181 return ( (q*q) + (w*w) ) |
|
1182 end |
|
1183 |
|
1184 function SelectGear(gear) |
|
1185 |
|
1186 d = GetDistFromGearToXY(gear, placedX[placedCount], placedY[placedCount]) |
|
1187 |
|
1188 if d < closestDist then |
|
1189 closestDist = d |
|
1190 closestGear = gear |
|
1191 end |
|
1192 |
|
1193 end |
|
1194 |
|
1195 -- essentially called when user clicks the mouse |
|
1196 -- with girders or an airattack |
|
1197 function PlaceObject(x,y) |
|
1198 |
|
1199 placedX[placedCount] = x |
|
1200 placedY[placedCount] = y |
|
1201 placedType[placedCount] = cat[cIndex] |
|
1202 placedSpec[placedCount] = pMode[pIndex] |
|
1203 |
|
1204 if (clanUsedExtraTime[GetHogClan(CurrentHedgehog)] == true) and (cat[cIndex] == "Utility Crate Placement Mode") and (utilArray[pIndex][1] == amExtraTime) then |
|
1205 AddCaption(loc("You may only use 1 Extra Time per turn."),0xffba00ff,capgrpVolume) |
|
1206 PlaySound(sndDenied) |
|
1207 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 |
|
1208 AddCaption(loc("You may only spawn 5 crates per turn."),0xffba00ff,capgrpVolume) |
|
1209 PlaySound(sndDenied) |
|
1210 elseif (XYisInRect(x,y, clanBoundsSX[GetHogClan(CurrentHedgehog)],clanBoundsSY[GetHogClan(CurrentHedgehog)],clanBoundsEX[GetHogClan(CurrentHedgehog)],clanBoundsEY[GetHogClan(CurrentHedgehog)]) == true) |
|
1211 and (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) |
|
1212 then |
|
1213 |
|
1214 |
|
1215 |
|
1216 if cat[cIndex] == "Girder Placement Mode" then |
|
1217 PlaceGirder(x, y, CGR) |
|
1218 placedSpec[placedCount] = CGR |
|
1219 elseif cat[cIndex] == "Rubber Placement Mode" then |
|
1220 PlaceSprite(x,y, sprAmRubber, CGR, lfBouncy) |
|
1221 --PlaceGirder(x, y, CGR) |
|
1222 placedSpec[placedCount] = CGR |
|
1223 elseif cat[cIndex] == "Target Placement Mode" then |
|
1224 gear = AddGear(x, y, gtTarget, 0, 0, 0, 0) |
|
1225 elseif cat[cIndex] == "Cleaver Placement Mode" then |
|
1226 gear = AddGear(x, y, gtKnife, 0, 0, 0, 0) |
|
1227 elseif cat[cIndex] == "Health Crate Placement Mode" then |
|
1228 gear = SpawnHealthCrate(x,y) |
|
1229 SetHealth(gear, pMode[pIndex]) |
|
1230 setGearValue(gear,"caseType","med") |
|
1231 clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1 |
|
1232 elseif cat[cIndex] == "Weapon Crate Placement Mode" then |
|
1233 gear = SpawnAmmoCrate(x, y, atkArray[pIndex][1]) |
|
1234 placedSpec[placedCount] = atkArray[pIndex][2] |
|
1235 setGearValue(gear,"caseType","ammo") |
|
1236 setGearValue(gear,"contents",atkArray[pIndex][2]) |
|
1237 clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1 |
|
1238 elseif cat[cIndex] == "Utility Crate Placement Mode" then |
|
1239 gear = SpawnUtilityCrate(x, y, utilArray[pIndex][1]) |
|
1240 placedSpec[placedCount] = utilArray[pIndex][2] |
|
1241 setGearValue(gear,"caseType","util") |
|
1242 setGearValue(gear,"contents",utilArray[pIndex][2]) |
|
1243 if utilArray[pIndex][1] == amExtraTime then |
|
1244 clanUsedExtraTime[GetHogClan(CurrentHedgehog)] = true |
|
1245 end |
|
1246 clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1 |
|
1247 elseif cat[cIndex] == "Barrel Placement Mode" then |
|
1248 gear = AddGear(x, y, gtExplosives, 0, 0, 0, 0) |
|
1249 SetHealth(gear, pMode[pIndex]) |
|
1250 elseif cat[cIndex] == "Mine Placement Mode" then |
|
1251 gear = AddGear(x, y, gtMine, 0, 0, 0, 0) |
|
1252 SetTimer(gear, pMode[pIndex]) |
|
1253 elseif cat[cIndex] == "Sticky Mine Placement Mode" then |
|
1254 gear = AddGear(x, y, gtSMine, 0, 0, 0, 0) |
|
1255 elseif cat[cIndex] == "Advanced Repositioning Mode" then |
|
1256 |
|
1257 if pMode[pIndex] == "Selection Mode" then |
|
1258 closestDist = 999999999 |
|
1259 closestGear = nil -- just in case |
|
1260 sGear = nil |
|
1261 runOnGears(SelectGear) |
|
1262 sGear = closestGear |
|
1263 closestGear = nil |
|
1264 elseif pMode[pIndex] == "Placement Mode" then |
|
1265 if sGear ~= nil then |
|
1266 SetGearPosition(sGear, x, y) |
|
1267 end |
|
1268 end |
|
1269 |
|
1270 elseif cat[cIndex] == "Tagging Mode" then |
|
1271 |
|
1272 closestDist = 999999999 |
|
1273 closestGear = nil |
|
1274 sGear = nil |
|
1275 runOnGears(SelectGear) |
|
1276 |
|
1277 |
|
1278 if closestGear ~= nil then |
|
1279 |
|
1280 if getGearValue(closestGear,"tag") == nil then |
|
1281 |
|
1282 --if there is no tag, add a victory/failure tag and circle |
|
1283 setGearValue(closestGear, "tCirc",AddVisualGear(0,0,vgtCircle,0,true)) |
|
1284 |
|
1285 --AddCaption("circ added",0xffba00ff,capgrpVolume) |
|
1286 |
|
1287 if pMode[pIndex] == "Tag Victory Mode" then |
|
1288 setGearValue(closestGear, "tag","victory") |
|
1289 SetVisualGearValues(getGearValue(closestGear,"tCirc"), 0, 0, 100, 255, 1, 10, 0, 40, 3, 0xff0000ff) |
|
1290 elseif pMode[pIndex] == "Tag Failure Mode" then |
|
1291 setGearValue(closestGear, "tag","failure") |
|
1292 SetVisualGearValues(getGearValue(closestGear,"tCirc"), 0, 0, 100, 255, 1, 10, 0, 40, 3, 0x0000ffff) |
|
1293 end |
|
1294 |
|
1295 |
|
1296 else |
|
1297 -- remove tag and delete circ |
|
1298 --AddCaption("circ removed",0xffba00ff,capgrpVolume) |
|
1299 setGearValue(closestGear, "tag", nil) |
|
1300 DeleteVisualGear(getGearValue(closestGear,"tCirc")) |
|
1301 setGearValue(closestGear, "tCirc", nil) |
|
1302 end |
|
1303 |
|
1304 end |
|
1305 |
|
1306 |
|
1307 elseif cat[cIndex] == "Sprite Testing Mode" then |
|
1308 |
|
1309 frameID = 1 |
|
1310 visualSprite = reducedSpriteIDArray[pIndex] |
|
1311 --visualSprite = spriteIDArray[pIndex] |
|
1312 tempE = AddVisualGear(x, y, vgtStraightShot, 0, true) |
|
1313 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) |
|
1314 SetVisualGearValues(tempE, g1, g2, 0, 0, g5, frameID, g7, visualSprite, g9, g10 ) |
|
1315 --sprHorizonLong crashes game, so does skyL, as does flake |
|
1316 |
|
1317 -- reduced list of cool sprites |
|
1318 -- sprBigDigit, sprKnife, sprFrozenHog, sprKowtow, sprBee, sprExplosion50, sprPiano, sprChunk, sprHHTelepMask, sprSeduction, sprSwitch, sprGirder, |
|
1319 --sprAMAmmos, sprAMSlotKeys, sprTurnsLeft, sprExplosivesRoll + maybe some others like the health case, arrows, etc |
|
1320 |
|
1321 elseif cat[cIndex] == "Sprite Placement Mode" then |
|
1322 |
|
1323 PlaceSprite(x,y, reducedSpriteIDArray[pIndex], 1, landType) |
|
1324 --PlaceGirder(x, y, CGR) |
|
1325 placedSpec[placedCount] = reducedSpriteTextArray[pIndex] |
|
1326 placedSuperSpec[placedCount] = landType |
|
1327 |
|
1328 if landType == lfIce then |
|
1329 placedSuperSpec[placedCount] = "lfIce" |
|
1330 elseif landType == lfIndestructible then |
|
1331 placedSuperSpec[placedCount] = "lfIndestructible" |
|
1332 elseif landType == lfBouncy then |
|
1333 placedSuperSpec[placedCount] = "lfBouncy" |
|
1334 else |
|
1335 placedSuperSpec[placedCount] = "lfNormal" |
|
1336 end |
|
1337 |
|
1338 elseif cat[cIndex] == "Structure Placement Mode" then |
|
1339 |
|
1340 AddStruc(x,y, pMode[pIndex],GetHogClan(CurrentHedgehog)) |
|
1341 |
|
1342 end |
|
1343 |
|
1344 clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] - placedExpense |
|
1345 placedCount = placedCount + 1 |
|
1346 |
|
1347 else |
|
1348 AddCaption("Invalid Placement",0xffba00ff,capgrpVolume) |
|
1349 PlaySound(sndDenied) |
|
1350 end |
|
1351 |
|
1352 |
|
1353 end |
|
1354 |
|
1355 -- called when user changes primary selection |
|
1356 -- either via up/down keys |
|
1357 -- or selecting girder/airattack |
|
1358 function RedefineSubset() |
|
1359 |
|
1360 pIndex = 1 |
|
1361 pMode = {} |
|
1362 placedExpense = 1 |
|
1363 |
|
1364 if cat[cIndex] == "Girder Placement Mode" then |
|
1365 pIndex = CGR |
|
1366 pMode = {"Girder"} |
|
1367 -- pCount = 1 |
|
1368 elseif cat[cIndex] == "Rubber Placement Mode" then |
|
1369 pIndex = CGR |
|
1370 pMode = {"Rubber"} |
|
1371 placedExpense = 3 |
|
1372 -- pCount = 1??? |
|
1373 elseif cat[cIndex] == "Target Placement Mode" then |
|
1374 pMode = {"Standard Target"} |
|
1375 elseif cat[cIndex] == "Cleaver Placement Mode" then |
|
1376 pMode = {"Standard Cleaver"} |
|
1377 elseif cat[cIndex] == "Barrel Placement Mode" then |
|
1378 --pMode = {1,50,75,100} |
|
1379 pMode = {50} |
|
1380 placedExpense = 10 |
|
1381 elseif cat[cIndex] == "Health Crate Placement Mode" then |
|
1382 --pMode = {25,50,75,100} |
|
1383 pMode = {25} |
|
1384 placedExpense = 5 |
|
1385 elseif cat[cIndex] == "Weapon Crate Placement Mode" then |
|
1386 for i = 1, #atkArray do |
|
1387 pMode[i] = atkArray[i][4] -- was [2] |
|
1388 --placedExpense = atkArray[5] |
|
1389 end |
|
1390 placedExpense = 30 |
|
1391 elseif cat[cIndex] == "Utility Crate Placement Mode" then |
|
1392 for i = 1, #utilArray do |
|
1393 pMode[i] = utilArray[i][4] -- was [2] |
|
1394 --placedExpense = utilArray[5] |
|
1395 end |
|
1396 placedExpense = 20 |
|
1397 elseif cat[cIndex] == "Mine Placement Mode" then |
|
1398 --pMode = {1,1000,2000,3000,4000,5000,0} |
|
1399 pMode = {1,1000,2000,3000,4000,5000} |
|
1400 -- 0 is dud right, or is that nil? |
|
1401 placedExpense = 15 |
|
1402 elseif cat[cIndex] == "Sticky Mine Placement Mode" then |
|
1403 pMode = {"Normal Sticky Mine"} |
|
1404 --elseif cat[cIndex] == "Gear Repositioning Mode" then |
|
1405 -- for i = 1, #hhs do |
|
1406 -- pMode[i] = GetHogName(hhs[i]) |
|
1407 -- end |
|
1408 placedExpense = 20 |
|
1409 elseif cat[cIndex] == "Advanced Repositioning Mode" then |
|
1410 pMode = {"Selection Mode","Placement Mode"} |
|
1411 elseif cat[cIndex] == "Tagging Mode" then |
|
1412 pMode = {"Tag Victory Mode","Tag Failure Mode"} |
|
1413 elseif cat[cIndex] == "Sprite Testing Mode" or cat[cIndex] == "Sprite Placement Mode" then |
|
1414 --for i = 1, #spriteTextArray do |
|
1415 -- pMode[i] = spriteTextArray[i] |
|
1416 --end |
|
1417 for i = 1, #reducedSpriteTextArray do |
|
1418 pMode[i] = reducedSpriteTextArray[i] |
|
1419 end |
|
1420 placedExpense = 100 |
|
1421 elseif cat[cIndex] == "Structure Placement Mode" then |
|
1422 pMode = {loc("Healing Station"), loc("Bio-Filter"), loc("Weapon Filter"), loc("Reflector Shield"), loc("Respawner"),loc("Teleportation Node"),--[[loc("Core"),]]loc("Generator"),loc("Construction Station"),loc("Support Station")} |
|
1423 --placedExpense = 100 |
|
1424 end |
|
1425 |
|
1426 |
|
1427 |
|
1428 |
|
1429 end |
|
1430 |
|
1431 -- called in onGameTick() |
|
1432 function HandleHedgeEditor() |
|
1433 |
|
1434 if CurrentHedgehog ~= nil then |
|
1435 |
|
1436 if wallsVisible == true then |
|
1437 HandleBorderEffects() |
|
1438 end |
|
1439 |
|
1440 if (CurrentHedgehog ~= nil) and (TurnTimeLeft ~= TurnTime) then |
|
1441 if (lastWep ~= GetCurAmmoType()) then |
|
1442 checkForSpecialWeapons() |
|
1443 end |
|
1444 end |
|
1445 |
|
1446 genTimer = genTimer + 1 |
|
1447 |
|
1448 if genTimer >= 100 then |
|
1449 |
|
1450 genTimer = 0 |
|
1451 |
|
1452 DrawTag(1) |
|
1453 |
|
1454 HandleStructures() |
|
1455 |
|
1456 curWep = GetCurAmmoType() |
|
1457 |
|
1458 -- change to girder mode on weapon swap |
|
1459 if (cIndex ~= 1) and (curWep == amGirder) then |
|
1460 cIndex = 1 |
|
1461 RedefineSubset() |
|
1462 elseif (cIndex ~=2) and (curWep == amRubber) then |
|
1463 cIndex = 2 |
|
1464 RedefineSubset() |
|
1465 -- change to generic mode if girder no longer selected |
|
1466 elseif (cIndex == 1) and (curWep ~= amGirder) then |
|
1467 cIndex = 3 -- was 2 |
|
1468 RedefineSubset() |
|
1469 elseif (cIndex == 2) and (curWep ~= amRubber) then |
|
1470 cIndex = 3 --new |
|
1471 RedefineSubset() |
|
1472 |
|
1473 end |
|
1474 |
|
1475 -- update display selection criteria |
|
1476 if (curWep == amGirder) or (curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) or (curWep == amRubber) then |
|
1477 |
|
1478 ---------------hooolllllyyyy fucking shit this |
|
1479 -- code is a broken mess now |
|
1480 -- it was redesigned and compromised three times |
|
1481 -- so now it is a mess trying to do what it was |
|
1482 -- never designed to do |
|
1483 -- needs to be rewritten badly sadface |
|
1484 -- this bit here catches the new 3 types of weapons |
|
1485 if ((sProx[cIndex][1] == loc("Structure Placement Mode") and (curWep ~= amAirAttack))) then |
|
1486 updatePlacementDisplay(1) |
|
1487 elseif (sProx[cIndex][1] == loc("Health Crate Placement Mode")) or |
|
1488 (sProx[cIndex][1] == loc("Weapon Crate Placement Mode")) or |
|
1489 (sProx[cIndex][1] == loc("Utility Crate Placement Mode")) then |
|
1490 if curWep ~= amNapalm then |
|
1491 updatePlacementDisplay(1) |
|
1492 end |
|
1493 |
|
1494 elseif (sProx[cIndex][1] == loc("Mine Placement Mode")) or |
|
1495 (sProx[cIndex][1] == loc("Sticky Mine Placement Mode")) or |
|
1496 (sProx[cIndex][1] == loc("Barrel Placement Mode")) then |
|
1497 if curWep ~= amDrillStrike then |
|
1498 updatePlacementDisplay(1) |
|
1499 end |
|
1500 |
|
1501 end |
|
1502 |
|
1503 --this is called when it happens that we have placement |
|
1504 --mode selected and we are looking at something |
|
1505 --we shouldn't be allowed to look at, as would be the case |
|
1506 --when you WERE allowed to look at it, but then maybe |
|
1507 --a bomb blows up the structure that was granting you |
|
1508 --that ability |
|
1509 if (sProx[cIndex][2] ~= true) then |
|
1510 updatePlacementDisplay(1) |
|
1511 else |
|
1512 updateCost() |
|
1513 end |
|
1514 |
|
1515 |
|
1516 AddCaption(cat[cIndex],0xffba00ff,capgrpMessage) |
|
1517 AddCaption(pMode[pIndex],0xffba00ff,capgrpMessage2) |
|
1518 wallsVisible = true |
|
1519 else |
|
1520 wallsVisible = false |
|
1521 end |
|
1522 |
|
1523 end |
|
1524 |
|
1525 end |
|
1526 |
|
1527 --update selected gear display |
|
1528 if (cat[cIndex] == "Advanced Repositioning Mode") and (sGear ~= nil) then |
|
1529 SetVisualGearValues(sCirc, GetX(sGear), GetY(sGear), 100, 255, 1, 10, 0, 300, 3, 0xff00ffff) |
|
1530 elseif (cat[cIndex] == "Tagging Mode") then |
|
1531 if (sGear ~= nil) or (closestGear ~= nil) then |
|
1532 SetVisualGearValues(sCirc, GetX(sGear), GetY(sGear), 0, 1, 1, 10, 0, 1, 1, 0x00000000) |
|
1533 closestGear = nil |
|
1534 sGear = nil |
|
1535 end |
|
1536 end |
|
1537 |
|
1538 -- some kind of target detected, tell me your story |
|
1539 if cGear ~= nil then |
|
1540 |
|
1541 x,y = GetGearTarget(cGear) |
|
1542 |
|
1543 if GetGearType(cGear) == gtAirAttack then |
|
1544 DeleteGear(cGear) |
|
1545 PlaceObject(x, y) |
|
1546 elseif GetGearType(cGear) == gtTeleport then |
|
1547 |
|
1548 CheckTeleport(cGear, x, y) |
|
1549 cGear = nil |
|
1550 elseif GetGearType(cGear) == gtGirder then |
|
1551 |
|
1552 CGR = GetState(cGear) |
|
1553 |
|
1554 -- improve rectangle test based on CGR when you can be bothered |
|
1555 --if TestRectForObstacle(x-20, y-20, x+20, y+20, true) then |
|
1556 -- AddCaption("Invalid Girder Placement",0xffba00ff,capgrpVolume) |
|
1557 --else |
|
1558 PlaceObject(x, y) |
|
1559 --end |
|
1560 |
|
1561 -- this allows the girder tool to be used like a mining laser |
|
1562 |
|
1563 --[[ |
|
1564 |
|
1565 if CGR < 4 then |
|
1566 AddGear(x, y, gtGrenade, 0, 0, 0, 1) |
|
1567 elseif CGR == 4 then |
|
1568 g = AddGear(x-30, y, gtGrenade, 0, 0, 0, 1) |
|
1569 g = AddGear(x+30, y, gtGrenade, 0, 0, 0, 1) |
|
1570 elseif CGR == 5 then ------- |
|
1571 g = AddGear(x+30, y+30, gtGrenade, 0, 0, 0, 1) |
|
1572 g = AddGear(x-30, y-30, gtGrenade, 0, 0, 0, 1) |
|
1573 elseif CGR == 6 then |
|
1574 g = AddGear(x, y+30, gtGrenade, 0, 0, 0, 1) |
|
1575 g = AddGear(x, y-30, gtGrenade, 0, 0, 0, 1) |
|
1576 elseif CGR == 7 then ------- |
|
1577 g = AddGear(x+30, y-30, gtGrenade, 0, 0, 0, 1) |
|
1578 g = AddGear(x-30, y+30, gtGrenade, 0, 0, 0, 1) |
|
1579 end |
|
1580 ]] |
|
1581 end |
|
1582 |
|
1583 end |
|
1584 |
|
1585 end |
|
1586 |
|
1587 -------------------------------------------------- |
|
1588 -- EVENT HANDLERS |
|
1589 -------------------------------------------------- |
|
1590 |
|
1591 function onTaunt(t) |
|
1592 tauntString = tauntString .. t |
|
1593 if (tauntString == "101") and (clanPower[GetHogClan(CurrentHedgehog)] < 300) and (clanBoon[GetHogClan(CurrentHedgehog)] == false) then |
|
1594 clanBoon[GetHogClan(CurrentHedgehog)] = true |
|
1595 clanPower[GetHogClan(CurrentHedgehog)] = 1000 |
|
1596 AddCaption(loc("The Great Hog in the sky sees your sadness and grants you a boon.")) |
|
1597 end |
|
1598 end |
|
1599 |
|
1600 --------------------------------------------------------------- |
|
1601 -- Cycle through selection subsets (by changing pIndex, pMode) |
|
1602 -- i.e health of barrels, medikits, |
|
1603 -- timer of mines |
|
1604 -- contents of crates |
|
1605 -- gears to reposition etc. |
|
1606 --------------------------------------------------------------- |
|
1607 |
|
1608 function updateCost() |
|
1609 |
|
1610 if pMode[pIndex] == loc("Healing Station") then |
|
1611 placedExpense = 50 |
|
1612 elseif pMode[pIndex] == loc("Weapon Filter") then |
|
1613 placedExpense = 50 |
|
1614 elseif pMode[pIndex] == loc("Bio-Filter") then |
|
1615 placedExpense = 100 |
|
1616 elseif pMode[pIndex] == loc("Respawner") then |
|
1617 placedExpense = 300 |
|
1618 elseif pMode[pIndex] == loc("Teleportation Node") then |
|
1619 placedExpense = 30 |
|
1620 elseif pMode[pIndex] == loc("Support Station") then |
|
1621 placedExpense = 50 |
|
1622 elseif pMode[pIndex] == loc("Construction Station") then |
|
1623 placedExpense = 50 |
|
1624 elseif pMode[pIndex] == loc("Generator") then |
|
1625 placedExpense = 300 |
|
1626 elseif pMode[pIndex] == loc("Reflector Shield") then |
|
1627 placedExpense = 200 |
|
1628 elseif pMode[pIndex] == loc("Core") then |
|
1629 placedExpense = 1 |
|
1630 elseif cat[cIndex] == loc("Weapon Crate Placement Mode") then |
|
1631 placedExpense = atkArray[pIndex][5] |
|
1632 elseif cat[cIndex] == loc("Utility Crate Placement Mode") then |
|
1633 placedExpense = utilArray[pIndex][5] |
|
1634 end |
|
1635 |
|
1636 AddCaption(loc("Cost") .. ": " .. placedExpense,0xffba00ff,capgrpAmmostate) |
|
1637 |
|
1638 end |
|
1639 |
|
1640 function onLeft() |
|
1641 |
|
1642 pIndex = pIndex - 1 |
|
1643 if pIndex == 0 then |
|
1644 pIndex = #pMode |
|
1645 end |
|
1646 |
|
1647 if (curWep == amGirder) or (curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) then |
|
1648 AddCaption(pMode[pIndex],0xffba00ff,capgrpMessage2) |
|
1649 updateCost() |
|
1650 end |
|
1651 |
|
1652 |
|
1653 end |
|
1654 |
|
1655 function onRight() |
|
1656 |
|
1657 pIndex = pIndex + 1 |
|
1658 if pIndex > #pMode then |
|
1659 pIndex = 1 |
|
1660 end |
|
1661 |
|
1662 if (curWep == amGirder) or (curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) then |
|
1663 AddCaption(pMode[pIndex],0xffba00ff,capgrpMessage2) |
|
1664 updateCost() |
|
1665 end |
|
1666 |
|
1667 end |
|
1668 |
|
1669 |
|
1670 function updatePlacementDisplay(pDir) |
|
1671 |
|
1672 foundMatch = false |
|
1673 while(foundMatch == false) do |
|
1674 cIndex = cIndex + pDir |
|
1675 |
|
1676 if (cIndex == 1) or (cIndex == 2) then --1 --we no longer hit girder by normal means |
|
1677 cIndex = #cat |
|
1678 elseif cIndex > #cat then |
|
1679 cIndex = 3 -- 2 ----we no longer hit girder by normal means |
|
1680 end |
|
1681 |
|
1682 -- new way of doing things |
|
1683 -- sProx[cIndex][2] == true just basically means we have ACCESS to something |
|
1684 -- but that doesn't neccessarily mean we are in the correct content menu, anymore |
|
1685 -- so we need to refine this a little |
|
1686 if sProx[cIndex][2] == true then |
|
1687 if (GetCurAmmoType() == amNapalm) then |
|
1688 if (sProx[cIndex][1] == loc("Health Crate Placement Mode")) or |
|
1689 (sProx[cIndex][1] == loc("Weapon Crate Placement Mode")) or |
|
1690 (sProx[cIndex][1] == loc("Utility Crate Placement Mode")) |
|
1691 then |
|
1692 foundMatch = true |
|
1693 end |
|
1694 elseif (GetCurAmmoType() == amDrillStrike) then |
|
1695 if (sProx[cIndex][1] == loc("Mine Placement Mode")) or |
|
1696 (sProx[cIndex][1] == loc("Sticky Mine Placement Mode")) or |
|
1697 (sProx[cIndex][1] == loc("Barrel Placement Mode")) |
|
1698 then |
|
1699 foundMatch = true |
|
1700 end |
|
1701 elseif (GetCurAmmoType() == amAirAttack) then |
|
1702 if sProx[cIndex][1] == loc("Structure Placement Mode") then |
|
1703 foundMatch = true |
|
1704 end |
|
1705 end |
|
1706 end |
|
1707 |
|
1708 |
|
1709 if foundMatch == true then |
|
1710 --if sProx[cIndex][2] == true then |
|
1711 -- normal case (scrolling through) |
|
1712 --foundMatch = true |
|
1713 RedefineSubset() |
|
1714 updateCost() |
|
1715 end |
|
1716 |
|
1717 end |
|
1718 |
|
1719 end |
|
1720 |
|
1721 --------------------------------------------------------- |
|
1722 -- Cycle through primary categories (by changing cIndex) |
|
1723 -- i.e mine, sticky mine, barrels |
|
1724 -- health/weapon/utility crate, placement of gears |
|
1725 --------------------------------------------------------- |
|
1726 function onUp() |
|
1727 |
|
1728 if ((curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) ) then |
|
1729 updatePlacementDisplay(-1) |
|
1730 end |
|
1731 |
|
1732 end |
|
1733 |
|
1734 function onDown() |
|
1735 |
|
1736 if ((curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) ) then |
|
1737 updatePlacementDisplay(1) |
|
1738 end |
|
1739 |
|
1740 end |
|
1741 |
|
1742 ---------------------------- |
|
1743 -- standard event handlers |
|
1744 ---------------------------- |
|
1745 |
|
1746 function onGameInit() |
|
1747 |
|
1748 Explosives = 0 |
|
1749 MinesNum = 0 |
|
1750 |
|
1751 EnableGameFlags(gfInfAttack) |
|
1752 |
|
1753 |
|
1754 RedefineSubset() |
|
1755 |
|
1756 end |
|
1757 |
|
1758 function initialSetup(gear) |
|
1759 |
|
1760 FindPlace(gear, false, clanBoundsSX[GetHogClan(gear)], clanBoundsEX[GetHogClan(gear)],true) |
|
1761 |
|
1762 -- for now, everyone should have this stuff |
|
1763 AddAmmo(gear, amAirAttack, 100) |
|
1764 AddAmmo(gear, amSwitch, 100) |
|
1765 AddAmmo(gear, amSkip, 100) |
|
1766 |
|
1767 end |
|
1768 |
|
1769 function onGameStart() |
|
1770 |
|
1771 trackTeams() |
|
1772 |
|
1773 ShowMission ( |
|
1774 loc("CONSTRUCTION MODE"), |
|
1775 loc("a Hedgewars mini-game"), |
|
1776 " " .. "|" .. |
|
1777 loc("Build a fortress and destroy your enemy.") .. "|" .. |
|
1778 --loc("Defend your core from the enemy.") .. "|" .. |
|
1779 loc("There are a variety of structures available to aid you.") .. "|" .. |
|
1780 loc("Use the air-attack weapons and the arrow keys to select structures.") .. "|" .. |
|
1781 " " .. "|" .. |
|
1782 --loc("Core") .. ": " .. loc("Allows placement of structures.") .. "|" .. |
|
1783 loc("Healing Station") .. ": " .. loc("Grants nearby hogs life-regeneration.") .. "|" .. |
|
1784 loc("Bio-Filter") .. ": " .. loc("Aggressively removes enemy hedgehogs.") .. "|" .. |
|
1785 loc("Weapon Filter") .. ": " .. loc("Dematerializes weapons and equipment carried by enemy hedgehogs.") .. "|" .. |
|
1786 loc("Reflector Shield") .. ": " .. loc("Reflects enemy projectiles.") .. "|" .. |
|
1787 |
|
1788 loc("Generator") .. ": " .. loc("Generates power.") .. "|" .. |
|
1789 loc("Respawner") .. ": " .. loc("Resurrects dead hedgehogs.") .. "|" .. |
|
1790 loc("Teleporation Node") .. ": " .. loc("Allows free teleportation between other nodes.") .. "|" .. |
|
1791 loc("Construction Station") .. ": " .. loc("Allows placement of girders, rubber-bands, mines, sticky mines and barrels.") .. "|" .. |
|
1792 loc("Support Station") .. ": " .. loc("Allows the placement of weapons, utiliites, and health crates.") .. "|" .. |
|
1793 |
|
1794 |
|
1795 " " .. "|" .. |
|
1796 --" " .. "|" .. |
|
1797 "", 4, 5000 |
|
1798 ) |
|
1799 |
|
1800 |
|
1801 sCirc = AddVisualGear(0,0,vgtCircle,0,true) |
|
1802 SetVisualGearValues(sCirc, 0, 0, 100, 255, 1, 10, 0, 40, 3, 0x00000000) |
|
1803 |
|
1804 for i = 0, ClansCount-1 do |
|
1805 clanPower[i] = 500 |
|
1806 clanBoon[i] = false |
|
1807 clanLWepIndex[i] = 1 -- for ease of use let's track this stuff |
|
1808 clanLUtilIndex[i] = 1 |
|
1809 clanLGearIndex[i] = 1 |
|
1810 clanUsedExtraTime[i] = false |
|
1811 clanCratesSpawned[i] = 0 |
|
1812 |
|
1813 |
|
1814 end |
|
1815 |
|
1816 tMapWidth = RightX - LeftX |
|
1817 tMapHeight = WaterLine - TopY |
|
1818 clanInterval = div(tMapWidth,ClansCount) |
|
1819 |
|
1820 for i = 1, ClansCount do |
|
1821 |
|
1822 clanBoundsSX[i-1] = LeftX+(clanInterval*i)-clanInterval+20 |
|
1823 clanBoundsSY[i-1] = TopY |
|
1824 clanBoundsEX[i-1] = LeftX+(clanInterval*i)-20 |
|
1825 clanBoundsEY[i-1] = WaterLine |
|
1826 |
|
1827 --top and bottom |
|
1828 AddWall(LeftX+(clanInterval*i)-clanInterval,TopY,clanInterval,margin,GetClanColor(i-1)) |
|
1829 AddWall(LeftX+(clanInterval*i)-clanInterval,WaterLine-25,clanInterval,margin,GetClanColor(i-1)) |
|
1830 |
|
1831 --add a wall to the left and right |
|
1832 AddWall(LeftX+(clanInterval*i)-clanInterval+20,TopY,margin,WaterLine,GetClanColor(i-1)) |
|
1833 AddWall(LeftX+(clanInterval*i)-20,TopY,margin,WaterLine,GetClanColor(i-1)) |
|
1834 |
|
1835 end |
|
1836 |
|
1837 runOnHogs(initialSetup) |
|
1838 |
|
1839 end |
|
1840 |
|
1841 |
|
1842 function onNewTurn() |
|
1843 |
|
1844 tauntString = "" |
|
1845 clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] + 50 |
|
1846 clanUsedExtraTime[GetHogClan(CurrentHedgehog)] = false |
|
1847 clanCratesSpawned[GetHogClan(CurrentHedgehog)] = 0 |
|
1848 |
|
1849 end |
|
1850 |
|
1851 function onGameTick() |
|
1852 HandleHedgeEditor() |
|
1853 end |
|
1854 |
|
1855 function isATrackedGear(gear) |
|
1856 if (GetGearType(gear) == gtHedgehog) or |
|
1857 (GetGearType(gear) == gtTarget) or |
|
1858 (GetGearType(gear) == gtCase) |
|
1859 then |
|
1860 return(true) |
|
1861 else |
|
1862 return(false) |
|
1863 end |
|
1864 end |
|
1865 |
|
1866 -- track hedgehogs and placement gears |
|
1867 function onGearAdd(gear) |
|
1868 |
|
1869 if GetGearType(gear) == gtHedgehog then |
|
1870 --table.insert(hhs, gear) |
|
1871 elseif (GetGearType(gear) == gtAirAttack) or (GetGearType(gear) == gtTeleport) or (GetGearType(gear) == gtGirder) then |
|
1872 cGear = gear |
|
1873 |
|
1874 end |
|
1875 |
|
1876 if isATrackedGear(gear) then |
|
1877 trackGear(gear) |
|
1878 elseif gearCanBeDeflected(gear) then |
|
1879 trackGear(gear) |
|
1880 setGearReflectionValues(gear) |
|
1881 end |
|
1882 |
|
1883 end |
|
1884 |
|
1885 function onGearDelete(gear) |
|
1886 |
|
1887 if GetGearType(gear) == gtTarget then |
|
1888 CheckGearForStructureLink(gear) |
|
1889 end |
|
1890 |
|
1891 if (GetGearType(gear) == gtAirAttack) or (GetGearType(gear) == gtTeleport) or (GetGearType(gear) == gtGirder) then |
|
1892 cGear = nil |
|
1893 end |
|
1894 |
|
1895 if (isATrackedGear(gear) or gearCanBeDeflected(gear)) then |
|
1896 |
|
1897 if getGearValue(gear, "tCirc") ~= nil then |
|
1898 DeleteVisualGear(getGearValue(gear, "tCirc")) |
|
1899 end |
|
1900 |
|
1901 trackDeletion(gear) |
|
1902 |
|
1903 end |
|
1904 |
|
1905 end |