fix: update logic select option in dlg npc.

This commit is contained in:
Tungdv
2025-11-18 19:01:03 +07:00
parent 6f3a509534
commit bb28c8505d
5 changed files with 391 additions and 300 deletions
@@ -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<CONTENT_ACCEPT_TASK>()
};
return SerializeCommand(CommandID.SEVNPC_SERVE, cmd);
}
}
}
@@ -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;
}
}
}
+72 -64
View File
@@ -143,43 +143,43 @@ namespace PerfectWorld.Scripts.Task
}
return null;
}
// const ATaskTempl* GetCap() const { return reinterpret_cast<const ATaskTempl*>(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<const ATaskTempl*>(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;
}
};
}
+97 -16
View File
@@ -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<uint>(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<int>(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<uint>(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<uint>(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<byte>(fp, ref readBytes) > 0;
logContent += $"m_bAwardDeath: {ad.m_bAwardDeath} \n";
@@ -3198,7 +3214,7 @@ namespace BrewMonster.Scripts.Task
ad.m_ulPQRankingAwardCnt = AAssit.ReadFromBinaryOf<uint>(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<uint>(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<uint>(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<byte>(fp, ref readBytes) > 0;
@@ -3229,21 +3245,21 @@ namespace BrewMonster.Scripts.Task
ad.m_ulDisplayKeyCnt = AAssit.ReadFromBinaryOf<uint>(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<uint>(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<uint>(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<int>(fp, ref readBytes);
@@ -3260,7 +3276,7 @@ namespace BrewMonster.Scripts.Task
ad.m_ulTitleNum = AAssit.ReadFromBinaryOf<uint>(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<int>(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_ulScales; i++)
{
if (ratio <= p.m_Ratios[i])
{
pAward = p.m_Awards[i];
return;
}
}
}
public void CalcAwardDataByItems(
TaskInterface pTask,
ref AWARD_DATA pAward,
ActiveTaskEntry pEntry)
{
AWARD_ITEMS_SCALE p = (pEntry.IsSuccess() ? m_AwByItems_S : m_AwByItems_F);
uint ulCount = (uint)pTask.GetTaskItemCount(p.m_ulItemId), i;
for (i = 0; i < p.m_ulScales; i++)
{
if (ulCount >= p.m_Counts[i])
{
pAward = p.m_Awards[i];
return;
}
}
}
}
}
+204 -203
View File
@@ -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<TASK_ITEM> 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<TASK_ITEM> 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<TASK_ITEM>* a_uiTasks[] = { &taskIn, &taskOut, &taskMatter };
//for (int idx = 0; idx < sizeof(a_uiTasks) / sizeof(a_uiTasks[0]); idx++)
//{
// abase::vector<TASK_ITEM>::iterator it;
// for (it = a_uiTasks[idx].begin(); it != a_uiTasks[idx].end(); ++it)
// {
// idTask = it.task_id;
m_pLst_Main.ResetContent();
abase::vector<TASK_ITEM>* a_uiTasks[] = { &taskIn, &taskOut, &taskMatter };
for (int idx = 0; idx < sizeof(a_uiTasks) / sizeof(a_uiTasks[0]); idx++)
{
abase::vector<TASK_ITEM>::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<CDlgAward*>(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;
}
}