Author Topic: Damage Detector  (Read 1128 times)

How would I make it so if Player 1 shoots Player 2, It would have a certain damage range (ie 1-10) and centerprint Player 1 the damage he made?

Code: [Select]
AddDamageType("Gun",   '<bitmap:add-ons/Weapon_Gun/CI_gun> %1',    '%2 <bitmap:add-ons/Weapon_Gun/CI_gun> %1',0.2,1);
datablock ProjectileData(gunProjectile)
{
   projectileShapeName = "./bullet.dts";
   directDamage        = getrandom(1, 10);                             \\<<<< Over here
   directDamageType    = $DamageType::Gun;
   radiusDamageType    = $DamageType::Gun;

   brickExplosionRadius = 0;
   brickExplosionImpact = true;         
   brickExplosionForce  = 10;
   brickExplosionMaxVolume = 1;         
   brickExplosionMaxVolumeFloating = 2;

   impactImpulse      = 400;
   verticalImpulse   = 400;
   explosion           = gunExplosion;
   particleEmitter     = "";

   muzzleVelocity      = 90;
   velInheritFactor    = 1;

   armingDelay         = 00;
   lifetime            = 4000;
   fadeDelay           = 3500;
   bounceElasticity    = 0.5;
   bounceFriction      = 0.20;
   isBallistic         = false;
   gravityMod = 0.0;

   hasLight    = false;
   lightRadius = 3.0;
   lightColor  = "0 0 0.5";

   uiName = "Gun Bullet";
};


I don't know how to script at all really, would this work?


If not, I think it should.
« Last Edit: April 26, 2009, 03:42:19 PM by Zenthos »

I think it would do the same damage. It only changes if you reload the datablocks. Or at least that's what I think it would do.

I think it would do the same damage. It only changes if you reload the datablocks. Or at least that's what I think it would do.

Oh good point. It would find a random number then use that until you restarted the server. (I had to think out loud.)


Hmm... You would have to do something customy.


Answer us god of scripting!
« Last Edit: April 26, 2009, 04:00:23 PM by Zenthos »

I'd make it do 0 damage and in the projectile's ::onCollision if its a player do .addHealth(getRandom(0,10)); and then centerprint it to the projectiles owner.

I'd make it do 0 damage and in the projectile's ::onCollision if its a player do .addHealth(getRandom(-10, 0)); and then centerprint it to the projectiles owner.


Fix'd



If you don't know how to script, why are you in coding help? And AZIMUTH! WHYYYYYYYYY!

Projectile Damage Function

Do something like
%directDamage = mClampF(%this.directDamage+10-getRandom(20), -100, 100) * %scale;

Then it has a 'spread' of ten damage around whatever you set in the projectile. (e.g. a Gun doing 30 damage would do anywhere from 20 to 40)

If you want it to affect all projectiles, use Projectile::damage(...) (for instance, a 'critical hits' or 'damage spread' system)
If you want it to affect your kind specifically, use gunProjectile::damage(...)

Projectile Damage Function

Do something like
%directDamage = mClampF(%this.directDamage+10-getRandom(20), -100, 100) * %scale;

Then it has a 'spread' of ten damage around whatever you set in the projectile. (e.g. a Gun doing 30 damage would do anywhere from 20 to 40)

If you want it to affect all projectiles, use Projectile::damage(...) (for instance, a 'critical hits' or 'damage spread' system)
If you want it to affect your kind specifically, use gunProjectile::damage(...)

Oh, forgot about that. Locking