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