mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 03:53:52 +00:00
Merge remote-tracking branch 'zini/master' into nifogre
This commit is contained in:
commit
82091e3d07
13 changed files with 209 additions and 114 deletions
|
@ -16,6 +16,8 @@
|
||||||
#include "../mwworld/cellstore.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
#include "../mwworld/physicssystem.hpp"
|
#include "../mwworld/physicssystem.hpp"
|
||||||
#include "../mwworld/nullaction.hpp"
|
#include "../mwworld/nullaction.hpp"
|
||||||
|
#include "../mwworld/containerstore.hpp"
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
#include "../mwrender/objects.hpp"
|
#include "../mwrender/objects.hpp"
|
||||||
#include "../mwrender/renderinginterface.hpp"
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
|
@ -290,6 +292,76 @@ namespace MWClass
|
||||||
ref->mBase = record;
|
ref->mBase = record;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Armor::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
||||||
|
{
|
||||||
|
MWWorld::InventoryStore& invStore = MWWorld::Class::get(npc).getInventoryStore(npc);
|
||||||
|
|
||||||
|
// slots that this item can be equipped in
|
||||||
|
std::pair<std::vector<int>, bool> slots = MWWorld::Class::get(ptr).getEquipmentSlots(ptr);
|
||||||
|
|
||||||
|
std::string npcRace = npc.get<ESM::NPC>()->mBase->mRace;
|
||||||
|
|
||||||
|
for (std::vector<int>::const_iterator slot=slots.first.begin();
|
||||||
|
slot!=slots.first.end(); ++slot)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Beast races cannot equip shoes / boots, or full helms (head part vs hair part)
|
||||||
|
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(npcRace);
|
||||||
|
if(race->mData.mFlags & ESM::Race::Beast)
|
||||||
|
{
|
||||||
|
std::vector<ESM::PartReference> parts = ptr.get<ESM::Armor>()->mBase->mParts.mParts;
|
||||||
|
|
||||||
|
if(*slot == MWWorld::InventoryStore::Slot_Helmet)
|
||||||
|
{
|
||||||
|
for(std::vector<ESM::PartReference>::iterator itr = parts.begin(); itr != parts.end(); ++itr)
|
||||||
|
{
|
||||||
|
if((*itr).mPart == ESM::PRT_Head)
|
||||||
|
{
|
||||||
|
if(npc == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() )
|
||||||
|
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage13}");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*slot == MWWorld::InventoryStore::Slot_Boots)
|
||||||
|
{
|
||||||
|
for(std::vector<ESM::PartReference>::iterator itr = parts.begin(); itr != parts.end(); ++itr)
|
||||||
|
{
|
||||||
|
if((*itr).mPart == ESM::PRT_LFoot || (*itr).mPart == ESM::PRT_RFoot)
|
||||||
|
{
|
||||||
|
if(npc == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() )
|
||||||
|
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage14}");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*slot == MWWorld::InventoryStore::Slot_CarriedLeft)
|
||||||
|
{
|
||||||
|
MWWorld::ContainerStoreIterator weapon = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||||
|
|
||||||
|
if(weapon == invStore.end())
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if(weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::LongBladeTwoHand ||
|
||||||
|
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::BluntTwoClose ||
|
||||||
|
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::BluntTwoWide ||
|
||||||
|
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::SpearTwoWide ||
|
||||||
|
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::AxeTwoHand ||
|
||||||
|
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanBow ||
|
||||||
|
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanCrossbow)
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> Armor::use (const MWWorld::Ptr& ptr) const
|
boost::shared_ptr<MWWorld::Action> Armor::use (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
|
||||||
|
|
|
@ -67,6 +67,9 @@ namespace MWClass
|
||||||
|
|
||||||
virtual void applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
|
virtual void applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
|
||||||
|
|
||||||
|
virtual int canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const;
|
||||||
|
///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that.
|
||||||
|
|
||||||
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
|
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
|
||||||
const;
|
const;
|
||||||
///< Generate action for using via inventory menu
|
///< Generate action for using via inventory menu
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "../mwworld/cellstore.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
#include "../mwworld/physicssystem.hpp"
|
#include "../mwworld/physicssystem.hpp"
|
||||||
#include "../mwworld/nullaction.hpp"
|
#include "../mwworld/nullaction.hpp"
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
#include "../mwgui/tooltips.hpp"
|
#include "../mwgui/tooltips.hpp"
|
||||||
|
|
||||||
|
@ -237,6 +238,57 @@ namespace MWClass
|
||||||
ref->mBase = record;
|
ref->mBase = record;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Clothing::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
||||||
|
{
|
||||||
|
// slots that this item can be equipped in
|
||||||
|
std::pair<std::vector<int>, bool> slots = MWWorld::Class::get(ptr).getEquipmentSlots(ptr);
|
||||||
|
|
||||||
|
std::string npcRace = npc.get<ESM::NPC>()->mBase->mRace;
|
||||||
|
|
||||||
|
for (std::vector<int>::const_iterator slot=slots.first.begin();
|
||||||
|
slot!=slots.first.end(); ++slot)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Beast races cannot equip shoes / boots, or full helms (head part vs hair part)
|
||||||
|
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(npcRace);
|
||||||
|
if(race->mData.mFlags & ESM::Race::Beast)
|
||||||
|
{
|
||||||
|
std::vector<ESM::PartReference> parts = ptr.get<ESM::Clothing>()->mBase->mParts.mParts;
|
||||||
|
|
||||||
|
if(*slot == MWWorld::InventoryStore::Slot_Helmet)
|
||||||
|
{
|
||||||
|
for(std::vector<ESM::PartReference>::iterator itr = parts.begin(); itr != parts.end(); ++itr)
|
||||||
|
{
|
||||||
|
if((*itr).mPart == ESM::PRT_Head)
|
||||||
|
{
|
||||||
|
if(npc == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() )
|
||||||
|
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage13}");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*slot == MWWorld::InventoryStore::Slot_Boots)
|
||||||
|
{
|
||||||
|
for(std::vector<ESM::PartReference>::iterator itr = parts.begin(); itr != parts.end(); ++itr)
|
||||||
|
{
|
||||||
|
if((*itr).mPart == ESM::PRT_LFoot || (*itr).mPart == ESM::PRT_RFoot)
|
||||||
|
{
|
||||||
|
if(npc == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() )
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage15}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> Clothing::use (const MWWorld::Ptr& ptr) const
|
boost::shared_ptr<MWWorld::Action> Clothing::use (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
|
||||||
|
|
|
@ -61,6 +61,9 @@ namespace MWClass
|
||||||
|
|
||||||
virtual void applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
|
virtual void applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
|
||||||
|
|
||||||
|
virtual int canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const;
|
||||||
|
///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that.
|
||||||
|
|
||||||
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
|
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
|
||||||
const;
|
const;
|
||||||
///< Generate action for using via inventory menu
|
///< Generate action for using via inventory menu
|
||||||
|
|
|
@ -384,6 +384,32 @@ namespace MWClass
|
||||||
ref->mBase = record;
|
ref->mBase = record;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Weapon::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
||||||
|
{
|
||||||
|
std::pair<std::vector<int>, bool> slots = MWWorld::Class::get(ptr).getEquipmentSlots(ptr);
|
||||||
|
|
||||||
|
// equip the item in the first free slot
|
||||||
|
for (std::vector<int>::const_iterator slot=slots.first.begin();
|
||||||
|
slot!=slots.first.end(); ++slot)
|
||||||
|
{
|
||||||
|
if(*slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
||||||
|
{
|
||||||
|
if(ptr.get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::LongBladeTwoHand ||
|
||||||
|
ptr.get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::BluntTwoClose ||
|
||||||
|
ptr.get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::BluntTwoWide ||
|
||||||
|
ptr.get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::SpearTwoWide ||
|
||||||
|
ptr.get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::AxeTwoHand ||
|
||||||
|
ptr.get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanBow ||
|
||||||
|
ptr.get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanCrossbow)
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> Weapon::use (const MWWorld::Ptr& ptr) const
|
boost::shared_ptr<MWWorld::Action> Weapon::use (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
|
||||||
|
|
|
@ -67,6 +67,9 @@ namespace MWClass
|
||||||
|
|
||||||
virtual void applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
|
virtual void applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
|
||||||
|
|
||||||
|
virtual int canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const;
|
||||||
|
///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that.
|
||||||
|
|
||||||
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
|
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
|
||||||
const;
|
const;
|
||||||
///< Generate action for using via inventory menu
|
///< Generate action for using via inventory menu
|
||||||
|
|
|
@ -36,8 +36,7 @@ namespace MWMechanics
|
||||||
void Actors::updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused)
|
void Actors::updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused)
|
||||||
{
|
{
|
||||||
if (!paused && ptr.getRefData().getHandle()!="player")
|
if (!paused && ptr.getRefData().getHandle()!="player")
|
||||||
MWWorld::Class::get (ptr).getInventoryStore (ptr).autoEquip (
|
MWWorld::Class::get (ptr).getInventoryStore (ptr).autoEquip (ptr);
|
||||||
MWWorld::Class::get (ptr).getNpcStats (ptr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actors::adjustMagicEffects (const MWWorld::Ptr& creature)
|
void Actors::adjustMagicEffects (const MWWorld::Ptr& creature)
|
||||||
|
|
|
@ -53,14 +53,18 @@ namespace MWMechanics
|
||||||
|
|
||||||
bool Enchanting::create()
|
bool Enchanting::create()
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||||
ESM::Enchantment enchantment;
|
ESM::Enchantment enchantment;
|
||||||
enchantment.mData.mCharge = getGemCharge();
|
enchantment.mData.mCharge = getGemCharge();
|
||||||
|
|
||||||
//Exception for Azura Star, it's not destroyed after enchanting
|
mSoulGemPtr.getRefData().setCount (mSoulGemPtr.getRefData().getCount()-1);
|
||||||
|
|
||||||
|
//Exception for Azura Star, new one will be added after enchanting
|
||||||
if(boost::iequals(mSoulGemPtr.get<ESM::Miscellaneous>()->mBase->mId, "Misc_SoulGem_Azura"))
|
if(boost::iequals(mSoulGemPtr.get<ESM::Miscellaneous>()->mBase->mId, "Misc_SoulGem_Azura"))
|
||||||
mSoulGemPtr.getCellRef().mSoul="";
|
{
|
||||||
else
|
MWWorld::ManualRef azura (MWBase::Environment::get().getWorld()->getStore(), "Misc_SoulGem_Azura");
|
||||||
mSoulGemPtr.getRefData().setCount (mSoulGemPtr.getRefData().getCount()-1);
|
MWWorld::Class::get (player).getContainerStore (player).add (azura.getPtr());
|
||||||
|
}
|
||||||
|
|
||||||
if(mSelfEnchanting)
|
if(mSelfEnchanting)
|
||||||
{
|
{
|
||||||
|
@ -87,7 +91,6 @@ namespace MWMechanics
|
||||||
MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), mOldItemId);
|
MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), mOldItemId);
|
||||||
ref.getPtr().getRefData().setCount (mOldItemCount-1);
|
ref.getPtr().getRefData().setCount (mOldItemCount-1);
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
|
||||||
MWWorld::Class::get (player).getContainerStore (player).add (ref.getPtr());
|
MWWorld::Class::get (player).getContainerStore (player).add (ref.getPtr());
|
||||||
if(!mSelfEnchanting)
|
if(!mSelfEnchanting)
|
||||||
payForEnchantment();
|
payForEnchantment();
|
||||||
|
|
|
@ -18,8 +18,21 @@ namespace MWWorld
|
||||||
|
|
||||||
void ActionEquip::executeImp (const Ptr& actor)
|
void ActionEquip::executeImp (const Ptr& actor)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr object = getTarget();
|
||||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(actor).getInventoryStore(actor);
|
MWWorld::InventoryStore& invStore = MWWorld::Class::get(actor).getInventoryStore(actor);
|
||||||
|
|
||||||
|
switch(MWWorld::Class::get (object).canBeEquipped (object, actor))
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return;
|
||||||
|
case 2:
|
||||||
|
invStore.equip(MWWorld::InventoryStore::Slot_CarriedLeft, invStore.end());
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
invStore.equip(MWWorld::InventoryStore::Slot_CarriedRight, invStore.end());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// slots that this item can be equipped in
|
// slots that this item can be equipped in
|
||||||
std::pair<std::vector<int>, bool> slots = MWWorld::Class::get(getTarget()).getEquipmentSlots(getTarget());
|
std::pair<std::vector<int>, bool> slots = MWWorld::Class::get(getTarget()).getEquipmentSlots(getTarget());
|
||||||
|
|
||||||
|
@ -27,7 +40,7 @@ namespace MWWorld
|
||||||
MWWorld::ContainerStoreIterator it = invStore.begin();
|
MWWorld::ContainerStoreIterator it = invStore.begin();
|
||||||
for (; it != invStore.end(); ++it)
|
for (; it != invStore.end(); ++it)
|
||||||
{
|
{
|
||||||
if (*it == getTarget())
|
if (*it == object)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -44,108 +57,6 @@ namespace MWWorld
|
||||||
slot!=slots.first.end(); ++slot)
|
slot!=slots.first.end(); ++slot)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Beast races cannot equip shoes / boots, or full helms (head part vs hair part)
|
|
||||||
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(npcRace);
|
|
||||||
if(race->mData.mFlags & ESM::Race::Beast)
|
|
||||||
{
|
|
||||||
if(*slot == MWWorld::InventoryStore::Slot_Helmet)
|
|
||||||
{
|
|
||||||
std::vector<ESM::PartReference> parts;
|
|
||||||
if(it.getType() == MWWorld::ContainerStore::Type_Clothing)
|
|
||||||
parts = it->get<ESM::Clothing>()->mBase->mParts.mParts;
|
|
||||||
else
|
|
||||||
parts = it->get<ESM::Armor>()->mBase->mParts.mParts;
|
|
||||||
|
|
||||||
bool allow = true;
|
|
||||||
for(std::vector<ESM::PartReference>::iterator itr = parts.begin(); itr != parts.end(); ++itr)
|
|
||||||
{
|
|
||||||
if((*itr).mPart == ESM::PRT_Head)
|
|
||||||
{
|
|
||||||
if(actor == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() )
|
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage13}");
|
|
||||||
|
|
||||||
allow = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!allow)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*slot == MWWorld::InventoryStore::Slot_Boots)
|
|
||||||
{
|
|
||||||
bool allow = true;
|
|
||||||
std::vector<ESM::PartReference> parts;
|
|
||||||
if(it.getType() == MWWorld::ContainerStore::Type_Clothing)
|
|
||||||
parts = it->get<ESM::Clothing>()->mBase->mParts.mParts;
|
|
||||||
else
|
|
||||||
parts = it->get<ESM::Armor>()->mBase->mParts.mParts;
|
|
||||||
for(std::vector<ESM::PartReference>::iterator itr = parts.begin(); itr != parts.end(); ++itr)
|
|
||||||
{
|
|
||||||
if((*itr).mPart == ESM::PRT_LFoot || (*itr).mPart == ESM::PRT_RFoot)
|
|
||||||
{
|
|
||||||
allow = false;
|
|
||||||
// Only notify the player, not npcs
|
|
||||||
if(actor == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() )
|
|
||||||
{
|
|
||||||
if(it.getType() == MWWorld::ContainerStore::Type_Clothing){ // It's shoes
|
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage15}");
|
|
||||||
}
|
|
||||||
|
|
||||||
else // It's boots
|
|
||||||
{
|
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage14}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!allow)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//Disable twohanded when shield equipped, shield when twohanded equipped
|
|
||||||
if(*slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
|
||||||
{
|
|
||||||
if (it.getType() == MWWorld::ContainerStore::Type_Weapon)
|
|
||||||
{
|
|
||||||
if(it->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::LongBladeTwoHand ||
|
|
||||||
it->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::BluntTwoClose ||
|
|
||||||
it->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::BluntTwoWide ||
|
|
||||||
it->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::SpearTwoWide ||
|
|
||||||
it->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::AxeTwoHand ||
|
|
||||||
it->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanBow ||
|
|
||||||
it->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanCrossbow)
|
|
||||||
{
|
|
||||||
//unequip lefthand item
|
|
||||||
invStore.equip(MWWorld::InventoryStore::Slot_CarriedLeft, invStore.end());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(*slot == MWWorld::InventoryStore::Slot_CarriedLeft)
|
|
||||||
{
|
|
||||||
ContainerStoreIterator weapon = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
|
||||||
|
|
||||||
if (weapon.getType() == MWWorld::ContainerStore::Type_Weapon)
|
|
||||||
{
|
|
||||||
if(weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::LongBladeTwoHand ||
|
|
||||||
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::BluntTwoClose ||
|
|
||||||
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::BluntTwoWide ||
|
|
||||||
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::SpearTwoWide ||
|
|
||||||
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::AxeTwoHand ||
|
|
||||||
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanBow ||
|
|
||||||
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanCrossbow)
|
|
||||||
{
|
|
||||||
//unequip twohanded item
|
|
||||||
invStore.equip(MWWorld::InventoryStore::Slot_CarriedRight, invStore.end());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if all slots are occupied, replace the last slot
|
// if all slots are occupied, replace the last slot
|
||||||
if (slot == --slots.first.end())
|
if (slot == --slots.first.end())
|
||||||
{
|
{
|
||||||
|
@ -163,10 +74,10 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string script = MWWorld::Class::get(*it).getScript(*it);
|
std::string script = MWWorld::Class::get(object).getScript(object);
|
||||||
|
|
||||||
/* Set OnPCEquip Variable on item's script, if the player is equipping it, and it has a script with that variable declared */
|
/* Set OnPCEquip Variable on item's script, if the player is equipping it, and it has a script with that variable declared */
|
||||||
if(equipped && actor == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() && script != "")
|
if(equipped && actor == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() && script != "")
|
||||||
(*it).mRefData->getLocals().setVarByInt(script, "onpcequip", 1);
|
(object).mRefData->getLocals().setVarByInt(script, "onpcequip", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -264,6 +264,11 @@ namespace MWWorld
|
||||||
throw std::runtime_error ("class can't be enchanted");
|
throw std::runtime_error ("class can't be enchanted");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Class::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void Class::adjustPosition(const MWWorld::Ptr& ptr) const
|
void Class::adjustPosition(const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,6 +245,9 @@ namespace MWWorld
|
||||||
|
|
||||||
virtual void applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
|
virtual void applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
|
||||||
|
|
||||||
|
virtual int canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const;
|
||||||
|
///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that.
|
||||||
|
|
||||||
virtual Ptr
|
virtual Ptr
|
||||||
copyToCell(const Ptr &ptr, CellStore &cell) const;
|
copyToCell(const Ptr &ptr, CellStore &cell) const;
|
||||||
|
|
||||||
|
|
|
@ -128,8 +128,11 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getSlot (int slot)
|
||||||
return mSlots[slot];
|
return mSlots[slot];
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats)
|
void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& npc)
|
||||||
{
|
{
|
||||||
|
const MWMechanics::NpcStats& stats = MWWorld::Class::get(npc).getNpcStats(npc);
|
||||||
|
MWWorld::InventoryStore& invStore = MWWorld::Class::get(npc).getInventoryStore(npc);
|
||||||
|
|
||||||
TSlots slots;
|
TSlots slots;
|
||||||
initSlots (slots);
|
initSlots (slots);
|
||||||
|
|
||||||
|
@ -183,6 +186,18 @@ void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch(MWWorld::Class::get (test).canBeEquipped (test, npc))
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
continue;
|
||||||
|
case 2:
|
||||||
|
invStore.equip(MWWorld::InventoryStore::Slot_CarriedLeft, invStore.end());
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
invStore.equip(MWWorld::InventoryStore::Slot_CarriedRight, invStore.end());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!itemsSlots.second) // if itemsSlots.second is true, item can stay stacked when equipped
|
if (!itemsSlots.second) // if itemsSlots.second is true, item can stay stacked when equipped
|
||||||
{
|
{
|
||||||
// unstack item pointed to by iterator if required
|
// unstack item pointed to by iterator if required
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace MWWorld
|
||||||
|
|
||||||
ContainerStoreIterator getSlot (int slot);
|
ContainerStoreIterator getSlot (int slot);
|
||||||
|
|
||||||
void autoEquip (const MWMechanics::NpcStats& stats);
|
void autoEquip (const MWWorld::Ptr& npc);
|
||||||
///< Auto equip items according to stats and item value.
|
///< Auto equip items according to stats and item value.
|
||||||
|
|
||||||
const MWMechanics::MagicEffects& getMagicEffects();
|
const MWMechanics::MagicEffects& getMagicEffects();
|
||||||
|
|
Loading…
Reference in a new issue