本文整理汇总了C++中CNpc::GetDamage方法的典型用法代码示例。如果您正苦于以下问题:C++ CNpc::GetDamage方法的具体用法?C++ CNpc::GetDamage怎么用?C++ CNpc::GetDamage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNpc
的用法示例。
在下文中一共展示了CNpc::GetDamage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RecvNpcAttack
void CAISocket::RecvNpcAttack(Packet & pkt)
{
CNpc * pAttacker;
Unit * pTarget;
uint16 sAttackerID, sTargetID;
int16 sDamage;
uint8 bResult = ATTACK_FAIL;
pkt >> sAttackerID >> sTargetID;
pAttacker = g_pMain->GetNpcPtr(sAttackerID);
pTarget = g_pMain->GetUnitPtr(sTargetID);
if (pAttacker == nullptr
|| pAttacker->isPlayer()
|| pTarget == nullptr
|| pAttacker->isDead()
|| pTarget->isDead())
return;
// TO-DO: Wrap this up into its own virtual method
sDamage = pAttacker->GetDamage(pTarget);
if (sDamage > 0)
{
pTarget->HpChange(-(sDamage), pAttacker);
if (pTarget->isDead())
bResult = ATTACK_TARGET_DEAD;
else
bResult = ATTACK_SUCCESS;
// Every hit takes a little of the defender's armour durability.
if (pTarget->isPlayer())
TO_USER(pTarget)->ItemWoreOut(DEFENCE, sDamage);
}
Packet result(WIZ_ATTACK, uint8(DIRECT_ATTACK));
result << bResult << sAttackerID << sTargetID;
pAttacker->SendToRegion(&result);
}