2010-08-03 15:24:44 +02:00
|
|
|
#include "misc.hpp"
|
|
|
|
|
2022-06-04 15:26:36 +02:00
|
|
|
#include <MyGUI_TextIterator.h>
|
|
|
|
|
2022-09-08 21:08:59 +02:00
|
|
|
#include <components/esm3/loadcrea.hpp>
|
2022-01-22 15:58:41 +01:00
|
|
|
#include <components/esm3/loadmisc.hpp>
|
2022-09-08 21:08:59 +02:00
|
|
|
#include <components/esm3/loadnpc.hpp>
|
|
|
|
|
2023-06-27 23:41:06 +02:00
|
|
|
#include <components/settings/values.hpp>
|
2010-08-03 15:24:44 +02:00
|
|
|
|
2012-04-23 15:27:03 +02:00
|
|
|
#include "../mwbase/environment.hpp"
|
2012-08-12 18:11:09 +02:00
|
|
|
#include "../mwbase/windowmanager.hpp"
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2013-03-30 15:51:07 +01:00
|
|
|
#include "../mwworld/actionsoulgem.hpp"
|
2012-06-29 16:48:50 +02:00
|
|
|
#include "../mwworld/cellstore.hpp"
|
2015-02-09 15:01:49 +01:00
|
|
|
#include "../mwworld/esmstore.hpp"
|
2012-07-25 17:18:17 +04:00
|
|
|
#include "../mwworld/manualref.hpp"
|
2013-02-17 15:56:22 +01:00
|
|
|
#include "../mwworld/nullaction.hpp"
|
2023-01-16 01:28:21 +01:00
|
|
|
#include "../mwworld/worldmodel.hpp"
|
2010-08-03 17:11:41 +02:00
|
|
|
|
2012-04-16 22:58:16 +02:00
|
|
|
#include "../mwgui/tooltips.hpp"
|
2022-08-24 22:16:03 +02:00
|
|
|
#include "../mwgui/ustring.hpp"
|
2010-08-03 17:11:41 +02:00
|
|
|
|
2012-01-27 15:11:02 +01:00
|
|
|
#include "../mwrender/objects.hpp"
|
2012-07-03 13:15:20 +02:00
|
|
|
#include "../mwrender/renderinginterface.hpp"
|
2012-01-27 15:11:02 +01:00
|
|
|
|
2022-06-29 00:32:11 +02:00
|
|
|
#include "classmodel.hpp"
|
|
|
|
|
2010-08-03 15:24:44 +02:00
|
|
|
namespace MWClass
|
|
|
|
{
|
2022-04-04 02:44:53 +02:00
|
|
|
Miscellaneous::Miscellaneous()
|
|
|
|
: MWWorld::RegisteredClass<Miscellaneous>(ESM::Miscellaneous::sRecordId)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-12-18 15:27:06 +01:00
|
|
|
bool Miscellaneous::isGold(const MWWorld::ConstPtr& ptr) const
|
2015-07-20 08:05:52 +09:00
|
|
|
{
|
2022-10-18 09:26:55 +02:00
|
|
|
return ptr.getCellRef().getRefId() == "gold_001" || ptr.getCellRef().getRefId() == "gold_005"
|
|
|
|
|| ptr.getCellRef().getRefId() == "gold_010" || ptr.getCellRef().getRefId() == "gold_025"
|
|
|
|
|| ptr.getCellRef().getRefId() == "gold_100";
|
2015-07-20 08:05:52 +09:00
|
|
|
}
|
2014-07-18 09:56:58 +02:00
|
|
|
|
2015-01-12 11:29:56 +01:00
|
|
|
void Miscellaneous::insertObjectRendering(
|
|
|
|
const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
2010-08-14 10:02:54 +02:00
|
|
|
{
|
2012-07-24 20:22:11 +04:00
|
|
|
if (!model.empty())
|
|
|
|
{
|
2013-08-07 03:51:57 -07:00
|
|
|
renderingInterface.getObjects().insertModel(ptr, model);
|
2010-08-14 10:02:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-18 15:51:05 +01:00
|
|
|
std::string Miscellaneous::getModel(const MWWorld::ConstPtr& ptr) const
|
2011-11-11 23:01:12 -05:00
|
|
|
{
|
2022-06-29 00:32:11 +02:00
|
|
|
return getClassModel<ESM::Miscellaneous>(ptr);
|
2011-11-11 23:01:12 -05:00
|
|
|
}
|
|
|
|
|
2022-08-16 21:15:03 +02:00
|
|
|
std::string_view Miscellaneous::getName(const MWWorld::ConstPtr& ptr) const
|
2010-08-03 17:11:41 +02:00
|
|
|
{
|
2015-12-18 15:27:06 +01:00
|
|
|
const MWWorld::LiveCellRef<ESM::Miscellaneous>* ref = ptr.get<ESM::Miscellaneous>();
|
2019-09-11 00:06:50 +03:00
|
|
|
const std::string& name = ref->mBase->mName;
|
2010-08-03 17:11:41 +02:00
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
return !name.empty() ? name : ref->mBase->mId.getRefIdString();
|
2010-08-03 17:11:41 +02:00
|
|
|
}
|
|
|
|
|
2022-04-06 17:06:55 +02:00
|
|
|
std::unique_ptr<MWWorld::Action> Miscellaneous::activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const
|
2010-08-07 20:25:17 +02:00
|
|
|
{
|
2013-08-08 22:34:53 -07:00
|
|
|
return defaultItemActivate(ptr, actor);
|
2010-08-07 20:25:17 +02:00
|
|
|
}
|
|
|
|
|
2023-02-20 23:18:05 +01:00
|
|
|
ESM::RefId Miscellaneous::getScript(const MWWorld::ConstPtr& ptr) const
|
2010-08-05 15:40:03 +02:00
|
|
|
{
|
2015-12-18 00:12:03 +01:00
|
|
|
const MWWorld::LiveCellRef<ESM::Miscellaneous>* ref = ptr.get<ESM::Miscellaneous>();
|
2010-08-05 15:40:03 +02:00
|
|
|
|
2012-11-05 16:07:59 +04:00
|
|
|
return ref->mBase->mScript;
|
2010-08-05 15:40:03 +02:00
|
|
|
}
|
|
|
|
|
2015-12-18 15:27:06 +01:00
|
|
|
int Miscellaneous::getValue(const MWWorld::ConstPtr& ptr) const
|
2012-04-07 19:53:49 +02:00
|
|
|
{
|
2015-12-18 15:27:06 +01:00
|
|
|
const MWWorld::LiveCellRef<ESM::Miscellaneous>* ref = ptr.get<ESM::Miscellaneous>();
|
2012-04-07 19:53:49 +02:00
|
|
|
|
2014-01-09 01:34:10 +01:00
|
|
|
int value = ref->mBase->mData.mValue;
|
2014-05-25 14:13:07 +02:00
|
|
|
if (ptr.getCellRef().getGoldValue() > 1 && ptr.getRefData().getCount() == 1)
|
|
|
|
value = ptr.getCellRef().getGoldValue();
|
2013-03-27 17:27:43 +01:00
|
|
|
|
2022-08-16 21:15:03 +02:00
|
|
|
if (!ptr.getCellRef().getSoul().empty())
|
2013-03-27 17:39:49 +01:00
|
|
|
{
|
2018-03-08 23:38:04 +00:00
|
|
|
const ESM::Creature* creature
|
2023-04-20 21:07:53 +02:00
|
|
|
= MWBase::Environment::get().getESMStore()->get<ESM::Creature>().search(ref->mRef.getSoul());
|
2018-05-21 13:59:20 +01:00
|
|
|
if (creature)
|
|
|
|
{
|
2018-05-21 18:16:04 +01:00
|
|
|
int soul = creature->mData.mSoul;
|
2023-06-27 23:41:06 +02:00
|
|
|
if (Settings::game().mRebalanceSoulGemValues)
|
2018-05-21 13:59:20 +01:00
|
|
|
{
|
2018-05-21 22:14:23 +01:00
|
|
|
// use the 'soul gem value rebalance' formula from the Morrowind Code Patch
|
2018-05-21 13:59:20 +01:00
|
|
|
float soulValue = 0.0001 * pow(soul, 3) + 2 * soul;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2018-05-21 13:59:20 +01:00
|
|
|
// for Azura's star add the unfilled value
|
2022-10-18 09:26:55 +02:00
|
|
|
if (ptr.getCellRef().getRefId() == "Misc_SoulGem_Azura")
|
2018-05-21 13:59:20 +01:00
|
|
|
value += soulValue;
|
|
|
|
else
|
|
|
|
value = soulValue;
|
|
|
|
}
|
2018-05-20 17:06:26 +01:00
|
|
|
else
|
2018-05-21 18:16:04 +01:00
|
|
|
value *= soul;
|
2018-05-20 17:06:26 +01:00
|
|
|
}
|
2013-03-27 17:39:49 +01:00
|
|
|
}
|
|
|
|
|
2013-03-27 17:27:43 +01:00
|
|
|
return value;
|
2012-04-07 19:53:49 +02:00
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
const ESM::RefId& Miscellaneous::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
2012-03-13 18:50:32 +02:00
|
|
|
{
|
2022-10-13 23:14:00 +02:00
|
|
|
static const ESM::RefId soundGold = ESM::RefId::stringRefId("Item Gold Up");
|
|
|
|
static const ESM::RefId soundMisc = ESM::RefId::stringRefId("Item Misc Up");
|
2013-03-30 18:29:21 +01:00
|
|
|
if (isGold(ptr))
|
2022-10-13 23:14:00 +02:00
|
|
|
return soundGold;
|
|
|
|
|
|
|
|
return soundMisc;
|
2012-03-13 18:50:32 +02:00
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
const ESM::RefId& Miscellaneous::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
2012-03-13 18:50:32 +02:00
|
|
|
{
|
2022-10-13 23:14:00 +02:00
|
|
|
static const ESM::RefId soundGold = ESM::RefId::stringRefId("Item Gold Down");
|
|
|
|
static const ESM::RefId soundMisc = ESM::RefId::stringRefId("Item Misc Down");
|
2013-03-30 18:29:21 +01:00
|
|
|
if (isGold(ptr))
|
2022-10-13 23:14:00 +02:00
|
|
|
return soundGold;
|
|
|
|
return soundMisc;
|
2012-03-13 18:50:32 +02:00
|
|
|
}
|
2012-04-15 17:52:39 +02:00
|
|
|
|
2022-08-22 16:55:53 +02:00
|
|
|
const std::string& Miscellaneous::getInventoryIcon(const MWWorld::ConstPtr& ptr) const
|
2012-04-15 17:52:39 +02:00
|
|
|
{
|
2015-12-18 15:53:47 +01:00
|
|
|
const MWWorld::LiveCellRef<ESM::Miscellaneous>* ref = ptr.get<ESM::Miscellaneous>();
|
2012-04-15 17:52:39 +02:00
|
|
|
|
2012-11-05 16:07:59 +04:00
|
|
|
return ref->mBase->mIcon;
|
2012-04-15 17:52:39 +02:00
|
|
|
}
|
2012-05-11 10:40:40 +02:00
|
|
|
|
2015-12-19 16:29:07 +01:00
|
|
|
MWGui::ToolTipInfo Miscellaneous::getToolTipInfo(const MWWorld::ConstPtr& ptr, int count) const
|
2012-04-16 22:58:16 +02:00
|
|
|
{
|
2015-12-18 15:27:06 +01:00
|
|
|
const MWWorld::LiveCellRef<ESM::Miscellaneous>* ref = ptr.get<ESM::Miscellaneous>();
|
2012-04-16 22:58:16 +02:00
|
|
|
|
|
|
|
MWGui::ToolTipInfo info;
|
|
|
|
|
2013-03-30 18:29:21 +01:00
|
|
|
bool gold = isGold(ptr);
|
2014-01-29 15:22:07 +01:00
|
|
|
if (gold)
|
|
|
|
count *= getValue(ptr);
|
2012-05-16 17:22:25 +02:00
|
|
|
|
|
|
|
std::string countString;
|
2013-03-30 18:29:21 +01:00
|
|
|
if (!gold)
|
2012-05-16 17:22:25 +02:00
|
|
|
countString = MWGui::ToolTips::getCountString(count);
|
|
|
|
else // gold displays its count also if it's 1.
|
2017-05-06 23:05:13 +02:00
|
|
|
countString = " (" + std::to_string(count) + ")";
|
2012-05-12 14:29:49 +02:00
|
|
|
|
2022-08-16 21:15:03 +02:00
|
|
|
std::string_view name = getName(ptr);
|
2022-08-25 21:37:20 +02:00
|
|
|
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name))
|
|
|
|
+ MWGui::ToolTips::getCountString(count) + MWGui::ToolTips::getSoulString(ptr.getCellRef());
|
2012-11-05 16:07:59 +04:00
|
|
|
info.icon = ref->mBase->mIcon;
|
2012-05-12 14:29:49 +02:00
|
|
|
|
2012-04-16 22:58:16 +02:00
|
|
|
std::string text;
|
|
|
|
|
2016-08-14 19:37:22 +09:00
|
|
|
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
|
2022-09-30 12:16:45 +02:00
|
|
|
if (!gold && !(ref->mBase->mData.mFlags & ESM::Miscellaneous::Key))
|
2013-03-27 17:39:49 +01:00
|
|
|
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
2012-04-16 22:58:16 +02:00
|
|
|
|
2012-04-24 02:02:03 +02:00
|
|
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
|
|
|
|
{
|
2014-07-22 20:03:35 +02:00
|
|
|
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript.getRefIdString(), "Script");
|
2012-04-16 22:58:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
info.text = text;
|
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
2012-07-25 17:18:17 +04:00
|
|
|
|
2023-04-23 20:37:28 +02:00
|
|
|
static MWWorld::Ptr createGold(MWWorld::CellStore& cell, int goldAmount)
|
2012-07-25 17:18:17 +04:00
|
|
|
{
|
2023-04-23 20:37:28 +02:00
|
|
|
std::string_view base = "gold_001";
|
|
|
|
if (goldAmount >= 100)
|
|
|
|
base = "gold_100";
|
|
|
|
else if (goldAmount >= 25)
|
|
|
|
base = "gold_025";
|
|
|
|
else if (goldAmount >= 10)
|
|
|
|
base = "gold_010";
|
|
|
|
else if (goldAmount >= 5)
|
|
|
|
base = "gold_005";
|
2012-08-09 14:33:21 +02:00
|
|
|
|
2023-04-20 21:07:53 +02:00
|
|
|
const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
|
2023-04-23 20:37:28 +02:00
|
|
|
MWWorld::ManualRef newRef(store, ESM::RefId::stringRefId(base));
|
|
|
|
const MWWorld::LiveCellRef<ESM::Miscellaneous>* ref = newRef.getPtr().get<ESM::Miscellaneous>();
|
|
|
|
|
|
|
|
MWWorld::Ptr ptr(cell.insert(ref), &cell);
|
|
|
|
ptr.getCellRef().setGoldValue(goldAmount);
|
|
|
|
ptr.getRefData().setCount(1);
|
|
|
|
return ptr;
|
|
|
|
}
|
2012-07-25 17:18:17 +04:00
|
|
|
|
2023-04-23 20:37:28 +02:00
|
|
|
MWWorld::Ptr Miscellaneous::copyToCell(const MWWorld::ConstPtr& ptr, MWWorld::CellStore& cell, int count) const
|
|
|
|
{
|
|
|
|
MWWorld::Ptr newPtr;
|
2013-03-30 18:29:21 +01:00
|
|
|
if (isGold(ptr))
|
2023-04-23 20:37:28 +02:00
|
|
|
newPtr = createGold(cell, getValue(ptr) * count);
|
|
|
|
else
|
2013-03-30 18:29:21 +01:00
|
|
|
{
|
2023-04-23 20:37:28 +02:00
|
|
|
const MWWorld::LiveCellRef<ESM::Miscellaneous>* ref = ptr.get<ESM::Miscellaneous>();
|
2015-11-14 17:12:05 +01:00
|
|
|
newPtr = MWWorld::Ptr(cell.insert(ref), &cell);
|
2023-04-23 20:37:28 +02:00
|
|
|
newPtr.getRefData().setCount(count);
|
|
|
|
}
|
|
|
|
newPtr.getCellRef().unsetRefNum();
|
|
|
|
newPtr.getRefData().setLuaScripts(nullptr);
|
2023-05-30 21:44:54 +02:00
|
|
|
MWBase::Environment::get().getWorldModel()->registerPtr(newPtr);
|
2023-04-23 20:37:28 +02:00
|
|
|
return newPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
MWWorld::Ptr Miscellaneous::moveToCell(const MWWorld::Ptr& ptr, MWWorld::CellStore& cell) const
|
|
|
|
{
|
|
|
|
MWWorld::Ptr newPtr;
|
|
|
|
if (isGold(ptr))
|
|
|
|
{
|
2023-07-25 13:38:14 +02:00
|
|
|
newPtr = createGold(cell, getValue(ptr) * ptr.getRefData().getCount());
|
2023-04-23 20:37:28 +02:00
|
|
|
newPtr.getRefData() = ptr.getRefData();
|
|
|
|
newPtr.getCellRef().setRefNum(ptr.getCellRef().getRefNum());
|
2014-01-29 15:22:07 +01:00
|
|
|
newPtr.getRefData().setCount(1);
|
2012-07-25 17:18:17 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-12-18 16:24:24 +01:00
|
|
|
const MWWorld::LiveCellRef<ESM::Miscellaneous>* ref = ptr.get<ESM::Miscellaneous>();
|
2015-11-14 17:12:05 +01:00
|
|
|
newPtr = MWWorld::Ptr(cell.insert(ref), &cell);
|
2012-07-25 17:18:17 +04:00
|
|
|
}
|
2023-04-23 20:37:28 +02:00
|
|
|
ptr.getRefData().setLuaScripts(nullptr);
|
2023-05-30 21:44:54 +02:00
|
|
|
MWBase::Environment::get().getWorldModel()->registerPtr(newPtr);
|
2012-07-25 17:18:17 +04:00
|
|
|
return newPtr;
|
|
|
|
}
|
2013-03-30 15:51:07 +01:00
|
|
|
|
2022-07-25 01:47:10 +03:00
|
|
|
std::unique_ptr<MWWorld::Action> Miscellaneous::use(const MWWorld::Ptr& ptr, bool force) const
|
2022-07-24 23:02:26 +03:00
|
|
|
{
|
2022-08-25 21:37:20 +02:00
|
|
|
if (isSoulGem(ptr))
|
2022-07-25 01:47:10 +03:00
|
|
|
return std::make_unique<MWWorld::ActionSoulgem>(ptr);
|
2022-07-24 23:02:26 +03:00
|
|
|
|
2022-07-25 01:47:10 +03:00
|
|
|
return std::make_unique<MWWorld::NullAction>();
|
2013-03-30 15:51:07 +01:00
|
|
|
}
|
|
|
|
|
2015-12-18 15:58:23 +01:00
|
|
|
bool Miscellaneous::canSell(const MWWorld::ConstPtr& item, int npcServices) const
|
2013-04-07 21:38:53 +02:00
|
|
|
{
|
2015-12-18 15:58:23 +01:00
|
|
|
const MWWorld::LiveCellRef<ESM::Miscellaneous>* ref = item.get<ESM::Miscellaneous>();
|
2013-04-07 21:38:53 +02:00
|
|
|
|
2022-09-30 12:16:45 +02:00
|
|
|
return !(ref->mBase->mData.mFlags & ESM::Miscellaneous::Key) && (npcServices & ESM::NPC::Misc) && !isGold(item);
|
2013-04-07 21:38:53 +02:00
|
|
|
}
|
|
|
|
|
2015-12-18 16:00:50 +01:00
|
|
|
float Miscellaneous::getWeight(const MWWorld::ConstPtr& ptr) const
|
2013-05-11 18:38:27 +02:00
|
|
|
{
|
2015-12-18 16:00:50 +01:00
|
|
|
const MWWorld::LiveCellRef<ESM::Miscellaneous>* ref = ptr.get<ESM::Miscellaneous>();
|
2013-05-11 18:38:27 +02:00
|
|
|
return ref->mBase->mData.mWeight;
|
|
|
|
}
|
|
|
|
|
2015-12-18 15:27:06 +01:00
|
|
|
bool Miscellaneous::isKey(const MWWorld::ConstPtr& ptr) const
|
2014-01-01 22:37:52 +01:00
|
|
|
{
|
2015-12-18 15:27:06 +01:00
|
|
|
const MWWorld::LiveCellRef<ESM::Miscellaneous>* ref = ptr.get<ESM::Miscellaneous>();
|
2022-09-30 12:16:45 +02:00
|
|
|
return ref->mBase->mData.mFlags & ESM::Miscellaneous::Key;
|
2014-01-01 22:37:52 +01:00
|
|
|
}
|
|
|
|
|
2022-08-25 21:37:20 +02:00
|
|
|
bool Miscellaneous::isSoulGem(const MWWorld::ConstPtr& ptr) const
|
|
|
|
{
|
2023-03-01 22:48:00 +01:00
|
|
|
return ptr.getCellRef().getRefId().startsWith("misc_soulgem");
|
2022-08-25 21:37:20 +02:00
|
|
|
}
|
|
|
|
|
2010-08-03 15:24:44 +02:00
|
|
|
}
|