[Quest API] (Performance) Check event EVENT_ITEM_TICK or EVENT_WEAPON_PROC exist before export and execute (#2914)

* [Quest API] Optionally parse EVENT_ITEM_TICK

# Notes
- Optionally parse this event instead of always doing so.

* Update mob.cpp
This commit is contained in:
Alex King 2023-02-12 23:22:22 -05:00 committed by GitHub
parent 241f900dc4
commit 086538754e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 6 deletions

View File

@ -8102,9 +8102,12 @@ void Client::TryItemTick(int slot)
if (GetLevel() >= zone->tick_items[iid].level && zone->random.Int(0, 100) >= (100 - zone->tick_items[iid].chance) && (zone->tick_items[iid].bagslot || slot <= EQ::invslot::EQUIPMENT_END))
{
EQ::ItemInstance* e_inst = (EQ::ItemInstance*)inst;
if (parse->ItemHasQuestSub(e_inst, EVENT_ITEM_TICK)) {
parse->EventItem(EVENT_ITEM_TICK, this, e_inst, nullptr, "", slot);
}
}
}
//Only look at augs in main inventory
if (slot > EQ::invslot::EQUIPMENT_END) { return; }
@ -8121,11 +8124,14 @@ void Client::TryItemTick(int slot)
if( GetLevel() >= zone->tick_items[iid].level && zone->random.Int(0, 100) >= (100 - zone->tick_items[iid].chance) )
{
EQ::ItemInstance* e_inst = (EQ::ItemInstance*) a_inst;
if (parse->ItemHasQuestSub(e_inst, EVENT_ITEM_TICK)) {
parse->EventItem(EVENT_ITEM_TICK, this, e_inst, nullptr, "", slot);
}
}
}
}
}
void Client::ItemTimerCheck()
{

View File

@ -4139,11 +4139,21 @@ void Mob::ExecWeaponProc(const EQ::ItemInstance *inst, uint16 spell_id, Mob *on,
//const cast is dirty but it would require redoing a ton of interfaces at this point
//It should be safe as we don't have any truly const EQ::ItemInstance floating around anywhere.
//So we'll live with it for now
int i = parse->EventItem(EVENT_WEAPON_PROC, CastToClient(), const_cast<EQ::ItemInstance*>(inst), on, "", spell_id);
if (parse->ItemHasQuestSub(const_cast<EQ::ItemInstance*>(inst), EVENT_WEAPON_PROC)) {
int i = parse->EventItem(
EVENT_WEAPON_PROC,
CastToClient(),
const_cast<EQ::ItemInstance*>(inst),
on,
"",
spell_id
);
if (i != 0) {
return;
}
}
}
bool twinproc = false;
int32 twinproc_chance = 0;