Hello, I got a shotgun beening worked on and I what to get the damage to be lowered the longer it is alive.
This is how the theory goes.
When the project is created it gets simtime.
Spawn Time = 0
The max it can live too is 2 seconds.
DeathTime = 0 - 2000
Lets assume it gets hit half way through its life.
Damage = 10 - ((1000 - 0)/1000)*3
Which equals.
Damage = 7
If the lifetime 0
Damage = 10
If lifetime = 2000
Damage = 4
however. This is what I have and it doesn't work. I get console errors about missing function 'Onadd'
function Projectile::onadd(%obj,%a,%b)
{
Parent::onadd(%obj,%a,%b);
if(%obj.dataBlock $= "blunderbussprojectile")
{
%obj.spawntime = getsimtime();
}
}
function BlunderbussProjectile::Damage(%this,%obj,%col,%fade,%pos,%norm)
{
%obj.deathtime = getsimtime();
%obj.life = ((%obdeathtime - %obj.spawntime) / 1000) * 3;
echo(%obj.life);
%damage = %this.directdamage - %obj.life;
%col.damage(%obj,%pos,%damage,%this.directDamageType);
}