本文整理汇总了C++中Damage::set方法的典型用法代码示例。如果您正苦于以下问题:C++ Damage::set方法的具体用法?C++ Damage::set怎么用?C++ Damage::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Damage
的用法示例。
在下文中一共展示了Damage::set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: splDispelAlign
int splDispelAlign(Creature* player, cmd* cmnd, SpellData* spellData, const char* spell, int align) {
Creature* target=0;
Damage damage;
if((target = player->findMagicVictim(cmnd->str[2], cmnd->val[2], spellData, true, false, "Cast on what?\n", "You don't see that here.\n")) == nullptr)
return(0);
if(player == target) {
// mobs can't cast on themselves!
if(!player->getAsPlayer())
return(0);
// turn into a boolean!
// are they in alignment?
if(align == PINKISH)
align = player->getAlignment() <= align;
else
align = player->getAlignment() >= align;
if(spellData->how == CastType::CAST || spellData->how == CastType::SCROLL || spellData->how == CastType::WAND)
player->print("You cannot cast that spell on yourself.\n");
else if(spellData->how == CastType::POTION && !align)
player->print("Nothing happens.\n");
else if(spellData->how == CastType::POTION && align) {
player->smashInvis();
damage.set(mrand(spellData->level * 2, spellData->level * 4));
damage.add(MAX(0, bonus((int) player->piety.getCur())));
player->modifyDamage(player, MAGICAL, damage);
player->print("You feel as if your soul is savagely ripped apart!\n");
player->printColor("You take %s%d^x points of damage!\n", player->customColorize("*CC:DAMAGE*").c_str(), damage.get());
broadcast(player->getSock(), player->getParent(), "%M screams and doubles over in pain!", player);
player->hp.decrease(damage.get());
if(player->hp.getCur() < 1) {
player->print("Your body explodes. You're dead!\n");
broadcast(player->getSock(), player->getParent(), "%M's body explodes! %s's dead!", player,
player->upHeShe());
player->getAsPlayer()->die(EXPLODED);
}
}
} else {
if(player->spellFail( spellData->how))
return(0);
cmnd->str[2][0] = up(cmnd->str[2][0]);
target = player->getParent()->findCreature(player, cmnd->str[2], cmnd->val[2], false);
if(!target) {
player->print("That's not here.\n");
return(0);
}
if(!player->canAttack(target))
return(0);
if( (target->getLevel() > spellData->level + 7) ||
(!player->isStaff() && target->isStaff())
) {
player->print("Your magic would be too weak to harm %N.\n", target);
return(0);
}
player->smashInvis();
// turn into a boolean!
// are they in alignment?
if(align == PINKISH)
align = target->getAlignment() <= align;
else
align = target->getAlignment() >= align;
if(spellData->how == CastType::CAST || spellData->how == CastType::SCROLL || spellData->how == CastType::WAND) {
player->print("You cast %s on %N.\n", spell, target);
broadcast(player->getSock(), target->getSock(), player->getParent(), "%M casts a %s spell on %N.", player, spell, target);
if(target->getAsPlayer()) {
target->wake("Terrible nightmares disturb your sleep!");
target->print("%M casts a %s spell on you.\n", player, spell);
}
if(!align) {
player->print("Nothing happens.\n");
} else {
damage.set(mrand(spellData->level * 2, spellData->level * 4));
damage.add(abs(player->getAlignment()/100));
damage.add(MAX(0, bonus((int) player->piety.getCur())));
target->modifyDamage(player, MAGICAL, damage);
if(target->chkSave(SPL, player,0))
damage.set(damage.get() / 2);
player->printColor("The spell did %s%d^x damage.\n", player->customColorize("*CC:DAMAGE*").c_str(), damage.get());
player->print("%M screams in agony as %s soul is ripped apart!\n",
target, target->hisHer());
target->printColor("You take %s%d^x points of damage as your soul is ripped apart!\n", target->customColorize("*CC:DAMAGE*").c_str(), damage.get());
broadcastGroup(false, target, "%M cast a %s spell on ^M%N^x for *CC:DAMAGE*%d^x damage, %s%s\n",
//.........这里部分代码省略.........