📄 roleaction.cpp
字号:
return false;
}
else if (m_Info.cmdProc.iStatus == _CMDSTATUS_DEPART)
{
this->Attack();
return true;
}
return true;
}
//--------------------------------------------------------------
BOOL CRole::InTone(void)
{
/* if(_CMDSTATUS_BEGIN == m_Info.cmdProc.iStatus)
{
this->StaticAction(_ACTION_BEGININTONE);
m_Info.cmdProc.iStatus =_CMDSTATUS_PROGRESS;
}
else if (_CMDSTATUS_PROGRESS == m_Info.cmdProc.iStatus)
{
this->StaticAction(_ACTION_INTONE);
m_Info.cmdProc.iStatus = _CMDSTATUS_CONTINUE;
}
*/
return false;
}
//--------------------------------------------------------------
BOOL CRole::LockBooth(void)
{
assert(m_Info.cmdProc.iType==_COMMAND_LOCKBOOTH);
if (m_Info.cmdProc.iStatus == _CMDSTATUS_BEGIN)
m_Info.cmdProc.iStatus = _CMDSTATUS_PROGRESS;
if (m_Info.cmdProc.iStatus == _CMDSTATUS_PROGRESS ||
m_Info.cmdProc.iStatus == _CMDSTATUS_CONTINUE)
{
m_Info.objPath.ClearStep();
CPlayer* pTarget = g_objPlayerSet.GetPlayer(m_Info.cmdProc.idTarget);
if (!pTarget)
{
m_Info.objPath.ClearStep();
StandBy();
this->SetDir(m_Info.cmdProc.nDir);
m_Info.cmdProc.iStatus =_CMDSTATUS_ACCOMPLISH;
return false;
}
CMyPos posTarget;
pTarget->GetPos(posTarget);
CMyPos posBooth;
posBooth.x = posTarget.x + _DELTA_X[0]*0;
posBooth.y = posTarget.y + _DELTA_Y[0];
CPlayer* pPlayer=g_objPlayerSet.GetPlayer(posBooth.x, posBooth.y);
if(pPlayer)
return false;
g_objGameMap.FindPath(m_Info.objPath, m_Info.posMap, posBooth);
if(m_Info.objPath.GetStepAmount() > 0) // not reach target
{
StepInfo infoStep;
m_Info.objPath.GetNextStep(infoStep);
m_Info.iDirection = infoStep.cStepDir;
Step();
// reset action type
// reset action
if (m_Info.cmdProc.iStatus == _CMDSTATUS_PROGRESS)
{
m_Info.cmdProc.iStatus =_CMDSTATUS_CONTINUE;
if(m_Info.iActType == _ACTION_RUNR || m_Info.iActType == _ACTION_RUNL)
m_Info.iActType =_ACTION_RUNL;
else
m_Info.iActType =_ACTION_WALKL;
}
else
{
m_Info.cmdProc.iStatus =_CMDSTATUS_PROGRESS;
if(m_Info.iActType == _ACTION_RUNR || m_Info.iActType == _ACTION_RUNL)
m_Info.iActType =_ACTION_RUNR;
else
m_Info.iActType =_ACTION_WALKR;
}
/*
if (m_Info.cmdProc.iStatus == _CMDSTATUS_PROGRESS)
{
m_Info.iActType =_ACTION_RUNL;
m_Info.cmdProc.iStatus =_CMDSTATUS_CONTINUE;
}
else if (m_Info.cmdProc.iStatus == _CMDSTATUS_CONTINUE)
{
m_Info.iActType =_ACTION_RUNR;
m_Info.cmdProc.iStatus =_CMDSTATUS_PROGRESS;
}
*/
}
else
{
StandBy();
m_Info.cmdProc.iStatus =_CMDSTATUS_ACCOMPLISH;
}
}
return true;
}
//--------------------------------------------------------------
BOOL CRole::LockAtk(void)
{
assert(m_Info.cmdProc.iType==_COMMAND_LOCKATK);
if (m_Info.cmdProc.iStatus == _CMDSTATUS_BEGIN)
{
m_Info.cmdProc.iStatus = _CMDSTATUS_PROGRESS;
}
if (m_Info.cmdProc.iStatus == _CMDSTATUS_PROGRESS ||
m_Info.cmdProc.iStatus == _CMDSTATUS_CONTINUE)
{
m_Info.objPath.ClearStep();
CPlayer* pTarget = g_objPlayerSet.GetPlayer(m_Info.cmdProc.idTarget, true);
if (pTarget)
{
CMyPos posTarget;
pTarget->GetPos(posTarget);
CMyPos posMyself;
this->GetPos(posMyself);
int nAtkRange = (this->GetAddSize()+pTarget->GetAddSize()+1)/2+this->GetAtkRange();
BOOL bCheck = false;
if(!this->IsMyPet())
bCheck = true;
else
{
CPlayer* pStandPlayer = g_objPlayerSet.GetPlayer(posMyself.x, posMyself.y);
if(!pStandPlayer || pStandPlayer == this)
bCheck = true;
}
if (abs(posMyself.x-posTarget.x) <= nAtkRange &&
abs(posMyself.y-posTarget.y) <= nAtkRange && bCheck)
{
m_Info.cmdProc.nDir = this->GetDir(posTarget);
if(this->HaveBow())
{
this->Attack();
CMyPos posTargetWorld;
g_objGameMap.Cell2World(posTarget.x, posTarget.y, posTargetWorld.x, posTargetWorld.y);
m_Info.posDir.x = posTargetWorld.x;
m_Info.posDir.y = posTargetWorld.y;
m_Info.bAdjustDir = true;
// create arrow
if(pTarget)
{
CMagicEffect* pEffect = CMagicEffect::CreateNew(g_objHero.GetID(), pTarget->GetID(), g_objHero.GetRWeapon(), 0);
g_objGameMap.AddMagicEffect(pEffect);
}
}
else
{
// 如果是召唤兽,不可重叠攻击 ...
if(this->IsMyPet())
{
CPlayer* pStandPlayer = g_objPlayerSet.GetPlayer(posMyself.x, posMyself.y);
if(!pStandPlayer || pStandPlayer == this)
this->Attack();
else
{
StandBy();
m_Info.cmdProc.iStatus =_CMDSTATUS_ACCOMPLISH;
return false;
}
}
this->Attack();
}
return true;
}
}
else
{
m_Info.objPath.ClearStep();
StandBy();
m_Info.cmdProc.iStatus =_CMDSTATUS_ACCOMPLISH;
return false;
}
CMyPos posTarget;
pTarget->GetPos(posTarget);
// 如果是召唤兽,找合适地点攻击
if(this->IsMyPet())
{
CMyPos posMyTarget;
int nDir = ::RandGet(8);
posMyTarget.x = posTarget.x + _DELTA_X[nDir];
posMyTarget.y = posTarget.y + _DELTA_Y[nDir];
CPlayer* pStandPlayer = g_objPlayerSet.GetPlayer(posMyTarget.x, posMyTarget.y);
if(!pStandPlayer || pStandPlayer == this)
g_objGameMap.FindPath(m_Info.objPath, m_Info.posMap, posMyTarget);
else
{
m_Info.objPath.ClearStep();
StandBy();
m_Info.cmdProc.iStatus =_CMDSTATUS_ACCOMPLISH;
return false;
}
}
else
{
g_objGameMap.FindPath(m_Info.objPath, m_Info.posMap, posTarget);
}
if (m_Info.objPath.GetStepAmount() > 0)
{
StepInfo infoStep;
m_Info.objPath.GetNextStep(infoStep);
m_Info.iDirection = infoStep.cStepDir;
Step();
// reset action to running
// reset action
// reset action
if (m_Info.cmdProc.iStatus == _CMDSTATUS_PROGRESS)
{
m_Info.cmdProc.iStatus =_CMDSTATUS_CONTINUE;
if(m_Info.iActType == _ACTION_RUNR || m_Info.iActType == _ACTION_RUNL)
m_Info.iActType =_ACTION_RUNL;
else
m_Info.iActType =_ACTION_WALKL;
}
else
{
m_Info.cmdProc.iStatus =_CMDSTATUS_PROGRESS;
if(m_Info.iActType == _ACTION_RUNR || m_Info.iActType == _ACTION_RUNL)
m_Info.iActType =_ACTION_RUNR;
else
m_Info.iActType =_ACTION_WALKR;
}
/*
if (m_Info.cmdProc.iStatus == _CMDSTATUS_PROGRESS)
{
m_Info.iActType =_ACTION_RUNL;
m_Info.cmdProc.iStatus =_CMDSTATUS_CONTINUE;
}
else if (m_Info.cmdProc.iStatus == _CMDSTATUS_CONTINUE)
{
m_Info.iActType =_ACTION_RUNR;
m_Info.cmdProc.iStatus =_CMDSTATUS_PROGRESS;
}*/
}
else
{
m_Info.objPath.ClearStep();
StandBy();
m_Info.cmdProc.iStatus =_CMDSTATUS_ACCOMPLISH;
return false;
}
}
return true;
}
//--------------------------------------------------------------
BOOL CRole::TeamFollow (void)
{
assert(_COMMAND_TEAMFOLLOW == m_Info.cmdProc.iType);
CMyPos posOffset = m_Info.cmdProc.posTarget;
// get follow target
CRole* pTarget =g_objPlayerSet.GetPlayer(m_Info.cmdProc.idTarget);
if(!pTarget)
{
if(g_objHero.GetID() == m_Info.cmdProc.idTarget)
pTarget =&g_objHero;
else // error, no target found
{
m_Info.cmdProc.iStatus =_CMDSTATUS_ACCOMPLISH;
StandBy();
m_Info.cmdProc.posTarget = posOffset;
return false;
}
}
if(!g_objHero.GetTeamMemberInfoByID(m_Info.cmdProc.idTarget))
{
m_Info.cmdProc.iStatus =_CMDSTATUS_ACCOMPLISH;
StandBy();
m_Info.cmdProc.posTarget = posOffset;
return false;
}
// get follow pos
CMyPos posTarget;
pTarget->GetPos(posTarget);
int nDir = pTarget->GetDir(this);
//const int _DELTA_X[8]={0,-1,-1,-1,0,1,1,1};
//const int _DELTA_Y[8]={1,1,0,-1,-1,-1,0,1};
m_Info.cmdProc.posTarget.x = posTarget.x + _DELTA_X[nDir] * m_Info.cmdProc.dwData;
m_Info.cmdProc.posTarget.y = posTarget.y + _DELTA_Y[nDir] * m_Info.cmdProc.dwData;
if(m_Info.posMap.x != m_Info.cmdProc.posTarget.x ||
m_Info.posMap.y != m_Info.cmdProc.posTarget.y)
{
m_Info.cmdProc.iStatus =_CMDSTATUS_BEGIN;
}
// step now...
if(m_Info.cmdProc.iStatus==_CMDSTATUS_BEGIN)
{
//m_Info.objStepData.ClearStep();
g_objGameMap.FindPath(m_Info.objPath, m_Info.posMap, m_Info.cmdProc.posTarget);
BOOL bHavePath = false;
if(m_Info.objPath.GetStepAmount() > 0)
bHavePath =true;
if (bHavePath)
m_Info.cmdProc.iStatus =_CMDSTATUS_PROGRESS;
else
{
m_Info.objPath.ClearStep();
StandBy();
m_Info.cmdProc.iStatus =_CMDSTATUS_CONTINUE;
m_Info.cmdProc.posTarget = posOffset;
return false;
}
}
if(m_Info.cmdProc.iStatus==_CMDSTATUS_PROGRESS)
{
if(m_Info.objPath.GetStepAmount() > 0) // not reach target
{
StepInfo infoStep;
m_Info.objPath.GetNextStep(infoStep);
m_Info.iDirection = infoStep.cStepDir;
// reset action to running
/* if(m_Info.objPath.GetStepAmount() > 2)
{
if (m_Info.cmdProc.iStatus == _CMDSTATUS_PROGRESS)
{
m_Info.iActType =_ACTION_RUNL;
m_Info.cmdProc.iStatus =_CMDSTATUS_CONTINUE;
}
else if (m_Info.cmdProc.iStatus == _CMDSTATUS_CONTINUE)
{
m_Info.iActType =_ACTION_RUNR;
m_Info.cmdProc.iStatus =_CMDSTATUS_PROGRESS;
}
} */
Step();
}
else
{
StandBy();
m_Info.cmdProc.iStatus =_CMDSTATUS_CONTINUE;
}
}
if(m_Info.cmdProc.iStatus==_CMDSTATUS_ACCOMPLISH)
{
m_Info.cmdProc.posTarget = posOffset;
return true;
}
else
{
m_Info.cmdProc.posTarget = posOffset;
return false;
}
}
//--------------------------------------------------------------
BOOL CRole::PickUp(void)
{
MYASSERT (m_Info.cmdProc.iType == _COMMAND_PICKUP);
CMyPos posMyself;
this->GetPos(posMyself);
CMyPos posTarget = m_Info.cmdProc.posTarget;
int nRange = 0; //this->GetAddSize()+1;
if (m_Info.cmdProc.iStatus==_CMDSTATUS_BEGIN)
{
m_Info.objPath.ClearStep();
g_objGameMap.FindPath(m_Info.objPath, m_Info.posMap, m_Info.cmdProc.posTarget);
if (abs(posMyself.x-posTarget.x) <= nRange &&
abs(posMyself.y-posTarget.y) <= nRange)
{
StandBy();
m_Info.cmdProc.iStatus =_CMDSTATUS_ACCOMPLISH;
this->StaticAction(_ACTION_PICKUP, this->GetDir());//this->GetDir(posTarget));
return true;
}
else if (m_Info.objPath.GetStepAmount() > 0)
m_Info.cmdProc.iStatus =_CMDSTATUS_PROGRESS;
else // no way
{
m_Info.objPath.ClearStep();
m_Info.cmdProc.iStatus =_CMDSTATUS_ACCOMPLISH;
this->StandBy();
return false;
}
}
if (m_Info.cmdProc.iStatus == _CMDSTATUS_PROGRESS ||
m_Info.cmdProc.iStatus == _CMDSTATUS_CONTINUE)
{
if (abs(posMyself.x-posTarget.x) <= nRange &&
abs(posMyself.y-posTarget.y) <= nRange)
{
m_Info.cmdProc.iStatus = _CMDSTATUS_ACCOMPLISH;
this->StaticAction(_ACTION_PICKUP, this->GetDir());//this->GetDir(posTarget));
return true;
}
else
{
if(m_Info.objPath.GetStepAmount() > 0) // not reach target
{
StepInfo infoStep;
m_Info.objPath.GetNextStep(infoStep);
m_Info.iDirection = infoStep.cStepDir;
Step();
// reset action type
// reset action
if (m_Info.cmdProc.iStatus == _CMDSTATUS_PROGRESS)
{
m_Info.cmdProc.iStatus =_CMDSTATUS_CONTINUE;
if(m_Info.iActType == _ACTION_RUNR || m_Info.iActType == _ACTION_RUNL)
m_Info.iActType =_ACTION_RUNL;
else
m_Info.iActType =_ACTION_WALKL;
}
else
{
m_Info.cmdProc.iStatus =_CMDSTATUS_PROGRESS;
if(m_Info.iActType == _ACTION_RUNR || m_Info.iActType == _ACTION_RUNL)
m_Info.iActType =_ACTION_RUNR;
else
m_Info.iActType =_ACTION_WALKR;
}
/*
if (m_Info.cmdProc.iStatus == _CMDSTATUS_PROGRESS)
{
m_Info.iActType =_ACTION_RUNL;
m_Info.cmdProc.iStatus =_CMDSTATUS_CONTINUE;
}
else if (m_Info.cmdProc.iStatus == _CMDSTATUS_CONTINUE)
{
m_Info.iActType =_ACTION_RUNR;
m_Info.cmdProc.iStatus =_CMDSTATUS_PROGRESS;
}
*/
}
else
{
StandBy();
m_Info.cmdProc.iStatus =_CMDSTATUS_ACCOMPLISH;
}
}
}
return false;
}
//--------------------------------------------------------------
// return the direction to step, -1 means fail to step...
int CRole::GetStepDir(void)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -