[Help] stats and damage formulas

Welcome in the osRose emulator Project.

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

[Help] stats and damage formulas

Postby meydan on Thu Dec 12, 2013 4:10 pm

how can i know the formulas of the damage and the stats (including hp/mp)?
meydan
Jelly Bean
Jelly Bean
 
Posts: 30
Joined: Tue Aug 06, 2013 12:23 pm

Re: [Help] stats and damage formulas

Postby PurpleYouko on Thu Dec 12, 2013 7:10 pm

damage is calculated in battle.cpp
stats are calculated in PlayerStats.cpp

You can do what you like with damage calculations since they are handled 100% in the server
Most Stats, however, are not! We have to figure out how to make them match the values that the client calculates for itself.
Mismatches between server and client are one of the main causes for annoying bugs
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: [Help] stats and damage formulas

Postby meydan on Fri Dec 13, 2013 12:04 am

PurpleYouko wrote:damage is calculated in battle.cpp
stats are calculated in PlayerStats.cpp

You can do what you like with damage calculations since they are handled 100% in the server
Most Stats, however, are not! We have to figure out how to make them match the values that the client calculates for itself.
Mismatches between server and client are one of the main causes for annoying bugs

yeah so how can i find out how much hp/mp i gain each lvl and stuff like that ?
meydan
Jelly Bean
Jelly Bean
 
Posts: 30
Joined: Tue Aug 06, 2013 12:23 pm

Re: [Help] stats and damage formulas

Postby PurpleYouko on Fri Dec 13, 2013 3:17 pm

Only way to do that is to make a huge list of effects that changing stuff has on your client.

In short though, don't bother unless you find differences between client and server values.
It has been done already. People spent huge amounts of time making sure the values were the same on both sides. Since we don't have access to the calculations in the client, we had to get the nearest fit that we could find by tweaking the formulae in the server.

I personally spent almost a full week making graphs of pretty much everything then applied the correct formulae to my KTRose source.

If you are concerned then use the stats window in the client to get client values then compare them to server values using the /mystat command
/mystat mspd = movespeed and so on. there are dozens of variations that I added and also a /mystat2 command (which I don't see the point of at all when /mystat is already infinitely expandable). no idea who added that one or why.
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: [Help] stats and damage formulas

Postby meydan on Fri Dec 13, 2013 6:06 pm

PurpleYouko wrote:Only way to do that is to make a huge list of effects that changing stuff has on your client.

In short though, don't bother unless you find differences between client and server values.
It has been done already. People spent huge amounts of time making sure the values were the same on both sides. Since we don't have access to the calculations in the client, we had to get the nearest fit that we could find by tweaking the formulae in the server.

I personally spent almost a full week making graphs of pretty much everything then applied the correct formulae to my KTRose source.

If you are concerned then use the stats window in the client to get client values then compare them to server values using the /mystat command
/mystat mspd = movespeed and so on. there are dozens of variations that I added and also a /mystat2 command (which I don't see the point of at all when /mystat is already infinitely expandable). no idea who added that one or why.

Im only asking this because im building a different method for the hp/mp but i dont know how to calculate how much they gain each lvl and for str,int
meydan
Jelly Bean
Jelly Bean
 
Posts: 30
Joined: Tue Aug 06, 2013 12:23 pm

Re: [Help] stats and damage formulas

Postby PurpleYouko on Fri Dec 13, 2013 10:05 pm

the only way to figure it out is to watch the values in the client stats window then figure out a formula that reproduces those same results.

As i said, that has already been done for most stuff. Some aren't perfect though.

We can't change the client so we have to do our best to emulate it in the server.
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: [Help] stats and damage formulas

Postby meydan on Sat Dec 14, 2013 6:10 pm

PurpleYouko wrote:the only way to figure it out is to watch the values in the client stats window then figure out a formula that reproduces those same results.

As i said, that has already been done for most stuff. Some aren't perfect though.

We can't change the client so we have to do our best to emulate it in the server.

in ragezone someone has published the official server of irose and taiwan rose including the client
it can help us easily to understand the client and even change it
but i cant understand the hp/mp formula can you help me ?
this is the check for getexp

int CObjUSER::GetCur_MaxHP ()
{
return this->m_Battle.m_nMaxHP + m_EndurancePack.GetStateValue( ING_INC_MAX_HP ) + m_AruaAddHp;
};
meydan
Jelly Bean
Jelly Bean
 
Posts: 30
Joined: Tue Aug 06, 2013 12:23 pm

Re: [Help] stats and damage formulas

Postby PurpleYouko on Sat Dec 14, 2013 8:40 pm

OK first of all that is not irose source. It's actually evo source.

You are right that it could help to understand the correct formula to use in the server though
  1. int CObjUSER::GetCur_MaxHP ()
  2. {
  3. return this->m_Battle.m_nMaxHP + m_EndurancePack.GetStateValue( ING_INC_MAX_HP ) + m_AruaAddHp;
  4. };


That particular function returns a player's maximum HP.
this refers to the current player who has been cast as class CObjUSER
m_Battle.nMaxHP is (I assume) the base value for maximum HP for that player. The actual calculations are somewhere else. You are going to have to search for where this is initially calculated
m_EndurancPack.GetStateValue(ING_INC_MAX_HP) appears to be a function that returns a modifier based on your current endurance buff state. ING_INC_MAX_HP is a constant that is defined somewhere else. Again you are going to need to find out what the constant is and what the function call actually does.
m_AruaAddHp would seem to be a variable that is defined elsewhere. It is probably a class variable. Go find where it is defined.

It's not the easiest thing in the world to figure out what is going on in that code base. Each function seems to call a bunch of other functions in massive nests. You have to go down each of those branches to find the root values before you can work out what each function will return.
It's doable but it will be very convoluted.
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: [Help] stats and damage formulas

Postby meydan on Sun Dec 15, 2013 2:33 am

PurpleYouko wrote:OK first of all that is not irose source. It's actually evo source.

You are right that it could help to understand the correct formula to use in the server though
  1. int CObjUSER::GetCur_MaxHP ()
  2. {
  3. return this->m_Battle.m_nMaxHP + m_EndurancePack.GetStateValue( ING_INC_MAX_HP ) + m_AruaAddHp;
  4. };


That particular function returns a player's maximum HP.
this refers to the current player who has been cast as class CObjUSER
m_Battle.nMaxHP is (I assume) the base value for maximum HP for that player. The actual calculations are somewhere else. You are going to have to search for where this is initially calculated
m_EndurancPack.GetStateValue(ING_INC_MAX_HP) appears to be a function that returns a modifier based on your current endurance buff state. ING_INC_MAX_HP is a constant that is defined somewhere else. Again you are going to need to find out what the constant is and what the function call actually does.
m_AruaAddHp would seem to be a variable that is defined elsewhere. It is probably a class variable. Go find where it is defined.

It's not the easiest thing in the world to figure out what is going on in that code base. Each function seems to call a bunch of other functions in massive nests. You have to go down each of those branches to find the root values before you can work out what each function will return.
It's doable but it will be very convoluted.

ok i started exploring and i have found the calculations of m_Battle.nMaxHP as you said its the base hp calculation
so the calculation goes like that
m_Battle.m_nMaxHP = (short)( ( this->GetCur_LEVEL()+iA ) * sqrtf(this->GetCur_LEVEL()+iM1) * fC + ( this->GetCur_STR()*2 ) + this->m_iAddValue[ AT_MAX_HP ] );
i have found everything except "this->m_iAddValue[ AT_MAX_HP ] );" (AT_MAX_HP = 38)
i know its a value at the array in place 38 but i searched the entire source and i couldnt find a row that changes the value inside this array except the function ZeroMemory that sends this array but it only changes everything to 0
can you help me ?
meydan
Jelly Bean
Jelly Bean
 
Posts: 30
Joined: Tue Aug 06, 2013 12:23 pm

Re: [Help] stats and damage formulas

Postby PurpleYouko on Sun Dec 15, 2013 8:35 pm

the original definition of m_iAddValue[] is in file CUserDATA.h line 628
  1. int m_iAddValue   [ AT_MAX ];

AT_MAX is a constant defined globally as 133 so there's the initial size of the array.
As you rightly surmise, AT_MAX_HP is a constant with a global value of 38 and it is used as an index value for this array.
 
You should note that the line of code that you quoted seems to be found in a couple of places.
The first is at line 346 in CUserDATA.cpp
 
  1. #ifdef _NEWSTATUS
  2.        
  3.         float fC;
  4.         iA=5,   iM1=20, fC=3.5f;
  5.         m_Battle.m_nMaxHP  = (short)( ( this->GetCur_LEVEL()+iA ) * sqrtf(this->GetCur_LEVEL()+iM1) * fC + ( this->GetCur_STR()*2 ) + this->m_iAddValue[ AT_MAX_HP ] );

It is located in side a conditional based on whether or not the constant _NEWSTATUS is defined,
When I compile this code, it shows up as NOT defined in the code editor (it is greyed out) so under those conditions it is not actually compiled anyway.
Strangely though, _NWSTATUS IS defined in StdAfx.h which is definitely run in this project so I wonder if intelisense is just being dumb in this case.
The next instance of it is in the ELSE part of the same conditional on line
  1. m_Battle.m_nMaxHP  = ( this->GetCur_LEVEL()+iA ) * iM1 + ( this->GetCur_STR()*iM2 ) + this->m_iAddValue[ AT_MAX_HP ];

It is not quite identical as you will notice.
it also appears at line 408
  1. m_Battle.m_nMaxHP  = ( this->GetCur_LEVEL()+iA ) * iM1 + ( this->GetCur_STR()*iM2 ) + this->m_iAddValue[ AT_MAX_HP ];

And this one is exactly the same as the second one

As far as i can deduce the array iAddValue[] applies only to added stats from items that are currently being used.
Take a look at function void CUserDATA::Cal_AddAbility (tagITEM &sITEM, short nItemTYPE) (starts at line 250)
It would appear that m_iAddValue[ AT_MAX_HP ] contains the total of all item effects that could boost your max HP. When no items are equipped it is equal to zero.
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


Return to Support - OsRose Emulator

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest