Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ini switch for removing emote when eating. Now send object pointer to Eat trigger #1207

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3442,13 +3442,13 @@ 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.





12-02-2024, Drk84
- Updated SphereCrypt.ini.

13-03-2024, Jhobean
- Added: Item properties functionnality:HITAREAPHYSICAL,HITAREAFIRE,HITAREACOLD,HITAREAPOISON,HITAREAENERGY,HITFIREBALL,HITHARM,HITLIGHTNING,HITMAGICARROW,REFLECTPHYSICALDAM

16-03-2024, Jhobean
- Added: Flag EMOTEF_EAT is added on the ini to avoid see the emote when eating.
- Added: NPC_EAT_GRASS MSG to be able change the hardcode name of "grass" when an animal eat grass
- Added: Item been eaten can now be read on the ARGO parameter of the trigger @eat.
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
16 changes: 11 additions & 5 deletions src/game/chars/CCharAct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2230,18 +2230,22 @@ 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");
ASSERT(pItem);
static const SOUND_TYPE sm_EatSounds[] = { 0x03a, 0x03b, 0x03c };
Sound(sm_EatSounds[Calc_GetRandVal(ARRAY_COUNT(sm_EatSounds))]);

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());
Jhobean marked this conversation as resolved.
Show resolved Hide resolved
Emote(pszMsg);
}

ushort uiHits = 0;
ushort uiMana = 0;
Expand All @@ -2256,9 +2260,11 @@ void CChar::EatAnim( lpctstr pszName, ushort uiQty )
Args.m_VarsLocal.SetNumNew("Stam", uiStam);
Args.m_VarsLocal.SetNumNew("Food", uiFood);
Args.m_iN1 = uiStatsLimit;
if ( OnTrigger(CTRIG_Eat, this, &Args) == TRIGRET_RET_TRUE )
Args.m_pO1 = pItem;
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
12 changes: 8 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,9 @@ bool CChar::NPC_Act_Food()
if ( pResBit && pResBit->GetAmount() && ( pResBit->GetTopPoint().m_z == iMyZ ) )
{
ushort uiEaten = pResBit->ConsumeAmount(10);
EatAnim("grass", uiEaten/10);
CSString sMsg = g_Cfg.GetDefaultMsg(DEFMSG_NPC_EAT_GRASS);
pResBit->SetName(sMsg); //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 +2476,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 +2533,9 @@ void CChar::NPC_Food()
{
EXC_SET_BLOCK("eating grass");
const ushort uiEaten = pResBit->ConsumeAmount(15);
EatAnim("grass", uiEaten/10);
CSString sMsg = g_Cfg.GetDefaultMsg(DEFMSG_NPC_EAT_GRASS);
pResBit->SetName(sMsg); //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
5 changes: 3 additions & 2 deletions src/tables/defmessages.tbl
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,8 @@ MSG(MUSICANSHIP_POOR, "You play poorly.")
MSG(NPC_VENDOR_GUARDS, "Ahh, Guards my goods are gone !!")
MSG(NPC_VENDOR_SELL_TY, "Here you are, %d gold coin%s. I thank thee for thy business.")
MSG(NON_ALIVE, "That does not appear to be a living being.")
MSG(NPC_BANKER_DEPOSIT, "I shall deposit %d gold in your account")
MSG(NPC_BANKER_DEPOSIT, "I shall deposit %d gold in your account")
MSG(NPC_EAT_GRASS, "grass")
MSG(NPC_GENERIC_CRIM, "Help! Guards a Criminal!")
MSG(NPC_GENERIC_DONTWANT, "They don't appear to want the item")
MSG(NPC_GENERIC_GONE_1, "Well it was nice speaking to you %s but I must go about my business")
Expand Down Expand Up @@ -1168,4 +1169,4 @@ MSG(HOUSE_ADD_LIMIT, "House redeeded. You already own the max
MSG(DEED_NAME, "Deed to a %s")
MSG(LOCATION_INVALID, "That location is not valid.")

#undef MSG
#undef MSG
Loading