void BTPc::activateItems(BTDisplay &d) { BTGame *game = BTGame::getGame(); BTParty &party = game->getParty(); int pc = party.find(this); BTFactory<BTItem> &itemList = game->getItemList(); BTFactory<BTSpell, BTSpell1> &spellList = game->getSpellList(); int numItems = 0; for (numItems = 0; numItems < BT_ITEMS; ++numItems) { if (BTITEM_NONE == item[numItems].id) break; if (BTITEM_EQUIPPED != item[numItems].equipped) continue; if (BTTIMESUSABLE_CONTINUOUS == item[numItems].charges) { int spellCast = itemList[item[numItems].id].getSpellCast(); if (spellCast != BTITEMCAST_NONE) { int effectID = item[numItems].effectID; if ((effectID != BTEFFECTID_NONE) && (!game->hasEffectID(effectID))) effectID = BTEFFECTID_NONE; if (effectID == BTEFFECTID_NONE) { item[numItems].effectID = effectID = game->nextEffectID(); spellList[spellCast].silentActivate(d, pc, effectID, level); } } } } }
void BTPc::deactivateItems(BTDisplay &d) { BTGame *game = BTGame::getGame(); BTParty &party = game->getParty(); int pc = party.find(this); BTFactory<BTItem> &itemList = game->getItemList(); BTFactory<BTSpell, BTSpell1> &spellList = game->getSpellList(); int numItems = 0; for (numItems = 0; numItems < BT_ITEMS; ++numItems) { if (BTITEM_NONE == item[numItems].id) break; if (BTITEM_EQUIPPED != item[numItems].equipped) continue; if (BTTIMESUSABLE_CONTINUOUS == item[numItems].charges) { int effectID = item[numItems].effectID; if (effectID != BTEFFECTID_NONE) { game->clearEffectsByEffectID(d, effectID); item[numItems].effectID = BTEFFECTID_NONE; } } } }
void BTParty::giveItem(int itemID, BTDisplay &d) { BTGame *game = BTGame::getGame(); int who = 0; int charges = game->getItemList()[itemID].getTimesUsable(); for (; who < size(); ++who) { if ((*this)[who]->giveItem(itemID, true, charges)) break; } char tmp[100]; if (who < size()) { snprintf(tmp, 100, "%s gets %s.", (*this)[who]->name, game->getItemList()[itemID].getName().c_str()); } else { snprintf(tmp, 100, "No one has room for %s!", game->getItemList()[itemID].getName().c_str()); } d.drawText(tmp); }
std::string BTPc::attack(BTCombatant *defender, int weapon, int &numAttacksLeft, int &activeNum) { BTGame *game = BTGame::getGame(); BTFactory<BTItem> &itemList = game->getItemList(); BTFactory<BTMonster> &monList = game->getMonsterList(); BTDice damageDice(1, 2); IShort chanceXSpecial(0); IShort xSpecial(BTEXTRADAMAGE_NONE); bool melee = true; if (-1 == weapon) { if (BTMONSTER_NONE != monster) { damageDice = monList[monster].getMeleeDamage(); chanceXSpecial = 100; xSpecial = monList[monster].getMeleeExtra(); } else { XMLVector<BTSkill*> &skill = game->getSkillList(); for (int i = 0; i < skill.size(); ++i) { if ((skill[i]->special == BTSKILLSPECIAL_BAREHANDS) && (hasSkillUse(i))) { BTDice *skillDice = skill[i]->getRoll(getSkill(i)); if (skillDice) damageDice = *skillDice; break; } } } } else { BTItem &itemWeapon = itemList[weapon]; damageDice = itemWeapon.getDamage(); chanceXSpecial = itemWeapon.getChanceXSpecial(); xSpecial = itemWeapon.getXSpecial(); if ((BTITEM_ARROW == itemWeapon.getType()) || (BTITEM_THROWNWEAPON == itemWeapon.getType())) melee = false; } if (stat[BTSTAT_ST] > 14) damageDice.setModifier(damageDice.getModifier() + stat[BTSTAT_ST] - 14); std::string cause; std::string effect; if (-1 == weapon) { if (BTMONSTER_NONE == monster) { cause = "punches at"; effect = "and strikes"; } else { cause = monList[monster].getMeleeMessage(); effect = "and hits"; } } else { BTItem &itemWeapon = itemList[weapon]; cause = itemWeapon.getCause(); effect = itemWeapon.getEffect(); if ((effect.length() >= 4) && (0 == strcmp(effect.c_str() + effect.length() - 4, " for"))) effect.resize(effect.length() - 4); } return BTCombatant::attack(defender, melee, cause, effect, damageDice, chanceXSpecial, xSpecial, numAttacksLeft, activeNum); }