From 086538754e49ad0bfb757dfe1225e3b7bd8529a9 Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Sun, 12 Feb 2023 23:22:22 -0500 Subject: [PATCH] [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 --- zone/client.cpp | 12 +++++++++--- zone/mob.cpp | 16 +++++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index efd944d21..393830fce 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -8102,7 +8102,10 @@ 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; - parse->EventItem(EVENT_ITEM_TICK, this, e_inst, nullptr, "", slot); + + if (parse->ItemHasQuestSub(e_inst, EVENT_ITEM_TICK)) { + parse->EventItem(EVENT_ITEM_TICK, this, e_inst, nullptr, "", slot); + } } } @@ -8120,8 +8123,11 @@ 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; - parse->EventItem(EVENT_ITEM_TICK, this, e_inst, nullptr, "", slot); + 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); + } } } } diff --git a/zone/mob.cpp b/zone/mob.cpp index d7e5e5ac0..848242869 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -4139,9 +4139,19 @@ 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(inst), on, "", spell_id); - if(i != 0) { - return; + if (parse->ItemHasQuestSub(const_cast(inst), EVENT_WEAPON_PROC)) { + int i = parse->EventItem( + EVENT_WEAPON_PROC, + CastToClient(), + const_cast(inst), + on, + "", + spell_id + ); + + if (i != 0) { + return; + } } }