Announcement

Collapse
No announcement yet.

Damage Given?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Damage Given?

    I've successfully written one mutator a long time ago, and am now wanting to try my hand at a 2nd. I'm having trouble finding something though. Where is the total damage a player has given stored?

    What I'm wanting to put together is a mutator that awards points based on damage, not kills. That way, if it's a DM game, and you're the guy that does all the damage, but doesn't necessarily get the kill, it'll be reflected in the score at the end.

    At this point, the ratio of damage to score doesn't even need to be configurable. I'll probably just hardcode it to 100 damage = 1 kill. Bear in mind that 100 damage might be 50 damage to two different opponents.

    Also, if someone has 30 health, and you hit them w/the LG (70 damage) would it be possible for me to count the whole 70 instead of just the 30?

    #2
    the thing is the damage is givin y the weaponfire clases

    u can make a new GameRules class ( i think off hand ) and u can use its functions to modify the damages given and get the types and amount given *RPG Magic* lol

    Comment


      #3
      Can I add a variable to the playerreplicationinfo class and simply add to it each time damage is given? I think I could do that in gamerules - netdamage, couldn't I?

      Comment


        #4
        yea i bet

        Comment


          #5
          If someone could look this over and help me out, I'd really appreciate it.

          The way I'm coding this, I'm thinking I need three following classes:

          Main Mutator Class:
          Code:
          //=============================================================================
          // MutDamagePoints - 100 Damage = 1 point, not 1 frag = 1 point
          //=============================================================================
          class MutDamagePoints extends Mutator;
          
          simulated function PostBeginPlay()
          {
          	local GameRules G;
          	
          	Super.PostBeginPlay();
          	G = spawn(class'DamagePoints');
          	if ( Level.Game.GameRulesModifiers == None )
          		Level.Game.GameRulesModifiers = G;
          	else    
          		Level.Game.GameRulesModifiers.AddGameRules(G);
          //	Destroy();
          }
          Class to add a var to PlayerReplicationInfo
          Code:
          //=============================================================================
          // MutDamagePoints - 100 Damage = 1 point, not 1 frag = 1 point
          //=============================================================================
          class DP_PlayerReplicationInfo extends PlayerReplicationInfo;
          
          var int DPoints;
          Class to keep DPoints variable up to date, and set the players score accordingly
          Code:
          class DamagePoints extends GameRules;
          
          //function NetDamage( int Damage, pawn injured, pawn instigatedBy, vector HitLocation, out vector Momentum, class<DamageType> DamageType )
          function int NetDamage( int OriginalDamage, int Damage, pawn injured, pawn instigatedBy, vector HitLocation, out vector Momentum, class<DamageType> DamageType)
          {
          	if (Injured != instagatedBy)
          	{
          		instigatedBy.DP_PlayerReplicationInfo.DPoints += Damage;
          	}
          	return Damage;
          }
          
          
          
          function ScoreKill ( Controller Killer, Controller Killed )
          {
          	DP_PlayerReplicationInfo.Score = DP_PlayerReplicationInfo.DPoints/100;
          	//Super.ScoreKill(); 
          }

          Comment


            #6
            You shouldn't subclass PlayerReplicationInfo. It'll break other mutators/mods. Besides, it doesn't work at all because you're not replacing the PlayerReplicationInfo with DP_PlayerReplicationInfo.

            What you could do instead: make dynamic array of a struct in your GameRules subclass. The struct should hold a PlayerReplicationInfo and an Integer. If a PlayerReplicationInfo is not present in the struct, add it.

            I don't know if this works in theory. Maybe you can just make two dynamic arrays, but I'm not sure if things can get mixed up. Could someone please verify this?

            Comment


              #7
              I'm making some headway on this, but I've got a couple questions.

              From the NetDamage function, how can I tell if it was a suicide (fell, etc.)?

              Why doesn't my overridden HandleRestartGame function get called with a level restart (from within UTComp)?

              Comment


                #8
                Some old code, modify to whatever you're doing...

                Code:
                function int NetDamage( int OriginalDamage, int Damage, Pawn Injured, Pawn InstigatedBy, Vector HitLocation, out Vector Momentum, class<DamageType> DamageType )
                {
                    local int DmgAmount;
                
                    if ( NextGameRules != None ) {
                        Damage = NextGameRules.NetDamage( OriginalDamage, Damage, Injured, InstigatedBy, HitLocation, Momentum, DamageType );
                    }
                
                    if ( Damage <= 0 ) return Damage;
                
                    if ( ( Injured.Controller != None ) &&
                         ( Injured.Health > 0 ) ) {
                
                        DmgAmount = Min( Damage, Injured.Health );
                
                        if ( ( InstigatedBy != None ) &&
                             ( InstigatedBy.Controller != None ) && 
                             ( InstigatedBy.Controller != Injured.Controller ) ) {
                
                            if ( ( !Level.Game.bTeamGame ) ||
                                 ( !InstigatedBy.Controller.SameTeamAs( Injured.Controller ) ) ) {
                
                            .... Count it
                Add some elses for self damage, etc. One thing, though- if I remember right, NetDamage is called before armor calculations.

                Comment


                  #9
                  Thanks a lot. I'll be working on this tonight after work and the kids are in bed.

                  I'm probably going to post the source here once I get everything worked out. I'm sure there will be ways to improve what I've got.

                  Comment


                    #10
                    It will be a nice mutator. There was an old Quake 3 mod called Decimal that counted 10 damage as 0.1 frag. A tiny change, but makes a big difference in DM & TDM.

                    Comment


                      #11
                      Exactly. We're a somewhat competitive clan that plays mostly 1v1. The thing is, once you have 4 or more people on the server, you're spending more time waiting than playing.

                      DM and TDM are good alternatives, but it gets frustrating when you do a lot of damage, but aren't rewarded with points if you're not the one to actually finish someone off.

                      As a starting point, I'm calculating points as damage / 100. At some point it may be configurable, but right now I just want to get the basics working so we can see if it makes the FFA's any more enjoyable.

                      Comment


                        #12
                        I got passed one hurdle, but I'm at another. I'm trying to find out when the level is restarted so I reset each element in my DamagePoints array to 0, but HandleRestartGame doesn't seem to be getting called on a level restart.

                        Comment

                        Working...
                        X