Fix /setspeedmod: apply per-character, persist across stat recalculation
Previously stomped the shared GServer->MOVE_SPEED_MOD movement-timing divisor, which character.cpp's UpdatePosition also uses for monster position interpolation -- GM testing broke movement/attack range server-wide until restart. Now stores a per-character SpeedModPercent that GetMoveSpeed() applies on every recompute, so it survives future SetStats() calls instead of being silently overwritten back to base speed. Also fixes Mspd_base (the value actually broadcast to clients) never being set while WALKING.
This commit is contained in:
1 parent
15e562cb04
commit
16dccc94f2
4 files changed
+28
-2
No files matched your search
@@ -40,6 +40,7 @@ CCharacter::CCharacter( )
|
|||||||
Stats->Accury = 0;
|
Stats->Accury = 0;
|
||||||
Stats->Magic_Defense = 0;
|
Stats->Magic_Defense = 0;
|
||||||
Stats->Move_Speed = 0;
|
Stats->Move_Speed = 0;
|
||||||
|
Stats->SpeedModPercent = 100;
|
||||||
Stats->Attack_Speed = 0;
|
Stats->Attack_Speed = 0;
|
||||||
Stats->Attack_Distance = 0;
|
Stats->Attack_Distance = 0;
|
||||||
Stats->MaxWeight = 0;
|
Stats->MaxWeight = 0;
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ struct STATS
|
|||||||
unsigned int Magic_Defense;
|
unsigned int Magic_Defense;
|
||||||
unsigned int Move_Speed;
|
unsigned int Move_Speed;
|
||||||
unsigned int Mspd_base;
|
unsigned int Mspd_base;
|
||||||
|
unsigned int SpeedModPercent; // GM /setspeedmod override, 100 = unmodified; applied in GetMoveSpeed()
|
||||||
unsigned int Attack_Speed;
|
unsigned int Attack_Speed;
|
||||||
float Attack_Distance;
|
float Attack_Distance;
|
||||||
unsigned int MaxWeight;
|
unsigned int MaxWeight;
|
||||||
|
|||||||
@@ -3814,10 +3814,27 @@ bool CWorldServer::pakGMChangeMonsterDmg(CPlayer* thisclient, int rate)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//change the mSpeedModif || For test only
|
//change this GM's own move speed by a percentage (100 = unmodified) || For test only
|
||||||
bool CWorldServer::pakGMChangeMSpeedModif(CPlayer* thisclient, int modif)
|
bool CWorldServer::pakGMChangeMSpeedModif(CPlayer* thisclient, int modif)
|
||||||
{
|
{
|
||||||
GServer->MOVE_SPEED_MOD = modif;
|
// NOTE: this used to stomp GServer->MOVE_SPEED_MOD, a server-wide
|
||||||
|
// constant that character.cpp's UpdatePosition also uses for monster
|
||||||
|
// position interpolation -- overwriting it here broke movement/attack
|
||||||
|
// range for everyone until the next restart reloaded it from
|
||||||
|
// list_config.movespeedmod. Use a per-character percent instead, which
|
||||||
|
// GetMoveSpeed() applies on every recompute so it survives future stat
|
||||||
|
// refreshes (equip changes, buffs, etc.) instead of being a one-shot
|
||||||
|
// value that the next SetStats() call overwrites back to base.
|
||||||
|
if(modif == 0) modif = 100;
|
||||||
|
thisclient->Stats->SpeedModPercent = modif;
|
||||||
|
thisclient->SetStats( );
|
||||||
|
|
||||||
|
BEGINPACKET( pakspd, 0x782 );
|
||||||
|
ADDWORD( pakspd, thisclient->clientid );
|
||||||
|
ADDBYTE( pakspd, thisclient->Status->Stance );
|
||||||
|
ADDWORD( pakspd, thisclient->Stats->Mspd_base );
|
||||||
|
SendToVisible( &pakspd, thisclient );
|
||||||
|
|
||||||
BEGINPACKET (pak, 0x702);
|
BEGINPACKET (pak, 0x702);
|
||||||
ADDSTRING(pak, "mSpeedModif Changed.");
|
ADDSTRING(pak, "mSpeedModif Changed.");
|
||||||
ADDBYTE(pak, 0);
|
ADDBYTE(pak, 0);
|
||||||
|
|||||||
@@ -1050,6 +1050,13 @@ unsigned int CPlayer::GetMoveSpeed( )
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(Stats->SpeedModPercent != 100)
|
||||||
|
mspeed = mspeed * Stats->SpeedModPercent / 100;
|
||||||
|
// Mspd_base (what actually gets broadcast to clients, e.g. worldpackets.cpp's
|
||||||
|
// 0x782) was previously only touched by the RUNNING/DRIVING branches above --
|
||||||
|
// WALKING/default left it stale, so speed changes never showed up client-side
|
||||||
|
// while walking. Mirror the final value unconditionally.
|
||||||
|
Stats->Mspd_base = mspeed;
|
||||||
return mspeed;
|
return mspeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user