Damage Calculation

06/04/2010 05:24 dragon89928#1
Okay. I haven't found any physical damage calculations out there that involves BP. Maybe nobody wants it or what but Ive been lurking these forums for a while looking for ideas for my server. Anyway, here's my ROUGH (+- 1.5k) damage compared to the real co. If anyone got any ideas on how to improve my equation by all means please post.

I use 5165 but the gist of it should be the same as other servers.
also, thanks to CoEmu v2, I used some of the damage calculation from there namely the reborn percentages.

This is only to fix FB/SS. Melee you need to change yourself in attack.cs
in skills.cs find

Code:
public uint GetDamage(Character C)
if you look a little bit below that line you should see

Code:
case DamageType.Melee:
replace the whole case with:
Code:
if (Game.World.NoPKMaps.Contains(User.Loc.Map))
                                    if (Info.ExtraEff == ExtraEffect.None)
                                        return 0;

                                ushort Def = (ushort)((double)C.EqStats.defense*2);
                                Buff Shield = C.BuffOf(SkillsClass.ExtraEffect.MagicShield);
                                if (Shield.Eff == SkillsClass.ExtraEffect.MagicShield)
                                    Def = (ushort)(Def * Shield.Value);

                                Damage = User.PrepareAttack(2, false);
                                Damage = (uint)(Damage * Info.EffectValue);
                                Damage += Info.Damage;


                                if (Def >= Damage)
                                    Damage = 1;
                                else
                                    Damage -= Def;

                                if (C.Reborns == 1)
                                {
                                    Damage = (uint)Math.Floor((double)Damage * .7);
                                }
                                else if (C.Reborns == 2)
                                {
                                    Damage = (uint)Math.Floor((double)Damage * .7);
                                    if (User.Reborns < 2)
                                        Damage = (uint)(Math.Floor((double)Damage * .5));
                                }

                                //STGs
                                Damage = (uint)(Math.Floor((double)Damage * (1 - ((C.EqStats.GemBless < .50) ? C.EqStats.GemBless : .50))));
                                

                                //EQ bless
                                if (C.EqStats.TotalBless > 0)
                                {
                                    Damage = (uint)(Math.Floor((double)Damage * (1 - ((C.EqStats.TotalBless < 60) ? (double)C.EqStats.TotalBless : (double)60) * .01)));
                                    //Console.WriteLine(C.EqStats.TotalBless);
                                }
                                
                                //BP
                                //Console.WriteLine(User.Name + " " + (int)User.Potency);
                                //Console.WriteLine(C.Name + " " + (int)C.Potency);
                                if (User.Potency < C.Potency)
                                {
                                    Damage = (uint)(((double)Damage) * (((double)C.Potency / (double)User.Potency) + .85) / Math.Sqrt((double)(C.Potency - User.Potency)));
                                    if (C.Potency - User.Potency >= 50)
                                        Damage = (uint)((double)Damage * .6);
                                }
                                else
                                {

                                    Damage = (uint)((double)Damage * .9);
                                }

                                if (C.Potency >= 300)
                                {
                                    Damage = Damage = (uint)((double)Damage * .7);
                                }





                                Damage += User.EqStats.MeleeDamageIncrease;
                                if (C.EqStats.MeleeDamageDecrease >= Damage)
                                    Damage = 1;
                                else
                                    Damage -= C.EqStats.MeleeDamageDecrease;
                                break;
anyway I also removed something I forget.. I think it was archer_fly or something

Also for 5165 users. Server calculates BP wrong. It doesn't add in the steed BP. So to make it add the steed bp to total bp:

find
Code:
public ushort Potency
replace with
Code:
public ushort Potency
        {
            get
            {
                string s = ((ushort)Equips.HeadGear.Soc1).ToString();
                int prePotency = 0;
                prePotency += Level + 5 * Reborns;
                for (byte x = 1; x <= 12; x++)
                {
                    Item I = Equips.Get(x);
                    if (I.UID != 0)
                        prePotency += I.Pot;
                }
                prePotency += (byte)Nobility.Rank;
                return (ushort)prePotency;
            }
        }
Added:
find:
Code:
public static void GetGemEffect(ref EquipStats E, Gem G)
and add the following cases:
Code:
case Gem.NormalTortoiseGem:
                    {
                        E.GemBless += 0.02;
                        break;
                    }
                case Gem.RefinedTortoiseGem:
                    {
                        E.GemBless += 0.04;
                        break;
                    }
                case Gem.SuperTortoiseGem:
                    {
                        E.GemBless += 0.06;
                        break;
                    }
find:
Code:
public double GemExtraMAttack;
below it add:
Code:
public double GemBless;


find:
Code:
Eqp.GemExtraMAttack += eqp.GemExtraMAttack;
below it add:
Code:
Eqp.GemBless += eqp.GemBless;


find:
Code:
Eqp.GemExtraMAttack -= eqp.GemExtraMAttack;
below it add:
Code:
Eqp.GemBless -= eqp.GemBless;


find:
Code:
EqStats.GemExtraAttack = 1;
below it add:
Code:
EqStats.GemBless = 0;
I think that should be it. If I'm missing anything just post something.

Also to those that wanna help make a better damage equation i also attached an excel file with all the info on the damages. It's kinda messy though but meh.

And if you are gonna use this, some thanks would be nice.
06/04/2010 06:19 xSynthesis#2
I really didn't thing someone gonna release a proper damage calculation for 5165 source. Good job +k
06/04/2010 06:29 BlueFlame11#3
Same thanks dude <333

#Edit
You should take the time to release it on 4bot before some one else does

Thanks AGAIN

#Edit 2

I get 2 errors when adding the the stuff above

Quote:
Error 1 A local variable named 'Def' cannot be declared in this scope because it would give a different meaning to 'Def', which is already used in a 'child' scope to denote something else C:\Users\DesignMonkey\Desktop\Stuff\Conquer Sources\Project #2\Game\Features\Skills.cs 459 32 NewestCOServer
Quote:
Error 2 A local variable named 'Shield' cannot be declared in this scope because it would give a different meaning to 'Shield', which is already used in a 'child' scope to denote something else C:\Users\DesignMonkey\Desktop\Stuff\Conquer Sources\Project #2\Game\Features\Skills.cs 460 30 NewestCOServer
06/04/2010 09:29 dragon89928#4
@synthesis
Yeah.. I got tired of the stupid 30ks full +12s did to each other on my server. This is a VERY rough estimation of the damages.

@blueflame11

Did you remove even the "case"? The code should be..

Code:
case DamageType.Melee:
if (Game.World.NoPKMaps.Contains(User.Loc.Map))
                                    if (Info.ExtraEff == ExtraEffect.None)
                                        return 0;

                                ushort Def = (ushort)((double)C.EqStats.defense*2);
                                Buff Shield = C.BuffOf(SkillsClass.ExtraEffect.MagicShield);
                                if (Shield.Eff == SkillsClass.ExtraEffect.MagicShield)
                                    Def = (ushort)(Def * Shield.Value);

                                Damage = User.PrepareAttack(2, false);
                                Damage = (uint)(Damage * Info.EffectValue);
                                Damage += Info.Damage;


                                if (Def >= Damage)
                                    Damage = 1;
                                else
                                    Damage -= Def;

                                if (C.Reborns == 1)
                                {
                                    Damage = (uint)Math.Floor((double)Damage * .7);
                                }
                                else if (C.Reborns == 2)
                                {
                                    Damage = (uint)Math.Floor((double)Damage * .7);
                                    if (User.Reborns < 2)
                                        Damage = (uint)(Math.Floor((double)Damage * .5));
                                }

                                //STGs
                                Damage = (uint)(Math.Floor((double)Damage * (1 - ((C.EqStats.GemBless < .50) ? C.EqStats.GemBless : .50))));
                                

                                //EQ bless
                                if (C.EqStats.TotalBless > 0)
                                {
                                    Damage = (uint)(Math.Floor((double)Damage * (1 - ((C.EqStats.TotalBless < 60) ? (double)C.EqStats.TotalBless : (double)60) * .01)));
                                    //Console.WriteLine(C.EqStats.TotalBless);
                                }
                                
                                //BP
                                //Console.WriteLine(User.Name + " " + (int)User.Potency);
                                //Console.WriteLine(C.Name + " " + (int)C.Potency);
                                if (User.Potency < C.Potency)
                                {
                                    Damage = (uint)(((double)Damage) * (((double)C.Potency / (double)User.Potency) + .85) / Math.Sqrt((double)(C.Potency - User.Potency)));
                                    if (C.Potency - User.Potency >= 50)
                                        Damage = (uint)((double)Damage * .6);
                                }
                                else
                                {

                                    Damage = (uint)((double)Damage * .9);
                                }

                                if (C.Potency >= 300)
                                {
                                    Damage = Damage = (uint)((double)Damage * .7);
                                }





                                Damage += User.EqStats.MeleeDamageIncrease;
                                if (C.EqStats.MeleeDamageDecrease >= Damage)
                                    Damage = 1;
                                else
                                    Damage -= C.EqStats.MeleeDamageDecrease;
                                break;
ie. Def and Shield has to be within the case
06/04/2010 10:26 BlueFlame11#5
Quote:
Originally Posted by dragon89928 View Post
@synthesis
Yeah.. I got tired of the stupid 30ks full +12s did to each other on my server. This is a VERY rough estimation of the damages.

@blueflame11

Did you remove even the "case"? The code should be..

Code:
case DamageType.Melee:
if (Game.World.NoPKMaps.Contains(User.Loc.Map))
                                    if (Info.ExtraEff == ExtraEffect.None)
                                        return 0;

                                ushort Def = (ushort)((double)C.EqStats.defense*2);
                                Buff Shield = C.BuffOf(SkillsClass.ExtraEffect.MagicShield);
                                if (Shield.Eff == SkillsClass.ExtraEffect.MagicShield)
                                    Def = (ushort)(Def * Shield.Value);

                                Damage = User.PrepareAttack(2, false);
                                Damage = (uint)(Damage * Info.EffectValue);
                                Damage += Info.Damage;


                                if (Def >= Damage)
                                    Damage = 1;
                                else
                                    Damage -= Def;

                                if (C.Reborns == 1)
                                {
                                    Damage = (uint)Math.Floor((double)Damage * .7);
                                }
                                else if (C.Reborns == 2)
                                {
                                    Damage = (uint)Math.Floor((double)Damage * .7);
                                    if (User.Reborns < 2)
                                        Damage = (uint)(Math.Floor((double)Damage * .5));
                                }

                                //STGs
                                Damage = (uint)(Math.Floor((double)Damage * (1 - ((C.EqStats.GemBless < .50) ? C.EqStats.GemBless : .50))));
                                

                                //EQ bless
                                if (C.EqStats.TotalBless > 0)
                                {
                                    Damage = (uint)(Math.Floor((double)Damage * (1 - ((C.EqStats.TotalBless < 60) ? (double)C.EqStats.TotalBless : (double)60) * .01)));
                                    //Console.WriteLine(C.EqStats.TotalBless);
                                }
                                
                                //BP
                                //Console.WriteLine(User.Name + " " + (int)User.Potency);
                                //Console.WriteLine(C.Name + " " + (int)C.Potency);
                                if (User.Potency < C.Potency)
                                {
                                    Damage = (uint)(((double)Damage) * (((double)C.Potency / (double)User.Potency) + .85) / Math.Sqrt((double)(C.Potency - User.Potency)));
                                    if (C.Potency - User.Potency >= 50)
                                        Damage = (uint)((double)Damage * .6);
                                }
                                else
                                {

                                    Damage = (uint)((double)Damage * .9);
                                }

                                if (C.Potency >= 300)
                                {
                                    Damage = Damage = (uint)((double)Damage * .7);
                                }





                                Damage += User.EqStats.MeleeDamageIncrease;
                                if (C.EqStats.MeleeDamageDecrease >= Damage)
                                    Damage = 1;
                                else
                                    Damage -= C.EqStats.MeleeDamageDecrease;
                                break;
ie. Def and Shield has to be within the case
WOOT
Thanks!!!!!!
06/04/2010 19:11 dragon89928#6
Quote:
Originally Posted by BlueFlame11 View Post
WOOT
Thanks!!!!!!
haha np. I wasn't too sure if that would fix it but glad it did :)
07/20/2010 23:28 wolvreen2006#7
i found it great release but it need more work
thanks any ways
07/21/2010 00:20 .Beatz#8
Quote:
Originally Posted by wolvreen2006 View Post
i found it great release but it need more work
thanks any ways
Need more work? Then help out the thread starter and do "more work" to it then release it on this thread. I am sure the thread starter will be gratefull for your help :)
07/21/2010 02:18 CØĐ£Ř||Mã©hÍñє#9
muaaaah OMG you are the best
07/21/2010 10:37 -impulse-#10
Here's mine:

Code:
            int Damage = 0;

            if (attacked.ContainsFlag(Network.GamePackets.Update.Flags.ShurikenVortex))
                return 1;
            if (!attacker.Transformed)
                Damage = ServerBase.Kernel.Random.Next((int)attacker.MinAttack, (int)attacker.MaxAttack + 1);
            else
                Damage = ServerBase.Kernel.Random.Next((int)attacker.TransformationMinAttack, (int)attacker.TransformationMaxAttack + 1);

            if (attacker.OnSuperman())
                if (attacked.EntityFlag == EntityFlag.Monster)
                    Damage *= 10;
                else
                    Damage *= 2;

            if (attacker.OnFatalStrike())
                if (attacked.EntityFlag == EntityFlag.Monster)
                    Damage *= 5;

            if (!attacked.Transformed)
                Damage -= attacked.Defence;
            else
                Damage -= attacked.TransformationDefence;

            Damage -= Damage * attacked.ItemBless / 100;

            int potDifference = attacker.Potency - attacked.Potency;
            if (potDifference > 0)
            {
                float rate = (float)potDifference / 100;
                uint damageplus = (uint)(Damage * rate);
                if (damageplus > Damage)
                    Damage = (int)damageplus;
            }

            Damage += attacker.PhysicalDamageIncrease;
            Damage -= attacked.PhysicalDamageDecrease;

            if (Damage <= 0)
                Damage = 1;
For me,since MinAttack, MaxAttack and the Defence are accessors, when shield/stigma is on they get changed directly, so I don't have to add it every where.
07/21/2010 11:12 ~Yuki~#11
both not rly accurate
07/21/2010 20:46 -impulse-#12
Quote:
Originally Posted by ~Yuki~ View Post
both not rly accurate
I don't know about his, but for me, mine works pretty well.
08/02/2010 12:20 Escapex#13
anyway I also removed something I forget.. I think it was archer_fly or something

Also for 5165 users. Server calculates BP wrong. It doesn't add in the steed BP. So to make it add the steed bp to total bp:

find
Code:

public ushort Potency

replace with
Code:

public ushort Potency
{
get
{
string s = ((ushort)Equips.HeadGear.Soc1).ToString();
int prePotency = 0;
prePotency += Level + 5 * Reborns;
for (byte x = 1; x <= 12; x++)
{
Item I = Equips.Get(x);
if (I.UID != 0)
prePotency += I.Pot;
}
prePotency += (byte)Nobility.Rank;
return (ushort)prePotency;
}
}


--------------------------------------
dragon please input the following words
---------------------------------------
Character.cs to find this top stuff. <.<