本文整理汇总了C++中Weapon::rollAttack方法的典型用法代码示例。如果您正苦于以下问题:C++ Weapon::rollAttack方法的具体用法?C++ Weapon::rollAttack怎么用?C++ Weapon::rollAttack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Weapon
的用法示例。
在下文中一共展示了Weapon::rollAttack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: attack
//.........这里部分代码省略.........
}
attackBonus += level();
damageBonus = 1 + w->data.damageBonus;
}
switch (w->data.weaponType) {
case Weapon::THROWN_WEAPON:
case Weapon::PROJECTILE_WEAPON:
case Weapon::AMMUNITION_WEAPON:
{
attackBonus -= MAX(0,distanceToTarget - w->data.range) / FEET_PER_TILE;
}
}
//ofLog() << getName() << " > target ac: " << ac << " tohit: "<<attackBonus<<" damageBonus: "<<damageBonus;
//ofLog() << "attack roll: " << roll << " +" << attackBonus << ", against ac: "<<ac;
if (roll==1) {
// whiff!!
hit = false;
} else if (roll>=w->data.criticalThreat) {
//ofLog() << "Crit!";
// have critical threat, but roll again...
roll = d20();
if (roll+attackBonus>=ac) {
crit = true;
ce->type = CombatEvent::CRIT_EVENT;
} else {
hit = true;
ce->type = CombatEvent::HIT_EVENT;
}
} else if (roll+attackBonus>=ac) {
hit = true;
ce->type = CombatEvent::HIT_EVENT;
}
if (crit||hit) {
ce->dmg = w->rollAttack() + damageBonus;
if (crit) {
for (int i=1; i<w->data.criticalMultiplier; i++) {
ce->dmg += w->rollAttack() + damageBonus;
}
}
}
if (ce->dmg ==0) ce->type = CombatEvent::MISS_EVENT;
if (w->data.weaponType == Weapon::PROJECTILE_WEAPON) {
ofPtr<CombatEvent> ae = ofPtr<CombatEvent>(new CombatEvent());
ae->a = this;
ae->b = a;
ae->nextEvent = ce;
ae->type = CombatEvent::ARROW_EVENT;
ofNotifyEvent(CombatEvent::combatEvent, *ae);
} else {
ofNotifyEvent(CombatEvent::combatEvent, *ce);
}
//a->takeDamage(ce->dmg); // TODO: move this logic to a combat resolution class
actionDebt += ((float)w->data.attackDebt) * ((float)data.attackSpeed / 100.0f);
} else {
ofLog() << getName() << " has no weapon in hand!";
}
return 0;
}