www.pudn.com > XmudOSr.rar > NpcInfo.cpp
#include "stdafx.h" #include "XMudClient.h" #include "NpcInfo.h" extern CListnpclist; extern CList npcskilllist; extern char g_tszPathName[256]; CList skilltypelist; BOOL GetNpcInfo(CString sNpcFile) { return TRUE; } BOOL GetNpcEquipInfo(CString sNpcFile) { return TRUE; } //设置NPC的技能信息 BOOL GetNpcSkillInfo(CStringList * strComList) { npcskilllist.RemoveAll(); CNpcSkillInfo *lpSkillInfo; int i,j; CStringList strls; CString strtmp,parm; int itmp; LPTSTR lpsz; char *ps; BOOL bFindHead=FALSE; strtmp = strComList->GetHead(); lpsz = strtmp.GetBuffer(strtmp.GetLength()+1); parm=CString(","); ps=strtok(lpsz,(const char*)parm); strls.AddTail(ps); for(;;) { ps=strtok(NULL,(const char*)parm); if(ps==NULL)break; strls.AddTail(ps); } j = strls.GetCount(); for(i=0;i j) return FALSE; strtmp = strls.GetAt( strls.FindIndex(i+3)); if(lstrcmp("'RCEND'",strtmp))return FALSE; lpSkillInfo = new CNpcSkillInfo; if(!lpSkillInfo)return FALSE; strtmp = strls.GetAt( strls.FindIndex(i+1)); lpSkillInfo->m_sCNAME = strtmp = strtmp.Mid(1,strtmp.GetLength()-2); strtmp = strls.GetAt( strls.FindIndex(i+2)); strtmp = strtmp = strtmp.Mid(1,strtmp.GetLength()-2); lpsz = strtmp.GetBuffer(20); itmp=strtol(lpsz,'\0',10); strtmp.ReleaseBuffer(); lpSkillInfo->m_iLEVEL = itmp; lpSkillInfo->m_sMAPPING =""; lpSkillInfo->m_sENAME = ""; lpSkillInfo->m_iSCORER = 0; strtmp = strls.GetAt( strls.FindIndex(i+4)); if(!lstrcmp("'NPCSKILLEND'",strtmp)) { npcskilllist.AddTail(lpSkillInfo); break; } i = i+3; npcskilllist.AddTail(lpSkillInfo); } } strls.RemoveAll(); return TRUE; } CString GetNpcFaceInfo(CString sNpcName) { CString szResult = "有什么事情吗?"; CString buf; CFile file; char szFileName[256]; strcpy(szFileName,g_tszPathName); strcat(szFileName,"\\muddata\\NpcMsg.dat"); if( !file.Open( szFileName, CFile::modeRead , NULL ) ) { return szResult; } CArchive ar(&file,CArchive::load); while(ar.ReadString(buf)) { if( sNpcName == buf ) { ar.ReadString(buf); szResult = buf; break; } } ar.Close(); file.Close(); return szResult; }