📄 hero.cpp
字号:
if(0 == stricmp(szCmd, "color"))
{
DWORD dwColor;
if (2 == sscanf(pszCmdLine, "%s %x", szCmd, &dwColor))
{
g_objGameMap.SetARGB(dwColor);
}
}
#endif
#ifdef _ANALYSIS_ON
if(0 == stricmp(szCmd, "analysis"))
{
g_bShowAnalysisInfo = !g_bShowAnalysisInfo;
}
#endif
}
}
if (_TXTATR_ACTION == unAttribute)
{
CONST DWORD INTERVAL_TALK = 5000;
DWORD dwTimeNow = ::TimeGet();
if (dwTimeNow - m_dwLastTalk > INTERVAL_TALK)
{
m_dwLastTalk = dwTimeNow;
CMsgTalk msg;
if (msg.Create((char*)this->GetName(), (char*)pszTarget, (char*)pszWords, (char*)pszEmotion, dwColor, unAttribute, unStyle))
msg.Send();
}
}
else
{
if (!(this->IsGhost() && unAttribute != _TXTATR_TEAM && unAttribute !=_TXTATR_GHOST))
{
CMsgTalk msg;
if (msg.Create((char*)this->GetName(), (char*)pszTarget, (char*)pszWords, (char*)pszEmotion, dwColor, unAttribute, unStyle))
msg.Send();
}
}
g_objGameMsg.AddMsg((char*)this->GetName(), (char*)pszTarget, (char*)pszEmotion, (char*)pszWords, dwColor, unStyle, unAttribute, ::SysTimeGet());
if (unAttribute != _TXTATR_ACTION &&
unAttribute != _TXTATR_PRIVATE &&
unAttribute != _TXTATR_REJECT)
this->Say(pszWords);
}
//////////////////////////////////////////////////////////////////////
void CHero::Talk(CPlayer* pTarget, const char* pszWords, const char* pszEmotion,
DWORD dwColor, unsigned short unAttribute, unsigned short unStyle)
{
if (!pszWords)
return;
char szSender[256];
strcpy (szSender, this->GetName());
char szTarget[256];
const OBJID idEveryOne = 100026;
if (!pTarget)
strcpy(szTarget, g_objGameDataSet.GetStr(idEveryOne));
else
strcpy(szTarget, pTarget->GetName());
this->Talk(szTarget, pszWords, pszEmotion, dwColor, unAttribute, unStyle);
}
//////////////////////////////////////////////////////////////////////
BOOL CHero::CanPk(CPlayer* pTarget)
{
if (!pTarget)
return false;
if (pTarget->IsMyPet ())
return false;
switch(m_nPkMode)
{
case PKMODE_SYNDICATE:
{
if (!pTarget->IsNpc())
{
if (this->GetDistance(pTarget) == 1)
{
if(this->GetSyndicate() == ID_NONE)
{
return true;
}
else if(this->GetSyndicate() == pTarget->GetSyndicate())
{
const OBJID idCanNotPk = 100027;
g_objGameMsg.AddMsg(g_objGameDataSet.GetStr(idCanNotPk));
return false;
}
}
}
}
break;
case PKMODE_ARRESTMENT:
{
if (!pTarget->IsNpc() && !pTarget->IsBaddy())
{
if (this->GetDistance(pTarget) == 1)
{
const OBJID idCanNotPk = 100164;
g_objGameMsg.AddMsg(g_objGameDataSet.GetStr(idCanNotPk));
}
return false;
}
if (pTarget->IsPlayer () && pTarget->TestStatus (USERSTATUS_RED))
{
if (this->GetDistance(pTarget) == 1)
{
const OBJID idCanNotPk = 100164;
g_objGameMsg.AddMsg(g_objGameDataSet.GetStr(idCanNotPk));
}
return false;
}
if (pTarget->IsPet() && !pTarget->IsBaddy())
{
if (this->GetDistance(pTarget) == 1)
{
const OBJID idCanNotPk = 100164;
g_objGameMsg.AddMsg(g_objGameDataSet.GetStr(idCanNotPk));
}
return false;
}
}
break;
case PKMODE_MONSTERONLY:
{
if (!pTarget->IsNpc())
{
if (this->GetDistance(pTarget) == 1)
{
const OBJID idCanNotPk = 100027;
g_objGameMsg.AddMsg(g_objGameDataSet.GetStr(idCanNotPk));
}
return false;
}
}
break;
case PKMODE_TMEXCLUDE:
{
// team members
if (this->IsTeamMember(pTarget->GetID()))
{
if (this->GetDistance(pTarget) == 1)
{
const OBJID idCanNotPkTeamMember = 100165;
g_objGameMsg.AddMsg(g_objGameDataSet.GetStr(idCanNotPkTeamMember));
}
return false;
}
// mate
if (0 == strcmp(this->GetMate(), pTarget->GetName()))
return false;
}
break;
default:
break;
}
return true;
}
//////////////////////////////////////////////////////////////////////
void CHero::Shoot(CPlayer* pTarget, OBJID idBullet, BOOL bForced)
{
int nAction = _ACTION_ATTACK0+::RandGet(3);
int nDir = this->GetDir(pTarget);
this->SetActionCmd(nAction, nDir);
if(this->GetLWeapon() == ID_NONE)
return;
// create arrow
if(pTarget)
{
CMagicEffect* pEffect = CMagicEffect::CreateNewArrow(this->GetID(), pTarget->GetID(), this->GetLWeapon());
g_objGameMap.AddMagicEffect(pEffect);
pEffect->AddRoleInfo(pTarget->GetID(), 50);
}
}
//////////////////////////////////////////////////////////////////////
void CHero::Attack (CPlayer* pTarget, BOOL bForced/*=false*/)
{
if (!pTarget)
return;
if (this->IsDead() || pTarget->IsDead())
return;
if (!this->CanPk(pTarget))
return;
// set command of role
CCommand cmd;
cmd.iType =_COMMAND_ATTACK;
cmd.iStatus =_CMDSTATUS_BEGIN;
cmd.idTarget =pTarget->GetID();
CMyPos posTarget;
pTarget->GetPos(posTarget);
cmd.nDir =this->GetDir(posTarget);
this->SetCommand(&cmd);
}
//////////////////////////////////////////////////////////////////////
void CHero::TeamFollow()
{
this->AbortIntone();
TeamMemberInfo* pInfo = this->GetTeamMemberInfo(0);
if(!pInfo)
return;
if(pInfo->id == this->GetID())
return;
CPlayer* pTarget = g_objPlayerSet.GetPlayer(pInfo->id);
if(!pTarget)
return;
// set command of role
CCommand cmd;
cmd.iType =_COMMAND_TEAMFOLLOW;
cmd.iStatus =_CMDSTATUS_BEGIN;
cmd.idTarget =pTarget->GetID();
// get my index in the team ...
int nAmount = this->GetTeamMemberAmount();
for(int i = 0; i < nAmount; i ++)
{
TeamMemberInfo* pInfo = this->GetTeamMemberInfo(i);
if(pInfo && pInfo->id == this->GetID())
{
cmd.dwData = i;
break;
}
}
// offset
CMyPos posTarget;
pTarget->GetPos(posTarget);
cmd.posTarget.x = m_Info.posMap.x - posTarget.x;
cmd.posTarget.y = m_Info.posMap.y - posTarget.y;
cmd.nDir =this->GetDir(posTarget);
this->SetCommand(&cmd);
}
//////////////////////////////////////////////////////////////////////
void CHero::LockAttack (CPlayer* pTarget, BOOL bForced, BOOL bMove)
{
if(this->TestStatus(USERSTATUS_CANNOTMOVE))
return;
if(this->IsMagicLock())
return;
if (!pTarget)
return;
if(pTarget->IsPlayer()) //禁止pk区域检测
{
CMyPos posHero;
this->GetPos(posHero);
if(!g_objGameMap.IsPkRegion(posHero))
{
const OBJID idStr = 100157;
g_objGameMsg.AddMsg(g_objGameDataSet.GetStr(100157));
return;
}
}
if (g_objGameMap.GetType() & MAPTYPE_BOOTH_ENABLE)
return;
this->AbortIntone();
if (this->IsDead() || pTarget->IsDead())
return;
if (!this->CanPk(pTarget))
{
CMyPos posTarget;
pTarget->GetPos(posTarget);
int nDir = this->GetDir(posTarget);
// if(!this->TestStatus(USERSTATUS_FLY))
// {
posTarget.x -= _DELTA_X[nDir];
posTarget.y -= _DELTA_Y[nDir];
this->Walk(posTarget.x, posTarget.y);
// }
// else
// {
// posTarget.x -= _DELTA_X[nDir];
// posTarget.y -= _DELTA_Y[nDir];
// this->Jump(posTarget.x, posTarget.y);
// }
}
else
{
const OBJID idGuard = 100028;
if (pTarget->IsGuard())
{
if (!(bForced && PKMODE_FREE == this->GetPkMode()))
{
const OBJID idCanNotPkGuard = 100029;
g_objGameMsg.AddMsg(_TXTATR_SYSTEM, g_objGameDataSet.GetStr(idCanNotPkGuard));
return;
}
}
if (pTarget->IsPlayer() &&
this->GetSydicateID() != ID_NONE &&
pTarget->GetSydicateID() == this->GetSydicateID() &&
!bForced)
{
OBJID idStr = 100126;
g_objGameMsg.AddMsg(_TXTATR_SYSTEM, g_objGameDataSet.GetStr(idStr));
//g_objGameMsg.AddMsg(_TXTATR_SYSTEM, "攻击帮派兄弟必须使用按住Ctrl键的强制PK模式。");
return;
}
this->SetIDMyTarget(pTarget->GetID());
if(this->HaveBow())
{
if(this->GetLWeapon() == ID_NONE)
{
const OBJID idStr = 100140;
g_objGameMsg.AddMsg(g_objGameDataSet.GetStr(idStr));
return;
}
/*
if(this->TestStatus(USERSTATUS_CHARGEUP) || !bMove)
{
CMyPos posTarget;
pTarget->GetPos(posTarget);
int nAtkRange = (this->GetAddSize()+pTarget->GetAddSize()+1)/2+this->GetAtkRange();
if (abs(m_Info.posMap.x - posTarget.x) > nAtkRange ||
abs(m_Info.posMap.y - posTarget.y) > nAtkRange)
{
const OBJID idStr = 100141;
g_objGameMsg.AddMsg(g_objGameDataSet.GetStr(idStr));
return;
}
}
*/
}
// attack now
{
// set lock attck command
CCommand cmd;
cmd.iType =_COMMAND_LOCKATK;
cmd.iStatus =_CMDSTATUS_BEGIN;
cmd.idTarget =pTarget->GetID();
this->SetCommand(&cmd);
m_bFirstAtk = true;
}
}
}
//////////////////////////////////////////////////////////////////////
void CHero::LockBooth(CPlayer* pTarget)
{
if(this->IsMagicLock())
return;
if (!pTarget)
return;
CCommand cmd;
cmd.iType =_COMMAND_LOCKBOOTH;
cmd.iStatus =_CMDSTATUS_BEGIN;
cmd.idTarget =pTarget->GetID();
cmd.nDir =pTarget->GetDir();
this->SetCommand(&cmd);
}
//////////////////////////////////////////////////////////////////////
BOOL CHero::CanBooth(CPlayer* pTarget)
{
if(this->m_objBoothManager.IsActive())
return false;
if(!pTarget)
return false;
CMyPos posTarget;
pTarget->GetPos(posTarget);
int nDir = pTarget->m_pIRoleView->GetVariable(_VAR_DIR);
CMyPos posBooth;
posBooth.x = posTarget.x + _DELTA_X[nDir]*2;
posBooth.y = posTarget.y + _DELTA_Y[nDir]*2;
CPlayer* pPlayer=g_objPlayerSet.GetPlayer(posBooth.x, posBooth.y);
CMyPos posHero;
this->GetPos(posHero);
if(posHero.x == posBooth.x && posHero.y == posBooth.y)
return false;
if(pPlayer)
return false;
return true;
}
//////////////////////////////////////////////////////////////////////
void CHero::RushAttack (CPlayer* pTarget, BOOL bForced/*=false*/)
{
if(this->IsMagicLock())
return;
if (!pTarget)
return;
this->AbortIntone();
if (this->IsDead() || pTarget->IsDead())
return;
if (!this->CanPk(pTarget))
return;
// find pos to stand around the target
CMyPos posTarget;
pTarget->GetPos(posTarget);
CMyPos pos;
int nDir = pTarget->GetDir(this);
for (int i=0; i<8; i++)
{
pos.x = posTarget.x+_DELTA_X[nDir];
pos.y = posTarget.y+_DELTA_Y[nDir];
if (this->CanJump(pos))
break;
nDir++;
}
// set command of role
CCommand cmd;
cmd.iType =_COMMAND_RUSHATK;
cmd.iStatus =_CMDSTATUS_BEGIN;
cmd.idTarget =pTarget->GetID();
cmd.nDir =this->GetDir(pos);
cmd.posTarget.x =pos.x;
cmd.posTarget.y =pos.y;
this->SetCommand(&cmd);
}
//////////////////////////////////////////////////////////////////////
void CHero::SkillAttack (CPlayer* pTarget, OBJID idSkillType, BOOL bForced/*=false*/)
{
if (!pTarget || idSkillType == ID_NONE)
return;
this->AbortIntone();
if (this->IsDead() || pTarget->IsDead())
return;
if (!this->CanPk(pTarget))
return;
// set command of role
/*
CCommand cmd;
cmd.iType =_COMMAND_SPATTACK;
cmd.iStatus =_CMDSTATUS_BEGIN;
cmd.idTarget =pTarget->GetID();
cmd.dwData =uPowerUsed;
strcpy(cmd.szString, pszSkill);
CMyPos posTarget;
pTarget->GetPos(posTarget);
cmd.nDir =this->GetDir(posTarget);
this->SetCommand(&cmd);
*/
}
//////////////////////////////////////////////////////////////////////
void CHero::Emotion (int nEmotionType, CPlayer* pTarget)
{
if (this->IsDead())// || this->TestStatus(USERSTATUS_FLY))
return;
this->AbortIntone();
if (nEmotionType == _ACTION_DANCE1 &&
(m_pEquipment[ITEMPOSITION_WEAPONR-1] || m_pEquipment[ITEMPOSITION_WEAPONL-1]))
{
const OBJID idCanNotDanceWithWeapon = 100030;
g_objGameMsg.AddMsg(_TXTATR_SYSTEM, g_objGameDataSet.GetStr(idCanNotDanceWithWeapon));
return;
}
// set command of role
CCommand cmd;
cmd.iType =_COMMAND_EMOTION;
cmd.iStatus =_CMDSTATUS_BEGIN;
cmd.nData =nEmotionType;
if (pTarget)
{
CMyPos posTarget;
pTarget->GetPos(posTarget);
cmd.nDir =this->GetDir(posTarget);
}
else
cmd.nDir =this->GetDir();
this->SetCommand(&cmd);
if (_ACTION_COOLPOSE == nEmotionType)
{
if (this->IsAllEquipmentNonsuch())
this->AddProfessionalCoolposEffect(this->GetProfession(), true);
else
{
if ((this->GetArmor()%10) == 9)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -