Fix reach site notify task

This commit is contained in:
HungDK
2026-01-05 16:37:25 +07:00
parent a933d34a20
commit 6eb046ec29
2 changed files with 59 additions and 22 deletions
@@ -873,8 +873,7 @@ namespace BrewMonster.Scripts.Task
pos[2] = vPos.z;
}
var world = World.CECWorld.Instance;
//TODO: world.GetInstanceID()
return world != null ? 0 /*world.GetInstanceID()*/ : 0;
return world != null ? world.GetInstanceID() : 0;
}
public bool CheckSimpleTaskFinshConditon(uint task_id)
+58 -20
View File
@@ -167,24 +167,43 @@ namespace BrewMonster.Scripts.Task
{
for (uint iRegion = 0; iRegion < pTempl.m_FixedData.m_ulReachSiteCnt; iRegion++)
{
Task_Region t = pTempl.m_FixedData.m_pReachSite[(int)iRegion];
if (IsInZone(t.zvMin, t.zvMax, pos))
Task_Region t = pTempl.m_FixedData.m_pReachSite[(int)iRegion];
if (IsInZone(t.zvMin, t.zvMax, pos))
{
var pTalk = pTempl.m_AwardTalk;
// If num_window == 1 but windows is null/empty, treat as no options (send notification)
bool shouldNotifyDirectly = false;
if (pTalk.num_window == 0)
{
var pTalk = pTempl.m_AwardTalk;
if (pTalk.num_window == 0 || (pTalk.num_window == 1 && pTalk.windows != null && pTalk.windows.Length > 0 && pTalk.windows[0].num_option == 0))
{
pTempl.IncValidCount();
_notify_svr(pTask, ClientNotificationConstants.TASK_CLT_NOTIFY_REACH_SITE, (ushort)pTempl.GetID());
}
else
{
// TODO: PopupTaskFinishDialog not exposed; implement UI as needed
s_finishDlgShownTime = ulCurTime;
}
break;
shouldNotifyDirectly = true;
}
else if (pTalk.num_window == 1)
{
if (pTalk.windows == null || pTalk.windows.Length == 0)
{
// Invalid state: num_window == 1 but windows is null/empty - treat as no options
shouldNotifyDirectly = true;
}
else if (pTalk.windows[0].num_option == 0)
{
shouldNotifyDirectly = true;
}
}
if (shouldNotifyDirectly)
{
pTempl.IncValidCount();
_notify_svr(pTask, (byte)ClientNotificationConstants.TASK_CLT_NOTIFY_REACH_SITE, (ushort)pTempl.GetID());
}
else
{
// TODO: PopupTaskFinishDialog not exposed; implement UI as needed
s_finishDlgShownTime = ulCurTime;
}
break;
}
}
}
continue;
}
@@ -195,16 +214,16 @@ namespace BrewMonster.Scripts.Task
if (ulCurTime - s_finishDlgShownTime < FINISH_DLG_SHOWN_TIME)
continue;
float[] pos = new float[3];
uint ulWorldId = (uint)pTask.GetPos(pos);
float[] leavePos = new float[3];
uint leaveWorldId = (uint)pTask.GetPos(leavePos);
bool regRet = false;
if (ulWorldId == pTempl.m_FixedData.m_ulLeaveSiteId)
if (leaveWorldId == pTempl.m_FixedData.m_ulLeaveSiteId)
{
for (uint iRegion = 0; iRegion < pTempl.m_FixedData.m_ulLeaveSiteCnt; iRegion++)
{
Task_Region t = pTempl.m_FixedData.m_pLeaveSite[(int)iRegion];
if (IsInZone(t.zvMin, t.zvMax, pos))
if (IsInZone(t.zvMin, t.zvMax, leavePos))
{
regRet = true;
break;
@@ -214,10 +233,29 @@ namespace BrewMonster.Scripts.Task
if (!regRet)
{
var pTalk = pTempl.m_AwardTalk;
if (pTalk.num_window == 0 || (pTalk.num_window == 1 && pTalk.windows != null && pTalk.windows.Length > 0 && pTalk.windows[0].num_option == 0))
// If num_window == 1 but windows is null/empty, treat as no options (send notification)
bool shouldNotifyDirectly = false;
if (pTalk.num_window == 0)
{
shouldNotifyDirectly = true;
}
else if (pTalk.num_window == 1)
{
if (pTalk.windows == null || pTalk.windows.Length == 0)
{
// Invalid state: num_window == 1 but windows is null/empty - treat as no options
shouldNotifyDirectly = true;
}
else if (pTalk.windows[0].num_option == 0)
{
shouldNotifyDirectly = true;
}
}
if (shouldNotifyDirectly)
{
pTempl.IncValidCount();
_notify_svr(pTask, ClientNotificationConstants.TASK_CLT_NOTIFY_LEAVE_SITE, (ushort)pTempl.GetID());
_notify_svr(pTask, (byte)ClientNotificationConstants.TASK_CLT_NOTIFY_LEAVE_SITE, (ushort)pTempl.GetID());
}
else
{