Player & Monster Damage Equations

If you want to help us or give some corrections / codes, put it here ;)

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Player & Monster Damage Equations

Postby Planetary_Myth on Fri Nov 05, 2010 3:07 am

Edit: Added the code I am using for testing this.

Spent 12 hours today trying different equations and came up with these 2.
They should be very close to the base damage on official.

Player Damage
  1. MonsterDef + MonsterM-Def / 15 = ?
  2. PlayerAtt - ? = PlayerDmg


Monster Damage
  1. PlayerDef + PlayerM-Def / 15 = ?
  2. MonsterAtt - ? = MonsterDmg


Edit: Changed code found problems with last code.
Commented out some bonuses they were throwing off the values.
This what I am using to test.
Changes are in red.
In: Battle.cpp
  1.    reduceItemsLifeSpan( false );
  2.     Enemy->OnBeAttacked( this );
  3.    float DefTotal = (Enemy->Stats->Magic_Defense + Enemy->Stats->Defense) / 15;
  4.     float attack = Stats->Attack_Power - DefTotal;
  5.     //float attack = (float)Stats->Attack_Power - ((Enemy->Stats->Magic_Defense+Enemy->Stats->Defense )/2);
  6.     //if(attack<0) attack = 5;
  7.     //attack *= 0.65;
  8.     //float d_attack = attack / 100;    if(attack<0) attack = 5;
  9.     attack += (float)GServer->RandNumber( 0, 7 ) - 2;
  10.    //attack += ((Stats->Level - Enemy->Stats->Level) * d_attack);    if(attack<7) attack = 5;
  11.    long int hitpower = (long int)floor (attack); //(attack + GServer->RandNumber(0, 4));    /*if(IsPlayer( ))
  12.         hitpower = (long int)floor(attack * 1.2 );*/
  13.     if(IsPlayer( )) //temp fix to find balance btw monster and player
  14.         hitpower = (long int)floor(attack * (GServer->Config.PlayerDmg/100.00));
  15.     if(IsMonster( )) //temp fix to find balance btw monster and player
  16.         hitpower = (long int)floor(attack * (GServer->Config.MonsterDmg/100.00));
Last edited by Planetary_Myth on Fri Nov 05, 2010 2:34 pm, edited 2 times in total.
Planetary_Myth
Smoulie
Smoulie
 
Posts: 49
Joined: Sun Apr 18, 2010 2:50 pm

Re: Player & Monster Damage Equations

Postby PurpleYouko on Fri Nov 05, 2010 1:55 pm

Why are you adding MonsterDef and MonsterM-Def together?

Regular defense and magic defense are completely different and should never be combined.

Every attack in the game is defined as either magic or normal (It's in the STBs) so a regular attack should completely circumvent Magical defense and vice versa.

I've always wondered why the basic servers seem to add the two together like this.

In my KTRose (osprose base) server I completely seperated them and it works MUCH better
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: Player & Monster Damage Equations

Postby Planetary_Myth on Fri Nov 05, 2010 2:45 pm

PurpleYouko wrote:Why are you adding MonsterDef and MonsterM-Def together?

Regular defense and magic defense are completely different and should never be combined.

Every attack in the game is defined as either magic or normal (It's in the STBs) so a regular attack should completely circumvent Magical defense and vice versa.

I've always wondered why the basic servers seem to add the two together like this.

In my KTRose (osprose base) server I completely seperated them and it works MUCH better


I added them together because it is the way its done in the original svn code.
Right now this was the best solution to make it playable.

I agree the Def and M-Def should be seperate but I am not sure who is working on the code.
So in short I just wanted a fix that works for now.
Planetary_Myth
Smoulie
Smoulie
 
Posts: 49
Joined: Sun Apr 18, 2010 2:50 pm

Re: Player & Monster Damage Equations

Postby PurpleYouko on Fri Nov 05, 2010 3:14 pm

here's the code that I use.
You might find it useful
It still needs to be tweaked a little i think. It's pretty good but not perfect.

  1.  
  2. Enemy->OnBeAttacked( this );
  3.     Position->destiny  = Position->current;
  4.     Log(MSG_DEBUG,"(NormalAttack) Destiny set to current position X: %f Y: %f.",Position->current.x,Position->current.y);
  5.    
  6.     // new formula
  7.     float levelmult = (float) Stats->Level / Enemy->Stats->Level;
  8.     if(levelmult > 2)levelmult = 2;
  9.     float atkdefmult = 0;
  10.     float attack = 0;
  11.     float constant = 4;
  12.     if(Stats->magicattack == 1)
  13.     {
  14.         atkdefmult = (float) Stats->Attack_Power / Enemy->Stats->Magic_Defense;
  15.     }
  16.     else
  17.     {
  18.         atkdefmult = (float) Stats->Attack_Power / Enemy->Stats->Defense;
  19.     }
  20.     attack = Stats->Attack_Power * levelmult * atkdefmult / constant;
  21.    
  22.     if(attack < 5) attack = 5;
  23.     float d_attack = attack / 100;
  24.     float mod = GServer->RandNumber( 0, 10 ) * d_attack;
  25.     attack += mod;
  26.     long int hitpower = (long int)floor(attack);
  27.     if(IsPlayer( )) //temp fix to find balance btw monster and player
  28.     {
  29.         hitpower = (long int)floor(attack * (GServer->Config.PlayerDmg/100.00));
  30.         hitpower+=((hitpower*(Stats->ExtraDamage))/100);
  31.     }
  32.     if(IsSummon( )) //temp fix to find balance btw monster and player
  33.     {
  34.         hitpower = (long int)floor(attack * (GServer->Config.PlayerDmg/100.00));
  35.         //Log(MSG_DEBUG,"Summon hitpower = %i",hitpower);
  36.     }
  37.     if(IsMonster( )) //temp fix to find balance btw monster and player
  38.         hitpower = (long int)floor(attack * (GServer->Config.MonsterDmg/100.00));
  39.     bool critical = false;
  40.     if(hitpower <= 5)
  41.     {
  42.         hitpower = 5;
  43.     }
  44.     else
  45.     {
  46.         if(GServer->RandNumber(0,300)<Stats->Critical)
  47.         {
  48.             hitpower = (long int)floor(hitpower * 1.5);
  49.             critical = true;
  50.         }
  51.     }
  52.     // dodge
  53.     unsigned int hitvalue = (unsigned int)floor((double)(Stats->Accury * 40 / Enemy->Stats->Dodge));
  54.     if(hitvalue > 100) hitvalue = 100;
  55.     if(GServer->RandNumber( 0, 100 ) > hitvalue)
  56.         hitpower = 0; // dodged
  57.     if (hitpower > 0x7ff)//2047 packet size limit.
  58.     {
  59.        hitpower = 0x7ff;
  60.     }
  61.     Battle->atktarget = Battle->target;
  62.  
  63.     //if(IsMonster())
  64.     //{
  65.         //Log(MSG_INFO,"Monster hits player for %i damage. Attack target = %i",hitpower,Battle->atktarget);
  66.     //}
  67.     //Log( MSG_INFO, "hitpower %i. Attack %f ", hitpower,attack );
  68.     if(!Enemy->IsSummon( ) && Enemy->IsMonster( ))
  69.     {
  70.         Enemy->AddDamage( this, hitpower );
  71.         Enemy->damagecounter += hitpower;// is for AI
  72.     }
  73.     Enemy->Stats->HP -= hitpower;
  74.     //if(IsPlayer())
  75.     //    Log(MSG_DEBUG,"Player attack did damage %i",hitpower);
  76.     //if(IsMonster())
  77.     //    Log(MSG_DEBUG,"Monster attack did damage %i",hitpower);
  78.    

I still have a load of debug outputs in this, some commented out but others active.

i don't think the dev rev actually loads in a value to define magic attack or normal attack so you will probably be missing
Stats->magicattack

The use of "constant" is what lets me adjust the formula easily. It is presently defined as 4 but you can play around with this and use any number you like.
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: Player & Monster Damage Equations

Postby Planetary_Myth on Fri Nov 05, 2010 3:44 pm

Very usefull thank you for sharing.
Planetary_Myth
Smoulie
Smoulie
 
Posts: 49
Joined: Sun Apr 18, 2010 2:50 pm


Return to Submit Code

Who is online

Users browsing this forum: No registered users and 2 guests