changeset 12949 | 4fa79a6a1883 |
parent 12948 | f85a040d0350 |
child 12950 | a260d233cef3 |
12948:f85a040d0350 | 12949:4fa79a6a1883 |
---|---|
57 |
57 |
58 ---------------------------------------------- |
58 ---------------------------------------------- |
59 -- STRUCTURES STUFF |
59 -- STRUCTURES STUFF |
60 ---------------------------------------------- |
60 ---------------------------------------------- |
61 |
61 |
62 strucID = {} |
62 local strucID = {} |
63 strucGear = {} |
63 local strucGear = {} |
64 strucClan = {} |
64 local strucClan = {} |
65 strucType = {} |
65 local strucType = {} |
66 strucCost = {} |
66 local strucCost = {} |
67 strucHealth = {} |
67 local strucHealth = {} |
68 |
68 |
69 strucCirc = {} |
69 local strucCirc = {} |
70 strucCircCol = {} |
70 local strucCircCol = {} |
71 strucCircRadius = {} |
71 local strucCircRadius = {} |
72 strucCircType = {} |
72 local strucCircType = {} |
73 strucAltDisplay = {} |
73 local strucAltDisplay = {} |
74 |
74 |
75 fortMode = false |
75 local fortMode = false |
76 |
76 |
77 placedExpense = 0 |
77 local placedExpense = 0 |
78 |
78 |
79 tempID = nil |
79 local globalTempID = nil |
80 |
80 |
81 sUID = 0 |
81 local sUID = 0 |
82 |
82 |
83 colorRed = 0xff0000ff |
83 local cGear = nil |
84 colorGreen = 0x00ff00ff |
84 |
85 |
85 local colorRed = 0xff0000ff |
86 clanBoundsSX = {} |
86 local colorGreen = 0x00ff00ff |
87 clanBoundsSY = {} |
87 |
88 clanBoundsEX = {} |
88 local clanBoundsSX = {} |
89 clanBoundsEY = {} |
89 local clanBoundsSY = {} |
90 |
90 local clanBoundsEX = {} |
91 clanPower = {} |
91 local clanBoundsEY = {} |
92 clanID = {} |
92 |
93 local clanPower = {} |
|
94 local clanID = {} |
|
93 |
95 |
94 -- for ease of use let's track previous selection |
96 -- for ease of use let's track previous selection |
95 teamLStructIndex = {} |
97 local teamLStructIndex = {} |
96 teamLObjectMode = {} |
98 local teamLObjectMode = {} |
97 teamLCrateMode = {} |
99 local teamLCrateMode = {} |
98 teamLMineIndex = {} |
100 local teamLMineIndex = {} |
99 teamLWeapIndex = {} |
101 local teamLWeapIndex = {} |
100 teamLUtilIndex = {} |
102 local teamLUtilIndex = {} |
101 |
103 |
102 clanUsedExtraTime = {} |
104 local clanUsedExtraTime = {} |
103 clanCratesSpawned = {} |
105 local clanCratesSpawned = {} |
104 clanFirstTurn = {} |
106 local clanFirstTurn = {} |
105 |
107 |
106 effectTimer = 0 |
108 local effectTimer = 0 |
107 |
109 |
108 wallsVisible = false |
110 local wallsVisible = false |
109 wX = {} |
111 local wX = {} |
110 wY = {} |
112 local wY = {} |
111 wWidth = {} |
113 local wWidth = {} |
112 wHeight = {} |
114 local wHeight = {} |
113 wCol = {} |
115 local wCol = {} |
114 margin = 20 |
116 local margin = 20 |
115 |
117 |
116 clanPowerTag = nil |
118 local clanPowerTag = nil |
117 lastWep = nil |
119 local lastWep = nil |
118 |
120 |
119 checkForSpecialWeaponsIn = -1 |
121 local checkForSpecialWeaponsIn = -1 |
120 |
122 |
121 -- Fake ammo types, for the overwritten weapons in Construction Mode |
123 -- Fake ammo types, for the overwritten weapons in Construction Mode |
122 amCMStructurePlacer = amAirAttack |
124 local amCMStructurePlacer = amAirAttack |
123 amCMCratePlacer = amNapalm |
125 local amCMCratePlacer = amNapalm |
124 amCMObjectPlacer = amDrillStrike |
126 local amCMObjectPlacer = amDrillStrike |
125 |
127 |
126 -- Config variables (script parameter) |
128 -- Config variables (script parameter) |
127 conf_initialEnergy = 550 |
129 local conf_initialEnergy = 550 |
128 conf_energyPerRound = 50 |
130 local conf_energyPerRound = 50 |
129 conf_maxEnergy = 1000 |
131 local conf_maxEnergy = 1000 |
130 conf_cratesPerRound = 5 |
132 local conf_cratesPerRound = 5 |
133 |
|
134 ----------------------- |
|
135 -- CRATE DEFINITIONS -- |
|
136 ----------------------- |
|
137 -- format: |
|
138 -- { ammoType, ammoTypeString, unused, cost } |
|
139 |
|
140 -- Cost factor |
|
141 local placeholder = 20 |
|
142 |
|
143 -- WEAPON CRATES |
|
144 -- Weapons which shouldn't be aded: |
|
145 -- Air attack, napalm, drillstrike: Overwritten weapons for the Construction Mode tools |
|
146 local atkArray = { |
|
147 {amBazooka, "amBazooka", 0, 2*placeholder}, |
|
148 --{amBee, "amBee", 0, 4*placeholder}, |
|
149 {amMortar, "amMortar", 0, 1*placeholder}, |
|
150 {amDrill, "amDrill", 0, 3*placeholder}, |
|
151 {amSnowball, "amSnowball", 0, 3*placeholder}, |
|
152 |
|
153 {amGrenade, "amGrenade", 0, 2*placeholder}, |
|
154 {amClusterBomb, "amClusterBomb", 0, 3*placeholder}, |
|
155 {amWatermelon, "amWatermelon", 0, 25*placeholder}, |
|
156 {amHellishBomb, "amHellishBomb", 0, 25*placeholder}, |
|
157 {amMolotov, "amMolotov", 0, 3*placeholder}, |
|
158 {amGasBomb, "amGasBomb", 0, 3*placeholder}, |
|
159 |
|
160 {amShotgun, "amShotgun", 0, 2*placeholder}, |
|
161 {amDEagle, "amDEagle", 0, 2*placeholder}, |
|
162 {amSniperRifle, "amSniperRifle", 0, 3*placeholder}, |
|
163 --{amSineGun, "amSineGun", 0, 6*placeholder}, |
|
164 {amFlamethrower, "amFlamethrower", 0, 4*placeholder}, |
|
165 {amIceGun, "amIceGun", 0, 15*placeholder}, |
|
166 |
|
167 {amFirePunch, "amFirePunch", 0, 3*placeholder}, |
|
168 {amWhip, "amWhip", 0, 1*placeholder}, |
|
169 {amBaseballBat, "amBaseballBat", 0, 7*placeholder}, |
|
170 --{amKamikaze, "amKamikaze", 0, 1*placeholder}, |
|
171 {amSeduction, "amSeduction", 0, 1*placeholder}, |
|
172 {amHammer, "amHammer", 0, 1*placeholder}, |
|
173 |
|
174 {amMine, "amMine", 0, 1*placeholder}, |
|
175 {amDynamite, "amDynamite", 0, 9*placeholder}, |
|
176 {amCake, "amCake", 0, 25*placeholder}, |
|
177 {amBallgun, "amBallgun", 0, 40*placeholder}, |
|
178 --{amRCPlane, "amRCPlane", 0, 25*placeholder}, |
|
179 {amSMine, "amSMine", 0, 5*placeholder}, |
|
180 |
|
181 --{amMineStrike, "amMineStrike", 0, 15*placeholder}, |
|
182 --{amPiano, "amPiano", 0, 40*placeholder}, |
|
183 |
|
184 {amPickHammer, "amPickHammer", 0, 2*placeholder}, |
|
185 {amBlowTorch, "amBlowTorch", 0, 4*placeholder}, |
|
186 {amKnife, "amKnife", 0, 2*placeholder}, |
|
187 |
|
188 {amBirdy, "amBirdy", 0, 7*placeholder}, |
|
189 |
|
190 {amDuck, "amDuck", 0, 2*placeholder} |
|
191 } |
|
192 |
|
193 -- UTILITY CRATES -- |
|
194 |
|
195 -- Utilities which shouldn't be added: |
|
196 -- * Teleport: We have teleportation node |
|
197 -- * Switch: Always infinite |
|
198 -- * Girder, rubber: Requires construction station |
|
199 -- * Resurrector: We have the resurrector structure for this |
|
200 |
|
201 -- Utilities which might be weird for this mode: |
|
202 -- * Tardis: Randomly teleports hog, maybe even into enemy clan's area |
|
203 local utilArray = { |
|
204 {amLandGun, "amLandGun", 0, 5*placeholder}, |
|
205 |
|
206 {amRope, "amRope", 0, 7*placeholder}, |
|
207 {amParachute, "amParachute", 0, 2*placeholder}, |
|
208 {amJetpack, "amJetpack", 0, 8*placeholder}, |
|
209 {amPortalGun, "amPortalGun", 0, 15*placeholder}, |
|
210 |
|
211 {amInvulnerable, "amInvulnerable", 0, 5*placeholder}, |
|
212 {amLaserSight, "amLaserSight", 0, 2*placeholder}, |
|
213 {amVampiric, "amVampiric", 0, 6*placeholder}, |
|
214 |
|
215 {amLowGravity, "amLowGravity", 0, 4*placeholder}, |
|
216 {amExtraDamage, "amExtraDamage", 0, 6*placeholder}, |
|
217 {amExtraTime, "amExtraTime", 0, 8*placeholder} |
|
218 } |
|
219 |
|
220 ---------------------------- |
|
221 -- Placement stuff |
|
222 ---------------------------- |
|
223 |
|
224 local cGear = nil -- detects placement of girders and objects (using airattack) |
|
225 local curWep = amNothing |
|
226 |
|
227 -- primary placement categories |
|
228 local cIndex = 1 -- category index |
|
229 local cat = { |
|
230 "Girder Placement Mode", |
|
231 "Rubber Placement Mode", |
|
232 "Mine Placement Mode", |
|
233 "Sticky Mine Placement Mode", |
|
234 "Barrel Placement Mode", |
|
235 "Weapon Crate Placement Mode", |
|
236 "Utility Crate Placement Mode", |
|
237 "Health Crate Placement Mode", |
|
238 "Structure Placement Mode" |
|
239 } |
|
240 local catReverse = {} |
|
241 for c=1, #cat do |
|
242 catReverse[cat[c]] = c |
|
243 end |
|
244 |
|
245 local sProx = { |
|
246 {loc("Girder Placement Mode"),false}, |
|
247 {loc("Rubber Placement Mode"),false}, |
|
248 {loc("Mine Placement Mode"),false}, |
|
249 {loc("Sticky Mine Placement Mode"),false}, |
|
250 {loc("Barrel Placement Mode"),false}, |
|
251 {loc("Weapon Crate Placement Mode"),false}, |
|
252 {loc("Utility Crate Placement Mode"),false}, |
|
253 {loc("Health Crate Placement Mode"),false}, |
|
254 {loc("Structure Placement Mode"),false}, |
|
255 {loc("Teleportation Mode"),false}, |
|
256 } |
|
257 |
|
258 |
|
259 local pMode = {} -- pMode contains custom subsets of the main categories |
|
260 local pIndex = 1 |
|
261 |
|
262 local CGR = 1 -- current girder rotation, we actually need this as HW remembers what rotation you last used |
|
263 |
|
264 local placedX = {} |
|
265 local placedY = {} |
|
266 local placedSpec = {} |
|
267 local placedSuperSpec = {} |
|
268 local placedType = {} |
|
269 local placedCount = 0 |
|
270 |
|
271 local sCirc -- circle that appears around selected gears |
|
272 local sGear = nil |
|
273 |
|
274 local tCirc = {} -- array of circles that appear around tagged gears |
|
275 |
|
276 |
|
131 |
277 |
132 function DrawClanPowerTag() |
278 function DrawClanPowerTag() |
133 |
279 |
134 zoomL = 1.3 |
280 local zoomL = 1.1 |
135 |
281 local xOffset = 45 |
136 xOffset = 40 |
282 local yOffset = 70 |
137 |
283 local tValue = clanPower[GetHogClan(CurrentHedgehog)] |
138 zoomL = 1.1 |
284 local tCol = 0x00ff00ff |
139 xOffset = 45 |
|
140 yOffset = 70 |
|
141 tCol = 0x00ff00ff |
|
142 tValue = clanPower[GetHogClan(CurrentHedgehog)] |
|
143 |
285 |
144 DeleteVisualGear(clanPowerTag) |
286 DeleteVisualGear(clanPowerTag) |
145 clanPowerTag = AddVisualGear(0, 0, vgtHealthTag, 0, false) |
287 clanPowerTag = AddVisualGear(-div(ScreenWidth, 2) + xOffset, ScreenHeight - yOffset, vgtHealthTag, tValue, false) |
146 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(clanPowerTag) |
288 |
147 SetVisualGearValues ( |
289 SetVisualGearValues( |
148 clanPowerTag, --id |
290 clanPowerTag, -- id |
149 -div(ScreenWidth,2) + xOffset, --xoffset |
291 nil, -- x offset (set above) |
150 ScreenHeight - yOffset, --yoffset |
292 nil, -- y offset (set above) |
151 0, --dx |
293 0, -- dx |
152 0, --dy |
294 0, -- dy |
153 zoomL, --zoom |
295 zoomL, -- zoom |
154 1, --~= 0 means align to screen |
296 1, -- ~= 0 means align to screen |
155 g7, --frameticks |
297 nil, -- frameticks |
156 tValue, --value |
298 nil, -- value (set above) |
157 240000, --timer |
299 240000, -- timer |
158 tCol --GetClanColor( GetHogClan(CurrentHedgehog) ) |
300 tCol -- color. -- GetClanColor( GetHogClan(CurrentHedgehog) ) |
159 ) |
301 ) |
160 |
302 |
161 end |
303 end |
162 |
304 |
163 function XYisInRect(px, py, psx, psy, pex, pey) |
305 function XYisInRect(px, py, psx, psy, pex, pey) |
164 |
306 |
168 return(false) |
310 return(false) |
169 end |
311 end |
170 |
312 |
171 end |
313 end |
172 |
314 |
173 function AddWall(zXMin,zYMin, zWidth, zHeight, zCol) |
315 function AddWall(zXMin, zYMin, zWidth, zHeight, zCol) |
174 |
316 |
175 table.insert(wX, zXMin) |
317 table.insert(wX, zXMin) |
176 table.insert(wY, zYMin) |
318 table.insert(wY, zYMin) |
177 table.insert(wWidth, zWidth) |
319 table.insert(wWidth, zWidth) |
178 table.insert(wHeight, zHeight) |
320 table.insert(wHeight, zHeight) |
180 |
322 |
181 end |
323 end |
182 |
324 |
183 function BorderSpark(zXMin,zYMin, zWidth, zHeight, bCol) |
325 function BorderSpark(zXMin,zYMin, zWidth, zHeight, bCol) |
184 |
326 |
185 eX = zXMin + GetRandom(zWidth+10) |
327 local eX = zXMin + GetRandom(zWidth+10) |
186 eY = zYMin + GetRandom(zHeight+10) |
328 local eY = zYMin + GetRandom(zHeight+10) |
187 tempE = AddVisualGear(eX, eY, vgtDust, 0, false) |
329 local tempE = AddVisualGear(eX, eY, vgtDust, 0, false) |
188 if tempE ~= 0 then |
330 if tempE ~= 0 then |
189 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) |
331 SetVisualGearValues(tempE, eX, eY, nil, nil, nil, nil, nil, 1, nil, bCol) |
190 SetVisualGearValues(tempE, eX, eY, g3, g4, g5, g6, g7, 1, g9, bCol ) |
|
191 end |
332 end |
192 |
333 |
193 end |
334 end |
194 |
335 |
195 function HandleBorderEffects() |
336 function HandleBorderEffects() |
242 |
383 |
243 end |
384 end |
244 |
385 |
245 function getThreatDamage(gear) |
386 function getThreatDamage(gear) |
246 |
387 |
388 local dmg |
|
247 --- damage amounts for weapons |
389 --- damage amounts for weapons |
248 if (GetGearType(gear) == gtGrenade) or |
390 if (GetGearType(gear) == gtGrenade) or |
249 (GetGearType(gear) == gtClusterBomb) or |
391 (GetGearType(gear) == gtClusterBomb) or |
250 (GetGearType(gear) == gtGasBomb) or |
392 (GetGearType(gear) == gtGasBomb) or |
251 (GetGearType(gear) == gtKnife) or |
393 (GetGearType(gear) == gtKnife) or |
252 (GetGearType(gear) == gtEgg) or |
394 (GetGearType(gear) == gtEgg) or |
253 (GetGearType(gear) == gtMolotov) or |
395 (GetGearType(gear) == gtMolotov) or |
254 (GetGearType(gear) == gtHellishBomb) or |
396 (GetGearType(gear) == gtHellishBomb) or |
255 (GetGearType(gear) == gtWatermelon) or |
397 (GetGearType(gear) == gtWatermelon) or |
256 (GetGearType(gear) == gtSMine) |
398 (GetGearType(gear) == gtSMine) then |
257 then |
|
258 dmg = 30 |
399 dmg = 30 |
259 |
400 |
260 elseif (GetGearType(gear) == gtMelonPiece) then |
401 elseif (GetGearType(gear) == gtMelonPiece) then |
261 dmg = 40 |
402 dmg = 40 |
262 |
403 |
266 (GetGearType(gear) == gtCluster) then |
407 (GetGearType(gear) == gtCluster) then |
267 dmg = 20 |
408 dmg = 20 |
268 |
409 |
269 elseif (GetGearType(gear) == gtFlame) or |
410 elseif (GetGearType(gear) == gtFlame) or |
270 (GetGearType(gear) == gtPortal) or |
411 (GetGearType(gear) == gtPortal) or |
271 (GetGearType(gear) == gtDynamite) |
412 (GetGearType(gear) == gtDynamite) then |
272 then |
|
273 dmg = 0 |
413 dmg = 0 |
274 |
414 |
275 elseif (GetGearType(gear) == gtBall) then |
415 elseif (GetGearType(gear) == gtBall) then |
276 dmg = 1 |
416 dmg = 1 |
277 |
417 |
278 else --normal shell, snowball etc |
418 else -- normal shell, snowball etc |
279 dmg = 65 |
419 dmg = 65 |
280 end |
420 end |
281 |
421 |
282 return(dmg) |
422 return(dmg) |
283 |
423 |
284 end |
424 end |
285 |
425 |
286 function setGearReflectionValues(gear) |
426 function setGearReflectionValues(gear) |
287 |
427 |
288 dmg = getThreatDamage(gear) |
428 local dmg = getThreatDamage(gear) |
289 setGearValue(gear,"damage",dmg) |
429 setGearValue(gear,"damage",dmg) |
290 setGearValue(gear,"deflects",0) |
430 setGearValue(gear,"deflects",0) |
291 |
431 |
292 if (CurrentHedgehog ~= nil) then |
432 if (CurrentHedgehog ~= nil) then |
293 setGearValue(gear,"owner",GetHogClan(CurrentHedgehog)) -- NEW NEEDS CHANGE? |
433 setGearValue(gear,"owner",GetHogClan(CurrentHedgehog)) -- NEW NEEDS CHANGE? |
310 |
450 |
311 function AddStruc(pX,pY, pType, pClan) |
451 function AddStruc(pX,pY, pType, pClan) |
312 |
452 |
313 sUID = sUID + 1 |
453 sUID = sUID + 1 |
314 |
454 |
315 tempG = AddGear(0, 0, gtTarget, 0, 0, 0, 0) |
455 local tempG = AddGear(0, 0, gtTarget, 0, 0, 0, 0) |
316 SetGearPosition(tempG, pX, pY) |
456 SetGearPosition(tempG, pX, pY) |
317 setGearValue(tempG, "sUID", sUID) |
457 setGearValue(tempG, "sUID", sUID) |
318 |
458 |
319 tempCirc = AddVisualGear(0,0,vgtCircle,0,true) |
459 local tempCirc = AddVisualGear(0,0,vgtCircle,0,true) |
320 |
460 |
321 SetVisualGearValues(tempCirc, 0, 0, 100, 255, 1, 100, 0, 500, 1, 0xFFFFFF00) |
461 SetVisualGearValues(tempCirc, 0, 0, 100, 255, 1, 100, 0, 500, 1, 0xFFFFFF00) |
322 |
462 |
323 table.insert(strucID, sUID) |
463 table.insert(strucID, sUID) |
324 table.insert(strucType, pType) |
464 table.insert(strucType, pType) |
325 table.insert(strucGear,tempG) |
465 table.insert(strucGear,tempG) |
326 table.insert(strucClan,pClan) |
466 table.insert(strucClan,pClan) |
327 table.insert(strucCost,2) |
467 table.insert(strucCost,2) |
328 |
468 |
329 frameID = 0 |
469 local frameID = 0 |
330 visualSprite = sprTarget |
470 local visualSprite = sprTarget |
331 madness = AddVisualGear(GetX(tempG), GetY(tempG), vgtStraightShot, 1, true,1) |
471 local madness = AddVisualGear(GetX(tempG), GetY(tempG), vgtStraightShot, 1, true,1) |
332 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(madness) --g9 |
|
333 |
|
334 |
472 |
335 if pType == loc("Reflector Shield") then |
473 if pType == loc("Reflector Shield") then |
336 table.insert(strucHealth,255) |
474 table.insert(strucHealth,255) |
337 |
475 |
338 else |
476 else |
381 table.insert(strucCircRadius,750) |
519 table.insert(strucCircRadius,750) |
382 frameID = 5 |
520 frameID = 5 |
383 end |
521 end |
384 |
522 |
385 |
523 |
386 SetVisualGearValues(madness, g1, g2, 0, 0, g5, frameID, g7, visualSprite, g9, g10 ) |
524 SetVisualGearValues(madness, nil, nil, 0, 0, nil, frameID, nil, visualSprite, nil, nil) |
387 SetState(tempG, bor(GetState(tempG),gstInvisible) ) |
525 SetState(tempG, bor(GetState(tempG),gstInvisible) ) |
388 table.insert(strucAltDisplay, madness) |
526 table.insert(strucAltDisplay, madness) |
389 |
527 |
390 end |
528 end |
391 |
529 |
392 -- this is basically onStructureDelete |
530 -- this is basically onStructureDelete |
393 -- we may need to expand it for non-gear structures later |
531 -- we may need to expand it for non-gear structures later |
394 function CheckGearForStructureLink(gear) |
532 function CheckGearForStructureLink(gear) |
395 |
533 |
396 respawnerDestroyed = false |
534 local respawnerDestroyed = false |
397 |
535 |
398 for i = 1, #strucID do |
536 for i = 1, #strucID do |
399 if strucID[i] == getGearValue(gear,"sUID") then |
537 if strucID[i] == getGearValue(gear,"sUID") then |
400 |
538 |
401 if strucType[i] == loc("Respawner") then |
539 if strucType[i] == loc("Respawner") then |
438 end |
576 end |
439 |
577 |
440 -- this is called when a respawner blows up |
578 -- this is called when a respawner blows up |
441 function RecalibrateRespawn(gear) |
579 function RecalibrateRespawn(gear) |
442 |
580 |
443 respawnerList = {} |
581 local respawnerList = {} |
444 for i = 1, #strucID do |
582 for i = 1, #strucID do |
445 if (strucType[i] == loc("Respawner")) and (strucClan[i] == GetHogClan(gear)) then |
583 if (strucType[i] == loc("Respawner")) and (strucClan[i] == GetHogClan(gear)) then |
446 table.insert(respawnerList, i) |
584 table.insert(respawnerList, i) |
447 end |
585 end |
448 end |
586 end |
456 end |
594 end |
457 |
595 |
458 --resposition dead hogs at a respawner if they own one |
596 --resposition dead hogs at a respawner if they own one |
459 function FindRespawner(gear) |
597 function FindRespawner(gear) |
460 |
598 |
461 respawnerList = {} |
599 local respawnerList = {} |
462 for i = 1, #strucID do |
600 for i = 1, #strucID do |
463 if (strucType[i] == loc("Respawner")) and (strucClan[i] == GetHogClan(gear)) then |
601 if (strucType[i] == loc("Respawner")) and (strucClan[i] == GetHogClan(gear)) then |
464 table.insert(respawnerList, i) |
602 table.insert(respawnerList, i) |
465 end |
603 end |
466 end |
604 end |
467 |
605 |
468 if #respawnerList >= 1 then |
606 if #respawnerList >= 1 then |
469 i = GetRandom(#respawnerList)+1 |
607 local i = GetRandom(#respawnerList)+1 |
470 SetGearPosition(gear,GetX(strucGear[respawnerList[i]]),GetY(strucGear[respawnerList[i]])-25) |
608 SetGearPosition(gear,GetX(strucGear[respawnerList[i]]),GetY(strucGear[respawnerList[i]])-25) |
471 AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false) |
609 AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false) |
472 else -- (this should never happen, but just in case) |
610 else -- (this should never happen, but just in case) |
473 SetEffect(gear, heResurrectable, 0) |
611 SetEffect(gear, heResurrectable, 0) |
474 DeleteGear(gear) |
612 DeleteGear(gear) |
476 |
614 |
477 end |
615 end |
478 |
616 |
479 function CheckTeleport(gear, tX, tY) |
617 function CheckTeleport(gear, tX, tY) |
480 |
618 |
481 teleportOriginSuccessful = false |
619 local teleportOriginSuccessful = false |
482 teleportDestinationSuccessful = false |
620 local teleportDestinationSuccessful = false |
483 |
621 |
484 for i = 1, #strucID do |
622 for i = 1, #strucID do |
485 |
623 |
486 if (strucType[i] == loc("Teleportation Node")) and (strucClan[i] == GetHogClan(CurrentHedgehog)) then |
624 if (strucType[i] == loc("Teleportation Node")) and (strucClan[i] == GetHogClan(CurrentHedgehog)) then |
487 |
625 |
488 dist = GetDistFromGearToXY(CurrentHedgehog,GetX(strucGear[i]), GetY(strucGear[i])) |
626 local dist = GetDistFromGearToXY(CurrentHedgehog,GetX(strucGear[i]), GetY(strucGear[i])) |
627 local NR |
|
489 if strucCircType[i] == 0 then |
628 if strucCircType[i] == 0 then |
490 NR = strucCircRadius[i] |
629 NR = strucCircRadius[i] |
491 else |
630 else |
492 NR = (48/100*strucCircRadius[i])/2 |
631 NR = (48/100*strucCircRadius[i])/2 |
493 end |
632 end |
518 end |
657 end |
519 |
658 |
520 --Check for proximity of gears to structures, and make structures behave accordingly |
659 --Check for proximity of gears to structures, and make structures behave accordingly |
521 function CheckProximity(gear) |
660 function CheckProximity(gear) |
522 |
661 |
523 dist = GetDistFromGearToXY(gear, GetX(strucGear[tempID]), GetY(strucGear[tempID])) |
662 local dist = GetDistFromGearToXY(gear, GetX(strucGear[globalTempID]), GetY(strucGear[globalTempID])) |
524 if not dist then |
663 if not dist then |
525 return |
664 return |
526 end |
665 end |
527 |
666 |
528 -- calculate my real radius if I am an aura |
667 -- calculate my real radius if I am an aura |
529 if strucCircType[tempID] == 0 then |
668 local NR |
530 NR = strucCircRadius[tempID] |
669 if strucCircType[globalTempID] == 0 then |
670 NR = strucCircRadius[globalTempID] |
|
531 else |
671 else |
532 NR = (48/100*strucCircRadius[tempID])/2 |
672 NR = (48/100*strucCircRadius[globalTempID])/2 |
533 end |
673 end |
534 |
674 |
535 -- we're in business |
675 -- we're in business |
536 if dist <= NR*NR then |
676 if dist <= NR*NR then |
537 |
677 |
538 -- heal clan hogs |
678 -- heal clan hogs |
539 if strucType[tempID] == loc("Healing Station") then |
679 if strucType[globalTempID] == loc("Healing Station") then |
540 |
680 |
541 if GetGearType(gear) == gtHedgehog then |
681 if GetGearType(gear) == gtHedgehog then |
542 if GetHogClan(gear) == strucClan[tempID] then |
682 if GetHogClan(gear) == strucClan[globalTempID] then |
543 |
683 |
544 local hogLife = GetHealth(gear) |
684 local hogLife = GetHealth(gear) |
545 -- Heal hog by 1 HP, up to 150 HP total |
685 -- Heal hog by 1 HP, up to 150 HP total |
546 if hogLife < 150 then |
686 if hogLife < 150 then |
547 if ((hogLife + 1) % 5) == 0 then |
687 if ((hogLife + 1) % 5) == 0 then |
551 SetHealth(gear, hogLife+1) |
691 SetHealth(gear, hogLife+1) |
552 end |
692 end |
553 end |
693 end |
554 |
694 |
555 -- change this to the med kit sprite health ++++s later |
695 -- change this to the med kit sprite health ++++s later |
556 tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true) |
696 local tempE = AddVisualGear(GetX(strucGear[globalTempID]), GetY(strucGear[globalTempID]), vgtSmoke, 0, true) |
557 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) |
697 SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, colorGreen) |
558 SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, colorGreen ) |
|
559 |
698 |
560 end |
699 end |
561 end |
700 end |
562 |
701 |
563 -- explode enemy clan hogs |
702 -- explode enemy clan hogs |
564 elseif strucType[tempID] == loc("Bio-Filter") then |
703 elseif strucType[globalTempID] == loc("Bio-Filter") then |
565 |
704 |
566 if GetGearType(gear) == gtHedgehog then |
705 if GetGearType(gear) == gtHedgehog then |
567 if (GetHogClan(gear) ~= strucClan[tempID]) and (GetHealth(gear) > 0) then |
706 if (GetHogClan(gear) ~= strucClan[globalTempID]) and (GetHealth(gear) > 0) then |
568 AddGear(GetX(gear), GetY(gear), gtGrenade, 0, 0, 0, 1) |
707 AddGear(GetX(gear), GetY(gear), gtGrenade, 0, 0, 0, 1) |
569 end |
708 end |
570 end |
709 end |
571 |
710 |
572 -- were those weapons in your pocket, or were you just happy to see me? |
711 -- were those weapons in your pocket, or were you just happy to see me? |
573 elseif strucType[tempID] == loc("Weapon Filter") then |
712 elseif strucType[globalTempID] == loc("Weapon Filter") then |
574 |
713 |
575 if GetGearType(gear) == gtHedgehog then |
714 if GetGearType(gear) == gtHedgehog then |
576 if (GetHogClan(gear) ~= strucClan[tempID]) then |
715 if (GetHogClan(gear) ~= strucClan[globalTempID]) then |
577 |
716 |
578 for wpnIndex = 1, #atkArray do |
717 for wpnIndex = 1, #atkArray do |
579 AddAmmo(gear, atkArray[wpnIndex][1], 0) |
718 AddAmmo(gear, atkArray[wpnIndex][1], 0) |
580 end |
719 end |
581 |
720 |
589 |
728 |
590 end |
729 end |
591 end |
730 end |
592 |
731 |
593 -- BOUNCE! POGO! POGO! POGO! POGO! |
732 -- BOUNCE! POGO! POGO! POGO! POGO! |
594 elseif strucType[tempID] == loc("Reflector Shield") then |
733 elseif strucType[globalTempID] == loc("Reflector Shield") then |
595 |
734 |
596 -- add check for whose projectile it is |
735 -- add check for whose projectile it is |
597 if gearCanBeDeflected(gear) == true then |
736 if gearCanBeDeflected(gear) == true then |
598 |
737 |
599 gOwner = getGearValue(gear,"owner") |
738 local gOwner = getGearValue(gear,"owner") |
600 gDeflects = getGearValue(gear,"deflects") |
739 local gDeflects = getGearValue(gear,"deflects") |
601 gDmg = getGearValue(gear,"damage") |
740 local gDmg = getGearValue(gear,"damage") |
602 |
741 |
603 if gDeflects >= 3 then |
742 if gDeflects >= 3 then |
604 DeleteGear(gear) |
743 DeleteGear(gear) |
605 AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false) |
744 AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false) |
606 PlaySound(sndVaporize) |
745 PlaySound(sndVaporize) |
607 elseif gOwner ~= strucClan[tempID] then |
746 elseif gOwner ~= strucClan[globalTempID] then |
608 --whether to vaporize gears or bounce them |
747 --whether to vaporize gears or bounce them |
609 if gDmg ~= 0 then |
748 if gDmg ~= 0 then |
610 dx, dy = GetGearVelocity(gear) |
749 local dx, dy = GetGearVelocity(gear) |
611 |
750 |
612 if (dx == 0) and (dy == 0) then |
751 if (dx == 0) and (dy == 0) then |
613 -- static mine, explosive, etc encountered |
752 -- static mine, explosive, etc encountered |
614 -- do nothing |
753 -- do nothing |
615 else |
754 else |
622 setGearValue(gear,"deflects",(gDeflects+1)) |
761 setGearValue(gear,"deflects",(gDeflects+1)) |
623 |
762 |
624 AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false) |
763 AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false) |
625 PlaySound(sndExplosion) |
764 PlaySound(sndExplosion) |
626 |
765 |
627 strucHealth[tempID] = strucHealth[tempID] - gDmg |
766 strucHealth[globalTempID] = strucHealth[globalTempID] - gDmg |
628 strucCircCol[tempID] = strucCircCol[tempID] - gDmg |
767 strucCircCol[globalTempID] = strucCircCol[globalTempID] - gDmg |
629 |
768 |
630 if strucHealth[tempID] <= 0 then |
769 if strucHealth[globalTempID] <= 0 then |
631 AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtExplosion, 0, false) |
770 AddVisualGear(GetX(strucGear[globalTempID]), GetY(strucGear[globalTempID]), vgtExplosion, 0, false) |
632 DeleteGear(strucGear[tempID]) |
771 DeleteGear(strucGear[globalTempID]) |
633 PlaySound(sndExplosion) |
772 PlaySound(sndExplosion) |
634 end |
773 end |
635 |
774 |
636 end |
775 end |
637 |
776 |
642 end |
781 end |
643 end |
782 end |
644 end |
783 end |
645 |
784 |
646 --mark as within range of a teleporter node |
785 --mark as within range of a teleporter node |
647 elseif strucType[tempID] == loc("Teleportation Node") then |
786 elseif strucType[globalTempID] == loc("Teleportation Node") then |
648 |
787 |
649 if GetGearType(gear) == gtHedgehog then |
788 if GetGearType(gear) == gtHedgehog then |
650 if GetHogClan(gear) == strucClan[tempID] then |
789 if GetHogClan(gear) == strucClan[globalTempID] then |
651 |
790 |
652 for i = 1, #sProx do |
791 for i = 1, #sProx do |
653 if sProx[i][1] == loc("Teleportation Mode") then |
792 if sProx[i][1] == loc("Teleportation Mode") then |
654 sProx[i][2] = true |
793 sProx[i][2] = true |
655 end |
794 end |
659 end |
798 end |
660 |
799 |
661 -- mark as within range of construction station |
800 -- mark as within range of construction station |
662 -- and thus allow menu access to placement modes |
801 -- and thus allow menu access to placement modes |
663 -- for girders, mines, sticky mines and barrels |
802 -- for girders, mines, sticky mines and barrels |
664 elseif strucType[tempID] == loc("Construction Station") then |
803 elseif strucType[globalTempID] == loc("Construction Station") then |
665 |
804 |
666 if GetGearType(gear) == gtHedgehog then |
805 if GetGearType(gear) == gtHedgehog then |
667 if GetHogClan(gear) == strucClan[tempID] then |
806 if GetHogClan(gear) == strucClan[globalTempID] then |
668 tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true) |
807 AddVisualGear(GetX(strucGear[globalTempID]), GetY(strucGear[globalTempID]), vgtSmoke, 0, true) |
669 |
808 |
670 for i = 1, #sProx do |
809 for i = 1, #sProx do |
671 if ((sProx[i][1] == loc("Girder Placement Mode")) |
810 if ((sProx[i][1] == loc("Girder Placement Mode")) |
672 or (sProx[i][1] == loc("Rubber Placement Mode")) |
811 or (sProx[i][1] == loc("Rubber Placement Mode")) |
673 or (sProx[i][1] == loc("Mine Placement Mode")) |
812 or (sProx[i][1] == loc("Mine Placement Mode")) |
683 end |
822 end |
684 |
823 |
685 -- mark as within stupport station range |
824 -- mark as within stupport station range |
686 -- and thus allow menu access to placement modes |
825 -- and thus allow menu access to placement modes |
687 -- for weapon, utility, and med crates |
826 -- for weapon, utility, and med crates |
688 elseif strucType[tempID] == loc("Support Station") then |
827 elseif strucType[globalTempID] == loc("Support Station") then |
689 |
828 |
690 if GetGearType(gear) == gtHedgehog then |
829 if GetGearType(gear) == gtHedgehog then |
691 if GetHogClan(gear) == strucClan[tempID] then |
830 if GetHogClan(gear) == strucClan[globalTempID] then |
692 tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true) |
831 AddVisualGear(GetX(strucGear[globalTempID]), GetY(strucGear[globalTempID]), vgtSmoke, 0, true) |
693 |
832 |
694 for i = 1, #sProx do |
833 for i = 1, #sProx do |
695 if ((sProx[i][1] == loc("Health Crate Placement Mode")) |
834 if ((sProx[i][1] == loc("Health Crate Placement Mode")) |
696 or (sProx[i][1] == loc("Weapon Crate Placement Mode")) |
835 or (sProx[i][1] == loc("Weapon Crate Placement Mode")) |
697 or (sProx[i][1] == loc("Utility Crate Placement Mode"))) |
836 or (sProx[i][1] == loc("Utility Crate Placement Mode"))) |
737 |
876 |
738 for i = 1, #strucID do |
877 for i = 1, #strucID do |
739 |
878 |
740 SetVisualGearValues(strucCirc[i], GetX(strucGear[i]), GetY(strucGear[i]), nil, nil, nil, nil, nil, strucCircRadius[i], nil, strucCircCol[i]) |
879 SetVisualGearValues(strucCirc[i], GetX(strucGear[i]), GetY(strucGear[i]), nil, nil, nil, nil, nil, strucCircRadius[i], nil, strucCircCol[i]) |
741 |
880 |
742 tempID = i |
881 globalTempID = i |
743 |
882 |
744 SetVisualGearValues(strucAltDisplay[i], GetX(strucGear[i]), GetY(strucGear[i]), 0, 0, nil, nil, 800000, sprTarget) |
883 SetVisualGearValues(strucAltDisplay[i], GetX(strucGear[i]), GetY(strucGear[i]), 0, 0, nil, nil, 800000, sprTarget) |
745 |
884 |
746 if GameTime % 100 == 0 then |
885 if GameTime % 100 == 0 then |
747 -- Check For proximity of stuff to our structures |
886 -- Check For proximity of stuff to our structures |
778 |
917 |
779 -- this is kinda messy and gross (even more than usual), fix it up at some point |
918 -- this is kinda messy and gross (even more than usual), fix it up at some point |
780 -- it just assumes that if you have access to girders, it works for rubbers |
919 -- it just assumes that if you have access to girders, it works for rubbers |
781 -- as that is what the struc implemenation means due to construction station |
920 -- as that is what the struc implemenation means due to construction station |
782 if GameTime % 100 == 0 and CurrentHedgehog ~= nil then |
921 if GameTime % 100 == 0 and CurrentHedgehog ~= nil then |
783 anyUIProx = false |
922 local anyUIProx = false |
784 for i = 1, #sProx do |
923 for i = 1, #sProx do |
785 |
924 |
786 if sProx[i][1] == loc("Girder Placement Mode") then |
925 if sProx[i][1] == loc("Girder Placement Mode") then |
787 if sProx[i][2] == true then |
926 if sProx[i][2] == true then |
788 AddAmmo(CurrentHedgehog, amGirder, 100) |
927 AddAmmo(CurrentHedgehog, amGirder, 100) |
825 |
964 |
826 lastWep = GetCurAmmoType() |
965 lastWep = GetCurAmmoType() |
827 |
966 |
828 end |
967 end |
829 |
968 |
830 --------------------------------- |
|
831 -- crates are made of this stuff |
|
832 --------------------------------- |
|
833 local placeholder = 20 |
|
834 |
|
835 -- Weapons which shouldn't be aded: |
|
836 -- Air attack, napalm, drillstrike: Overwritten weapons for the Construction Mode tools |
|
837 atkArray = { |
|
838 {amBazooka, "amBazooka", 0, 2*placeholder}, |
|
839 --{amBee, "amBee", 0, 4*placeholder}, |
|
840 {amMortar, "amMortar", 0, 1*placeholder}, |
|
841 {amDrill, "amDrill", 0, 3*placeholder}, |
|
842 {amSnowball, "amSnowball", 0, 3*placeholder}, |
|
843 |
|
844 {amGrenade, "amGrenade", 0, 2*placeholder}, |
|
845 {amClusterBomb, "amClusterBomb", 0, 3*placeholder}, |
|
846 {amWatermelon, "amWatermelon", 0, 25*placeholder}, |
|
847 {amHellishBomb, "amHellishBomb", 0, 25*placeholder}, |
|
848 {amMolotov, "amMolotov", 0, 3*placeholder}, |
|
849 {amGasBomb, "amGasBomb", 0, 3*placeholder}, |
|
850 |
|
851 {amShotgun, "amShotgun", 0, 2*placeholder}, |
|
852 {amDEagle, "amDEagle", 0, 2*placeholder}, |
|
853 {amSniperRifle, "amSniperRifle", 0, 3*placeholder}, |
|
854 --{amSineGun, "amSineGun", 0, 6*placeholder}, |
|
855 {amFlamethrower, "amFlamethrower", 0, 4*placeholder}, |
|
856 {amIceGun, "amIceGun", 0, 15*placeholder}, |
|
857 |
|
858 {amFirePunch, "amFirePunch", 0, 3*placeholder}, |
|
859 {amWhip, "amWhip", 0, 1*placeholder}, |
|
860 {amBaseballBat, "amBaseballBat", 0, 7*placeholder}, |
|
861 --{amKamikaze, "amKamikaze", 0, 1*placeholder}, |
|
862 {amSeduction, "amSeduction", 0, 1*placeholder}, |
|
863 {amHammer, "amHammer", 0, 1*placeholder}, |
|
864 |
|
865 {amMine, "amMine", 0, 1*placeholder}, |
|
866 {amDynamite, "amDynamite", 0, 9*placeholder}, |
|
867 {amCake, "amCake", 0, 25*placeholder}, |
|
868 {amBallgun, "amBallgun", 0, 40*placeholder}, |
|
869 --{amRCPlane, "amRCPlane", 0, 25*placeholder}, |
|
870 {amSMine, "amSMine", 0, 5*placeholder}, |
|
871 |
|
872 --{amMineStrike, "amMineStrike", 0, 15*placeholder}, |
|
873 --{amPiano, "amPiano", 0, 40*placeholder}, |
|
874 |
|
875 {amPickHammer, "amPickHammer", 0, 2*placeholder}, |
|
876 {amBlowTorch, "amBlowTorch", 0, 4*placeholder}, |
|
877 {amKnife, "amKnife", 0, 2*placeholder}, |
|
878 |
|
879 {amBirdy, "amBirdy", 0, 7*placeholder}, |
|
880 |
|
881 {amDuck, "amDuck", 0, 2*placeholder} |
|
882 } |
|
883 |
|
884 -- Utilities which shouldn't be added: |
|
885 -- * Teleport: We have teleportation node |
|
886 -- * Switch: Always infinite |
|
887 -- * Girder, rubber: Requires construction station |
|
888 -- * Resurrector: We have the resurrector structure for this |
|
889 |
|
890 -- Utilities which might be weird for this mode: |
|
891 -- * Tardis: Randomly teleports hog, maybe even into enemy clan's area |
|
892 utilArray = { |
|
893 {amLandGun, "amLandGun", 0, 5*placeholder}, |
|
894 |
|
895 {amRope, "amRope", 0, 7*placeholder}, |
|
896 {amParachute, "amParachute", 0, 2*placeholder}, |
|
897 {amJetpack, "amJetpack", 0, 8*placeholder}, |
|
898 {amPortalGun, "amPortalGun", 0, 15*placeholder}, |
|
899 |
|
900 {amInvulnerable, "amInvulnerable", 0, 5*placeholder}, |
|
901 {amLaserSight, "amLaserSight", 0, 2*placeholder}, |
|
902 {amVampiric, "amVampiric", 0, 6*placeholder}, |
|
903 |
|
904 {amLowGravity, "amLowGravity", 0, 4*placeholder}, |
|
905 {amExtraDamage, "amExtraDamage", 0, 6*placeholder}, |
|
906 {amExtraTime, "amExtraTime", 0, 8*placeholder} |
|
907 } |
|
908 |
|
909 ---------------------------- |
|
910 -- Placement stuff |
|
911 ---------------------------- |
|
912 |
|
913 local cGear = nil -- detects placement of girders and objects (using airattack) |
|
914 local curWep = amNothing |
|
915 |
|
916 -- primary placement categories |
|
917 local cIndex = 1 -- category index |
|
918 local cat = { |
|
919 "Girder Placement Mode", |
|
920 "Rubber Placement Mode", |
|
921 "Mine Placement Mode", |
|
922 "Sticky Mine Placement Mode", |
|
923 "Barrel Placement Mode", |
|
924 "Weapon Crate Placement Mode", |
|
925 "Utility Crate Placement Mode", |
|
926 "Health Crate Placement Mode", |
|
927 "Structure Placement Mode" |
|
928 } |
|
929 local catReverse = {} |
|
930 for c=1, #cat do |
|
931 catReverse[cat[c]] = c |
|
932 end |
|
933 |
|
934 sProx = { |
|
935 {loc("Girder Placement Mode"),false}, |
|
936 {loc("Rubber Placement Mode"),false}, |
|
937 {loc("Mine Placement Mode"),false}, |
|
938 {loc("Sticky Mine Placement Mode"),false}, |
|
939 {loc("Barrel Placement Mode"),false}, |
|
940 {loc("Weapon Crate Placement Mode"),false}, |
|
941 {loc("Utility Crate Placement Mode"),false}, |
|
942 {loc("Health Crate Placement Mode"),false}, |
|
943 {loc("Structure Placement Mode"),false}, |
|
944 {loc("Teleportation Mode"),false}, |
|
945 } |
|
946 |
|
947 |
|
948 local pMode = {} -- pMode contains custom subsets of the main categories |
|
949 local pIndex = 1 |
|
950 |
|
951 local CGR = 1 -- current girder rotation, we actually need this as HW remembers what rotation you last used |
|
952 |
|
953 local placedX = {} |
|
954 local placedY = {} |
|
955 local placedSpec = {} |
|
956 local placedSuperSpec = {} |
|
957 local placedType = {} |
|
958 local placedCount = 0 |
|
959 |
|
960 local sCirc -- circle that appears around selected gears |
|
961 local sGear = nil |
|
962 local closestDist |
|
963 local closestGear = nil |
|
964 |
|
965 local tCirc = {} -- array of circles that appear around tagged gears |
|
966 |
|
967 ------------------------ |
969 ------------------------ |
968 -- SOME GENERAL METHODS |
970 -- SOME GENERAL METHODS |
969 ------------------------ |
971 ------------------------ |
970 |
972 |
971 function GetDistFromGearToXY(gear, g2X, g2Y) |
973 function GetDistFromGearToXY(gear, g2X, g2Y) |
972 |
974 |
973 g1X, g1Y = GetGearPosition(gear) |
975 local g1X, g1Y = GetGearPosition(gear) |
974 if not g1X then |
976 if not g1X then |
975 return nil |
977 return nil |
976 end |
978 end |
977 q = g1X - g2X |
979 local q = g1X - g2X |
978 w = g1Y - g2Y |
980 local w = g1Y - g2Y |
979 |
981 |
980 return ( (q*q) + (w*w) ) |
982 return ( (q*q) + (w*w) ) |
981 |
983 |
982 end |
984 end |
983 |
985 |
984 function GetDistFromXYtoXY(a, b, c, d) |
986 function GetDistFromXYtoXY(a, b, c, d) |
985 q = a - c |
987 local q = a - c |
986 w = b - d |
988 local w = b - d |
987 return ( (q*q) + (w*w) ) |
989 return ( (q*q) + (w*w) ) |
988 end |
|
989 |
|
990 function SelectGear(gear) |
|
991 |
|
992 d = GetDistFromGearToXY(gear, placedX[placedCount], placedY[placedCount]) |
|
993 |
|
994 if d < closestDist then |
|
995 closestDist = d |
|
996 closestGear = gear |
|
997 end |
|
998 |
|
999 end |
990 end |
1000 |
991 |
1001 -- essentially called when user clicks the mouse |
992 -- essentially called when user clicks the mouse |
1002 -- with girders or an airattack |
993 -- with girders or an airattack |
1003 function PlaceObject(x,y) |
994 function PlaceObject(x,y) |
1016 elseif (XYisInRect(x,y, clanBoundsSX[GetHogClan(CurrentHedgehog)],clanBoundsSY[GetHogClan(CurrentHedgehog)],clanBoundsEX[GetHogClan(CurrentHedgehog)],clanBoundsEY[GetHogClan(CurrentHedgehog)]) == true) |
1007 elseif (XYisInRect(x,y, clanBoundsSX[GetHogClan(CurrentHedgehog)],clanBoundsSY[GetHogClan(CurrentHedgehog)],clanBoundsEX[GetHogClan(CurrentHedgehog)],clanBoundsEY[GetHogClan(CurrentHedgehog)]) == true) |
1017 and (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) |
1008 and (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) |
1018 then |
1009 then |
1019 -- For checking if the actual placement succeeded |
1010 -- For checking if the actual placement succeeded |
1020 local placed = false |
1011 local placed = false |
1012 local gear |
|
1021 if cat[cIndex] == "Girder Placement Mode" then |
1013 if cat[cIndex] == "Girder Placement Mode" then |
1022 placed = PlaceGirder(x, y, CGR) |
1014 placed = PlaceGirder(x, y, CGR) |
1023 placedSpec[placedCount] = CGR |
1015 placedSpec[placedCount] = CGR |
1024 elseif cat[cIndex] == "Rubber Placement Mode" then |
1016 elseif cat[cIndex] == "Rubber Placement Mode" then |
1025 placed = PlaceRubber(x, y, CGR) |
1017 placed = PlaceRubber(x, y, CGR) |
1255 end |
1247 end |
1256 |
1248 |
1257 -- some kind of target detected, tell me your story |
1249 -- some kind of target detected, tell me your story |
1258 if cGear ~= nil then |
1250 if cGear ~= nil then |
1259 |
1251 |
1260 x,y = GetGearTarget(cGear) |
1252 local x,y = GetGearTarget(cGear) |
1261 |
1253 |
1262 if GetGearType(cGear) == gtAirAttack then |
1254 if GetGearType(cGear) == gtAirAttack then |
1263 DeleteGear(cGear) |
1255 DeleteGear(cGear) |
1264 PlaceObject(x, y) |
1256 PlaceObject(x, y) |
1265 elseif GetGearType(cGear) == gtTeleport then |
1257 elseif GetGearType(cGear) == gtTeleport then |
1620 teamLMineIndex[team] = 1 |
1612 teamLMineIndex[team] = 1 |
1621 teamLWeapIndex[team] = 1 |
1613 teamLWeapIndex[team] = 1 |
1622 teamLUtilIndex[team] = 1 |
1614 teamLUtilIndex[team] = 1 |
1623 end |
1615 end |
1624 |
1616 |
1625 tMapWidth = RightX - LeftX |
1617 local tMapWidth = RightX - LeftX |
1626 tMapHeight = WaterLine - TopY |
1618 local tMapHeight = WaterLine - TopY |
1627 clanInterval = div(tMapWidth,ClansCount) |
1619 local clanInterval = div(tMapWidth,ClansCount) |
1628 |
1620 |
1629 -- define construction areas for each clan |
1621 -- define construction areas for each clan |
1630 -- if there are forts-based spawn locations, adjust areas around them |
1622 -- if there are forts-based spawn locations, adjust areas around them |
1631 for i = 0, ClansCount-1 do |
1623 for i = 0, ClansCount-1 do |
1632 local slot |
1624 local slot |