www.pudn.com > 3D_OnlineGame_Humen.rar > CmdApprentice.cpp
#include "stdafx.h" #include "XMudClient.h" #include "MenuCreateNew.h" #include "MapInfo.h" #include "NpcInfo.h" #include "D3DRMScreen.h" #include "CommandCheck.h" #include "MainScreen.h" #include "CmdFunction.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif extern rmfullglobals myglobs; extern int g_nGameState; extern SOCKET hLCltForRSvrSock; extern CListplayerlist; extern CRITICAL_SECTION csMaplist; extern CList maplist; extern CList skilllist; extern CList animationlist; extern CList npcskilllist; extern CList skilltypelist; extern int g_playerState; extern char g_tszPathName[256]; extern CMainScreen m_MainScreen; CComApprentice::CComApprentice() { } CComApprentice::~CComApprentice() { } void CComApprentice::DoApprenticeProc() { CPlayerInfo *lpPlayerInfo; CMapInfo *lpMapInfo; animationCallbackArgs *cb; int i,j; BOOL bFindPerson = FALSE; CString strtmp; lpPlayerInfo = playerlist.GetHead(); EnterCriticalSection(&csMaplist); j = maplist.GetCount(); for(i=0;i m_sENAME == lpPlayerInfo->m_sPERSONA){ bFindPerson = TRUE; break; } } LeaveCriticalSection(&csMaplist); if(!bFindPerson){ strtmp = szGreenLow; strtmp += CString("這個地圖裡面沒有") + lpPlayerInfo->m_sPERSONA + ("這個對象"); AddSelfMsg(strtmp); return; } bFindPerson = FALSE; if(lpPlayerInfo->m_sTEACHER == lpMapInfo->m_sENAME) { cb = animationlist.GetHead(); g_playerState = KETOU; cb->time = KETOU_START; strtmp = szGreenHigt; strtmp += CString("你恭恭敬敬的向師傅磕頭請安"); AddSelfMsg(strtmp); return; } strtmp = CString(SZAPPRENTICE) + (" ") + lpMapInfo->m_sENAME; Send(hLCltForRSvrSock,strtmp); } void DoApprenticeProc(CStringList *strComList) { CString strtmp; char sz1[20],sz2[20],sz3[20]; CPlayerInfo * lpPlayerInfo; int nLevelDec = 1; lpPlayerInfo = playerlist.GetHead(); if( strComList->GetAt(strComList->FindIndex(1)) == "OK") { strtmp = szGreenHigt; strtmp += strComList->GetAt(strComList->FindIndex(2)); AddSelfMsg(strtmp); strtmp = strComList->GetTail(); strtmp.Replace(","," "); sscanf(strtmp,"%s %s %d %s",sz1,sz2, &lpPlayerInfo->m_iGENERATION,sz3); lpPlayerInfo->m_sFAMILY = sz1; lpPlayerInfo->m_sTEACHER = sz2; lpPlayerInfo->m_sXFILENAME = sz3; m_MainScreen.bDrawPlayInfo[0] = TRUE; m_MainScreen.bDrawPlayInfo[1] = TRUE; }else if( strComList->GetAt(strComList->FindIndex(1)) == "BETRAY") { strtmp = szGreenHigt; strtmp += strComList->GetAt(strComList->FindIndex(2)); AddSelfMsg(strtmp); strtmp = strComList->GetTail(); strtmp.Replace(","," "); sscanf(strtmp,"%s %s %d %d %d %s %d",sz1,sz2, &lpPlayerInfo->m_iGENERATION, &lpPlayerInfo->m_iBETRAY, &lpPlayerInfo->m_iEXP, sz3, &nLevelDec); lpPlayerInfo->m_sFAMILY = sz1; lpPlayerInfo->m_sTEACHER = sz2; lpPlayerInfo->m_sXFILENAME = sz3; CSkillInfo * lpSkillInfo; for(int i=0;i m_iLEVEL > nLevelDec) { lpSkillInfo->m_iSCORER = 1; lpSkillInfo->m_iLEVEL -= nLevelDec; } else { lpSkillInfo->m_iSCORER = 0; lpSkillInfo->m_iLEVEL = 0; } } m_MainScreen.bDrawPlayInfo[0] = TRUE; m_MainScreen.bDrawPlayInfo[1] = TRUE; if(m_MainScreen.mFirstFD.nShowState == SHOWSKILL) { m_MainScreen.mFirstFD.bReDraw[0] = TRUE; m_MainScreen.mFirstFD.bReDraw[1] = TRUE; m_MainScreen.mFirstFD.ResetCount(); } } } void CComApprentice::OpenNpcSkill() { CPlayerInfo *lpPlayerInfo; CMapInfo *lpMapInfo; CString strtmp; int i,j; BOOL bFindInMap = FALSE; lpPlayerInfo = playerlist.GetHead(); EnterCriticalSection(&csMaplist); j = maplist.GetCount(); for(i=0;i m_sPERSONA == lpMapInfo->m_sENAME) { bFindInMap = TRUE; break; } } LeaveCriticalSection(&csMaplist); if(!bFindInMap) { strtmp = szGreenLow; strtmp += CString("這個地圖裡面沒有") + lpPlayerInfo->m_sPERSONA + ("這個對象"); AddSelfMsg(strtmp); return; } strtmp = CString(SZMASTERSKILL) + (" ") + lpMapInfo->m_sENAME; Send(hLCltForRSvrSock,strtmp); } void DoGetMasterSkillProc(CStringList * strComList) { strComList->RemoveHead(); strComList->RemoveHead(); GetNpcSkillInfo(strComList); m_MainScreen.mFirstFD.nShowState = SHOWNPCSKILL; m_MainScreen.mFirstFD.bReDraw[0] = TRUE; m_MainScreen.mFirstFD.bReDraw[1] = TRUE; } void CComApprentice::LearnNpcSkill(CString szNpcSkillName,char* szTimes) { CPlayerInfo *lpPlayerInfo; CMapInfo *lpMapInfo; int nTimes = atoi(szTimes); int i,j; BOOL bFindPerson = FALSE; CString strtmp; lpPlayerInfo = playerlist.GetHead(); EnterCriticalSection(&csMaplist); j = maplist.GetCount(); for(i=0;i m_sENAME == lpPlayerInfo->m_sPERSONA) { bFindPerson = TRUE; break; } } LeaveCriticalSection(&csMaplist); if(!bFindPerson) { strtmp = szGreenLow; strtmp += CString("這個地圖裡面沒有") + lpPlayerInfo->m_sPERSONA + ("這個對象"); AddSelfMsg(strtmp); return; } if(lpPlayerInfo->m_iQIANNENG < nTimes) { strtmp = szGreenLow; strtmp += CString("你的潛能已經發揮到極限了,沒有辦法再成長了."); AddSelfMsg(strtmp); return; } int iNeedJing = (150/lpPlayerInfo->m_iINT) * nTimes; if(lpPlayerInfo->m_iEFFJING <= iNeedJing) { strtmp = szGreenLow; strtmp += CString("你現在過於疲倦,無法專心下來學習新知."); AddSelfMsg(strtmp); return; } strtmp = CString(SZLEARNSKILL) + (" ") + lpMapInfo->m_sENAME + (" ") + szNpcSkillName + (" ") + szTimes; Send(hLCltForRSvrSock,strtmp); } void DoLearnProc(CStringList * slLearnData) { CPlayerInfo * lpPlayerInfo; lpPlayerInfo = playerlist.GetHead(); int iNeedJing = 150/lpPlayerInfo->m_iINT; int nTimes = 1; CSkillInfo *lptmpSkillInfo,*lpSkillInfo; CString strtmp; char sz1[20],sz2[20]; if(slLearnData->GetAt(slLearnData->FindIndex(1)) == "OK") { nTimes = atoi((char *)(LPCTSTR)slLearnData->GetTail()); if(!nTimes) nTimes = 1; lpPlayerInfo->m_iQIANNENG -= nTimes; lpPlayerInfo->m_iEFFJING -= iNeedJing * nTimes; m_MainScreen.bDrawPlayInfo[0] = TRUE; m_MainScreen.bDrawPlayInfo[1] = TRUE; strtmp = szGreenLow; strtmp += slLearnData->GetAt(slLearnData->FindIndex(2)); AddSelfMsg((char*)(LPCSTR)strtmp); lptmpSkillInfo = new CSkillInfo; strtmp = slLearnData->GetAt(slLearnData->FindIndex(3)); //ANDY_NEW strtmp.Replace(","," "); //ANDY_END sscanf(strtmp,"%s %s %d",sz1,sz2, &lptmpSkillInfo->m_iSCORER); lptmpSkillInfo->m_sCNAME = sz1; lptmpSkillInfo->m_sENAME = sz2; lptmpSkillInfo->m_iLEVEL = 1; lptmpSkillInfo->m_sMAPPING = ""; lptmpSkillInfo->m_iSCORER = nTimes * (lptmpSkillInfo->m_iSCORER); lpSkillInfo = GetSkillPtr(lptmpSkillInfo->m_sCNAME); if(lpSkillInfo != NULL) Improve(lpPlayerInfo, lpSkillInfo, lptmpSkillInfo->m_iSCORER); else skilllist.AddTail(lptmpSkillInfo); if(m_MainScreen.mFirstFD.nShowState == SHOWSKILL) { m_MainScreen.mFirstFD.bReDraw[0] = TRUE; m_MainScreen.mFirstFD.bReDraw[1] = TRUE; m_MainScreen.mFirstFD.ResetCount(); } } } void Improve(CPlayerInfo * lpPlayerInfo, CSkillInfo * lpSkillInfo, int nAddScore) { if( ((lpSkillInfo->m_iLEVEL * lpSkillInfo->m_iLEVEL * lpSkillInfo->m_iLEVEL) / 30) > lpPlayerInfo->m_iEXP ) return ; else lpSkillInfo->m_iSCORER += nAddScore; while( ( lpSkillInfo->m_iSCORER >= (lpSkillInfo->m_iLEVEL * lpSkillInfo->m_iLEVEL ) ) && (((lpSkillInfo->m_iLEVEL * lpSkillInfo->m_iLEVEL * lpSkillInfo->m_iLEVEL) / 30) <= lpPlayerInfo->m_iEXP)) { lpSkillInfo->m_iSCORER -= lpSkillInfo->m_iLEVEL*lpSkillInfo->m_iLEVEL; lpSkillInfo->m_iLEVEL++; if( lpSkillInfo->m_sENAME == "BaseDodge" ) { if( lpSkillInfo->m_iLEVEL%10 == 0 ) lpPlayerInfo->m_iDEX++; }else if( lpSkillInfo->m_sENAME == "BaseUnarmed" ) { if( lpSkillInfo->m_iLEVEL%10 == 0 ) { lpPlayerInfo->m_iMAXDRINK += 10; lpPlayerInfo->m_iMAXEAT += 10; lpPlayerInfo->m_iSTR++; } }else if( lpSkillInfo->m_sENAME == "BaseForce" ) { if( lpSkillInfo->m_iLEVEL%10 == 0 ) lpPlayerInfo->m_iCON++; }else if( lpSkillInfo->m_sENAME == "OtherLiterate" ) { if( lpSkillInfo->m_iLEVEL%10 == 0 ) lpPlayerInfo->m_iINT++; } } } //ANDY_331 /* void Improve(CPlayerInfo * lpPlayerInfo, CSkillInfo * lpSkillInfo, int nAddScore) { lpSkillInfo->m_iSCORER += nAddScore; if(lpSkillInfo->m_iSCORER >= lpSkillInfo->m_iLEVEL*lpSkillInfo->m_iLEVEL) { lpSkillInfo->m_iSCORER -= lpSkillInfo->m_iLEVEL*lpSkillInfo->m_iLEVEL; lpSkillInfo->m_iLEVEL++; if(lpSkillInfo->m_sENAME == "BaseDodge") { if(lpSkillInfo->m_iLEVEL%10 == 0) lpPlayerInfo->m_iDEX++; } else if(lpSkillInfo->m_sENAME == "BaseUnarmed") { if(lpSkillInfo->m_iLEVEL%10 == 0) { lpPlayerInfo->m_iMAXDRINK += 10; lpPlayerInfo->m_iMAXEAT += 10; lpPlayerInfo->m_iSTR++; } } else if(lpSkillInfo->m_sENAME == "BaseForce") { if(lpSkillInfo->m_iLEVEL%10 == 0) lpPlayerInfo->m_iCON++; } else if(lpSkillInfo->m_sENAME == "OtherLiterate") { if(lpSkillInfo->m_iLEVEL%10 == 0) lpPlayerInfo->m_iINT++; } } } */ //ANDY_END