Advertisement
inkoalawetrust

Destructible Car

Apr 14th, 2021
570
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.92 KB | None | 0 0
  1. Class DestructibleSedan : DestructibleVehicleBase
  2. {
  3.     Default
  4.     {
  5.         //$Title Sedan
  6.         //$Category Obstacles/Vehicles
  7.         //$Angled
  8.         Health 500;
  9.         Radius 64;
  10.         Height 48;
  11.         DeathHeight 48;
  12.         Mass 1500;
  13.         Obituary "%o was killed by a car explosion.";
  14.         DamageFactor "TankCrush", 32767;
  15.         DestructibleVehicleBase.VehicleCrashVolume 0.5;
  16.         DestructibleVehicleBase.VehicleFallThreshold 32;
  17.     }
  18.     Bool User_DisableFireParticles;
  19.     Bool User_NoCarAlarm;
  20.     Bool User_Indestructible;
  21.     Bool GlassBroken;
  22.     Void A_RandomizeSedanParticleValues()
  23.     {
  24.         RNGXOfs = FRandom (64,48);
  25.         RNGYOfs = FRandom (-16,16);
  26.         RNGVel = FRandom (2,8);
  27.         RNGSize = FRandom (2,6);
  28.         RNGLife = Random (35/2,35);
  29.     }
  30.     Override Void Tick()
  31.     {
  32.         Super.Tick();
  33.         //These user variables are checked here so they can be changed at runtime.
  34.         If (User_Indestructible) {bInvulnerable = True;}
  35.         Else {bInvulnerable = False;}
  36.         If (User_NoCarAlarm) {bNoPain = True;}
  37.         Else {bNoPain = False;}
  38.     }
  39.     Void A_BreakSedanWindows(Double voffset = 40)
  40.     {
  41.         //Glass spawn points (In relation to the front of the car.)
  42.         A_SpawnItemEx ("GlassShardSpawner",16,24,voffset); //Front right door window.
  43.         A_SpawnItemEx ("GlassShardSpawner",16,-24,voffset); //Front left door window.
  44.         A_SpawnItemEx ("GlassShardSpawner",-32,24,voffset); //Back right door window.
  45.         A_SpawnItemEx ("GlassShardSpawner",-32,-24,voffset); //Back left door window.
  46.         A_SpawnItemEx ("GlassShardSpawner",32,0,voffset); //Front car windshield.
  47.         A_SpawnItemEx ("GlassShardSpawner",-64,0,voffset); //Back car windshield.
  48.     }
  49.     States
  50.     {
  51.         Spawn:
  52.             RCND A 0
  53.             {
  54.                 If (Health < 400)
  55.                 {
  56.                     SetStateLabel ("MinorDamage");
  57.                 }
  58.             }
  59.             RCND A 1;
  60.             Loop;
  61.         MinorDamage:
  62.             RCBW A 0
  63.             {
  64.                 If (GlassBroken == False)
  65.                 {
  66.                     A_StartSound ("DestVeh/Generic/GlassBreaking");
  67.                     A_BreakSedanWindows();
  68.                     GlassBroken = True;
  69.                 }
  70.                 Else {}
  71.             }
  72.             RCBW A 0
  73.             {
  74.                 If (Health < 200)
  75.                 {
  76.                     SetStateLabel ("ExtraDamage");
  77.                 }
  78.             }
  79.             RCBW A 1;
  80.             Goto MinorDamage+1;
  81.         ExtraDamage:
  82.             RCCW A 1;
  83.             Loop;
  84.         Death:
  85.             RCBU A 4 Bright
  86.             {
  87.                 A_StopSound (CHAN_ALARM);
  88.                 A_StartSound ("DestVeh/Generic/CarExplosion");
  89.                 A_Explode (128,256,XF_NOTMISSILE,True,96);
  90.                 A_QuakeEx (1,1,1,35,0,512+128,flags:QF_SCALEDOWN);
  91.                 bSolid = True;
  92.                 bShootable = True;
  93.                 bNoDamage = True;
  94.                 bNeverTarget = True;
  95.                 bNotAutoAimed = True;
  96.             }
  97.             RCBU BCDEFGH 4 Bright;
  98.             RCBR ABCD 4 Bright
  99.             {
  100.                 If (User_DisableFireParticles == False)
  101.                 {
  102.                     A_SpawnParticle ("FFE50B",SPF_FULLBRIGHT|SPF_RELATIVE,lifetime:RNGLife,size:RNGSize,xoff:RNGXOfs,yoff:RNGYOfs,zoff:38,velz:RNGVel,accelz:0.1,sizestep:0.1);
  103.                     A_RandomizeSedanParticleValues();
  104.                     A_SpawnParticle ("FFE50B",SPF_FULLBRIGHT|SPF_RELATIVE,lifetime:RNGLife,size:RNGSize,xoff:RNGXOfs,yoff:RNGYOfs,zoff:38,velz:RNGVel,accelz:0.1,sizestep:0.1);
  105.                     A_RandomizeSedanParticleValues();
  106.                 }
  107.             }
  108.             Goto Death+8;
  109.         Crush:
  110.             TNT1 A 0;
  111.             Goto Death.TankCrush;
  112.         Death.TankCrush:
  113.             RCCR A 1
  114.             {
  115.                 A_BreakSedanWindows(8);
  116.                 A_StartSound ("DestVeh/Generic/GlassBreakingLoud");
  117.                 A_StartSound ("DestVeh/Generic/CarCrush");
  118.             }
  119.             RCCR A -1;
  120.             Stop;
  121.     }
  122. }
  123.  
  124. Class SedanGlassShard : Actor
  125. {
  126.     Default
  127.     {
  128.         Mass 1;
  129.         BounceType "Classic";
  130.         BounceFactor 0.2;
  131.         -NoGravity;
  132.     }
  133.     States
  134.     {
  135.         Spawn:
  136.             CSHR ABCDE 0 A_Jump (256/5,"DoGlassStuff");
  137.             Goto DoGlassStuff;
  138.         DoGlassStuff:
  139.             CSHR "#"
  140.             {
  141.                 A_SetAngle (FRandom(90,-90));
  142.                 A_ChangeVelocity (FRandom(2.0,8.0),FRandom(4.0,-4.0),FRandom(0.0,8.0));
  143.             }
  144.             CSHR "##########" 35;
  145.             Stop;
  146.     }
  147. }
  148.  
  149. Class GlassShardSpawner : Actor
  150. {
  151.     Default {+NoInteraction;}
  152.     Override PostBeginPlay()
  153.     {
  154.         Super.PostBeginplay();
  155.         A_SpawnItemEx ("SedanGlassShard");
  156.         A_SpawnItemEx ("SedanGlassShard");
  157.         A_SpawnItemEx ("SedanGlassShard");
  158.         A_SpawnItemEx ("SedanGlassShard");
  159.         A_SpawnItemEx ("SedanGlassShard");
  160.         Self.Destroy();
  161.     }
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement