📄 hero.cpp
字号:
// Hero.cpp: implementation of the CHero class.
//
//////////////////////////////////////////////////////////////////////
#include "basefunc.h"
#include "3DGameMap.h"
#include "GameMsg.h"
#include "Hero.h"
#include "GamePlayerSet.h"
#include "GameDataSet.h"
#include "AllMsg.h"
#include "MsgAllot.h"
#include "ImgNumCounter.h"
#include "3DRoleData.h"
#include "SkyLayer.h"
#include "EncryptData.h"
#include "Pet.h"
#include "ItemObserver.h"
#include "NetCmd.h"
#include "NDsound.h"
// external...
extern UINT g_uStatus;
// globle...
CHero g_objHero;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CHero::CHero()
{
m_nType = MAP_HERO;
m_dwMoney =0;
m_timeDie =0;
m_timeGhost =0;
m_idAccount =ID_NONE;
m_posAlign.x =-1;
m_posAlign.y =-1;
m_nPkMode = PKMODE_FREE;
m_setFriend.clear();
m_nHeightCanJump = 200;
m_bXpSkillEnable = FALSE;
m_dwXpFullTime = 0;
m_dwXpStartTime = 0;
m_dwKoCount = 0;
m_dwKoScale = 0;
for (int i=0; i<_MAX_EQUIPMENT; i++)
m_pEquipment[i] = NULL;
m_setSingleHandWeaponSkill.clear();
m_setDoubleHandWeaponSkill.clear();
m_setOtherWeaponSkill.clear();
m_bMagicAttackBusy = false;
this->CreateLevelExp();
m_bFriendQueryBusy = false;
m_idFriendQuery = ID_NONE;
m_bFriendQueryReturn = false;
strcpy(m_szSyndicateAnnounce, "");
strcpy(m_szSyndicateAnnounceTime,"");
this->SetRoleType(_ROLE_HERO);
m_dwTimeSynWarReportLastFlash = ::TimeGet();
memset(m_szWanted, 0L, sizeof(m_szWanted));
memset(m_szPoliceWanted, 0L, sizeof(m_szPoliceWanted));
m_dwBeginUseTransformMagicTime = ::TimeGet();
m_dwTransformBegin = ::TimeGet();
m_dwTransformDuration = 0;
m_dwLastBump = 0;
m_bShowAbortTransformDialog = false;
m_nSynListIndex = 0;
m_dwKoXpAdd = 0;
m_bChargeUp = false;
m_dwLastTalk = 0;
m_idWhoAttackMe = ID_NONE;
m_idMyTarget = ID_NONE;
m_idSpecialTarget = ID_NONE;
m_idFriendLastApply = ID_NONE;
strcpy(m_szActionMessageBox, "");
strcpy(m_szFriendLastApplyInfo, "");
strcpy(m_szFriendLastAcceptInfo, "");
m_idTaskDialog = ID_NONE;
m_idAttchPet = ID_NONE;
this->ClearPet();
m_setSynKickDoc.clear();
m_idLastSynAlly = ID_NONE;
strcpy(m_szLastSynAllyName, "");
m_bShowHpBar = true;
m_pPackageNormal = IItemPackage::CreateNew();
m_pPackagePet = IItemPackage::CreateNew();
m_pPackageSoul = IItemPackage::CreateNew();
m_pPackageEgg = IItemPackage::CreateNew();
m_dwFlashTeamMemberID = ID_NONE;
m_bQuerySchoolMember = false;
m_idLastTeacherApply = ID_NONE;
m_idLastStudentApply = ID_NONE;
strcpy(m_szLastTeacherApply, "");
strcpy(m_szLastStudentApply, "");
m_dwSpeedRate = 100;
m_bMagicLock = false;
m_strCurrentMusic = "";
m_strCurrentMusicPlay = "";
m_dwLastChangeMusicTimer = 0;
m_setSecSchoolMember.clear();
strcpy(m_AuctionName,"");
strcpy(m_AuctionOwnerName,"");
m_AuctionItemId = ID_NONE;
m_AuctionItemMoney = 0;
m_nFastRunSetp = 0;
m_dwTimeWhoAttackMe = 0;
m_nMaxPetCall = 0;
}
CHero::~CHero()
{
this->Reset();
}
//////////////////////////////////////////////////////////////////////
void CHero::Init(void)
{
m_nType = MAP_HERO;
m_dwMoney =0;
m_timeDie =0;
m_timeGhost =0;
m_idAccount =ID_NONE;
m_posAlign.x =-1;
m_posAlign.y =-1;
m_nPkMode = PKMODE_FREE;
m_setFriend.clear();
m_nHeightCanJump = 200;
m_idAttchPet = ID_NONE;
this->ClearPet();
m_setSynKickDoc.clear();
m_bXpSkillEnable = FALSE;
m_dwXpFullTime = 0;
m_dwXpStartTime = 0;
m_dwKoCount = 0;
m_dwKoScale = 0;
for (int i=0; i<_MAX_EQUIPMENT; i++)
m_pEquipment[i] = NULL;
m_setSingleHandWeaponSkill.clear();
m_setDoubleHandWeaponSkill.clear();
m_setOtherWeaponSkill.clear();
m_bMagicAttackBusy = false;
m_bFriendQueryBusy = false;
m_idFriendQuery = ID_NONE;
m_bFriendQueryReturn = false;
strcpy(m_szSyndicateAnnounce, "");
strcpy(m_szSyndicateAnnounceTime,"");
this->SetRoleType(_ROLE_HERO);
m_dwTimeSynWarReportLastFlash = ::TimeGet();
memset(m_szWanted, 0L, sizeof(m_szWanted));
memset(m_szPoliceWanted, 0L, sizeof(m_szPoliceWanted));
this->SetData(CPlayer::_PLAYER_CURRENTLIFE, 0);
m_idLastTeacherApply = ID_NONE;
m_idLastStudentApply = ID_NONE;
strcpy(m_szLastTeacherApply, "");
strcpy(m_szLastStudentApply, "");
m_dwSpeedRate = 100;
strcpy(m_AuctionName,"");
strcpy(m_AuctionOwnerName,"");
m_AuctionItem = NULL;
m_AuctionItemId = ID_NONE;
m_AuctionItemMoney = 0;
m_AuctionItem = new CItem;
m_nMaxPetCall = 0;
}
//////////////////////////////////////////////////////////////////////
void CHero::Reset()
{
this->ClearSchoolMemberList();
this->ClearPlayerTaskList();
this->ClearFriendList();
this->ClearEnemyList();
this->DestroyWeaponSkill();
this->ClearItem();
this->DestroyMagicSet();
this->ClearSynWarReport();
this->ClearHelpTip();
this->ClearTips();
g_objPlayerSet.DelAllPlayer();
m_objTeam.Destroy();
this->Init();
memset(&m_infoPlayer, 0L, sizeof(m_infoPlayer));
strcpy(m_szCryOut, "");
const DWORD MaxPhysicalForce = 100;
m_infoPlayer.dwMaxPhysicalForce = MaxPhysicalForce;
this->ClearSynMember();
m_bShowAbortTransformDialog = false;
this->m_objEffect.Clear();
this->m_objDiceManager.Close(false);
::PostCmd(CMD_RESET);
m_objCheck.Reset();
m_idWhoAttackMe = ID_NONE;
m_idMyTarget = ID_NONE;
m_idSpecialTarget = ID_NONE;
m_idAttchPet = ID_NONE;
this->ClearPet();
m_objDummy.ClearEquipment();
m_Info.usHair = ID_NONE;
m_Info.usFace = ID_NONE;
m_Info.idLWeaponType = ID_NONE;
m_Info.idRWeaponType = ID_NONE;
m_Info.idArmorType = ID_NONE;
m_Info.idArmetType = ID_NONE;
m_Info.idMountType = ID_NONE;
m_infoPlayer.setMedal.clear();
m_infoPlayer.setHonorTitle.clear();
m_setSynKickDoc.clear();
m_idFriendLastApply = ID_NONE;
strcpy(m_szActionMessageBox, "");
strcpy(m_szFriendLastApplyInfo, "");
strcpy(m_szFriendLastAcceptInfo, "");
m_pPackageNormal->Clear();
m_pPackageEgg->Clear();
m_pPackagePet->Clear();
m_pPackageSoul->Clear();
m_idLastTeacherApply = ID_NONE;
m_idLastStudentApply = ID_NONE;
strcpy(m_szLastTeacherApply, "");
strcpy(m_szLastStudentApply, "");
m_dwSpeedRate = 100;
m_bMagicLock = false;
strcpy(m_AuctionName,"");
strcpy(m_AuctionOwnerName,"");
m_AuctionItemId = ID_NONE;
m_AuctionItemMoney = 0;
SAFE_DELETE(m_AuctionItem);
m_bXpSkillEnable = FALSE;
m_dwXpFullTime = 0;
m_dwXpStartTime = 0;
m_dwKoCount = 0;
m_dwKoScale = 0;
m_strCurrentMusic = "";
m_strCurrentMusicPlay = "";
m_dwLastChangeMusicTimer = 0;
::DXSetSoundVolume(0);
::DXSetMusicVolume(0);
g_objHero.SetMusicVolume(0);
m_dwTimeWhoAttackMe = 0;
m_nMaxPetCall = 0;
}
//////////////////////////////////////////////////////////////////////
void CHero::Walk(int nPosX, int nPosY)
{
if(this->IsMagicLock())
return;
if(this->TestStatus(USERSTATUS_CANNOTMOVE))
return;
this->StopChargeUp();
int nCommandType = this->GetCommandType();
if(nCommandType == _COMMAND_ATTACK ||
nCommandType == _COMMAND_ACTION ||
nCommandType == _COMMAND_EMOTION ||
nCommandType == _COMMAND_WOUND ||
nCommandType == _COMMAND_DEFEND)
this->ResetActionData();
// if(this->TestStatus(USERSTATUS_FLY))
// {
// this->Jump(nPosX, nPosY);
// return;
// }
if(this->GetCommandType() == _COMMAND_ATTACK)
this->ResetActionData();
if(m_objBoothManager.IsActive())
return;
extern UINT g_uStatus;
if (_STATUS_NORMAL != g_uStatus)
return;
this->AbortIntone();
if (this->IsDead() && !this->TestStatus(USERSTATUS_GHOST))
return;
// prevent repeat the same target point
CCommand* pcmdNow =this->GetCommand();
if(_COMMAND_WALK == pcmdNow->iType)
{
if(nPosX == pcmdNow->posTarget.x &&
nPosY == pcmdNow->posTarget .y)
return;
}
// here got player already
CPlayer* pPlayer = g_objPlayerSet.GetPlayer(nPosX, nPosY);
if ((pPlayer && !pPlayer->IsDead()))// || (pPlayer && pPlayer->TestStatus(USERSTATUS_GHOST)))
return;
// set command of role
CCommand cmd;
cmd.iType =_COMMAND_WALK;
cmd.iStatus =_CMDSTATUS_BEGIN;
cmd.posTarget.x =nPosX;
cmd.posTarget.y =nPosY;
this->SetCommand(&cmd);
}
//////////////////////////////////////////////////////////////////////
void CHero::Run(int nPosX, int nPosY)
{
if(this->IsMagicLock())
return;
if(this->TestStatus(USERSTATUS_CANNOTMOVE))
return;
this->StopChargeUp();
int nCommandType = this->GetCommandType();
if(nCommandType == _COMMAND_ATTACK ||
nCommandType == _COMMAND_ACTION ||
nCommandType == _COMMAND_EMOTION ||
nCommandType == _COMMAND_WOUND ||
nCommandType == _COMMAND_DEFEND)
this->ResetActionData();
// if(this->TestStatus(USERSTATUS_FLY))
// {
// this->Jump(nPosX, nPosY);
// return;
// }
if(this->GetCommandType() == _COMMAND_ATTACK)
this->ResetActionData();
if(m_objBoothManager.IsActive())
return;
extern UINT g_uStatus;
if (_STATUS_NORMAL != g_uStatus)
return;
this->AbortIntone();
if (this->IsDead())
{
if (this->TestStatus(USERSTATUS_GHOST))
this->Walk(nPosX, nPosY);
return;
}
// prevent repeat the same target point
CCommand* pcmdNow =this->GetCommand();
if(_COMMAND_RUN == pcmdNow->iType)
{
if(nPosX == pcmdNow->posTarget.x &&
nPosY == pcmdNow->posTarget .y)
return;
}
// here got player already
CPlayer* pPlayer = g_objPlayerSet.GetPlayer(nPosX, nPosY);
if (pPlayer && !pPlayer->IsDead())
return;
// set command of role
CCommand cmd;
cmd.iType =_COMMAND_RUN;
cmd.iStatus =_CMDSTATUS_BEGIN;
cmd.posTarget.x =nPosX;
cmd.posTarget.y =nPosY;
this->SetCommand(&cmd);
}
//////////////////////////////////////////////////////////////////////
void CHero::Jump(int nPosX, int nPosY)
{
g_objGameMsg.AddMsg("Jump is not allowed in BELIEF.");
}
//////////////////////////////////////////////////////////////////////
void CHero::Direction(int nPosX, int nPosY)
{
if(m_objBoothManager.IsActive())
return;
if (this->IsDead() && !this->TestStatus(USERSTATUS_GHOST))
return;
CMyPos posTarget;
posTarget.x =nPosX;
posTarget.y =nPosY;
int nDir =this->GetDir(posTarget);
this->SetDir(nDir);
CMyPos posHero;
this->GetPos(posHero);
CMsgAction msg;
if (msg.Create(this->GetID(), posHero.x, posHero.y, nDir, actionChgDir))
msg.Send();
}
//////////////////////////////////////////////////////////////////////
void CHero::Reject(int nType)
{
char szMsg[64]="ERROR";
char szName[64]="ERROR";
switch(nType)
{
case REJECT_FRIEND:
strcpy(szMsg, "a");
strcpy(szName, this->GetNameFriendLastApply());
break;
case REJECT_TRADE:
strcpy(szMsg, "b");
strcpy(szName, this->m_objTrade.GetLastApplyPlayerName());
break;
case REJECT_TEAM:
strcpy(szMsg, "c");
strcpy(szName, this->GetTeamApplyerName());
break;
case REJECT_TEACHER:
strcpy(szMsg, "d");
strcpy(szName, this->GetLastTeacherApply());
break;
case REJECT_STUDENT:
strcpy(szMsg, "e");
strcpy(szName, this->GetLastStudentApply ());
break;
default:
return;
}
if(strlen(szName) >= _MAX_NAMESIZE)
return;
this->Talk(szName, szMsg, NULL, 0xffffffff, _TXTATR_REJECT);
}
//////////////////////////////////////////////////////////////////////
void CHero::Talk(const char* pszTarget, const char* pszWords, const char* pszEmotion,
DWORD dwColor, unsigned short unAttribute, unsigned short unStyle)
{
if (!pszTarget || !pszWords)
return;
if (this->IsGhost() && unAttribute == _TXTATR_TALK)
unAttribute = _TXTATR_GHOST;
if (pszWords[0] == '/')
{ // cmd line
const char* pszCmdLine = pszWords+1;
char szCmd[256] = "";
if (1 == sscanf(pszCmdLine, "%s", szCmd))
{
if (0 == stricmp(szCmd, "BaseScale"))
{
float fBaseScale;
if (2 == sscanf(pszCmdLine, "%s %f", szCmd, &fBaseScale))
{
CRole::s_fBaseScale = fBaseScale;
return;
}
}
if (0 == stricmp(szCmd, "info"))
{
g_objGameMap.SwitchScreenInfo();
return;
}
if (0 == stricmp(szCmd, "scrshot"))
{
char szFile[256] = "";
if (2 == sscanf(pszCmdLine, "%s %s", szCmd, szFile))
{
CMyBitmap::ScreenShot(szFile);
return;
}
}
if (0 == stricmp(szCmd, "lifePer"))
{
int percent = 0;
if (2 == sscanf(pszCmdLine, "%s %d", szCmd, &percent))
{
this->SetMaxLifePercent(percent);
return;
}
}
if (0 == stricmp(szCmd, "test"))
{
/* g_objHero.LoadKongfu("test.kf");
CCommand cmd;
cmd.iType =_COMMAND_KONGFU;
cmd.iStatus =_CMDSTATUS_BEGIN;
g_objHero.SetCommand(&cmd);*/
return;
}
if (0 == stricmp(szCmd, "Action"))
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -