Author Topic: Gun Damage Percentage?  (Read 781 times)

I am making a gun pack, and I want to know if its possible and if so how to do this.

I want to make a gun in which it has 90% to do 100k damage and 10% to do 1 damage.


Thanks.

Code: [Select]
function luckyGunProjectile::onCollision(%db,%proj,%hit,%vec,%pos)
{
if(%hit.getType() & $TypeMasks::PlayerObjectType)
{
if(getRandom(0,9) == 0)
{
%hit.damage(%proj.client,%pos,1,%db.damageType);
}
else
{
%hit.damage(%proj.client,%pos,100*1000,%db.damageType);
}
return;
}
parent::onCollision(%db,%proj,%hit,%vec,%pos);
}

you would want to do something like this for the projectile, the first if statement checks to see if the thing you hit is a player object type, then it chooses a random number between 0-9 meaning landing on a single number is a 10% chance, if the random gets a 0, it applies 1 damage to the hit object, otherwise it applies 100,000 damage to the hit object, the return statement prevents the normal collision code from occuring

if the object is not a player object type the normal collision code will occur

Code: [Select]
function luckyGunProjectile::onCollision(%db,%proj,%hit,%vec,%pos)
{
if(%hit.getType() & $TypeMasks::PlayerObjectType)
{
if(getRandom(0,9) == 0)
{
%hit.damage(%proj.client,%pos,1,%db.damageType);
}
else
{
%hit.damage(%proj.client,%pos,100*1000,%db.damageType);
}
return;
}
parent::onCollision(%db,%proj,%hit,%vec,%pos);
}

you would want to do something like this for the projectile, the first if statement checks to see if the thing you hit is a player object type, then it chooses a random number between 0-9 meaning landing on a single number is a 10% chance, if the random gets a 0, it applies 1 damage to the hit object, otherwise it applies 100,000 damage to the hit object, the return statement prevents the normal collision code from occuring

if the object is not a player object type the normal collision code will occur
beautiful, thank you.

locking thread.