PDA

View Full Version : Count damage inflicted mover


Euphoric Beaver
3rd Oct 2001, 03:37 AM
Could someone write or tell me what to do to make a mover that instead of just triggering, when a certain damage is met but counts up the damage so several enforcer shots would be added together untill the mover gets triggered?

The_Pixie
3rd Oct 2001, 04:00 AM
The Q&D way maybe?

1. subclass the mover class

2. add variables to count the number of shots it has taken and how many shots it can take before triggering:

var() int ShotsThreashold; //number of shots mover can stand before triggered
var int shots; //number of shots fired at mover

defaultproperties
{
ShotsThreashold=10;
}

3. override the TakeDamage() method:

// When damaged
function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation,
Vector momentum, name damageType)
{
if(++shots>=ShotsThreashold)
{
self.Trigger(self, instigatedBy);
shots=0; //reset the counter again
}
}


Not sure at all if it will work ;)

Euphoric Beaver
3rd Oct 2001, 08:39 AM
I was hoping instead of shot count is there anyway of adding up the damage it takes.
eg.
Enforcer takes ten rounds for it to activate.
Shock Rifle takes one round for it to activate.

The_Pixie
3rd Oct 2001, 08:51 AM
Well, instead of increasing the number of shots, just keep track of the damage delivered. You got the Damage variable already:

----------------------------------------
class MyMover extends Mover;

var int TotalDamage;

// When damaged
function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation,
Vector momentum, name damageType)
{
TotalDamage+=Damage;
if(TotalDamage>=DamageThreshold)
{
self.Trigger(self, instigatedBy);
TotalDamage=0; //reset the counter again
}
}
----------------------------------------

Something like that? (not tested)