本文整理汇总了C++中BitField::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ BitField::clear方法的具体用法?C++ BitField::clear怎么用?C++ BitField::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitField
的用法示例。
在下文中一共展示了BitField::clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateActive
bool BTMonsterEditor::updateActive(ObjectSerializer &serial, BitField &active, int modField)
{
BTFactory<BTMonster> &monsterList = BTCore::getCore()->getMonsterList();
bool refresh = false;
unsigned int newXp = monsterList[current].calcXp();
if (newXp != prevXp)
{
XMLAction *xpField = serial.find("xp", NULL);
unsigned int *xp = (reinterpret_cast<unsigned int*>(xpField->object));
*xp += newXp;
*xp -= prevXp;
prevXp = newXp;
refresh = true;
}
if (modField == MONSTERLOC_RANGEDTYPE)
{
BitField old = active;
XMLAction *curField = serial.find("rangedType", NULL);
int type = *(reinterpret_cast<int*>(curField->object));
if (type == BTRANGEDTYPE_MAGIC)
{
if (!active.isSet(MONSTERLOC_RANGEDSPELL))
{
active.set(MONSTERLOC_RANGEDSPELL);
XMLAction *extraField = serial.find("rangedSpell", NULL);
*(reinterpret_cast<int*>(extraField->object)) = 0;
}
}
else
active.clear(MONSTERLOC_RANGEDSPELL);
return (refresh || (!(active == old)));
}
return refresh;
}
示例2: initActive
void BTMonsterEditor::initActive(ObjectSerializer &serial, BitField &active)
{
BTFactory<BTMonster> &monsterList = BTCore::getCore()->getMonsterList();
prevXp = monsterList[current].calcXp();
XMLAction *curField = serial.find("rangedType", NULL);
int type = *(reinterpret_cast<int*>(curField->object));
for (int i = 0; i < entries; ++i)
{
switch (i)
{
case MONSTERLOC_RANGEDSPELL:
{
if (type == BTRANGEDTYPE_MAGIC)
active.set(i);
else
active.clear(i);
break;
}
default:
active.set(i);
}
}
}
示例3: attack
std::string BTCombatant::attack(BTCombatant *defender, bool melee, const std::string &cause, const std::string &effect, const BTDice &damageDice, IShort chanceXSpecial, IShort xSpecial, int &numAttacksLeft, int &activeNum, int toHitBonus /*= 0*/)
{
int hits = 0;
int totalDamage = 0;
bool dead = false;
bool totalDrain = false;
BitField finalSpecial;
while ((defender->isAlive()) && (numAttacksLeft > 0))
{
int roll = BTDice(1, 20).roll();
if ((1 != roll) && ((20 == roll) || (roll + toHit + toHitBonus >= defender->ac)))
{
++hits;
int damage = 0;
BitField special;
damage = damageDice.roll();
for (int i = 0; i < dmgBonus.size(); i++)
damage += dmgBonus[i]->apply(melee);
if ((BTEXTRADAMAGE_NONE != xSpecial) && (BTDice(1, 100).roll() <= chanceXSpecial))
special.set(xSpecial);
if (damage < 0)
damage = 0;
totalDamage += damage;
if (defender->takeHP(damage))
{
dead = true;
defender->deactivate(activeNum);
}
else
{
useAutoCombatSkill(melee, special);
int maxSpecial = special.getMaxSet();
if (maxSpecial > -1)
{
std::string specialText;
for (int i = 0; i <= maxSpecial; ++i)
{
if (!special.isSet(i))
continue;
if (defender->savingThrow(BTSAVE_DIFFICULTY))
{
special.clear(i);
continue;
}
switch(i)
{
case BTEXTRADAMAGE_POISON:
defender->status.set(BTSTATUS_POISONED);
break;
case BTEXTRADAMAGE_LEVELDRAIN:
if (defender->drainLevel())
{
totalDrain = true;
defender->deactivate(activeNum);
}
break;
case BTEXTRADAMAGE_INSANITY:
defender->status.set(BTSTATUS_INSANE);
break;
case BTEXTRADAMAGE_AGED:
if (defender->age())
{
defender->deactivate(activeNum);
}
break;
case BTEXTRADAMAGE_POSSESSION:
defender->status.set(BTSTATUS_POSSESSED);
break;
case BTEXTRADAMAGE_PARALYSIS:
defender->status.set(BTSTATUS_PARALYZED);
break;
case BTEXTRADAMAGE_STONED:
defender->status.set(BTSTATUS_STONED);
defender->deactivate(activeNum);
break;
case BTEXTRADAMAGE_CRITICALHIT:
defender->status.set(BTSTATUS_DEAD);
defender->deactivate(activeNum);
break;
case BTEXTRADAMAGE_ITEMZOT:
if (!defender->drainItem(5))
{
special.clear(BTEXTRADAMAGE_ITEMZOT);
}
break;
case BTEXTRADAMAGE_POINTPHAZE:
if (!defender->takeSP(5))
{
special.clear(BTEXTRADAMAGE_POINTPHAZE);
}
break;
default:
break;
}
}
finalSpecial |= special;
}
}
}
--numAttacksLeft;
//.........这里部分代码省略.........
示例4: specialAttack
std::string BTCombatant::specialAttack(BTCombatant *defender, const BTDice &damageDice, IShort xSpecial, bool farRange, int &activeNum, bool *saved /*= NULL*/)
{
int totalDamage = 0;
bool dead = false;
bool totalDrain = false;
BitField special;
totalDamage = damageDice.roll();
if (farRange)
totalDamage = totalDamage / 2;
bool saveResult = false;
if (saved)
saveResult = *saved;
else
saveResult = defender->savingThrow(BTSAVE_DIFFICULTY);
if (saveResult)
{
totalDamage = totalDamage / 2;
}
else if (BTEXTRADAMAGE_NONE != xSpecial)
{
special.set(xSpecial);
}
if (defender->takeHP(totalDamage))
{
dead = true;
defender->deactivate(activeNum);
}
else
{
int maxSpecial = special.getMaxSet();
if (maxSpecial > -1)
{
for (int i = 0; i <= maxSpecial; ++i)
{
if (!special.isSet(i))
continue;
switch(i)
{
case BTEXTRADAMAGE_POISON:
defender->status.set(BTSTATUS_POISONED);
break;
case BTEXTRADAMAGE_LEVELDRAIN:
if (defender->drainLevel())
{
totalDrain = true;
defender->deactivate(activeNum);
}
break;
case BTEXTRADAMAGE_INSANITY:
defender->status.set(BTSTATUS_INSANE);
break;
case BTEXTRADAMAGE_AGED:
if (defender->age())
{
defender->deactivate(activeNum);
}
break;
case BTEXTRADAMAGE_POSSESSION:
defender->status.set(BTSTATUS_POSSESSED);
break;
case BTEXTRADAMAGE_PARALYSIS:
defender->status.set(BTSTATUS_PARALYZED);
break;
case BTEXTRADAMAGE_STONED:
defender->status.set(BTSTATUS_STONED);
defender->deactivate(activeNum);
break;
case BTEXTRADAMAGE_CRITICALHIT:
defender->status.set(BTSTATUS_DEAD);
defender->deactivate(activeNum);
break;
case BTEXTRADAMAGE_ITEMZOT:
if (!defender->drainItem(5))
{
special.clear(BTEXTRADAMAGE_ITEMZOT);
}
break;
case BTEXTRADAMAGE_POINTPHAZE:
if (!defender->takeSP(5))
{
special.clear(BTEXTRADAMAGE_POINTPHAZE);
}
break;
default:
break;
}
}
}
}
std::string text;
std::string defenderName;
text = defenderName = defender->getName();
if (saveResult == false)
{
if (totalDamage > 0)
{
text += " takes ";
char tmp[20];
sprintf(tmp, "%d", totalDamage);
text += tmp;
//.........这里部分代码省略.........