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
-
- case 311://Medicine
- case 312://Food
- {
- useitem->usescript = 1;
- useitem->usetype = UseList.Index[useitem->itemnum]->useeffect[0];
- useitem->usevalue = UseList.Index[useitem->itemnum]->useeffect[1];
- }
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
-
- case 1: // Food
- {
- thisclient->UsedItem->usevalue = thisuse->usevalue;
- thisclient->UsedItem->usetype = thisuse->usetype;
- thisclient->UsedItem->userate = 15;
- thisclient->UsedItem->used = 0;
- BEGINPACKET( pak,0x7a3 );
- ADDWORD ( pak, thisclient->clientid );
- ADDWORD ( pak, thisuse->itemnum );
- SendToVisible( &pak, thisclient );
- flag = true;
- }
(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.
- // Heal Player when use Food/Pots
- bool CPlayer::PlayerHeal()
- {
- clock_t transtime = clock() - UsedItem->lastRegTime;
- if( UsedItem->usevalue!=0 && transtime >= 0.3*CLOCKS_PER_SEC )
- {
- if( UsedItem->used < UsedItem->usevalue && Stats->HP > 0 )
- {
- int value = UsedItem->userate;
- if((UsedItem->usevalue - UsedItem->used) < value)
- {
- value = UsedItem->usevalue - UsedItem->used;
- }
- switch( UsedItem->usetype )
- {
- case 16: // HP
- Stats->HP += value;
- if(Stats->HP > GetMaxHP())
- Stats->HP = GetMaxHP();
- break;
- case 17: // MP
- Stats->MP += value;
- if(Stats->MP > GetMaxMP())
- Stats->MP = GetMaxMP();
- break;
- }
- UsedItem->used += value;
- UsedItem->lastRegTime = clock();
- }
- else
- {
- BEGINPACKET( pak,0x7b7 );
- ADDWORD ( pak, clientid );
- ADDDWORD ( pak, GServer->BuildBuffs( this ) );
- switch( UsedItem->usetype )
- {
- case 16: // HP
- ADDWORD( pak, Stats->HP );
- break;
- case 17: // MP
- ADDWORD( pak, Stats->MP );
- break;
- }
- GServer->SendToVisible( &pak, this );
- UsedItem->used = 0;
- UsedItem->usevalue = 0;
- UsedItem->userate = 0;
- UsedItem->usetype = 0;
- }
- }
- return true;
- }
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
)
-
- // Heal Player when use Food/Pots
- bool CPlayer::PlayerHeal()
- {
- clock_t transtime = clock() - UsedItem->lastRegTime;
- if( UsedItem->usevalue!=0 && transtime >= 0.3*CLOCKS_PER_SEC )
- {
- if( UsedItem->used < UsedItem->usevalue && Stats->HP > 0 )
- {
- int value = UsedItem->userate;
- if((UsedItem->usevalue - UsedItem->used) < value)
- {
- value = UsedItem->usevalue - UsedItem->used;
- }
- switch( UsedItem->usetype )
- {
- case 16: // HP
- Stats->HP += value;
- if(Stats->HP > GetMaxHP())
- Stats->HP = GetMaxHP();
- break;
- case 17: // MP
- Stats->MP += value;
- if(Stats->MP > GetMaxMP())
- Stats->MP = GetMaxMP();
- break;
- case 37: // Skill points
- CharInfo->SkillPoints += value;
- break;
- case 76: //Stamina
- CharInfo->stamina += value;
- if(CharInfo->stamina > 5000)
- CharInfo->stamina = 5000;
- break;
- }
- UsedItem->used += value;
- UsedItem->lastRegTime = clock();
- }
- else
- {
- BEGINPACKET( pak,0x7b7 );
- ADDWORD ( pak, clientid );
- ADDDWORD ( pak, GServer->BuildBuffs( this ) );
- switch( UsedItem->usetype )
- {
- case 16: // HP
- ADDWORD( pak, Stats->HP );
- break;
- case 17: // MP
- ADDWORD( pak, Stats->MP );
- break;
- case 37: //Skill Points
- ADDWORD( pak, CharInfo->SkillPoints );
- break;
- case 76: //Stamina
- ADDWORD( pak, CharInfo->stamina );
- break;
- }
- GServer->SendToVisible( &pak, this );
- UsedItem->used = 0;
- UsedItem->usevalue = 0;
- UsedItem->userate = 0;
- UsedItem->usetype = 0;
- }
- }
- return true;
- }