117 -1 means “do nothing”. ]] |
116 -1 means “do nothing”. ]] |
118 local checkForSpecialWeaponsIn = -1 |
117 local checkForSpecialWeaponsIn = -1 |
119 local lastWep = amNothing -- helper variable to track the previous hack |
118 local lastWep = amNothing -- helper variable to track the previous hack |
120 |
119 |
121 -- Colors |
120 -- Colors |
122 local colorRed = 0xff0000ff |
121 local colorClanTag = 0x00ff00ff |
123 local colorGreen = 0x00ff00ff |
122 |
|
123 local colorSupportStation = 0xFFFF00FF |
|
124 local colorConstructionStation = 0xFFFFFFFF |
|
125 local colorTeleportationNode = 0x0000FFFF |
|
126 local colorHealingStation = 0xFF808040 -- Just a slight glow |
|
127 local colorBioFilter = 0xFF0000FF |
|
128 local colorReflectorShield = 0xFFAE00FF |
|
129 local colorWeaponFilter = 0xA800FFFF |
|
130 |
|
131 local colorHealingStationParticle = 0x00FF00FF |
|
132 |
|
133 local colorMessage = 0xFFBA00FF |
124 |
134 |
125 -- Fake ammo types, for the overwritten weapons in Construction Mode |
135 -- Fake ammo types, for the overwritten weapons in Construction Mode |
126 local amCMStructurePlacer = amAirAttack |
136 local amCMStructurePlacer = amAirAttack |
127 local amCMCratePlacer = amNapalm |
137 local amCMCratePlacer = amNapalm |
128 local amCMObjectPlacer = amDrillStrike |
138 local amCMObjectPlacer = amDrillStrike |
441 SetGearPosition(tempG, pX, pY) |
452 SetGearPosition(tempG, pX, pY) |
442 setGearValue(tempG, "uniqueStructureID", uniqueStructureID) |
453 setGearValue(tempG, "uniqueStructureID", uniqueStructureID) |
443 |
454 |
444 local tempCirc = AddVisualGear(0,0,vgtCircle,0,true) |
455 local tempCirc = AddVisualGear(0,0,vgtCircle,0,true) |
445 |
456 |
446 SetVisualGearValues(tempCirc, 0, 0, 100, 255, 1, 100, 0, 500, 1, 0xFFFFFF00) |
457 if pType ~= "Respawner" and pType ~= "Generator" then |
|
458 SetVisualGearValues(tempCirc, 0, 0, 100, 255, 1, 100, 0, 500, 1, 0xFFFFFF00) |
|
459 table.insert(strucCirc, tempCirc) |
|
460 else |
|
461 table.insert(strucCirc, false) |
|
462 end |
447 |
463 |
448 table.insert(strucID, uniqueStructureID) |
464 table.insert(strucID, uniqueStructureID) |
449 table.insert(strucType, pType) |
465 table.insert(strucType, pType) |
450 table.insert(strucGear,tempG) |
466 table.insert(strucGear,tempG) |
451 table.insert(strucClan,pClan) |
467 table.insert(strucClan,pClan) |
460 |
476 |
461 else |
477 else |
462 table.insert(strucHealth,1) |
478 table.insert(strucHealth,1) |
463 end |
479 end |
464 |
480 |
465 table.insert(strucCirc,tempCirc) |
|
466 |
|
467 table.insert(strucCircType, 1) |
|
468 if pType == "Bio-Filter" then |
481 if pType == "Bio-Filter" then |
469 table.insert(strucCircCol,colorRed) |
482 table.insert(strucCircCol, colorBioFilter) |
470 table.insert(strucCircRadius,1000) |
483 table.insert(strucCircRadius,1000) |
471 frameID = 7 |
484 frameID = 7 |
472 elseif pType == "Healing Station" then |
485 elseif pType == "Healing Station" then |
473 table.insert(strucCircCol,0xFF00FF00) |
486 table.insert(strucCircCol, colorHealingStation) |
474 table.insert(strucCircRadius,500) |
487 table.insert(strucCircRadius,500) |
475 frameID = 3 |
488 frameID = 3 |
476 elseif pType == "Respawner" then |
489 elseif pType == "Respawner" then |
477 table.insert(strucCircCol,0xFF00FF00) |
490 table.insert(strucCircCol, 0) |
478 table.insert(strucCircRadius,75) |
491 table.insert(strucCircRadius,0) |
479 runOnHogs(EnableHogResurrectionForThisClan) |
492 runOnHogs(EnableHogResurrectionForThisClan) |
480 frameID = 1 |
493 frameID = 1 |
481 elseif pType == "Teleportation Node" then |
494 elseif pType == "Teleportation Node" then |
482 table.insert(strucCircCol,0x0000FFFF) |
495 table.insert(strucCircCol, colorTeleportationNode) |
483 table.insert(strucCircRadius,350) |
496 table.insert(strucCircRadius,350) |
484 frameID = 6 |
497 frameID = 6 |
485 elseif pType == "Generator" then |
498 elseif pType == "Generator" then |
486 table.insert(strucCircCol,0xFFFF00FF) |
499 table.insert(strucCircCol, 0) |
487 table.insert(strucCircRadius,75) |
500 table.insert(strucCircRadius,0) |
488 setGearValue(tempG, "power", 0) |
501 setGearValue(tempG, "power", 0) |
489 frameID = 2 |
502 frameID = 2 |
490 elseif pType == "Support Station" then |
503 elseif pType == "Support Station" then |
491 table.insert(strucCircCol,0xFFFF00FF) |
504 table.insert(strucCircCol, colorSupportStation) |
492 table.insert(strucCircRadius,500) |
505 table.insert(strucCircRadius,500) |
493 frameID = 4 |
506 frameID = 4 |
494 elseif pType == "Construction Station" then |
507 elseif pType == "Construction Station" then |
495 table.insert(strucCircCol,0xFFFFFFFF) |
508 table.insert(strucCircCol, colorConstructionStation) |
496 table.insert(strucCircRadius,500) |
509 table.insert(strucCircRadius,500) |
497 frameID = 8 |
510 frameID = 8 |
498 elseif pType == "Reflector Shield" then |
511 elseif pType == "Reflector Shield" then |
499 table.insert(strucCircCol,0xffae00ff) |
512 table.insert(strucCircCol, colorReflectorShield) |
500 table.insert(strucCircRadius,750) |
513 table.insert(strucCircRadius,750) |
501 frameID = 9 |
514 frameID = 9 |
502 elseif pType == "Weapon Filter" then |
515 elseif pType == "Weapon Filter" then |
503 table.insert(strucCircCol,0xa800ffff) |
516 table.insert(strucCircCol, colorWeaponFilter) |
504 table.insert(strucCircRadius,750) |
517 table.insert(strucCircRadius,750) |
505 frameID = 5 |
518 frameID = 5 |
506 end |
519 end |
507 |
520 |
508 |
521 |
535 DeleteVisualGear(strucCirc[i]) |
548 DeleteVisualGear(strucCirc[i]) |
536 table.remove(strucCirc,i) |
549 table.remove(strucCirc,i) |
537 |
550 |
538 table.remove(strucCircCol,i) |
551 table.remove(strucCircCol,i) |
539 table.remove(strucCircRadius,i) |
552 table.remove(strucCircRadius,i) |
540 table.remove(strucCircType,i) |
|
541 |
553 |
542 if strucAltDisplay[i] ~= 1 then |
554 if strucAltDisplay[i] ~= 1 then |
543 DeleteVisualGear(strucAltDisplay[i]) |
555 DeleteVisualGear(strucAltDisplay[i]) |
544 end |
556 end |
545 table.remove(strucAltDisplay,i) |
557 table.remove(strucAltDisplay,i) |
608 |
620 |
609 if (strucType[i] == "Teleportation Node") and (strucClan[i] == GetHogClan(CurrentHedgehog)) then |
621 if (strucType[i] == "Teleportation Node") and (strucClan[i] == GetHogClan(CurrentHedgehog)) then |
610 |
622 |
611 local dist = GetDistFromGearToXY(CurrentHedgehog,GetX(strucGear[i]), GetY(strucGear[i])) |
623 local dist = GetDistFromGearToXY(CurrentHedgehog,GetX(strucGear[i]), GetY(strucGear[i])) |
612 local NR |
624 local NR |
613 if strucCircType[i] == 0 then |
625 NR = (48/100*strucCircRadius[i])/2 |
614 NR = strucCircRadius[i] |
|
615 else |
|
616 NR = (48/100*strucCircRadius[i])/2 |
|
617 end |
|
618 if dist <= NR*NR then |
626 if dist <= NR*NR then |
619 teleportOriginSuccessful = true |
627 teleportOriginSuccessful = true |
620 end |
628 end |
621 |
629 |
622 dist = GetDistFromXYtoXY(tX,tY,GetX(strucGear[i]), GetY(strucGear[i])) |
630 dist = GetDistFromXYtoXY(tX,tY,GetX(strucGear[i]), GetY(strucGear[i])) |
623 if strucCircType[i] == 0 then |
631 NR = (48/100*strucCircRadius[i])/2 |
624 NR = strucCircRadius[i] |
|
625 else |
|
626 NR = (48/100*strucCircRadius[i])/2 |
|
627 end |
|
628 if dist <= NR*NR then |
632 if dist <= NR*NR then |
629 teleportDestinationSuccessful = true |
633 teleportDestinationSuccessful = true |
630 end |
634 end |
631 |
635 |
632 end |
636 end |
679 end |
679 end |
680 end |
680 end |
681 |
681 |
682 -- change this to the med kit sprite health ++++s later |
682 -- change this to the med kit sprite health ++++s later |
683 local tempE = AddVisualGear(GetX(strucGear[sID]), GetY(strucGear[sID]), vgtSmoke, 0, true) |
683 local tempE = AddVisualGear(GetX(strucGear[sID]), GetY(strucGear[sID]), vgtSmoke, 0, true) |
684 SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, colorGreen) |
684 SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, colorHealingStationParticle) |
685 |
685 |
686 end |
686 end |
687 end |
687 end |
688 |
688 |
689 -- explode enemy clan hogs |
689 -- explode enemy clan hogs |
749 |
749 |
750 AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false) |
750 AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false) |
751 PlaySound(sndExplosion) |
751 PlaySound(sndExplosion) |
752 |
752 |
753 strucHealth[sID] = strucHealth[sID] - gDmg |
753 strucHealth[sID] = strucHealth[sID] - gDmg |
754 strucCircCol[sID] = strucCircCol[sID] - gDmg |
754 if strucCirc[sID] then |
|
755 strucCircCol[sID] = strucCircCol[sID] - gDmg |
|
756 end |
755 |
757 |
756 if strucHealth[sID] <= 0 then |
758 if strucHealth[sID] <= 0 then |
757 AddVisualGear(GetX(strucGear[sID]), GetY(strucGear[sID]), vgtExplosion, 0, false) |
759 AddVisualGear(GetX(strucGear[sID]), GetY(strucGear[sID]), vgtExplosion, 0, false) |
758 DeleteGear(strucGear[sID]) |
760 DeleteGear(strucGear[sID]) |
759 PlaySound(sndExplosion) |
761 PlaySound(sndExplosion) |
842 end |
844 end |
843 end |
845 end |
844 |
846 |
845 for i = 1, #strucID do |
847 for i = 1, #strucID do |
846 |
848 |
847 SetVisualGearValues(strucCirc[i], GetX(strucGear[i]), GetY(strucGear[i]), nil, nil, nil, nil, nil, strucCircRadius[i], nil, strucCircCol[i]) |
849 if strucCirc[i] then |
|
850 SetVisualGearValues(strucCirc[i], GetX(strucGear[i]), GetY(strucGear[i]), nil, nil, nil, nil, nil, strucCircRadius[i], nil, strucCircCol[i]) |
|
851 end |
848 |
852 |
849 tempID_CheckProximity = i |
853 tempID_CheckProximity = i |
850 |
854 |
851 SetVisualGearValues(strucAltDisplay[i], GetX(strucGear[i]), GetY(strucGear[i]), 0, 0, nil, nil, 800000, sprTarget) |
855 SetVisualGearValues(strucAltDisplay[i], GetX(strucGear[i]), GetY(strucGear[i]), 0, 0, nil, nil, 800000, sprTarget) |
852 |
856 |
948 -- essentially called when user clicks the mouse |
952 -- essentially called when user clicks the mouse |
949 -- with girders or an airattack |
953 -- with girders or an airattack |
950 function PlaceObject(x,y) |
954 function PlaceObject(x,y) |
951 |
955 |
952 if (clanUsedExtraTime[GetHogClan(CurrentHedgehog)] == true) and (cat[cIndex] == "Utility Crate Placement Mode") and (utilArray[pIndex][1] == amExtraTime) then |
956 if (clanUsedExtraTime[GetHogClan(CurrentHedgehog)] == true) and (cat[cIndex] == "Utility Crate Placement Mode") and (utilArray[pIndex][1] == amExtraTime) then |
953 AddCaption(loc("You may only place 1 Extra Time crate per turn."),0xffba00ff,capgrpVolume) |
957 AddCaption(loc("You may only place 1 Extra Time crate per turn."),colorMessage,capgrpVolume) |
954 PlaySound(sndDenied) |
958 PlaySound(sndDenied) |
955 elseif (conf_cratesPerRound ~= "inf" and clanCratesSpawned[GetHogClan(CurrentHedgehog)] >= conf_cratesPerRound) and ( (cat[cIndex] == "Health Crate Placement Mode") or (cat[cIndex] == "Utility Crate Placement Mode") or (cat[cIndex] == "Weapon Crate Placement Mode") ) then |
959 elseif (conf_cratesPerRound ~= "inf" and clanCratesSpawned[GetHogClan(CurrentHedgehog)] >= conf_cratesPerRound) and ( (cat[cIndex] == "Health Crate Placement Mode") or (cat[cIndex] == "Utility Crate Placement Mode") or (cat[cIndex] == "Weapon Crate Placement Mode") ) then |
956 AddCaption(string.format(loc("You may only place %d crates per round."), conf_cratesPerRound),0xffba00ff,capgrpVolume) |
960 AddCaption(string.format(loc("You may only place %d crates per round."), conf_cratesPerRound),colorMessage,capgrpVolume) |
957 PlaySound(sndDenied) |
961 PlaySound(sndDenied) |
958 elseif (XYisInRect(x,y, clanBoundsSX[GetHogClan(CurrentHedgehog)],clanBoundsSY[GetHogClan(CurrentHedgehog)],clanBoundsEX[GetHogClan(CurrentHedgehog)],clanBoundsEY[GetHogClan(CurrentHedgehog)]) == true) |
962 elseif (XYisInRect(x,y, clanBoundsSX[GetHogClan(CurrentHedgehog)],clanBoundsSY[GetHogClan(CurrentHedgehog)],clanBoundsEX[GetHogClan(CurrentHedgehog)],clanBoundsEY[GetHogClan(CurrentHedgehog)]) == true) |
959 and (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) |
963 and (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) |
960 then |
964 then |
961 -- For checking if the actual placement succeeded |
965 -- For checking if the actual placement succeeded |
1008 end |
1012 end |
1009 |
1013 |
1010 if placed then |
1014 if placed then |
1011 clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] - placedExpense |
1015 clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] - placedExpense |
1012 else |
1016 else |
1013 AddCaption(loc("Invalid Placement"),0xffba00ff,capgrpVolume) |
1017 AddCaption(loc("Invalid Placement"),colorMessage,capgrpVolume) |
1014 PlaySound(sndDenied) |
1018 PlaySound(sndDenied) |
1015 end |
1019 end |
1016 |
1020 |
1017 else |
1021 else |
1018 if (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) then |
1022 if (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) then |
1019 AddCaption(loc("Invalid Placement"),0xffba00ff,capgrpVolume) |
1023 AddCaption(loc("Invalid Placement"),colorMessage,capgrpVolume) |
1020 else |
1024 else |
1021 AddCaption(loc("Insufficient Power"),0xffba00ff,capgrpVolume) |
1025 AddCaption(loc("Insufficient Power"),colorMessage,capgrpVolume) |
1022 end |
1026 end |
1023 PlaySound(sndDenied) |
1027 PlaySound(sndDenied) |
1024 end |
1028 end |
1025 |
1029 |
1026 end |
1030 end |