From 4633e8278cc3153d9e3b9ae8062938c501a7bb82 Mon Sep 17 00:00:00 2001 From: Tungdv Date: Tue, 18 Nov 2025 16:40:04 +0700 Subject: [PATCH 1/5] fix: update logic send cmd accept task. --- .../PerfectWorld/Scripts/NPC/CECNPCServer.cs | 10 + .../CSNetwork/C2SCommand/C2SCommand.cs | 7 + .../CSNetwork/C2SCommand/C2SCommandFactory.cs | 16 + .../Scripts/Network/CSNetwork/GameSession.cs | 12 + .../Scripts/Network/UnityGameSession.cs | 10 + Assets/PerfectWorld/Scripts/UI/AUIManager.cs | 10 + .../PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs | 610 +++++++++--------- Assets/Scripts/CECHostPlayer.cs | 328 +++++++--- 8 files changed, 612 insertions(+), 391 deletions(-) diff --git a/Assets/PerfectWorld/Scripts/NPC/CECNPCServer.cs b/Assets/PerfectWorld/Scripts/NPC/CECNPCServer.cs index 38c650a54b..0b5badac55 100644 --- a/Assets/PerfectWorld/Scripts/NPC/CECNPCServer.cs +++ b/Assets/PerfectWorld/Scripts/NPC/CECNPCServer.cs @@ -10,6 +10,7 @@ public class CECNPCServer : CECNPC { NPC_ESSENCE? m_pDBEssence; MONSTER_ESSENCE? m_pMonEssence; + float m_fTaxRate = 0.05f; // Tax rate public override void SetUpCECNPC(CECNPCMan pNPCMan) { base.SetUpCECNPC(pNPCMan); @@ -71,4 +72,13 @@ public class CECNPCServer : CECNPC // Get essence data in database public NPC_ESSENCE? GetDBEssence() { return m_pDBEssence; } + + // Get tax rate + public float GetTaxRate() { return m_fTaxRate; } + + // Get item price scale factor + public float GetPriceScale() + { + return 1.0f + m_pDBEssence.Value.tax_rate; + } } diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommand.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommand.cs index 78946e471a..8008fa9482 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommand.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommand.cs @@ -1365,6 +1365,13 @@ namespace CSNetwork.S2CCommand public int service_type; public uint len; }; + + public struct CONTENT_ACCEPT_TASK + { + public int idTask; + public int idStorage; + public int idRefreshItem; + }; } // Player and NPC state \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs index 9fc23a5f7c..d30a7ae6d0 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs @@ -513,5 +513,21 @@ namespace CSNetwork.C2SCommand }; return SerializeCommand(CommandID.SEVNPC_SERVE, cmd); } + + public static Octets CreateNPCSevAcceptTaskCmd(int serviceType, int id_Task, int id_Storage, int id_RefreshItem) + { + CONTENT_ACCEPT_TASK pContent = new CONTENT_ACCEPT_TASK + { + idTask = id_Task, + idStorage = id_Storage, + idRefreshItem = id_RefreshItem + }; + var cmd = new cmd_sevnpc_serve + { + service_type = serviceType, + len = (uint)Marshal.SizeOf() + }; + return SerializeCommand(CommandID.SEVNPC_SERVE, cmd); + } } } diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs index 88fe0edc17..fc44808d40 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs @@ -6,6 +6,7 @@ using CSNetwork.C2SCommand; using CSNetwork.GPDataType; using CSNetwork.Protocols; using CSNetwork.Protocols.RPCData; +using CSNetwork.S2CCommand; using System; using System; using System.Collections.Generic; @@ -1114,6 +1115,17 @@ namespace CSNetwork // } } + public void c2s_SendCmdNPCSevAcceptTask(int idTask, int idStorage, int idRefreshItem) + { + gamedatasend gamedatasend = new gamedatasend(); + gamedatasend.Data = C2SCommandFactory.CreateNPCSevAcceptTaskCmd( + NPC_service_type.GP_NPCSEV_TASK_ACCEPT, + idTask, + idStorage, + idRefreshItem); + SendProtocol(gamedatasend); + } + public void GetRoleCustomizeData(int iNumRole, List aRoleIDs) { if (iNumRole <= 0 || aRoleIDs == null || aRoleIDs.Count == 0) return; diff --git a/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs b/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs index 3185b0a712..9a9820af7d 100644 --- a/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs +++ b/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs @@ -273,6 +273,16 @@ namespace BrewMonster.Network { Instance._gameSession.c2s_CmdSendEnterPKPrecinctint(); } + + public static void c2s_CmdNPCSevHeal() + { + + } + + public static void c2s_CmdNPCSevAcceptTask(int idTask, int idStorage, int idRefreshItem) + { + Instance._gameSession.c2s_SendCmdNPCSevAcceptTask(idTask, idStorage, idRefreshItem); + } #region Task public static void c2s_CmdGetAllData(bool byPack, bool byEquip, bool byTask) { diff --git a/Assets/PerfectWorld/Scripts/UI/AUIManager.cs b/Assets/PerfectWorld/Scripts/UI/AUIManager.cs index f50a08f130..7ac4bfd5eb 100644 --- a/Assets/PerfectWorld/Scripts/UI/AUIManager.cs +++ b/Assets/PerfectWorld/Scripts/UI/AUIManager.cs @@ -12,6 +12,7 @@ namespace BrewMonster.UI protected Canvas m_canvas; protected Dictionary m_StringTable = new Dictionary(); protected Dictionary m_auiDialog_stringTable = new Dictionary(); + protected Dictionary m_DlgName = new Dictionary(); public string GetStringFromTable(int idString) { @@ -254,5 +255,14 @@ namespace BrewMonster.UI } return true; } + + public AUIDialog GetDialog(string pszName) + { + if(m_DlgName.TryGetValue(pszName, out AUIDialog dlg)) + { + return dlg; + } + return null; + } } } diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs index 8816e48fca..5972cf4650 100644 --- a/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs +++ b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs @@ -1,3 +1,4 @@ +using BrewMonster.Assets.PerfectWorld.Scripts.UI; using BrewMonster.Common; using BrewMonster.Managers; using BrewMonster.Network; @@ -1330,334 +1331,335 @@ namespace BrewMonster.UI bool PopupCorrespondingServiceDialog(int idFunction, int iService, object pData) { - //AUIDialog pShow1 = null, pShow2 = null; - //NPC_ESSENCE? pCurNPCEssence = GetGameUIMan().m_pCurNPCEssence; + AUIDialog pShow1 = null, pShow2 = null; + NPC_ESSENCE? pCurNPCEssence = GetGameUIMan().m_pCurNPCEssence; - //if (idFunction == (int)SERVICE_TYPE.NPC_SELL || idFunction == (int)SERVICE_TYPE.NPC_BUY) - //{ - // Button pButton; + if (idFunction == (int)SERVICE_TYPE.NPC_SELL || idFunction == (int)SERVICE_TYPE.NPC_BUY) + { + //Button pButton; - // pShow1 = m_pAUIManager.GetDialog("Win_Shop"); - // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + //pShow1 = m_pAUIManager.GetDialog("Win_Shop"); + //pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); - // GetHostPlayer().PrepareNPCService(iService); - // GetGameUIMan().m_pDlgShop.UpdateShop(1); + //GetHostPlayer().PrepareNPCService(iService); + //GetGameUIMan().m_pDlgShop.UpdateShop(1); - // if (pCurNPCEssence && pCurNPCEssence.id_repair_service) - // { - // pShow1.GetDlgItem("Btn_Repair").Show(true); - // pShow1.GetDlgItem("Btn_RepairAll").Show(true); - // } - // else - // { - // pShow1.GetDlgItem("Btn_Repair").Show(false); - // pShow1.GetDlgItem("Btn_RepairAll").Show(false); - // } + //if (pCurNPCEssence && pCurNPCEssence.id_repair_service) + //{ + // pShow1.GetDlgItem("Btn_Repair").Show(true); + // pShow1.GetDlgItem("Btn_RepairAll").Show(true); + //} + //else + //{ + // pShow1.GetDlgItem("Btn_Repair").Show(false); + // pShow1.GetDlgItem("Btn_RepairAll").Show(false); + //} - // pButton = (PAUISTILLIMAGEBUTTON)pShow2.GetDlgItem("Btn_NormalItem"); - // pButton.SetPushed(true); - // pButton = (PAUISTILLIMAGEBUTTON)pShow2.GetDlgItem("Btn_QuestItem"); - // pButton.SetPushed(false); - // GetGameUIMan().m_pDlgInventory.SetShowItem(CDlgInventory::INVENTORY_ITEM_NORMAL); - //} - //else if (idFunction == NPC_INSTALL) - //{ - // pShow1 = m_pAUIManager.GetDialog("Win_Enchase"); - // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); - //} - //else if (idFunction == NPC_UNINSTALL) - //{ - // pShow1 = m_pAUIManager.GetDialog("Win_Disenchase"); - // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); - //} - //else if (idFunction == NPC_HEAL) - //{ - // GetGameSession().c2s_CmdNPCSevHeal(); - // GetGameUIMan().EndNPCService(); - //} - //else if (idFunction == NPC_TRANSMIT) - //{ - // pShow1 = m_pAUIManager.GetDialog("Win_WorldMapTravel"); - // ((CDlgWorldMap*)pShow1).BuildTravelMap(DT_NPC_TRANSMIT_SERVICE, pData); - //} - //else if (idFunction == NPC_SKILL) - //{ - // string strText = m_pLst_Main.GetText(m_pLst_Main.GetCurSel()); - // string strHead = GetStringFromTable(249); - // string strComp = string(strHead + GetStringFromTable(7107)); - // if (0 == a_stricmp(strText, strComp)) - // { - // pShow1 = m_pAUIManager.GetDialog("Win_ELFLearn"); - // ((CDlgELFLearn*)pShow1).SetNPCName(pCurNPCEssence.name); - // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); - // GetHostPlayer().PrepareNPCService(iService); - // pShow1.SetData(DT_NPC_SKILL_SERVICE); - // } - // else - // { - // pShow1 = m_pAUIManager.GetDialog("Win_Teach"); - // GetHostPlayer().PrepareNPCService(iService); - // pShow1.SetData(DT_NPC_SKILL_SERVICE); - // GetGameUIMan().UpdateTeach(0); - // } - //} - //else if (idFunction == NPC_MAKE) - //{ - // NPC_MAKE_SERVICE* pMake = (NPC_MAKE_SERVICE*)pData; - // if (pMake.produce_type == 2) - // pShow1 = m_pAUIManager.GetDialog("Win_Produce1"); - // else - // pShow1 = m_pAUIManager.GetDialog("Win_Produce"); - // GetGameUIMan().m_pDlgProduce = (CDlgProduce*)pShow1; - // GetHostPlayer().PrepareNPCService(iService); - // pShow1.SetDataPtr(pMake, "ptr_NPC_MAKE_SERVICE"); - // if (pMake.produce_type == 1 || - // pMake.produce_type == 3 || - // pMake.produce_type == 4 || - // pMake.produce_type == 5) - // GetGameUIMan().m_pDlgProduce.ClearMaterial(); - // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); - // GetGameUIMan().m_pDlgProduce.UpdateProduce(1, 0); - //} - //else if (idFunction == NPC_DECOMPOSE) - //{ - // pShow1 = m_pAUIManager.GetDialog("Win_Split"); - // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); - // pShow1.SetDataPtr(pData, "ptr_NPC_DECOMPOSE_SERVICE"); + //pButton = (Button)pShow2.GetDlgItem("Btn_NormalItem"); + //pButton.SetPushed(true); + //pButton = (Button)pShow2.GetDlgItem("Btn_QuestItem"); + //pButton.SetPushed(false); + //GetGameUIMan().m_pDlgInventory.SetShowItem(CDlgInventory::INVENTORY_ITEM_NORMAL); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_INSTALL) + { + pShow1 = m_pAUIManager.GetDialog("Win_Enchase"); + pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_UNINSTALL) + { + pShow1 = m_pAUIManager.GetDialog("Win_Disenchase"); + pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_HEAL) + { + UnityGameSession.c2s_CmdNPCSevHeal(); + GetGameUIMan().EndNPCService(); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_TRANSMIT) + { + //pShow1 = m_pAUIManager.GetDialog("Win_WorldMapTravel"); + //((CDlgWorldMap)pShow1).BuildTravelMap(DATA_TYPE.DT_NPC_TRANSMIT_SERVICE, pData); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_SKILL) + { + //string strText = m_pLst_Main.GetText(m_pLst_Main.GetCurSel()); + //string strHead = GetStringFromTable(249); + //string strComp = (strHead + GetStringFromTable(7107)); + //if (0 == a_stricmp(strText, strComp)) + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_ELFLearn"); + // ((CDlgELFLearn*)pShow1).SetNPCName(pCurNPCEssence.name); + // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + // GetHostPlayer().PrepareNPCService(iService); + // pShow1.SetData(DATA_TYPE.DT_NPC_SKILL_SERVICE); + //} + //else + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_Teach"); + // GetHostPlayer().PrepareNPCService(iService); + // pShow1.SetData((uint)DATA_TYPE.DT_NPC_SKILL_SERVICE, ""); + // GetGameUIMan().UpdateTeach(0); + //} + } + else if (idFunction == (int)SERVICE_TYPE.NPC_MAKE) + { + //NPC_MAKE_SERVICE pMake = (NPC_MAKE_SERVICE)pData; + //if (pMake.produce_type == 2) + // pShow1 = m_pAUIManager.GetDialog("Win_Produce1"); + //else + // pShow1 = m_pAUIManager.GetDialog("Win_Produce"); + //GetGameUIMan().m_pDlgProduce = (CDlgProduce*)pShow1; + //GetHostPlayer().PrepareNPCService(iService); + //pShow1.SetDataPtr(pMake, "ptr_NPC_MAKE_SERVICE"); + //if (pMake.produce_type == 1 || + // pMake.produce_type == 3 || + // pMake.produce_type == 4 || + // pMake.produce_type == 5) + // GetGameUIMan().m_pDlgProduce.ClearMaterial(); + //pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + //GetGameUIMan().m_pDlgProduce.UpdateProduce(1, 0); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_DECOMPOSE) + { + //pShow1 = m_pAUIManager.GetDialog("Win_Split"); + //pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + //pShow1.SetDataPtr(pData, "ptr_NPC_DECOMPOSE_SERVICE"); - // PAUIPROGRESS pProgress; - // PAUIIMAGEPICTURE pImage; + //PAUIPROGRESS pProgress; + //PAUIIMAGEPICTURE pImage; - // pImage = (PAUIIMAGEPICTURE)pShow1.GetDlgItem("Item_a"); - // pImage.ClearCover(); - // pImage.SetDataPtr(NULL); + //pImage = (PAUIIMAGEPICTURE)pShow1.GetDlgItem("Item_a"); + //pImage.ClearCover(); + //pImage.SetDataPtr(NULL); - // pImage = (PAUIIMAGEPICTURE)pShow1.GetDlgItem("Item_b"); - // pImage.ClearCover(); - // pImage.SetDataPtr(NULL); + //pImage = (PAUIIMAGEPICTURE)pShow1.GetDlgItem("Item_b"); + //pImage.ClearCover(); + //pImage.SetDataPtr(NULL); - // pProgress = (PAUIPROGRESS)pShow1.GetDlgItem("Prgs_1"); - // pProgress.SetProgress(0); + //pProgress = (PAUIPROGRESS)pShow1.GetDlgItem("Prgs_1"); + //pProgress.SetProgress(0); - // pShow1.GetDlgItem("Btn_Start").Enable(false); - // pShow1.GetDlgItem("Btn_Cancel").Enable(true); - // pShow1.GetDlgItem("Txt_no1").SetText(_AL("")); - // pShow1.GetDlgItem("Txt_no2").SetText(_AL("")); - // pShow1.GetDlgItem("Txt_Gold").SetText(_AL("")); - // pShow1.GetDlgItem("Txt_SkillName").SetText(_AL("")); - // pShow1.GetDlgItem("Txt_SkillLevel").SetText(_AL("")); - //} - //else if (idFunction == NPC_WAR_TOWERBUILD) - //{ - // pShow1 = m_pAUIManager.GetDialog("Win_WarTower"); - //} - //else if (idFunction == NPC_RESETPROP) - //{ - // pShow1 = m_pAUIManager.GetDialog("Win_ResetProp"); - // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); - //} - //else if (idFunction == NPC_PETNAME) - //{ - // pShow1 = m_pAUIManager.GetDialog("Win_PetRename"); - // pShow2 = m_pAUIManager.GetDialog("Win_PetList"); - //} - //else if (idFunction == NPC_PETLEARNSKILL) - //{ - // CECPetCorral* pPetCorral = GetHostPlayer().GetPetCorral(); - // CECPetData* pPet = pPetCorral.GetActivePet(); - // if (!pPet) - // { - // GetGameUIMan().MessageBox("", GetStringFromTable(814), MB_OK, A3DCOLORRGB(255, 255, 255)); - // GetGameUIMan().EndNPCService(); - // } - // else - // { - // pShow1 = m_pAUIManager.GetDialog("Win_Teach"); - // GetHostPlayer().PrepareNPCService(iService); - // pShow1.SetData(DT_NPC_PETLEARNSKILL_SERVICE); - // GetGameUIMan().UpdateTeach(0); - // } - //} - //else if (idFunction == NPC_PETFORGETSKILL) - //{ - // CECPetCorral* pPetCorral = GetHostPlayer().GetPetCorral(); - // CECPetData* pPet = pPetCorral.GetActivePet(); - // if (!pPet) - // { - // GetGameUIMan().MessageBox("", GetStringFromTable(814), MB_OK, A3DCOLORRGB(255, 255, 255)); - // GetGameUIMan().EndNPCService(); - // } - // else - // pShow1 = m_pAUIManager.GetDialog("Win_PetRetrain"); - //} - //else if (idFunction == NPC_EQUIPBIND) - //{ - // pShow1 = m_pAUIManager.GetDialog("Win_EquipBind"); - // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); - // pShow1.SetData((DWORD)pData, "ptr_NPC_EQUIPBIND_SERVICE"); - //} - //else if (idFunction == NPC_EQUIPDESTROY) - //{ - // pShow1 = m_pAUIManager.GetDialog("Win_EquipDestroy"); - // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); - //} - //else if (idFunction == NPC_EQUIPUNDESTROY) - //{ - // pShow1 = m_pAUIManager.GetDialog("Win_EquipUndestroy"); - // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); - //} - //else if (idFunction == NPC_IDENTIFY) - //{ - // PAUIIMAGEPICTURE pImage; + //pShow1.GetDlgItem("Btn_Start").Enable(false); + //pShow1.GetDlgItem("Btn_Cancel").Enable(true); + //pShow1.GetDlgItem("Txt_no1").SetText(_AL("")); + //pShow1.GetDlgItem("Txt_no2").SetText(_AL("")); + //pShow1.GetDlgItem("Txt_Gold").SetText(_AL("")); + //pShow1.GetDlgItem("Txt_SkillName").SetText(_AL("")); + //pShow1.GetDlgItem("Txt_SkillLevel").SetText(_AL("")); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_WAR_TOWERBUILD) + { + pShow1 = m_pAUIManager.GetDialog("Win_WarTower"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_RESETPROP) + { + pShow1 = m_pAUIManager.GetDialog("Win_ResetProp"); + pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_PETNAME) + { + pShow1 = m_pAUIManager.GetDialog("Win_PetRename"); + pShow2 = m_pAUIManager.GetDialog("Win_PetList"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_PETLEARNSKILL) + { + //CECPetCorral* pPetCorral = GetHostPlayer().GetPetCorral(); + //CECPetData* pPet = pPetCorral.GetActivePet(); + //if (!pPet) + //{ + // GetGameUIMan().MessageBox("", GetStringFromTable(814), MB_OK, A3DCOLORRGB(255, 255, 255)); + // GetGameUIMan().EndNPCService(); + //} + //else + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_Teach"); + // GetHostPlayer().PrepareNPCService(iService); + // pShow1.SetData(DT_NPC_PETLEARNSKILL_SERVICE); + // GetGameUIMan().UpdateTeach(0); + //} + } + else if (idFunction == (int)SERVICE_TYPE.NPC_PETFORGETSKILL) + { + //CECPetCorral* pPetCorral = GetHostPlayer().GetPetCorral(); + //CECPetData* pPet = pPetCorral.GetActivePet(); + //if (!pPet) + //{ + // GetGameUIMan().MessageBox("", GetStringFromTable(814), MB_OK, A3DCOLORRGB(255, 255, 255)); + // GetGameUIMan().EndNPCService(); + //} + //else + // pShow1 = m_pAUIManager.GetDialog("Win_PetRetrain"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_EQUIPBIND) + { + //pShow1 = m_pAUIManager.GetDialog("Win_EquipBind"); + //pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + //pShow1.SetData((DWORD)pData, "ptr_NPC_EQUIPBIND_SERVICE"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_EQUIPDESTROY) + { + pShow1 = m_pAUIManager.GetDialog("Win_EquipDestroy"); + pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_EQUIPUNDESTROY) + { + pShow1 = m_pAUIManager.GetDialog("Win_EquipUndestroy"); + pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_IDENTIFY) + { + //PAUIIMAGEPICTURE pImage; - // pShow1 = m_pAUIManager.GetDialog("Win_Identify"); - // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); - // pShow1.SetDataPtr(pData, "ptr_NPC_IDENTIFY_SERVICE"); + //pShow1 = m_pAUIManager.GetDialog("Win_Identify"); + //pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + //pShow1.SetDataPtr(pData, "ptr_NPC_IDENTIFY_SERVICE"); - // pImage = (PAUIIMAGEPICTURE)pShow1.GetDlgItem("Item"); - // pImage.ClearCover(); - // pImage.SetDataPtr(NULL); + //pImage = (PAUIIMAGEPICTURE)pShow1.GetDlgItem("Item"); + //pImage.ClearCover(); + //pImage.SetDataPtr(NULL); - // pShow1.GetDlgItem("Txt").SetText(_AL("")); - // pShow1.GetDlgItem("Txt_Gold").SetText(_AL("")); - // pShow1.GetDlgItem("Btn_Confirm").Enable(false); - // pShow1.GetDlgItem("Btn_Cancel").Enable(true); - //} - //else if (idFunction == NPC_GIVE_TASK) - //{ - // talk_proc::option* opt = (talk_proc::option*)pData; - // int idTask = opt.param; - // if (g_pGame.GetConfigs().IsMiniClient() && CECUIConfig::Instance().GetGameUI().IsTaskDisabledInMiniClient(idTask)) - // { - // GetGameUIMan().MessageBox("", GetStringFromTable(10714), MB_OK, A3DCOLORRGBA(255, 255, 255, 160)); - // } - // else - // { - // GetGameSession().c2s_CmdNPCSevAcceptTask(idTask, 0, 0); - // } - // GetGameUIMan().EndNPCService(); - //} - //else if (idFunction == NPC_COMPLETE_TASK) - //{ - // AWARD_DATA ad; - // talk_proc::option* opt = (talk_proc::option*)pData; - // CECTaskInterface* pTask = GetHostPlayer().GetTaskInterface(); + //pShow1.GetDlgItem("Txt").SetText(_AL("")); + //pShow1.GetDlgItem("Txt_Gold").SetText(_AL("")); + //pShow1.GetDlgItem("Btn_Confirm").Enable(false); + //pShow1.GetDlgItem("Btn_Cancel").Enable(true); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_GIVE_TASK) + { + talk_proc.option opt = new talk_proc.option(); + opt = (talk_proc.option)pData; + int idTask = (int)opt.param; + //if (EC_Game.GetConfigs().IsMiniClient() && CECUIConfig.Instance().GetGameUI().IsTaskDisabledInMiniClient(idTask)) + //{ + // GetGameUIMan().MessageBox("", GetStringFromTable(10714), MB_OK, A3DCOLORRGBA(255, 255, 255, 160)); + //} + //else + { + UnityGameSession.c2s_CmdNPCSevAcceptTask(idTask, 0, 0); + } + GetGameUIMan().EndNPCService(); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_COMPLETE_TASK) + { + AWARD_DATA ad; + talk_proc::option* opt = (talk_proc::option*)pData; + CECTaskInterface* pTask = GetHostPlayer().GetTaskInterface(); - // pTask.GetAwardCandidates(opt.param, &ad); - // if (ad.m_ulCandItems > 1) - // { - // pShow1 = m_pAUIManager.GetDialog("Win_Award"); - // CDlgAward* pAward = dynamic_cast(pShow1); - // if (pAward) pAward.UpdateAwardItem(opt.param, true); - // } - // else - // { - // GetGameSession().c2s_CmdNPCSevReturnTask(opt.param, 0); - // GetGameUIMan().EndNPCService(); - // } - //} - //else if (idFunction == NPC_GIVE_TASK_MATTER) - //{ - // talk_proc::option* opt = (talk_proc::option*)pData; - // GetGameSession().c2s_CmdNPCSevTaskMatter(opt.param); - // GetGameUIMan().EndNPCService(); - //} - //else if (idFunction == NPC_STORAGE) - //{ - // if (GetHostPlayer().TrashBoxHasPsw()) - // { - // pShow1 = m_pAUIManager.GetDialog("Win_InputString"); - // pShow1.GetDlgItem("DEFAULT_Txt_Input").SetText(_AL("")); - // } - // else - // g_pGame.GetGameSession().c2s_CmdNPCSevOpenTrash(""); - //} - //else if (idFunction == NPC_STORAGE_PASSWORD) - //{ - // pShow1 = m_pAUIManager.GetDialog("Win_InputString3"); - //} - //else if (idFunction == NPC_ACCOUNT_STORAGE) - //{ - // if (CECCrossServer::Instance().IsOnSpecialServer()) - // { - // GetGameUIMan().ShowErrorMsg(10130); - // GetGameUIMan().EndNPCService(); - // } - // else g_pGame.GetGameSession().c2s_CmdNPCSevOpenAccountBox(); - //} - //else if (idFunction == NPC_ENGRAVE) - //{ - // pShow1 = m_pAUIManager.GetDialog("Win_Engrave"); - // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); - //} - //else if (idFunction == NPC_RANDPROP) - //{ - // pShow1 = m_pAUIManager.GetDialog("Win_RandProp"); - // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); - // GetHostPlayer().PrepareNPCService(iService); - // pShow1.SetDataPtr(pData, "ptr_NPC_RANDPROP_SERVICE"); - //} - //else if (idFunction == TALK_RETURN) - //{ - // OnCommand_back("back"); - // return true; // To avoid to close NPC dialog. - //} - //else if (idFunction == TALK_EXIT) - //{ - // GetGameUIMan().EndNPCService(); + pTask.GetAwardCandidates(opt.param, &ad); + if (ad.m_ulCandItems > 1) + { + pShow1 = m_pAUIManager.GetDialog("Win_Award"); + CDlgAward* pAward = dynamic_cast(pShow1); + if (pAward) pAward.UpdateAwardItem(opt.param, true); + } + else + { + GetGameSession().c2s_CmdNPCSevReturnTask(opt.param, 0); + GetGameUIMan().EndNPCService(); + } + } + else if (idFunction == (int)SERVICE_TYPE.NPC_GIVE_TASK_MATTER) + { + talk_proc.option opt = (talk_proc.option)pData; + GetGameSession().c2s_CmdNPCSevTaskMatter(opt.param); + GetGameUIMan().EndNPCService(); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_STORAGE) + { + //if (GetHostPlayer().TrashBoxHasPsw()) + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_InputString"); + // pShow1.GetDlgItem("DEFAULT_Txt_Input").SetText(_AL("")); + //} + //else + // g_pGame.GetGameSession().c2s_CmdNPCSevOpenTrash(""); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_STORAGE_PASSWORD) + { + pShow1 = m_pAUIManager.GetDialog("Win_InputString3"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_ACCOUNT_STORAGE) + { + //if (CECCrossServer::Instance().IsOnSpecialServer()) + //{ + // GetGameUIMan().ShowErrorMsg(10130); + // GetGameUIMan().EndNPCService(); + //} + //else g_pGame.GetGameSession().c2s_CmdNPCSevOpenAccountBox(); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_ENGRAVE) + { + pShow1 = m_pAUIManager.GetDialog("Win_Engrave"); + pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_RANDPROP) + { + pShow1 = m_pAUIManager.GetDialog("Win_RandProp"); + pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + GetHostPlayer().PrepareNPCService(iService); + pShow1.SetDataPtr(pData, "ptr_NPC_RANDPROP_SERVICE"); + } + else if (idFunction == (int)SERVICE_TYPE.TALK_RETURN) + { + OnCommand_back("back"); + return true; // To avoid to close NPC dialog. + } + else if (idFunction == (int)SERVICE_TYPE.TALK_EXIT) + { + GetGameUIMan().EndNPCService(); - // int idCurFinishTask = GetGameUIMan().m_idCurFinishTask; - // if (GetData() == CDlgNPC::NPC_DIALOG_TASK_TALK && idCurFinishTask > 0) - // { - // GetHostPlayer().GetTaskInterface().OnUIDialogEnd(idCurFinishTask); - // GetGameUIMan().m_idCurFinishTask = -1; - // } - //} - //else if (idFunction == TALK_GIVEUP_TASK) - //{ - // talk_proc::option* opt = (talk_proc::option*)pData; - // GetHostPlayer().GetTaskInterface().GiveUpTask(opt.param); - // GetGameUIMan().EndNPCService(); - //} - //else - //{ - // GetHostPlayer().GetPack(IVTRTYPE_PACK).UnfreezeAllItems(); - // GetGameUIMan().EndNPCService(); - //} + int idCurFinishTask = GetGameUIMan().m_idCurFinishTask; + if (GetData() == CDlgNPC::NPC_DIALOG_TASK_TALK && idCurFinishTask > 0) + { + GetHostPlayer().GetTaskInterface().OnUIDialogEnd(idCurFinishTask); + GetGameUIMan().m_idCurFinishTask = -1; + } + } + else if (idFunction == (int)SERVICE_TYPE.TALK_GIVEUP_TASK) + { + talk_proc::option* opt = (talk_proc::option*)pData; + GetHostPlayer().GetTaskInterface().GiveUpTask(opt.param); + GetGameUIMan().EndNPCService(); + } + else + { + GetHostPlayer().GetPack(IVTRTYPE_PACK).UnfreezeAllItems(); + GetGameUIMan().EndNPCService(); + } - //if (pShow1) - //{ - // DATA_TYPE DataType; - // elementdataman* pDataMan = g_pGame.GetElementDataMan(); + if (pShow1) + { + DATA_TYPE DataType; + elementdataman* pDataMan = g_pGame.GetElementDataMan(); - // pDataMan.get_data_ptr(iService, ID_SPACE_ESSENCE, DataType); + pDataMan.get_data_ptr(iService, ID_SPACE_ESSENCE, DataType); - // pShow1.Show(true); + pShow1.Show(true); - // if (pShow2) - // { - // POINT ptPos = pShow1.GetPos(); - // if (ptPos.x == 0 && ptPos.y == 0) - // { - // SIZE s1 = pShow1.GetSize(); - // SIZE s2 = pShow2.GetSize(); - // A3DVIEWPORTPARAM* p = m_pA3DEngine.GetActiveViewport().GetParam(); - // int x, y = (p.Height - max(s1.cy, s2.cy)) / 2; + if (pShow2) + { + POINT ptPos = pShow1.GetPos(); + if (ptPos.x == 0 && ptPos.y == 0) + { + SIZE s1 = pShow1.GetSize(); + SIZE s2 = pShow2.GetSize(); + A3DVIEWPORTPARAM* p = m_pA3DEngine.GetActiveViewport().GetParam(); + int x, y = (p.Height - max(s1.cy, s2.cy)) / 2; - // x = (p.Width - s1.cx - s2.cx) / 2; + x = (p.Width - s1.cx - s2.cx) / 2; - // // old : pShow1.SetPos(x, y); - // pShow1.SetPosEx(x, y); + // old : pShow1.SetPos(x, y); + pShow1.SetPosEx(x, y); - // x += s1.cx; + x += s1.cx; - // // old : pShow2.SetPos(x, y); - // pShow2.SetPosEx(x, y); - // } + // old : pShow2.SetPos(x, y); + pShow2.SetPosEx(x, y); + } - // pShow2.Show(true); - // } - //} + pShow2.Show(true); + } + } Show(false); return true; diff --git a/Assets/Scripts/CECHostPlayer.cs b/Assets/Scripts/CECHostPlayer.cs index 12b5eccc79..54b260dedc 100644 --- a/Assets/Scripts/CECHostPlayer.cs +++ b/Assets/Scripts/CECHostPlayer.cs @@ -2,6 +2,7 @@ using BrewMonster.Assets.PerfectWorld.Scripts.Players; using BrewMonster.Managers; using BrewMonster.Network; +using BrewMonster.PerfectWorld.Scripts.Vfx; using BrewMonster.Scripts; using BrewMonster.Scripts.Managers; using BrewMonster.Scripts.Player; @@ -10,18 +11,19 @@ using CSNetwork; using CSNetwork.GPDataType; using CSNetwork.Protocols.RPCData; using ModelRenderer.Scripts.GameData; +using PerfectWorld.Scripts.Managers; using PerfectWorld.Scripts.Player; using System; using System.Collections.Generic; +using System.Reflection; using System.Runtime.InteropServices; using System.Text; -using BrewMonster.PerfectWorld.Scripts.Vfx; +using System.Xml.Linq; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; -using Trace_reason = CECHPWorkTrace.Trace_reason; using Host_work_ID = BrewMonster.Scripts.CECHPWork.Host_work_ID; -using PerfectWorld.Scripts.Managers; +using Trace_reason = CECHPWorkTrace.Trace_reason; public partial class CECHostPlayer : CECPlayer { @@ -568,8 +570,8 @@ public partial class CECHostPlayer : CECPlayer { // Update UI when profession changes, save all shortcut configurations // to remove effects from intermediate skills (invalid pointers) - // C++: CECGameUIMan *pGameUIMan = g_pGame->GetGameRun()->GetUIManager()->GetInGameUIMan(); - // pGameUIMan->UpdateSkillRelatedUI(); + // C++: CECGameUIMan *pGameUIMan = g_pGame.GetGameRun().GetUIManager().GetInGameUIMan(); + // pGameUIMan.UpdateSkillRelatedUI(); hostPlayer.UpdateSkillRelatedUI(); }*/ } @@ -1100,32 +1102,32 @@ public partial class CECHostPlayer : CECPlayer // ASSERT(pCmd); // // // test code... -// // g_pGame->GetRTDebug()->OutputNotifyMessage(RTDCOL_WARNING, _AL("start attack !")); +// // g_pGame.GetRTDebug().OutputNotifyMessage(RTDCOL_WARNING, _AL("start attack !")); // // // Check whether target is the one that we have selected -// if (m_idSelTarget != pCmd->idTarget) -// g_pGame->RuntimeDebugInfo(RTDCOL_WARNING, _AL("Target has changed !")); +// if (m_idSelTarget != pCmd.idTarget) +// g_pGame.RuntimeDebugInfo(RTDCOL_WARNING, _AL("Target has changed !")); // // // If target turn to be un-attackable, cancel action -// if (!AttackableJudge(pCmd->idTarget, true)) +// if (!AttackableJudge(pCmd.idTarget, true)) // { -// g_pGame->GetGameSession()->c2s_CmdCancelAction(); -// g_pGame->RuntimeDebugInfo(RTDCOL_WARNING, _AL("Cannel attacking !")); +// g_pGame.GetGameSession().c2s_CmdCancelAction(); +// g_pGame.RuntimeDebugInfo(RTDCOL_WARNING, _AL("Cannel attacking !")); // return; // } // // // Synchronize ammo amount -// CECIvtrItem* pItem = m_pEquipPack->GetItem(EQUIPIVTR_PROJECTILE); +// CECIvtrItem* pItem = m_pEquipPack.GetItem(EQUIPIVTR_PROJECTILE); // if (pItem) // { -// if (!pCmd->ammo_remain) -// m_pEquipPack->SetItem(EQUIPIVTR_PROJECTILE, NULL); +// if (!pCmd.ammo_remain) +// m_pEquipPack.SetItem(EQUIPIVTR_PROJECTILE, NULL); // else -// pItem->SetAmount(pCmd->ammo_remain); +// pItem.SetAmount(pCmd.ammo_remain); // } // -// CECHPWorkMelee* pWork = (CECHPWorkMelee*)m_pWorkMan->CreateWork(CECHPWork::WORK_HACKOBJECT); -// m_pWorkMan->StartWork_p1(pWork); +// CECHPWorkMelee* pWork = (CECHPWorkMelee*)m_pWorkMan.CreateWork(CECHPWork::WORK_HACKOBJECT); +// m_pWorkMan.StartWork_p1(pWork); // // m_bMelee = true; // AP_ActionEvent(AP_EVENT_STARTMELEE); @@ -1178,7 +1180,7 @@ public partial class CECHostPlayer : CECPlayer } // #ifdef _SHOW_AUTOPOLICY_DEBUG -// a_LogOutput(1, "Stop Attack, Reason = %d", pCmd->iReason); +// a_LogOutput(1, "Stop Attack, Reason = %d", pCmd.iReason); // #endif } @@ -1274,10 +1276,10 @@ public partial class CECHostPlayer : CECPlayer { // Load GFX var gfxCaster = EC_Game.GetGFXCaster(); - // m_pMoveTargetGFX = g_pGame->GetGFXCaster()->LoadGFXEx(res_GFXFile(RES_GFX_MOVETARGET)); + // m_pMoveTargetGFX = g_pGame.GetGFXCaster().LoadGFXEx(res_GFXFile(RES_GFX_MOVETARGET)); m_pSelectedGFX = await gfxCaster.LoadGFXEx(EC_Resource.res_GFXFile((int)GfxResourceType.RES_GFX_SELECTED)); m_pHoverGFX = await gfxCaster.LoadGFXEx(EC_Resource.res_GFXFile((int)GfxResourceType.RES_GFX_CURSORHOVER)); - // m_pFloatDust = g_pGame->GetGFXCaster()->LoadGFXEx(res_GFXFile(RES_GFX_FLOATING_DUST)); + // m_pFloatDust = g_pGame.GetGFXCaster().LoadGFXEx(res_GFXFile(RES_GFX_FLOATING_DUST)); if (true /*CECUIConfig::Instance().GetGameUI().bEnableActionSwitch*/) { @@ -1732,11 +1734,11 @@ public partial class CECHostPlayer : CECPlayer //// If we press a chargeable skill again when it's being charged, //// we cast it out at once - //if (IsSpellingMagic() && m_pCurSkill && m_pCurSkill->IsCharging() && - // m_pCurSkill->GetSkillID() == pSkill->GetSkillID()) + //if (IsSpellingMagic() && m_pCurSkill && m_pCurSkill.IsCharging() && + // m_pCurSkill.GetSkillID() == pSkill.GetSkillID()) //{ - // m_pCurSkill->EndCharging(); - // g_pGame->GetGameSession()->c2s_CmdContinueAction(); + // m_pCurSkill.EndCharging(); + // g_pGame.GetGameSession().c2s_CmdContinueAction(); // return true; //} @@ -1755,12 +1757,12 @@ public partial class CECHostPlayer : CECPlayer // bForceAttack = iForceAtk > 0 ? true : false; //// Check negative effect skill - //if (pSkill->GetType() == CECSkill::TYPE_ATTACK || pSkill->GetType() == CECSkill::TYPE_CURSE) + //if (pSkill.GetType() == CECSkill::TYPE_ATTACK || pSkill.GetType() == CECSkill::TYPE_CURSE) //{ // if (idSelTarget == m_PlayerInfo.cid) // { // // Host cannot spell negative effect magic to himself. - // g_pGame->GetGameRun()->AddFixedChannelMsg(FIXMSG_TARGETWRONG, GP_CHAT_FIGHT); + // g_pGame.GetGameRun().AddFixedChannelMsg(FIXMSG_TARGETWRONG, GP_CHAT_FIGHT); // return false; // } // else if (idSelTarget) @@ -1774,8 +1776,8 @@ public partial class CECHostPlayer : CECPlayer int idCastTarget = idSelTarget; int iTargetType = pSkill.GetTargetType(); - //if (pSkill->GetType() == CECSkill::TYPE_BLESS || - // pSkill->GetType() == CECSkill::TYPE_NEUTRALBLESS) + //if (pSkill.GetType() == CECSkill::TYPE_BLESS || + // pSkill.GetType() == CECSkill::TYPE_NEUTRALBLESS) //{ // if (!iTargetType || !ISPLAYERID(idSelTarget)) // idCastTarget = m_PlayerInfo.cid; @@ -1786,7 +1788,7 @@ public partial class CECHostPlayer : CECPlayer // // If host has set bless skill filter only to himself, bless skill couldn't add to other players // BYTE byBLSMask = glb_BuildBLSMask(); - // if (pSkill->GetRangeType() == CECSkill::RANGE_POINT) + // if (pSkill.GetRangeType() == CECSkill::RANGE_POINT) // { // if (!IsTeamMember(idCastTarget)) // { @@ -1794,31 +1796,31 @@ public partial class CECHostPlayer : CECPlayer // idCastTarget = m_PlayerInfo.cid; // else // { - // CECElsePlayer* pPlayer = (CECElsePlayer*)g_pGame->GetGameRun()->GetWorld()->GetPlayerMan()->GetPlayer(idCastTarget); + // CECElsePlayer* pPlayer = (CECElsePlayer*)g_pGame.GetGameRun().GetWorld().GetPlayerMan().GetPlayer(idCastTarget); // if (!pPlayer) // { // // Ä¿±êÏûʧ // return false; // } - // if (pPlayer->IsInvader() || pPlayer->IsPariah()) + // if (pPlayer.IsInvader() || pPlayer.IsPariah()) // { // if (byBLSMask & GP_BLSMASK_NORED) // idCastTarget = m_PlayerInfo.cid; // } - // if (!IsFactionMember(pPlayer->GetFactionID())) + // if (!IsFactionMember(pPlayer.GetFactionID())) // { // if (byBLSMask & GP_BLSMASK_NOMAFIA) // idCastTarget = m_PlayerInfo.cid; // } - // if (!IsFactionAllianceMember(pPlayer->GetFactionID())) + // if (!IsFactionAllianceMember(pPlayer.GetFactionID())) // { // if (byBLSMask & GP_BLSMASK_NOALLIANCE) // idCastTarget = m_PlayerInfo.cid; // } - // if (GetForce() != pPlayer->GetForce()) + // if (GetForce() != pPlayer.GetForce()) // { // if (byBLSMask & GP_BLSMASK_NOFORCE) // idCastTarget = m_PlayerInfo.cid; @@ -1834,29 +1836,29 @@ public partial class CECHostPlayer : CECPlayer // // If host is in battle, bless skill couldn't add to enemies // if (IsInBattle()) // { - // CECElsePlayer* pPlayer = m_pPlayerMan->GetElsePlayer(idCastTarget); + // CECElsePlayer* pPlayer = m_pPlayerMan.GetElsePlayer(idCastTarget); // if (!InSameBattleCamp(pPlayer)) // idCastTarget = m_PlayerInfo.cid; // } // } //} - //else if (pSkill->GetType() == CECSkill::TYPE_BLESSPET) + //else if (pSkill.GetType() == CECSkill::TYPE_BLESSPET) //{ - // CECPet* pPet = g_pGame->GetGameRun()->GetWorld()->GetNPCMan()->GetPetByID(idSelTarget); - // if (!pPet || pPet->GetMasterID() == GetCharacterID()) + // CECPet* pPet = g_pGame.GetGameRun().GetWorld().GetNPCMan().GetPetByID(idSelTarget); + // if (!pPet || pPet.GetMasterID() == GetCharacterID()) // { // // Spell skill on host's pet - // CECPetData* pPetData = m_pPetCorral->GetActivePet(); + // CECPetData* pPetData = m_pPetCorral.GetActivePet(); // if (!pPetData || - // pPetData->GetClass() != GP_PET_CLASS_COMBAT && - // pPetData->GetClass() != GP_PET_CLASS_SUMMON && - // pPetData->GetClass() != GP_PET_CLASS_EVOLUTION) + // pPetData.GetClass() != GP_PET_CLASS_COMBAT && + // pPetData.GetClass() != GP_PET_CLASS_SUMMON && + // pPetData.GetClass() != GP_PET_CLASS_EVOLUTION) // return false; - // idCastTarget = m_pPetCorral->GetActivePetNPCID(); + // idCastTarget = m_pPetCorral.GetActivePetNPCID(); // } // // Only fighting pet can be blessed. - // if (pPet && !pPet->CanBeAttacked()) + // if (pPet && !pPet.CanBeAttacked()) // return false; //} //else @@ -1866,7 +1868,7 @@ public partial class CECHostPlayer : CECPlayer //} //// iTargetType == 4 means target must be pet. The problem is that pet will - //// disappear from world after it died, so GetWorld()->GetObject() will return + //// disappear from world after it died, so GetWorld().GetObject() will return //// NULL when host spells revive-pet skill on his dead pet. So, the target //// type of revive-pet skill should be 0 //if (iTargetType) @@ -1878,7 +1880,7 @@ public partial class CECHostPlayer : CECPlayer // else if (iTargetType == 2) // iAliveFlag = 2; - // CECObject* pObject = g_pGame->GetGameRun()->GetWorld()->GetObject(idCastTarget, iAliveFlag); + // CECObject* pObject = g_pGame.GetGameRun().GetWorld().GetObject(idCastTarget, iAliveFlag); // if (!pObject) // return false; //} @@ -1887,17 +1889,17 @@ public partial class CECHostPlayer : CECPlayer // (!iTargetType || idCastTarget == m_PlayerInfo.cid)) //{ // // Cast this skill need't checking cast distance - // if (!pSkill->ReadyToCast()) + // if (!pSkill.ReadyToCast()) // return false; // // Prepare to cast skill, if skill isn't INSTANT and FLASHMOVE, // // we must stop moving and stand - // if (!pSkill->IsInstant() && pSkill->GetType() != CECSkill::TYPE_FLASHMOVE) + // if (!pSkill.IsInstant() && pSkill.GetType() != CECSkill::TYPE_FLASHMOVE) // { // if (!NaturallyStopMoving()) // return false; // Couldn't stop naturally, so cancel casting skill // } - // else if (pSkill->GetType() == CECSkill::TYPE_FLASHMOVE) + // else if (pSkill.GetType() == CECSkill::TYPE_FLASHMOVE) // { // if (!CanDo(CANDO_FLASHMOVE)) // return false; @@ -1913,12 +1915,12 @@ public partial class CECHostPlayer : CECPlayer //} //else // Have to trace selected object before cast skill //{ - // if (!pSkill->ReadyToCast()) + // if (!pSkill.ReadyToCast()) // return false; - // if (CECCastSkillWhenMove::Instance().IsSkillSupported(pSkill->GetSkillID(), this) && - // m_pWorkMan->IsMovingToPosition() && - // m_pWorkMan->CanCastSkillImmediately(pSkill->GetSkillID())) + // if (CECCastSkillWhenMove::Instance().IsSkillSupported(pSkill.GetSkillID(), this) && + // m_pWorkMan.IsMovingToPosition() && + // m_pWorkMan.CanCastSkillImmediately(pSkill.GetSkillID())) // { // m_pPrepSkill = pSkill; // return CastSkill(idCastTarget, bForceAttack); @@ -1928,7 +1930,7 @@ public partial class CECHostPlayer : CECPlayer bool bTraceOK = false; bool bUseAutoPF = false; /* CECPlayerWrapper* pWrapper = CECAutoPolicy::GetInstance().GetPlayerWrapper(); - if (CECAutoPolicy::GetInstance().IsAutoPolicyEnabled() && pWrapper->GetAttackError() >= 2) + if (CECAutoPolicy::GetInstance().IsAutoPolicyEnabled() && pWrapper.GetAttackError() >= 2) bUseAutoPF = true;*/ if (idCastTarget == 0) @@ -1979,20 +1981,20 @@ public partial class CECHostPlayer : CECPlayer { /* CECConfigs pConfigs = EC_Game.GetConfigs(); - if (pConfigs->GetGameSettings().bAtk_Player) + if (pConfigs.GetGameSettings().bAtk_Player) { byMask |= GP_PVPMASK_FORCE; - if (pConfigs->GetGameSettings().bAtk_NoMafia) + if (pConfigs.GetGameSettings().bAtk_NoMafia) byMask |= GP_PVPMASK_NOMAFIA; - if (pConfigs->GetGameSettings().bAtk_NoWhite) + if (pConfigs.GetGameSettings().bAtk_NoWhite) byMask |= GP_PVPMASK_NOWHITE; - if (pConfigs->GetGameSettings().bAtk_NoAlliance) + if (pConfigs.GetGameSettings().bAtk_NoAlliance) byMask |= GP_PVPMASK_NOALLIANCE; - if (pConfigs->GetGameSettings().bAtk_NoForce) + if (pConfigs.GetGameSettings().bAtk_NoForce) byMask |= GP_PVPMASK_NOFORCE; }*/ } @@ -2356,12 +2358,12 @@ public partial class CECHostPlayer : CECPlayer { /*bool bForceAttack = false; - CECInputCtrl* pInputCtrl = g_pGame->GetGameRun()->GetInputCtrl(); + CECInputCtrl* pInputCtrl = g_pGame.GetGameRun().GetInputCtrl(); if (pdwParam) - bForceAttack = pInputCtrl->IsCtrlPressed(*pdwParam); + bForceAttack = pInputCtrl.IsCtrlPressed(*pdwParam); else - bForceAttack = pInputCtrl->KeyIsBeingPressed(VK_CONTROL); + bForceAttack = pInputCtrl.KeyIsBeingPressed(VK_CONTROL); return bForceAttack;*/ return true; @@ -2587,7 +2589,7 @@ public partial class CECHostPlayer : CECPlayer void UpdateGFXs(float dwDeltaTime) { // if (m_pLevelUpGFX) -// m_pLevelUpGFX->SetParentTM(GetAbsoluteTM()); +// m_pLevelUpGFX.SetParentTM(GetAbsoluteTM()); if (m_pHoverGFX)// && m_idCurHover != m_idSelTarget) { @@ -2633,20 +2635,20 @@ public partial class CECHostPlayer : CECPlayer // if (m_pFloatDust) // { - // A3DTerrainWater* pWater = g_pGame->GetGameRun()->GetWorld()->GetTerrainWater(); + // A3DTerrainWater* pWater = g_pGame.GetGameRun().GetWorld().GetTerrainWater(); // - // if (pWater->IsUnderWater(m_CameraCoord.GetPos())) + // if (pWater.IsUnderWater(m_CameraCoord.GetPos())) // { - // if (m_pFloatDust->GetState() == ST_STOP) + // if (m_pFloatDust.GetState() == ST_STOP) // { - // m_pFloatDust->Start(true); - // m_pFloatDust->TickAnimation(2000); + // m_pFloatDust.Start(true); + // m_pFloatDust.TickAnimation(2000); // } // - // m_pFloatDust->SetParentTM(GetAbsoluteTM()); + // m_pFloatDust.SetParentTM(GetAbsoluteTM()); // } - // else if (m_pFloatDust->GetState() != ST_STOP) - // m_pFloatDust->Stop(); + // else if (m_pFloatDust.GetState() != ST_STOP) + // m_pFloatDust.Stop(); // } // UpdateMonsterSpiritGfx(dwDeltaTime); } @@ -2654,16 +2656,16 @@ public partial class CECHostPlayer : CECPlayer // Level up public void LevelUp() { - // CECGameSession *pSession = g_pGame->GetGameSession(); + // CECGameSession *pSession = g_pGame.GetGameSession(); // // m_BasicProps.iLevel++; - // g_pGame->GetGameRun()->AddFixedMessage(FIXMSG_LEVELUP, m_BasicProps.iLevel); + // g_pGame.GetGameRun().AddFixedMessage(FIXMSG_LEVELUP, m_BasicProps.iLevel); // // // Get all extend properties - // pSession->c2s_CmdGetExtProps(); + // pSession.c2s_CmdGetExtProps(); // if (m_pLevelUpGFX) -// m_pLevelUpGFX->Start(true); +// m_pLevelUpGFX.Start(true); PlayGfx(EC_Resource.res_GFXFile((int)GfxResourceType.RES_GFX_LEVELUP), null, 1f,1);//PLAYERMODEL_TYPEALL // // Popup notify bubble text @@ -2673,29 +2675,29 @@ public partial class CECHostPlayer : CECPlayer // ACHAR szInfo[40]; // a_sprintf(szInfo, _AL("L%d"), m_BasicProps.iLevel); // - // for (int i=0; i < m_pFriendMan->GetGroupNum(); i++) + // for (int i=0; i < m_pFriendMan.GetGroupNum(); i++) // { - // CECFriendMan::GROUP* pGroup = m_pFriendMan->GetGroupByIndex(i); - // for (int j=0; j < pGroup->aFriends.GetSize(); j++) + // CECFriendMan::GROUP* pGroup = m_pFriendMan.GetGroupByIndex(i); + // for (int j=0; j < pGroup.aFriends.GetSize(); j++) // { - // CECFriendMan::FRIEND* pFriend = pGroup->aFriends[j]; - // if (pFriend->IsGameOnline()) + // CECFriendMan::FRIEND* pFriend = pGroup.aFriends[j]; + // if (pFriend.IsGameOnline()) // { - // pSession->SendPrivateChatData(pFriend->GetName(), - // szInfo, GNET::CHANNEL_USERINFO, pFriend->id); + // pSession.SendPrivateChatData(pFriend.GetName(), + // szInfo, GNET::CHANNEL_USERINFO, pFriend.id); // } // } // } // // if (GetBasicProps().iLevel==30) // { - // CECGameUIMan* pGameUI = g_pGame->GetGameRun()->GetUIManager()->GetInGameUIMan(); - // pGameUI->AddChatMessage(pGameUI->GetStringFromTable(9638), GP_CHAT_SYSTEM); + // CECGameUIMan* pGameUI = g_pGame.GetGameRun().GetUIManager().GetInGameUIMan(); + // pGameUI.AddChatMessage(pGameUI.GetStringFromTable(9638), GP_CHAT_SYSTEM); // } // if (GetBasicProps().iLevel>31) // { - // CECGameUIMan* pGameUI = g_pGame->GetGameRun()->GetUIManager()->GetInGameUIMan(); - // ((CDlgOnlineAward*)pGameUI->GetDialog("Win_AddExp2"))->RestartWhenLevelup(); + // CECGameUIMan* pGameUI = g_pGame.GetGameRun().GetUIManager().GetInGameUIMan(); + // ((CDlgOnlineAward*)pGameUI.GetDialog("Win_AddExp2")).RestartWhenLevelup(); // } } @@ -2820,7 +2822,7 @@ public partial class CECHostPlayer : CECPlayer // first of all see if we need to cancel sitdown work. // if (m_pWorkMan.IsSitting()) // { - // g_pGame->GetGameSession()->c2s_CmdStandUp(); + // g_pGame.GetGameSession().c2s_CmdStandUp(); // return false; // } @@ -2847,6 +2849,158 @@ public partial class CECHostPlayer : CECPlayer return NormalAttackObject(idTarget, bForceAttack, bMoreClose); } + + // Fill NPC packs + void FillNPCPack(int iIndex, ushort[] szName, int[] aItems, float fPriceScale, bool bRecipe) + { + // CECNPCInventory* pPack = m_aNPCPacks[iIndex]; + // pPack.RemoveAllItems(); + // pPack.SetName(szName); + + // ID_SPACE idSpace = bRecipe ? ID_SPACE_RECIPE : ID_SPACE_ESSENCE; + // int iScaleType = bRecipe ? CECIvtrItem::SCALE_MAKE : CECIvtrItem::SCALE_BUY; + + // for (int i=0; i Date: Tue, 18 Nov 2025 19:01:03 +0700 Subject: [PATCH 2/5] fix: update logic select option in dlg npc. --- .../CSNetwork/C2SCommand/C2SCommandFactory.cs | 16 - .../Scripts/Task/CECTaskInterface.cs | 19 +- .../PerfectWorld/Scripts/Task/TaskProcess.cs | 136 +++--- Assets/PerfectWorld/Scripts/Task/TaskTempl.cs | 113 ++++- .../PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs | 407 +++++++++--------- 5 files changed, 391 insertions(+), 300 deletions(-) diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs index dc26eaea7a..1289756374 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs @@ -549,21 +549,5 @@ namespace CSNetwork.C2SCommand }; return SerializeCommand(CommandID.SEVNPC_SERVE, cmd); } - - public static Octets CreateNPCSevAcceptTaskCmd(int serviceType, int id_Task, int id_Storage, int id_RefreshItem) - { - CONTENT_ACCEPT_TASK pContent = new CONTENT_ACCEPT_TASK - { - idTask = id_Task, - idStorage = id_Storage, - idRefreshItem = id_RefreshItem - }; - var cmd = new cmd_sevnpc_serve - { - service_type = serviceType, - len = (uint)Marshal.SizeOf() - }; - return SerializeCommand(CommandID.SEVNPC_SERVE, cmd); - } } } diff --git a/Assets/PerfectWorld/Scripts/Task/CECTaskInterface.cs b/Assets/PerfectWorld/Scripts/Task/CECTaskInterface.cs index f3c3990cd2..98fddf1116 100644 --- a/Assets/PerfectWorld/Scripts/Task/CECTaskInterface.cs +++ b/Assets/PerfectWorld/Scripts/Task/CECTaskInterface.cs @@ -1162,7 +1162,24 @@ namespace BrewMonster.Scripts.Task string strName = m_pHost.GetName(); // assumes string; use ToString() if needed return ret.Replace(SYMBOL_HOSTNAME, $"&{strName}&"); } - } + + public bool GetAwardCandidates(uint ulTaskId, ref AWARD_DATA pAward) + { + ActiveTaskList pLst = GetActiveTaskList() as ActiveTaskList; + ActiveTaskEntry pEntry = pLst.GetEntry(ulTaskId); + if (pEntry == null || pEntry.m_ulTemplAddr == 0) return false; + + uint ulCurTime = GetCurTime(); + pEntry.GetTempl().CalcAwardData( + this, + pAward, + pEntry, + pEntry.m_ulTaskTime, + ulCurTime); + + return true; + } + } } diff --git a/Assets/PerfectWorld/Scripts/Task/TaskProcess.cs b/Assets/PerfectWorld/Scripts/Task/TaskProcess.cs index 3f36271765..c96f463f58 100644 --- a/Assets/PerfectWorld/Scripts/Task/TaskProcess.cs +++ b/Assets/PerfectWorld/Scripts/Task/TaskProcess.cs @@ -143,43 +143,43 @@ namespace PerfectWorld.Scripts.Task } return null; } - // const ATaskTempl* GetCap() const { return reinterpret_cast(m_ulCapTemplAddr); } - // const ATaskTempl* GetCapOrSelf() const - // { - // if (m_ulCapTemplAddr) return GetCap(); - // else return GetTempl(); - // } - // bool HasParent() const { return m_ParentIndex != 0xff; } - // bool HasChildren() const { return m_ChildIndex != 0xff; } - // bool IsValid(unsigned char uIndex, unsigned char uMaxCount) const - // { - // if (m_ParentIndex != 0xff) - // { - // if (m_ParentIndex >= uIndex || m_ParentIndex >= uMaxCount) - // return false; - // } - // - // if (m_PrevSblIndex != 0xff) - // { - // if (m_PrevSblIndex >= uIndex || m_PrevSblIndex >= uMaxCount) - // return false; - // } - // - // if (m_NextSblIndex != 0xff) - // { - // if (m_NextSblIndex <= uIndex || m_NextSblIndex >= uMaxCount) - // return false; - // } - // - // if (m_ChildIndex != 0xff) - // { - // if (m_ChildIndex <= uIndex || m_ChildIndex >= uMaxCount) - // return false; - // } - // - // return true; - // } - }; + // const ATaskTempl* GetCap() const { return reinterpret_cast(m_ulCapTemplAddr); } + // const ATaskTempl* GetCapOrSelf() const + // { + // if (m_ulCapTemplAddr) return GetCap(); + // else return GetTempl(); + // } + // bool HasParent() const { return m_ParentIndex != 0xff; } + // bool HasChildren() const { return m_ChildIndex != 0xff; } + // bool IsValid(unsigned char uIndex, unsigned char uMaxCount) const + // { + // if (m_ParentIndex != 0xff) + // { + // if (m_ParentIndex >= uIndex || m_ParentIndex >= uMaxCount) + // return false; + // } + // + // if (m_PrevSblIndex != 0xff) + // { + // if (m_PrevSblIndex >= uIndex || m_PrevSblIndex >= uMaxCount) + // return false; + // } + // + // if (m_NextSblIndex != 0xff) + // { + // if (m_NextSblIndex <= uIndex || m_NextSblIndex >= uMaxCount) + // return false; + // } + // + // if (m_ChildIndex != 0xff) + // { + // if (m_ChildIndex <= uIndex || m_ChildIndex >= uMaxCount) + // return false; + // } + // + // return true; + // } + }; public class ActiveTaskList { @@ -241,31 +241,39 @@ namespace PerfectWorld.Scripts.Task } } - // void UpdateTaskMask(unsigned long& ulMask) const; - // void UpdateUsedCount(); - // void RealignTask(ActiveTaskEntry* pEntry, unsigned char uReserve); - // void ClearTask(TaskInterface* pTask, ActiveTaskEntry* pEntry, bool bRemoveItem); - // void RecursiveClearTask(TaskInterface* pTask, ActiveTaskEntry* pEntry, bool bRemoveItem, bool bRemoveAcquired, bool bClearTask); - // void ClearChildrenOf(TaskInterface* pTask, ActiveTaskEntry* pParent, bool bRemoveItem = true); - // ActiveTaskEntry* GetEntry(unsigned long ulId) - // { - // for (unsigned char i = 0; i < m_uTaskCount; i++) - // if (m_TaskEntries[i].m_ID == ulId) - // return &m_TaskEntries[i]; - // - // return NULL; - // } - // void RemoveAll() - // { - // unsigned short ver = m_Version; - // memset(this, 0, sizeof(*this)); - // m_Version = ver; - // } - // bool IsValid() const { return m_uTaskCount <= TASK_ACTIVE_LIST_MAX_LEN; } - // bool IsTimeMarkUpdate() const { return (m_uListState & TLIST_STATE_UPDATE_TIME_MARK) != 0; } - // void SetTimeMarkUpdate() { m_uListState |= TLIST_STATE_UPDATE_TIME_MARK; } - // void ClearTimeMarkUpdate() { m_uListState &= ~TLIST_STATE_UPDATE_TIME_MARK; } - // int GetMaxSimultaneousCount() {return m_uMaxSimultaneousCount ? TASK_MAX_SIMULTANEOUS_COUT : TASK_DEFAULT_MAX_SIMULTANEOUS_COUT;} - // void ExpandMaxSimultaneousCount() {m_uMaxSimultaneousCount = 1;} - }; + // void UpdateTaskMask(unsigned long& ulMask) const; + // void UpdateUsedCount(); + // void RealignTask(ActiveTaskEntry* pEntry, unsigned char uReserve); + // void ClearTask(TaskInterface* pTask, ActiveTaskEntry* pEntry, bool bRemoveItem); + // void RecursiveClearTask(TaskInterface* pTask, ActiveTaskEntry* pEntry, bool bRemoveItem, bool bRemoveAcquired, bool bClearTask); + // void ClearChildrenOf(TaskInterface* pTask, ActiveTaskEntry* pParent, bool bRemoveItem = true); + // ActiveTaskEntry* GetEntry(unsigned long ulId) + // { + // for (unsigned char i = 0; i < m_uTaskCount; i++) + // if (m_TaskEntries[i].m_ID == ulId) + // return &m_TaskEntries[i]; + // + // return NULL; + // } + // void RemoveAll() + // { + // unsigned short ver = m_Version; + // memset(this, 0, sizeof(*this)); + // m_Version = ver; + // } + // bool IsValid() const { return m_uTaskCount <= TASK_ACTIVE_LIST_MAX_LEN; } + // bool IsTimeMarkUpdate() const { return (m_uListState & TLIST_STATE_UPDATE_TIME_MARK) != 0; } + // void SetTimeMarkUpdate() { m_uListState |= TLIST_STATE_UPDATE_TIME_MARK; } + // void ClearTimeMarkUpdate() { m_uListState &= ~TLIST_STATE_UPDATE_TIME_MARK; } + // int GetMaxSimultaneousCount() {return m_uMaxSimultaneousCount ? TASK_MAX_SIMULTANEOUS_COUT : TASK_DEFAULT_MAX_SIMULTANEOUS_COUT;} + // void ExpandMaxSimultaneousCount() {m_uMaxSimultaneousCount = 1;} + public ActiveTaskEntry GetEntry(uint ulId) + { + for (int i = 0; i < m_uTaskCount; i++) + if (m_TaskEntries[i].m_ID == ulId) + return m_TaskEntries[i]; + + return null; + } + }; } \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Task/TaskTempl.cs b/Assets/PerfectWorld/Scripts/Task/TaskTempl.cs index 4f509ec9f1..e0f8df9401 100644 --- a/Assets/PerfectWorld/Scripts/Task/TaskTempl.cs +++ b/Assets/PerfectWorld/Scripts/Task/TaskTempl.cs @@ -350,7 +350,7 @@ namespace BrewMonster.Scripts.Task public struct ITEM_WANTED { public uint m_ulItemTemplId; - // when check bool -> m_bCommonItem > 0 == true + // when check bool . m_bCommonItem > 0 == true [MarshalAs(UnmanagedType.U1)] public bool m_bCommonItem; public uint m_ulItemNum; @@ -1266,6 +1266,22 @@ namespace BrewMonster.Scripts.Task public byte m_uValidCount; private uint m_ulMask; // 任务掩码 // Task mask + + /* ÈÎÎñ½áÊøºóµÄ½±Àø */ + + uint m_ulAwardType_S; + uint m_ulAwardType_F; + // ʱ¼äÏÞÖÆ + uint m_ulTimeLimit; + /* ÆÕͨºÍ°´Ã¿¸ö·½Ê½ */ + AWARD_DATA m_Award_S = new AWARD_DATA(); /* ³É¹¦ */ + AWARD_DATA m_Award_F = new AWARD_DATA(); /* ʧ°Ü */ + /* ʱ¼ä±ÈÀý·½Ê½ */ + AWARD_RATIO_SCALE m_AwByRatio_S; + AWARD_RATIO_SCALE m_AwByRatio_F; + /* °´»ñµÃÎï±ÈÀý·½Ê½ */ + AWARD_ITEMS_SCALE m_AwByItems_S; + AWARD_ITEMS_SCALE m_AwByItems_F; public bool LoadFromBinFile(FileStream fp) { LoadBinary(fp); @@ -1287,7 +1303,7 @@ namespace BrewMonster.Scripts.Task if (pTask == null || pEntry == null) break; if (!pTask.IsDeliverLegal()) break; - // 已完成直接返回 // Already finished -> true + // 已完成直接返回 // Already finished . true if (pEntry.IsFinished()) { ret = true; @@ -1536,7 +1552,7 @@ namespace BrewMonster.Scripts.Task // ATaskTempl* pSub = new ATaskTempl; // g_ulNewCount++; // AddSubTaskTempl(pSub); - // pSub->LoadBinary(fp); + // pSub.LoadBinary(fp); // } // 上述C++逻辑的C#实现 // C# implementation of the above C++ logic if (m_nSubCount > 0) @@ -2191,7 +2207,7 @@ namespace BrewMonster.Scripts.Task fixedData.m_ulMutexTasks = AAssit.ReadArrayFromBinary(fp, TaskTemplConstants.MAX_MUTEX_TASK_COUNT, ref readBytes); logContent += $"m_ulMutexTasks[0..{TaskTemplConstants.MAX_MUTEX_TASK_COUNT - 1}] loaded\n\n"; - // Living skills levels (C++ long -> 4 bytes). Read as int and widen to long + // Living skills levels (C++ long . 4 bytes). Read as int and widen to long var skillLevelsInt = AAssit.ReadArrayFromBinary(fp, TaskTemplConstants.MAX_LIVING_SKILLS, ref readBytes); fixedData.m_lSkillLev = Array.ConvertAll(skillLevelsInt, v => (long)v); logContent += $"m_lSkillLev[0..{TaskTemplConstants.MAX_LIVING_SKILLS - 1}] loaded\n\n"; @@ -3154,12 +3170,12 @@ namespace BrewMonster.Scripts.Task ad.m_ulCandItems = AAssit.ReadFromBinaryOf(fp, ref readBytes); logContent += $"m_ulCandItems: {ad.m_ulCandItems} \n"; fp.Seek(4, SeekOrigin.Current); // C++: AWARD_ITEMS_CAND* m_CandItems; skip pointer address - logContent += $"skip 4 bytes -> AWARD_ITEMS_CAND* m_CandItems \n"; + logContent += $"skip 4 bytes . AWARD_ITEMS_CAND* m_CandItems \n"; ad.m_ulSummonedMonsters = AAssit.ReadFromBinaryOf(fp, ref readBytes); logContent += $"m_ulSummonedMonsters: {ad.m_ulSummonedMonsters} \n"; fp.Seek(4, SeekOrigin.Current); // C++: AWARD_MONSTERS_SUMMONED* m_SummonedMonsters; skip pointer address - logContent += $"skip 4 bytes -> AWARD_MONSTERS_SUMMONED* m_SummonedMonsters \n"; + logContent += $"skip 4 bytes . AWARD_MONSTERS_SUMMONED* m_SummonedMonsters \n"; ad.m_bAwardDeath = AAssit.ReadFromBinaryOf(fp, ref readBytes) > 0; logContent += $"m_bAwardDeath: {ad.m_bAwardDeath} \n"; @@ -3198,7 +3214,7 @@ namespace BrewMonster.Scripts.Task ad.m_ulPQRankingAwardCnt = AAssit.ReadFromBinaryOf(fp, ref readBytes); logContent += $"m_ulPQRankingAwardCnt: {ad.m_ulPQRankingAwardCnt} \n"; fp.Seek(4, SeekOrigin.Current); // C++: AWARD_PQ_RANKING* m_PQRankingAward; skip pointer address - logContent += $"skip 4 bytes -> AWARD_PQ_RANKING* m_PQRankingAward \n"; + logContent += $"skip 4 bytes . AWARD_PQ_RANKING* m_PQRankingAward \n"; // Change global key/value arrays (pointers to basic types) ad.m_ulChangeKeyCnt = AAssit.ReadFromBinaryOf(fp, ref readBytes); @@ -3206,7 +3222,7 @@ namespace BrewMonster.Scripts.Task fp.Seek(4, SeekOrigin.Current); // C++: long* m_plChangeKey; skip sizeof(long) fp.Seek(4, SeekOrigin.Current); // C++: long* m_plChangeKeyValue; skip sizeof(long) fp.Seek(4, SeekOrigin.Current); // C++: bool* m_pbChangeType; skip sizeof(bool) - logContent += $"skip 4 pointers -> m_plChangeKey(4) \n m_plChangeKeyValue(4) \n m_pbChangeType(4) \n"; + logContent += $"skip 4 pointers . m_plChangeKey(4) \n m_plChangeKeyValue(4) \n m_pbChangeType(4) \n"; // Modify historical progress ad.m_ulHistoryChangeCnt = AAssit.ReadFromBinaryOf(fp, ref readBytes); @@ -3215,7 +3231,7 @@ namespace BrewMonster.Scripts.Task fp.Seek(4, SeekOrigin.Current); // C++: long* m_plHistoryChangeKey fp.Seek(4, SeekOrigin.Current); // C++: long* m_plHistoryChangeKeyValue fp.Seek(4, SeekOrigin.Current); // C++: bool* m_pbHistoryChangeType - logContent += $"skip pointers -> m_plHistoryChangeKey(4) \n m_plHistoryChangeKeyValue(4) \n m_pbHistoryChangeType(4) \n"; + logContent += $"skip pointers . m_plHistoryChangeKey(4) \n m_plHistoryChangeKeyValue(4) \n m_pbHistoryChangeType(4) \n"; // Multiplier ad.m_bMulti = AAssit.ReadFromBinaryOf(fp, ref readBytes) > 0; @@ -3229,21 +3245,21 @@ namespace BrewMonster.Scripts.Task ad.m_ulDisplayKeyCnt = AAssit.ReadFromBinaryOf(fp, ref readBytes); logContent += $"m_ulDisplayKeyCnt: {ad.m_ulDisplayKeyCnt} \n"; fp.Seek(4, SeekOrigin.Current); // C++: long* m_plDisplayKey - logContent += $"skip 4 bytes -> long* m_plDisplayKey \n"; + logContent += $"skip 4 bytes . long* m_plDisplayKey \n"; // Display global variable expressions ad.m_ulExpCnt = AAssit.ReadFromBinaryOf(fp, ref readBytes); logContent += $"m_ulExpCnt: {ad.m_ulExpCnt} \n"; fp.Seek(4, SeekOrigin.Current); // C++: char (*m_pszExp)[TASK_AWARD_MAX_DISPLAY_CHAR_LEN] fp.Seek(4, SeekOrigin.Current); // C++: TASK_EXPRESSION (*m_pExpArr)[TASK_AWARD_MAX_DISPLAY_CHAR_LEN] - logContent += $"skip 4 bytes -> m_pszExp(row ptr) \n"; - logContent += $"skip 4 bytes -> m_pExpArr(row ptr) \n"; + logContent += $"skip 4 bytes . m_pszExp(row ptr) \n"; + logContent += $"skip 4 bytes . m_pExpArr(row ptr) \n"; // Display global variable expression prompt strings ad.m_ulTaskCharCnt = AAssit.ReadFromBinaryOf(fp, ref readBytes); logContent += $"m_ulTaskCharCnt: {ad.m_ulTaskCharCnt} \n"; fp.Seek(4, SeekOrigin.Current); // C++: task_char (*m_pTaskChar)[TASK_AWARD_MAX_DISPLAY_CHAR_LEN] - logContent += $"skip 4 bytes -> task_char (*m_pTaskChar)[LEN] \n"; + logContent += $"skip 4 bytes . task_char (*m_pTaskChar)[LEN] \n"; // Force-related ad.m_iForceContribution = AAssit.ReadFromBinaryOf(fp, ref readBytes); @@ -3260,7 +3276,7 @@ namespace BrewMonster.Scripts.Task ad.m_ulTitleNum = AAssit.ReadFromBinaryOf(fp, ref readBytes); logContent += $"m_ulTitleNum: {ad.m_ulTitleNum} \n"; fp.Seek(4, SeekOrigin.Current); // C++: TITLE_AWARD* m_pTitleAward - logContent += $"skip 4 bytes -> TITLE_AWARD* m_pTitleAward \n"; + logContent += $"skip 4 bytes . TITLE_AWARD* m_pTitleAward \n"; ad.m_iLeaderShip = AAssit.ReadFromBinaryOf(fp, ref readBytes); logContent += $"m_iLeaderShip: {ad.m_iLeaderShip} \n"; @@ -3287,7 +3303,7 @@ namespace BrewMonster.Scripts.Task if (ad.m_ulSummonedMonsters > 0) { - //C++: ad.m_SummonedMonsters->m_ulMonsterNum = ad.m_ulSummonedMonsters; + //C++: ad.m_SummonedMonsters.m_ulMonsterNum = ad.m_ulSummonedMonsters; ad.m_SummonedMonsters.m_ulMonsterNum = ad.m_ulSummonedMonsters; LoadAwardMonstersBin(fp, ref ad.m_SummonedMonsters, ulVersion, ref readBytes); } @@ -3296,7 +3312,7 @@ namespace BrewMonster.Scripts.Task if (ad.m_ulPQRankingAwardCnt > 0) { - // C++: ad.m_PQRankingAward->m_ulRankingAwardNum = ad.m_ulPQRankingAwardCnt; + // C++: ad.m_PQRankingAward.m_ulRankingAwardNum = ad.m_ulPQRankingAwardCnt; ad.m_PQRankingAward.m_ulRankingAwardNum = ad.m_ulPQRankingAwardCnt; LoadAwardPQRankingBin(fp, ref ad.m_PQRankingAward, ulVersion, ref readBytes); } @@ -4081,5 +4097,70 @@ namespace BrewMonster.Scripts.Task unchecked { m_uDepth += uDepthLocal; } } + + public void CalcAwardData( + TaskInterface pTask, + ref AWARD_DATA pAward, + ActiveTaskEntry pEntry, + uint ulTaskTime, + uint ulCurTime) + { + var ulType = (pEntry.IsSuccess() ? m_ulAwardType_S : m_ulAwardType_F); + switch (ulType) + { + case (uint)TaskAwardType.enumTATNormal: + case (uint)TaskAwardType.enumTATEach: + pAward = (pEntry.IsSuccess() ? m_Award_S : m_Award_F); + break; + case (uint)TaskAwardType.enumTATRatio: + CalcAwardDataByRatio(ref pAward, pEntry, ulTaskTime, ulCurTime); + break; + case (uint)TaskAwardType.enumTATItemCount: + CalcAwardDataByItems(pTask, ref pAward, pEntry); + break; + default: + break; + } + } + + public void CalcAwardDataByRatio( + ref AWARD_DATA pAward, + ActiveTaskEntry pEntry, + uint ulTaskTime, + uint ulCurTime) + { + if (m_ulTimeLimit == 0) return; + + AWARD_RATIO_SCALE p = (pEntry.IsSuccess() ? m_AwByRatio_S : m_AwByRatio_F); + float ratio = (float)(ulCurTime - ulTaskTime) / m_ulTimeLimit; + uint i; + + for (i = 0; i= p.m_Counts[i]) + { + pAward = p.m_Awards[i]; + return; + } + } + } } } \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs index 5972cf4650..8598eacf5a 100644 --- a/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs +++ b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs @@ -8,6 +8,7 @@ using CSNetwork.Common; using CSNetwork.GPDataType; using ModelRenderer.Scripts.Common; using ModelRenderer.Scripts.GameData; +using PerfectWorld.Scripts.Task; using System; using System.Drawing; using System.Runtime.InteropServices; @@ -1084,222 +1085,222 @@ namespace BrewMonster.UI void PopupTaskDialog(bool bTaskNPC) { - //NPC_ESSENCE pCurNPCEssence = GetGameUIMan().m_pCurNPCEssence; - //NPC_ESSENCE pEssence = pCurNPCEssence; - ////if (!pEssence) return; + NPC_ESSENCE pCurNPCEssence = GetGameUIMan().m_pCurNPCEssence; + NPC_ESSENCE pEssence = pCurNPCEssence; + //if (!pEssence) return; - //int i, j, idTask; - //object pData; - //DATA_TYPE DataType = new DATA_TYPE(); - //unsigned int* a_idTask; - //uint[] a_uiService = - //{ - // pEssence.id_task_out_service, // صķID: - // pEssence.id_task_in_service, // صķID: ֤ - // pEssence.id_task_matter_service // صķID: Ʒ - // }; - //int idLastTask = 0, nLastTaskTime = 0, nFinishTime; - //elementdataman pDataMan = EC_Game.GetElementDataMan(); - //abase::vector taskIn, taskOut, taskMatter; - //CECTaskInterface* pTask = GetHostPlayer().GetTaskInterface(); + int i, j, idTask; + object pData; + DATA_TYPE DataType = new DATA_TYPE(); + unsigned int* a_idTask; + uint[] a_uiService = + { + pEssence.id_task_out_service, // صķID: + pEssence.id_task_in_service, // صķID: ֤ + pEssence.id_task_matter_service // صķID: Ʒ + }; + int idLastTask = 0, nLastTaskTime = 0, nFinishTime; + elementdataman pDataMan = EC_Game.GetElementDataMan(); + abase::vector taskIn, taskOut, taskMatter; + CECTaskInterface* pTask = GetHostPlayer().GetTaskInterface(); - //for (i = 0; i < sizeof(a_uiService) / sizeof(unsigned int) ; i++ ) - //{ - // pData = pDataMan.get_data_ptr(a_uiService[i], ID_SPACE_ESSENCE, DataType); + for (i = 0; i < sizeof(a_uiService) / sizeof(unsigned int) ; i++ ) + { + pData = pDataMan.get_data_ptr(a_uiService[i], ID_SPACE_ESSENCE, DataType); - // if (DataType == DT_NPC_TASK_IN_SERVICE || - // DataType == DT_NPC_TASK_OUT_SERVICE) - // { - // int total_count = 0; + if (DataType == DT_NPC_TASK_IN_SERVICE || + DataType == DT_NPC_TASK_OUT_SERVICE) + { + int total_count = 0; - // if (DataType == DT_NPC_TASK_IN_SERVICE) - // { - // NPC_TASK_IN_SERVICE* pService = (NPC_TASK_IN_SERVICE*)pData; - // a_idTask = pService.id_tasks; - // total_count = sizeof(pService.id_tasks) / sizeof(pService.id_tasks[0]); - // } - // else - // { - // NPC_TASK_OUT_SERVICE* pService = (NPC_TASK_OUT_SERVICE*)pData; + if (DataType == DT_NPC_TASK_IN_SERVICE) + { + NPC_TASK_IN_SERVICE* pService = (NPC_TASK_IN_SERVICE*)pData; + a_idTask = pService.id_tasks; + total_count = sizeof(pService.id_tasks) / sizeof(pService.id_tasks[0]); + } + else + { + NPC_TASK_OUT_SERVICE* pService = (NPC_TASK_OUT_SERVICE*)pData; - // // if storage task not exists - // if (pService.storage_id == 0 || pService.storage_open_item == 0) - // { - // a_idTask = pService.id_tasks; - // total_count = sizeof(pService.id_tasks) / sizeof(pService.id_tasks[0]); - // } - // } + // if storage task not exists + if (pService.storage_id == 0 || pService.storage_open_item == 0) + { + a_idTask = pService.id_tasks; + total_count = sizeof(pService.id_tasks) / sizeof(pService.id_tasks[0]); + } + } - // for (j = 0; j < total_count; j++) - // { - // idTask = a_idTask[j]; - // if (idTask <= 0) continue; + for (j = 0; j < total_count; j++) + { + idTask = a_idTask[j]; + if (idTask <= 0) continue; - // if (DataType == DT_NPC_TASK_IN_SERVICE) - // taskIn.push_back(TASK_ITEM(idTask, a_uiService[i])); - // else - // taskOut.push_back(TASK_ITEM(idTask, a_uiService[i])); + if (DataType == DT_NPC_TASK_IN_SERVICE) + taskIn.push_back(TASK_ITEM(idTask, a_uiService[i])); + else + taskOut.push_back(TASK_ITEM(idTask, a_uiService[i])); - // nFinishTime = (int)pTask.GetTaskFinishedTime(idTask); - // if (nFinishTime > nLastTaskTime) - // { - // idLastTask = idTask; - // nLastTaskTime = nFinishTime; - // } - // } - // } - // else if (DataType == DT_NPC_TASK_MATTER_SERVICE) - // { - // NPC_TASK_MATTER_SERVICE* pService = (NPC_TASK_MATTER_SERVICE*)pData; + nFinishTime = (int)pTask.GetTaskFinishedTime(idTask); + if (nFinishTime > nLastTaskTime) + { + idLastTask = idTask; + nLastTaskTime = nFinishTime; + } + } + } + else if (DataType == DT_NPC_TASK_MATTER_SERVICE) + { + NPC_TASK_MATTER_SERVICE* pService = (NPC_TASK_MATTER_SERVICE*)pData; - // for (j = 0; j < 16; j++) - // { - // idTask = pService.tasks[j].id_task; - // if (idTask > 0) - // { - // taskMatter.push_back(TASK_ITEM(idTask, a_uiService[i])); - // } - // } - // } - //} + for (j = 0; j < 16; j++) + { + idTask = pService.tasks[j].id_task; + if (idTask > 0) + { + taskMatter.push_back(TASK_ITEM(idTask, a_uiService[i])); + } + } + } + } - //A3DCOLOR color; - //string strText; - //const talk_proc* pTalk; - //ATaskTempl* pTemp, *pTempRoot; - //int nIndex, nNumTasks = 0; - //int nHostLevel = GetHostPlayer().GetBasicProps().iLevel; - //ATaskTemplMan* pTempMan = g_pGame.GetTaskTemplateMan(); + A3DCOLOR color; + string strText; + const talk_proc* pTalk; + ATaskTempl* pTemp, *pTempRoot; + int nIndex, nNumTasks = 0; + int nHostLevel = GetHostPlayer().GetBasicProps().iLevel; + ATaskTemplMan* pTempMan = g_pGame.GetTaskTemplateMan(); - //m_pLst_Main.ResetContent(); - //abase::vector* a_uiTasks[] = { &taskIn, &taskOut, &taskMatter }; - //for (int idx = 0; idx < sizeof(a_uiTasks) / sizeof(a_uiTasks[0]); idx++) - //{ - // abase::vector::iterator it; - // for (it = a_uiTasks[idx].begin(); it != a_uiTasks[idx].end(); ++it) - // { - // idTask = it.task_id; + m_pLst_Main.ResetContent(); + abase::vector* a_uiTasks[] = { &taskIn, &taskOut, &taskMatter }; + for (int idx = 0; idx < sizeof(a_uiTasks) / sizeof(a_uiTasks[0]); idx++) + { + abase::vector::iterator it; + for (it = a_uiTasks[idx].begin(); it != a_uiTasks[idx].end(); ++it) + { + idTask = it.task_id; - // color = 0; - // bool bNeedSetSpecialColor = false; - // pTemp = NULL; - // pTalk = NULL; - // color = m_pLst_Main.GetColor(); - // strText = GetStringFromTable(249); + color = 0; + bool bNeedSetSpecialColor = false; + pTemp = NULL; + pTalk = NULL; + color = m_pLst_Main.GetColor(); + strText = GetStringFromTable(249); - // if (idx == 1) - // { - // if (pTask.HasTask(idTask)) - // { - // if (!pTask.CanFinishTask(idTask)) - // { - // pTemp = pTempMan.GetTaskTemplByID(idTask); - // pTalk = pTemp.GetUnfinishedTalk(); - // } - // } - // else if (pTask.CanShowTask(idTask)) - // { - // pTemp = pTempMan.GetTaskTemplByID(idTask); + if (idx == 1) + { + if (pTask.HasTask(idTask)) + { + if (!pTask.CanFinishTask(idTask)) + { + pTemp = pTempMan.GetTaskTemplByID(idTask); + pTalk = pTemp.GetUnfinishedTalk(); + } + } + else if (pTask.CanShowTask(idTask)) + { + pTemp = pTempMan.GetTaskTemplByID(idTask); - // if (0 == pTask.CanDeliverTask(idTask)) - // pTalk = pTemp.GetDeliverTaskTalk(); - // else - // { - // pTalk = pTemp.GetUnqualifiedTalk(); - // color = A3DCOLORRGB(128, 128, 128); - // bNeedSetSpecialColor = true; - // } - // } - // } + if (0 == pTask.CanDeliverTask(idTask)) + pTalk = pTemp.GetDeliverTaskTalk(); + else + { + pTalk = pTemp.GetUnqualifiedTalk(); + color = A3DCOLORRGB(128, 128, 128); + bNeedSetSpecialColor = true; + } + } + } - // if (idx == 0 && pTask.HasTask(idTask) - // && pTask.CanFinishTask(idTask) && !pTalk) - // { - // pTemp = pTempMan.GetTaskTemplByID(idTask); - // pTalk = pTemp.GetAwardTalk(); - // strText = GetStringFromTable(302); - // } + if (idx == 0 && pTask.HasTask(idTask) + && pTask.CanFinishTask(idTask) && !pTalk) + { + pTemp = pTempMan.GetTaskTemplByID(idTask); + pTalk = pTemp.GetAwardTalk(); + strText = GetStringFromTable(302); + } - // if (pTemp && pTalk && (pTalk.num_window > 1 || pTalk.num_window == 1 && wcslen(pTalk.windows[0].talk_text))) - // { - // if (pTemp.IsKeyTask()) - // { - // color = A3DCOLORRGB(255, 162, 0); - // bNeedSetSpecialColor = true; - // } - // else if (color != 0) - // { - // // ȥ񼶱ıɫ߼ - // /* - // nLevel = pTemp.GetSuitableLevel(); - // if( nHostLevel <= nLevel - 2 ) - // color = A3DCOLORRGB(255, 54, 0); - // else if( nHostLevel >= nLevel + 3 ) - // color = A3DCOLORRGB(22, 142, 54); - // */ - // } + if (pTemp && pTalk && (pTalk.num_window > 1 || pTalk.num_window == 1 && wcslen(pTalk.windows[0].talk_text))) + { + if (pTemp.IsKeyTask()) + { + color = A3DCOLORRGB(255, 162, 0); + bNeedSetSpecialColor = true; + } + else if (color != 0) + { + // ȥ񼶱ıɫ߼ + /* + nLevel = pTemp.GetSuitableLevel(); + if( nHostLevel <= nLevel - 2 ) + color = A3DCOLORRGB(255, 54, 0); + else if( nHostLevel >= nLevel + 3 ) + color = A3DCOLORRGB(22, 142, 54); + */ + } - // pTempRoot = (ATaskTempl*)pTemp.GetTopTask(); - // if (pTemp != pTempRoot) - // { - // if (bNeedSetSpecialColor) - // { - // strText += CDlgTask::GetTaskNameWithOutColor(pTempRoot); - // } - // else - // { - // strText += CDlgTask::GetTaskNameWithColor(pTempRoot); - // } - // strText += _AL(" - "); - // } - // if (bNeedSetSpecialColor) - // { - // strText += CDlgTask::GetTaskNameWithOutColor(pTemp); - // } - // else - // { - // strText += CDlgTask::GetTaskNameWithColor(pTemp); - // } - // m_pLst_Main.AddString(strText); - // nIndex = m_pLst_Main.GetCount() - 1; - // m_pLst_Main.SetItemData(nIndex, it.service); // Service ID. - // m_pLst_Main.SetItemDataPtr(nIndex, (void*)pTalk); // Talk data. - // m_pLst_Main.SetItemData64(nIndex, pTemp.GetID(), 0, "TaskID"); + pTempRoot = (ATaskTempl*)pTemp.GetTopTask(); + if (pTemp != pTempRoot) + { + if (bNeedSetSpecialColor) + { + strText += CDlgTask::GetTaskNameWithOutColor(pTempRoot); + } + else + { + strText += CDlgTask::GetTaskNameWithColor(pTempRoot); + } + strText += _AL(" - "); + } + if (bNeedSetSpecialColor) + { + strText += CDlgTask::GetTaskNameWithOutColor(pTemp); + } + else + { + strText += CDlgTask::GetTaskNameWithColor(pTemp); + } + m_pLst_Main.AddString(strText); + nIndex = m_pLst_Main.GetCount() - 1; + m_pLst_Main.SetItemData(nIndex, it.service); // Service ID. + m_pLst_Main.SetItemDataPtr(nIndex, (void*)pTalk); // Talk data. + m_pLst_Main.SetItemData64(nIndex, pTemp.GetID(), 0, "TaskID"); - // if (bNeedSetSpecialColor) - // { - // m_pLst_Main.SetItemTextColor(nIndex, color); - // } - // nNumTasks++; - // } - // } - //} + if (bNeedSetSpecialColor) + { + m_pLst_Main.SetItemTextColor(nIndex, color); + } + nNumTasks++; + } + } + } - //if (idLastTask > 0) - //{ - // pTemp = pTempMan.GetTaskTemplByID(idLastTask); - // if (a_strlen(pTemp.GetTribute()) > 0) - // m_pTxt_Content.SetText(pTemp.GetTribute()); - // else - // { - // if (nNumTasks > 0) - // m_pTxt_Content.SetText(GetStringFromTable(502)); - // else - // m_pTxt_Content.SetText(GetStringFromTable(501)); - // } - //} - //else if (bTaskNPC) - // m_pTxt_Content.SetText(pCurNPCEssence.hello_msg); - //else - //{ - // if (nNumTasks > 0) - // m_pTxt_Content.SetText(GetStringFromTable(502)); - // else - // m_pTxt_Content.SetText(GetStringFromTable(501)); - //} + if (idLastTask > 0) + { + pTemp = pTempMan.GetTaskTemplByID(idLastTask); + if (a_strlen(pTemp.GetTribute()) > 0) + m_pTxt_Content.SetText(pTemp.GetTribute()); + else + { + if (nNumTasks > 0) + m_pTxt_Content.SetText(GetStringFromTable(502)); + else + m_pTxt_Content.SetText(GetStringFromTable(501)); + } + } + else if (bTaskNPC) + m_pTxt_Content.SetText(pCurNPCEssence.hello_msg); + else + { + if (nNumTasks > 0) + m_pTxt_Content.SetText(GetStringFromTable(502)); + else + m_pTxt_Content.SetText(GetStringFromTable(501)); + } - //SetData(NPC_DIALOG_TASK_LIST); + SetData(NPC_DIALOG_TASK_LIST); } public void PopupNPCDialog(talk_proc pTalk) @@ -1541,27 +1542,27 @@ namespace BrewMonster.UI } else if (idFunction == (int)SERVICE_TYPE.NPC_COMPLETE_TASK) { - AWARD_DATA ad; - talk_proc::option* opt = (talk_proc::option*)pData; - CECTaskInterface* pTask = GetHostPlayer().GetTaskInterface(); + AWARD_DATA ad = new AWARD_DATA(); + talk_proc.option opt = (talk_proc.option)pData; + CECTaskInterface pTask = GetHostPlayer().GetTaskInterface(); - pTask.GetAwardCandidates(opt.param, &ad); + pTask.GetAwardCandidates(opt.param, ref ad); if (ad.m_ulCandItems > 1) { pShow1 = m_pAUIManager.GetDialog("Win_Award"); - CDlgAward* pAward = dynamic_cast(pShow1); + CDlgAward pAward = (pShow1) as CDlgAward; if (pAward) pAward.UpdateAwardItem(opt.param, true); } else { - GetGameSession().c2s_CmdNPCSevReturnTask(opt.param, 0); + UnityGameSession.c2s_CmdNPCSevReturnTask(opt.param, 0); GetGameUIMan().EndNPCService(); } } else if (idFunction == (int)SERVICE_TYPE.NPC_GIVE_TASK_MATTER) { talk_proc.option opt = (talk_proc.option)pData; - GetGameSession().c2s_CmdNPCSevTaskMatter(opt.param); + UnityGameSession.c2s_CmdNPCSevTaskMatter(opt.param); GetGameUIMan().EndNPCService(); } else if (idFunction == (int)SERVICE_TYPE.NPC_STORAGE) @@ -2728,7 +2729,7 @@ namespace BrewMonster.UI NPC_TASK_OUT_SERVICE pService = (NPC_TASK_OUT_SERVICE)pData; if (!(pService.storage_id == 0 || pService.storage_open_item == 0)) { - //PopupStorageTaskDialog(pService, false); + PopupStorageTaskDialog(pService, false); return; } } From 0324dc909e4f0bc79f343700248f1e0e0c066383 Mon Sep 17 00:00:00 2001 From: Tungdv Date: Wed, 19 Nov 2025 19:12:24 +0700 Subject: [PATCH 3/5] fix: update logic select option dlg NPC. --- .../Scripts/Managers/EC_Inventory.cs | 20 +- .../CSNetwork/C2SCommand/C2SCommand.cs | 10 + .../CSNetwork/C2SCommand/C2SCommandFactory.cs | 37 +- .../Scripts/Network/CSNetwork/GameSession.cs | 19 +- .../Scripts/Network/UnityGameSession.cs | 10 + .../Scripts/Task/CECTaskInterface.cs | 86 +- .../Scripts/Task/TaskInterface.cs | 6 +- .../Scripts/Task/TaskTempl.Method.cs | 12 +- Assets/PerfectWorld/Scripts/Task/TaskTempl.cs | 53 + .../Scripts/UI/Dialogs/AUIListBox.cs | 27 + .../PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs | 950 ++++++++++++++---- .../Scripts/UI/Dialogs/ItemUIListBox.cs | 2 + .../Scripts/UI/GamePlay/EC_GameUIMan.cs | 1 + Assets/Scripts/CECHostPlayer.cs | 1 + 14 files changed, 996 insertions(+), 238 deletions(-) diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_Inventory.cs b/Assets/PerfectWorld/Scripts/Managers/EC_Inventory.cs index ce5b1312cf..adee590321 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_Inventory.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_Inventory.cs @@ -387,7 +387,25 @@ namespace BrewMonster.Scripts.Managers Debug.Log($"[Inventory] {tag}: RAW HEX (len={buffer?.Length ?? 0})=\n{(buffer == null ? "" : BitConverter.ToString(buffer))}"); } - } + // Inventory type + public static class Inventory_type + { + public const int IVTRTYPE_PACK = 0, // Normal pack + IVTRTYPE_EQUIPPACK = 1, // Equipment + IVTRTYPE_TASKPACK = 2, // Task pack + IVTRTYPE_TRASHBOX = 3, // Trash box + IVTRTYPE_TRASHBOX2 = 4, // Trash box - material box + IVTRTYPE_TRASHBOX3 = 5, // Trash box - fashion box + IVTRTYPE_ACCOUNT_BOX = 6, // User account box + IVTRTYPE_GENERALCARD_BOX = 7; // ư + }; + + // ע IVTRTYPE_CLIENT_GENERALCARD_PACK öֵܺ Inventory type ֵظ + public static class IVTRTYPE_PACK_CLIENT_GENERALCAR + { + public const int IVTRTYPE_CLIENT_GENERALCARD_PACK = 1024; // ͻ˱ذ ڿͼҪѻÿͨ췢͡Ϊͳһ촰ڵƷӱذ + }; + } } diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommand.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommand.cs index f4f0cf1607..c90bdd8b32 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommand.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommand.cs @@ -1372,6 +1372,16 @@ namespace CSNetwork.S2CCommand public int idStorage; public int idRefreshItem; }; + + public struct SevReturnTaskCONTENT + { + public int idTask; + public int iChoice; + } + public struct SevTaskMatterCONTENT + { + public int idTask; + } } // Player and NPC state \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs index 1289756374..d9365b1ada 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs @@ -516,22 +516,22 @@ namespace CSNetwork.C2SCommand return SerializeCommand(CommandID.NORMAL_ATTACK, cmd); } - public static Octets CreateCmdNPCSevAcceptTask(int idTask,int idStorage,int idRefreshItem) + public static Octets CreateCmdNPCSevAcceptTask(int idTask, int idStorage, int idRefreshItem) { cmd_sevnpc_serve cmd = new cmd_sevnpc_serve() { - service_type = 1, + service_type = NPC_service_type.GP_NPCSEV_TASK_ACCEPT, len = (uint)Marshal.SizeOf() }; - accept_task_CONTENT acceptTaskContent = new accept_task_CONTENT() + accept_task_CONTENT content = new accept_task_CONTENT() { idTask = idTask, idStorage = idStorage, idRefreshItem = idRefreshItem }; - var octets = SerializeCommand(CommandID.SEVNPC_SERVE, command: cmd, command2: acceptTaskContent); + var octets = SerializeCommand(CommandID.SEVNPC_SERVE, command: cmd, command2: content); return octets; } @@ -549,5 +549,34 @@ namespace CSNetwork.C2SCommand }; return SerializeCommand(CommandID.SEVNPC_SERVE, cmd); } + + public static Octets CreateNPCSevReturnTaskCmd(int idTask, int iChoice) + { + var cmd = new cmd_sevnpc_serve + { + service_type = NPC_service_type.GP_NPCSEV_TASK_RETURN, + len = (uint)Marshal.SizeOf() + }; + SevReturnTaskCONTENT content = new SevReturnTaskCONTENT() + { + idTask = idTask, + iChoice = iChoice, + }; + return SerializeCommand(CommandID.SEVNPC_SERVE, cmd, content); + } + + public static Octets CreateNPCSevTaskMatterCmd(int idTask) + { + var cmd = new cmd_sevnpc_serve + { + service_type = NPC_service_type.GP_NPCSEV_TASK_MATTER, + len = (uint)Marshal.SizeOf() + }; + SevTaskMatterCONTENT content = new SevTaskMatterCONTENT() + { + idTask = idTask + }; + return SerializeCommand(CommandID.SEVNPC_SERVE, cmd, content); + } } } diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs index 9437ada27a..58057745ee 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs @@ -1125,14 +1125,29 @@ namespace CSNetwork public void c2s_SendCmdNPCSevAcceptTask(int idTask, int idStorage, int idRefreshItem) { gamedatasend gamedatasend = new gamedatasend(); - gamedatasend.Data = C2SCommandFactory.CreateNPCSevAcceptTaskCmd( - NPC_service_type.GP_NPCSEV_TASK_ACCEPT, + gamedatasend.Data = C2SCommandFactory.CreateCmdNPCSevAcceptTask( idTask, idStorage, idRefreshItem); SendProtocol(gamedatasend); } + public void c2s_SendCmdNPCSevReturnTask(int idTask, int iChoice) + { + gamedatasend gamedatasend = new gamedatasend(); + gamedatasend.Data = C2SCommandFactory.CreateNPCSevReturnTaskCmd( + idTask, + iChoice); + SendProtocol(gamedatasend); + } + + public void c2s_SendCmdNPCSevTaskMatter(int idTask) + { + gamedatasend gamedatasend = new gamedatasend(); + gamedatasend.Data = C2SCommandFactory.CreateNPCSevTaskMatterCmd(idTask); + SendProtocol(gamedatasend); + } + public void GetRoleCustomizeData(int iNumRole, List aRoleIDs) { if (iNumRole <= 0 || aRoleIDs == null || aRoleIDs.Count == 0) return; diff --git a/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs b/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs index 9df7682e3a..d806f73d62 100644 --- a/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs +++ b/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs @@ -282,6 +282,16 @@ namespace BrewMonster.Network { Instance._gameSession.c2s_CmdNPCSevAcceptTask(idTask, idStorage, idRefreshItem); } + + public static void c2s_CmdNPCSevReturnTask(int idTask, int iChoice) + { + Instance._gameSession.c2s_SendCmdNPCSevReturnTask(idTask, iChoice); + } + + public static void c2s_CmdNPCSevTaskMatter(int idTask) + { + Instance._gameSession.c2s_SendCmdNPCSevTaskMatter(idTask); + } #region Task public static void c2s_CmdGetAllData(bool byPack, bool byEquip, bool byTask) { diff --git a/Assets/PerfectWorld/Scripts/Task/CECTaskInterface.cs b/Assets/PerfectWorld/Scripts/Task/CECTaskInterface.cs index 98fddf1116..f5e68e48dc 100644 --- a/Assets/PerfectWorld/Scripts/Task/CECTaskInterface.cs +++ b/Assets/PerfectWorld/Scripts/Task/CECTaskInterface.cs @@ -335,7 +335,7 @@ namespace BrewMonster.Scripts.Task private Dictionary m_TasksToConfirm = new Dictionary(); private readonly System.Collections.Generic.Dictionary m_emotionTask = new System.Collections.Generic.Dictionary(); private bool m_bForceNavigateFinish; - + private int m_tmFinishDlgShown; public CECTaskInterface() { @@ -445,7 +445,7 @@ namespace BrewMonster.Scripts.Task public bool IsDeliverLegal() { - // return !m_pHost->IsTrading() && m_pHost->GetBoothState() == 0 && !m_pHost->IsDead(); + // return !m_pHost.IsTrading() && m_pHost.GetBoothState() == 0 && !m_pHost.IsDead(); return true; // TODO: implement return m_pHost.IsTrading() && m_pHost.GetBoothState() == 0 && !m_pHost.IsDead(); @@ -464,8 +464,8 @@ namespace BrewMonster.Scripts.Task public int GetTaskItemCount(uint ulTaskItem) { - // CECInventory* pPack = m_pHost->GetTaskPack(); - // return pPack ? pPack->GetItemTotalNum((int)ulTaskItem) : 0; + // CECInventory* pPack = m_pHost.GetTaskPack(); + // return pPack ? pPack.GetItemTotalNum((int)ulTaskItem) : 0; return EC_Inventory.GetItemTotalNum(EC_Inventory.IVTRTYPE_TASKPACK, (int)ulTaskItem); } @@ -474,7 +474,7 @@ namespace BrewMonster.Scripts.Task { return EC_Game.GetTaskTemplateMan(); } - private ActiveTaskList GetActiveTaskList() + public ActiveTaskList GetActiveTaskList() { return m_pActiveListBuf; } @@ -964,7 +964,7 @@ namespace BrewMonster.Scripts.Task if (!IsDeliverLegal()) return (uint)TaskInterfaceConstants.TASK_PREREQU_FAIL_INDETERMINATE; - // return pTempl->CheckPrerequisite(this, static_cast(GetActiveTaskList()), GetCurTime(), true, true, false); + // return pTempl.CheckPrerequisite(this, static_cast(GetActiveTaskList()), GetCurTime(), true, true, false); return pTempl.CheckPrerequisite(this, GetActiveTaskList(), GetCurTime(), true, true, false); // if (!pTempl.CheckReachLevel(this)) return (uint)TaskInterfaceConstants.TASK_PREREQU_FAIL_BELOW_LEVEL; @@ -1146,7 +1146,7 @@ namespace BrewMonster.Scripts.Task return; } - private uint GetCurTime() + public uint GetCurTime() { // use this to avoid task hack by changing the system time return (uint)EC_Game.GetServerAbsTime(); @@ -1172,13 +1172,83 @@ namespace BrewMonster.Scripts.Task uint ulCurTime = GetCurTime(); pEntry.GetTempl().CalcAwardData( this, - pAward, + ref pAward, pEntry, pEntry.m_ulTaskTime, ulCurTime); return true; } + + public uint GetTaskFinishedTime(uint value) { return 0; } + + bool IsCaptain() + { + // TO DO: fix later + //CECTeam pTeam = m_pHost.GetTeam(); + //if (!pTeam) + // return false; + + //return pTeam.GetLeaderID() == m_pHost.GetCharacterID(); + + return true; + } + + public bool CanFinishTask(uint ulTaskId) + { + ActiveTaskEntry pEntry = (GetActiveTaskList() as ActiveTaskList).GetEntry(ulTaskId); + + if (pEntry == null) + return false; + + ATaskTempl pTempl = pEntry.GetTempl(); + + if (pTempl == null) + return false; + + if (pTempl.m_FixedData.m_bMarriage && !IsCaptain()) + return false; + + return pTempl.CanFinishTask(this, pEntry, GetCurTime()); + } + + public bool CanShowTask(uint ulTaskId) + { + ATaskTempl pTempl = GetTaskTemplMan().GetTopTaskByID(ulTaskId); + return pTempl != null && pTempl.CanShowTask(this); + } + + public void SetFinishDlgShowTime(int t) { m_tmFinishDlgShown = t; } + + public void OnUIDialogEnd(uint ulTask) + { + SetFinishDlgShowTime(0); + ActiveTaskList pLst = GetActiveTaskList() as ActiveTaskList; + ActiveTaskEntry pEntry = pLst.GetEntry(ulTask); + if (pEntry == null || pEntry.m_ulTemplAddr == 0) return; + //ATaskTempl pTempl = (pEntry.m_ulTemplAddr) as ATaskTempl; + ATaskTempl pTempl = GetTaskTemplMan().GetTaskTemplByID(pEntry.m_ulTemplAddr); + + switch (pTempl.m_FixedData.m_enumMethod) + { + case (uint)TaskCompletionMethod.enumTMReachSite: + pTempl.IncValidCount(); + _notify_svr(this, 3, (ushort)ulTask); //TASK_CLT_NOTIFY_REACH_SITE = 3 + break; + } + } + + public void GiveUpTask(uint ulTaskId) + { + ActiveTaskEntry pEntry = (GetActiveTaskList() as ActiveTaskList).GetEntry(ulTaskId); + if (pEntry == null || pEntry.GetTempl() == null) return; + _notify_svr(this, 2, (ushort)(pEntry.GetTempl().GetTopTask().GetID())); //TASK_CLT_NOTIFY_CHECK_GIVEUP = 2 + } + + void _notify_svr(TaskInterface pTask, byte uReason, ushort uTaskID) + { + + } } diff --git a/Assets/PerfectWorld/Scripts/Task/TaskInterface.cs b/Assets/PerfectWorld/Scripts/Task/TaskInterface.cs index 2a31733edf..b14f796e29 100644 --- a/Assets/PerfectWorld/Scripts/Task/TaskInterface.cs +++ b/Assets/PerfectWorld/Scripts/Task/TaskInterface.cs @@ -1,3 +1,5 @@ +using PerfectWorld.Scripts.Task; + namespace BrewMonster.Scripts.Task { public interface TaskInterface @@ -79,6 +81,8 @@ namespace BrewMonster.Scripts.Task bool IsKing(); bool IsInTeam(); uint GetAccountTotalCash(); - + uint GetCurTime(); + ActiveTaskList GetActiveTaskList(); + void SetFinishDlgShowTime(int t); } } \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Task/TaskTempl.Method.cs b/Assets/PerfectWorld/Scripts/Task/TaskTempl.Method.cs index ede8415632..3f384652c6 100644 --- a/Assets/PerfectWorld/Scripts/Task/TaskTempl.Method.cs +++ b/Assets/PerfectWorld/Scripts/Task/TaskTempl.Method.cs @@ -406,13 +406,13 @@ namespace BrewMonster.Scripts.Task // const wchar_t* GetDescription() const { assert(m_pwstrDescript); return (wchar_t*)m_pwstrDescript; } // const wchar_t* GetOkText() const { assert(m_pwstrOkText); return (wchar_t*)m_pwstrOkText; } // const wchar_t* GetNoText() const { assert(m_pwstrNoText); return (wchar_t*)m_pwstrNoText; } - // const wchar_t* GetTribute() const { assert(m_pwstrTribute); return (wchar_t*)m_pwstrTribute; } + public ushort[] GetTribute() { return m_pwstrTribute; } // - // const talk_proc* GetDeliverTaskTalk() const { return &m_DelvTaskTalk; } - // const talk_proc* GetUnqualifiedTalk() const { return &m_UnqualifiedTalk; } - // const talk_proc* GetDeliverItemTalk() const { return &m_DelvItemTalk; } - // const talk_proc* GetUnfinishedTalk() const { return &m_ExeTalk; } - // const talk_proc* GetAwardTalk() const { return &m_AwardTalk; } + public talk_proc GetDeliverTaskTalk() { return m_DelvTaskTalk; } + public talk_proc GetUnqualifiedTalk() { return m_UnqualifiedTalk; } + public talk_proc GetDeliverItemTalk() { return m_DelvItemTalk; } + public talk_proc GetUnfinishedTalk() { return m_ExeTalk; } + public talk_proc GetAwardTalk() { return m_AwardTalk; } // public uint GetDeliverNPC() { return m_FixedData.m_ulDelvNPC; } public uint GetAwardNPC() { return m_FixedData.m_ulAwardNPC; } diff --git a/Assets/PerfectWorld/Scripts/Task/TaskTempl.cs b/Assets/PerfectWorld/Scripts/Task/TaskTempl.cs index e0f8df9401..89f02e00d5 100644 --- a/Assets/PerfectWorld/Scripts/Task/TaskTempl.cs +++ b/Assets/PerfectWorld/Scripts/Task/TaskTempl.cs @@ -4162,5 +4162,58 @@ namespace BrewMonster.Scripts.Task } } } + + public bool CanShowTask(TaskInterface pTask) + { + + uint ulCurTime = pTask.GetCurTime(); + + if (m_pParent != null + || (pTask.GetActiveTaskList() as ActiveTaskList).GetEntry(GetID()) != null + || CheckTimetable(ulCurTime) > 0 + || CheckDeliverTime(pTask, ulCurTime) > 0 + || CheckFnshLst(pTask, ulCurTime) > 0 + || CheckMutexTask(pTask, ulCurTime) > 0 + || CheckLivingSkill(pTask) > 0 + || CheckSpecialAward(pTask) > 0 + || CheckGlobalKeyValue(pTask, false) > 0) + return false; + + uint ulRet; + + if (m_FixedData.m_bShowByDeposit && CheckDeposit(pTask) > 0) return false; + if (m_FixedData.m_bShowByGender && CheckGender(pTask) > 0) return false; + if (m_FixedData.m_bShowByItems && CheckItems(pTask) > 0) return false; + ulRet = CheckLevel(pTask); + if (ulRet == TaskInterfaceConstants.TASK_PREREQU_FAIL_ABOVE_LEVEL || (m_FixedData.m_bShowByLev && ulRet > 0)) return false; + if (m_FixedData.m_bShowByTransformed && CheckTransform(pTask) > 0) return false; + if (m_FixedData.m_bShowByForce && CheckForce(pTask) > 0) return false; + if (m_FixedData.m_bShowByForceActivityLevel && CheckForceActivityLevel(pTask) > 0) return false; + if (m_FixedData.m_bShowByForceExp && CheckExp(pTask) > 0) return false; + if (m_FixedData.m_bShowByForceSP && CheckSP(pTask) > 0) return false; + if (m_FixedData.m_bShowByForceContribution && CheckForceContribution(pTask) > 0) return false; + if (m_FixedData.m_bShowByForceReputation && CheckForceReputation(pTask) > 0) return false; + if (m_FixedData.m_bShowByNeedRecordTasksNum && CheckRecordTasksNum(pTask) > 0) return false; + if (m_FixedData.m_bShowByFactionContrib && CheckFactionContrib(pTask) > 0) return false; + if (m_FixedData.m_bShowByOccup && CheckOccupation(pTask) > 0) return false; + if (m_FixedData.m_bShowByPreTask && CheckPreTask(pTask) > 0) return false; + if (m_FixedData.m_bShowByRepu && CheckRepu(pTask) > 0) return false; + if (m_FixedData.m_bShowByTeam && CheckTeamTask(pTask) > 0) return false; + if (m_FixedData.m_bShowByFaction && CheckFaction(pTask) > 0) return false; + if (m_FixedData.m_bShowByPeriod && CheckPeriod(pTask) > 0) return false; + if (m_FixedData.m_bShowByCharTime && CheckCharTime(pTask) > 0) return false; + if (m_FixedData.m_bShowByRMB && CheckAccountRMB(pTask) > 0) return false; + if (m_FixedData.m_bShowByWeddingOwner && CheckWeddingOwner(pTask) > 0) return false; + if (m_FixedData.m_bShowByKing && CheckKing(pTask) > 0) return false; + if (m_FixedData.m_bShowByNotInTeam && CheckNotInTeam(pTask) > 0) return false; + if (m_FixedData.m_bShowByReincarnation && CheckReincarnation(pTask) > 0) return false; + if (m_FixedData.m_bShowByRealmLevel && (CheckRealmLevel(pTask) > 0 || CheckRealmExpFull(pTask) > 0)) return false; + if (m_FixedData.m_bShowByGeneralCard && CheckCardCollection(pTask) > 0) return false; + if (m_FixedData.m_bShowByGeneralCardRank && CheckCardRankCount(pTask) > 0) return false; + if (m_FixedData.m_bShowByHistoryStage && CheckHistoryStage(pTask) > 0) return false; + + return true; + } + public uint GetType() { return m_FixedData.m_ulType; } } } \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIListBox.cs b/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIListBox.cs index cc1bc4f40a..61e23921be 100644 --- a/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIListBox.cs +++ b/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIListBox.cs @@ -62,6 +62,18 @@ namespace BrewMonster.UI return nIndex; } + public int SetItemData64(int nIndex, ulong pData, int nSubIndex = 0, string strName = "") + { + if (nIndex < 0 || nIndex >= (m_Item.Count)) + return -1; + if (nSubIndex < 0 || nSubIndex >= 20) // #define AUILISTBOX_DATA_NUM AUILISTBOX_MAX_COLUMN 20 + return -1; + + m_Item[nIndex].strData64Name[nSubIndex] = strName; + m_Item[nIndex].uiData64[nSubIndex] = pData; + return nIndex; + } + public int GetCount() { return m_Item.Count; @@ -111,5 +123,20 @@ namespace BrewMonster.UI else return m_Item[nIndex].strText; } + + //public int SetItemTextColor(int nIndex, A3DCOLOR color, int nItem) + //{ + // if (nIndex < 0 || nIndex >= int(m_Item.size())) + // return AUILISTBOX_ERROR; + + // UpdateRenderTarget(); + + // if (nItem >= 0) + // m_Item[nIndex].color[nItem] = color; + // else + // for (int i = 0; i < max(1, m_nNumColumns); i++) + // m_Item[nIndex].color[i] = color; + // return nIndex; + //} } } diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs index 8598eacf5a..cef931770d 100644 --- a/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs +++ b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs @@ -1,7 +1,8 @@ -using BrewMonster.Assets.PerfectWorld.Scripts.UI; +using BrewMonster.Assets.PerfectWorld.Scripts.UI; using BrewMonster.Common; using BrewMonster.Managers; using BrewMonster.Network; +using BrewMonster.Scripts.Managers; using BrewMonster.Scripts.Task; using CSNetwork; using CSNetwork.Common; @@ -10,7 +11,9 @@ using ModelRenderer.Scripts.Common; using ModelRenderer.Scripts.GameData; using PerfectWorld.Scripts.Task; using System; +using System.Collections.Generic; using System.Drawing; +using System.Reflection; using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Text; @@ -31,6 +34,18 @@ namespace BrewMonster.UI int m_iTracedTaskNPCID; CECTimeSafeChecker m_tracedTaskTimer; + public struct TASK_ITEM + { + public int task_id; + public int service; + + public TASK_ITEM(int id, int serv) + { + task_id = id; + service = serv; + } + }; + bool HasTracedTask() { return m_iTracedTaskID > 0; @@ -114,14 +129,14 @@ namespace BrewMonster.UI CDLGNPC_OFFLINESHOP_SELLBUY = 0xFFFFF45, CDLGNPC_REINCARNATION = 0xFFFFF46, CDLGNPC_GIFTCARD = 0xFFFFF47, - CDLGNPC_TRICKBATTLE = 0xFFFFF48, // , ս - CDLGNPC_CARDRESPAWN = 0xFFFFF49, // ת - CDLGNPC_QUERYCHARIOTAMOUNT = 0xFFFFF50, // ս - CDLGNPC_FLYSWORDIMPROVE = 0xFFFFF51, // ɽǿ - CDLGNPC_OPEN_FACTION_PVP = 0xFFFFF52, // Ӷ + CDLGNPC_TRICKBATTLE = 0xFFFFF48, // ¿ç·þ»î¶¯, Õ½³µ + CDLGNPC_CARDRESPAWN = 0xFFFFF49, // ¿¨ÅÆ×ªÉú + CDLGNPC_QUERYCHARIOTAMOUNT = 0xFFFFF50, // Õ½³µÊýÁ¿ + CDLGNPC_FLYSWORDIMPROVE = 0xFFFFF51, // ·É½£Ç¿»¯ + CDLGNPC_OPEN_FACTION_PVP = 0xFFFFF52, // ¿ªÆô°ïÅÉÂÓ¶á CDLGNPC_FACTION_RENAME = 0xFFFFF53, CDLGNPC_GOLD_SHOP = 0xFFFFF54, - CDLGNPC_PLAYER_CHANGE_GENDER = 0xFFFFF55; // ޸Ա + CDLGNPC_PLAYER_CHANGE_GENDER = 0xFFFFF55; // ÐÞ¸ÄÐÔ±ð }; bool PopupTracedTaskDialog(NPC_ESSENCE pEssence) @@ -220,32 +235,32 @@ namespace BrewMonster.UI // pEssence.id_goblin_skill_service = 1; uint[] a_uiService = { - pEssence.id_talk_service, // ̸ķID - pEssence.id_sell_service, // ƷķID - pEssence.id_buy_service, // չƷķID - pEssence.id_install_service, // װǶƷķID - pEssence.id_uninstall_service, // ǶƷķID - pEssence.id_skill_service, // ڼܵķID - pEssence.id_heal_service, // ƵķID - pEssence.id_transmit_service, // ͵ķID - pEssence.id_transport_service, // ķID - pEssence.id_proxy_service, // ۵ķID - pEssence.id_storage_service, // ֿķID - pEssence.id_make_service, // ķID - pEssence.id_decompose_service, // ֽķID - pEssence.id_identify_service, // ķID - pEssence.id_war_towerbuild_service,// ķID - pEssence.id_resetprop_service, // ϴķID - pEssence.id_petname_service, // - pEssence.id_petlearnskill_service, // ѧϰܷ - pEssence.id_petforgetskill_service,// ܷ - pEssence.id_equipbind_service, // װ󶨷 - pEssence.id_equipdestroy_service, // װٷ - pEssence.id_equipundestroy_service,// װٷ - pEssence.id_goblin_skill_service, // Сѧϰ - pEssence.id_engrave_service, // Կ̷ - pEssence.id_randprop_service, // - pEssence.id_force_service, // + pEssence.id_talk_service, // ½»Ì¸µÄ·þÎñID + pEssence.id_sell_service, // ³öÊÛÉÌÆ·µÄ·þÎñID + pEssence.id_buy_service, // ÊÕ¹ºÆ·µÄ·þÎñID + pEssence.id_install_service, // °²×°ÏâǶƷµÄ·þÎñID + pEssence.id_uninstall_service, // ²ð³ýÏâǶƷµÄ·þÎñID + pEssence.id_skill_service, // ½ÌÊÚ¼¼ÄܵķþÎñID + pEssence.id_heal_service, // ÖÎÁƵķþÎñID + pEssence.id_transmit_service, // ´«Ë͵ķþÎñID + pEssence.id_transport_service, // ÔËÊäµÄ·þÎñID + pEssence.id_proxy_service, // ´úÊ۵ķþÎñID + pEssence.id_storage_service, // ²Ö¿âµÄ·þÎñID + pEssence.id_make_service, // Éú²úµÄ·þÎñID + pEssence.id_decompose_service, // ·Ö½âµÄ·þÎñID + pEssence.id_identify_service, // ¼ø¶¨µÄ·þÎñID + pEssence.id_war_towerbuild_service,// ½¨Ôì¼ýËþµÄ·þÎñID + pEssence.id_resetprop_service, // Ï´µãµÄ·þÎñID + pEssence.id_petname_service, // ³èÎï¸ÄÃû·þÎñ + pEssence.id_petlearnskill_service, // ³èÎïѧϰ¼¼ÄÜ·þÎñ + pEssence.id_petforgetskill_service,// ³èÎïÒÅÍü¼¼ÄÜ·þÎñ + pEssence.id_equipbind_service, // ×°±¸°ó¶¨·þÎñ + pEssence.id_equipdestroy_service, // ×°±¸Ïú»Ù·þÎñ + pEssence.id_equipundestroy_service,// ×°±¸½â³ýÏú»Ù·þÎñ + pEssence.id_goblin_skill_service, // С¾«Áéѧϰ·þÎñ + pEssence.id_engrave_service, // ïÔ¿Ì·þÎñ + pEssence.id_randprop_service, // Ëæ»úÊôÐÔ + pEssence.id_force_service, // ÊÆÁ¦ÊôÐÔ }; GetGameUIMan().m_pCurNPCEssence = (NPC_ESSENCE)pEssence; @@ -410,13 +425,13 @@ namespace BrewMonster.UI if (idFaction <= 0 || EC_Game.GetFactionMan().GetFaction((uint)idFaction, false) == null) { - // ްɡ߰Ϣδѯ + // ÎÞ°ïÅÉ¡¢»òÕß°ïÅÉÐÅÏ¢ÉÐδ²éѯµ½ break; } if (GetHostPlayer().GetFactionFortressConfig().require_level == int.MinValue) // this replace logic == null { - // ûлñ + // ûÓлùµØÅäÖñí break; } @@ -445,31 +460,31 @@ namespace BrewMonster.UI if (bFortressOK) { - // ɻ + // °ïÅÉ»ùµØÏà¹Ø if ((pEssence.combined_services & 0x8000000) != 0) { if (bMaster) { - // Դ + // °ïÖ÷¿ÉÒÔ´´½¨»ùµØ m_pLst_Main.AddString(strText + GetStringFromTable(9101)); m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CGLDNPC_FORTRESS_CREATE); } // if (bMaster || bViceMaster) // { - // // Դս + // // °ïÖ÷¡¢¸±°ïÖ÷¿ÉÒÔ´¦ÀíÕ½¶·ÊÂÒË // m_pLst_Main.AddString(strText + GetStringFromTable(9102)); // m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CGLDNPC_FORTRESS_WAR); // } if (!bInFortressNow) { - // ʱɽҷ + // °ïÖÚËæÊ±¿É½øÈëÎÒ·½»ùµØ m_pLst_Main.AddString(strText + GetStringFromTable(9107)); m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CGLDNPC_FORTRESS_ENTER); } - // ʱɲ鿴ս + // °ïÖÚËæÊ±¿É²é¿´¶ÔÕ½±í // m_pLst_Main.AddString(strText + GetStringFromTable(9108)); // m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CGLDNPC_FORTRESS_WARLIST); } @@ -480,23 +495,23 @@ namespace BrewMonster.UI { if (!GetHostPlayer().IsInFortressWar()) { - // սʱʩ + // °ïÖ÷·Çսʱ¿ÉÒÔÉý¼¶»ùµØÉèÊ© m_pLst_Main.AddString(strText + GetStringFromTable(9103)); m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CGLDNPC_FORTRESS_UPGRADE); } } - // ڿԽɲ + // °ïÖÚ¿ÉÒÔ½ÉÄɲÄÁÏ m_pLst_Main.AddString(strText + GetStringFromTable(9104)); m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CGLDNPC_FORTRESS_HANDIN_MATERIAL); - // ڿԽɹ׶ + // °ïÖÚ¿ÉÒÔ½ÉÄɹ±Ï×¶È m_pLst_Main.AddString(strText + GetStringFromTable(9105)); m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CGLDNPC_FORTRESS_HANDIN_CONTRIB); if (bInFortressNow) { - // ڿ뿪 + // °ïÖÚ¿ÉÒÔÀ뿪»ùµØ m_pLst_Main.AddString(strText + GetStringFromTable(9109)); m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CGLDNPC_FORTRESS_LEAVE); } @@ -506,7 +521,7 @@ namespace BrewMonster.UI { if (bMaster) { - // Զһ + // °ïÖ÷¿ÉÒÔ¶Ò»»²ÄÁÏ m_pLst_Main.AddString(strText + GetStringFromTable(9106)); m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CGLDNPC_FORTRESS_EXCHANGE_MATERIAL); } @@ -574,26 +589,26 @@ namespace BrewMonster.UI // m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_GOTO_ORIGINALSERVER); //} } - // + // ¸ÄÃû·þÎñ if ((pEssence.combined_services2 & 0x00000020) != 0) { m_pLst_Main.AddString(strText + GetStringFromTable(10150)); m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_PLAYER_RENAME); } - // ʯת + // ±¦Ê¯×ª»» bool bHasStoneChange = (pEssence.combined_services2 & 0x00000040) != 0; if (bHasStoneChange) { m_pLst_Main.AddString(strText + GetStringFromTable(10172)); m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_STONE_CHANGE); } - // + // ¹úÍõÏà¹Ø if ((pEssence.combined_services2 & 0x00000080) != 0) { m_pLst_Main.AddString(strText + GetStringFromTable(10304)); m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_KING_SERVICE); } - // + // ¼ÄÂô·þÎñ if ((pEssence.combined_services2 & 0x00000100) != 0) { m_pLst_Main.AddString(strText + GetStringFromTable(10508)); @@ -602,7 +617,7 @@ namespace BrewMonster.UI m_pLst_Main.AddString(strText + GetStringFromTable(10513)); m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_OFFLINESHOP_SELLBUY); } - // ʱװ + // ʱװ²ð·Ö if ((pEssence.combined_services2 & 0x00000200) != 0) { m_pLst_Main.AddString(strText + GetStringFromTable(10430)); @@ -610,7 +625,7 @@ namespace BrewMonster.UI } if ((pEssence.combined_services2 & 0x00000400) != 0) { - // ת汾 + // תÉú°æ±¾ÉÏÏÞ if (GetHostPlayer().GetReincarnationCount() < CECPlayer.MAX_REINCARNATION) { m_pLst_Main.AddString(strText + GetStringFromTable(10800)); @@ -632,7 +647,7 @@ namespace BrewMonster.UI m_pLst_Main.AddString(strText + GetStringFromTable(11000)); m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_CARDRESPAWN); } - if ((pEssence.combined_services2 & 0x00001000) != 0) // սnpc Զиķͻˣ + if ((pEssence.combined_services2 & 0x00001000) != 0) // Õ½³µ¿ªÆônpc ×Ô¶¯´øÓиķþÎñÆ÷£¬£¨´¿¿Í»§¶Ë£© { m_pLst_Main.AddString(strText + GetStringFromTable(10912)); m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_QUERYCHARIOTAMOUNT); @@ -840,7 +855,7 @@ namespace BrewMonster.UI } else { - // δʶķ + // δʶ±ðµÄ·þÎñ continue; } @@ -913,7 +928,7 @@ namespace BrewMonster.UI // } //} - // ĩβӣжԡءʾбֱʾб + // ÈÎÎñÏà¹ØÄ©Î²Ìí¼Ó£¬ÒÔÅжÏÊÇÒÔ¡°ÈÎÎñÏà¹Ø¡±ÏÔʾÔÚÁбíÀ»¹ÊÇÖ±½ÓÏÔʾÈÎÎñÁбí CheckTaskService(pEssence); if (pEssence.domain_related == 1) @@ -985,9 +1000,9 @@ namespace BrewMonster.UI uint[] a_uiService2 = { - pEssence.id_task_out_service, // صķID: - pEssence.id_task_in_service, // صķID: ֤ - pEssence.id_task_matter_service, // صķID: Ʒ + pEssence.id_task_out_service, // ÈÎÎñÏà¹ØµÄ·þÎñID: ·¢·ÅÈÎÎñ·þÎñ + pEssence.id_task_in_service, // ÈÎÎñÏà¹ØµÄ·þÎñID: ÑéÖ¤Íê³ÉÈÎÎñ·þÎñ + pEssence.id_task_matter_service, // ÈÎÎñÏà¹ØµÄ·þÎñID: ·¢·ÅÈÎÎñÎïÆ··þÎñ }; object pData; @@ -1011,7 +1026,7 @@ namespace BrewMonster.UI for (int i = 0; i < a_uiService2.Length; i++) { if (a_uiService2[i] == 0) continue; - + pData = ElementDataManProvider.GetElementDataMan().get_data_ptr(a_uiService2[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType); // ignore other service @@ -1055,7 +1070,7 @@ namespace BrewMonster.UI if (isEmptyMenu && pStorageService.storage_deliver_per_day == int.MinValue) { - // ûзѡֱӵ + // ûÓзÇÈÎÎñÑ¡Ïֱ½Óµ¯³öÈÎÎñÄÚÈÝ PopupTaskDialog(true); } else @@ -1074,7 +1089,7 @@ namespace BrewMonster.UI { pData = pDataMan.get_data_ptr(validTaskService, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); - // ݣؼзڡء + // ÓÐÆäËü·ÇÈÎÎñÄÚÈÝ£¬°ÑËùÓÐÈÎÎñÏà¹Ø¼¯ÖзÅÔÚ¡°ÈÎÎñÏà¹Ø¡±À¸Àï m_pLst_Main.AddString(strText + GetStringFromTable(244)); m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, validTaskService); m_pLst_Main.SetItemDataPtr(m_pLst_Main.GetCount() - 1, pData); @@ -1085,63 +1100,65 @@ namespace BrewMonster.UI void PopupTaskDialog(bool bTaskNPC) { - NPC_ESSENCE pCurNPCEssence = GetGameUIMan().m_pCurNPCEssence; - NPC_ESSENCE pEssence = pCurNPCEssence; + NPC_ESSENCE? pCurNPCEssence = GetGameUIMan().m_pCurNPCEssence; + NPC_ESSENCE pEssence = pCurNPCEssence.Value; //if (!pEssence) return; int i, j, idTask; object pData; DATA_TYPE DataType = new DATA_TYPE(); - unsigned int* a_idTask; + uint[] a_idTask = new uint[0]; uint[] a_uiService = { - pEssence.id_task_out_service, // صķID: - pEssence.id_task_in_service, // صķID: ֤ - pEssence.id_task_matter_service // صķID: Ʒ - }; + pEssence.id_task_out_service, // ÈÎÎñÏà¹ØµÄ·þÎñID: ·¢·ÅÈÎÎñ·þÎñ + pEssence.id_task_in_service, // ÈÎÎñÏà¹ØµÄ·þÎñID: ÑéÖ¤Íê³ÉÈÎÎñ·þÎñ + pEssence.id_task_matter_service // ÈÎÎñÏà¹ØµÄ·þÎñID: ·¢·ÅÈÎÎñÎïÆ··þÎñ + }; int idLastTask = 0, nLastTaskTime = 0, nFinishTime; elementdataman pDataMan = EC_Game.GetElementDataMan(); - abase::vector taskIn, taskOut, taskMatter; - CECTaskInterface* pTask = GetHostPlayer().GetTaskInterface(); + List taskIn = new List(), + taskOut = new List(), + taskMatter = new List(); + CECTaskInterface pTask = GetHostPlayer().GetTaskInterface(); - for (i = 0; i < sizeof(a_uiService) / sizeof(unsigned int) ; i++ ) + for (i = 0; i < a_uiService.Length; i++) { - pData = pDataMan.get_data_ptr(a_uiService[i], ID_SPACE_ESSENCE, DataType); + pData = pDataMan.get_data_ptr(a_uiService[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType); - if (DataType == DT_NPC_TASK_IN_SERVICE || - DataType == DT_NPC_TASK_OUT_SERVICE) + if (DataType == DATA_TYPE.DT_NPC_TASK_IN_SERVICE || + DataType == DATA_TYPE.DT_NPC_TASK_OUT_SERVICE) { int total_count = 0; - if (DataType == DT_NPC_TASK_IN_SERVICE) + if (DataType == DATA_TYPE.DT_NPC_TASK_IN_SERVICE) { - NPC_TASK_IN_SERVICE* pService = (NPC_TASK_IN_SERVICE*)pData; + NPC_TASK_IN_SERVICE pService = (NPC_TASK_IN_SERVICE)pData; a_idTask = pService.id_tasks; - total_count = sizeof(pService.id_tasks) / sizeof(pService.id_tasks[0]); + total_count = pService.id_tasks.Length; } else { - NPC_TASK_OUT_SERVICE* pService = (NPC_TASK_OUT_SERVICE*)pData; + NPC_TASK_OUT_SERVICE pService = (NPC_TASK_OUT_SERVICE)pData; // if storage task not exists if (pService.storage_id == 0 || pService.storage_open_item == 0) { a_idTask = pService.id_tasks; - total_count = sizeof(pService.id_tasks) / sizeof(pService.id_tasks[0]); + total_count = pService.id_tasks.Length; } } for (j = 0; j < total_count; j++) { - idTask = a_idTask[j]; + idTask = (int)a_idTask[j]; if (idTask <= 0) continue; - if (DataType == DT_NPC_TASK_IN_SERVICE) - taskIn.push_back(TASK_ITEM(idTask, a_uiService[i])); + if (DataType == DATA_TYPE.DT_NPC_TASK_IN_SERVICE) + taskIn.Add(new TASK_ITEM(idTask, (int)a_uiService[i])); else - taskOut.push_back(TASK_ITEM(idTask, a_uiService[i])); + taskOut.Add(new TASK_ITEM(idTask, (int)a_uiService[i])); - nFinishTime = (int)pTask.GetTaskFinishedTime(idTask); + nFinishTime = (int)pTask.GetTaskFinishedTime((uint)idTask); if (nFinishTime > nLastTaskTime) { idLastTask = idTask; @@ -1149,129 +1166,128 @@ namespace BrewMonster.UI } } } - else if (DataType == DT_NPC_TASK_MATTER_SERVICE) + else if (DataType == DATA_TYPE.DT_NPC_TASK_MATTER_SERVICE) { - NPC_TASK_MATTER_SERVICE* pService = (NPC_TASK_MATTER_SERVICE*)pData; + NPC_TASK_MATTER_SERVICE pService = (NPC_TASK_MATTER_SERVICE)pData; for (j = 0; j < 16; j++) { - idTask = pService.tasks[j].id_task; + idTask = (int)pService.tasks[j].id_task; if (idTask > 0) { - taskMatter.push_back(TASK_ITEM(idTask, a_uiService[i])); + taskMatter.Add(new TASK_ITEM(idTask, (int)a_uiService[i])); } } } } - A3DCOLOR color; - string strText; - const talk_proc* pTalk; - ATaskTempl* pTemp, *pTempRoot; + //A3DCOLOR color; + string strText = ""; + talk_proc? pTalk; + ATaskTempl pTemp, pTempRoot; int nIndex, nNumTasks = 0; int nHostLevel = GetHostPlayer().GetBasicProps().iLevel; - ATaskTemplMan* pTempMan = g_pGame.GetTaskTemplateMan(); + ATaskTemplMan pTempMan = EC_Game.GetTaskTemplateMan(); m_pLst_Main.ResetContent(); - abase::vector* a_uiTasks[] = { &taskIn, &taskOut, &taskMatter }; - for (int idx = 0; idx < sizeof(a_uiTasks) / sizeof(a_uiTasks[0]); idx++) + List[] a_uiTasks = { taskIn, taskOut, taskMatter }; + for (int idx = 0; idx < a_uiTasks.Length; idx++) { - abase::vector::iterator it; - for (it = a_uiTasks[idx].begin(); it != a_uiTasks[idx].end(); ++it) + foreach (var it in a_uiTasks[idx]) { idTask = it.task_id; - color = 0; + //color = 0; bool bNeedSetSpecialColor = false; - pTemp = NULL; - pTalk = NULL; - color = m_pLst_Main.GetColor(); + pTemp = null; + pTalk = null; + //color = m_pLst_Main.GetColor(); strText = GetStringFromTable(249); if (idx == 1) { - if (pTask.HasTask(idTask)) + if (pTask.HasTask((uint)idTask)) { - if (!pTask.CanFinishTask(idTask)) + if (!pTask.CanFinishTask((uint)idTask)) { - pTemp = pTempMan.GetTaskTemplByID(idTask); + pTemp = pTempMan.GetTaskTemplByID((uint)idTask); pTalk = pTemp.GetUnfinishedTalk(); } } - else if (pTask.CanShowTask(idTask)) + else if (pTask.CanShowTask((uint)idTask)) { - pTemp = pTempMan.GetTaskTemplByID(idTask); + pTemp = pTempMan.GetTaskTemplByID((uint)idTask); - if (0 == pTask.CanDeliverTask(idTask)) + if (0 == pTask.CanDeliverTask((uint)idTask)) pTalk = pTemp.GetDeliverTaskTalk(); else { pTalk = pTemp.GetUnqualifiedTalk(); - color = A3DCOLORRGB(128, 128, 128); + //color = A3DCOLORRGB(128, 128, 128); bNeedSetSpecialColor = true; } } } - if (idx == 0 && pTask.HasTask(idTask) - && pTask.CanFinishTask(idTask) && !pTalk) + if (idx == 0 && pTask.HasTask((uint)idTask) + && pTask.CanFinishTask((uint)idTask) && pTalk == null) { - pTemp = pTempMan.GetTaskTemplByID(idTask); + pTemp = pTempMan.GetTaskTemplByID((uint)idTask); pTalk = pTemp.GetAwardTalk(); strText = GetStringFromTable(302); } - if (pTemp && pTalk && (pTalk.num_window > 1 || pTalk.num_window == 1 && wcslen(pTalk.windows[0].talk_text))) + if (pTemp != null && pTalk != null && (pTalk?.num_window > 1 || pTalk?.num_window == 1 && (pTalk?.windows[0].talk_text).Length > 0)) { if (pTemp.IsKeyTask()) { - color = A3DCOLORRGB(255, 162, 0); + //color = A3DCOLORRGB(255, 162, 0); bNeedSetSpecialColor = true; } - else if (color != 0) - { - // ȥ񼶱ıɫ߼ - /* - nLevel = pTemp.GetSuitableLevel(); - if( nHostLevel <= nLevel - 2 ) - color = A3DCOLORRGB(255, 54, 0); - else if( nHostLevel >= nLevel + 3 ) - color = A3DCOLORRGB(22, 142, 54); - */ - } + //else if (color != 0) + //{ + // // È¥µô¸ù¾ÝÈËÎïºÍÈÎÎñ¼¶±ð²îÀ´¸Ä±äÑÕÉ«µÄÂß¼­ + // /* + // nLevel = pTemp.GetSuitableLevel(); + // if( nHostLevel <= nLevel - 2 ) + // color = A3DCOLORRGB(255, 54, 0); + // else if( nHostLevel >= nLevel + 3 ) + // color = A3DCOLORRGB(22, 142, 54); + // */ + //} - pTempRoot = (ATaskTempl*)pTemp.GetTopTask(); + pTempRoot = (ATaskTempl)pTemp.GetTopTask(); if (pTemp != pTempRoot) { if (bNeedSetSpecialColor) { - strText += CDlgTask::GetTaskNameWithOutColor(pTempRoot); + strText += GetTaskNameWithOutColor(pTempRoot); } else { - strText += CDlgTask::GetTaskNameWithColor(pTempRoot); + strText += GetTaskNameWithColor(pTempRoot); } - strText += _AL(" - "); + strText += (" - "); } if (bNeedSetSpecialColor) { - strText += CDlgTask::GetTaskNameWithOutColor(pTemp); + strText += GetTaskNameWithOutColor(pTemp); } else { - strText += CDlgTask::GetTaskNameWithColor(pTemp); + strText += GetTaskNameWithColor(pTemp); } m_pLst_Main.AddString(strText); nIndex = m_pLst_Main.GetCount() - 1; - m_pLst_Main.SetItemData(nIndex, it.service); // Service ID. - m_pLst_Main.SetItemDataPtr(nIndex, (void*)pTalk); // Talk data. + m_pLst_Main.SetItemData(nIndex, (uint)it.service); // Service ID. + m_pLst_Main.SetItemDataPtr(nIndex, (object)pTalk); // Talk data. m_pLst_Main.SetItemData64(nIndex, pTemp.GetID(), 0, "TaskID"); - if (bNeedSetSpecialColor) - { - m_pLst_Main.SetItemTextColor(nIndex, color); - } + //if (bNeedSetSpecialColor) + //{ + // m_pLst_Main.SetItemTextColor(nIndex, color); + //} nNumTasks++; } } @@ -1279,9 +1295,12 @@ namespace BrewMonster.UI if (idLastTask > 0) { - pTemp = pTempMan.GetTaskTemplByID(idLastTask); - if (a_strlen(pTemp.GetTribute()) > 0) - m_pTxt_Content.SetText(pTemp.GetTribute()); + pTemp = pTempMan.GetTaskTemplByID((uint)idLastTask); + if ((pTemp.GetTribute().Length) > 0) + { + string text = Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pTemp.GetTribute())); + m_pTxt_Content.SetText(text); + } else { if (nNumTasks > 0) @@ -1291,7 +1310,13 @@ namespace BrewMonster.UI } } else if (bTaskNPC) - m_pTxt_Content.SetText(pCurNPCEssence.hello_msg); + { + if (pCurNPCEssence != null) + { + string text = Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pCurNPCEssence.Value.hello_msg)); + m_pTxt_Content.SetText(text); + } + } else { if (nNumTasks > 0) @@ -1300,7 +1325,60 @@ namespace BrewMonster.UI m_pTxt_Content.SetText(GetStringFromTable(501)); } - SetData(NPC_DIALOG_TASK_LIST); + SetData(NPC_DIALOG.NPC_DIALOG_TASK_LIST, ""); + } + + string GetTaskNameWithOutColor(ATaskTempl pTempl) + { + string text = Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pTempl.m_FixedData.m_szName)); + return TrimColorPrefix(text); + } + + string GetTaskNameWithColor(ATaskTempl pTempl) + { + string text = Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pTempl.m_FixedData.m_szName)); + if (pTempl.GetType() == (uint)ENUM_TASK_TYPE.enumTTQiShaList && text[0] == '^') + { + // Èç¹ûÊÇÆßɱ°ñÈÎÎñÇÒÒѾ­¼ÓÁËÑÕÉ«£¬ÔòÑÕÉ«²»±ä + return text; + } + string strTaskName = GetTaskNameWithOutColor(pTempl); + //string strColorPreFix = A3DCOLOR_TO_STRING(GetTaskColor(pTempl)); + + //strTaskName = strColorPreFix + strTaskName; + return strTaskName; + } + + string TrimColorPrefix(string szName) + { + const int COLOR_PREFIX_LENGTH = 7; // "^ffffff" + + if (!string.IsNullOrEmpty(name) && name.Length >= COLOR_PREFIX_LENGTH && name[0] == '^') + { + bool bColorPrefix = true; + for (int i = 1; i < COLOR_PREFIX_LENGTH; i++) + { + char c = name[i]; + bool isHexDigit = + (c >= '0' && c <= '9') || + (c >= 'a' && c <= 'f') || + (c >= 'A' && c <= 'F'); + + if (!isHexDigit) + { + bColorPrefix = false; + break; + } + } + + if (bColorPrefix) + { + // Lấy phần sau prefix + return name.Substring(COLOR_PREFIX_LENGTH); + } + } + + return name; } public void PopupNPCDialog(talk_proc pTalk) @@ -1330,7 +1408,7 @@ namespace BrewMonster.UI if (!IsShow()) Show(true); } - bool PopupCorrespondingServiceDialog(int idFunction, int iService, object pData) + bool c(int idFunction, int iService, object pData) { AUIDialog pShow1 = null, pShow2 = null; NPC_ESSENCE? pCurNPCEssence = GetGameUIMan().m_pCurNPCEssence; @@ -1555,14 +1633,14 @@ namespace BrewMonster.UI } else { - UnityGameSession.c2s_CmdNPCSevReturnTask(opt.param, 0); + UnityGameSession.c2s_CmdNPCSevReturnTask((int)opt.param, 0); GetGameUIMan().EndNPCService(); } } else if (idFunction == (int)SERVICE_TYPE.NPC_GIVE_TASK_MATTER) { talk_proc.option opt = (talk_proc.option)pData; - UnityGameSession.c2s_CmdNPCSevTaskMatter(opt.param); + UnityGameSession.c2s_CmdNPCSevTaskMatter((int)opt.param); GetGameUIMan().EndNPCService(); } else if (idFunction == (int)SERVICE_TYPE.NPC_STORAGE) @@ -1610,53 +1688,53 @@ namespace BrewMonster.UI GetGameUIMan().EndNPCService(); int idCurFinishTask = GetGameUIMan().m_idCurFinishTask; - if (GetData() == CDlgNPC::NPC_DIALOG_TASK_TALK && idCurFinishTask > 0) + if (GetData() == NPC_DIALOG.NPC_DIALOG_TASK_TALK && idCurFinishTask > 0) { - GetHostPlayer().GetTaskInterface().OnUIDialogEnd(idCurFinishTask); + GetHostPlayer().GetTaskInterface().OnUIDialogEnd((uint)idCurFinishTask); GetGameUIMan().m_idCurFinishTask = -1; } } else if (idFunction == (int)SERVICE_TYPE.TALK_GIVEUP_TASK) { - talk_proc::option* opt = (talk_proc::option*)pData; + talk_proc.option opt = (talk_proc.option)pData; GetHostPlayer().GetTaskInterface().GiveUpTask(opt.param); GetGameUIMan().EndNPCService(); } else { - GetHostPlayer().GetPack(IVTRTYPE_PACK).UnfreezeAllItems(); + //GetHostPlayer().GetPack(IVTRTYPE_PACK).UnfreezeAllItems(); GetGameUIMan().EndNPCService(); } if (pShow1) { - DATA_TYPE DataType; - elementdataman* pDataMan = g_pGame.GetElementDataMan(); + DATA_TYPE DataType = new DATA_TYPE(); + elementdataman pDataMan = EC_Game.GetElementDataMan(); - pDataMan.get_data_ptr(iService, ID_SPACE_ESSENCE, DataType); + pDataMan.get_data_ptr((uint)iService, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); pShow1.Show(true); if (pShow2) { - POINT ptPos = pShow1.GetPos(); - if (ptPos.x == 0 && ptPos.y == 0) - { - SIZE s1 = pShow1.GetSize(); - SIZE s2 = pShow2.GetSize(); - A3DVIEWPORTPARAM* p = m_pA3DEngine.GetActiveViewport().GetParam(); - int x, y = (p.Height - max(s1.cy, s2.cy)) / 2; + //POINT ptPos = pShow1.GetPos(); + //if (ptPos.x == 0 && ptPos.y == 0) + //{ + // SIZE s1 = pShow1.GetSize(); + // SIZE s2 = pShow2.GetSize(); + // A3DVIEWPORTPARAM* p = m_pA3DEngine.GetActiveViewport().GetParam(); + // int x, y = (p.Height - max(s1.cy, s2.cy)) / 2; - x = (p.Width - s1.cx - s2.cx) / 2; + // x = (p.Width - s1.cx - s2.cx) / 2; - // old : pShow1.SetPos(x, y); - pShow1.SetPosEx(x, y); + // // old : pShow1.SetPos(x, y); + // pShow1.SetPosEx(x, y); - x += s1.cx; + // x += s1.cx; - // old : pShow2.SetPos(x, y); - pShow2.SetPosEx(x, y); - } + // // old : pShow2.SetPos(x, y); + // pShow2.SetPosEx(x, y); + //} pShow2.Show(true); } @@ -1666,6 +1744,82 @@ namespace BrewMonster.UI return true; } + void OnCommand_back(string szCommand) + { + + NPC_ESSENCE? pCurNPCEssence = GetGameUIMan().m_pCurNPCEssence; + + if (GetData() == NPC_DIALOG.NPC_DIALOG_TALK || + GetData() == NPC_DIALOG.NPC_DIALOG_TASK_TALK) + { + int i, j, nIndex; + string strText; + talk_proc pTalk = (talk_proc)GetDataPtr("ptr_talk_proc"); + uint id = 0;//(uint)m_pTxt_Content.GetData(); + CECTaskInterface pTask = GetHostPlayer().GetTaskInterface(); + + if (0xFFFFFFFF == id) // No any more parent window. + { + if (GetData() == NPC_DIALOG.NPC_DIALOG_TALK) + PopupNPCDialog(pCurNPCEssence.Value); + else if (pCurNPCEssence != null) + { + // ������̸���ص������б����� + + // �ȵ���ӭ���棬����ӭ�����Ƿ���������б����� + PopupNPCDialog(pCurNPCEssence.Value); + if (GetData() != NPC_DIALOG.NPC_DIALOG_TASK_LIST) + { + // ��ӭ���治�������б����棬���������� + // ���µ��������б����� + PopupTaskDialog(false); + m_pLst_Main.AddString(GetStringFromTable(503)); + } + } + } + else + { + for (i = 0; i < pTalk.num_window; i++) + { + if (id != pTalk.windows[i].id) continue; + string text = Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pTalk.windows[i].talk_text)); + m_pTxt_Content.SetText(pTask.FormatTaskTalk(text)); + //m_pTxt_Content.SetData(pTalk.windows[i].id_parent); + + m_pLst_Main.ResetContent(); + for (j = 0; j < pTalk.windows[i].num_option; j++) + { + strText = GetStringFromTable(249); + strText += pTalk.windows[i].options[j].text; + m_pLst_Main.AddString(strText); + nIndex = m_pLst_Main.GetCount() - 1; + m_pLst_Main.SetItemData(nIndex, pTalk.windows[i].options[j].id); + m_pLst_Main.SetItemDataPtr(nIndex, pTalk.windows[i].options[j]); + } + + break; + } + } + } + + else if (GetData() == NPC_DIALOG.NPC_DIALOG_TASK_LIST) + { + PopupNPCDialog(pCurNPCEssence.Value); + + if (GetData() == NPC_DIALOG.NPC_DIALOG_TASK_LIST) + { + // �����ǰNPCֻ��������ط����򷵻ص�ͬ���˳�NPC���� + Show(false); + GetGameUIMan().EndNPCService(); + } + } + else if (GetData() == NPC_DIALOG.NPC_DIALOG_ESSENCE) + { + Show(false); + GetGameUIMan().EndNPCService(); + } + } + void SelectListItem(int index) { m_pLst_Main.SetCurSel(index); @@ -1709,24 +1863,24 @@ namespace BrewMonster.UI int nIndex1 = (int)CECGameUIMan.TALKPROC_GET_FUNCTION_ID(id); uint[] a_uiService = { - pEssence.id_talk_service, // ̸ķID - pEssence.id_sell_service, // ƷķID - pEssence.id_buy_service, // չƷķID - pEssence.id_repair_service, // ƷķID - pEssence.id_install_service, // װǶƷķID - pEssence.id_uninstall_service, // ǶƷķID - pEssence.id_task_out_service, // صķID: - pEssence.id_task_in_service, // صķID: ֤ - pEssence.id_task_matter_service, // صķID: Ʒ - pEssence.id_skill_service, // ڼܵķID - pEssence.id_heal_service, // ƵķID - pEssence.id_transmit_service, // ͵ķID - pEssence.id_transport_service, // ķID - pEssence.id_proxy_service, // ۵ķID - pEssence.id_storage_service, // ֿķID - pEssence.id_make_service, // ķID - pEssence.id_decompose_service, // ֽķID - pEssence.id_identify_service, // ķID + pEssence.id_talk_service, // ½»Ì¸µÄ·þÎñID + pEssence.id_sell_service, // ³öÊÛÉÌÆ·µÄ·þÎñID + pEssence.id_buy_service, // ÊÕ¹ºÆ·µÄ·þÎñID + pEssence.id_repair_service, // ÐÞÀíÉÌÆ·µÄ·þÎñID + pEssence.id_install_service, // °²×°ÏâǶƷµÄ·þÎñID + pEssence.id_uninstall_service, // ²ð³ýÏâǶƷµÄ·þÎñID + pEssence.id_task_out_service, // ÈÎÎñÏà¹ØµÄ·þÎñID: ·¢·ÅÈÎÎñ·þÎñ + pEssence.id_task_in_service, // ÈÎÎñÏà¹ØµÄ·þÎñID: ÑéÖ¤Íê³ÉÈÎÎñ·þÎñ + pEssence.id_task_matter_service, // ÈÎÎñÏà¹ØµÄ·þÎñID: ·¢·ÅÈÎÎñÎïÆ··þÎñ + pEssence.id_skill_service, // ½ÌÊÚ¼¼ÄܵķþÎñID + pEssence.id_heal_service, // ÖÎÁƵķþÎñID + pEssence.id_transmit_service, // ´«Ë͵ķþÎñID + pEssence.id_transport_service, // ÔËÊäµÄ·þÎñID + pEssence.id_proxy_service, // ´úÊ۵ķþÎñID + pEssence.id_storage_service, // ²Ö¿âµÄ·þÎñID + pEssence.id_make_service, // Éú²úµÄ·þÎñID + pEssence.id_decompose_service, // ·Ö½âµÄ·þÎñID + pEssence.id_identify_service, // ¼ø¶¨µÄ·þÎñID 0, // Talk return. 0, // Talk exit. 0 // Storage password. @@ -1923,7 +2077,7 @@ namespace BrewMonster.UI //GetGameUIMan().m_pDlgMailList.Show(true); return; } - else if (iService == CDLGNPC.CDLGNPC_AUCTION && (pEssence?.combined_services & 0x80 ) != 0) + else if (iService == CDLGNPC.CDLGNPC_AUCTION && (pEssence?.combined_services & 0x80) != 0) { Show(false); // TO DO: fix later @@ -2039,7 +2193,7 @@ namespace BrewMonster.UI } else if (iService == CDLGNPC.CDLGNPC_ELFGENIUSRESET && (pEssence?.combined_services & 0x40000) != 0) { - //µĶԻ + //еĶԻ°¿ò Show(false); //GetGameUIMan().m_pDlgELFGeniusReset.Show(true); //GetGameUIMan().m_pDlgInventory.Show(true); @@ -2126,7 +2280,7 @@ namespace BrewMonster.UI } else if (iService == CDLGNPC.CGLDNPC_FORTRESS_CREATE && (pEssence?.combined_services & 0x8000000) != 0) { - // + // ´´½¨»ùµØ //CECHostPlayer pHost = GetHostPlayer(); //int idFaction = pHost.GetFactionID(); @@ -2145,7 +2299,7 @@ namespace BrewMonster.UI // bool bOK = true; - // // ɵȼ + // // °ïÅɵȼ¶ // if (pInfo.GetLevel() < pConfig.require_level) // bOK = false; @@ -2156,7 +2310,7 @@ namespace BrewMonster.UI // strMsg += strNextLine; // strMsg += strTemp; - // // + // // µÀ¾ßÐèÇó // CECInventory* pPack = pHost.GetPack(); // int nItems = sizeof(pConfig.require_item) / sizeof(pConfig.require_item[0]); // for (int i = 0; i < nItems; ++i) @@ -2184,13 +2338,13 @@ namespace BrewMonster.UI // if (!bOK) // { - // // 㣬ʾϢ + // // Ìõ¼þ²»Âú×㣬ÏÔʾ¾ßÌåÐÅÏ¢ // GetGameUIMan().MessageBox("", strMsg, MB_OK, A3DCOLORRGB(255, 255, 255)); // GetGameUIMan().EndNPCService(); // } // else // { - // // 㣬Իȷ + // // Ìõ¼þÂú×㣬µ¯³ö¶Ô»°¿òÈ·ÈÏ // GetGameUIMan().MessageBox("Fortress_Create", strMsg, MB_YESNO, A3DCOLORRGBA(255, 255, 255, 160)); // } //} @@ -2204,7 +2358,7 @@ namespace BrewMonster.UI } else if (iService == CDLGNPC.CGLDNPC_FORTRESS_WAR && (pEssence?.combined_services & 0x8000000) != 0) { - // ս + // »ùµØÕ½ //PAUIDIALOG pDlg1 = GetGameUIMan().GetDialog("Win_FortressWar"); //if (pDlg1) //{ @@ -2219,7 +2373,7 @@ namespace BrewMonster.UI } else if (iService == CDLGNPC.CGLDNPC_FORTRESS_ENTER && (pEssence?.combined_services & 0x8000000) != 0) { - // + // ½øÈë»ùµØ //GetGameSession().factionFortress_Enter(GetHostPlayer().GetFactionID()); //GetGameUIMan().EndNPCService(); Show(false); @@ -2227,7 +2381,7 @@ namespace BrewMonster.UI } else if (iService == CDLGNPC.CGLDNPC_FORTRESS_WARLIST && (pEssence?.combined_services & 0x8000000) != 0) { - // ضս + // »ùµØ¶ÔÕ½±í //PAUIDIALOG pDlg1 = GetGameUIMan().GetDialog("Win_FortressWarList"); //if (pDlg1) //{ @@ -2242,7 +2396,7 @@ namespace BrewMonster.UI } else if (iService == CDLGNPC.CGLDNPC_FORTRESS_UPGRADE && (pEssence?.combined_services & 0x10000000) != 0) { - // + // »ùµØÉý¼¶ //PAUIDIALOG pDlg1 = GetGameUIMan().GetDialog("Win_FortressInfo"); //PAUIDIALOG pDlg2 = GetGameUIMan().GetDialog("Win_FortressBuild"); //if (pDlg1 && pDlg2) @@ -2259,7 +2413,7 @@ namespace BrewMonster.UI } else if (iService == CDLGNPC.CGLDNPC_FORTRESS_HANDIN_MATERIAL && (pEssence?.combined_services & 0x10000000) != 0) { - // ɲ + // ½ÉÄɲÄÁÏ //PAUIDIALOG pDlg1 = GetGameUIMan().GetDialog("Win_FortressInfo"); //PAUIDIALOG pDlg2 = GetGameUIMan().GetDialog("Win_FortressMaterial"); //if (pDlg1 && pDlg2) @@ -2276,7 +2430,7 @@ namespace BrewMonster.UI } else if (iService == CDLGNPC.CGLDNPC_FORTRESS_HANDIN_CONTRIB && (pEssence?.combined_services & 0x10000000) != 0) { - // ɹ׶ + // ½ÉÄɹ±Ï×¶È //PAUIDIALOG pDlg1 = GetGameUIMan().GetDialog("Win_FortressInfo"); //PAUIDIALOG pDlg2 = GetGameUIMan().GetDialog("Win_FortressContrib"); //if (pDlg1 && pDlg2) @@ -2293,7 +2447,7 @@ namespace BrewMonster.UI } else if (iService == CDLGNPC.CGLDNPC_FORTRESS_LEAVE && (pEssence?.combined_services & 0x10000000) != 0) { - // 뿪 + // À뿪»ùµØ //GetGameSession().c2s_CmdNPCSevFactionFortressLeave(); GetGameUIMan().EndNPCService(); Show(false); @@ -2301,7 +2455,7 @@ namespace BrewMonster.UI } else if (iService == CDLGNPC.CGLDNPC_FORTRESS_EXCHANGE_MATERIAL && (pEssence?.combined_services & 0x200000000) != 0) { - // һ + // ¶Ò»»²ÄÁÏ //PAUIDIALOG pDlg1 = GetGameUIMan().GetDialog("Win_FortressInfo"); //PAUIDIALOG pDlg2 = GetGameUIMan().GetDialog("Win_FortressExchange"); //if (pDlg1 && pDlg2) @@ -2351,7 +2505,7 @@ namespace BrewMonster.UI Show(false); return; } - else if ((iService == CDLGNPC.CDLGNPC_JOIN_COUNTRY || iService == CDLGNPC.CDLGNPC_QUIT_COUNTRY) + else if ((iService == CDLGNPC.CDLGNPC_JOIN_COUNTRY || iService == CDLGNPC.CDLGNPC_QUIT_COUNTRY) && (pEssence?.combined_services2 & 0x00000001) != 0) { //if (iService == CDLGNPC.CDLGNPC_JOIN_COUNTRY) @@ -2365,7 +2519,7 @@ namespace BrewMonster.UI // bool bOK(true); - // // ҵȼ + // // Íæ¼ÒµÈ¼¶ // const int REQUIRE_LEVEL = CECUIConfig::Instance().GetGameUI().nCountryWarEnterLevel; // int iLevel = GetHostPlayer().GetMaxLevelSofar(); // if (iLevel < REQUIRE_LEVEL) bOK = false; @@ -2377,7 +2531,7 @@ namespace BrewMonster.UI // strMsg += strNextLine; // strMsg += strTemp; - // // + // // µÀ¾ßÐèÇó // const int REQUIRE_ITEM = CECUIConfig::Instance().GetGameUI().nCountryWarEnterItem; // const int REQUIRE_COUNT = CECUIConfig::Instance().GetGameUI().nCountryWarEnterItemCount; // CECInventory* pPack = pHost.GetPack(); @@ -2394,7 +2548,7 @@ namespace BrewMonster.UI // strMsg += strNextLine; // strMsg += strTemp; - // // ҪǶӳ + // // ×é¶ÓÒªÇóÊǶӳ¤ // CECTeam* pTeam = pHost.GetTeam(); // if (pTeam != NULL) // { @@ -2407,7 +2561,7 @@ namespace BrewMonster.UI // strMsg += strTemp; // } - // // ȴ + // // ÀäÈ´¼ì²é // bool bCoolDown = pHost.GetCoolTime(GP_CT_COUNTRY_BATTLE_APPLY) > 0; // if (bCoolDown) bOK = false; // strTemp.Format(GetStringFromTable(9774) @@ -2421,13 +2575,13 @@ namespace BrewMonster.UI // if (!bOK) // { - // // 㣬ʾϢ + // // Ìõ¼þ²»Âú×㣬ÏÔʾ¾ßÌåÐÅÏ¢ // GetGameUIMan().MessageBox("", strMsg, MB_OK, A3DCOLORRGB(255, 255, 255)); // GetGameUIMan().EndNPCService(); // } // else // { - // // 㣬Իȷ + // // Ìõ¼þÂú×㣬µ¯³ö¶Ô»°¿òÈ·ÈÏ // PAUIDIALOG pDlgMsgBox = NULL; // GetGameUIMan().MessageBox("Country_JoinLeave", strMsg, MB_YESNO, A3DCOLORRGBA(255, 255, 255, 160), &pDlgMsgBox); // pDlgMsgBox.SetData(1); @@ -2435,7 +2589,7 @@ namespace BrewMonster.UI //} //else //{ - // // 뿪ȷ + // // À뿪ȷ¶¨ // PAUIDIALOG pDlgMsgBox = NULL; // string strMsg = GetStringFromTable(9770); // GetGameUIMan().MessageBox("Country_JoinLeave", strMsg, MB_YESNO, A3DCOLORRGBA(255, 255, 255, 160), &pDlgMsgBox); @@ -2446,7 +2600,7 @@ namespace BrewMonster.UI } else if (iService == CDLGNPC.CDLGNPC_LEAVE_COUNTRY_WAR && (pEssence?.combined_services2 & 0x00000002) != 0) { - // 뿪ȷ + // À뿪ȷ¶¨ string strMsg = GetStringFromTable(9915); //GetGameUIMan().MessageBox("Country_LeaveWar", strMsg, MB_YESNO, A3DCOLORRGBA(255, 255, 255, 160)); Show(false); @@ -2472,7 +2626,7 @@ namespace BrewMonster.UI // bool bOK(true); - // // ҵȼ + // // Íæ¼ÒµÈ¼¶ // const int REQUIRE_LEVEL = CECUIConfig::Instance().GetGameUI().nCrossServerEnterLevel; // int iLevel = GetHostPlayer().GetMaxLevelSofar(); // if (iLevel < REQUIRE_LEVEL) bOK = false; @@ -2484,7 +2638,7 @@ namespace BrewMonster.UI // strMsg += strNextLine; // strMsg += strTemp; - // // Ҫ + // // ÐÞÕæÒªÇó // const int REQUIRE_LEVEL2 = CECUIConfig::Instance().GetGameUI().nCrossServerEnterLevel2; // int iLevel2 = GetHostPlayer().GetBasicProps().iLevel2; // if (iLevel2 < REQUIRE_LEVEL2) bOK = false; @@ -2496,7 +2650,7 @@ namespace BrewMonster.UI // strMsg += strNextLine; // strMsg += strTemp; - // // ȴ + // // ÀäÈ´¼ì²é // bool bCoolDown = pHost.GetCoolTime(GP_CT_CROSS_SERVER_APPLY) > 0; // if (bCoolDown) bOK = false; // strTemp.Format(GetStringFromTable(9774) @@ -2511,13 +2665,13 @@ namespace BrewMonster.UI // if (!bOK) // { - // // 㣬ʾϢ + // // Ìõ¼þ²»Âú×㣬ÏÔʾ¾ßÌåÐÅÏ¢ // GetGameUIMan().MessageBox("", strMsg, MB_OK, A3DCOLORRGB(255, 255, 255)); // GetGameUIMan().EndNPCService(); // } // else // { - // // 㣬Իȷ + // // Ìõ¼þÂú×㣬µ¯³ö¶Ô»°¿òÈ·ÈÏ // GetGameUIMan().MessageBox("CrossServer_GetIn", strMsg, MB_YESNO, A3DCOLORRGBA(255, 255, 255, 160)); // } //} @@ -2535,7 +2689,7 @@ namespace BrewMonster.UI return; } else if (iService == CDLGNPC.CDLGNPC_PLAYER_RENAME && (pEssence?.combined_services2 & 0x00000020) != 0) - {// + {// ¸ÄÃû·þÎñ //if (CECCrossServer::Instance().IsOnSpecialServer()) //{ // GetGameUIMan().ShowErrorMsg(10130); @@ -2543,7 +2697,7 @@ namespace BrewMonster.UI //} //else if (!CECUIConfig::Instance().GetGameUI().bEnablePlayerRename) //{ - // // δʾöԻ + // // 먦Æô¸ÄÃû·þÎñÔò²»ÏÔʾ¸Ã¶Ô»°¿ò // GetGameUIMan().ShowErrorMsg(10152); // GetGameUIMan().EndNPCService(); //} @@ -2666,7 +2820,7 @@ namespace BrewMonster.UI //GetGameUIMan().MessageBox("Faction_PVP_Open", strMsg, MB_YESNO, A3DCOLORRGBA(255, 255, 255, 160)); return; } - else if (iService == CDLGNPC.CDLGNPC_GOLD_SHOP + else if (iService == CDLGNPC.CDLGNPC_GOLD_SHOP && ((pEssence?.combined_services2 & 0x00010000) != 0 || (pEssence?.combined_services2 & 0x00020000) != 0)) { Show(false); @@ -2729,7 +2883,7 @@ namespace BrewMonster.UI NPC_TASK_OUT_SERVICE pService = (NPC_TASK_OUT_SERVICE)pData; if (!(pService.storage_id == 0 || pService.storage_open_item == 0)) { - PopupStorageTaskDialog(pService, false); + //PopupStorageTaskDialog(pService, false); return; } } @@ -2897,10 +3051,374 @@ namespace BrewMonster.UI } else { - object pData1 = m_pLst_Main.GetItemDataPtr(nCurSel, 0 ,""); + object pData1 = m_pLst_Main.GetItemDataPtr(nCurSel, 0, ""); PopupCorrespondingServiceDialog(idFunction, iService, pData1); } } } + + bool PopupCorrespondingServiceDialog(int idFunction, int iService, object pData) + { + AUIDialog pShow1 = null, pShow2 = null; + NPC_ESSENCE? pCurNPCEssence = GetGameUIMan().m_pCurNPCEssence; + + if (idFunction == (int)SERVICE_TYPE.NPC_SELL || idFunction == (int)SERVICE_TYPE.NPC_BUY) + { + //Button pButton; + + //pShow1 = m_pAUIManager.GetDialog("Win_Shop"); + //pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + + //GetHostPlayer().PrepareNPCService(iService); + //GetGameUIMan().m_pDlgShop.UpdateShop(1); + + //if (pCurNPCEssence && pCurNPCEssence.id_repair_service) + //{ + // pShow1.GetDlgItem("Btn_Repair").Show(true); + // pShow1.GetDlgItem("Btn_RepairAll").Show(true); + //} + //else + //{ + // pShow1.GetDlgItem("Btn_Repair").Show(false); + // pShow1.GetDlgItem("Btn_RepairAll").Show(false); + //} + + //pButton = (PAUISTILLIMAGEBUTTON)pShow2.GetDlgItem("Btn_NormalItem"); + //pButton.SetPushed(true); + //pButton = (PAUISTILLIMAGEBUTTON)pShow2.GetDlgItem("Btn_QuestItem"); + //pButton.SetPushed(false); + //GetGameUIMan().m_pDlgInventory.SetShowItem(CDlgInventory::INVENTORY_ITEM_NORMAL); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_INSTALL) + { + pShow1 = m_pAUIManager.GetDialog("Win_Enchase"); + pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_UNINSTALL) + { + pShow1 = m_pAUIManager.GetDialog("Win_Disenchase"); + pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_HEAL) + { + UnityGameSession.c2s_CmdNPCSevHeal(); + GetGameUIMan().EndNPCService(); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_TRANSMIT) + { + pShow1 = m_pAUIManager.GetDialog("Win_WorldMapTravel"); + //((CDlgWorldMap*)pShow1).BuildTravelMap(DT_NPC_TRANSMIT_SERVICE, pData); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_SKILL) + { + //string strText = m_pLst_Main.GetText(m_pLst_Main.GetCurSel()); + //string strHead = GetStringFromTable(249); + //string strComp = (strHead + GetStringFromTable(7107)); + //if (0 == a_stricmp(strText, strComp)) + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_ELFLearn"); + // ((CDlgELFLearn*)pShow1).SetNPCName(pCurNPCEssence.name); + // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + // GetHostPlayer().PrepareNPCService(iService); + // pShow1.SetData(DT_NPC_SKILL_SERVICE); + //} + //else + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_Teach"); + // GetHostPlayer().PrepareNPCService(iService); + // pShow1.SetData(DT_NPC_SKILL_SERVICE); + // GetGameUIMan().UpdateTeach(0); + //} + } + else if (idFunction == (int)SERVICE_TYPE.NPC_MAKE) + { + //NPC_MAKE_SERVICE pMake = (NPC_MAKE_SERVICE)pData; + //if (pMake.produce_type == 2) + // pShow1 = m_pAUIManager.GetDialog("Win_Produce1"); + //else + // pShow1 = m_pAUIManager.GetDialog("Win_Produce"); + //GetGameUIMan().m_pDlgProduce = (CDlgProduce*)pShow1; + //GetHostPlayer().PrepareNPCService(iService); + //pShow1.SetDataPtr(pMake, "ptr_NPC_MAKE_SERVICE"); + //if (pMake.produce_type == 1 || + // pMake.produce_type == 3 || + // pMake.produce_type == 4 || + // pMake.produce_type == 5) + // GetGameUIMan().m_pDlgProduce.ClearMaterial(); + //pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + //GetGameUIMan().m_pDlgProduce.UpdateProduce(1, 0); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_DECOMPOSE) + { + //pShow1 = m_pAUIManager.GetDialog("Win_Split"); + //pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + //pShow1.SetDataPtr(pData, "ptr_NPC_DECOMPOSE_SERVICE"); + + //PAUIPROGRESS pProgress; + //PAUIIMAGEPICTURE pImage; + + //pImage = (PAUIIMAGEPICTURE)pShow1.GetDlgItem("Item_a"); + //pImage.ClearCover(); + //pImage.SetDataPtr(NULL); + + //pImage = (PAUIIMAGEPICTURE)pShow1.GetDlgItem("Item_b"); + //pImage.ClearCover(); + //pImage.SetDataPtr(NULL); + + //pProgress = (PAUIPROGRESS)pShow1.GetDlgItem("Prgs_1"); + //pProgress.SetProgress(0); + + //pShow1.GetDlgItem("Btn_Start").Enable(false); + //pShow1.GetDlgItem("Btn_Cancel").Enable(true); + //pShow1.GetDlgItem("Txt_no1").SetText(_AL("")); + //pShow1.GetDlgItem("Txt_no2").SetText(_AL("")); + //pShow1.GetDlgItem("Txt_Gold").SetText(_AL("")); + //pShow1.GetDlgItem("Txt_SkillName").SetText(_AL("")); + //pShow1.GetDlgItem("Txt_SkillLevel").SetText(_AL("")); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_WAR_TOWERBUILD) + { + pShow1 = m_pAUIManager.GetDialog("Win_WarTower"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_RESETPROP) + { + pShow1 = m_pAUIManager.GetDialog("Win_ResetProp"); + pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_PETNAME) + { + pShow1 = m_pAUIManager.GetDialog("Win_PetRename"); + pShow2 = m_pAUIManager.GetDialog("Win_PetList"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_PETLEARNSKILL) + { + //CECPetCorral* pPetCorral = GetHostPlayer().GetPetCorral(); + //CECPetData* pPet = pPetCorral.GetActivePet(); + //if (!pPet) + //{ + // GetGameUIMan().MessageBox("", GetStringFromTable(814), MB_OK, A3DCOLORRGB(255, 255, 255)); + // GetGameUIMan().EndNPCService(); + //} + //else + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_Teach"); + // GetHostPlayer().PrepareNPCService(iService); + // pShow1.SetData(DT_NPC_PETLEARNSKILL_SERVICE); + // GetGameUIMan().UpdateTeach(0); + //} + } + else if (idFunction == (int)SERVICE_TYPE.NPC_PETFORGETSKILL) + { + //CECPetCorral* pPetCorral = GetHostPlayer().GetPetCorral(); + //CECPetData* pPet = pPetCorral.GetActivePet(); + //if (!pPet) + //{ + // GetGameUIMan().MessageBox("", GetStringFromTable(814), MB_OK, A3DCOLORRGB(255, 255, 255)); + // GetGameUIMan().EndNPCService(); + //} + //else + // pShow1 = m_pAUIManager.GetDialog("Win_PetRetrain"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_EQUIPBIND) + { + pShow1 = m_pAUIManager.GetDialog("Win_EquipBind"); + pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + pShow1.SetData((uint)pData, "ptr_NPC_EQUIPBIND_SERVICE"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_EQUIPDESTROY) + { + pShow1 = m_pAUIManager.GetDialog("Win_EquipDestroy"); + pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_EQUIPUNDESTROY) + { + pShow1 = m_pAUIManager.GetDialog("Win_EquipUndestroy"); + pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_IDENTIFY) + { + //PAUIIMAGEPICTURE pImage; + + //pShow1 = m_pAUIManager.GetDialog("Win_Identify"); + //pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + //pShow1.SetDataPtr(pData, "ptr_NPC_IDENTIFY_SERVICE"); + + //pImage = (PAUIIMAGEPICTURE)pShow1.GetDlgItem("Item"); + //pImage.ClearCover(); + //pImage.SetDataPtr(NULL); + + //pShow1.GetDlgItem("Txt").SetText(_AL("")); + //pShow1.GetDlgItem("Txt_Gold").SetText(_AL("")); + //pShow1.GetDlgItem("Btn_Confirm").Enable(false); + //pShow1.GetDlgItem("Btn_Cancel").Enable(true); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_GIVE_TASK) + { + talk_proc.option opt = (talk_proc.option)pData; + int idTask = (int)opt.param; + //if (g_pGame.GetConfigs().IsMiniClient() && CECUIConfig::Instance().GetGameUI().IsTaskDisabledInMiniClient(idTask)) + //{ + // GetGameUIMan().MessageBox("", GetStringFromTable(10714), MB_OK, A3DCOLORRGBA(255, 255, 255, 160)); + //} + //else + { + UnityGameSession.c2s_CmdNPCSevAcceptTask(idTask, 0, 0); + } + GetGameUIMan().EndNPCService(); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_COMPLETE_TASK) + { + AWARD_DATA ad = new AWARD_DATA(); + talk_proc.option opt = (talk_proc.option)pData; + CECTaskInterface pTask = GetHostPlayer().GetTaskInterface(); + + pTask.GetAwardCandidates(opt.param, ref ad); + if (ad.m_ulCandItems > 1) + { + pShow1 = m_pAUIManager.GetDialog("Win_Award"); + CDlgAward pAward = (pShow1) as CDlgAward; + if (pAward) pAward.UpdateAwardItem(opt.param, true); + } + else + { + UnityGameSession.c2s_CmdNPCSevReturnTask((int)opt.param, 0); + GetGameUIMan().EndNPCService(); + } + } + else if (idFunction == (int)SERVICE_TYPE.NPC_GIVE_TASK_MATTER) + { + talk_proc.option opt = (talk_proc.option)pData; + UnityGameSession.c2s_CmdNPCSevTaskMatter((int)opt.param); + GetGameUIMan().EndNPCService(); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_STORAGE) + { + //if (GetHostPlayer().TrashBoxHasPsw()) + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_InputString"); + // pShow1.GetDlgItem("DEFAULT_Txt_Input").SetText(_AL("")); + //} + //else + // g_pGame.GetGameSession().c2s_CmdNPCSevOpenTrash(""); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_STORAGE_PASSWORD) + { + pShow1 = m_pAUIManager.GetDialog("Win_InputString3"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_ACCOUNT_STORAGE) + { + //if (CECCrossServer::Instance().IsOnSpecialServer()) + //{ + // GetGameUIMan().ShowErrorMsg(10130); + // GetGameUIMan().EndNPCService(); + //} + //else g_pGame.GetGameSession().c2s_CmdNPCSevOpenAccountBox(); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_ENGRAVE) + { + pShow1 = m_pAUIManager.GetDialog("Win_Engrave"); + pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + } + else if (idFunction == (int)SERVICE_TYPE.NPC_RANDPROP) + { + pShow1 = m_pAUIManager.GetDialog("Win_RandProp"); + pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + GetHostPlayer().PrepareNPCService(iService); + pShow1.SetDataPtr(pData, "ptr_NPC_RANDPROP_SERVICE"); + } + else if (idFunction == (int)SERVICE_TYPE.TALK_RETURN) + { + OnCommand_back("back"); + return true; // To avoid to close NPC dialog. + } + else if (idFunction == (int)SERVICE_TYPE.TALK_EXIT) + { + GetGameUIMan().EndNPCService(); + + int idCurFinishTask = GetGameUIMan().m_idCurFinishTask; + if (GetData() == NPC_DIALOG.NPC_DIALOG_TASK_TALK && idCurFinishTask > 0) + { + GetHostPlayer().GetTaskInterface().OnUIDialogEnd((uint)idCurFinishTask); + GetGameUIMan().m_idCurFinishTask = -1; + } + } + else if (idFunction == (int)SERVICE_TYPE.TALK_GIVEUP_TASK) + { + talk_proc.option opt = (talk_proc.option)pData; + GetHostPlayer().GetTaskInterface().GiveUpTask(opt.param); + GetGameUIMan().EndNPCService(); + } + else + { + //GetHostPlayer().GetPack(IVTRTYPE_PACK).UnfreezeAllItems(); + GetGameUIMan().EndNPCService(); + } + + if (pShow1) + { + DATA_TYPE DataType = new DATA_TYPE(); + elementdataman pDataMan = EC_Game.GetElementDataMan(); + + pDataMan.get_data_ptr((uint)iService, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + + pShow1.Show(true); + + if (pShow2) + { + //POINT ptPos = pShow1.GetPos(); + //if (ptPos.x == 0 && ptPos.y == 0) + //{ + // SIZE s1 = pShow1.GetSize(); + // SIZE s2 = pShow2.GetSize(); + // A3DVIEWPORTPARAM* p = m_pA3DEngine.GetActiveViewport().GetParam(); + // int x, y = (p.Height - max(s1.cy, s2.cy)) / 2; + + // x = (p.Width - s1.cx - s2.cx) / 2; + + // // old : pShow1.SetPos(x, y); + // pShow1.SetPosEx(x, y); + + // x += s1.cx; + + // // old : pShow2.SetPos(x, y); + // pShow2.SetPosEx(x, y); + //} + + pShow2.Show(true); + } + } + Show(false); + + return true; + } + + //void PopupStorageTaskDialog(NPC_TASK_OUT_SERVICE pService, bool bTaskNPC) + //{ + // NPC_ESSENCE? pCurNPCEssence = GetGameUIMan().m_pCurNPCEssence; + + // if (GetHostPlayer().GetPack().GetItemTotalNum(pService.storage_open_item) > 0) + // { + // Show(false); + + // PAUIDIALOG pDlg = GetGameUIMan().GetDialog("Win_QuestList"); + // if (pDlg) + // { + // pDlg.Show(true); + // } + // else // in case the dialog is missing or name changed... + // { + // GetGameUIMan().EndNPCService(); + // } + // } + // else + // { + // EC_IvtrItem pItem = CECIvtrItem::CreateItem(pService.storage_open_item, 0, 1); + // string szMsg; + // // cannot open storage task + // m_pLst_Main.ResetContent(); + // m_pTxt_Content.SetText(bTaskNPC ? pCurNPCEssence.hello_msg : szMsg.Format(GetStringFromTable(984), pItem.GetName())); + // SetData(NPC_DIALOG_TASK_LIST); + // } + //} } } diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/ItemUIListBox.cs b/Assets/PerfectWorld/Scripts/UI/Dialogs/ItemUIListBox.cs index 0c94883f22..79e3e7e0dd 100644 --- a/Assets/PerfectWorld/Scripts/UI/Dialogs/ItemUIListBox.cs +++ b/Assets/PerfectWorld/Scripts/UI/Dialogs/ItemUIListBox.cs @@ -9,6 +9,8 @@ namespace BrewMonster public string[] strDataName = new string[20]; public string[] strDataPtrName = new string[20]; + public string[] strData64Name = new string[20]; + public ulong[] uiData64 = new ulong[20]; public uint[] dwData = new uint[20]; public object[] pvData = new object[20]; diff --git a/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs b/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs index 86657af0a7..d7b32064e5 100644 --- a/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs +++ b/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs @@ -14,6 +14,7 @@ namespace BrewMonster.UI { DlgNPC m_pDlgNPC; public NPC_ESSENCE? m_pCurNPCEssence; + public int m_idCurFinishTask = -1; public static bool TALKPROC_IS_TERMINAL(uint id) { diff --git a/Assets/Scripts/CECHostPlayer.cs b/Assets/Scripts/CECHostPlayer.cs index 54b260dedc..463ae8d666 100644 --- a/Assets/Scripts/CECHostPlayer.cs +++ b/Assets/Scripts/CECHostPlayer.cs @@ -22,6 +22,7 @@ using System.Xml.Linq; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; +using static BrewMonster.Scripts.Managers.EC_Inventory; using Host_work_ID = BrewMonster.Scripts.CECHPWork.Host_work_ID; using Trace_reason = CECHPWorkTrace.Trace_reason; From ceec82ffc572af9f0873d0100944567edd955110 Mon Sep 17 00:00:00 2001 From: Tungdv Date: Thu, 20 Nov 2025 18:18:06 +0700 Subject: [PATCH 4/5] fix: update logic select option in dlgnpc. --- .../Scripts/UI/Dialogs/AUIListBox.cs | 24 +++++++++++++ .../PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs | 35 ++++++++++--------- .../Scripts/UI/Dialogs/ItemUIListBox.cs | 20 ++++++++++- Assets/Scripts/CECHostPlayer.cs | 4 +-- 4 files changed, 63 insertions(+), 20 deletions(-) diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIListBox.cs b/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIListBox.cs index 61e23921be..5d9f6b9387 100644 --- a/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIListBox.cs +++ b/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIListBox.cs @@ -15,6 +15,7 @@ namespace BrewMonster.UI List m_Item = new List(); int m_nCurSel = 0; + Action m_OnClickBtn = null; const uint AUILISTBOX_ERROR = 0xFFFFFFFF; // same as -1 for uint public void ResetContent() @@ -28,6 +29,11 @@ namespace BrewMonster.UI content.sizeDelta = Vector2.zero; } + public void SetActionOnClickBtnItem(Action onClick) + { + m_OnClickBtn = onClick; + } + public void AddString(string pszString) { ItemUIListBox item = Instantiate(prefabItemUIListBox, content); @@ -47,6 +53,8 @@ namespace BrewMonster.UI return -1; m_Item[nIndex].strDataName[nSubIndex] = strName; m_Item[nIndex].dwData[nSubIndex] = dwItemData; + + m_Item[nIndex].SetActOnClickBtn(m_OnClickBtn, nIndex); return nIndex; } @@ -59,6 +67,8 @@ namespace BrewMonster.UI m_Item[nIndex].strDataPtrName[nSubIndex] = strName; m_Item[nIndex].pvData[nSubIndex] = pData; + + m_Item[nIndex].SetActOnClickBtn(m_OnClickBtn, nIndex); return nIndex; } @@ -71,9 +81,23 @@ namespace BrewMonster.UI m_Item[nIndex].strData64Name[nSubIndex] = strName; m_Item[nIndex].uiData64[nSubIndex] = pData; + + m_Item[nIndex].SetActOnClickBtn(m_OnClickBtn, nIndex); return nIndex; } + public ulong GetItemData64(int nIndex, int nSubIndex, string strName) + { + if (nIndex < 0 || nIndex >= (m_Item.Count)) + return AUILISTBOX_ERROR; + if (nSubIndex < 0 || nSubIndex >= 20) // AUILISTBOX_DATA_NUM 20 + return AUILISTBOX_ERROR; + + //if (0 != m_Item[nIndex].uiData64[nSubIndex] && strName != m_Item[nIndex].strData64Name[nSubIndex]) + // AUI_ReportError(__LINE__, 1, "AUIListBox::GetItemData64(), data name not match"); + return m_Item[nIndex].uiData64[nSubIndex]; + } + public int GetCount() { return m_Item.Count; diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs index cef931770d..f8563a1399 100644 --- a/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs +++ b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs @@ -159,18 +159,18 @@ namespace BrewMonster.UI } } } - //if (GetData() == NPC_DIALOG.NPC_DIALOG_TASK_LIST) - //{ - // for (int i = 0; i < m_pLst_Main.GetCount() - 1; ++i) - // { - // UINT64 taskid = m_pLst_Main.GetItemData64(i, 0, "TaskID"); - // if (taskid == m_iTracedTaskID) - // { - // SelectListItem(i); - // return GetData() == NPC_DIALOG.NPC_DIALOG_TASK_TALK; - // } - // } - //} + if (GetData() == NPC_DIALOG.NPC_DIALOG_TASK_LIST) + { + for (int i = 0; i < m_pLst_Main.GetCount() - 1; ++i) + { + ulong taskid = m_pLst_Main.GetItemData64(i, 0, "TaskID"); + if (taskid == (ulong)m_iTracedTaskID) + { + SelectListItem(i); + return GetData() == NPC_DIALOG.NPC_DIALOG_TASK_TALK; + } + } + } return false; } @@ -271,6 +271,7 @@ namespace BrewMonster.UI //m_pLst_Main.SetHOver(true); m_pLst_Main.ResetContent(); + m_pLst_Main.SetActionOnClickBtnItem((int value) => { SelectListItem(value); }); //add for test by czx @@ -1628,8 +1629,8 @@ namespace BrewMonster.UI if (ad.m_ulCandItems > 1) { pShow1 = m_pAUIManager.GetDialog("Win_Award"); - CDlgAward pAward = (pShow1) as CDlgAward; - if (pAward) pAward.UpdateAwardItem(opt.param, true); + //CDlgAward pAward = (pShow1) as CDlgAward; + //if (pAward) pAward.UpdateAwardItem(opt.param, true); } else { @@ -2871,7 +2872,7 @@ namespace BrewMonster.UI int idFunction = 0, id_dialog = 0; object pData = m_pLst_Main.GetItemDataPtr(nCurSel, 0, ""); - EC_Game.GetElementDataMan().get_data_ptr((uint)iService, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + ElementDataManProvider.GetElementDataMan().get_data_ptr((uint)iService, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); if (DataType == DATA_TYPE.DT_NPC_TASK_IN_SERVICE || DataType == DATA_TYPE.DT_NPC_TASK_OUT_SERVICE || @@ -3276,8 +3277,8 @@ namespace BrewMonster.UI if (ad.m_ulCandItems > 1) { pShow1 = m_pAUIManager.GetDialog("Win_Award"); - CDlgAward pAward = (pShow1) as CDlgAward; - if (pAward) pAward.UpdateAwardItem(opt.param, true); + //CDlgAward pAward = (pShow1) as CDlgAward; + //if (pAward) pAward.UpdateAwardItem(opt.param, true); } else { diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/ItemUIListBox.cs b/Assets/PerfectWorld/Scripts/UI/Dialogs/ItemUIListBox.cs index 79e3e7e0dd..5e2e927b2f 100644 --- a/Assets/PerfectWorld/Scripts/UI/Dialogs/ItemUIListBox.cs +++ b/Assets/PerfectWorld/Scripts/UI/Dialogs/ItemUIListBox.cs @@ -1,5 +1,7 @@ +using System; using TMPro; using UnityEngine; +using UnityEngine.UI; namespace BrewMonster { @@ -13,13 +15,29 @@ namespace BrewMonster public ulong[] uiData64 = new ulong[20]; public uint[] dwData = new uint[20]; public object[] pvData = new object[20]; - + public int indexItem; public string strText; + Button btnItem = null; + public void OnEnable() + { + if(btnItem == null) + { + btnItem = GetComponent