mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-13 06:13:06 +00:00
Unify soulgems and restore soul text
This commit is contained in:
parent
d9ea6e36fa
commit
ac84027b90
5 changed files with 25 additions and 42 deletions
|
|
@ -143,7 +143,7 @@ namespace MWClass
|
||||||
countString = " (" + std::to_string(count) + ")";
|
countString = " (" + std::to_string(count) + ")";
|
||||||
|
|
||||||
std::string_view name = getName(ptr);
|
std::string_view name = getName(ptr);
|
||||||
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name)) + MWGui::ToolTips::getCountString(count);
|
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name)) + MWGui::ToolTips::getCountString(count) + MWGui::ToolTips::getSoulString(ptr.getCellRef());
|
||||||
info.icon = ref->mBase->mIcon;
|
info.icon = ref->mBase->mIcon;
|
||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
|
|
@ -204,9 +204,7 @@ namespace MWClass
|
||||||
|
|
||||||
std::unique_ptr<MWWorld::Action> Miscellaneous::use (const MWWorld::Ptr& ptr, bool force) const
|
std::unique_ptr<MWWorld::Action> Miscellaneous::use (const MWWorld::Ptr& ptr, bool force) const
|
||||||
{
|
{
|
||||||
const std::string_view soulgemPrefix = "misc_soulgem";
|
if (isSoulGem(ptr))
|
||||||
|
|
||||||
if (Misc::StringUtils::ciStartsWith(ptr.getCellRef().getRefId(), soulgemPrefix))
|
|
||||||
return std::make_unique<MWWorld::ActionSoulgem>(ptr);
|
return std::make_unique<MWWorld::ActionSoulgem>(ptr);
|
||||||
|
|
||||||
return std::make_unique<MWWorld::NullAction>();
|
return std::make_unique<MWWorld::NullAction>();
|
||||||
|
|
@ -231,4 +229,9 @@ namespace MWClass
|
||||||
return ref->mBase->mData.mIsKey != 0;
|
return ref->mBase->mData.mIsKey != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Miscellaneous::isSoulGem(const MWWorld::ConstPtr& ptr) const
|
||||||
|
{
|
||||||
|
return Misc::StringUtils::ciStartsWith(ptr.getCellRef().getRefId(), "misc_soulgem");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,8 @@ namespace MWClass
|
||||||
bool isKey (const MWWorld::ConstPtr &ptr) const override;
|
bool isKey (const MWWorld::ConstPtr &ptr) const override;
|
||||||
|
|
||||||
bool isGold (const MWWorld::ConstPtr& ptr) const override;
|
bool isGold (const MWWorld::ConstPtr& ptr) const override;
|
||||||
|
|
||||||
|
bool isSoulGem(const MWWorld::ConstPtr& ptr) const override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -172,13 +172,9 @@ void soulTrap(const MWWorld::Ptr& creature)
|
||||||
MWWorld::ContainerStore& container = caster.getClass().getContainerStore(caster);
|
MWWorld::ContainerStore& container = caster.getClass().getContainerStore(caster);
|
||||||
MWWorld::ContainerStoreIterator gem = container.end();
|
MWWorld::ContainerStoreIterator gem = container.end();
|
||||||
float gemCapacity = std::numeric_limits<float>::max();
|
float gemCapacity = std::numeric_limits<float>::max();
|
||||||
std::string soulgemFilter = "misc_soulgem"; // no other way to check for soulgems? :/
|
for (auto it = container.begin(MWWorld::ContainerStore::Type_Miscellaneous); it != container.end(); ++it)
|
||||||
for (MWWorld::ContainerStoreIterator it = container.begin(MWWorld::ContainerStore::Type_Miscellaneous);
|
|
||||||
it != container.end(); ++it)
|
|
||||||
{
|
{
|
||||||
const std::string& id = it->getCellRef().getRefId();
|
if (it->getClass().isSoulGem(*it))
|
||||||
if (id.size() >= soulgemFilter.size()
|
|
||||||
&& id.substr(0,soulgemFilter.size()) == soulgemFilter)
|
|
||||||
{
|
{
|
||||||
float thisGemCapacity = it->get<ESM::Miscellaneous>()->mBase->mData.mValue * fSoulgemMult;
|
float thisGemCapacity = it->get<ESM::Miscellaneous>()->mBase->mData.mValue * fSoulgemMult;
|
||||||
if (thisGemCapacity >= creatureSoulValue && thisGemCapacity < gemCapacity
|
if (thisGemCapacity >= creatureSoulValue && thisGemCapacity < gemCapacity
|
||||||
|
|
|
||||||
|
|
@ -303,55 +303,35 @@ namespace MWScript
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore (ptr);
|
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore (ptr);
|
||||||
MWWorld::ContainerStoreIterator it = invStore.begin();
|
auto found = invStore.end();
|
||||||
|
const auto& store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
|
|
||||||
// With soul gems we prefer filled ones.
|
// With soul gems we prefer filled ones.
|
||||||
|
for (auto it = invStore.begin(); it != invStore.end(); ++it)
|
||||||
const std::string soulgemPrefix = "misc_soulgem";
|
|
||||||
|
|
||||||
if (Misc::StringUtils::ciStartsWith(item, soulgemPrefix))
|
|
||||||
{
|
{
|
||||||
it = invStore.end();
|
if (Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), item))
|
||||||
|
|
||||||
for (auto it_any = invStore.begin(); it_any != invStore.end(); ++it_any)
|
|
||||||
{
|
{
|
||||||
if (::Misc::StringUtils::ciEqual(it_any->getCellRef().getRefId(), item))
|
found = it;
|
||||||
{
|
const std::string& soul = it->getCellRef().getSoul();
|
||||||
if (!it_any->getCellRef().getSoul().empty() &&
|
if (!it->getClass().isSoulGem(*it) || (!soul.empty() && store.get<ESM::Creature>().search(soul)))
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().search(it_any->getCellRef().getSoul()))
|
|
||||||
{
|
|
||||||
it = it_any;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (it == invStore.end())
|
|
||||||
it = it_any;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (; it != invStore.end(); ++it)
|
|
||||||
{
|
|
||||||
if (::Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), item))
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it == invStore.end())
|
if (found == invStore.end())
|
||||||
{
|
{
|
||||||
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), item, 1);
|
MWWorld::ManualRef ref(store, item, 1);
|
||||||
it = ptr.getClass().getContainerStore (ptr).add (ref.getPtr(), 1, ptr, false);
|
found = ptr.getClass().getContainerStore(ptr).add(ref.getPtr(), 1, ptr, false);
|
||||||
Log(Debug::Warning) << "Implicitly adding one " << item <<
|
Log(Debug::Warning) << "Implicitly adding one " << item <<
|
||||||
" to the inventory store of " << ptr.getCellRef().getRefId() <<
|
" to the inventory store of " << ptr.getCellRef().getRefId() <<
|
||||||
" to fulfill the requirements of Equip instruction";
|
" to fulfill the requirements of Equip instruction";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptr == MWMechanics::getPlayer())
|
if (ptr == MWMechanics::getPlayer())
|
||||||
MWBase::Environment::get().getWindowManager()->useItem(*it, true);
|
MWBase::Environment::get().getWindowManager()->useItem(*found, true);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::unique_ptr<MWWorld::Action> action = it->getClass().use(*it, true);
|
std::unique_ptr<MWWorld::Action> action = found->getClass().use(*found, true);
|
||||||
action->execute(ptr, true);
|
action->execute(ptr, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -293,6 +293,8 @@ namespace MWWorld
|
||||||
|
|
||||||
virtual bool isGold(const MWWorld::ConstPtr& ptr) const { return false; }
|
virtual bool isGold(const MWWorld::ConstPtr& ptr) const { return false; }
|
||||||
|
|
||||||
|
virtual bool isSoulGem(const MWWorld::ConstPtr& ptr) const { return false; }
|
||||||
|
|
||||||
virtual bool allowTelekinesis(const MWWorld::ConstPtr& ptr) const { return true; }
|
virtual bool allowTelekinesis(const MWWorld::ConstPtr& ptr) const { return true; }
|
||||||
///< Return whether this class of object can be activated with telekinesis
|
///< Return whether this class of object can be activated with telekinesis
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue