Use PlayerState to generate stun particles

This commit is contained in:
Michael Cook (mackal) 2015-05-08 00:59:38 -04:00
parent 103d808925
commit bf4ff03641
9 changed files with 68 additions and 36 deletions

View File

@ -2858,10 +2858,7 @@ void Bot::SaveTimers() {
bool Bot::Process() bool Bot::Process()
{ {
if(IsStunned() && stunned_timer.Check()) if(IsStunned() && stunned_timer.Check())
{ Mob::UnStun();
this->stunned = false;
this->stunned_timer.Disable();
}
if(!GetBotOwner()) if(!GetBotOwner())
return false; return false;

View File

@ -10347,7 +10347,6 @@ void Client::Handle_OP_PlayerStateRemove(const EQApplicationPacket *app)
PlayerState_Struct *ps = (PlayerState_Struct *)app->pBuffer; PlayerState_Struct *ps = (PlayerState_Struct *)app->pBuffer;
RemovePlayerState(ps->state); RemovePlayerState(ps->state);
// We should probably save it server side, but for now this works
entity_list.QueueClients(this, app, true); entity_list.QueueClients(this, app, true);
} }

View File

@ -197,10 +197,8 @@ bool Client::Process() {
instalog = true; instalog = true;
} }
if (IsStunned() && stunned_timer.Check()) { if (IsStunned() && stunned_timer.Check())
this->stunned = false; Mob::UnStun();
this->stunned_timer.Disable();
}
if(!m_CheatDetectMoved) if(!m_CheatDetectMoved)
{ {

View File

@ -173,6 +173,18 @@ enum class NumHit { // Numhits type
OffensiveSpellProcs = 11 // Offensive buff procs OffensiveSpellProcs = 11 // Offensive buff procs
}; };
enum class PlayerState : uint32 {
None = 0,
Open = 1,
WeaponSheathed = 2,
Aggressive = 4,
ForcedAggressive = 8,
InstrumentEquipped = 16,
Stunned = 32,
PrimaryWeaponEquipped = 64,
SecondaryWeaponEquipped = 128
};
//this is our internal representation of the BUFF struct, can put whatever we want in it //this is our internal representation of the BUFF struct, can put whatever we want in it
struct Buffs_Struct { struct Buffs_Struct {
uint16 spellid; uint16 spellid;

View File

@ -1236,10 +1236,7 @@ void Merc::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) {
bool Merc::Process() bool Merc::Process()
{ {
if(IsStunned() && stunned_timer.Check()) if(IsStunned() && stunned_timer.Check())
{ Mob::UnStun();
this->stunned = false;
this->stunned_timer.Disable();
}
if (GetDepop()) if (GetDepop())
{ {

View File

@ -148,7 +148,7 @@ Mob::Mob(const char* in_name,
size = in_size; size = in_size;
base_size = size; base_size = size;
runspeed = in_runspeed; runspeed = in_runspeed;
PlayerState = 0; m_PlayerState = 0;
// sanity check // sanity check
@ -916,7 +916,7 @@ void Mob::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho)
ns->spawn.class_ = class_; ns->spawn.class_ = class_;
ns->spawn.gender = gender; ns->spawn.gender = gender;
ns->spawn.level = level; ns->spawn.level = level;
ns->spawn.PlayerState = PlayerState; ns->spawn.PlayerState = m_PlayerState;
ns->spawn.deity = deity; ns->spawn.deity = deity;
ns->spawn.animation = 0; ns->spawn.animation = 0;
ns->spawn.findable = findable?1:0; ns->spawn.findable = findable?1:0;
@ -5423,3 +5423,30 @@ bool Mob::CanClassEquipItem(uint32 item_id)
else else
return true; return true;
} }
void Mob::SendAddPlayerState(PlayerState new_state)
{
auto app = new EQApplicationPacket(OP_PlayerStateAdd, sizeof(PlayerState_Struct));
auto ps = (PlayerState_Struct *)app->pBuffer;
ps->spawn_id = GetID();
ps->state = static_cast<uint32>(new_state);
AddPlayerState(ps->state);
entity_list.QueueClients(nullptr, app);
safe_delete(app);
}
void Mob::SendRemovePlayerState(PlayerState old_state)
{
auto app = new EQApplicationPacket(OP_PlayerStateRemove, sizeof(PlayerState_Struct));
auto ps = (PlayerState_Struct *)app->pBuffer;
ps->spawn_id = GetID();
ps->state = static_cast<uint32>(old_state);
RemovePlayerState(ps->state);
entity_list.QueueClients(nullptr, app);
safe_delete(app);
}

View File

@ -1026,10 +1026,12 @@ protected:
uint32 follow_dist; uint32 follow_dist;
bool no_target_hotkey; bool no_target_hotkey;
uint32 PlayerState; uint32 m_PlayerState;
uint32 GetPlayerState() { return PlayerState; } uint32 GetPlayerState() { return m_PlayerState; }
void AddPlayerState(uint32 new_state) { PlayerState |= new_state; } void AddPlayerState(uint32 new_state) { m_PlayerState |= new_state; }
void RemovePlayerState(uint32 old_state) { PlayerState &= ~old_state; } void RemovePlayerState(uint32 old_state) { m_PlayerState &= ~old_state; }
void SendAddPlayerState(PlayerState new_state);
void SendRemovePlayerState(PlayerState old_state);
uint8 gender; uint8 gender;
uint16 race; uint16 race;

View File

@ -569,8 +569,7 @@ bool NPC::Process()
{ {
if (IsStunned() && stunned_timer.Check()) if (IsStunned() && stunned_timer.Check())
{ {
this->stunned = false; Mob::UnStun();
this->stunned_timer.Disable();
this->spun_timer.Disable(); this->spun_timer.Disable();
} }

View File

@ -4708,7 +4708,7 @@ void Mob::Stun(int duration)
{ {
stunned = true; stunned = true;
stunned_timer.Start(duration); stunned_timer.Start(duration);
SendStunAppearance(); SendAddPlayerState(PlayerState::Stunned);
} }
} }
@ -4716,6 +4716,7 @@ void Mob::UnStun() {
if(stunned && stunned_timer.Enabled()) { if(stunned && stunned_timer.Enabled()) {
stunned = false; stunned = false;
stunned_timer.Disable(); stunned_timer.Disable();
SendRemovePlayerState(PlayerState::Stunned);
} }
} }