Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
673 lines
20 KiB
C++
673 lines
20 KiB
C++
// NPCList.cpp: implementation of the CNPCList class.
|
||
//
|
||
//////////////////////////////////////////////////////////////////////
|
||
|
||
#include "NPCList.h"
|
||
#include <ScriptEngine/ScriptEngine.h>
|
||
|
||
CNPCList g_NPCList;
|
||
static SCRIPT m_scQuestScript;
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
// Construction/Destruction
|
||
//////////////////////////////////////////////////////////////////////
|
||
|
||
static void ScriptErrorMessage(const char *msg)
|
||
{
|
||
MessageBox(NULL, msg, "Script Error", MB_OK);
|
||
}
|
||
|
||
//static void SetNpc(int nUID, int nJob, const char *strNpcSkin, const char *strNpcName)
|
||
static void SetNpc(int nZone, int nUID, int nJob, const char *strNpcSkin, const char *strNpcName)
|
||
{
|
||
if(nZone != g_NPCList.GetZone()) return;
|
||
//
|
||
if(!g_NPCList.IsExistNpc(nUID))
|
||
{
|
||
LPNPCNode lpNPCNode = new NPCNode;
|
||
lpNPCNode->m_dwUID = (unsigned long)nUID;
|
||
lpNPCNode->m_dwJob = (unsigned long)nJob;
|
||
lpNPCNode->m_strNpcSkin = new char[strlen(strNpcSkin) + 1];
|
||
strcpy(lpNPCNode->m_strNpcSkin, strNpcSkin);
|
||
lpNPCNode->m_fDirection = 0.0f;
|
||
lpNPCNode->m_fPosX = 0.0f;
|
||
lpNPCNode->m_fPosY = 0.0f;
|
||
lpNPCNode->m_fPosZ = 0.0f;
|
||
lpNPCNode->m_strNpcName = new char[strlen(strNpcName) + 1];
|
||
strcpy(lpNPCNode->m_strNpcName, strNpcName);
|
||
|
||
g_NPCList.AddNpc(lpNPCNode);
|
||
}
|
||
}
|
||
|
||
static void SetPosition(int nUID, float fDirection, float fPosX, float fPosY, float fPosZ)
|
||
{
|
||
LPNPCNode lpNode = g_NPCList.GetNPCNode(nUID);
|
||
|
||
if(lpNode)
|
||
{
|
||
lpNode->m_fDirection = fDirection + (3.1415926535f);
|
||
lpNode->m_fPosX = fPosX;
|
||
lpNode->m_fPosY = fPosY;
|
||
lpNode->m_fPosZ = fPosZ;
|
||
}
|
||
}
|
||
|
||
static void AddWords(int nUID, const char *strNpcScript)
|
||
{
|
||
LPNPCNode lpNode = g_NPCList.GetNPCNode(nUID);
|
||
|
||
if(lpNode)
|
||
{
|
||
char *strScript = new char[strlen(strNpcScript) + 1];
|
||
strcpy(strScript, strNpcScript);
|
||
LPDialogNode lpWord = new DialogNode;
|
||
lpWord->m_wKindWord = 0;
|
||
lpWord->m_wDialogFlag = 0;
|
||
lpWord->m_strWord = strScript;
|
||
lpNode->m_lstScript.push_back(lpWord);
|
||
}
|
||
}
|
||
|
||
static void AddDialog(int nUID, int nPage, int nFlag, const char *strNpcScript)
|
||
{
|
||
LPNPCNode lpNode = g_NPCList.GetNPCNode(nUID);
|
||
|
||
if(lpNode)
|
||
{
|
||
char *strScript = new char[strlen(strNpcScript) + 1];
|
||
strcpy(strScript, strNpcScript);
|
||
LPDialogNode lpWord = new DialogNode;
|
||
lpWord->m_wKindWord = (unsigned short)nPage;
|
||
lpWord->m_wDialogFlag = (unsigned short)nFlag;
|
||
lpWord->m_strWord = strScript;
|
||
lpNode->m_lstScript.push_back(lpWord);
|
||
}
|
||
}
|
||
|
||
static void AddItem(int nUID, int nKindItem, int nTabPage, int nIndexPosition)
|
||
{
|
||
LPNPCNode lpNode = g_NPCList.GetNPCNode(nUID);
|
||
|
||
if(lpNode)
|
||
{
|
||
LPITEMNode lpItem = lpNode->GetITEMNode(nKindItem);
|
||
if(!lpItem)
|
||
{
|
||
lpItem = new ITEMNode;
|
||
lpItem->m_wKindItem = (unsigned short)nKindItem;
|
||
lpItem->m_wSkill = 0;
|
||
lpItem->m_wSkillLevel = 0;
|
||
lpItem->m_wTabPage = (unsigned short)nTabPage;
|
||
lpItem->m_dwIndexPosition = (unsigned long)nIndexPosition;
|
||
lpNode->m_lstItem.push_back(lpItem);
|
||
}
|
||
}
|
||
}
|
||
|
||
static void AddSkillBook(int nUID, int nKindItem, int nSkill, int nSkillLevel, int nTabPage, int nIndexPosition)
|
||
{
|
||
LPNPCNode lpNode = g_NPCList.GetNPCNode(nUID);
|
||
|
||
if(lpNode)
|
||
{
|
||
LPITEMNode lpItem;
|
||
|
||
lpItem = new ITEMNode;
|
||
lpItem->m_wKindItem = (unsigned short)nKindItem;
|
||
lpItem->m_wSkill = (unsigned short)nSkill;
|
||
lpItem->m_wSkillLevel = (unsigned short)nSkillLevel;
|
||
lpItem->m_wTabPage = (unsigned short)nTabPage;
|
||
lpItem->m_dwIndexPosition = (unsigned long)nIndexPosition;
|
||
lpNode->m_lstItem.push_back(lpItem);
|
||
}
|
||
}
|
||
|
||
static void AddZoneMove(int nUID, int nZoneNumber, float fPosX, float fPosY, float fPosZ)
|
||
{
|
||
LPNPCNode lpNode = g_NPCList.GetNPCNode(nUID);
|
||
|
||
if(lpNode)
|
||
{
|
||
LPWarpNode lpZone = new WarpNode;
|
||
lpZone->m_wNumber = (unsigned short)lpNode->m_lstWarpZone.size();
|
||
lpZone->m_wZoneNumber = (unsigned short)nZoneNumber;
|
||
lpZone->m_fPosX = fPosX;
|
||
lpZone->m_fPosY = fPosY;
|
||
lpZone->m_fPosZ = fPosZ;
|
||
lpNode->m_lstWarpZone.push_back(lpZone);
|
||
}
|
||
}
|
||
|
||
static void AddQuest(int nUID, int nQuestID, int nMinLevel, int nMaxLevel, int nClass, int nCompleteClass, const char *strQuestFunc)
|
||
{
|
||
LPNPCNode lpNode = g_NPCList.GetNPCNode(nUID);
|
||
|
||
if(lpNode)
|
||
{
|
||
g_NPCList.m_lpQuestNode = new QuestNode;
|
||
g_NPCList.m_lpQuestNode->m_wQuestID = (unsigned short)nQuestID;
|
||
g_NPCList.m_lpQuestNode->m_wMinLevel = (unsigned short)nMinLevel;
|
||
g_NPCList.m_lpQuestNode->m_wMaxLevel = (unsigned short)nMaxLevel;
|
||
g_NPCList.m_lpQuestNode->m_dwClass = nClass;
|
||
g_NPCList.m_lpQuestNode->m_dwCompletedQuest = nCompleteClass;
|
||
g_NPCList.m_lpQuestNode->m_strQuestTitle = NULL;
|
||
|
||
SE_FUNC Func_Quest = _SE_GetScriptFunction(m_scQuestScript, T_VOID, strQuestFunc, 0 );
|
||
_SE_CallScriptFunction(m_scQuestScript, Func_Quest);
|
||
|
||
lpNode->m_lstQuest.push_back(g_NPCList.m_lpQuestNode);
|
||
g_NPCList.m_lpQuestNode = NULL;
|
||
g_NPCList.m_lpPhaseNode = NULL;
|
||
g_NPCList.m_lpTriggerNode = NULL;
|
||
}
|
||
}
|
||
|
||
static void QuestTitle(const char *strQuestTitle)
|
||
{
|
||
if(g_NPCList.m_lpQuestNode)
|
||
{
|
||
char *strScript = new char[strlen(strQuestTitle) + 1];
|
||
strcpy(strScript, strQuestTitle);
|
||
g_NPCList.m_lpQuestNode->m_strQuestTitle = strScript;
|
||
}
|
||
}
|
||
|
||
static void AddPhase(int nPhaseNumber, const char *strQuestDesc)
|
||
{
|
||
if(g_NPCList.m_lpQuestNode)
|
||
{
|
||
g_NPCList.m_lpPhaseNode = new PhaseNode;
|
||
g_NPCList.m_lpPhaseNode->m_dwPhaseNumber = nPhaseNumber;
|
||
char *strScript = new char[strlen(strQuestDesc) + 1];
|
||
strcpy(strScript, strQuestDesc);
|
||
g_NPCList.m_lpPhaseNode->m_strPhaseDesc = strScript;
|
||
|
||
g_NPCList.m_lpQuestNode->m_lstPhase.push_back(g_NPCList.m_lpPhaseNode);
|
||
|
||
g_NPCList.m_lpTriggerNode = NULL;
|
||
}
|
||
}
|
||
|
||
static void Trigger_Start(void)
|
||
{
|
||
if(g_NPCList.m_lpPhaseNode)
|
||
{
|
||
g_NPCList.m_lpTriggerNode = new TriggerNode;
|
||
g_NPCList.m_lpTriggerNode->m_dwTriggerKind = TRIGGER_START;
|
||
g_NPCList.m_lpTriggerNode->m_dwTriggerID = 0;
|
||
g_NPCList.m_lpTriggerNode->m_dwZoneID = 0;
|
||
g_NPCList.m_lpTriggerNode->m_fDistance = 0.0f;
|
||
g_NPCList.m_lpTriggerNode->m_fPosX = 0.0f;
|
||
g_NPCList.m_lpTriggerNode->m_fPosY = 0.0f;
|
||
g_NPCList.m_lpTriggerNode->m_fPosZ = 0.0f;
|
||
|
||
g_NPCList.m_lpPhaseNode->m_lstTrigger.push_back(g_NPCList.m_lpTriggerNode);
|
||
}
|
||
}
|
||
|
||
static void Trigger_Puton(int nItemID, int nZoneID, float fPosX, float fPosY, float fPosZ, float fDistance)
|
||
{
|
||
if(g_NPCList.m_lpPhaseNode)
|
||
{
|
||
g_NPCList.m_lpTriggerNode = new TriggerNode;
|
||
g_NPCList.m_lpTriggerNode->m_dwTriggerKind = TRIGGER_PUTON;
|
||
g_NPCList.m_lpTriggerNode->m_dwTriggerID = nItemID;
|
||
g_NPCList.m_lpTriggerNode->m_dwZoneID = nZoneID;
|
||
g_NPCList.m_lpTriggerNode->m_fDistance = fDistance;
|
||
g_NPCList.m_lpTriggerNode->m_fPosX = fPosX;
|
||
g_NPCList.m_lpTriggerNode->m_fPosY = fPosY;
|
||
g_NPCList.m_lpTriggerNode->m_fPosZ = fPosZ;
|
||
|
||
g_NPCList.m_lpPhaseNode->m_lstTrigger.push_back(g_NPCList.m_lpTriggerNode);
|
||
}
|
||
}
|
||
|
||
static void Trigger_Geton(int nItemID, int nZoneID, float fPosX, float fPosY, float fPosZ, float fDistance)
|
||
{
|
||
if(g_NPCList.m_lpPhaseNode)
|
||
{
|
||
g_NPCList.m_lpTriggerNode = new TriggerNode;
|
||
g_NPCList.m_lpTriggerNode->m_dwTriggerKind = TRIGGER_GETON;
|
||
g_NPCList.m_lpTriggerNode->m_dwTriggerID = nItemID;
|
||
g_NPCList.m_lpTriggerNode->m_dwZoneID = nZoneID;
|
||
g_NPCList.m_lpTriggerNode->m_fDistance = fDistance;
|
||
g_NPCList.m_lpTriggerNode->m_fPosX = fPosX;
|
||
g_NPCList.m_lpTriggerNode->m_fPosY = fPosY;
|
||
g_NPCList.m_lpTriggerNode->m_fPosZ = fPosZ;
|
||
|
||
g_NPCList.m_lpPhaseNode->m_lstTrigger.push_back(g_NPCList.m_lpTriggerNode);
|
||
}
|
||
}
|
||
|
||
static void Trigger_Talk(int nNpcID)
|
||
{
|
||
if(g_NPCList.m_lpPhaseNode)
|
||
{
|
||
g_NPCList.m_lpTriggerNode = new TriggerNode;
|
||
g_NPCList.m_lpTriggerNode->m_dwTriggerKind = TRIGGER_TALK;
|
||
g_NPCList.m_lpTriggerNode->m_dwTriggerID = nNpcID;
|
||
g_NPCList.m_lpTriggerNode->m_dwZoneID = 0;
|
||
g_NPCList.m_lpTriggerNode->m_fDistance = 0.0f;
|
||
g_NPCList.m_lpTriggerNode->m_fPosX = 0.0f;
|
||
g_NPCList.m_lpTriggerNode->m_fPosY = 0.0f;
|
||
g_NPCList.m_lpTriggerNode->m_fPosZ = 0.0f;
|
||
|
||
g_NPCList.m_lpPhaseNode->m_lstTrigger.push_back(g_NPCList.m_lpTriggerNode);
|
||
}
|
||
}
|
||
|
||
static void Trigger_Kill(int nMonsterID)
|
||
{
|
||
if(g_NPCList.m_lpPhaseNode)
|
||
{
|
||
g_NPCList.m_lpTriggerNode = new TriggerNode;
|
||
g_NPCList.m_lpTriggerNode->m_dwTriggerKind = TRIGGER_KILL;
|
||
g_NPCList.m_lpTriggerNode->m_dwTriggerID = nMonsterID;
|
||
g_NPCList.m_lpTriggerNode->m_dwZoneID = 0;
|
||
g_NPCList.m_lpTriggerNode->m_fDistance = 0.0f;
|
||
g_NPCList.m_lpTriggerNode->m_fPosX = 0.0f;
|
||
g_NPCList.m_lpTriggerNode->m_fPosY = 0.0f;
|
||
g_NPCList.m_lpTriggerNode->m_fPosZ = 0.0f;
|
||
|
||
g_NPCList.m_lpPhaseNode->m_lstTrigger.push_back(g_NPCList.m_lpTriggerNode);
|
||
}
|
||
}
|
||
|
||
static void Trigger_Pick(int nItemID)
|
||
{
|
||
if(g_NPCList.m_lpPhaseNode)
|
||
{
|
||
g_NPCList.m_lpTriggerNode = new TriggerNode;
|
||
g_NPCList.m_lpTriggerNode->m_dwTriggerKind = TRIGGER_PICK;
|
||
g_NPCList.m_lpTriggerNode->m_dwTriggerID = nItemID;
|
||
g_NPCList.m_lpTriggerNode->m_dwZoneID = 0;
|
||
g_NPCList.m_lpTriggerNode->m_fDistance = 0.0f;
|
||
g_NPCList.m_lpTriggerNode->m_fPosX = 0.0f;
|
||
g_NPCList.m_lpTriggerNode->m_fPosY = 0.0f;
|
||
g_NPCList.m_lpTriggerNode->m_fPosZ = 0.0f;
|
||
|
||
g_NPCList.m_lpPhaseNode->m_lstTrigger.push_back(g_NPCList.m_lpTriggerNode);
|
||
}
|
||
}
|
||
|
||
static void Event_Disappear(int nItemID, int nAmount)
|
||
{
|
||
if(g_NPCList.m_lpTriggerNode)
|
||
{
|
||
LPEventNode lpEventNode = new EventNode;
|
||
lpEventNode->m_dwEventKind = EVENT_DISAPPEAR;
|
||
lpEventNode->m_dwEventNumber = nItemID;
|
||
lpEventNode->m_dwEventAmount = nAmount;
|
||
lpEventNode->m_fPosX = 0.0f;
|
||
lpEventNode->m_fPosY = 0.0f;
|
||
lpEventNode->m_fPosZ = 0.0f;
|
||
lpEventNode->m_strWord = NULL;
|
||
|
||
g_NPCList.m_lpTriggerNode->m_lstEvent.push_back(lpEventNode);
|
||
}
|
||
}
|
||
|
||
static void Event_Get(int nItemID, int nAmount)
|
||
{
|
||
if(g_NPCList.m_lpTriggerNode)
|
||
{
|
||
LPEventNode lpEventNode = new EventNode;
|
||
lpEventNode->m_dwEventKind = EVENT_GET;
|
||
lpEventNode->m_dwEventNumber = nItemID;
|
||
lpEventNode->m_dwEventAmount = nAmount;
|
||
lpEventNode->m_fPosX = 0.0f;
|
||
lpEventNode->m_fPosY = 0.0f;
|
||
lpEventNode->m_fPosZ = 0.0f;
|
||
lpEventNode->m_strWord = NULL;
|
||
|
||
g_NPCList.m_lpTriggerNode->m_lstEvent.push_back(lpEventNode);
|
||
}
|
||
}
|
||
|
||
static void Event_Spawn(int nMonsterID, float fPosX, float fPosY, float fPosZ)
|
||
{
|
||
if(g_NPCList.m_lpTriggerNode)
|
||
{
|
||
LPEventNode lpEventNode = new EventNode;
|
||
lpEventNode->m_dwEventKind = EVENT_SPAWN;
|
||
lpEventNode->m_dwEventNumber = nMonsterID;
|
||
lpEventNode->m_dwEventAmount = 0;
|
||
lpEventNode->m_fPosX = fPosX;
|
||
lpEventNode->m_fPosY = fPosY;
|
||
lpEventNode->m_fPosZ = fPosZ;
|
||
lpEventNode->m_strWord = NULL;
|
||
|
||
g_NPCList.m_lpTriggerNode->m_lstEvent.push_back(lpEventNode);
|
||
}
|
||
}
|
||
|
||
static void Event_MonsterDrop(int nItemID, int nAmount)
|
||
{
|
||
if(g_NPCList.m_lpTriggerNode)
|
||
{
|
||
LPEventNode lpEventNode = new EventNode;
|
||
lpEventNode->m_dwEventKind = EVENT_MONSTERDROP;
|
||
lpEventNode->m_dwEventNumber = nItemID;
|
||
lpEventNode->m_dwEventAmount = nAmount;
|
||
lpEventNode->m_fPosX = 0.0f;
|
||
lpEventNode->m_fPosY = 0.0f;
|
||
lpEventNode->m_fPosZ = 0.0f;
|
||
lpEventNode->m_strWord = NULL;
|
||
|
||
g_NPCList.m_lpTriggerNode->m_lstEvent.push_back(lpEventNode);
|
||
}
|
||
}
|
||
|
||
static void Event_Drop(int nItemID, int nAmount, float fPosX, float fPosY, float fPosZ)
|
||
{
|
||
if(g_NPCList.m_lpTriggerNode)
|
||
{
|
||
LPEventNode lpEventNode = new EventNode;
|
||
lpEventNode->m_dwEventKind = EVENT_DROP;
|
||
lpEventNode->m_dwEventNumber = nItemID;
|
||
lpEventNode->m_dwEventAmount = nAmount;
|
||
lpEventNode->m_fPosX = fPosX;
|
||
lpEventNode->m_fPosY = fPosY;
|
||
lpEventNode->m_fPosZ = fPosZ;
|
||
lpEventNode->m_strWord = NULL;
|
||
|
||
g_NPCList.m_lpTriggerNode->m_lstEvent.push_back(lpEventNode);
|
||
}
|
||
}
|
||
|
||
static void Event_Award(int nExp, int nGold)
|
||
{
|
||
if(g_NPCList.m_lpTriggerNode)
|
||
{
|
||
LPEventNode lpEventNode = new EventNode;
|
||
lpEventNode->m_dwEventKind = EVENT_AWARD;
|
||
lpEventNode->m_dwEventNumber = nExp;
|
||
lpEventNode->m_dwEventAmount = nGold;
|
||
lpEventNode->m_fPosX = 0.0f;
|
||
lpEventNode->m_fPosY = 0.0f;
|
||
lpEventNode->m_fPosZ = 0.0f;
|
||
lpEventNode->m_strWord = NULL;
|
||
|
||
g_NPCList.m_lpTriggerNode->m_lstEvent.push_back(lpEventNode);
|
||
}
|
||
}
|
||
|
||
static void Event_MsgBox(const char *strMessage)
|
||
{
|
||
if(g_NPCList.m_lpTriggerNode)
|
||
{
|
||
LPEventNode lpEventNode = new EventNode;
|
||
lpEventNode->m_dwEventKind = EVENT_MSGBOX;
|
||
lpEventNode->m_dwEventNumber = 0;
|
||
lpEventNode->m_dwEventAmount = 0;
|
||
lpEventNode->m_fPosX = 0.0f;
|
||
lpEventNode->m_fPosY = 0.0f;
|
||
lpEventNode->m_fPosZ = 0.0f;
|
||
char *strScript = new char[strlen(strMessage) + 1];
|
||
strcpy(strScript, strMessage);
|
||
lpEventNode->m_strWord = strScript;
|
||
|
||
g_NPCList.m_lpTriggerNode->m_lstEvent.push_back(lpEventNode);
|
||
}
|
||
}
|
||
|
||
static void Event_Phase(int nPhaseNumber)
|
||
{
|
||
if(g_NPCList.m_lpTriggerNode)
|
||
{
|
||
LPEventNode lpEventNode = new EventNode;
|
||
lpEventNode->m_dwEventKind = EVENT_PHASE;
|
||
lpEventNode->m_dwEventNumber = nPhaseNumber;
|
||
lpEventNode->m_dwEventAmount = 0;
|
||
lpEventNode->m_fPosX = 0.0f;
|
||
lpEventNode->m_fPosY = 0.0f;
|
||
lpEventNode->m_fPosZ = 0.0f;
|
||
lpEventNode->m_strWord = NULL;
|
||
|
||
g_NPCList.m_lpTriggerNode->m_lstEvent.push_back(lpEventNode);
|
||
}
|
||
}
|
||
|
||
CNPCList::CNPCList()
|
||
{
|
||
m_lpQuestNode = NULL;
|
||
m_lpPhaseNode = NULL;
|
||
m_lpTriggerNode = NULL;
|
||
}
|
||
|
||
CNPCList::~CNPCList()
|
||
{
|
||
DestroyNPCList();
|
||
}
|
||
|
||
void CNPCList::Create()
|
||
{
|
||
|
||
}
|
||
|
||
BOOL CNPCList::Load(const char *strScriptFile, const char *strQuestFile, unsigned long dwZone)
|
||
{
|
||
DestroyNPCList();
|
||
|
||
m_dwZone = dwZone;
|
||
|
||
m_scQuestScript = _SE_Create(strQuestFile);
|
||
if(!m_scQuestScript) return FALSE;
|
||
|
||
_SE_RegisterFunction(m_scQuestScript, QuestTitle, T_VOID, "QuestTitle", T_STRING, 0);
|
||
_SE_RegisterFunction(m_scQuestScript, AddPhase, T_VOID, "AddPhase", T_INT, T_STRING, 0);
|
||
_SE_RegisterFunction(m_scQuestScript, Trigger_Start, T_VOID, "Trigger_Start", 0);
|
||
_SE_RegisterFunction(m_scQuestScript, Trigger_Puton, T_VOID, "Trigger_Puton", T_INT, T_INT, T_FLOAT, T_FLOAT, T_FLOAT, T_FLOAT, 0);
|
||
_SE_RegisterFunction(m_scQuestScript, Trigger_Geton, T_VOID, "Trigger_Geton", T_INT, T_INT, T_FLOAT, T_FLOAT, T_FLOAT, T_FLOAT, 0);
|
||
_SE_RegisterFunction(m_scQuestScript, Trigger_Talk, T_VOID, "Trigger_Talk", T_INT, 0);
|
||
_SE_RegisterFunction(m_scQuestScript, Trigger_Kill, T_VOID, "Trigger_Kill", T_INT, 0);
|
||
_SE_RegisterFunction(m_scQuestScript, Trigger_Pick, T_VOID, "Trigger_Pick", T_INT, 0);
|
||
_SE_RegisterFunction(m_scQuestScript, Event_Disappear, T_VOID, "Event_Disappear", T_INT, T_INT, 0);
|
||
_SE_RegisterFunction(m_scQuestScript, Event_Get, T_VOID, "Event_Get", T_INT, T_INT, 0);
|
||
_SE_RegisterFunction(m_scQuestScript, Event_Spawn, T_VOID, "Event_Spawn", T_INT, T_FLOAT, T_FLOAT, T_FLOAT, 0);
|
||
_SE_RegisterFunction(m_scQuestScript, Event_MonsterDrop, T_VOID, "Event_MonsterDrop", T_INT, T_INT, 0);
|
||
_SE_RegisterFunction(m_scQuestScript, Event_Drop, T_VOID, "Event_Drop", T_INT, T_INT, T_FLOAT, T_FLOAT, T_FLOAT, 0);
|
||
_SE_RegisterFunction(m_scQuestScript, Event_Award, T_VOID, "Event_Award", T_INT, T_INT, 0);
|
||
_SE_RegisterFunction(m_scQuestScript, Event_MsgBox, T_VOID, "Event_MsgBox", T_STRING, 0);
|
||
_SE_RegisterFunction(m_scQuestScript, Event_Phase, T_VOID, "Event_Phase", T_INT, 0);
|
||
|
||
_SE_SetMessageFunction(ScriptErrorMessage);
|
||
SCRIPT Script = _SE_Create(strScriptFile);
|
||
if(!Script) return FALSE;
|
||
|
||
// _SE_RegisterFunction(Script, SetNpc, T_VOID, "SetNPC", T_INT, T_INT, T_STRING, T_STRING, 0);
|
||
_SE_RegisterFunction(Script, SetNpc, T_VOID, "SetNPC", T_INT, T_INT, T_INT, T_STRING, T_STRING, 0);
|
||
_SE_RegisterFunction(Script, SetPosition, T_VOID, "SetPosition", T_INT, T_FLOAT, T_FLOAT, T_FLOAT, T_FLOAT, 0);
|
||
_SE_RegisterFunction(Script, AddWords, T_VOID, "AddWords", T_INT, T_STRING, 0);
|
||
_SE_RegisterFunction(Script, AddDialog, T_VOID, "AddDialog", T_INT, T_INT, T_INT, T_STRING, 0);
|
||
_SE_RegisterFunction(Script, AddItem, T_VOID, "AddItem", T_INT, T_INT, T_INT, T_INT, 0);
|
||
_SE_RegisterFunction(Script, AddSkillBook, T_VOID, "AddSkillBook", T_INT, T_INT, T_INT, T_INT, T_INT, T_INT, 0);
|
||
_SE_RegisterFunction(Script, AddZoneMove, T_VOID, "AddZoneMove", T_INT, T_INT, T_FLOAT, T_FLOAT, T_FLOAT, 0);
|
||
_SE_RegisterFunction(Script, AddQuest, T_VOID, "AddQuest", T_INT, T_INT, T_INT, T_INT, T_INT, T_INT, T_STRING, 0);
|
||
|
||
_SE_Execute(Script);
|
||
|
||
_SE_Destroy(Script);
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CNPCList::IsExistNpc(unsigned long dwUID)
|
||
{
|
||
vector<LPNPCNode>::iterator it;
|
||
for(it = m_lstNpcNode.begin(); it != m_lstNpcNode.end(); it++)
|
||
{
|
||
if((*it)->m_dwUID == dwUID) return TRUE;
|
||
}
|
||
|
||
return FALSE;
|
||
}
|
||
|
||
void CNPCList::AddNpc(LPNPCNode lpNewNode)
|
||
{
|
||
m_lstNpcNode.push_back(lpNewNode);
|
||
}
|
||
|
||
LPNPCNode CNPCList::GetNPCNode(unsigned long dwUID)
|
||
{
|
||
vector<LPNPCNode>::iterator it;
|
||
for(it = m_lstNpcNode.begin(); it != m_lstNpcNode.end(); it++)
|
||
{
|
||
if((*it)->m_dwUID == dwUID) return (*it);
|
||
}
|
||
|
||
return NULL;
|
||
}
|
||
|
||
void CNPCList::DestroyNPCList()
|
||
{
|
||
vector<LPNPCNode>::iterator it;
|
||
vector<LPDialogNode>::iterator itchar;
|
||
vector<LPITEMNode>::iterator itItem;
|
||
vector<LPWarpNode>::iterator itWarp;
|
||
vector<LPQuestNode>::iterator itQuest;
|
||
vector<LPPhaseNode>::iterator itPhase;
|
||
vector<LPTriggerNode>::iterator itTrigger;
|
||
vector<LPEventNode>::iterator itEvent;
|
||
|
||
LPNPCNode lpNPC;
|
||
LPDialogNode lpWord;
|
||
LPITEMNode lpItem;
|
||
LPWarpNode lpWarp;
|
||
LPQuestNode lpQuest;
|
||
LPPhaseNode lpPhase;
|
||
LPTriggerNode lpTrigger;
|
||
LPEventNode lpEvent;
|
||
for(it = m_lstNpcNode.begin(); it != m_lstNpcNode.end();)
|
||
{
|
||
lpNPC = (*it);
|
||
it = m_lstNpcNode.erase(it);
|
||
for(itchar = lpNPC->m_lstScript.begin(); itchar != lpNPC->m_lstScript.end();)
|
||
{
|
||
lpWord = (*itchar);
|
||
itchar = lpNPC->m_lstScript.erase(itchar);
|
||
delete[] lpWord->m_strWord;
|
||
delete lpWord;
|
||
}
|
||
lpNPC->m_lstScript.clear();
|
||
|
||
for(itItem = lpNPC->m_lstItem.begin(); itItem != lpNPC->m_lstItem.end();)
|
||
{
|
||
lpItem = (*itItem);
|
||
itItem = lpNPC->m_lstItem.erase(itItem);
|
||
delete lpItem;
|
||
}
|
||
lpNPC->m_lstItem.clear();
|
||
|
||
for(itWarp = lpNPC->m_lstWarpZone.begin(); itWarp != lpNPC->m_lstWarpZone.end();)
|
||
{
|
||
lpWarp = (*itWarp);
|
||
itWarp = lpNPC->m_lstWarpZone.erase(itWarp);
|
||
delete lpWarp;
|
||
}
|
||
lpNPC->m_lstWarpZone.clear();
|
||
|
||
for(itQuest = lpNPC->m_lstQuest.begin(); itQuest != lpNPC->m_lstQuest.end();)
|
||
{
|
||
lpQuest = (*itQuest);
|
||
itQuest = lpNPC->m_lstQuest.erase(itQuest);
|
||
for(itPhase = lpQuest->m_lstPhase.begin(); itPhase != lpQuest->m_lstPhase.end();)
|
||
{
|
||
lpPhase = (*itPhase);
|
||
itPhase = lpQuest->m_lstPhase.erase(itPhase);
|
||
for(itTrigger = lpPhase->m_lstTrigger.begin(); itTrigger != lpPhase->m_lstTrigger.end();)
|
||
{
|
||
lpTrigger = (*itTrigger);
|
||
itTrigger = lpPhase->m_lstTrigger.erase(itTrigger);
|
||
for(itEvent = lpTrigger->m_lstEvent.begin(); itEvent != lpTrigger->m_lstEvent.end();)
|
||
{
|
||
lpEvent = (*itEvent);
|
||
itEvent = lpTrigger->m_lstEvent.erase(itEvent);
|
||
if(lpEvent->m_strWord) delete[] lpEvent->m_strWord;
|
||
delete lpEvent;
|
||
}
|
||
lpTrigger->m_lstEvent.clear();
|
||
delete lpTrigger;
|
||
}
|
||
lpPhase->m_lstTrigger.clear();
|
||
|
||
delete[] lpPhase->m_strPhaseDesc;
|
||
|
||
delete lpPhase;
|
||
}
|
||
lpQuest->m_lstPhase.clear();
|
||
|
||
if(lpQuest->m_strQuestTitle) delete[] lpQuest->m_strQuestTitle;
|
||
|
||
delete lpQuest;
|
||
}
|
||
lpNPC->m_lstQuest.clear();
|
||
|
||
delete[] lpNPC->m_strNpcSkin;
|
||
delete[] lpNPC->m_strNpcName;
|
||
|
||
delete lpNPC;
|
||
}
|
||
m_lstNpcNode.clear();
|
||
|
||
_SE_Destroy(m_scQuestScript);
|
||
}
|
||
|
||
const char *CNPCList::GetGreeting(unsigned long dwUID)
|
||
{
|
||
vector<LPNPCNode>::iterator it;
|
||
for(it = m_lstNpcNode.begin(); it != m_lstNpcNode.end(); it++)
|
||
{
|
||
if((*it)->m_dwUID == dwUID)
|
||
{
|
||
return (*it)->GetGreeting();
|
||
}
|
||
}
|
||
|
||
return NULL;
|
||
}
|
||
|
||
void NPCNode::SearchQuestList(unsigned long m_dwLevel, unsigned long m_dwClass, unsigned short *m_lstCompleted, unsigned short m_wNumCompleted, unsigned short *m_lstQuestList)
|
||
{
|
||
vector<LPQuestNode>::iterator it;
|
||
unsigned long count = 0;
|
||
unsigned long i = 0;
|
||
|
||
for(it = m_lstQuest.begin(); it != m_lstQuest.end(); it++, i++)
|
||
{
|
||
BOOL bPass = FALSE;
|
||
// <20>̹<EFBFBD> <20><> <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD> <20>˻<EFBFBD><CBBB><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20>ߴ<EFBFBD><DFB4><EFBFBD> <20>˻<EFBFBD>
|
||
for(unsigned long t = 0; t < m_wNumCompleted; t++)
|
||
{
|
||
if(m_lstCompleted[t] == (*it)->m_wQuestID)
|
||
{
|
||
bPass = TRUE;
|
||
}
|
||
}
|
||
|
||
if(bPass) continue;
|
||
|
||
if((*it)->m_dwCompletedQuest)
|
||
{
|
||
for(unsigned long t = 0; t < m_wNumCompleted; t++)
|
||
{
|
||
if(m_lstCompleted[t] == (*it)->m_dwCompletedQuest)
|
||
{
|
||
bPass = TRUE;
|
||
}
|
||
}
|
||
|
||
if(!bPass) continue;
|
||
}
|
||
|
||
if((*it)->m_wMinLevel <= m_dwLevel && m_dwLevel <= (*it)->m_wMaxLevel)
|
||
{
|
||
m_lstQuestList[count] = i;
|
||
count++;
|
||
}
|
||
}
|
||
|
||
m_lstQuestList[count] = 0xFFFF;
|
||
}
|