mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
Use safePlaceObject for summoned creature spawning
This commit is contained in:
parent
be62ae758a
commit
7485abe5c3
@ -114,31 +114,16 @@ namespace MWMechanics
|
|||||||
bool found = creatureMap.find(std::make_pair(it->first, it->second)) != creatureMap.end();
|
bool found = creatureMap.find(std::make_pair(it->first, it->second)) != creatureMap.end();
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
ESM::Position ipos = mActor.getRefData().getPosition();
|
|
||||||
osg::Vec3f pos(ipos.asVec3());
|
|
||||||
|
|
||||||
osg::Quat rot (-ipos.rot[2], osg::Vec3f(0,0,1));
|
|
||||||
const float distance = 50;
|
|
||||||
pos = pos + (rot * osg::Vec3f(0,1,0)) * distance;
|
|
||||||
ipos.pos[0] = pos.x();
|
|
||||||
ipos.pos[1] = pos.y();
|
|
||||||
ipos.pos[2] = pos.z();
|
|
||||||
ipos.rot[0] = 0;
|
|
||||||
ipos.rot[1] = 0;
|
|
||||||
ipos.rot[2] = 0;
|
|
||||||
|
|
||||||
const std::string& creatureGmst = summonMap[it->first];
|
const std::string& creatureGmst = summonMap[it->first];
|
||||||
std::string creatureID =
|
std::string creatureID =
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(creatureGmst)->getString();
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(creatureGmst)->getString();
|
||||||
|
|
||||||
if (!creatureID.empty())
|
if (!creatureID.empty())
|
||||||
{
|
{
|
||||||
MWWorld::CellStore* store = mActor.getCell();
|
|
||||||
int creatureActorId = -1;
|
int creatureActorId = -1;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), creatureID, 1);
|
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), creatureID, 1);
|
||||||
ref.getPtr().getCellRef().setPosition(ipos);
|
|
||||||
|
|
||||||
MWMechanics::CreatureStats& summonedCreatureStats = ref.getPtr().getClass().getCreatureStats(ref.getPtr());
|
MWMechanics::CreatureStats& summonedCreatureStats = ref.getPtr().getClass().getCreatureStats(ref.getPtr());
|
||||||
|
|
||||||
@ -147,7 +132,7 @@ namespace MWMechanics
|
|||||||
summonedCreatureStats.getAiSequence().stack(package, ref.getPtr());
|
summonedCreatureStats.getAiSequence().stack(package, ref.getPtr());
|
||||||
creatureActorId = summonedCreatureStats.getActorId();
|
creatureActorId = summonedCreatureStats.getActorId();
|
||||||
|
|
||||||
MWWorld::Ptr placed = MWBase::Environment::get().getWorld()->placeObject(ref.getPtr(),store,ipos);
|
MWWorld::Ptr placed = MWBase::Environment::get().getWorld()->safePlaceObject(ref.getPtr(), mActor, mActor.getCell(), 0, 120.f);
|
||||||
|
|
||||||
MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(placed);
|
MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(placed);
|
||||||
if (anim)
|
if (anim)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user