From a72a56ffd6a7de7803713276b29c7934e850dc68 Mon Sep 17 00:00:00 2001 From: Jhobean Date: Sat, 13 Jan 2024 21:05:01 -0500 Subject: [PATCH] Change Eating trigger --- Changelog.txt | 3 +++ src/game/CServerConfig.h | 7 ++++--- src/game/chars/CChar.h | 2 +- src/game/chars/CCharAct.cpp | 12 ++++++++---- src/game/chars/CCharNPCAct.cpp | 10 ++++++---- src/game/chars/CCharUse.cpp | 2 +- src/sphere.ini | 7 ++++--- 7 files changed, 27 insertions(+), 16 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 4e85ee106..dd2fbd3be 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -3441,3 +3441,6 @@ Additionally, the problem of zig-zag issue following in the South direction has 13-12-2023, Nolok - Fixed: Rare crash occurring when a NPC is selecting an attackable target, but there's only one target (not attackable) in sight. + +14-01-2024, Jhobean +- Added: Flag EMOTEF_EAT is added on the ini to avoid see the emote when eating. diff --git a/src/game/CServerConfig.h b/src/game/CServerConfig.h index 627ff909f..8204082bf 100644 --- a/src/game/CServerConfig.h +++ b/src/game/CServerConfig.h @@ -179,9 +179,10 @@ enum REVEALFLAGS_TYPE enum EMOTEFLAGS_TYPE { - EMOTEF_ATTACKER = 0x01, // Only show %s is attacking %s! emote to attacked character. - EMOTEF_POISON = 0x02, // Only show poison emote to affected character. - EMOTEF_DESTROY = 0x04 // Only show item destroy emote to the owner of the item. + EMOTEF_ATTACKER = 0x01, // Only show %s is attacking %s! emote to attacked character. + EMOTEF_POISON = 0x02, // Only show poison emote to affected character. + EMOTEF_DESTROY = 0x04, // Only show item destroy emote to the owner of the item. + EMOTEF_EAT = 0x08 // Never show emote when eating food. }; enum TOOLTIPMODE_TYPE diff --git a/src/game/chars/CChar.h b/src/game/chars/CChar.h index 0b8fc7029..89dedc64b 100644 --- a/src/game/chars/CChar.h +++ b/src/game/chars/CChar.h @@ -1134,7 +1134,7 @@ public: void StatFlag_Mod(uint64 uiStatFlag, bool fMod) noexcept; bool Death(); bool Reveal( uint64 iFlags = 0 ); void Jail( CTextConsole * pSrc, bool fSet, int iCell ); - void EatAnim( lpctstr pszName, ushort uiQty ); + void EatAnim( CItem* pItem, ushort uiQty ); /** * @Brief I'm calling guards (Player speech) * diff --git a/src/game/chars/CCharAct.cpp b/src/game/chars/CCharAct.cpp index bb9d6e6f1..87e0f9a99 100644 --- a/src/game/chars/CCharAct.cpp +++ b/src/game/chars/CCharAct.cpp @@ -2229,7 +2229,7 @@ bool CChar::ItemEquip( CItem * pItem, CChar * pCharMsg, bool fFromDClick ) // OnEat() // Generating eating animation // also calling @Eat and setting food's level (along with other possible stats 'local.hits',etc?) -void CChar::EatAnim( lpctstr pszName, ushort uiQty ) +void CChar::EatAnim( CItem* pItem, ushort uiQty ) { ADDTOCALLSTACK("CChar::EatAnim"); static const SOUND_TYPE sm_EatSounds[] = { 0x03a, 0x03b, 0x03c }; @@ -2238,9 +2238,12 @@ void CChar::EatAnim( lpctstr pszName, ushort uiQty ) if ( !IsStatFlag(STATF_ONHORSE) ) UpdateAnimate(ANIM_EAT); - tchar * pszMsg = Str_GetTemp(); - snprintf(pszMsg, Str_TempLength(), g_Cfg.GetDefaultMsg(DEFMSG_MSG_EATSOME), pszName); - Emote(pszMsg); + if (!(g_Cfg.m_iEmoteFlags & EMOTEF_EAT)) + { + tchar * pszMsg = Str_GetTemp(); + snprintf(pszMsg, Str_TempLength(), g_Cfg.GetDefaultMsg(DEFMSG_MSG_EATSOME), pItem->GetName()); + Emote(pszMsg); + } ushort uiHits = 0; ushort uiMana = 0; @@ -2258,6 +2261,7 @@ void CChar::EatAnim( lpctstr pszName, ushort uiQty ) if ( OnTrigger(CTRIG_Eat, this, &Args) == TRIGRET_RET_TRUE ) return; + uiHits = (ushort)(Args.m_VarsLocal.GetKeyNum("Hits")) + Stat_GetVal(STAT_STR); uiMana = (ushort)(Args.m_VarsLocal.GetKeyNum("Mana")) + Stat_GetVal(STAT_INT); uiStam = (ushort)(Args.m_VarsLocal.GetKeyNum("Stam")) + Stat_GetVal(STAT_DEX); diff --git a/src/game/chars/CCharNPCAct.cpp b/src/game/chars/CCharNPCAct.cpp index 7a5fb8c91..a36ff14b9 100644 --- a/src/game/chars/CCharNPCAct.cpp +++ b/src/game/chars/CCharNPCAct.cpp @@ -1782,7 +1782,7 @@ bool CChar::NPC_Act_Food() { // can take and eat just in place ushort uiEaten = (ushort)(pClosestFood->ConsumeAmount(uiEatAmount)); - EatAnim(pClosestFood->GetName(), uiEaten); + EatAnim(pClosestFood, uiEaten); if ( !pClosestFood->GetAmount() ) { pClosestFood->Plant_CropReset(); // set growth if this is a plant @@ -1847,7 +1847,8 @@ bool CChar::NPC_Act_Food() if ( pResBit && pResBit->GetAmount() && ( pResBit->GetTopPoint().m_z == iMyZ ) ) { ushort uiEaten = pResBit->ConsumeAmount(10); - EatAnim("grass", uiEaten/10); + pResBit->SetName("grass"); //Change name of Worldgem to grass for the eating emote + EatAnim(pResBit, uiEaten / 10); // the bit is not needed in a worldsave, timeout of 10 minutes pResBit->m_TagDefs.SetNum("NOSAVE", 1); @@ -2474,7 +2475,7 @@ void CChar::NPC_Food() // can take and eat just in place EXC_SET_BLOCK("eating nearby"); ushort uiEaten = pClosestFood->ConsumeAmount(uiEatAmount); - EatAnim(pClosestFood->GetName(), uiEaten); + EatAnim(pClosestFood, uiEaten); if ( !pClosestFood->GetAmount() ) { pClosestFood->Plant_CropReset(); // set growth if this is a plant @@ -2531,7 +2532,8 @@ void CChar::NPC_Food() { EXC_SET_BLOCK("eating grass"); const ushort uiEaten = pResBit->ConsumeAmount(15); - EatAnim("grass", uiEaten/10); + pResBit->SetName("grass"); //Change name of Worldgem to grass for the eating emote + EatAnim(pResBit, uiEaten/10); // the bit is not needed in a worldsave, timeout of 10 minutes pResBit->m_TagDefs.SetNum("NOSAVE", 1); diff --git a/src/game/chars/CCharUse.cpp b/src/game/chars/CCharUse.cpp index a03ad57c1..324e88b0c 100644 --- a/src/game/chars/CCharUse.cpp +++ b/src/game/chars/CCharUse.cpp @@ -903,7 +903,7 @@ void CChar::Use_EatQty( CItem * pFood, ushort uiQty ) } UpdateDir(pFood); - EatAnim(pFood->GetName(), uiRestore * uiQty); + EatAnim(pFood, uiRestore * uiQty); pFood->ConsumeAmount(uiQty); } diff --git a/src/sphere.ini b/src/sphere.ini index 051d7bcb2..56e89bba6 100644 --- a/src/sphere.ini +++ b/src/sphere.ini @@ -497,9 +497,10 @@ RacialFlags=0 RevealFlags=01|02|04|08|010|040|080|0200 // Emote flags -// EMOTEF_ATTACKER 01 // Only show %s is attacking %s! emote to attacked character. -// EMOTEF_POISON 02 // Only show poison emotes to the affected character. -// EMOTEF_DESTROY 04 // Only show item destroyed emote to the owner of the item. +// EMOTEF_ATTACKER 01 // Only show %s is attacking %s! emote to attacked character. +// EMOTEF_POISON 02 // Only show poison emotes to the affected character. +// EMOTEF_DESTROY 04 // Only show item destroyed emote to the owner of the item. +// EMOTEF_EAT 08 // Never show emote when eating food. EmoteFlags=0 // Length of time (in seconds) for a char to remember his attacker (used for attacker keyword)