Author Topic: I need help with my mod.  (Read 3745 times)

I made a edited version of the dismemberment mod, and i have no clue how to add these features.

- Make this only work on bots
 
- When bot gets shot in the left or right arm, he drops the weapon (if he is holding one)

- Headshots spawn a explosion, and instantly kills the bot.

- If shot in the right or left leg, the bot must crawl for the rest of his life time.

Here is the mod http://www.mediafire.com/download/693pdg3tmpp9png/Support_RedDismemberment.zip

« Last Edit: May 25, 2016, 03:14:46 PM by _OXBADCODE# »

Replace if(%col.gettype() & $TypeMasks::PlayerObjectType && fileName(%col.dataBlock.shapeFile) $= "m.dts") with if(%col.getClassName() $= "AIPlayer" && fileName(%col.dataBlock.shapeFile) $= "m.dts") to make it only work on bots. There's two of these lines.

There's already head, arm, and foot detection in there.

When they get shot in the head just make a new projectile at that position and call %projectile.explode(); and %col.kill(); or %col.damage.

When they get hit in the foot call %col.setCrouching(1); You'll also probably want to set a variable on the bot and package AIPlayer::setCrouching and then make it not parent if that variable is true.

When they get hit in the foot call %col.setCrouching(1); You'll also probably want to set a variable on the bot and package AIPlayer::setCrouching and then make it not parent if that variable is true.
Variables? I don't know how to make these.
I replaced the first line, added the %col stuff in the right spots. But i don't know how to make variables.

You can assign variables onto objects to reference later on. So in this case, %col is the AIPlayer object (after the if statements are checked of course) so to assign a variable to an object, you can do something like %col.LegMissing = true;. Now that this variable has been assigned, you can access it later on (in a package like jes00 is suggesting).

If you don't know what a package is, here's a little tutorial on how to set up a package, what it does, and how to correctly use one:

Package Tutorial

Now you can package the AIPlayer::setCrouching method and access the variable (.LegMissing) to see if the variable is true, and simply perform logic (not calling the parent in the packaged function).

The crouching works, but sadly its still not enough...
When you shoot them in the leg they do fall down, but stand up when they try to crouch again...
Is there a way to make them turn into crouching playertype or something like that?
« Last Edit: May 26, 2016, 04:47:58 PM by _OXBADCODE# »

Post your code, you're doing something wrong.

Post your code, you're doing something wrong.
I didn't put variables into the code, all i did was put %col.setCrouching(1); in the function for shooting right and left leg

Code: [Select]
package ProjectileDismemberment
{
   function ProjectileData::damage(%this, %obj, %col, %fade, %pos, %normal)
   {
   parent::damage(%this, %obj, %col, %fade, %pos, %normal);
      if(%col.getClassName() $= "AIPlayer" && fileName(%col.dataBlock.shapeFile) $= "m.dts")
   {
      %fvec = %col.getForwardVector();
      %vec1 = -getWord(%fvec,1) SPC getWord(%fvec,0) SPC 0;
      %vec2 = vectorNormalize(%obj.initialVelocity);
     
      %damloc = (vectorDot(%vec1,%vec2) > 0);
     
      %scale = getWord(%col.getScale(),2);
      if(getword(%pos, 2) > getword(%col.getWorldBoxCenter(), 2) - 3.3*%scale)
      {
         %hidestr = "headskin";
         %col.kill();
         if(!%col.disHead)
            {
            %col.dishead = 1;
         %proj = new Projectile()
            {
               scale = %col.getScale();
               dataBlock = DismemExplosionProjectile;
               initialVelocity = %col.getVelocity();
               initialPosition = %col.getPosition();
               sourceObject = %col;
               sourceSlot = 0;
               client = %col.client;
            };
            MissionCleanup.add(%proj);
            }
         for(%i=0;$hat[%i] !$= "";%i++) %hidestr = %hidestr SPC $hat[%i];
         for(%i=0;$accent[%i] !$= "";%i++) %hidestr = %hidestr SPC $accent[%i];
      }
      else if(getword(%pos, 2) > getword(%col.getWorldBoxCenter(), 2) - 4.5*%scale)
      {
         if(%damLoc == 0)
         {
            %hidestr = "lhand lhook larm larmslim";
            if(!%col.dislhand)
            {
            %col.disLhand = 1;
            %proj = new Projectile()
            {
               scale = %col.getScale();
               dataBlock = DismemLHandProjectile;
               initialVelocity = %col.getVelocity();
               initialPosition = %col.getPosition();
               sourceObject = %col;
               sourceSlot = 0;
               client = %col.client;
            };
            MissionCleanup.add(%proj);
            %proj = new Projectile()
            {
               scale = %col.getScale();
               dataBlock = DismemshoulderProjectile;
               initialVelocity = %col.getVelocity();
               initialPosition = %col.getPosition();
               sourceObject = %col;
               sourceSlot = 0;
               client = %col.client;
            };
            MissionCleanup.add(%proj);
            }
         }
         else
         {
            %hidestr = "rhand rhook rarm rarmslim";
            if(!%col.dishand)
            {
            %col.dishand = 1;
            %proj = new Projectile()
            {
               scale = %col.getScale();
               dataBlock = DismemHandProjectile;
               initialVelocity = %col.getVelocity();
               initialPosition = %col.getPosition();
               sourceObject = %col;
               sourceSlot = 0;
               client = %col.client;
            };
            MissionCleanup.add(%proj);
            %proj = new Projectile()
            {
               scale = %col.getScale();
               dataBlock = DismemshoulderProjectile;
               initialVelocity = %col.getVelocity();
               initialPosition = %col.getPosition();
               sourceObject = %col;
               sourceSlot = 0;
               client = %col.client;
            };
            MissionCleanup.add(%proj);
         }
         }
      }
      else
      {
         if(%damLoc == 0)
         {
            %hidestr = "lshoe lpeg";
            if(!%col.dislfoot)
            {
            %col.disLfoot = 1;
            %col.setCrouching(1);
            %proj = new Projectile()
            {
               scale = %col.getScale();
               dataBlock = DismemFootProjectile;
               initialVelocity = %col.getVelocity();
               initialPosition = %col.getPosition();
               sourceObject = %col;
               sourceSlot = 0;
               client = %col.client;
            };
            MissionCleanup.add(%proj);
            }
         }
         else
         {
            %hidestr = "rshoe rpeg";
            if(!%col.disfoot)
            {
            %col.disfoot = 1;
            %col.setCrouching(1);
            %proj = new Projectile()
            {
               scale = %col.getScale();
               dataBlock = DismemFootProjectile;
               initialVelocity = %col.getVelocity();
               initialPosition = %col.getPosition();
               sourceObject = %col;
               sourceSlot = 0;
               client = %col.client;
            };
            MissionCleanup.add(%proj);
            }
         }
      }
     
      if(%col.dismembermentUnhideStr $= "")
         %col.dismembermentUnhideStr = "START";
     
      for(%i=0;%i<getWordCount(%hidestr);%i++)
      {
         %node = getWord(%hidestr,%i);
         if(%col.isNodeVisible(%node) && strStr(%col.dismembermentUnhideStr," " @ %node) == -1)
            %col.dismembermentUnhideStr = %col.dismembermentUnhideStr SPC %node;
         
         %col.hideNode(%node);
      }
     
      cancel(%col.dismembermentResetSched);
      %col.dismembermentResetSched = %col.schedule(5000,dismembermentReset);
   }

   //return Parent::Damage(%this, %obj, %col, %fade, %pos, %normal);
   }

   function WeaponImage::onRaycastDamage(%this,%obj,%slot,%col,%pos,%normal,%shotVec,%crit)
   {
      parent::onRaycastDamage(%this,%obj,%slot,%col,%pos,%normal,%shotVec,%crit);
     if(%col.gettype() & $TypeMasks::PlayerObjectType && fileName(%col.dataBlock.shapeFile) $= "m.dts")
   {
      %fvec = %col.getForwardVector();
      %vec1 = -getWord(%fvec,1) SPC getWord(%fvec,0) SPC 0;
      %vec2 = vectorNormalize(%obj.initialVelocity);
     
      %damloc = (vectorDot(%vec1,%vec2) > 0);
     
      %scale = getWord(%col.getScale(),2);
      if(getword(%pos, 2) > getword(%col.getWorldBoxCenter(), 2) - 3.3*%scale)
      {
         %hidestr = "headskin";
         if(!%col.disHead)
            {
            %col.dishead =1;
         %proj = new Projectile()
            {
               scale = %col.getScale();
               dataBlock = DismemExplosionProjectile;
               initialVelocity = %col.getVelocity();
               initialPosition = %col.getPosition();
               sourceObject = %col;
               sourceSlot = 0;
               client = %col.client;
            };
            MissionCleanup.add(%proj);
            }
         for(%i=0;$hat[%i] !$= "";%i++) %hidestr = %hidestr SPC $hat[%i];
         for(%i=0;$accent[%i] !$= "";%i++) %hidestr = %hidestr SPC $accent[%i];
      }
      else if(getword(%pos, 2) > getword(%col.getWorldBoxCenter(), 2) - 4.5*%scale)
      {
         if(%damLoc == 0)
         {
            %hidestr = "lhand lhook larm larmslim";
            if(!%col.dislhand)
            {
            %col.disLhand = 1;
            %proj = new Projectile()
            {
               scale = %col.getScale();
               dataBlock = DismemLHandProjectile;
               initialVelocity = %col.getVelocity();
               initialPosition = %col.getPosition();
               sourceObject = %col;
               sourceSlot = 0;
               client = %col.client;
            };
            MissionCleanup.add(%proj);
            %proj = new Projectile()
            {
               scale = %col.getScale();
               dataBlock = DismemshoulderProjectile;
               initialVelocity = %col.getVelocity();
               initialPosition = %col.getPosition();
               sourceObject = %col;
               sourceSlot = 0;
               client = %col.client;
            };
            MissionCleanup.add(%proj);
            }
         }
         else
         {
            %hidestr = "rhand rhook rarm rarmslim";
            if(!%col.dishand)
            {
            %col.dishand = 1;
            %proj = new Projectile()
            {
               scale = %col.getScale();
               dataBlock = DismemHandProjectile;
               initialVelocity = %col.getVelocity();
               initialPosition = %col.getPosition();
               sourceObject = %col;
               sourceSlot = 0;
               client = %col.client;
            };
            MissionCleanup.add(%proj);
            %proj = new Projectile()
            {
               scale = %col.getScale();
               dataBlock = DismemshoulderProjectile;
               initialVelocity = %col.getVelocity();
               initialPosition = %col.getPosition();
               sourceObject = %col;
               sourceSlot = 0;
               client = %col.client;
            };
            MissionCleanup.add(%proj);
         }
         }
      }
      else
      {
         if(%damLoc == 0)
         {
            %hidestr = "lshoe lpeg";
            if(!%col.dislfoot)
            {
            %col.disLfoot = 1;
            %proj = new Projectile()
            {
               scale = %col.getScale();
               dataBlock = DismemFootProjectile;
               initialVelocity = %col.getVelocity();
               initialPosition = %col.getPosition();
               sourceObject = %col;
               sourceSlot = 0;
               client = %col.client;
            };
            MissionCleanup.add(%proj);
            }
         }
         else
         {
            %hidestr = "rshoe rpeg";
            if(!%col.disfoot)
            {
            %col.disfoot = 1;
            %proj = new Projectile()
            {
               scale = %col.getScale();
               dataBlock = DismemFootProjectile;
               initialVelocity = %col.getVelocity();
               initialPosition = %col.getPosition();
               sourceObject = %col;
               sourceSlot = 0;
               client = %col.client;
            };
            MissionCleanup.add(%proj);
            }
         }
      }
     
      if(%col.dismembermentUnhideStr $= "")
         %col.dismembermentUnhideStr = "START";
     
      for(%i=0;%i<getWordCount(%hidestr);%i++)
      {
         %node = getWord(%hidestr,%i);
         if(%col.isNodeVisible(%node) && strStr(%col.dismembermentUnhideStr," " @ %node) == -1)
            %col.dismembermentUnhideStr = %col.dismembermentUnhideStr SPC %node;
         
         %col.hideNode(%node);
      }
     
      cancel(%col.dismembermentResetSched);
      %col.dismembermentResetSched = %col.schedule(5000,dismembermentReset);
   }
   }
};
activatepackage(ProjectileDismemberment);

datablock DebrisData(dismemheadDebris)
{
   emitters = smallBloodEmitter;

   shapeFile = "./head.dts";
   lifetime = 6.0;
   minSpinSpeed = -400.0;
   maxSpinSpeed = 200.0;
   elasticity = 0.5;
   friction = 0.2;
   numBounces = 3;
   staticOnMaxBounce = true;
   snapOnMaxBounce = false;
   fade = true;
   gravModifier = 2;
};
datablock DebrisData(dismemhandDebris : dismemheadDebris)
{
   emitters = smallBloodEmitter;

   shapeFile = "./hand.dts";
};
datablock DebrisData(dismemhandLeftDebris : dismemheadDebris)
{
   emitters = smallBloodEmitter;

   shapeFile = "./handLeft.dts";
};
datablock DebrisData(dismemshoulderDebris : dismemheadDebris)
{
   emitters = smallBloodEmitter;

   shapeFile = "./shoulder.dts";
};
datablock DebrisData(dismemfootDebris : dismemheadDebris)
{
   emitters = smallBloodEmitter;

   shapeFile = "./foot.dts";
};
datablock ProjectileData(DismemExplosionProjectile)
{
   projectileShapeName = "base/data/shapes/empty.dts";
   directDamage     = 10;
   directDamageType = $DamageType::Default; //Damagetype default actually does no damage
   radiusDamageType = $DamageType::Default;
   impactImpulse    = 10;
   verticalImpulse  = 10;
   explosion        = dismemExplosion;

   brickExplosionRadius            = 0;
   brickExplosionImpact            = false;
   brickExplosionForce             = 0;
   brickExplosionMaxVolume         = 0;
   brickExplosionMaxVolumeFloating = 0;

   muzzleVelocity   = 1;
   velInheritFactor = 1;

   lifetime         = 10;
   bounceElasticity = 0;
   bounceFriction   = 0;
   isBallistic    = false;
   explodeOnDeath = true;
   hasLight       = false;
};
datablock ExplosionData(dismemExplosion) //Gotta make sub-explosions first because an explosion has to exist to be a part of another explosion...
{
   lifetimeMS = 33;
   particleEmitter = "goreEmitter";
   debrisNumVariance      = 0;
   debrisPhiMin           = 0;
   debrisPhiMax           = 360;
   debrisThetaMin         = 5;
   debrisThetaMax         = 105;
   debrisVelocity         = 5;
   debrisVelocityVariance = 1;

   debris = dismemheadDebris;
   debrisNum = 1;

   faceViewer     = true;
   explosionScale = "1 1 1";

   shakeCamera = false;

   lightStartRadius = 0;
   lightEndRadius = 0;

   impulseRadius = 100;
   impulseForce = 100;

   radiusDamage = 0;
   damageRadius = 0;
};
datablock ExplosionData(dismemExplosionFoot : dismemExplosion)
{
   particleEmitter = "goreEmitter";
   debris = dismemfootDebris;
   debrisNum = 1;
   lifeTimeMS = 500;
   particleDensity = 45;
   particleRadius  = 2.5;
};
datablock ProjectileData(DismemFootProjectile : DismemExplosionProjectile)
{
   particleEmitter = "goreEmitter";
 explosion = dismemExplosionFoot; 
};
datablock ExplosionData(dismemExplosionShoulder : dismemExplosion)
{
   particleEmitter = "goreEmitter";
   debris = dismemshoulderDebris;
   debrisNum = 1;
   lifeTimeMS = 500;
   particleDensity = 45;
   particleRadius  = 2.5;
};
datablock ProjectileData(DismemShoulderProjectile : DismemExplosionProjectile)
{
   particleEmitter = "goreEmitter";
 explosion = dismemExplosionShoulder; 
};
datablock ExplosionData(dismemExplosionHand : dismemExplosion)
{
   particleEmitter = "goreEmitter";
   debris = dismemhandDebris;
   debrisNum = 1;
   lifeTimeMS = 500;
   particleDensity = 45;
   particleRadius  = 2.5;
};
datablock ProjectileData(DismemHandProjectile : DismemExplosionProjectile)
{
 explosion = dismemExplosionHand; 
};
datablock ExplosionData(dismemExplosionLHand : dismemExplosion)
{
   debris = dismemHandLeftDebris;
   debrisNum = 1;
   lifeTimeMS = 500;
   particleDensity = 45;
   particleRadius  = 2.5;
};
datablock ProjectileData(DismemLHandProjectile : DismemExplosionProjectile)
{
 explosion = dismemExplosionLHand; 
};
datablock ParticleData(smallBloodParticle)
{
   dragCoefficient = 3;
   gravityCoefficient = 0.5;
   inheritedVelFactor = 0.3;
   constantAcceleration = 0;
   lifetimeMS         = 700;
   lifetimeVarianceMS = 250;
   textureName = "base/data/particles/dot";
   spinSpeed     = 0;
   spinRandomMin = -20;
   spinRandomMax = 20;
   colors[0] = "0.6 0 0 1";
   colors[1] = "0.5 0 0 0.9 ";
   colors[2] = "0.4 0 0 0";
   sizes[0] = 0.06;
   sizes[1] = 0.09;
   sizes[2] = 0.04;
   times[1] = 0.5;
   times[2] = 1;
   useInvAlpha = true;
};

datablock ParticleEmitterData(smallBloodEmitter)
{
   ejectionPeriodMS = 2;
   periodVarianceMS = 0;
   ejectionVelocity = 2;
   velocityVariance = 1.2;
   ejectionOffset   = 0;
   thetaMin = 0;
   thetaMax = 180;
   phiReferenceVel = 0;
   phiVariance     = 360;
   overrideAdvance = false;
   lifetimeMS = 3500;
   particles = "smallBloodParticle";

   uiName = "Bleed";
};

datablock ParticleData(goreParticle)
{
   dragCoefficient      = 6;
   gravityCoefficient   = 0.6;
   inheritedVelFactor   = 0.5;
   constantAcceleration = 0;
   lifetimeMS           = 1000;
   lifetimeVarianceMS   = 500;
   textureName          = "./pain";
   spinSpeed      = 0;
   spinRandomMin  = -100;
   spinRandomMax   = 100;
   colors[0]     = "1 0 0 1";
   colors[1]     = "0.8 0 0 0.9 ";
   colors[2]     = "0.5 0 0 0";
   sizes[0]      = 1;
   sizes[1]      = 1.3;
   sizes[2]      = 0.65;
   times[1] = 0.5;
   times[2] = 1;
   useInvAlpha = true;
};
datablock ParticleEmitterData(goreEmitter)
{
   ejectionPeriodMS = 10;
   periodVarianceMS = 0;
   ejectionVelocity = 10;
   velocityVariance = 5;
   ejectionOffset   = 0.25;
   thetaMin         = 5;
   thetaMax         = 105;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "goreParticle";

   uiName = "Gore";
};

You need to package AIPlayer::setCrouching to keep them crouched. This is because hole bots will crouch and uncrouch on their own. By packaging it you can force them to stay crouched.
This code already sets %col.disLFoot and %col.disRFoot. So just package AIPlayer::setCrouching and if either of those variables are true, don't parent it.

I have no idea what you just said jes00, but okay?
Where do i package it though, how do i do it.
If you could help me, that would be nice.
Also is there a way to make players crouched too?
When i changed back the first line into the one before, headshots worked but leg shots didn't.

Code: [Select]
function AIPlayer::setCrouching(%obj, %bool)
{
if(!%bool && (%obj.disLFoot || %obj.disRFoot))
{
parent::setCrouching(%obj, %bool);
}
}
Put this in your package and put %col.setCrouching(1); in the left foot if statement, also put it in the right and left foot if statements in the second function(it's called when they get hit by most raycast weapons).

I have no idea what you just said jes00, but okay?
Where do i package it though, how do i do it.
If you could help me, that would be nice.
Also is there a way to make players crouched too?
When i changed back the first line into the one before, headshots worked but leg shots didn't.


Did you even read the package tutorial I posted in my previous post?

Something doesn't obviously work.
Code: [Select]
package Goretest
{
function AIPlayer::setCrouching(%obj, %bool)
{
if(!%bool && (%obj.disLFoot || %obj.disRFoot))
{
parent::setCrouching(%obj, %bool);
    }
};

Something doesn't obviously work.
Code: [Select]
package Goretest
{
function AIPlayer::setCrouching(%obj, %bool)
{
if(!%bool && (%obj.disLFoot || %obj.disRFoot))
{
parent::setCrouching(%obj, %bool);
    }
};
You're missing a bracket to close the if() statement there, other then that, that /should/ work.

Don't forget to activate the package. I'm sure that tutorial tells you how.