|
|
@ -402,41 +402,45 @@ 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();
|
|
|
|
|
|
|
|
|
|
|
|
newPtr.getCellRef().setMpNum(baseObject.mpNum);
|
|
|
|
if (newPtr.getClass().isActor())
|
|
|
|
|
|
|
|
|
|
|
|
newPtr = MWBase::Environment::get().getWorld()->placeObject(newPtr, cellStore, baseObject.position);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (baseObject.isSummon)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MWWorld::Ptr masterPtr;
|
|
|
|
newPtr = MWBase::Environment::get().getWorld()->placeObject(newPtr, cellStore, baseObject.position);
|
|
|
|
|
|
|
|
MWMechanics::CreatureStats& creatureStats = newPtr.getClass().getCreatureStats(newPtr);
|
|
|
|
if (baseObject.master.isPlayer)
|
|
|
|
|
|
|
|
masterPtr = MechanicsHelper::getPlayerPtr(baseObject.master);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
masterPtr = cellStore->searchExact(baseObject.master.refNum, baseObject.master.mpNum);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (masterPtr)
|
|
|
|
if (baseObject.isSummon)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOG_APPEND(Log::LOG_VERBOSE, "-- Actor has master: %s", masterPtr.getCellRef().getRefId().c_str());
|
|
|
|
MWWorld::Ptr masterPtr;
|
|
|
|
|
|
|
|
|
|
|
|
MWMechanics::AiFollow package(masterPtr);
|
|
|
|
if (baseObject.master.isPlayer)
|
|
|
|
newPtr.getClass().getCreatureStats(newPtr).getAiSequence().stack(package, newPtr);
|
|
|
|
masterPtr = MechanicsHelper::getPlayerPtr(baseObject.master);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
masterPtr = cellStore->searchExact(baseObject.master.refNum, baseObject.master.mpNum);
|
|
|
|
|
|
|
|
|
|
|
|
MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(newPtr);
|
|
|
|
if (masterPtr)
|
|
|
|
if (anim)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>()
|
|
|
|
LOG_APPEND(Log::LOG_VERBOSE, "-- Actor has master: %s", masterPtr.getCellRef().getRefId().c_str());
|
|
|
|
.search("VFX_Summon_Start");
|
|
|
|
|
|
|
|
if (fx)
|
|
|
|
|
|
|
|
anim->addEffect("meshes\\" + fx->mModel, -1, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int creatureActorId = newPtr.getClass().getCreatureStats(newPtr).getActorId();
|
|
|
|
MWMechanics::AiFollow package(masterPtr);
|
|
|
|
|
|
|
|
creatureStats.getAiSequence().stack(package, newPtr);
|
|
|
|
|
|
|
|
|
|
|
|
MWMechanics::CreatureStats& masterCreatureStats = masterPtr.getClass().getCreatureStats(masterPtr);
|
|
|
|
MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(newPtr);
|
|
|
|
masterCreatureStats.setSummonedCreatureActorId(baseObject.refId, creatureActorId);
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MWMechanics::CreatureStats& masterCreatureStats = masterPtr.getClass().getCreatureStats(masterPtr);
|
|
|
|
|
|
|
|
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!");
|
|
|
|