Vital Jam fix

Submit code for osProse project.

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

Vital Jam fix

Postby Blah4 on Sun Jun 01, 2008 7:31 pm

Small (and temporary?) fix for stamina stuff:
in extrafunctions.cpp, find:
  1.        case 312://Food
  2.         {
  3.             useitem->usescript = 1;
  4.             useitem->usetype = UseList.Index[useitem->itemnum]->useeffect[0];
  5.             useitem->usevalue = UseList.Index[useitem->itemnum]->useeffect[1];
  6.         }

and replace it with
  1.        case 312://Food
  2.         {
  3.             if( useitem->itemnum>55 && useitem->itemnum<61)//If it is Vital Jam
  4.             {
  5.                 int restore = 0;
  6.                 if( useitem->itemnum==56 )//Vital Jam +1
  7.                 {
  8.                     restore = 100;
  9.                 }
  10.                 else
  11.                 if( useitem->itemnum==57 )//Vital Jam +2
  12.                 {
  13.                     restore = 200;
  14.                 }
  15.                 else
  16.                 if( useitem->itemnum==58 )//Vital Jam +5
  17.                 {
  18.                     restore = 500;
  19.                 }
  20.                 else
  21.                 if( useitem->itemnum==59 )//Vital Jam +10
  22.                 {
  23.                     restore = 1000;
  24.                 }
  25.                 else
  26.                 if( useitem->itemnum==60 )//Vital Jam +20
  27.                 {
  28.                     restore = 2000;
  29.                 }
  30.                 if((thisclient->CharInfo->stamina) + restore >= 5000)//In case the maximum stamina gets exceeded
  31.                 {
  32.                     thisclient->CharInfo->stamina = 5000;
  33.                 }
  34.                 else
  35.                 {
  36.                     thisclient->CharInfo->stamina += restore;//And restore!
  37.                 }
  38.             }
  39.             useitem->usescript = 1;
  40.             useitem->usetype = UseList.Index[useitem->itemnum]->useeffect[0];
  41.             useitem->usevalue = UseList.Index[useitem->itemnum]->useeffect[1];
  42.         }


Simple solution, guess there is a better one but it works anyway.
Blah4
ospRose dev team
ospRose dev team
 
Posts: 199
Joined: Sun Jan 06, 2008 12:05 pm
Location: The Netherlands

Re: Vital Jam fix

Postby pepu on Mon Jun 02, 2008 1:32 pm

Upload this fix to the svn if u can please.
pepu
ospRose dev team
ospRose dev team
 
Posts: 283
Joined: Mon Feb 04, 2008 10:12 pm
Location: ESPAÑA(Aranjuez)

Re: Vital Jam fix

Postby PurpleYouko on Mon Jun 02, 2008 2:47 pm

This fix is actually in the wrong place in the code.
Putting it here would make an instant change to the value rather than treating it in the way that it should be done.

here is the way it works

this code
  1.  
  2. case 311://Medicine
  3.         case 312://Food
  4.         {
  5.             useitem->usescript = 1;
  6.             useitem->usetype = UseList.Index[useitem->itemnum]->useeffect[0];
  7.             useitem->usevalue = UseList.Index[useitem->itemnum]->useeffect[1];
  8.         }

Returns the values that you need to change Stamina and even SP (if you used a mana jam)
For a vital jam UseList.Index[useitem->itemnum]->useeffect[0] is 76
for a mana jam UseList.Index[useitem->itemnum]->useeffect[0] is 37

These values are taken back to PakUseItem in WorldPackets.cpp where values are assigned to the "thisclient->useditems" structure.
this bit of code
  1.  
  2. case 1: // Food
  3.         {
  4.             thisclient->UsedItem->usevalue = thisuse->usevalue;
  5.             thisclient->UsedItem->usetype = thisuse->usetype;
  6.             thisclient->UsedItem->userate = 15;
  7.             thisclient->UsedItem->used = 0;
  8.             BEGINPACKET( pak,0x7a3 );
  9.             ADDWORD    ( pak, thisclient->clientid );
  10.             ADDWORD    ( pak, thisuse->itemnum );
  11.             SendToVisible( &pak, thisclient );
  12.             flag = true;
  13.         }

(which incidentally is wrong since it uses brackets inside the switch structure. Un-necessary but won't break the code)
puts the values for usevalue and usetype into the structure.
Still no actual changes though. that is done elsewhere.

The bit where we actually change the values of our HP or MP is in bool CPlayer::PlayerHeal() in Playerfunctions.cpp so that is where the fix should be applied.

here is the code for the function as it stands.
  1. // Heal Player when use Food/Pots
  2. bool CPlayer::PlayerHeal()
  3. {
  4.     clock_t transtime = clock() - UsedItem->lastRegTime;
  5.     if( UsedItem->usevalue!=0 && transtime >= 0.3*CLOCKS_PER_SEC )  
  6.     {          
  7.         if( UsedItem->used < UsedItem->usevalue && Stats->HP > 0 )
  8.         {
  9.             int value = UsedItem->userate;                
  10.             if((UsedItem->usevalue - UsedItem->used) < value)
  11.             {
  12.                 value = UsedItem->usevalue - UsedItem->used;
  13.             }
  14.             switch( UsedItem->usetype )
  15.             {
  16.                 case 16: // HP
  17.                     Stats->HP += value;
  18.                     if(Stats->HP > GetMaxHP())
  19.                         Stats->HP = GetMaxHP();                            
  20.                 break;
  21.                 case 17: // MP
  22.                     Stats->MP += value;                    
  23.                     if(Stats->MP > GetMaxMP())
  24.                         Stats->MP = GetMaxMP();                        
  25.                 break;
  26.             }
  27.             UsedItem->used += value;
  28.             UsedItem->lastRegTime = clock();            
  29.         }
  30.         else
  31.         {
  32.             BEGINPACKET( pak,0x7b7 );
  33.             ADDWORD    ( pak, clientid );
  34.             ADDDWORD   ( pak, GServer->BuildBuffs( this ) );
  35.             switch( UsedItem->usetype )
  36.             {
  37.                 case 16: // HP
  38.                     ADDWORD( pak, Stats->HP );                        
  39.                 break;
  40.                 case 17: // MP
  41.                     ADDWORD( pak, Stats->MP );                    
  42.                 break;
  43.             }
  44.             GServer->SendToVisible( &pak, this );
  45.             UsedItem->used = 0;
  46.             UsedItem->usevalue = 0;
  47.             UsedItem->userate = 0;
  48.             UsedItem->usetype = 0;
  49.         }
  50.     }
  51.     return true;
  52. }

All we need to do is add two new cases to each switch. One for 76 and one for 37
it should look like this (not totally certain about the paks that i added though :? )
  1.  
  2. // Heal Player when use Food/Pots
  3. bool CPlayer::PlayerHeal()
  4. {
  5.     clock_t transtime = clock() - UsedItem->lastRegTime;
  6.     if( UsedItem->usevalue!=0 && transtime >= 0.3*CLOCKS_PER_SEC )  
  7.     {          
  8.         if( UsedItem->used < UsedItem->usevalue && Stats->HP > 0 )
  9.         {
  10.             int value = UsedItem->userate;                
  11.             if((UsedItem->usevalue - UsedItem->used) < value)
  12.             {
  13.                 value = UsedItem->usevalue - UsedItem->used;
  14.             }
  15.             switch( UsedItem->usetype )
  16.             {
  17.                 case 16: // HP
  18.                     Stats->HP += value;
  19.                     if(Stats->HP > GetMaxHP())
  20.                         Stats->HP = GetMaxHP();                            
  21.                 break;
  22.                 case 17: // MP
  23.                     Stats->MP += value;                    
  24.                     if(Stats->MP > GetMaxMP())
  25.                         Stats->MP = GetMaxMP();                        
  26.                 break;
  27.                 case 37: // Skill points
  28.                     CharInfo->SkillPoints += value;
  29.                 break;
  30.                 case 76: //Stamina
  31.                     CharInfo->stamina += value;
  32.                     if(CharInfo->stamina > 5000)
  33.                         CharInfo->stamina = 5000;
  34.                 break;
  35.             }
  36.             UsedItem->used += value;
  37.             UsedItem->lastRegTime = clock();            
  38.         }
  39.         else
  40.         {
  41.             BEGINPACKET( pak,0x7b7 );
  42.             ADDWORD    ( pak, clientid );
  43.             ADDDWORD   ( pak, GServer->BuildBuffs( this ) );
  44.             switch( UsedItem->usetype )
  45.             {
  46.                 case 16: // HP
  47.                     ADDWORD( pak, Stats->HP );                        
  48.                 break;
  49.                 case 17: // MP
  50.                     ADDWORD( pak, Stats->MP );                    
  51.                 break;
  52.                 case 37: //Skill Points
  53.                     ADDWORD( pak, CharInfo->SkillPoints );
  54.                 break;
  55.                 case 76: //Stamina
  56.                     ADDWORD( pak, CharInfo->stamina );
  57.                 break;
  58.             }
  59.             GServer->SendToVisible( &pak, this );
  60.             UsedItem->used = 0;
  61.             UsedItem->usevalue = 0;
  62.             UsedItem->userate = 0;
  63.             UsedItem->usetype = 0;
  64.         }
  65.     }
  66.     return true;
  67. }
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: 4595
Joined: Fri Aug 10, 2007 2:05 pm

Re: Vital Jam fix

Postby Blah4 on Mon Jun 02, 2008 7:09 pm

I don't get your point, Vital Jam is instant restore...

But I guess your one is better though.
Blah4
ospRose dev team
ospRose dev team
 
Posts: 199
Joined: Sun Jan 06, 2008 12:05 pm
Location: The Netherlands

Re: Vital Jam fix

Postby Drakia on Mon Jun 02, 2008 7:20 pm

It is an instant restore, but it has a cooldown time (As do all food items) so you need to implement it like the others so that cooldown is applied.
My favorite skill is scaring new users away.
If you haven't SEARCHED expect me to yell at you.
Image
Drakia
ospRose dev team
ospRose dev team
 
Posts: 1614
Joined: Tue Sep 18, 2007 6:53 am
Location: Nanaimo, BC, Canada

Re: Vital Jam fix

Postby PurpleYouko on Mon Jun 02, 2008 7:41 pm

I just tested my code and it does indeed give extra SP when you use a mana jam :D
Strangely though, When i summoned a pet choropie from a capsule my Stamina went down to 4000 then when i used a vital jam +1 (100 stamina) it jumped all the way back up to 5000

Something isn't being handled properly in the server I think.
Maybe we are not actually charging stamina points for summoning at server side then when we add stamina back on we are already at max so the packet sent includes a value of 5000.
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: 4595
Joined: Fri Aug 10, 2007 2:05 pm

Re: Vital Jam fix

Postby Blackdpd on Tue Jun 03, 2008 12:42 am

this was already bugged on irose..
the same as using the blood charms etc the stamina does not go down and when you relog its 4000
( normally when you kill a mob you get stamina )
but you dont get anything when you kill a mob plus that when you use a vital jam doesn not matter wich one it wil go to 5000 and then it does not go down anymore untill you relog.

Blackdpd `
User avatar
Blackdpd
El Verloon Marshall
El Verloon Marshall
 
Posts: 900
Joined: Sun Jan 27, 2008 10:06 pm
Location: The Netherlands

Re: Vital Jam fix

Postby Drakia on Tue Jun 03, 2008 1:52 am

Right now the only thing in the code that takes Stamina is summoning a mob using an item. You might want to check the STB for the vital jam, see what it's values are for restoring, it might not have the right value in the STB.
My favorite skill is scaring new users away.
If you haven't SEARCHED expect me to yell at you.
Image
Drakia
ospRose dev team
ospRose dev team
 
Posts: 1614
Joined: Tue Sep 18, 2007 6:53 am
Location: Nanaimo, BC, Canada

Re: Vital Jam fix

Postby PurpleYouko on Tue Jun 03, 2008 1:57 pm

The STB is where I got the data from.
A Vital Jam +1 is restoring type 76 (stamina) by a value of 100.

I will add some stamina stuff on the server side today to see if i can get this working properly. Shouldn't bee too hard.
I will also add stamina into the /mystat structure in the GM commands for easy checking.
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: 4595
Joined: Fri Aug 10, 2007 2:05 pm

Re: Vital Jam fix

Postby Blah4 on Tue Jun 03, 2008 7:09 pm

Shouldn't dance scroll be a party-stamina restore item?
Blah4
ospRose dev team
ospRose dev team
 
Posts: 199
Joined: Sun Jan 06, 2008 12:05 pm
Location: The Netherlands

Next

Return to Submit Code

Who is online

Users browsing this forum: No registered users and 1 guest