mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-11 15:22:26 +00:00
Refactor Mob::CastedSpellFinished
We now only call GetInv().GetItem() once
This commit is contained in:
parent
2f564d9651
commit
53a289a6bc
@ -967,6 +967,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo
|
|||||||
uint16 mana_used, uint32 inventory_slot, int16 resist_adjust)
|
uint16 mana_used, uint32 inventory_slot, int16 resist_adjust)
|
||||||
{
|
{
|
||||||
bool IsFromItem = false;
|
bool IsFromItem = false;
|
||||||
|
EQEmu::ItemInstance *item = nullptr;
|
||||||
|
|
||||||
if(IsClient() && slot != CastingSlot::Item && slot != CastingSlot::PotionBelt && spells[spell_id].recast_time > 1000) { // 10 is item
|
if(IsClient() && slot != CastingSlot::Item && slot != CastingSlot::PotionBelt && spells[spell_id].recast_time > 1000) { // 10 is item
|
||||||
if(!CastToClient()->GetPTimers().Expired(&database, pTimerSpellStart + spell_id, false)) {
|
if(!CastToClient()->GetPTimers().Expired(&database, pTimerSpellStart + spell_id, false)) {
|
||||||
@ -981,10 +982,10 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo
|
|||||||
if(IsClient() && (slot == CastingSlot::Item || slot == CastingSlot::PotionBelt))
|
if(IsClient() && (slot == CastingSlot::Item || slot == CastingSlot::PotionBelt))
|
||||||
{
|
{
|
||||||
IsFromItem = true;
|
IsFromItem = true;
|
||||||
EQEmu::ItemInstance *itm = CastToClient()->GetInv().GetItem(inventory_slot);
|
item = CastToClient()->GetInv().GetItem(inventory_slot);
|
||||||
if(itm && itm->GetItem()->RecastDelay > 0)
|
if(item && item->GetItem()->RecastDelay > 0)
|
||||||
{
|
{
|
||||||
if(!CastToClient()->GetPTimers().Expired(&database, (pTimerItemStart + itm->GetItem()->RecastType), false)) {
|
if(!CastToClient()->GetPTimers().Expired(&database, (pTimerItemStart + item->GetItem()->RecastType), false)) {
|
||||||
MessageString(Chat::Red, SPELL_RECAST);
|
MessageString(Chat::Red, SPELL_RECAST);
|
||||||
LogSpells("Casting of [{}] canceled: item spell reuse timer not expired", spell_id);
|
LogSpells("Casting of [{}] canceled: item spell reuse timer not expired", spell_id);
|
||||||
StopCasting();
|
StopCasting();
|
||||||
@ -1298,17 +1299,16 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo
|
|||||||
&& inventory_slot != 0xFFFFFFFF) // 10 is an item
|
&& inventory_slot != 0xFFFFFFFF) // 10 is an item
|
||||||
{
|
{
|
||||||
bool fromaug = false;
|
bool fromaug = false;
|
||||||
const EQEmu::ItemInstance* inst = CastToClient()->GetInv()[inventory_slot];
|
|
||||||
EQEmu::ItemData* augitem = nullptr;
|
EQEmu::ItemData* augitem = nullptr;
|
||||||
uint32 recastdelay = 0;
|
uint32 recastdelay = 0;
|
||||||
uint32 recasttype = 0;
|
uint32 recasttype = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (inst == nullptr)
|
if (item == nullptr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
for (int r = EQEmu::invaug::SOCKET_BEGIN; r <= EQEmu::invaug::SOCKET_END; r++) {
|
for (int r = EQEmu::invaug::SOCKET_BEGIN; r <= EQEmu::invaug::SOCKET_END; r++) {
|
||||||
const EQEmu::ItemInstance* aug_i = inst->GetAugment(r);
|
const EQEmu::ItemInstance* aug_i = item->GetAugment(r);
|
||||||
|
|
||||||
if (!aug_i)
|
if (!aug_i)
|
||||||
continue;
|
continue;
|
||||||
@ -1346,18 +1346,18 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inst && inst->IsClassCommon() && (inst->GetItem()->Click.Effect == spell_id) && inst->GetCharges() || fromaug)
|
if (item && item->IsClassCommon() && (item->GetItem()->Click.Effect == spell_id) && item->GetCharges() || fromaug)
|
||||||
{
|
{
|
||||||
//const ItemData* item = inst->GetItem();
|
//const ItemData* item = item->GetItem();
|
||||||
int16 charges = inst->GetItem()->MaxCharges;
|
int16 charges = item->GetItem()->MaxCharges;
|
||||||
|
|
||||||
if(fromaug) { charges = -1; } //Don't destroy the parent item
|
if(fromaug) { charges = -1; } //Don't destroy the parent item
|
||||||
|
|
||||||
if(charges > -1) { // charged item, expend a charge
|
if(charges > -1) { // charged item, expend a charge
|
||||||
LogSpells("Spell [{}]: Consuming a charge from item [{}] ([{}]) which had [{}]/[{}] charges", spell_id, inst->GetItem()->Name, inst->GetItem()->ID, inst->GetCharges(), inst->GetItem()->MaxCharges);
|
LogSpells("Spell [{}]: Consuming a charge from item [{}] ([{}]) which had [{}]/[{}] charges", spell_id, item->GetItem()->Name, item->GetItem()->ID, item->GetCharges(), item->GetItem()->MaxCharges);
|
||||||
DeleteChargeFromSlot = inventory_slot;
|
DeleteChargeFromSlot = inventory_slot;
|
||||||
} else {
|
} else {
|
||||||
LogSpells("Spell [{}]: Cast from unlimited charge item [{}] ([{}]) ([{}] charges)", spell_id, inst->GetItem()->Name, inst->GetItem()->ID, inst->GetItem()->MaxCharges);
|
LogSpells("Spell [{}]: Cast from unlimited charge item [{}] ([{}]) ([{}] charges)", spell_id, item->GetItem()->Name, item->GetItem()->ID, item->GetItem()->MaxCharges);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user