[FIX] Stat Calculations.

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

[FIX] Stat Calculations.

Postby T-Grave on Mon Jun 22, 2009 7:05 pm

Hi,

I'll be devoting (some) of my time to fixing the stat calculations found in osIrose, since most of them are way off. I'll be adding fixes to this list as soon as I tested them on my local server.

How does it work:
- I'll provide you with the full function code, and the adjustments I made to them.


NOTE: I'm using the unmodified version of HRose.exe(131), so I'm fixing the calculations to work with that client. If you have any suggestions or you find any bugs, post them down here.

Currently working on:
- Dodge (already fixed main calculation, fixing the bug were shields do not add dodge)

Known bugs:
- HP Generation(???)
I've got a question about this one, it seems like the server regenerates WAY faster then the client does, but the client only adds 1HP/sec or something like that, isn't this more of a clientside problem?
---------

Movement Speed:
Adjustments:
  • Replaced the whole function with PY's one from osprose (22/06/'09 - 8PM)
  • Added dexterity calculations to it. (22/06/'09 - 8PM)
  • Fixed shoe calculations (22/06/'09 - 8PM)

(note: You'll have to add "unsigned int Mspd_base" in the STAT struct found in chartype.h)
  1.  
  2. unsigned int CPlayer::GetMoveSpeed()
  3. {
  4.     UINT mspeed = 425;
  5.     if(!Status->CanRun)
  6.     {
  7.         Status->Stance = WALKING;
  8.     }
  9.     mspeed += UINT((Attr->Dex) * 0.85);
  10.     switch(Status->Stance)
  11.     {
  12.         case WALKING: //walking
  13.             mspeed = 200;
  14.         break;
  15.         case 1:
  16.         case RUNNING: // running 476 - 489
  17.         {
  18.             if(items[6].count != 0)//Foot
  19.             {
  20.                 UINT tspeed = GServer->EquipList[SHOE].Index[items[6].itemnum]->movespeed;
  21.                 UINT valspeed = tspeed - 65;
  22.                 mspeed += ((valspeed * 5) + (valspeed / 5));
  23.                 if(Session->codedebug) //Debug code
  24.                 {
  25.                     GServer->SendPM(this, "Move speed with shoes on %i", mspeed);
  26.                 }
  27.             }
  28.             for(UINT i=0;i<12;i++)//cloth stats [from tomiz]
  29.             {
  30.                 if(items[i].count != 0)
  31.                 {
  32.                     if(items[i].itemtype > 9)
  33.                     {
  34.                         Log(MSG_WARNING, "Char %s have equip invalid item: %i,%i", CharInfo->charname, items[i].itemtype, items[i].itemnum);
  35.                         continue;
  36.                     }
  37.                     if(GServer->EquipList[items[i].itemtype].Index[items[i].itemnum]->stat1[0] == MOVE_SPEED)
  38.                     {
  39.                         mspeed += GServer->EquipList[items[i].itemtype].Index[items[i].itemnum]->stat1[1];
  40.                     }
  41.                     if(GServer->EquipList[items[i].itemtype].Index[items[i].itemnum]->stat2[0] == MOVE_SPEED)
  42.                     {
  43.                         mspeed += GServer->EquipList[items[i].itemtype].Index[items[i].itemnum]->stat2[1];
  44.                     }
  45.                     if(Session->codedebug) //Debug code
  46.                     {
  47.                         GServer->SendPM(this, "Move speed %i after equipment stats for item in slot %i",mspeed,i);
  48.                     }
  49.                 }
  50.                 if(items[i].stats > 0 && items[i].stats < 500)
  51.                 {
  52.                     if(GServer->StatsList[items[i].stats].stat[0] == A_DASH)
  53.                     {
  54.                         mspeed += GServer->StatsList[items[i].stats].value[0];
  55.                     }
  56.                     if(GServer->StatsList[items[i].stats].stat[1] == A_DASH)
  57.                     {
  58.                         mspeed += GServer->StatsList[items[i].stats].value[1];
  59.                     }
  60.                     if(Session->codedebug) //Debug code
  61.                     {
  62.                         GServer->SendPM(this, "Move speed %i after adding extra/gem stats for item in slot %i",mspeed,i);
  63.                     }
  64.                 }
  65.             }
  66.             if(Session->codedebug) //Debug code
  67.             {
  68.                 GServer->SendPM(this, "Move speed %i after adding all equipped items",mspeed);
  69.             }
  70.             UINT Extra = 0;
  71.             for(UINT i=0;i<30;i++)
  72.             {
  73.                 if(pskill[i] == 0)
  74.                 {
  75.                     continue;
  76.                 }
  77.                 CSkills* skill = GServer->GetSkillByID((pskill[i])+(pskilllvl[i]));
  78.                 if(skill == NULL)
  79.                 continue;
  80.                 for(UINT j = 0; j < 2; j++)
  81.                 {
  82.                     if(skill->buff[j] == sMoveSpeed || skill->buff[j] ==  sMoveSpeed2)
  83.                     {
  84.                         if(skill->value2[j] > 0)
  85.                             Extra += mspeed * skill->value2[j] / 100;
  86.                         if(skill->value1[j] > 0)
  87.                             Extra += skill->value1[j];
  88.                     }
  89.                 }
  90.             }
  91.             mspeed += Extra;
  92.             if(Session->codedebug) //Debug code
  93.             {
  94.                 GServer->SendPM(this, "Move speed %i after adding passive skills", mspeed);
  95.             }
  96.             Stats->Mspd_base = mspeed;
  97.             if(Status->Dash_up != 0xff)
  98.             {
  99.                 mspeed += MagicStatus[Status->Dash_up].Value;
  100.                 if(Session->codedebug) //Debug code
  101.                 {
  102.                     GServer->SendPM(this, "Speed buff detected. amount: %i new move speed: %i",MagicStatus[Status->Dash_up].Value, mspeed);
  103.                 }
  104.             }
  105.             if(Status->Dash_down != 0xff)
  106.             {
  107.                 mspeed -= MagicStatus[Status->Dash_down].Value;
  108.                 if(Session->codedebug) //Debug code
  109.                 {
  110.                     GServer->SendPM(this, "Speed DE-buff detected. amount: %i new move speed: %i", MagicStatus[Status->Dash_down].Value, mspeed);
  111.                 }
  112.             }
  113.         }
  114.         break;
  115.         case DRIVING: //cart or gear
  116.         {
  117.             //Log(MSG_INFO, "player is driving");
  118.             float m_speed = 0;
  119.             int patType = GServer->PatList.Index[items[135].itemnum]->type;
  120.             //if(this->items[135].itemnum > 30 && this->items[135].itemnum < 40) //Castle gear body
  121.             if(patType == 512)
  122.             {
  123.                 m_speed = 1000;
  124.                 float mod1 =(float)GServer->PatList.Index[items[136].itemnum]->speed;
  125.                 mod1 /= 100; //engine
  126.                 float mod2 =(float)GServer->PatList.Index[items[137].itemnum]->speed;
  127.                 mod2 /= 100; // legs
  128.                 m_speed *= mod1;
  129.                 m_speed *= mod2;
  130.                 if(Session->codedebug) //Debug code
  131.                 {
  132.                     GServer->SendPM(this, "Move speed %i riding a Castle Gear",m_speed);
  133.                 }
  134.             }
  135.             else if(patType == 511) //Cart body
  136.             {
  137.                 m_speed = 1000;
  138.                 float mod1 =(float)GServer->PatList.Index[items[136].itemnum]->speed;
  139.                 mod1 /= 100; //engine
  140.                 float mod2 =(float)GServer->PatList.Index[items[137].itemnum]->speed;
  141.                 mod2 /= 100;  //wheels
  142.                 m_speed *= mod1;
  143.                 m_speed *= mod2;
  144.                 if(GServer->PatList.Index[items[138].itemnum]->condition[1] == 23) // accessory
  145.                     m_speed +=(float)GServer->PatList.Index[items[138].itemnum]->modifier[1];
  146.                 if(Session->codedebug) //Debug code
  147.                 {
  148.                     GServer->SendPM(this, "Move speed %f riding a Cart",m_speed);
  149.                 }
  150.             }
  151.             else
  152.             {
  153.                 Log(MSG_ERROR,"What the heck is this character driving? it is type %i", patType);
  154.             }
  155.             mspeed =(int)floor(m_speed);
  156.             if(Session->codedebug) //Debug code
  157.             {
  158.                 GServer->SendPM(this, "Final Speed: %i", mspeed);
  159.             }
  160.             Stats->Mspd_base = mspeed;
  161.  
  162.         }
  163.         break;
  164.     }
  165.     return mspeed;
  166. }
T-Grave
osiRose dev
osiRose dev
 
Posts: 211
Joined: Sun Jun 07, 2009 2:06 pm
Location: Belgium

Re: [FIX] Stat Calculations.

Postby PurpleYouko on Mon Jun 22, 2009 9:35 pm

Nice job. :D
Couple of questions though

1) Did you check the fairy buff? I'm not sure it's the same in osirose. It might be a multiplication by 1.1 rather than an addition. Whether fairies were in irose or not is besides the point. They do work there so I assume they were planned at least.
2) Are all the calcs done in the same order? Wouldn't surprise me to find otherwise.
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
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4548
Joined: Fri Aug 10, 2007 2:05 pm

Re: [FIX] Stat Calculations.

Postby T-Grave on Mon Jun 22, 2009 10:39 pm

1. I completely removed fairies from my server code :P
2. I think the order might have been different, but if they were in a different order, I already changed them ;)

Oh yeah, regarding the order, I'll check up on that sometime later so I can let you guys know if you'd have to change something ;)
T-Grave
osiRose dev
osiRose dev
 
Posts: 211
Joined: Sun Jun 07, 2009 2:06 pm
Location: Belgium

Re: [FIX] Stat Calculations.

Postby XxXshidoXxX on Tue Jun 23, 2009 12:37 pm

Well i think you deserve it , and arnold is ok too , you seem interested in osirose so we have provided you an svn acess , you can check it by email


Thanks for the code i'm gonna test it now
osrose mobile project
viewtopic.php?f=4&t=5779
Looking for a client ? Its here :
viewtopic.php?f=34&t=5787
OsRose Mobile development + Titan Rose redesign
https://github.com/shid0x
User avatar
XxXshidoXxX
osiRose dev
osiRose dev
 
Posts: 419
Joined: Mon Aug 27, 2007 11:44 am

Re: [FIX] Stat Calculations.

Postby PurpleYouko on Tue Jun 23, 2009 2:12 pm

1. I completely removed fairies from my server code :P

Well that's fine for your server but if you release this code to osirose svn you should probably leave options open for players to use them or not. Possibly set up a Config value to control whether they are allowed or not. ;)
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
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4548
Joined: Fri Aug 10, 2007 2:05 pm

Re: [FIX] Stat Calculations.

Postby Arnold on Wed Jun 24, 2009 8:56 pm

T-Grave wrote:since most of them are way off.

weird they were pretty close with my client

PurpleYouko wrote:Whether fairies were in irose or not is besides the point.

you really got no clue do you?
Arnold
osiRose dev
osiRose dev
 
Posts: 340
Joined: Sun Sep 09, 2007 8:50 pm
Location: pebkac

Re: [FIX] Stat Calculations.

Postby PurpleYouko on Wed Jun 24, 2009 9:46 pm

you really got no clue do you?

All I said here is that anyone who runs a server should be given the option to have fairies if they want them and that it is totally irrelevant whether the original server had them or not.
The point is that fairies work in irose clients if they are enabled on the server.
Frankly I don't remember whether they were there in the original or not and I really don't care very much either way.
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
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4548
Joined: Fri Aug 10, 2007 2:05 pm

Re: [FIX] Stat Calculations.

Postby T-Grave on Thu Jun 25, 2009 8:05 pm

In that case, people should just compare their current function to mine and take a look at what I changed(that way they might even learn a thing or two :p)

EDIT:
Oh lol, I just noticed the reply about svn acess, I looked over it previously. Thanks!
So, does that mean I can upload any code I want once I've tested it out?

I'll edit the fairies back in and add a config value to enable or disable them(you never know someone actually wants to use them, right?)
But does the irose client support fairies out of the box?
Because if it doesn't, editing them back in makes no sense, because anyone who can edit in the fairies in their client could also edit it in server side, right?
T-Grave
osiRose dev
osiRose dev
 
Posts: 211
Joined: Sun Jun 07, 2009 2:06 pm
Location: Belgium

Re: [FIX] Stat Calculations.

Postby PurpleYouko on Thu Jun 25, 2009 8:39 pm

the question is more like Does anyone still even have an out-of-the-box version of irose?
I think I still do someplace but I'm not certain.
A lot of the modded clients seem to have the fairy in them. Whether they were used or not i don't know but the ones I've looked at have all the ZMS, ZMO, EFT (and others)files for the fairy
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
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4548
Joined: Fri Aug 10, 2007 2:05 pm

Re: [FIX] Stat Calculations.

Postby T-Grave on Thu Jun 25, 2009 8:40 pm

I'll just leave it in, we can always edit them back out later on if it's necessary.
T-Grave
osiRose dev
osiRose dev
 
Posts: 211
Joined: Sun Jun 07, 2009 2:06 pm
Location: Belgium

Next

Return to Submit Code

Who is online

Users browsing this forum: No registered users and 1 guest

cron