mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 14:41:28 +00:00
[Quest API] (Performance) Check event EVENT_AGGRO, EVENT_ATTACK, or EVENT_COMBAT exist before export and execute (#2901)
* [Quest API] Optionally parse EVENT_COMBAT # Notes - Optionally parse this event instead of always doing so. * Optional EVENT_ATTACK * Update attack.cpp
This commit is contained in:
parent
bad44f35e2
commit
93f19d3971
@ -2324,9 +2324,12 @@ void NPC::Damage(Mob* other, int64 damage, uint16 spell_id, EQ::skills::SkillTyp
|
||||
//handle EVENT_ATTACK. Resets after we have not been attacked for 12 seconds
|
||||
if (attacked_timer.Check())
|
||||
{
|
||||
if (parse->HasQuestSub(GetNPCTypeID(), EVENT_ATTACK)) {
|
||||
LogCombat("Triggering EVENT_ATTACK due to attack by [{}]", other ? other->GetName() : "nullptr");
|
||||
|
||||
parse->EventNPC(EVENT_ATTACK, this, other, "", 0);
|
||||
}
|
||||
}
|
||||
attacked_timer.Start(CombatEventTimer_expire);
|
||||
|
||||
if (!IsEngaged())
|
||||
@ -3025,8 +3028,12 @@ void Mob::AddToHateList(Mob* other, int64 hate /*= 0*/, int64 damage /*= 0*/, bo
|
||||
}
|
||||
|
||||
if (!wasengaged) {
|
||||
if (IsNPC() && other->IsClient() && other->CastToClient())
|
||||
if (IsNPC() && other->IsClient() && other->CastToClient()) {
|
||||
if (parse->HasQuestSub(GetNPCTypeID(), EVENT_AGGRO)) {
|
||||
parse->EventNPC(EVENT_AGGRO, CastToNPC(), other, "", 0);
|
||||
}
|
||||
}
|
||||
|
||||
AI_Event_Engaged(other, iYellForHelp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5341,9 +5341,12 @@ void Bot::Damage(Mob *from, int64 damage, uint16 spell_id, EQ::skills::SkillType
|
||||
|
||||
//handle EVENT_ATTACK. Resets after we have not been attacked for 12 seconds
|
||||
if (attacked_timer.Check()) {
|
||||
if (parse->BotHasQuestSub(EVENT_ATTACK)) {
|
||||
LogCombat("Triggering EVENT_ATTACK due to attack by [{}]", from->GetName());
|
||||
|
||||
parse->EventBot(EVENT_ATTACK, this, from, "", 0);
|
||||
}
|
||||
}
|
||||
|
||||
attacked_timer.Start(CombatEventTimer_expire);
|
||||
// if spell is lifetap add hp to the caster
|
||||
|
||||
@ -1923,7 +1923,10 @@ void Mob::AI_Event_Engaged(Mob *attacker, bool yell_for_help)
|
||||
//if the target dies before it goes off
|
||||
if (attacker->GetHP() > 0) {
|
||||
if (!CastToNPC()->GetCombatEvent() && GetHP() > 0) {
|
||||
if (parse->HasQuestSub(GetNPCTypeID(), EVENT_COMBAT)) {
|
||||
parse->EventNPC(EVENT_COMBAT, CastToNPC(), attacker, "1", 0);
|
||||
}
|
||||
|
||||
auto emote_id = GetEmoteID();
|
||||
if (emote_id) {
|
||||
CastToNPC()->DoNPCEmote(EQ::constants::EmoteEventTypes::EnterCombat, emoteid);
|
||||
@ -1938,9 +1941,11 @@ void Mob::AI_Event_Engaged(Mob *attacker, bool yell_for_help)
|
||||
}
|
||||
|
||||
if (IsBot()) {
|
||||
if (parse->BotHasQuestSub(EVENT_COMBAT)) {
|
||||
parse->EventBot(EVENT_COMBAT, CastToBot(), attacker, "1", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Note: Hate list may not be actually clear until after this function call completes
|
||||
void Mob::AI_Event_NoLongerEngaged() {
|
||||
@ -1966,7 +1971,11 @@ void Mob::AI_Event_NoLongerEngaged() {
|
||||
if (CastToNPC()->GetCombatEvent() && GetHP() > 0) {
|
||||
if (entity_list.GetNPCByID(GetID())) {
|
||||
auto emote_id = CastToNPC()->GetEmoteID();
|
||||
|
||||
if (parse->HasQuestSub(GetNPCTypeID(), EVENT_COMBAT)) {
|
||||
parse->EventNPC(EVENT_COMBAT, CastToNPC(), nullptr, "0", 0);
|
||||
}
|
||||
|
||||
if (emote_id) {
|
||||
CastToNPC()->DoNPCEmote(EQ::constants::EmoteEventTypes::LeaveCombat, emoteid);
|
||||
}
|
||||
@ -1976,9 +1985,11 @@ void Mob::AI_Event_NoLongerEngaged() {
|
||||
}
|
||||
}
|
||||
} else if (IsBot()) {
|
||||
if (parse->BotHasQuestSub(EVENT_COMBAT)) {
|
||||
parse->EventBot(EVENT_COMBAT, CastToBot(), nullptr, "0", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//this gets called from InterruptSpell() for failure or SpellFinished() for success
|
||||
void NPC::AI_Event_SpellCastFinished(bool iCastSucceeded, uint16 slot) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user