Advertisement
BloodknightStudios

Untitled

Dec 13th, 2015
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.82 KB | None | 0 0
  1. //----------------------------------------------------------------------------
  2.  
  3. function DamageTypeCollision(%obj, %damageType){
  4.    
  5.     switch$ (%damageType){
  6.    
  7.        case "Suicide":
  8.           return;
  9.          
  10.       case "Drowning":
  11.          return;
  12.          
  13.       case "Paintball":
  14.          return;
  15.          
  16.       default:
  17.          // Process all other damage types
  18.                
  19.     }
  20.    
  21.     %centerpoint = %obj.getWorldBoxCenter();
  22.    
  23.    %normal[0] = "0.0 0.0 1.0";
  24.    %abNormal[0] = "2.0 2.0 0.0";
  25.    %normal[1] = "0.0 1.0 0.0";
  26.    %abNormal[1] = "2.0 0.0 2.0";
  27.    %normal[2] = "1.0 0.0 0.0";
  28.    %abNormal[2] = "0.0 2.0 2.0";
  29.    %normal[3] = "0.0 0.0 -1.0";
  30.    %abNormal[3] = "2.0 2.0 0.0";
  31.    %normal[4] = "0.0 -1.0 0.0";
  32.    %abNormal[4] = "2.0 0.0 2.0";
  33.    %normal[5] = "-1.0 0.0 0.0";
  34.    %abNormal[5] = "0.0 2.0 2.0";
  35.    
  36.    %clientCount = ClientGroup.getCount();
  37.    for (%i=0;%i<6;%i++)
  38.    {
  39.         %normalScaled = VectorScale(%normal[%i],-1); //distance to walls the blood splatters
  40.         %targetPoint = VectorAdd(%centerpoint,%normalScaled);
  41.         %mask = $TypeMasks::StaticObjectType | $TypeMasks::TerrainObjectType;
  42.         %hitObject = ContainerRayCast(%centerpoint, %targetPoint, %mask, %obj);
  43.        
  44.         if (%hitObject)
  45.         {
  46.             %splatterPoint = getWords(%hitObject,1,3);
  47.             %splatterNorm = getWords(%hitObject,4,6);
  48.             %splatterScaling = getRandom()*1.5 + %damage/30;
  49.             %splatterVary = getRandom()*getword(%abNormal[%i],0)-getword(%abNormal[%i],0)/2
  50.             SPC getRandom()*getword(%abNormal[%i],1)-getword(%abNormal[%i],1)/2 SPC getRandom()*getword(%abNormal[%i],2)-getword(%abNormal[%i],2)/2;            
  51.             %Decalposition = VectorAdd(%splatterPoint, %splatterVary);
  52.             if (%splatterScaling > 8)
  53.             { %splatterScaling = 8;}
  54.                
  55.             for (%clientIndex = 0; %clientIndex < %clientCount; %clientIndex++)
  56.             {
  57.                 %client = ClientGroup.getObject(%clientIndex);
  58.                 %ghostIndex = %client.getGhostID(%obj);
  59.        
  60.                 commandToClient(%client,'Spatter', %Decalposition, %splatterNorm, %splatterScaling);
  61.             }
  62.         }
  63.    }
  64.      
  65.    %particles = new ParticleEmitterNode()  
  66.    {  
  67.       position = %position;  
  68.       rotation = "1 0 0 0";  
  69.       scale = "1 1 1";  
  70.       dataBlock = "SmokeEmitterNode";  
  71.       emitter = "bloodBulletDirtSprayEmitter";  
  72.       velocity = "1";  
  73.    };  
  74.    MissionCleanup.add(%particles);  
  75.    %particles.schedule(1000, "delete");
  76.    //blood decals and particles finished
  77.    
  78. }
  79.  
  80. function PlayerData::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
  81. {
  82.    if (!isObject(%obj) || %obj.getState() $= "Dead" || !%damage)
  83.       return;    
  84.  
  85.    %location = %obj.getDamageLocation(%position);//"Body";
  86.    %bodyPart = getWord(%location, 0);
  87.    %region = getWord(%location, 1);
  88.    //echo(%obj @" \c4% DAMAGELOCATION:  bodyPart = "@ %bodyPart @" || REGION = "@ %region);
  89.    switch$ (%bodyPart)
  90.    {
  91.       case "head":
  92.          %damage = %damage*2.5; // 2,5 times the damage for a headshot
  93.       case "torso":
  94.       case "legs":
  95.          %damage = %damage/1.6; // about two third damage for legs
  96.    }
  97.    
  98.     DamageTypeCollision(%obj, %damageType);
  99.    
  100.    %obj.applyDamage(%damage);
  101.  
  102.    %location = "Body";
  103.  
  104.    // Deal with client callbacks here because we don't have this
  105.    // information in the onDamage or onDisable methods
  106.    %client = %obj.client;
  107.    %sourceClient = %sourceObject ? %sourceObject.client : 0;
  108.  
  109.    if (isObject(%client))
  110.    {
  111.       // Determine damage direction
  112.       if (%damageType !$= "Suicide"&& %damageType !$= "Drowning")//prevent Damage Direction indicator while drowning
  113.          %obj.setDamageDirection(%sourceObject, %position);
  114.  
  115.       if (%obj.getState() $= "Dead")
  116.          %client.onDeath(%sourceObject, %sourceClient, %damageType, %location);
  117.    }
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement