1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Count damage inflicted mover

Discussion in 'Programming' started by Euphoric Beaver, Oct 3, 2001.

  1. Euphoric Beaver

    Euphoric Beaver impeccably groomed

    Joined:
    Apr 19, 2001
    Messages:
    3,158
    Likes Received:
    0
    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?
     
  2. The_Pixie

    The_Pixie UnrealFortress coder

    Joined:
    Feb 20, 2001
    Messages:
    13
    Likes Received:
    0
    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 ;)
     
  3. Euphoric Beaver

    Euphoric Beaver impeccably groomed

    Joined:
    Apr 19, 2001
    Messages:
    3,158
    Likes Received:
    0
    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.
     
  4. The_Pixie

    The_Pixie UnrealFortress coder

    Joined:
    Feb 20, 2001
    Messages:
    13
    Likes Received:
    0
    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)
     

Share This Page