mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-11 03:31:08 +00:00
Changes to how valid light sources are critiqued
This commit is contained in:
+37
-23
@@ -352,9 +352,6 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, const glm::vec4& position, int if
|
||||
InitializeBuffSlots();
|
||||
CalcBonuses();
|
||||
raid_target = d->raid_target;
|
||||
|
||||
active_light = d->light;
|
||||
spell_light = equip_light = NOT_USED;
|
||||
}
|
||||
|
||||
NPC::~NPC()
|
||||
@@ -439,15 +436,15 @@ void NPC::RemoveItem(uint32 item_id, uint16 quantity, uint16 slot) {
|
||||
ServerLootItem_Struct* item = *cur;
|
||||
if (item->item_id == item_id && slot <= 0 && quantity <= 0) {
|
||||
itemlist.erase(cur);
|
||||
UpdateEquipLightValue();
|
||||
if (UpdateActiveLightValue()) { SendAppearancePacket(AT_Light, GetActiveLightValue()); }
|
||||
UpdateEquipmentLight();
|
||||
if (UpdateActiveLight()) { SendAppearancePacket(AT_Light, GetActiveLightType()); }
|
||||
return;
|
||||
}
|
||||
else if (item->item_id == item_id && item->equip_slot == slot && quantity >= 1) {
|
||||
if (item->charges <= quantity) {
|
||||
itemlist.erase(cur);
|
||||
UpdateEquipLightValue();
|
||||
if (UpdateActiveLightValue()) { SendAppearancePacket(AT_Light, GetActiveLightValue()); }
|
||||
UpdateEquipmentLight();
|
||||
if (UpdateActiveLight()) { SendAppearancePacket(AT_Light, GetActiveLightType()); }
|
||||
}
|
||||
else {
|
||||
item->charges -= quantity;
|
||||
@@ -483,9 +480,9 @@ void NPC::CheckMinMaxLevel(Mob *them)
|
||||
++cur;
|
||||
}
|
||||
|
||||
UpdateEquipLightValue();
|
||||
if (UpdateActiveLightValue())
|
||||
SendAppearancePacket(AT_Light, GetActiveLightValue());
|
||||
UpdateEquipmentLight();
|
||||
if (UpdateActiveLight())
|
||||
SendAppearancePacket(AT_Light, GetActiveLightType());
|
||||
}
|
||||
|
||||
void NPC::ClearItemList() {
|
||||
@@ -498,9 +495,9 @@ void NPC::ClearItemList() {
|
||||
}
|
||||
itemlist.clear();
|
||||
|
||||
UpdateEquipLightValue();
|
||||
if (UpdateActiveLightValue())
|
||||
SendAppearancePacket(AT_Light, GetActiveLightValue());
|
||||
UpdateEquipmentLight();
|
||||
if (UpdateActiveLight())
|
||||
SendAppearancePacket(AT_Light, GetActiveLightType());
|
||||
}
|
||||
|
||||
void NPC::QueryLoot(Client* to)
|
||||
@@ -718,24 +715,41 @@ uint32 NPC::CountLoot() {
|
||||
return(itemlist.size());
|
||||
}
|
||||
|
||||
void NPC::UpdateEquipLightValue()
|
||||
void NPC::UpdateEquipmentLight()
|
||||
{
|
||||
equip_light = NOT_USED;
|
||||
m_Light.Type.Equipment = 0;
|
||||
m_Light.Level.Equipment = 0;
|
||||
|
||||
for (int index = MAIN_BEGIN; index < EmuConstants::EQUIPMENT_SIZE; ++index) {
|
||||
if (equipment[index] == NOT_USED) { continue; }
|
||||
if (index == MainAmmo) { continue; }
|
||||
|
||||
auto item = database.GetItem(equipment[index]);
|
||||
if (item == nullptr) { continue; }
|
||||
if (item->Light & 0xF0) { continue; }
|
||||
if (item->Light > equip_light) { equip_light = item->Light; }
|
||||
|
||||
if (m_Light.IsLevelGreater(item->Light, m_Light.Type.Equipment)) {
|
||||
m_Light.Type.Equipment = item->Light;
|
||||
m_Light.Level.Equipment = m_Light.TypeToLevel(m_Light.Type.Equipment);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto iter = itemlist.begin(); iter != itemlist.end(); ++iter) {
|
||||
auto item = database.GetItem((*iter)->item_id);
|
||||
if (item == nullptr) { continue; }
|
||||
if (item->ItemType != ItemTypeMisc && item->ItemType != ItemTypeLight) { continue; }
|
||||
if (item->Light & 0xF0) { continue; }
|
||||
if (item->Light > equip_light) { equip_light = item->Light; }
|
||||
|
||||
switch (item->Light) {
|
||||
case lightTypeCandle:
|
||||
case lightTypeTorch:
|
||||
case lightTypeSmallLantern:
|
||||
case lightTypeLargeLantern:
|
||||
continue;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_Light.IsLevelGreater(item->Light, m_Light.Type.Equipment)) {
|
||||
m_Light.Type.Equipment = item->Light;
|
||||
m_Light.Level.Equipment = m_Light.TypeToLevel(m_Light.Type.Equipment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1810,8 +1824,8 @@ void NPC::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho)
|
||||
Mob::FillSpawnStruct(ns, ForWho);
|
||||
PetOnSpawn(ns);
|
||||
ns->spawn.is_npc = 1;
|
||||
UpdateActiveLightValue();
|
||||
ns->spawn.light = GetActiveLightValue();
|
||||
UpdateActiveLight();
|
||||
ns->spawn.light = GetActiveLightType();
|
||||
}
|
||||
|
||||
void NPC::PetOnSpawn(NewSpawn_Struct* ns)
|
||||
|
||||
Reference in New Issue
Block a user