当前位置: 首页>>代码示例>>C++>>正文


C++ BitField::set方法代码示例

本文整理汇总了C++中BitField::set方法的典型用法代码示例。如果您正苦于以下问题:C++ BitField::set方法的具体用法?C++ BitField::set怎么用?C++ BitField::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BitField的用法示例。


在下文中一共展示了BitField::set方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例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);
  }
 }
}
开发者ID:,项目名称:,代码行数:23,代码来源:

示例3: useAutoCombatSkill

void BTPc::useAutoCombatSkill(bool melee, BitField &special)
{
 BTGame *game = BTGame::getGame();
 BTSkillList &skillList = game->getSkillList();
 for (int i = 0; i < skillList.size(); ++i)
 {
  if ((skillList[i]->use == BTSKILLUSE_AUTOCOMBAT) ||
   ((melee) && (skillList[i]->use == BTSKILLUSE_AUTOCOMBATMELEE)) ||
   ((!melee) && (skillList[i]->use == BTSKILLUSE_AUTOCOMBATRANGED)))
  {
   if (((-1 == skillList[i]->after) || (combat.skillUsed == skillList[i]->after)) && (useSkill(i)))
   {
    special.set(skillList[i]->effect);
   }
  }
 }
}
开发者ID:Methuselas,项目名称:btbuilder,代码行数:17,代码来源:pc.C

示例4: 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;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例5: 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;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的BitField::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。