From 8db88a40a45817411f76a247aba15570727a4731 Mon Sep 17 00:00:00 2001 From: Julian Date: Sat, 23 Sep 2023 16:25:36 -0300 Subject: [PATCH 1/3] Skills menu update and SkillUpdate function added --- Changelog.txt | 9 +++ src/game/chars/CCharSkill.cpp | 5 +- src/game/clients/CClient.cpp | 3 + src/game/clients/CClient.h | 1 + src/game/clients/CClientTarg.cpp | 36 ++-------- src/game/clients/CClientUse.cpp | 110 ++++++++++++------------------- src/tables/CClient_functions.tbl | 1 + 7 files changed, 64 insertions(+), 101 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 7a0f10487..813bd38a5 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -3348,3 +3348,12 @@ Fixed: Client Linger Timer is 3600 seconds on stoned players. (Issue #1081) 23-09-2023, Jhobean Fixed: When deleting account, f_onchar_delete was not call on char and char's item was not remove causing warning on next server boot. ( Issue #1029) + +23-09-2023, Julian +- Fixed: Missing SkillUpdate function, seems I never commited it. +- Modified: @SkillMenu trigger to be able to open dialogs also, and added a few local variables. + LOCAL.ItemUsed (r) = The ID (not UID) of the item that triggered this action. + LOCAL.Skill (r) = The ID of the Skill used. + LOCAL.SkillMenu (rw) = The skill menu (sm_alchemy) or dialog (d_MyCraftingMenu) that is going to open. +- Modified: @SkillMakeItem trigger to enable/disable notification message when bouncing the crafted item. + LOCAL.Notify (rw) = 1/0. Using 0 will not show any "You put your..." message, 1 will show it. Default = 1. \ No newline at end of file diff --git a/src/game/chars/CCharSkill.cpp b/src/game/chars/CCharSkill.cpp index f30e50da5..f68198df0 100644 --- a/src/game/chars/CCharSkill.cpp +++ b/src/game/chars/CCharSkill.cpp @@ -804,10 +804,13 @@ bool CChar::Skill_MakeItem_Success() CUID uidOldAct = m_Act_UID; m_Act_UID = pItem->GetUID(); TRIGRET_TYPE iRet = TRIGRET_RET_DEFAULT; + bool notify = true; if ( IsTrigUsed(TRIGGER_SKILLMAKEITEM) ) { CScriptTriggerArgs Args(iSkillLevel, quality, uidOldAct.ObjFind()); + Args.m_VarsLocal.SetNum("Notify", 1); iRet = OnTrigger(CTRIG_SkillMakeItem, this, &Args); + notify = Args.m_VarsLocal.GetKeyNum("Notify") ? true : false; } m_Act_UID = uidOldAct; // restore @@ -841,7 +844,7 @@ bool CChar::Skill_MakeItem_Success() ChangeExperience(exp); } - ItemBounce(pItem); + ItemBounce(pItem, notify); return true; } diff --git a/src/game/clients/CClient.cpp b/src/game/clients/CClient.cpp index de0b635ee..608064b8f 100644 --- a/src/game/clients/CClient.cpp +++ b/src/game/clients/CClient.cpp @@ -1442,6 +1442,9 @@ bool CClient::r_Verb( CScript & s, CTextConsole * pSrc ) // Execute command from case CV_SKILLSELECT: Event_Skill_Use( g_Cfg.FindSkillKey( s.GetArgStr() ) ); break; + case CV_SKILLUPDATE: + addSkillWindow(g_Cfg.FindSkillKey(s.GetArgStr())); + break; case CV_SUMMON: { ASSERT(m_pChar); diff --git a/src/game/clients/CClient.h b/src/game/clients/CClient.h index 4752ca69e..336cba4f1 100644 --- a/src/game/clients/CClient.h +++ b/src/game/clients/CClient.h @@ -366,6 +366,7 @@ class CClient : public CSObjListRec, public CScriptObj, public CChatChanMember, int Cmd_Extract( CScript * pScript, const CRectMap &rect, int & zlowest ); int Cmd_Skill_Menu_Build( const CResourceID& rid, int iSelect, CMenuItem* item, int iMaxSize, bool *fShowMenu, bool *fLimitReached ); public: + bool Skill_Menu(SKILL_TYPE skill, lpctstr skillmenu, ITEMID_TYPE itemused = ITEMID_NOTHING); bool Cmd_Skill_Menu( const CResourceID& rid, int iSelect = -1 ); bool Cmd_Skill_Smith( CItem * pIngots ); bool Cmd_Skill_Magery( SPELL_TYPE iSpell, CObjBase * pSrc ); diff --git a/src/game/clients/CClientTarg.cpp b/src/game/clients/CClientTarg.cpp index 74ef9a443..59dd6e8a1 100644 --- a/src/game/clients/CClientTarg.cpp +++ b/src/game/clients/CClientTarg.cpp @@ -1886,13 +1886,7 @@ bool CClient::OnTarg_Use_Item( CObjBase * pObjTarg, CPointMap & pt, ITEMID_TYPE } if ( pItemUse->IsType(IT_CARPENTRY_CHOP) ) { - if ( IsTrigUsed(TRIGGER_SKILLMENU) ) - { - CScriptTriggerArgs args("sm_carpentry"); - if ( m_pChar->OnTrigger(CTRIG_SkillMenu, m_pChar, &args) == TRIGRET_RET_TRUE ) - return true; - } - return Cmd_Skill_Menu( g_Cfg.ResourceGetIDType( RES_SKILLMENU, "sm_carpentry" )); + return Skill_Menu(SKILL_CARPENTRY, "sm_carpentry", pItemUse->GetID()); } if ( pItemUse->IsSameDispID( ITEMID_DAGGER )) { @@ -1902,13 +1896,7 @@ bool CClient::OnTarg_Use_Item( CObjBase * pObjTarg, CPointMap & pt, ITEMID_TYPE else m_Targ_UID.InitUID(); - if ( IsTrigUsed(TRIGGER_SKILLMENU) ) - { - CScriptTriggerArgs args("sm_bowcraft"); - if ( m_pChar->OnTrigger(CTRIG_SkillMenu, m_pChar, &args) == TRIGRET_RET_TRUE ) - return true; - } - return Cmd_Skill_Menu( g_Cfg.ResourceGetIDType( RES_SKILLMENU, "sm_bowcraft" ) ); + return Skill_Menu(SKILL_BOWCRAFT, "sm_bowcraft", pItemUse->GetID()); } SysMessageDefault( DEFMSG_ITEMUSE_LOG_USE ); return false; @@ -2364,25 +2352,9 @@ static lpctstr const sm_Txt_LoomUse[] = { case IT_LEATHER: case IT_HIDE: - { - if ( IsTrigUsed(TRIGGER_SKILLMENU) ) - { - CScriptTriggerArgs args("sm_tailor_leather"); - if ( m_pChar->OnTrigger("@SkillMenu", m_pChar, &args) == TRIGRET_RET_TRUE ) - return true; - } - return Cmd_Skill_Menu( g_Cfg.ResourceGetIDType( RES_SKILLMENU, "sm_tailor_leather" ) ); - } + return Skill_Menu(SKILL_TAILORING, "sm_tailor_leather", pItemTarg->GetID()); case IT_CLOTH: - { - if ( IsTrigUsed(TRIGGER_SKILLMENU) ) - { - CScriptTriggerArgs args("sm_tailor_cloth"); - if ( m_pChar->OnTrigger("@SkillMenu", m_pChar, &args) == TRIGRET_RET_TRUE ) - return true; - } - return Cmd_Skill_Menu( g_Cfg.ResourceGetIDType( RES_SKILLMENU, "sm_tailor_cloth" ) ); - } + return Skill_Menu(SKILL_TAILORING, "sm_tailor_cloth", pItemTarg->GetID()); default: break; } diff --git a/src/game/clients/CClientUse.cpp b/src/game/clients/CClientUse.cpp index 600f071eb..b66c404ae 100644 --- a/src/game/clients/CClientUse.cpp +++ b/src/game/clients/CClientUse.cpp @@ -153,15 +153,7 @@ bool CClient::Cmd_Use_Item( CItem *pItem, bool fTestTouch, bool fScript ) case IT_SHAFT: case IT_FEATHER: - { - if ( IsTrigUsed(TRIGGER_SKILLMENU) ) - { - CScriptTriggerArgs args("sm_bolts"); - if ( m_pChar->OnTrigger("@SkillMenu", m_pChar, &args) == TRIGRET_RET_TRUE ) - return true; - } - return Cmd_Skill_Menu(g_Cfg.ResourceGetIDType(RES_SKILLMENU, "sm_bolts")); - } + return Skill_Menu(SKILL_BOWCRAFT, "sm_bolts", pItem->GetID()); case IT_FISH_POLE: // Just be near water ? addTarget(CLIMODE_TARG_USE_ITEM, g_Cfg.GetDefaultMsg(DEFMSG_FISHING_PROMT), true); @@ -368,15 +360,7 @@ bool CClient::Cmd_Use_Item( CItem *pItem, bool fTestTouch, bool fScript ) } case IT_CARPENTRY: - { - if ( IsTrigUsed(TRIGGER_SKILLMENU) ) - { - CScriptTriggerArgs args("sm_carpentry"); - if ( m_pChar->OnTrigger("@SkillMenu", m_pChar, &args) == TRIGRET_RET_TRUE ) - return true; - } - return Cmd_Skill_Menu(g_Cfg.ResourceGetIDType(RES_SKILLMENU, "sm_carpentry")); - } + return Skill_Menu(SKILL_CARPENTRY, "sm_carpentry", pItem->GetID()); case IT_FORGE: // Solve for the combination of this item with another. @@ -534,48 +518,16 @@ bool CClient::Cmd_Use_Item( CItem *pItem, bool fTestTouch, bool fScript ) return true; case IT_MORTAR: - { - if ( IsTrigUsed(TRIGGER_SKILLMENU) ) - { - CScriptTriggerArgs args("sm_alchemy"); - if ( m_pChar->OnTrigger("@SkillMenu", m_pChar, &args) == TRIGRET_RET_TRUE ) - return true; - } - return Cmd_Skill_Menu(g_Cfg.ResourceGetIDType(RES_SKILLMENU, "sm_alchemy")); - } + return Skill_Menu(SKILL_ALCHEMY, "sm_alchemy", pItem->GetID()); case IT_CARTOGRAPHY: - { - if ( IsTrigUsed(TRIGGER_SKILLMENU) ) - { - CScriptTriggerArgs args("sm_cartography"); - if ( m_pChar->OnTrigger("@SkillMenu", m_pChar, &args) == TRIGRET_RET_TRUE ) - return true; - } - return Cmd_Skill_Menu(g_Cfg.ResourceGetIDType(RES_SKILLMENU, "sm_cartography")); - } + return Skill_Menu(SKILL_CARTOGRAPHY, "sm_cartography", pItem->GetID()); case IT_COOKING: - { - if ( IsTrigUsed(TRIGGER_SKILLMENU) ) - { - CScriptTriggerArgs args("sm_cooking"); - if ( m_pChar->OnTrigger("@SkillMenu", m_pChar, &args) == TRIGRET_RET_TRUE ) - return true; - } - return Cmd_Skill_Menu(g_Cfg.ResourceGetIDType(RES_SKILLMENU, "sm_cooking")); - } + return Skill_Menu(SKILL_COOKING, "sm_cooking", pItem->GetID()); case IT_TINKER_TOOLS: - { - if ( IsTrigUsed(TRIGGER_SKILLMENU) ) - { - CScriptTriggerArgs args("sm_tinker"); - if ( m_pChar->OnTrigger("@SkillMenu", m_pChar, &args) == TRIGRET_RET_TRUE ) - return true; - } - return Cmd_Skill_Menu(g_Cfg.ResourceGetIDType(RES_SKILLMENU, "sm_tinker")); - } + return Skill_Menu(SKILL_TINKERING, "sm_tinker", pItem->GetID()); case IT_SEWING_KIT: { @@ -667,6 +619,40 @@ void CClient::Cmd_EditItem( CObjBase *pObj, int iSelect ) addItemMenu(CLIMODE_MENU_EDIT, item, count, pObj); } + +bool CClient::Skill_Menu(SKILL_TYPE skill, lpctstr skillmenu, ITEMID_TYPE itemused) +{ + // Default menu is d_craft_menu + // Open in page 0, args is skill used. + // LPCTSTR dSkillMenu = "d_CraftingMenu"; + CScriptTriggerArgs Args; + Args.m_VarsLocal.SetStrNew("SkillMenu", skillmenu); + Args.m_VarsLocal.SetNumNew("Skill", skill); + Args.m_VarsLocal.SetNumNew("ItemUsed", itemused); + if (IsTrigUsed(TRIGGER_SKILLMENU)) + { + if (m_pChar->Skill_OnCharTrigger(skill, CTRIG_SkillMenu, &Args) == TRIGRET_RET_TRUE) + return true; + + skillmenu = Args.m_VarsLocal.GetKeyStr("Skillmenu", false); + } + + LPCTSTR SkillUsed = g_Cfg.GetSkillKey(skill); + CResourceID ridDialog = g_Cfg.ResourceGetIDType(RES_DIALOG, skillmenu); + if (ridDialog.IsValidUID()) { + return Dialog_Setup(CLIMODE_DIALOG, g_Cfg.ResourceGetIDType(RES_DIALOG, skillmenu), 0, m_pChar, SkillUsed); + } else { + CResourceID ridMenu = g_Cfg.ResourceGetIDType(RES_SKILLMENU, skillmenu); + if (ridMenu.IsValidUID()) { + return Cmd_Skill_Menu(ridMenu); + } else { + g_Log.EventError("CClient::Skill_Menu - Not valid dialog or skillmenu %s \n", skillmenu); + } + } + + return false; +} + bool CClient::Cmd_Skill_Menu( const CResourceID& rid, int iSelect ) { ADDTOCALLSTACK("CClient::Cmd_Skill_Menu"); @@ -1275,13 +1261,7 @@ bool CClient::Cmd_Skill_Smith( CItem *pIngots ) // Select the blacksmith item type. // repair items or make type of items. - if ( IsTrigUsed(TRIGGER_SKILLMENU) ) - { - CScriptTriggerArgs args("sm_blacksmith"); - if ( m_pChar->OnTrigger("@SkillMenu", m_pChar, &args) == TRIGRET_RET_TRUE ) - return true; - } - return Cmd_Skill_Menu(g_Cfg.ResourceGetIDType(RES_SKILLMENU, "sm_blacksmith")); + return Skill_Menu(SKILL_BLACKSMITHING, "sm_blacksmith", pIngots->GetID()); } bool CClient::Cmd_Skill_Inscription() @@ -1302,13 +1282,7 @@ bool CClient::Cmd_Skill_Inscription() return false; } - if ( IsTrigUsed(TRIGGER_SKILLMENU) ) - { - CScriptTriggerArgs args("sm_inscription"); - if ( m_pChar->OnTrigger("@SkillMenu", m_pChar, &args) == TRIGRET_RET_TRUE ) - return true; - } - return Cmd_Skill_Menu(g_Cfg.ResourceGetIDType(RES_SKILLMENU, "sm_inscription")); + return Skill_Menu(SKILL_INSCRIPTION, "sm_inscription"); } bool CClient::Cmd_SecureTrade( CChar *pChar, CItem *pItem ) diff --git a/src/tables/CClient_functions.tbl b/src/tables/CClient_functions.tbl index 6996427ea..dbf69e695 100644 --- a/src/tables/CClient_functions.tbl +++ b/src/tables/CClient_functions.tbl @@ -47,6 +47,7 @@ ADD(SENDPACKET, "SENDPACKET") ADD(SHOWSKILLS, "SHOWSKILLS") ADD(SKILLMENU, "SKILLMENU") ADD(SKILLSELECT, "SKILLSELECT") +ADD(SKILLUPDATE, "SKILLUPDATE") ADD(SMSG, "SMSG") ADD(SMSGL, "SMSGL") ADD(SMSGLEX, "SMSGLEX") From e9ec0ff1e77497302e8be9e63f9c9eb03a25b499 Mon Sep 17 00:00:00 2001 From: Julian Date: Sat, 23 Sep 2023 16:30:29 -0300 Subject: [PATCH 2/3] Linux compilation error --- src/game/clients/CClientUse.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/clients/CClientUse.cpp b/src/game/clients/CClientUse.cpp index b66c404ae..e49c4dbc3 100644 --- a/src/game/clients/CClientUse.cpp +++ b/src/game/clients/CClientUse.cpp @@ -637,7 +637,7 @@ bool CClient::Skill_Menu(SKILL_TYPE skill, lpctstr skillmenu, ITEMID_TYPE itemus skillmenu = Args.m_VarsLocal.GetKeyStr("Skillmenu", false); } - LPCTSTR SkillUsed = g_Cfg.GetSkillKey(skill); + lpctstr SkillUsed = g_Cfg.GetSkillKey(skill); CResourceID ridDialog = g_Cfg.ResourceGetIDType(RES_DIALOG, skillmenu); if (ridDialog.IsValidUID()) { return Dialog_Setup(CLIMODE_DIALOG, g_Cfg.ResourceGetIDType(RES_DIALOG, skillmenu), 0, m_pChar, SkillUsed); From e50507f81eb58a1bf627010cd07fbc2863ecb45e Mon Sep 17 00:00:00 2001 From: cbnolok Date: Thu, 19 Oct 2023 16:58:25 +0200 Subject: [PATCH 3/3] Update Changelog.txt --- Changelog.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 813bd38a5..1914d9ed7 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -3349,11 +3349,11 @@ Fixed: Client Linger Timer is 3600 seconds on stoned players. (Issue #1081) 23-09-2023, Jhobean Fixed: When deleting account, f_onchar_delete was not call on char and char's item was not remove causing warning on next server boot. ( Issue #1029) -23-09-2023, Julian +19-10-2023, Julian - Fixed: Missing SkillUpdate function, seems I never commited it. - Modified: @SkillMenu trigger to be able to open dialogs also, and added a few local variables. - LOCAL.ItemUsed (r) = The ID (not UID) of the item that triggered this action. - LOCAL.Skill (r) = The ID of the Skill used. - LOCAL.SkillMenu (rw) = The skill menu (sm_alchemy) or dialog (d_MyCraftingMenu) that is going to open. + LOCAL.ItemUsed (r) = The ID (not UID) of the item that triggered this action. + LOCAL.Skill (r) = The ID of the Skill used. + LOCAL.SkillMenu (rw) = The skill menu (sm_alchemy) or dialog (d_MyCraftingMenu) that is going to open. - Modified: @SkillMakeItem trigger to enable/disable notification message when bouncing the crafted item. - LOCAL.Notify (rw) = 1/0. Using 0 will not show any "You put your..." message, 1 will show it. Default = 1. \ No newline at end of file + LOCAL.Notify (rw) = 1/0. Using 0 will not show any "You put your..." message, 1 will show it. Default = 1.