NPC Damage Too low? Look inside (Updated 9/27/07)

A place where you can talk about anything Dawn of Light or DAOC related

Moderators: Project Admin, Support Team

Postby IStandAloneToo » Tue Sep 25, 2007 2:56 am

Ok. Quick intro to switch.

Code: Select all
switch(player.level)
{
case 1:
case 2:
case 3:
//code
break;
case 4:
case 5:
...
case 50:
case 51:
...
}


What happens is that when it finds a match, it will 'fall through' until it reaches some code. So, this will allow you to do the same code for 1, 2, 3. Those will execute the code underneath 3. However, if the level >= 4, it wont execute that code. It will continue to fall until the first block of code.
Ryan
Hi :)
IStandAloneToo
Developer
 
Posts: 1179
Joined: Sat Jul 14, 2007 2:26 am
Location: California

Switched

Postby Krugus » Tue Sep 25, 2007 3:56 pm

You mean like this?

Code: Select all
/// <summary>
      /// Returns the Damage this Living does on an attack
      /// </summary>
      /// <param name="weapon">the weapon used for attack</param>
      /// <returns></returns>
        public virtual double AttackDamage(InventoryItem weapon)
        {//original code:   double damage = (1.0 + Level / 3.7 + Level * Level / 175.0) * AttackSpeed(weapon) * 0.001;
            double damage = ((((((((2.0 + Level) * Level) / 3.5) + Level) * Level) / 175.0) * AttackSpeed(weapon)) * 0.001) + Level*2.5;//Krugus - Tweaking DMG Output
            if (weapon == null || weapon.Item_Type == Slot.RIGHTHAND || weapon.Item_Type == Slot.LEFTHAND || weapon.Item_Type == Slot.TWOHAND)
            {
                //Melee damage buff and debuff
                damage *= GetModified(eProperty.MeleeDamage) * 0.01;
            }
            else if (weapon.Item_Type == Slot.RANGED)
            {
                //Ranged damage buff and debuff
                damage *= GetModified(eProperty.RangedDamage) * 0.01;
            }
            //Krugus - Below we adjust the dmg down so our players can survive it.  ATM It starts at the lowest level and is adjusted down .1 past the next tier.
            //This is so the next tier will hit just abit harder than the last.  The first tier is 0-9th then each tier is broken down into every 5 levels
            //till 50th then its adjusted back to every 10 levels.  Can be easily tweaked. 
            //if (this is GameNPC)
            if (this is GameNPC)
            {
                switch (this.Level)
                {
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                    case 6:
                    case 7:
                    case 8:
                    case 9:
                        return damage * (2.0 - ((Level) * 0.1222));
                    case 10:
                    case 11:
                    case 12:
                    case 13:
                    case 14:
                        return damage * (1.0 - ((Level - 10) * 0.09));
                    case 15:
                    case 16:
                    case 17:
                    case 18:
                    case 19:
                        return damage * (.65 - ((Level - 15) * 0.04));
                    case 20:
                    case 21:
                    case 22:
                    case 23:
                    case 24:
                        return damage * (.50 - ((Level - 20) * 0.0275));
                    case 25:
                    case 26:
                    case 27:
                    case 28:
                    case 29:
                        return damage * (.40 - ((Level - 25) * 0.015));
                    case 30:
                    case 31:
                    case 32:
                    case 33:
                    case 34:
                        return damage * (.35 - ((Level - 30) * 0.015));
                    case 35:
                    case 36:
                    case 37:
                    case 38:
                    case 39:
                        return damage * (.30 - ((Level - 35) * 0.015));
                    case 40:
                    case 41:
                    case 42:
                    case 43:
                    case 44:
                        return damage * (.25 - ((Level - 40) * 0.015));
                    case 45:
                    case 46:
                    case 47:
                    case 48:
                    case 49:
                        return damage * (.20 - ((Level - 45) * 0.015));
                    case 50:
                    case 51:
                    case 52:
                    case 53:
                    case 54:
                    case 55:
                    case 56:
                    case 57:
                    case 58:
                    case 59:
                        return damage * (.15 - ((Level - 50) * 0.00388));
                    case 60:
                    case 61:
                    case 62:
                    case 63:
                    case 64:
                    case 65:
                    case 66:
                    case 67:
                    case 68:
                    case 69:
                        return damage * (.125 - ((Level - 60) * 0.00388));
                    case 70:
                    case 71:
                    case 72:
                    case 73:
                    case 74:
                    case 75:
                    case 76:
                    case 77:
                    case 78:
                    case 79:
                        return damage * (.10 - ((Level - 70) * 0.00388));
                    case 80:
                    case 81:
                    case 82:
                    case 83:
                    case 84:
                    case 85:
                    case 86:
                    case 87:
                    case 88:
                    case 89:
                    case 90:
                    case 91:
                    case 92:
                    case 93:
                    case 94:
                    case 95:
                    case 96:
                    case 97:
                    case 98:
                    case 99:
                    case 100:
                        return damage * (.075 - ((Level - 70) * 0.00125));
                    default:return damage;
                }
            }
            return damage;
           }
        /// <summary>
      /// Max. Damage possible without style


break; was giving me an Unreachable code warning so I removed it and rebuild it without it. It works without it. I'm guessing that break is sorta like a return but different? yes? :lol:
"Stand back man! I have a Holy Avenger and I know how to use it! " ...quote from the unknown paladin.
User avatar
Krugus
DOL Initiate
 
Posts: 22
Joined: Mon Sep 10, 2007 4:38 am
Location: Arkansas

Postby Etaew » Tue Sep 25, 2007 4:01 pm

If's would be cleaner instead of 100 cases I think.
Retired DOL Enthusiast | Blog
User avatar
Etaew
Inactive Staff Member
 
Posts: 7602
Joined: Mon Oct 13, 2003 5:04 pm
Website: http://etaew.net
Location: England

Postby Krugus » Tue Sep 25, 2007 4:02 pm

I wasn't going to say anything either but I did learn something out of the deal! :lol:
"Stand back man! I have a Holy Avenger and I know how to use it! " ...quote from the unknown paladin.
User avatar
Krugus
DOL Initiate
 
Posts: 22
Joined: Mon Sep 10, 2007 4:38 am
Location: Arkansas

Postby Dinberg » Tue Sep 25, 2007 5:49 pm

Well that's as tall as the tower of pizza!
The Marvelous Contraption begins to stir...
User avatar
Dinberg
Inactive Staff Member
 
Posts: 4695
Joined: Sat Mar 10, 2007 9:47 am
Yahoo Messenger: dinberg_darktouch
Location: Jordheim

Postby nor » Tue Sep 25, 2007 7:18 pm

All the data can be put to an array. Or 3 arrays, depending on how it is done. Separate code from data is a good idea in this case. Another option is to use some formula which fits.

The array don't have to contain all and every level. All you do is basically change the value every 5 levels, with some exceptions. So can store only those changes. And I'd suggest to do it every 4 levels for better performance (bit shift can be used for index calculation), but not sure how important it is in this case.


Also, the switch has one problem: "default:return damage;" is probably not desired behaviour.

"break" controls execution flow, just as "return". Can't use both in C# because it makes no sense.
nor
Inactive Staff Member
 
Posts: 1584
Joined: Wed Mar 03, 2004 3:56 am

ah HA!

Postby Krugus » Thu Sep 27, 2007 8:37 pm

HA!

Ok after reviewing my damage code and tweaking and more tweaking and even MORE tweaking.

I think I found it! :idea:

I put the original code back in and removed if/case switch.

All that was needed was a simple way for it to scale by level.

Code: Select all
(1+(Level * .01) + (1 - (Level *0.02)))


I was trying to over complicate things. Thats all that is needed to make the damage scale at reasonable rate SHEESH!

Ok in GameLiving.cs

Code: Select all
/// <summary>
      /// Returns the Damage this Living does on an attack
      /// </summary>
      /// <param name="weapon">the weapon used for attack</param>
      /// <returns></returns>
        public virtual double AttackDamage(InventoryItem weapon)
        {           
            double damage = (1.0 + Level / 3.7 + Level * Level / 175.0) * AttackSpeed(weapon) * 0.001;
            if (weapon == null || weapon.Item_Type == Slot.RIGHTHAND || weapon.Item_Type == Slot.LEFTHAND || weapon.Item_Type == Slot.TWOHAND)
            {
                //Melee damage buff and debuff
                damage *= GetModified(eProperty.MeleeDamage) * 0.01;
            }
            else if (weapon.Item_Type == Slot.RANGED)
            {
                //Ranged damage buff and debuff
                damage *= GetModified(eProperty.RangedDamage) * 0.01;
            }
            //original code: return damage;
            //Krugus - damage level modifier.  Starts off at x2 dmg at level 0 and by 100th level its x1 dmg modifier.
            return damage * (1+(Level * .01) + (1 - (Level *0.02)));
            }
        /// <summary>
      /// Max. Damage possible without style
      /// </summary>
      /// <param name="weapon">attack weapon</param>
      /// <returns></returns>


Also you'll want to put in the pet damage code to make pets do better damage (same code as posted above but just repeating it to have it all in one place)

In GameLiving.cs

Code: Select all
 // apply total damage cap
            ad.UncappedDamage = ad.Damage;
            ad.Damage = Math.Min(ad.Damage, (int)(UnstyledDamageCap(weapon) * effectiveness));


//Krugus - Start of dmg mod for PETS (1+(level*.06)
//By 17th x2dmg, by 34th x3 dmg, by 50th x4 assuming default Server Properties of 1.0

      if ((this is GameNPC && (this as GameNPC).Brain is ControlledNpc && this.Realm != 0) && target is GameNPC)
      ad.Damage = (int)((double)ad.Damage * (1+(Level*.06) * (ServerProperties.Properties.PVE_DAMAGE)));//PET PVE dmg mod
      if ((this is GameNPC && (this as GameNPC).Brain is ControlledNpc && this.Realm != 0) && target is GamePlayer)
      ad.Damage = (int)((double)ad.Damage * (1+(Level*.06) * (ServerProperties.Properties.PVP_DAMAGE)));//PET PVP dmg mod
               
//End of DMG mod for PETS


            if ((this is GamePlayer || (this is GameNPC && (this as GameNPC).Brain is IControlledBrain && this.Realm != 0)) && target is GamePlayer)
               ad.Damage = (int)((double)ad.Damage * ServerProperties.Properties.PVP_DAMAGE);
            else if ((this is GamePlayer || (this is GameNPC && (this as GameNPC).Brain is IControlledBrain && this.Realm != 0)) && target is GameNPC)
               ad.Damage = (int)((double)ad.Damage * ServerProperties.Properties.PVE_DAMAGE);

            ad.UncappedDamage = ad.Damage;

            // patch to missed when 0 damage



Ok now I'm going to work on something else and stop tweaking the damage code.

:D
"Stand back man! I have a Holy Avenger and I know how to use it! " ...quote from the unknown paladin.
User avatar
Krugus
DOL Initiate
 
Posts: 22
Joined: Mon Sep 10, 2007 4:38 am
Location: Arkansas

Postby nor » Fri Sep 28, 2007 3:11 pm

That is the same thing as
Code: Select all
(2 - 0.01*Level)


I wonder. With nearly doubled damage at first levels is it possible to kill something?

As I remember first levels were pretty accurate, because it was tested with level 5 char. Higher levels should be more broken. But if people say there is no problem at first levels (my main concern) then why not...
nor
Inactive Staff Member
 
Posts: 1584
Joined: Wed Mar 03, 2004 3:56 am

Postby nor » Fri Sep 28, 2007 5:38 pm

Another thing to consider is extreme values like level 255 will result in negative damage. I'd suggest to cap this factor by 1, not lower.
nor
Inactive Staff Member
 
Posts: 1584
Joined: Wed Mar 03, 2004 3:56 am

Postby Krugus » Sat Sep 29, 2007 1:25 am

nor wrote:That is the same thing as
Code: Select all
(2 - 0.01*Level)


I wonder. With nearly doubled damage at first levels is it possible to kill something?

As I remember first levels were pretty accurate, because it was tested with level 5 char. Higher levels should be more broken. But if people say there is no problem at first levels (my main concern) then why not...


Ya know I was about to say it wasn't but as I looked at it again. It is!

Well I'm not having any issues killing with my lower levels but if it was an issue , one could always put an if statement in there to start using that adjustment around 5 to 10th level or so.
"Stand back man! I have a Holy Avenger and I know how to use it! " ...quote from the unknown paladin.
User avatar
Krugus
DOL Initiate
 
Posts: 22
Joined: Mon Sep 10, 2007 4:38 am
Location: Arkansas

Re: NPC Damage Too low? Look inside (Updated 9/27/07)

Postby Marko » Tue Mar 22, 2016 1:05 am

So glad I found this - wish it was built into the base code, but just had to implement it on the latest release 'cuz cabby pets were pretty LAME. Good fix, can't wait to try it out - wish this kind of tweak was a db tweak instead of a recompile kind of tweak :(

EDIT: So this is great for Cabby pets, but it boosts other pets way too much. Is there a way to isolate this damage modifier to only Cabalist pets?
User avatar
Marko
DOL Novice
 
Posts: 80
Joined: Mon Jun 09, 2014 8:17 pm
Location: Rural Central Utah (Near Bryce Canyon)


Return to “%s” General

Who is online

Users browsing this forum: No registered users and 1 guest