inkoalawetrust

Broken APC code

Feb 1st, 2021 (edited)
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.86 KB | None | 0 0
  1. //The APC itself.
  2. Class MarineArmoredCarrier : Actor
  3. {
  4.     Default
  5.     {
  6.         //$Title Armored Personnel Carrier
  7.         //$Category Vehicles
  8.         Tag "Troop Transport";
  9.         Species "Tank";
  10.         Species "APC";
  11.         Species "MarineAlly";
  12.         //Defenses
  13.         DamageFactor "TankCrush", 0.0;
  14.         DamageFactor "AutocannonShell", 0.3;
  15.         DamageFactor "TankShell", 0.9;
  16.         DamageFactor "None", 0.6;
  17.         RipLevelMin 2;
  18.         //========
  19.         FriendlySeeBlocks 32;
  20.         MaxTargetRange 4096;
  21.         Health 1200;
  22.         Radius 56;
  23.         Height 68;
  24.         Speed 12;
  25.         Mass 10000;
  26.         //Flags
  27.         Monster;
  28.         -CountKill;
  29.         +Friendly;
  30.         +AvoidMelee;
  31.         +LookAllAround;
  32.         +NeverRespawn; //No infinite marine supply.
  33.         +Telestomp;
  34.         +NoBlockMonst;
  35.         +MThruSpecies;
  36.         +NoInfightSpecies;
  37.         +DontDrain;
  38.         +NoBlood;
  39.         +PuffOnActors;
  40.     }
  41.     enum APCSoundSlots
  42.     {
  43.         CHAN_MOVING = 91837,
  44.         CHAN_DOORS = 91838
  45.     }
  46.     int User_MarinesToSpawn; //The limit to how many marines the APC will spawn.
  47.     int MarinesSpawned; //Keeps track of how many marines the APC has spawned.
  48.     int RelativeAngle;//Used to make the APC turn 180 degrees to deploy troops.
  49.     Override Void PostBeginPlay()
  50.     {
  51.         Super.PostBeginPlay();
  52.         User_MarinesToSpawn = 6; //Default amount of marines to deploy;
  53.         MarinesSpawned = User_MarinesToSpawn;
  54.     }
  55.     Override Void Tick()
  56.     {
  57.         Super.Tick();
  58.         If (IsFrozen()) {A_StopSound (CHAN_MOVING);}
  59.         If (InStateSequence (CurState, ResolveState ("See")))
  60.         { A_StartSound ("APC/Moving",CHAN_MOVING,CHANF_LOOPING);} Else {A_StopSound (CHAN_MOVING);}
  61.     }
  62.     States
  63.     {
  64.         Spawn:
  65.             APCM A 8 A_LookEx (maxseedist:8192,1536);
  66.             Loop;
  67.         See:
  68.             APCM AB 4 A_Chase (null,"OpenDoors"); //SpinAround
  69.             Loop;
  70.         SpinAround:
  71.             APCM AB 4 //Spins the APC until it has turned in a full 180 degree angle.
  72.             {
  73.                 If (RelativeAngle >= 180)
  74.                 {
  75.                     RelativeAngle = 0;
  76.                     SetStateLabel ("OpenDoors");
  77.                     A_Log ("Deploying marines now...");
  78.                 }
  79.                 A_SetAngle (Angle+10,SPF_INTERPOLATE);
  80.                 RelativeAngle = RelativeAngle + 10;
  81.             }
  82.             Loop;
  83.         OpenDoors: //Add a metal door opening sound.
  84.             TNT1 A 0
  85.             {
  86.                 //Don't deploy any more marines if MarinesSpawned is over the MarinesToSpawn  user variable.
  87.                 If (MarinesSpawned <= 0){SetStateLabel ("See"); A_LOG ("no marines left");}
  88.             }
  89.             APCB A 16;
  90.             APCB B 16;
  91.             Goto DeployMarines;
  92.         DeployMarines:
  93.             APCB B 40
  94.             {
  95.                 Bool Spawned = False;
  96.                 Actor SpawnedActor = Null;
  97.                 int RandomDoor = RandomPick (0,-24); //Picks a random door for the marine to come out from
  98.                 [Spawned,SpawnedActor] = A_SpawnItemEx ("APCInfantrySpawner",xofs:-96,yofs:RandomDoor,zofs:24);
  99.                 //If the APC has a target, transfer it to the spawner which then transfers it to the marines
  100.                 If (SpawnedActor && Self.Target)
  101.                 {
  102.                     SpawnedActor.Target = Self.Target;
  103.                 }
  104.                 If (Spawned == True) {MarinesSpawned--;}
  105.                 a_logint (marinesspawned);
  106.             }
  107.             //TNT1 A 0 A_Jump (72,"ChangePosition");
  108.             Loop;
  109.         CloseDoors:
  110.             APCB BA 16;
  111.             Goto See;
  112.         ChangePosition:
  113.             APCM ABABABAB 4 A_Wander();
  114.             Goto See;
  115.     }
  116. }
  117. //The spawner for the marines, hopefully I'll be able to make a suer variable that gives you multiple spawners to choose from for each APC
  118. Class APCInfantrySpawner : RandomSpawner
  119. {
  120.     Default
  121.     {
  122.         DropItem "MarineAllyMG", 255, 140;
  123.         DropItem "MarineAllyCG", 255, 96;
  124.         DropItem "MarineAllySG", 255, 128;
  125.         DropItem "MarineAllyPistol", 255, 96;
  126.         DropItem "MarineAllySniper",255, 64;
  127.         DropItem "MarineAllyMinigun", 255, 8;
  128.     }
  129.     //The marines have to be set to being friendly again because otherwise they get spawned
  130.     //as enemies for some reason, also for some reason, this code seems to make the APC
  131.     //drop off 3 more marines than what MarinesToSpawn is set to since before I added this
  132.     //code that did not happen.
  133.     Override Void PostSpawn (Actor Spawned)
  134.     {
  135.         If (Self.Target) {Spawned.Target = Self.Target;}
  136.         Spawned.bFriendly = True;
  137.         Super.PostSpawn (Spawned);
  138.     }
  139. }
Add Comment
Please, Sign In to add comment