Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //----------------------------------------------------------------------------
- function DamageTypeCollision(%obj, %damageType){
- switch$ (%damageType){
- case "Suicide":
- return;
- case "Drowning":
- return;
- case "Paintball":
- return;
- default:
- // Process all other damage types
- }
- %centerpoint = %obj.getWorldBoxCenter();
- %normal[0] = "0.0 0.0 1.0";
- %abNormal[0] = "2.0 2.0 0.0";
- %normal[1] = "0.0 1.0 0.0";
- %abNormal[1] = "2.0 0.0 2.0";
- %normal[2] = "1.0 0.0 0.0";
- %abNormal[2] = "0.0 2.0 2.0";
- %normal[3] = "0.0 0.0 -1.0";
- %abNormal[3] = "2.0 2.0 0.0";
- %normal[4] = "0.0 -1.0 0.0";
- %abNormal[4] = "2.0 0.0 2.0";
- %normal[5] = "-1.0 0.0 0.0";
- %abNormal[5] = "0.0 2.0 2.0";
- %clientCount = ClientGroup.getCount();
- for (%i=0;%i<6;%i++)
- {
- %normalScaled = VectorScale(%normal[%i],-1); //distance to walls the blood splatters
- %targetPoint = VectorAdd(%centerpoint,%normalScaled);
- %mask = $TypeMasks::StaticObjectType | $TypeMasks::TerrainObjectType;
- %hitObject = ContainerRayCast(%centerpoint, %targetPoint, %mask, %obj);
- if (%hitObject)
- {
- %splatterPoint = getWords(%hitObject,1,3);
- %splatterNorm = getWords(%hitObject,4,6);
- %splatterScaling = getRandom()*1.5 + %damage/30;
- %splatterVary = getRandom()*getword(%abNormal[%i],0)-getword(%abNormal[%i],0)/2
- SPC getRandom()*getword(%abNormal[%i],1)-getword(%abNormal[%i],1)/2 SPC getRandom()*getword(%abNormal[%i],2)-getword(%abNormal[%i],2)/2;
- %Decalposition = VectorAdd(%splatterPoint, %splatterVary);
- if (%splatterScaling > 8)
- { %splatterScaling = 8;}
- for (%clientIndex = 0; %clientIndex < %clientCount; %clientIndex++)
- {
- %client = ClientGroup.getObject(%clientIndex);
- %ghostIndex = %client.getGhostID(%obj);
- commandToClient(%client,'Spatter', %Decalposition, %splatterNorm, %splatterScaling);
- }
- }
- }
- %particles = new ParticleEmitterNode()
- {
- position = %position;
- rotation = "1 0 0 0";
- scale = "1 1 1";
- dataBlock = "SmokeEmitterNode";
- emitter = "bloodBulletDirtSprayEmitter";
- velocity = "1";
- };
- MissionCleanup.add(%particles);
- %particles.schedule(1000, "delete");
- //blood decals and particles finished
- }
- function PlayerData::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
- {
- if (!isObject(%obj) || %obj.getState() $= "Dead" || !%damage)
- return;
- %location = %obj.getDamageLocation(%position);//"Body";
- %bodyPart = getWord(%location, 0);
- %region = getWord(%location, 1);
- //echo(%obj @" \c4% DAMAGELOCATION: bodyPart = "@ %bodyPart @" || REGION = "@ %region);
- switch$ (%bodyPart)
- {
- case "head":
- %damage = %damage*2.5; // 2,5 times the damage for a headshot
- case "torso":
- case "legs":
- %damage = %damage/1.6; // about two third damage for legs
- }
- DamageTypeCollision(%obj, %damageType);
- %obj.applyDamage(%damage);
- %location = "Body";
- // Deal with client callbacks here because we don't have this
- // information in the onDamage or onDisable methods
- %client = %obj.client;
- %sourceClient = %sourceObject ? %sourceObject.client : 0;
- if (isObject(%client))
- {
- // Determine damage direction
- if (%damageType !$= "Suicide"&& %damageType !$= "Drowning")//prevent Damage Direction indicator while drowning
- %obj.setDamageDirection(%sourceObject, %position);
- if (%obj.getState() $= "Dead")
- %client.onDeath(%sourceObject, %sourceClient, %damageType, %location);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement