|
|
@ -6,6 +6,7 @@
|
|
|
|
#include "DedicatedPlayer.hpp"
|
|
|
|
#include "DedicatedPlayer.hpp"
|
|
|
|
#include "PlayerList.hpp"
|
|
|
|
#include "PlayerList.hpp"
|
|
|
|
#include "CellController.hpp"
|
|
|
|
#include "CellController.hpp"
|
|
|
|
|
|
|
|
#include "RecordHelper.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
#include <components/openmw-mp/Log.hpp>
|
|
|
|
#include <components/openmw-mp/Log.hpp>
|
|
|
|
|
|
|
|
|
|
|
@ -375,7 +376,7 @@ void ObjectList::placeObjects(MWWorld::CellStore* cellStore)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (std::exception&)
|
|
|
|
catch (std::exception&)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOG_APPEND(Log::LOG_INFO, "-- Ignored placement of invalid object");
|
|
|
|
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Ignored placement of invalid object %s", baseObject.refId.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -393,6 +394,11 @@ void ObjectList::spawnObjects(MWWorld::CellStore* cellStore)
|
|
|
|
// Ignore generic dynamic refIds because they could be anything on other clients
|
|
|
|
// Ignore generic dynamic refIds because they could be anything on other clients
|
|
|
|
if (baseObject.refId.find("$dynamic") != string::npos)
|
|
|
|
if (baseObject.refId.find("$dynamic") != string::npos)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
else if (!RecordHelper::doesCreatureExist(baseObject.refId) && !RecordHelper::doesNpcExist(baseObject.refId))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Ignored spawning of invalid object %s", baseObject.refId.c_str());
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr ptrFound = cellStore->searchExact(0, baseObject.mpNum);
|
|
|
|
MWWorld::Ptr ptrFound = cellStore->searchExact(0, baseObject.mpNum);
|
|
|
|
|
|
|
|
|
|
|
@ -402,45 +408,40 @@ void ObjectList::spawnObjects(MWWorld::CellStore* cellStore)
|
|
|
|
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), baseObject.refId, 1);
|
|
|
|
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), baseObject.refId, 1);
|
|
|
|
MWWorld::Ptr newPtr = ref.getPtr();
|
|
|
|
MWWorld::Ptr newPtr = ref.getPtr();
|
|
|
|
|
|
|
|
|
|
|
|
if (newPtr.getClass().isActor())
|
|
|
|
newPtr = MWBase::Environment::get().getWorld()->placeObject(newPtr, cellStore, baseObject.position);
|
|
|
|
|
|
|
|
MWMechanics::CreatureStats& creatureStats = newPtr.getClass().getCreatureStats(newPtr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (baseObject.isSummon)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
newPtr = MWBase::Environment::get().getWorld()->placeObject(newPtr, cellStore, baseObject.position);
|
|
|
|
MWWorld::Ptr masterPtr;
|
|
|
|
MWMechanics::CreatureStats& creatureStats = newPtr.getClass().getCreatureStats(newPtr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (baseObject.isSummon)
|
|
|
|
if (baseObject.master.isPlayer)
|
|
|
|
|
|
|
|
masterPtr = MechanicsHelper::getPlayerPtr(baseObject.master);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
masterPtr = cellStore->searchExact(baseObject.master.refNum, baseObject.master.mpNum);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (masterPtr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MWWorld::Ptr masterPtr;
|
|
|
|
LOG_APPEND(Log::LOG_VERBOSE, "-- Actor has master: %s", masterPtr.getCellRef().getRefId().c_str());
|
|
|
|
|
|
|
|
|
|
|
|
if (baseObject.master.isPlayer)
|
|
|
|
MWMechanics::AiFollow package(masterPtr);
|
|
|
|
masterPtr = MechanicsHelper::getPlayerPtr(baseObject.master);
|
|
|
|
creatureStats.getAiSequence().stack(package, newPtr);
|
|
|
|
else
|
|
|
|
|
|
|
|
masterPtr = cellStore->searchExact(baseObject.master.refNum, baseObject.master.mpNum);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (masterPtr)
|
|
|
|
MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(newPtr);
|
|
|
|
|
|
|
|
if (anim)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOG_APPEND(Log::LOG_VERBOSE, "-- Actor has master: %s", masterPtr.getCellRef().getRefId().c_str());
|
|
|
|
const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>()
|
|
|
|
|
|
|
|
.search("VFX_Summon_Start");
|
|
|
|
MWMechanics::AiFollow package(masterPtr);
|
|
|
|
if (fx)
|
|
|
|
creatureStats.getAiSequence().stack(package, newPtr);
|
|
|
|
anim->addEffect("meshes\\" + fx->mModel, -1, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(newPtr);
|
|
|
|
|
|
|
|
if (anim)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>()
|
|
|
|
|
|
|
|
.search("VFX_Summon_Start");
|
|
|
|
|
|
|
|
if (fx)
|
|
|
|
|
|
|
|
anim->addEffect("meshes\\" + fx->mModel, -1, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int creatureActorId = newPtr.getClass().getCreatureStats(newPtr).getActorId();
|
|
|
|
int creatureActorId = newPtr.getClass().getCreatureStats(newPtr).getActorId();
|
|
|
|
|
|
|
|
|
|
|
|
MWMechanics::CreatureStats& masterCreatureStats = masterPtr.getClass().getCreatureStats(masterPtr);
|
|
|
|
MWMechanics::CreatureStats& masterCreatureStats = masterPtr.getClass().getCreatureStats(masterPtr);
|
|
|
|
masterCreatureStats.setSummonedCreatureActorId(baseObject.refId, creatureActorId);
|
|
|
|
masterCreatureStats.setSummonedCreatureActorId(baseObject.refId, creatureActorId);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
LOG_APPEND(Log::LOG_VERBOSE, "-- Cannot spawn non-actor object!");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
LOG_APPEND(Log::LOG_VERBOSE, "-- Actor already existed!");
|
|
|
|
LOG_APPEND(Log::LOG_VERBOSE, "-- Actor already existed!");
|
|
|
|