Skip to content

Commit

Permalink
Change Eating trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhobean committed Jan 14, 2024
1 parent a5d5714 commit a72a56f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 16 deletions.
3 changes: 3 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
7 changes: 4 additions & 3 deletions src/game/CServerConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/game/chars/CChar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
*
Expand Down
12 changes: 8 additions & 4 deletions src/game/chars/CCharAct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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;
Expand All @@ -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);
Expand Down
10 changes: 6 additions & 4 deletions src/game/chars/CCharNPCAct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/game/chars/CCharUse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
7 changes: 4 additions & 3 deletions src/sphere.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a72a56f

Please sign in to comment.