mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-13 02:38:45 +00:00
initial tie in of makebuffpacket to logic (still need to do buff definition work)
This commit is contained in:
@@ -35,6 +35,8 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "zone/mob.h"
|
||||
|
||||
|
||||
namespace SoD
|
||||
{
|
||||
@@ -4285,3 +4287,66 @@ namespace SoD
|
||||
return index; // as long as we guard against bad slots server side, we should be fine
|
||||
}
|
||||
} /*SoD*/
|
||||
|
||||
namespace Buff {
|
||||
|
||||
std::unique_ptr<EQApplicationPacket> SoD::MakeLegacyBuffsPacket(Mob* mob, bool for_target, bool clear_buffs) const
|
||||
{
|
||||
// SoD only supports target refresh, not self refresh packets
|
||||
if (for_target) {
|
||||
uint32 count = 0;
|
||||
uint32 buff_count;
|
||||
|
||||
// for self we want all buffs, for target, we want to skip song window buffs
|
||||
// since NPCs and pets don't have a song window, we still see it for them :P
|
||||
if (for_target) {
|
||||
buff_count = (clear_buffs) ? 0 : mob->GetMaxBuffSlots();
|
||||
}
|
||||
else {
|
||||
buff_count = mob->GetMaxTotalSlots();
|
||||
}
|
||||
|
||||
Buffs_Struct* buffs = mob->GetBuffs();
|
||||
|
||||
for(int i = 0; i < buff_count; ++i) {
|
||||
if (buffs[i].spellid > 1) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_RefreshTargetBuffs,
|
||||
sizeof(BuffIcon_Struct) + sizeof(BuffIconEntry_Struct) * count);
|
||||
|
||||
BuffIcon_Struct *buff = (BuffIcon_Struct*)outapp->pBuffer;
|
||||
buff->entity_id = mob->GetID();
|
||||
buff->count = count;
|
||||
buff->all_buffs = 1;
|
||||
buff->tic_timer = mob->GetRemainingTicTime();
|
||||
// there are more types, the client doesn't seem to really care though. The others are also currently hard to fill in here ...
|
||||
// (see comment in common/eq_packet_structs.h)
|
||||
if (for_target)
|
||||
buff->type = mob->IsClient() ? 5 : 7;
|
||||
else
|
||||
buff->type = 0;
|
||||
|
||||
buff->name_lengths = 0; // hacky shit
|
||||
uint32 index = 0;
|
||||
for(int i = 0; i < buff_count; ++i) {
|
||||
if (buffs[i].spellid > 1) {
|
||||
buff->entries[index].buff_slot = i;
|
||||
buff->entries[index].spell_id = buffs[i].spellid;
|
||||
buff->entries[index].tics_remaining = buffs[i].ticsremaining;
|
||||
buff->entries[index].num_hits = buffs[i].hit_number;
|
||||
strn0cpy(buff->entries[index].caster, buffs[i].caster_name, 64);
|
||||
buff->name_lengths += strlen(buff->entries[index].caster);
|
||||
++index;
|
||||
}
|
||||
}
|
||||
|
||||
return outapp;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace Buff
|
||||
|
||||
Reference in New Issue
Block a user