mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 17:29:55 +00:00
Allow adding levelled lists with AddItem
This commit is contained in:
parent
f62905eb0a
commit
bdcd2bc802
2 changed files with 32 additions and 4 deletions
|
@ -60,6 +60,7 @@
|
||||||
Bug #5644: Summon effects running on the player during game initialization cause crashes
|
Bug #5644: Summon effects running on the player during game initialization cause crashes
|
||||||
Feature #390: 3rd person look "over the shoulder"
|
Feature #390: 3rd person look "over the shoulder"
|
||||||
Feature #2386: Distant Statics in the form of Object Paging
|
Feature #2386: Distant Statics in the form of Object Paging
|
||||||
|
Feature #2404: Levelled List can not be placed into a container
|
||||||
Feature #4894: Consider actors as obstacles for pathfinding
|
Feature #4894: Consider actors as obstacles for pathfinding
|
||||||
Feature #5043: Head Bobbing
|
Feature #5043: Head Bobbing
|
||||||
Feature #5297: Add a search function to the "Datafiles" tab of the OpenMW launcher
|
Feature #5297: Add a search function to the "Datafiles" tab of the OpenMW launcher
|
||||||
|
|
|
@ -28,12 +28,13 @@
|
||||||
#include "../mwworld/manualref.hpp"
|
#include "../mwworld/manualref.hpp"
|
||||||
|
|
||||||
#include "../mwmechanics/actorutil.hpp"
|
#include "../mwmechanics/actorutil.hpp"
|
||||||
|
#include "../mwmechanics/levelledlist.hpp"
|
||||||
|
|
||||||
#include "ref.hpp"
|
#include "ref.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void addToStore(MWWorld::Ptr& itemPtr, int count, MWWorld::Ptr& ptr, MWWorld::ContainerStore& store, bool resolve = true)
|
void addToStore(const MWWorld::Ptr& itemPtr, int count, MWWorld::Ptr& ptr, MWWorld::ContainerStore& store, bool resolve = true)
|
||||||
{
|
{
|
||||||
if (itemPtr.getClass().getScript(itemPtr).empty())
|
if (itemPtr.getClass().getScript(itemPtr).empty())
|
||||||
{
|
{
|
||||||
|
@ -46,6 +47,30 @@ namespace
|
||||||
store.add (itemPtr, 1, ptr, true, resolve);
|
store.add (itemPtr, 1, ptr, true, resolve);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addRandomToStore(const MWWorld::Ptr& itemPtr, int count, MWWorld::Ptr& owner, MWWorld::ContainerStore& store, bool topLevel = true)
|
||||||
|
{
|
||||||
|
if(itemPtr.getTypeName() == typeid(ESM::ItemLevList).name())
|
||||||
|
{
|
||||||
|
const ESM::ItemLevList* levItemList = itemPtr.get<ESM::ItemLevList>()->mBase;
|
||||||
|
|
||||||
|
if(topLevel && count > 1 && levItemList->mFlags & ESM::ItemLevList::Each)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < count; i++)
|
||||||
|
addRandomToStore(itemPtr, 1, owner, store, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string itemId = MWMechanics::getLevelledItem(itemPtr.get<ESM::ItemLevList>()->mBase, false);
|
||||||
|
if (itemId.empty())
|
||||||
|
return;
|
||||||
|
MWWorld::ManualRef manualRef(MWBase::Environment::get().getWorld()->getStore(), itemId, 1);
|
||||||
|
addRandomToStore(manualRef.getPtr(), count, owner, store, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
addToStore(itemPtr, count, owner, store);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
|
@ -112,7 +137,7 @@ namespace MWScript
|
||||||
{
|
{
|
||||||
if(store.isResolved())
|
if(store.isResolved())
|
||||||
{
|
{
|
||||||
// TODO #2404
|
addRandomToStore(itemPtr, count, ptr, store);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -122,8 +147,10 @@ namespace MWScript
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore(ptr);
|
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore(ptr);
|
||||||
// TODO #2404
|
if(isLevelledList)
|
||||||
addToStore(itemPtr, count, ptr, store);
|
addRandomToStore(itemPtr, count, ptr, store);
|
||||||
|
else
|
||||||
|
addToStore(itemPtr, count, ptr, store);
|
||||||
|
|
||||||
// Spawn a messagebox (only for items added to player's inventory and if player is talking to someone)
|
// Spawn a messagebox (only for items added to player's inventory and if player is talking to someone)
|
||||||
if (ptr == MWBase::Environment::get().getWorld ()->getPlayerPtr() )
|
if (ptr == MWBase::Environment::get().getWorld ()->getPlayerPtr() )
|
||||||
|
|
Loading…
Reference in a new issue