void BTPc::equip(BTDisplay &d, int index) { BTFactory<BTItem> &itemList = BTGame::getGame()->getItemList(); BTParty &party = BTGame::getGame()->getParty(); int pc = party.find(this); int type = itemList[item[index].id].getType(); for (int i = 0; i < BT_ITEMS; ++i) { if (BTITEM_NONE == item[i].id) break; if ((item[i].equipped == BTITEM_EQUIPPED) && (type == itemList[item[i].id].getType())) { unequip(d, i); } } ac += itemList[item[index].id].getArmorPlus(); toHit += itemList[item[index].id].getHitPlus(); item[index].equipped = BTITEM_EQUIPPED; if (BTTIMESUSABLE_CONTINUOUS == item[index].charges) { BTGame *game = BTGame::getGame(); BTFactory<BTSpell, BTSpell1> &spellList = BTGame::getGame()->getSpellList(); int spellCast = itemList[item[index].id].getSpellCast(); int effectID = item[index].effectID; if ((effectID != BTEFFECTID_NONE) && (!game->hasEffectID(effectID))) effectID = BTEFFECTID_NONE; if (effectID == BTEFFECTID_NONE) { item[index].effectID = effectID = game->nextEffectID(); spellList[spellCast].silentActivate(d, pc, effectID, level); } } }
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); } } } } }
bool BTPc::equip(BTDisplay &d, int index) { BTItemSlotList &itemSlotList = BTGame::getGame()->getItemSlotList(); BTItemTypeList &itemTypeList = BTGame::getGame()->getItemTypeList(); BTFactory<BTItem> &itemList = BTGame::getGame()->getItemList(); BTParty &party = BTGame::getGame()->getParty(); int pc = party.find(this); int type = itemList[item[index].id].getType(); int itemSlot = itemTypeList[type]->itemSlot; int numberSlots = itemSlotList[itemSlot]->number; int usedSlots = 0; for (int i = 0; i < BT_ITEMS; ++i) { if (BTITEM_NONE == item[i].id) break; if ((item[i].equipped == BTITEM_EQUIPPED) && (itemSlot == itemTypeList[itemList[item[i].id].getType()]->itemSlot)) { if (numberSlots == 1) unequip(d, i); else usedSlots++; } } if (usedSlots >= numberSlots) return false; ac += itemList[item[index].id].getArmorPlus(); if (itemTypeList[itemList[item[index].id].getType()]->toHitBonus == BTTOHITBONUS_ALWAYS) toHit += itemList[item[index].id].getHitPlus(); item[index].equipped = BTITEM_EQUIPPED; if (BTTIMESUSABLE_CONTINUOUS == item[index].charges) { BTGame *game = BTGame::getGame(); BTFactory<BTSpell, BTSpell1> &spellList = BTGame::getGame()->getSpellList(); int spellCast = itemList[item[index].id].getSpellCast(); int effectID = item[index].effectID; if ((effectID != BTEFFECTID_NONE) && (!game->hasEffectID(effectID))) effectID = BTEFFECTID_NONE; if (effectID == BTEFFECTID_NONE) { item[index].effectID = effectID = game->nextEffectID(); spellList[spellCast].silentActivate(d, pc, effectID, level); } } return true; }