From 43329dc583c4144bf492706ff2c2083e5caff298 Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Mon, 13 Feb 2023 00:09:34 -0500 Subject: [PATCH] [Quest API] (Performance) Check event exists before export and execute EVENT_KILLED_MERIT (#2911) - Optionally parse this event instead of always doing so. --- zone/attack.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index b78d7786b..4f839765c 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -2540,8 +2540,11 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy for (int i = 0; i < MAX_RAID_MEMBERS; i++) { if (kr->members[i].member != nullptr && kr->members[i].member->IsClient()) { // If Group Member is Client Client *c = kr->members[i].member; - parse->EventNPC(EVENT_KILLED_MERIT, this, c, "killed", 0); + c->RecordKilledNPCEvent(this); + if (parse->HasQuestSub(GetNPCTypeID(), EVENT_KILLED_MERIT)) { + parse->EventNPC(EVENT_KILLED_MERIT, this, c, "killed", 0); + } if (RuleB(NPC, EnableMeritBasedFaction)) c->SetFactionLevel(c->CharacterID(), GetNPCFactionID(), c->GetBaseClass(), c->GetBaseRace(), c->GetDeity()); @@ -2588,9 +2591,13 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy for (int i = 0; i < MAX_GROUP_MEMBERS; i++) { if (kg->members[i] != nullptr && kg->members[i]->IsClient()) { // If Group Member is Client Client *c = kg->members[i]->CastToClient(); - parse->EventNPC(EVENT_KILLED_MERIT, this, c, "killed", 0); + c->RecordKilledNPCEvent(this); + if (parse->HasQuestSub(GetNPCTypeID(), EVENT_KILLED_MERIT)) { + parse->EventNPC(EVENT_KILLED_MERIT, this, c, "killed", 0); + } + if (RuleB(NPC, EnableMeritBasedFaction)) c->SetFactionLevel(c->CharacterID(), GetNPCFactionID(), c->GetBaseClass(), c->GetBaseRace(), c->GetDeity()); @@ -2636,8 +2643,10 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy } /* Send the EVENT_KILLED_MERIT event */ - parse->EventNPC(EVENT_KILLED_MERIT, this, give_exp_client, "killed", 0); give_exp_client->RecordKilledNPCEvent(this); + if (parse->HasQuestSub(GetNPCTypeID(), EVENT_KILLED_MERIT)) { + parse->EventNPC(EVENT_KILLED_MERIT, this, give_exp_client, "killed", 0); + } if (RuleB(NPC, EnableMeritBasedFaction)) give_exp_client->SetFactionLevel(give_exp_client->CharacterID(), GetNPCFactionID(), give_exp_client->GetBaseClass(),