From 8d57444f5b59108b26dff2bf752bf5965f0674b7 Mon Sep 17 00:00:00 2001 From: Jhobean <51728381+Jhobean@users.noreply.github.com> Date: Mon, 14 Oct 2024 05:16:28 -0400 Subject: [PATCH] Add @petrelease trigger (#1302) --- Changelog.txt | 3 +++ src/game/CObjBase.h | 1 + src/game/chars/CChar.cpp | 1 + src/game/chars/CCharNPCPet.cpp | 10 ++++++++++ src/tables/triggers.tbl | 1 + 5 files changed, 16 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index eb900a6b8..034689fd8 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -3911,3 +3911,6 @@ Added: 'H' shortcut for variables to get the value as hexadecimal. CURFOLLOWER.DELUID: The same as .DEL/DELETE, just removed the pet via its UID. CURFOLLOWER.DELINDEX: Removes the pet via its id in the (cur)follower list for that owner. - Added: spells with SPELLFLAG_SUMMON now accept LOCAL.FollowerSlotsOverride in the triggers @Success and @SpellSuccess. Default value (do not override): -1. + +13-10-2024, Jhobean +- Added: @PetRelease trigger work like @petdesert and return 1 to prevent the pet from being released. diff --git a/src/game/CObjBase.h b/src/game/CObjBase.h index 7a94ef5e1..e34a42979 100644 --- a/src/game/CObjBase.h +++ b/src/game/CObjBase.h @@ -1170,6 +1170,7 @@ enum CTRIG_TYPE : short CTRIG_PayGold, // I'm going to give out money for a service (Skill Training, hiring...). CTRIG_PersonalSpace, // i just got stepped on by other char. CTRIG_PetDesert, // I'm deserting from my owner ( starving, being hit by him ...). + CTRIG_PetRelease, // I have been released by my owner. CTRIG_Profile, // someone hit the profile button for me. CTRIG_ReceiveItem, // I was just handed an item (Not yet checked if i want it). CTRIG_RegenStat, // Hits/mana/stam/food regeneration. diff --git a/src/game/chars/CChar.cpp b/src/game/chars/CChar.cpp index a4ac213d8..c1b95127a 100644 --- a/src/game/chars/CChar.cpp +++ b/src/game/chars/CChar.cpp @@ -169,6 +169,7 @@ lpctstr const CChar::sm_szTrigName[CTRIG_QTY+1] = // static "@PayGold", // I'm going to give out money for a service (Skill Training, hiring...). "@PersonalSpace", // +i just got stepped on by other char. "@PetDesert", // I just went wild again + "@PetRelease", // I just been released by my master "@Profile", // someone hit the profile button for me. "@ReceiveItem", // I was just handed an item (Not yet checked if i want it) "@RegenStat", // Regenerating any stat diff --git a/src/game/chars/CCharNPCPet.cpp b/src/game/chars/CCharNPCPet.cpp index a9ce07c0a..91e65ff6a 100644 --- a/src/game/chars/CCharNPCPet.cpp +++ b/src/game/chars/CCharNPCPet.cpp @@ -857,6 +857,16 @@ void CChar::NPC_PetRelease() if (!m_pNPC) return; + CChar* pCharOwn = NPC_PetGetOwner(); + if (!pCharOwn) + return; + + if (IsTrigUsed(TRIGGER_PETRELEASE)) + { + if (OnTrigger(CTRIG_PetRelease, pCharOwn, nullptr) == TRIGRET_RET_TRUE) + return; + } + if (IsStatFlag(STATF_CONJURED) || (m_pNPC->m_bonded && IsStatFlag(STATF_DEAD))) { Effect(EFFECT_XYZ, ITEMID_FX_TELE_VANISH, this, 10, 15); diff --git a/src/tables/triggers.tbl b/src/tables/triggers.tbl index b81dc78ff..a200f613a 100644 --- a/src/tables/triggers.tbl +++ b/src/tables/triggers.tbl @@ -156,6 +156,7 @@ ADD(PARTYREMOVE) ADD(PAYGOLD) ADD(PERSONALSPACE) ADD(PETDESERT) +ADD(PETRELEASE) ADD(PICKUP_GROUND) ADD(PICKUP_PACK) ADD(PICKUP_SELF)