321 lines
15 KiB
C#
321 lines
15 KiB
C#
using BrewMonster.Network;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace PerfectWorld.Scripts.Task
|
|
{
|
|
public class TaskInterfaceConstants
|
|
{
|
|
// Task Prerequisite Error Code
|
|
public const int TASK_PREREQU_FAIL_INDETERMINATE = 1;
|
|
public const int TASK_PREREQU_FAIL_NOT_ROOT = 2;
|
|
public const int TASK_PREREQU_FAIL_SAME_TASK = 3;
|
|
public const int TASK_PREREQU_FAIL_NO_SPACE = 4;
|
|
public const int TASK_PREREQU_FAIL_FULL = 5;
|
|
public const int TASK_PREREQU_FAIL_CANT_REDO = 6;
|
|
public const int TASK_PREREQU_FAIL_BELOW_LEVEL = 7;
|
|
public const int TASK_PREREQU_FAIL_ABOVE_LEVEL = 8;
|
|
public const int TASK_PREREQU_FAIL_NO_ITEM = 9;
|
|
public const int TASK_PREREQU_FAIL_BELOW_REPU = 10;
|
|
public const int TASK_PREREQU_FAIL_CLAN = 11;
|
|
public const int TASK_PREREQU_FAIL_WRONG_GENDER = 12;
|
|
public const int TASK_PREREQU_FAIL_NOT_IN_OCCU = 13;
|
|
public const int TASK_PREREQU_FAIL_WRONG_PERIOD = 14;
|
|
public const int TASK_PREREQU_FAIL_PREV_TASK = 15;
|
|
public const int TASK_PREREQU_FAIL_MAX_RCV = 16;
|
|
public const int TASK_PREREQU_FAIL_NO_DEPOSIT = 17;
|
|
public const int TASK_PREREQU_FAIL_NO_TASK = 18;
|
|
public const int TASK_PREREQU_FAIL_NOT_CAPTAIN = 19;
|
|
public const int TASK_PREREQU_FAIL_ILLEGAL_MEM = 20;
|
|
public const int TASK_PREREQU_FAIL_WRONG_TIME = 21;
|
|
public const int TASK_PREREQU_FAIL_NO_SUCH_SUB = 22;
|
|
public const int TASK_PREREQU_FAIL_MUTEX_TASK = 23;
|
|
public const int TASK_PREREQU_FAIL_NOT_IN_ZONE = 24;
|
|
public const int TASK_PREREQU_FAIL_WRONG_SUB = 25;
|
|
public const int TASK_PREREQU_FAIL_OUTOF_DIST = 26;
|
|
public const int TASK_PREREQU_FAIL_GIVEN_ITEM = 27;
|
|
public const int TASK_PREREQU_FAIL_LIVING_SKILL = 28;
|
|
public const int TASK_PREREQU_FAIL_SPECIAL_AWARD = 29;
|
|
public const int TASK_PREREQU_FAIL_GM = 30;
|
|
public const int TASK_PREREQU_FAIL_GLOBAL_KEYVAL = 31;
|
|
public const int TASK_PREREQU_FAIL_SHIELD_USER = 32;
|
|
public const int TASK_PREREQU_FAIL_ALREADY_HAS_PQ = 33;
|
|
public const int TASK_PREREQU_FAIL_MAX_ACC_CNT = 34;
|
|
public const int TASK_PREREQU_FAIL_RMB_NOT_ENOUGH = 35;
|
|
public const int TASK_PREREQU_FAIL_NOT_COUPLE = 36;
|
|
public const int TASK_PREREQU_FAIL_ERR_CHAR_TIME = 37;
|
|
public const int TASK_PREREQU_FAIL_NOT_IVTRSLOTNUM = 38; // version 81
|
|
public const int TASK_PREREQU_FAIL_BELOW_FACTION_CONTRIB = 39; // version 87
|
|
public const int TASK_PREREQU_FAIL_BELOW_RECORD_TASKS_NUM = 40; // version 91
|
|
public const int TASK_PREREQU_FAIL_OVER_RECEIVE_PER_DAY = 41;
|
|
public const int TASK_PREREQU_FAIL_TRANSFORM_MASK = 42;
|
|
public const int TASK_PREREQU_FAIL_FORCE = 43;
|
|
public const int TASK_PREREQU_FAIL_FORCE_REPUTATION = 44;
|
|
public const int TASK_PREREQU_FAIL_FORCE_CONTRIBUTION = 45;
|
|
public const int TASK_PREREQU_FAIL_EXP = 46;
|
|
public const int TASK_PREREQU_FAIL_SP = 47;
|
|
public const int TASK_PREREQU_FAIL_FORCE_AL = 48;
|
|
public const int TASK_PREREQU_FAIL_WEDDING_OWNER = 49;
|
|
public const int TASK_PREREQU_FAIL_CROSSSERVER_NO_ACOUNT_LIMIT = 50;
|
|
public const int TASK_PREREQU_FAIL_CROSSSERVER_NO_MARRIAGE = 51;
|
|
public const int TASK_PREREQU_FAIL_CROSSSERVER_NO_FORCE = 52;
|
|
public const int TASK_PREREQU_FAIL_KING = 53;
|
|
public const int TASK_PREREQU_FAIL_IN_TEAM = 54;
|
|
public const int TASK_PREREQU_FAIL_TITLE = 55;
|
|
public const int TASK_PREREQU_FAIL_HISTORYSTAGE = 56;
|
|
public const int TASK_PREREQU_FAIL_NO_GIFTCARD_TASK = 57;
|
|
public const int TASK_PREREQU_FAIL_BELOW_REINCARNATION = 57;
|
|
public const int TASK_PREREQU_FAIL_ABOVE_REINCARNATION = 58;
|
|
public const int TASK_PREREQU_FAIL_BELOW_REALMLEVEL = 59;
|
|
public const int TASK_PREREQU_FAIL_ABOVE_REALMLEVEL = 60;
|
|
public const int TASK_PREREQU_FAIL_REALM_EXP_FULL = 61;
|
|
public const int TASK_PREREQU_FAIL_CARD_COUNT_COLLECTION = 62;
|
|
public const int TASK_PREREQU_FAIL_MAX_ROLE_CNT = 63;
|
|
public const int TASK_PREREQU_FAIL_CARD_COUNT_RANK = 64;
|
|
public const int TASK_PREREQU_FAIL_TASK_FORBID = 65;
|
|
public const int TASK_PREREQU_FAIL_NO_NAVIGATE_INSHPAED = 66;
|
|
|
|
public const int TASK_AWARD_FAIL_GIVEN_ITEM = 150;
|
|
public const int TASK_AWARD_FAIL_NEW_TASK = 151;
|
|
public const int TASK_AWARD_FAIL_REPUTATION = 152;
|
|
public const int TASK_AWARD_FAIL_GLOBAL_KEYVAL = 153;
|
|
public const int TASK_AWARD_FAIL_CROSSSERVER_NO_ACOUNT_LIMIT = 154;
|
|
public const int TASK_AWARD_FAIL_CROSSSERVER_NO_ACOUNT_STORAGE = 155;
|
|
public const int TASK_AWARD_FAIL_CROSSSERVER_NO_DIVORCE = 156;
|
|
public const int TASK_AWARD_FAIL_CROSSSERVER_NO_FACTION_RALATED = 157;
|
|
public const int TASK_AWARD_FAIL_CROSSSERVER_NO_FORCE_RALATED = 158;
|
|
public const int TASK_AWARD_FAIL_CROSSSERVER_NO_DIVIEND = 159;
|
|
public const int TASK_AWARD_FAIL_LEVEL_CHECK = 160;
|
|
|
|
|
|
// Task messages
|
|
public const int TASK_MSG_NEW = 1;
|
|
public const int TASK_MSG_SUCCESS = 2;
|
|
public const int TASK_MSG_FAIL = 3;
|
|
|
|
public const int TASK_ACTIVE_LIST_HEADER_LEN = 8;
|
|
public const int TASK_ACTIVE_LIST_MAX_LEN = 175;
|
|
public const int TASK_FINISHED_LIST_MAX_LEN = 2040;
|
|
public const int TASK_DATA_BUF_MAX_LEN = 32;
|
|
public const int TASK_FINISH_TIME_MAX_LEN = 1700;
|
|
public const int TASK_FINISH_COUNT_MAX_LEN = 730;
|
|
|
|
// 库任务 // Library tasks
|
|
public const int TASK_MAX_DELIVER_COUNT = 5;
|
|
public const int TASK_STORAGE_COUNT = 32;
|
|
public const int TASK_STORAGE_LEN = 10;
|
|
public const int TASK_STORAGE_WHELL_SCALE = 10000; // 10000.f originally
|
|
|
|
// 当前激活的任务列表缓冲区大小 // Current active task list buffer size
|
|
public const int TASK_ACTIVE_LIST_BUF_SIZE = (TASK_ACTIVE_LIST_MAX_LEN * TASK_DATA_BUF_MAX_LEN + TASK_ACTIVE_LIST_HEADER_LEN);
|
|
// 已完成的任务列表缓冲区大小 // Completed task list buffer size
|
|
public const int TASK_FINISHED_LIST_BUF_SIZE = 8192;
|
|
public const int TASK_FINISHED_LIST_BUF_SIZE_OLD = 4096;
|
|
// 任务全局数据大小 // Task global data size
|
|
public const int TASK_GLOBAL_DATA_SIZE = 256;
|
|
// 任务完成时间 // Task completion time
|
|
public const int TASK_FINISH_TIME_LIST_BUF_SIZE = 10240;
|
|
//任务完成次数 // Task completion count
|
|
public const int TASK_FINISH_COUNT_LIST_BUF_SIZE = 10240;
|
|
// 库任务 // Library tasks
|
|
public const int TASK_STORAGE_LIST_BUF_SIZE = 1024;
|
|
|
|
|
|
// Masks
|
|
public const int TASK_MASK_KILL_MONSTER = 0x00000001;
|
|
public const int TASK_MASK_COLLECT_ITEM = 0x00000002;
|
|
public const int TASK_MASK_TALK_TO_NPC = 0x00000004;
|
|
public const int TASK_MASK_REACH_SITE = 0x00000008;
|
|
public const int TASK_MASK_ANSWER_QUESTION = 0x00000010;
|
|
public const int TASK_MASK_TINY_GAME = 0x00000020;
|
|
public const int TASK_MASK_KILL_PQ_MONSTER = 0x00000040;
|
|
public const int TASK_MASK_KILL_PLAYER = 0x00000080;
|
|
|
|
|
|
public const int MAX_MONSTER_WANTED = 3; // 受ActiveTaskEntry大小限制,最大3 // Limited by ActiveTaskEntry size, max 3
|
|
public const int MAX_PLAYER_WANTED = MAX_MONSTER_WANTED;
|
|
public const int MAX_ITEM_WANTED = 10;
|
|
public const int MAX_ITEM_AWARD = 64;
|
|
public const int MAX_MONSTER_SUMMONED = 32; // 最大召唤出的怪物数量 // Maximum number of summoned monsters
|
|
|
|
public const int MAX_OCCUPATIONS = 12; // 职业 // Occupations
|
|
|
|
public const int TASK_MSG_CHANNEL_LOCAL = 0;
|
|
public const int TASK_MSG_CHANNEL_WORLD = 1;
|
|
public const int TASK_MSG_CHANNEL_BROADCAST = 9;
|
|
|
|
public const int TASK_TEAM_RELATION_MARRIAGE = 1;
|
|
|
|
public const int TASK_AWARD_MAX_CHANGE_VALUE = 255;
|
|
public const int TASK_AWARD_MAX_DISPLAY_VALUE = 64;
|
|
|
|
public const int TASK_AWARD_MAX_DISPLAY_EXP_CNT = 32; // 表达式的个数 // Number of expressions
|
|
public const int TASK_AWARD_MAX_DISPLAY_CHAR_LEN = 64; // 表达式的长度 // Length of expression
|
|
|
|
public const int TASK_WORLD_CONTRIBUTION_SPEND_PER_DAY = 30; // 免费玩家每日消费贡献度上限 // Daily contribution spend cap for free players
|
|
|
|
}
|
|
|
|
|
|
public class CECTaskInterface : TaskInterface
|
|
{
|
|
public const int TASK_MAX_DELIVER_COUNT = 5;
|
|
public const int TASK_STORAGE_COUNT = 32;
|
|
public const int TASK_STORAGE_LEN = 10;
|
|
public const float TASK_STORAGE_WHELL_SCALE = 10000;
|
|
|
|
public const int TASK_ACTIVE_LIST_HEADER_LEN = 8;
|
|
public const int TASK_ACTIVE_LIST_MAX_LEN = 175;
|
|
public const int TASK_FINISHED_LIST_MAX_LEN = 2040;
|
|
public const int TASK_DATA_BUF_MAX_LEN = 32;
|
|
public const int TASK_FINISH_TIME_MAX_LEN = 1700;
|
|
public const int TASK_FINISH_COUNT_MAX_LEN = 730;
|
|
|
|
// µ±Ç°¼¤»îµÄÈÎÎñÁÐ±í»º³åÇø´óС
|
|
public int TASK_ACTIVE_LIST_BUF_SIZE =>
|
|
(TASK_ACTIVE_LIST_MAX_LEN * TASK_DATA_BUF_MAX_LEN + TASK_ACTIVE_LIST_HEADER_LEN);
|
|
|
|
CECHostPlayer m_pHost;
|
|
ActiveTaskList m_pActiveListBuf; // Active task list buffer
|
|
object[] m_pFinishedListBuf; // Finished task list buffer
|
|
object[] m_pFinishedTimeListBuf; // Finished time list buffer
|
|
object[] m_pFinishedCountListBuf;// Finished count list buffer
|
|
object[] m_pStorageTaskListBuf; // Storage tasks list buffer
|
|
private Dictionary<int, bool> m_TasksToConfirm = new Dictionary<int, bool>();
|
|
|
|
public CECTaskInterface()
|
|
{
|
|
|
|
}
|
|
public CECTaskInterface(CECHostPlayer pHost)
|
|
{
|
|
m_pHost = pHost;
|
|
|
|
m_pActiveListBuf = null;
|
|
m_pFinishedListBuf = null;
|
|
m_pFinishedTimeListBuf = null;
|
|
m_pFinishedCountListBuf = null;
|
|
m_pStorageTaskListBuf = null;
|
|
}
|
|
|
|
public bool Init(object[] pActiveListBuf, int iActiveListLen, object[] pFinishedListBuf, int iFinishedListLen, object[] pFinishedTimeListBuf, int iFinishedTimeListLen, object[] pFinishedCountListBuf, int iFinishedCountListLen, object[] pStorageTaskListBuf, int iStorageTaskListLen)
|
|
{
|
|
// if (!(m_pActiveListBuf = a_malloc(TASK_ACTIVE_LIST_BUF_SIZE)))
|
|
// {
|
|
// glb_ErrorOutput(ECERR_NOTENOUGHMEMORY, "CECTaskInterface::Init", __LINE__);
|
|
// return false;
|
|
// }
|
|
|
|
//if (!(m_pFinishedListBuf = a_malloc(TASK_FINISHED_LIST_BUF_SIZE)))
|
|
//{
|
|
// a_free(m_pActiveListBuf);
|
|
// m_pFinishedListBuf = NULL;
|
|
// glb_ErrorOutput(ECERR_NOTENOUGHMEMORY, "CECTaskInterface::Init", __LINE__);
|
|
// return false;
|
|
//}
|
|
|
|
//if (!(m_pFinishedTimeListBuf = a_malloc(TASK_FINISH_TIME_LIST_BUF_SIZE)))
|
|
//{
|
|
// a_free(m_pActiveListBuf);
|
|
// a_free(m_pFinishedListBuf);
|
|
// glb_ErrorOutput(ECERR_NOTENOUGHMEMORY, "CECTaskInterface::Init", __LINE__);
|
|
// return false;
|
|
//}
|
|
|
|
//if (!(m_pFinishedCountListBuf = a_malloc(TASK_FINISH_COUNT_LIST_BUF_SIZE)))
|
|
//{
|
|
// a_free(m_pActiveListBuf);
|
|
// a_free(m_pFinishedListBuf);
|
|
// a_free(m_pFinishedCountListBuf);
|
|
// glb_ErrorOutput(ECERR_NOTENOUGHMEMORY, "CECTaskInterface::Init", __LINE__);
|
|
// return false;
|
|
//}
|
|
|
|
//if (!(m_pStorageTaskListBuf = a_malloc(TASK_STORAGE_LIST_BUF_SIZE)))
|
|
//{
|
|
// a_free(m_pActiveListBuf);
|
|
// a_free(m_pFinishedListBuf);
|
|
// a_free(m_pFinishedCountListBuf);
|
|
// a_free(m_pStorageTaskListBuf);
|
|
// glb_ErrorOutput(ECERR_NOTENOUGHMEMORY, "CECTaskInterface::Init", __LINE__);
|
|
// return false;
|
|
//}
|
|
//ASSERT(pActiveListBuf && pFinishedListBuf && pFinishedTimeListBuf && pFinishedCountListBuf);
|
|
//memcpy(m_pActiveListBuf, pActiveListBuf, iActiveListLen);
|
|
//memcpy(m_pFinishedListBuf, pFinishedListBuf, iFinishedListLen);
|
|
//memcpy(m_pFinishedTimeListBuf, pFinishedTimeListBuf, iFinishedTimeListLen);
|
|
//memcpy(m_pFinishedCountListBuf, pFinishedCountListBuf, iFinishedCountListLen);
|
|
//memcpy(m_pStorageTaskListBuf, pStorageTaskListBuf, iStorageTaskListLen);
|
|
|
|
//// Clear rest buffer
|
|
//if (iActiveListLen < TASK_ACTIVE_LIST_BUF_SIZE)
|
|
// memset((BYTE*)m_pActiveListBuf + iActiveListLen, 0, TASK_ACTIVE_LIST_BUF_SIZE - iActiveListLen);
|
|
|
|
//if (iFinishedListLen < TASK_FINISHED_LIST_BUF_SIZE)
|
|
// memset((BYTE*)m_pFinishedListBuf + iFinishedListLen, 0, TASK_FINISHED_LIST_BUF_SIZE - iFinishedListLen);
|
|
|
|
//if (iFinishedTimeListLen < TASK_FINISH_TIME_LIST_BUF_SIZE)
|
|
// memset((BYTE*)m_pFinishedTimeListBuf + iFinishedTimeListLen, 0, TASK_FINISH_TIME_LIST_BUF_SIZE - iFinishedTimeListLen);
|
|
|
|
//if (iFinishedCountListLen < TASK_FINISH_COUNT_LIST_BUF_SIZE)
|
|
// memset((BYTE*)m_pFinishedCountListBuf + iFinishedCountListLen, 0, TASK_FINISH_COUNT_LIST_BUF_SIZE - iFinishedCountListLen);
|
|
|
|
//if (iStorageTaskListLen < TASK_STORAGE_LIST_BUF_SIZE)
|
|
// memset((BYTE*)m_pStorageTaskListBuf + iStorageTaskListLen, 0, TASK_STORAGE_LIST_BUF_SIZE - iStorageTaskListLen);
|
|
|
|
Debug.Log("[Dat]- Init GetTaskTemplMan");
|
|
ATaskTemplMan pTaskMan = GetTaskTemplMan();
|
|
if (pTaskMan == null)
|
|
{
|
|
Debug.LogError("[Dat]- fail to create ATaskTemplMan");
|
|
return false;
|
|
}
|
|
pTaskMan.Release();
|
|
// pTaskMan.LoadTasksFromPack("data\\tasks.data", true);
|
|
// pTaskMan.LoadNPCInfoFromPack("data\\task_npc.data");
|
|
// pTaskMan.VerifyDynTasksPack("userdata\\dyn_tasks.data");
|
|
// InitActiveTaskList();
|
|
|
|
//m_bForceNavigateFinish = false;
|
|
|
|
return true;
|
|
}
|
|
|
|
public void CheckPQEnterWorldInit()
|
|
{
|
|
return;
|
|
ActiveTaskList pList = GetActiveTaskList();
|
|
List<ActiveTaskEntry> aEntries = new List<ActiveTaskEntry>(pList.m_TaskEntries);
|
|
|
|
for(var i = 0; i < pList.m_uTaskCount; i++)
|
|
{
|
|
var CurEntry = aEntries[i];
|
|
|
|
if (CurEntry.m_ulTemplAddr == 0)
|
|
continue;
|
|
|
|
ATaskTempl pTempl = CurEntry.GetTempl();
|
|
if (pTempl == null || !pTempl.m_FixedData.m_bPQTask)
|
|
continue;
|
|
|
|
pTempl.IncValidCount();
|
|
// _notify_svr(this, TASK_CLT_NOTIFY_PQ_CHECK_INIT, CurEntry.m_ID);
|
|
}
|
|
}
|
|
|
|
public static void WriteLog(int nPlayerId, int nTaskId, int nType, string szLog)
|
|
{
|
|
//do something?
|
|
}
|
|
|
|
private ATaskTemplMan GetTaskTemplMan()
|
|
{
|
|
return EC_Game.GetTaskTemplateMan();
|
|
}
|
|
private ActiveTaskList GetActiveTaskList()
|
|
{
|
|
return m_pActiveListBuf;
|
|
}
|
|
}
|
|
}
|