Advertisement
Guest User

IzarianChunks

a guest
Jul 5th, 2014
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // IzarianChunks.
  3. //=============================================================================
  4. class IzarianChunks extends CreatureChunks;
  5.  
  6. simulated function PostBeginPlay()
  7. {
  8.     if ( Region.Zone.bDestructive || ((Level.Game != None) && Level.Game.bLowGore) )
  9.     {
  10.         Destroy();
  11.         return;
  12.     }
  13.     if ( bMasterChunk && (Level.NetMode == NM_Client) ) //only if client
  14.         ClientExtraChunks(true);
  15.     else if ( Level.NetMode == NM_Client )
  16.         SetTimer(0.05, false);
  17.  
  18.     Super.PostBeginPlay();
  19. }
  20.  
  21. simulated function ClientExtraChunks(bool bSpawnChunks)
  22. {
  23.     local IzarianChunks carc;
  24.     local bloodpuffblue Blood;
  25.     local bloodspurtblue b;
  26.     local int n;
  27.  
  28.     If ( Level.NetMode == NM_DedicatedServer )
  29.     return;
  30.  
  31.     bMustSpawnChunks = false;
  32.     b = Spawn(class 'Bloodspurtblue',,,,rot(16384,0,0));
  33.     if ( bGreenBlood )
  34.         b.GreenBlood();
  35.     b.RemoteRole = ROLE_None;
  36.  
  37.     if ( !bSpawnChunks || (CarcassClass == None) )
  38.         return;
  39.  
  40.     n = 1;
  41.  
  42.     while ( (n<8) && (CarcassClass.Default.bodyparts[n] != none) )
  43.     {
  44.         if ( CarcassClass.Static.AllowChunk(n, CarcassAnim) )
  45.         {
  46.             if ( CarcLocation == vect(0,0,0) ) CarcLocation = Location;
  47.             carc = Spawn(class 'IzarianChunks',,, CarcLocation
  48.                          + CarcassClass.Default.ZOffset[n] * CarcHeight * vect(0,0,1));
  49.             if (carc != None)
  50.             {
  51.                 carc.TrailSize = CarcassClass.Default.Trails[n];
  52.                 carc.Mesh = CarcassClass.Default.bodyparts[n];
  53.                 carc.Initfor(self);
  54.                 carc.RemoteRole = ROLE_None;
  55.             }
  56.         }
  57.         n++;
  58.     }
  59.  
  60.     if ( Level.bHighDetailMode && !bGreenBlood )
  61.     {
  62.         Blood = spawn(class'BloodPuffBlue',,, CarcLocation);
  63.         Blood.drawscale = 0.2 * CollisionRadius;
  64.         Blood.RemoteRole = ROLE_None;
  65.     }
  66. }
  67.  
  68. simulated function ZoneChange( ZoneInfo NewZone )
  69. {
  70.     local float splashsize;
  71.     local actor splash;
  72.  
  73.     if ( NewZone.bWaterZone )
  74.     {
  75.         if ( trail != None )
  76.         {
  77.             if ( Level.bHighDetailMode )
  78.                 bUnlit = false;
  79.             trail.Destroy();
  80.         }
  81.         if ( Mass <= Buoyancy )
  82.             SetCollisionSize(0,0);
  83.         if ( bSplash && !Region.Zone.bWaterZone && (Abs(Velocity.Z) < 80) )
  84.             RotationRate *= 0.6;
  85.         else if ( !Region.Zone.bWaterZone && (Velocity.Z < -200) )
  86.         {
  87.             // else play a splash
  88.             splashSize = FClamp(0.0001 * Mass * (250 - 0.5 * FMax(-600,Velocity.Z)), 1.0, 3.0 );
  89.             if ( NewZone.EntrySound != None )
  90.                 PlaySound(NewZone.EntrySound, SLOT_Interact, splashSize);
  91.             if ( NewZone.EntryActor != None )
  92.             {
  93.                 splash = Spawn(NewZone.EntryActor);
  94.                 if ( splash != None )
  95.                     splash.DrawScale = splashSize;
  96.             }
  97.         }
  98.         bSplash = true;
  99.     }
  100.  
  101.     if ( NewZone.bDestructive || (NewZone.bPainZone  && (NewZone.DamagePerSec > 0)) )
  102.         Destroy();
  103. }
  104.  
  105. simulated function Destroyed()
  106. {
  107.     if ( trail != None )
  108.         trail.Destroy();
  109.     Super.Destroyed();
  110. }
  111.  
  112. function Initfor(actor Other)
  113. {
  114.     local vector RandDir;
  115.  
  116.     if ( Other.IsA('Carcass') )
  117.         PlayerOwner = Carcass(Other).PlayerOwner;
  118.     bDecorative = false;
  119.     DrawScale = Other.DrawScale;
  120.     if ( DrawScale != 1.0 )
  121.         SetCollisionSize(CollisionRadius * 0.5 * (1 + DrawScale), CollisionHeight * 0.5 * (1 + DrawScale));
  122.     RotationRate.Yaw = Rand(200000) - 100000;
  123.     RotationRate.Pitch = Rand(200000 - Abs(RotationRate.Yaw)) - 0.5 * (200000 - Abs(RotationRate.Yaw));
  124.     RandDir = 700 * FRand() * VRand();
  125.     RandDir.Z = 200 * FRand() - 50;
  126.     if ( bMasterChunk )
  127.         SetAsMaster(Other);
  128.     else
  129.     {
  130.         Velocity = (0.2 + FRand()) * (other.Velocity + RandDir);
  131.         If (Region.Zone.bWaterZone)
  132.         Velocity *= 0.5;
  133.     }
  134.     if ( TrailSize > 0 )
  135.     {
  136.         if ( Other != None && Other.isa('ScriptedPawn'))
  137.             bGreenBlood = ScriptedPawn(Other).bGreenBlood;
  138.         else if ( IzarianCarcass(Other) != None )
  139.             bGreenBlood = CreatureCarcass(Other).bGreenBlood;
  140.         else if ( (IzarianChunks(Other) != None) )
  141.             bGreenBlood = CreatureChunks(Other).bGreenBlood;
  142.     }
  143.  
  144.     if ( FRand() < 0.3 )
  145.         Buoyancy = 1.06 * Mass; // float corpse
  146.     else
  147.         Buoyancy = 0.94 * Mass;
  148.  
  149.     if ( bMasterChunk ) // only if server
  150.         ClientExtraChunks(bMustSpawnChunks);
  151. }
  152.  
  153. function SetAsMaster(Actor Other)
  154. {
  155.     Velocity = Other.Velocity;
  156.     CarcassClass = class<CreatureCarcass>(Other.Class);
  157.     CarcassAnim = Other.AnimSequence;
  158.     CarcLocation = Other.Location;
  159.     CarcHeight = Other.CollisionHeight;
  160. }
  161.  
  162. function ChunkUp(int Damage)
  163. {
  164.     local BloodSpurtBlue b;
  165.  
  166.     if (bHidden)
  167.         return;
  168.     b = Spawn(class 'Bloodspurtblue',,,,rot(16384,0,0));
  169.     if ( bGreenBlood )
  170.         b.GreenBlood();
  171.     if (bPlayerCarcass)
  172.     {
  173.         bHidden = true;
  174.         SetPhysics(PHYS_None);
  175.         SetCollision(false,false,false);
  176.         bProjTarget = false;
  177.         if ( Trail != None )
  178.             Trail.Destroy();
  179.     }
  180.     else
  181.         destroy();
  182. }
  183.  
  184. simulated function Landed(vector HitNormal)
  185. {
  186.     local rotator finalRot;
  187.     local BloodSpurtblue b;
  188.     //local Bloodsplat2 BS2;
  189.  
  190.     if ( trail != None )
  191.     {
  192.         if ( Level.bHighDetailMode )
  193.             bUnlit = false;
  194.         trail.Destroy();
  195.         trail = None;
  196.     }
  197.     finalRot = Rotation;
  198.     finalRot.Roll = 0;
  199.     finalRot.Pitch = 0;
  200.     setRotation(finalRot);
  201.     if ( Level.NetMode != NM_DedicatedServer )
  202.     {
  203.         b = Spawn(class 'Bloodspurtblue',,,,rot(16384,0,0));
  204.         if ( bGreenBlood )
  205.             b.GreenBlood();
  206.         b.RemoteRole = ROLE_None;
  207.         //BS2=Spawn(class'BloodSplat2',Owner,,,Rotator(HitNormal));
  208.         //if (bGreenBlood && BS2 != none)
  209.         //  BS2.Green();
  210.     }
  211.     SetPhysics(PHYS_None);
  212.     SetCollision(true, false, false);
  213. }
  214.  
  215. simulated function HitWall(vector HitNormal, actor Wall)
  216. {
  217.     local float speed, decision;
  218.     local BloodSpurtblue b;
  219.     //local Bloodsplat2 BS2;
  220.  
  221.     Velocity = 0.8 * (Velocity - 2 * HitNormal * (Velocity Dot HitNormal));
  222.     Velocity.Z = FMin(Velocity.Z * 0.8, 700);
  223.     speed = VSize(Velocity);
  224.     if ( speed < 250 )
  225.     {
  226.         if ( trail != None )
  227.         {
  228.             if ( Level.bHighDetailMode )
  229.                 bUnlit = false;
  230.             trail.Destroy();
  231.             trail = None;
  232.         }
  233.         if ( speed < 120 )
  234.         {
  235.             bBounce = false;
  236.             Disable('HitWall');
  237.         }
  238.     }
  239.     else if ( speed > 350 )
  240.     {
  241.         if ( speed > 700 )
  242.             velocity *= 0.8;
  243.         if (  Level.NetMode != NM_DedicatedServer )
  244.         {
  245.             decision = FRand();
  246.             if ( decision < 0.2 )
  247.                 PlaySound(sound 'gibP1');
  248.             else if ( decision < 0.4 )
  249.                 PlaySound(sound 'gibP3');
  250.             else if ( decision < 0.6 )
  251.                 PlaySound(sound 'gibP4');
  252.             else if ( decision < 0.8 )
  253.                 PlaySound(sound 'gibP5');
  254.             else
  255.                 PlaySound(sound 'gibP6');
  256.         }
  257.     }
  258.     if ( (trail == None) && (Level.NetMode != NM_DedicatedServer) )
  259.     {
  260.         b = Spawn(class 'Bloodspurtblue',,,,Rotator(HitNormal));
  261.         if ( bGreenBlood )
  262.             b.GreenBlood();
  263.         b.RemoteRole = ROLE_None;
  264.     }
  265.     //if (Level.Netmode != NM_DedicatedServer)
  266.     //  BS2=Spawn(class'BloodSplat2',Owner,,,Rotator(HitNormal));
  267.     //if (bGreenBlood && BS2 != none)
  268.     //  BS2.Green();
  269. }
  270.  
  271. function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation,
  272.                      Vector momentum, name damageType)
  273. {
  274.     if (bStatic || bDeleteme)
  275.         return;
  276.     SetPhysics(PHYS_Falling);
  277.     bBobbing = false;
  278.     Velocity += momentum/Mass;
  279.     CumulativeDamage += Damage;
  280.     If ( Damage > FMin(15, Mass) || (CumulativeDamage > Mass) )
  281.     ChunkUp(Damage);
  282. }
  283.  
  284. simulated function Timer()
  285. {
  286.     if ( (Level.NetMode == NM_Client) && bMasterChunk )
  287.         ClientExtraChunks(bMustSpawnChunks);
  288. }
  289.  
  290.  
  291. auto state Dying
  292. {
  293.     ignores TakeDamage;
  294.  
  295. Begin:
  296.     if ( bDecorative )
  297.         SetPhysics(PHYS_None);
  298.     else if ( (TrailSize > 0) && !Region.Zone.bWaterZone )
  299.     {
  300.         trail = Spawn(class'BloodTrail',self);
  301. //      trail.DrawScale = TrailSize;
  302.         if ( bGreenBlood )
  303.             trail.GreenBlood();
  304.     }
  305.     Sleep(0.35);
  306.     SetCollision(true, false, false);
  307.     bMasterChunk = false;
  308.     GotoState('Dead');
  309. }
  310.  
  311. state Dead
  312. {
  313.     function BeginState()
  314.     {
  315.         if ( bDecorative )
  316.             lifespan = 0.0;
  317.         else
  318.             SetTimer(5.0, false);
  319.     }
  320. }
  321.  
  322. defaultproperties
  323. {
  324. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement