void BoltExample::draw(IGrafPort& port) { IBoltTop bolt(75, 125, IGPoint2D(100,100)); bolt.adoptAttributeState(new IFrameBundle(kDefaultFrameColor, kDefaultPenWidth)); bolt.draw(port); }
void nbolt(int fx, int fy, int tx, int ty, int hit, int dmg) { bolt(fx,fy,tx,ty,hit,dmg,NORMAL_DAMAGE); }
/* Added 12/30/98 DG */ void icebolt(int fx, int fy, int tx, int ty, int hit, int dmg) { bolt(fx,fy,tx,ty,hit,dmg,COLD); }
void lbolt(int fx, int fy, int tx, int ty, int hit, int dmg) { bolt(fx,fy,tx,ty,hit,dmg,ELECTRICITY); }
void fbolt(int fx, int fy, int tx, int ty, int hit, int dmg) { bolt(fx,fy,tx,ty,hit,dmg,FLAME); }
void MWWorld::InventoryStore::autoEquipWeapon (const MWWorld::Ptr& actor, TSlots& slots_) { if (!actor.getClass().isNpc()) { // In original game creatures do not autoequip weapon, but we need it for weapon sheathing. // The only case when the difference is noticable - when this creature sells weapon. // So just disable weapon autoequipping for creatures which sells weapon. int services = actor.getClass().getServices(actor); bool sellsWeapon = services & (ESM::NPC::Weapon|ESM::NPC::MagicItems); if (sellsWeapon) return; } static const ESM::Skill::SkillEnum weaponSkills[] = { ESM::Skill::LongBlade, ESM::Skill::Axe, ESM::Skill::Spear, ESM::Skill::ShortBlade, ESM::Skill::Marksman, ESM::Skill::BluntWeapon }; const size_t weaponSkillsLength = sizeof(weaponSkills) / sizeof(weaponSkills[0]); bool weaponSkillVisited[weaponSkillsLength] = { false }; // give arrows/bolt with max damage by default int arrowMax = 0; int boltMax = 0; ContainerStoreIterator arrow(end()); ContainerStoreIterator bolt(end()); // rate ammo for (ContainerStoreIterator iter(begin(ContainerStore::Type_Weapon)); iter!=end(); ++iter) { const ESM::Weapon* esmWeapon = iter->get<ESM::Weapon>()->mBase; if (esmWeapon->mData.mType == ESM::Weapon::Arrow) { if (esmWeapon->mData.mChop[1] >= arrowMax) { arrowMax = esmWeapon->mData.mChop[1]; arrow = iter; } } else if (esmWeapon->mData.mType == ESM::Weapon::Bolt) { if (esmWeapon->mData.mChop[1] >= boltMax) { boltMax = esmWeapon->mData.mChop[1]; bolt = iter; } } } // rate weapon for (int i = 0; i < static_cast<int>(weaponSkillsLength); ++i) { int max = 0; int maxWeaponSkill = -1; for (int j = 0; j < static_cast<int>(weaponSkillsLength); ++j) { int skillValue = actor.getClass().getSkill(actor, static_cast<int>(weaponSkills[j])); if (skillValue > max && !weaponSkillVisited[j]) { max = skillValue; maxWeaponSkill = j; } } if (maxWeaponSkill == -1) break; max = 0; ContainerStoreIterator weapon(end()); for (ContainerStoreIterator iter(begin(ContainerStore::Type_Weapon)); iter!=end(); ++iter) { if (!canActorAutoEquip(actor, *iter)) continue; const ESM::Weapon* esmWeapon = iter->get<ESM::Weapon>()->mBase; if (esmWeapon->mData.mType == ESM::Weapon::Arrow || esmWeapon->mData.mType == ESM::Weapon::Bolt) continue; if (iter->getClass().getEquipmentSkill(*iter) == weaponSkills[maxWeaponSkill]) { if (esmWeapon->mData.mChop[1] >= max) { max = esmWeapon->mData.mChop[1]; weapon = iter; } if (esmWeapon->mData.mSlash[1] >= max) { max = esmWeapon->mData.mSlash[1]; weapon = iter; } if (esmWeapon->mData.mThrust[1] >= max) { max = esmWeapon->mData.mThrust[1]; weapon = iter; } } } bool isBow = false; bool isCrossbow = false; if (weapon != end()) { const MWWorld::LiveCellRef<ESM::Weapon> *ref = weapon->get<ESM::Weapon>(); ESM::Weapon::Type type = (ESM::Weapon::Type)ref->mBase->mData.mType; if (type == ESM::Weapon::MarksmanBow) isBow = true; else if (type == ESM::Weapon::MarksmanCrossbow) isCrossbow = true; } if (weapon != end() && weapon->getClass().canBeEquipped(*weapon, actor).first) { // Do not equip ranged weapons, if there is no suitable ammo bool hasAmmo = true; if (isBow == true) { if (arrow == end()) hasAmmo = false; else slots_[Slot_Ammunition] = arrow; } if (isCrossbow == true) { if (bolt == end()) hasAmmo = false; else slots_[Slot_Ammunition] = bolt; } if (hasAmmo) { std::pair<std::vector<int>, bool> itemsSlots = weapon->getClass().getEquipmentSlots (*weapon); if (!itemsSlots.first.empty()) { if (!itemsSlots.second) { if (weapon->getRefData().getCount() > 1) { unstack(*weapon, actor); } } int slot = itemsSlots.first.front(); slots_[slot] = weapon; if (!isBow && !isCrossbow) slots_[Slot_Ammunition] = end(); } break; } } weaponSkillVisited[maxWeaponSkill] = true; } }