244 |
244 |
245 for i = 0, 1 do |
245 for i = 0, 1 do |
246 |
246 |
247 if fNeedsRespawn[i] == true then |
247 if fNeedsRespawn[i] == true then |
248 fGear[i] = SpawnFakeAmmoCrate(fSpawnX[i],fSpawnY[i],false,false) |
248 fGear[i] = SpawnFakeAmmoCrate(fSpawnX[i],fSpawnY[i],false,false) |
249 --fGear[i] = SpawnHealthCrate(fSpawnX[i],fSpawnY[i]) |
|
250 fNeedsRespawn[i] = false |
249 fNeedsRespawn[i] = false |
251 fIsMissing[i] = false -- new, this should solve problems of a respawned flag being "returned" when a player tries to score |
250 fIsMissing[i] = false -- new, this should solve problems of a respawned flag being "returned" when a player tries to score |
252 AddCaption(loc("Flag respawned!")) |
251 AddCaption(loc("Flag respawned!"), capcolDefault, capgrpAmmoinfo) |
253 end |
252 end |
254 |
253 |
255 end |
254 end |
256 |
255 |
257 end |
256 end |
258 |
257 |
259 function FlagDeleted(gear) |
258 function FlagDeleted(gear) |
260 |
259 |
261 local wtf, bbq |
260 local wtf, bbq |
262 PlaySound(sndShotgunReload) |
|
263 if (gear == fGear[0]) then |
261 if (gear == fGear[0]) then |
264 wtf = 0 |
262 wtf = 0 |
265 bbq = 1 |
263 bbq = 1 |
266 elseif (gear == fGear[1]) then |
264 elseif (gear == fGear[1]) then |
267 wtf = 1 |
265 wtf = 1 |
269 end |
267 end |
270 |
268 |
271 if CurrentHedgehog ~= nil then |
269 if CurrentHedgehog ~= nil then |
272 |
270 |
273 --if the player picks up the flag |
271 --if the player picks up the flag |
274 if CheckDistance(CurrentHedgehog, fGear[wtf]) < 1600 then |
272 if band(GetGearMessage(gear), gmDestroy) ~= 0 then |
275 |
273 |
276 fGear[wtf] = nil -- the flag has now disappeared and we shouldnt be pointing to it |
274 fGear[wtf] = nil -- the flag has now disappeared and we shouldnt be pointing to it |
277 |
275 |
278 -- player has successfully captured the enemy flag |
276 -- player has successfully captured the enemy flag |
279 if (GetHogClan(CurrentHedgehog) == wtf) and (CurrentHedgehog == fThief[bbq]) and (fIsMissing[wtf] == false) then |
277 if (GetHogClan(CurrentHedgehog) == wtf) and (CurrentHedgehog == fThief[bbq]) and (fIsMissing[wtf] == false) then |
|
278 PlaySound(sndShotgunReload) |
280 fIsMissing[wtf] = false |
279 fIsMissing[wtf] = false |
281 fNeedsRespawn[wtf] = true |
280 fNeedsRespawn[wtf] = true |
282 fIsMissing[bbq] = false |
281 fIsMissing[bbq] = false |
283 fNeedsRespawn[bbq] = true |
282 fNeedsRespawn[bbq] = true |
284 fCaptures[wtf] = fCaptures[wtf] +1 |
283 fCaptures[wtf] = fCaptures[wtf] +1 |
292 fThief[bbq] = nil -- player no longer has the enemy flag |
291 fThief[bbq] = nil -- player no longer has the enemy flag |
293 CheckScore(wtf) |
292 CheckScore(wtf) |
294 |
293 |
295 --if the player is returning the flag |
294 --if the player is returning the flag |
296 elseif GetHogClan(CurrentHedgehog) == wtf then |
295 elseif GetHogClan(CurrentHedgehog) == wtf then |
297 |
296 PlaySound(sndShotgunReload) |
298 fNeedsRespawn[wtf] = true |
297 fNeedsRespawn[wtf] = true |
299 |
298 |
300 -- NEW ADDIITON, does this work? Should make it possible to return your flag and then score in the same turn |
299 -- NEW ADDIITON, does this work? Should make it possible to return your flag and then score in the same turn |
301 if fIsMissing[wtf] == true then |
300 if fIsMissing[wtf] == true then |
302 HandleRespawns() -- this will set fIsMissing[wtf] to false :) |
301 HandleRespawns() -- this will set fIsMissing[wtf] to false :) |
303 AddCaption(loc("Flag returned!")) |
302 AddCaption(loc("Flag returned!"), capcolDefault, capgrpAmmoinfo) |
304 elseif fIsMissing[wtf] == false then |
303 elseif fIsMissing[wtf] == false then |
305 AddCaption(loc("That was pointless. The flag will respawn next round.")) |
304 AddCaption(loc("That was pointless. The flag will respawn next round.")) |
306 end |
305 end |
307 |
306 |
308 --if the player is taking the enemy flag |
307 --if the player is taking the enemy flag |
309 elseif GetHogClan(CurrentHedgehog) == bbq then |
308 elseif GetHogClan(CurrentHedgehog) == bbq then |
|
309 PlaySound(sndShotgunReload) |
310 fIsMissing[wtf] = true |
310 fIsMissing[wtf] = true |
311 for i = 0,numhhs-1 do |
311 for i = 0,numhhs-1 do |
312 if CurrentHedgehog == hhs[i] then |
312 if CurrentHedgehog == hhs[i] then |
313 fThief[wtf] = hhs[i] |
313 fThief[wtf] = hhs[i] |
314 end |
314 end |
319 else --below line doesnt usually get called |
319 else --below line doesnt usually get called |
320 AddCaption("Hmm... that wasn't supposed to happen...") |
320 AddCaption("Hmm... that wasn't supposed to happen...") |
321 |
321 |
322 end |
322 end |
323 |
323 |
324 -- if flag has been destroyed, probably |
324 -- if flag has been destroyed |
325 else |
325 else |
326 |
326 |
327 if GetY(fGear[wtf]) > 2025 then |
327 if GetY(fGear[wtf]) > 2025 then |
328 fGear[wtf] = nil |
328 fGear[wtf] = nil |
329 fIsMissing[wtf] = true |
329 fIsMissing[wtf] = true |
366 if fThiefY[wtf] > 2040 then |
366 if fThiefY[wtf] > 2040 then |
367 fGear[wtf] = SpawnFakeAmmoCrate(fThiefX[wtf],(fThiefY[wtf]+10),false,false) |
367 fGear[wtf] = SpawnFakeAmmoCrate(fThiefX[wtf],(fThiefY[wtf]+10),false,false) |
368 else |
368 else |
369 fGear[wtf] = SpawnFakeAmmoCrate(fThiefX[wtf],(fThiefY[wtf]-50),false,false) |
369 fGear[wtf] = SpawnFakeAmmoCrate(fThiefX[wtf],(fThiefY[wtf]-50),false,false) |
370 end |
370 end |
|
371 AddCaption(string.format(loc("%s has dropped the flag!"), GetHogName(gear)), capcolDefault, capgrpAmmoinfo) |
371 |
372 |
372 AddVisualGear(fThiefX[wtf], fThiefY[wtf], vgtBigExplosion, 0, false) |
373 AddVisualGear(fThiefX[wtf], fThiefY[wtf], vgtBigExplosion, 0, false) |
373 fThief[wtf] = nil |
374 fThief[wtf] = nil |
374 end |
375 end |
375 |
376 |
396 end |
397 end |
397 |
398 |
398 ------------------------ |
399 ------------------------ |
399 -- general methods |
400 -- general methods |
400 ------------------------ |
401 ------------------------ |
401 |
|
402 function CheckDistance(gear1, gear2) |
|
403 |
|
404 local g1X, g1Y = GetGearPosition(gear1) |
|
405 local g2X, g2Y = GetGearPosition(gear2) |
|
406 |
|
407 g1X = g1X - g2X |
|
408 g1Y = g1Y - g2Y |
|
409 local dist = (g1X*g1X) + (g1Y*g1Y) |
|
410 |
|
411 return dist |
|
412 |
|
413 end |
|
414 |
402 |
415 function CheckTeleporters() |
403 function CheckTeleporters() |
416 |
404 |
417 local teleportActive = false |
405 local teleportActive = false |
418 |
406 |
537 end |
526 end |
538 |
527 |
539 |
528 |
540 function onGameStart() |
529 function onGameStart() |
541 |
530 |
542 ShowMission(loc("CTF_Blizzard"), loc("Capture The Flag"), loc(" - Return the enemy flag to your base to score | - First team to 3 captures wins | - You may only score when your flag is in your base | - Hogs will drop the flag if killed, or drowned | - Dropped flags may be returned or recaptured | - Hogs respawn when killed"), 0, 0) |
531 ShowMission(loc("CTF_Blizzard"), loc("Capture The Flag"), |
543 |
532 loc("- Place your clan flag at the end of your first turn") .. "|" .. |
|
533 loc("- Return the enemy flag to your base to score") .."|".. |
|
534 string.format(loc("- First clan to score %d captures wins"), 3) .. "|".. |
|
535 loc("- You may only score when your flag is in your base") .."|".. |
|
536 loc("- Hogs will drop the flag when killed") .."|".. |
|
537 loc("- Dropped flags may be returned or recaptured").."|".. |
|
538 loc("- Hogs will be revived") .."|".. |
|
539 loc("- Enter the sparkling forcefield to teleport"), 0, 0) |
544 |
540 |
545 -- initialize teleporters |
541 -- initialize teleporters |
546 redTel = CreateZone(342,1316,42,449) -- red teleporter |
542 redTel = CreateZone(342,1316,42,449) -- red teleporter |
547 orangeTel = CreateZone(3719,1330,45,449) -- orange teleporter |
543 orangeTel = CreateZone(3719,1330,45,449) -- orange teleporter |
548 |
544 |