1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 10:23:52 +00:00

[Client] Initialize Creatures as LocalActors

This commit is contained in:
David Cernat 2017-04-24 11:58:39 +03:00
parent 661da98941
commit 841e6a63f8
3 changed files with 29 additions and 19 deletions

View file

@ -254,6 +254,16 @@ void Cell::initializeLocalActors()
initializeLocalActor(ptr); initializeLocalActor(ptr);
} }
MWWorld::CellRefList<ESM::Creature> *creatureList = store->getCreatures();
for (typename MWWorld::CellRefList<ESM::Creature>::List::iterator listIter(creatureList->mList.begin());
listIter != creatureList->mList.end(); ++listIter)
{
MWWorld::Ptr ptr(&*listIter, store);
initializeLocalActor(ptr);
}
} }
void Cell::initializeDedicatedActor(const MWWorld::Ptr& ptr) void Cell::initializeDedicatedActor(const MWWorld::Ptr& ptr)

View file

@ -4,9 +4,9 @@
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/mechanicsmanagerimp.hpp" #include "../mwmechanics/mechanicsmanagerimp.hpp"
#include "../mwmechanics/movement.hpp" #include "../mwmechanics/movement.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "../mwrender/animation.hpp" #include "../mwrender/animation.hpp"
@ -95,17 +95,17 @@ void DedicatedActor::setAnimFlags()
using namespace MWMechanics; using namespace MWMechanics;
if (drawState == 0) if (drawState == 0)
ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Nothing); ptr.getClass().getCreatureStats(ptr).setDrawState(DrawState_Nothing);
else if (drawState == 1) else if (drawState == 1)
ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Weapon); ptr.getClass().getCreatureStats(ptr).setDrawState(DrawState_Weapon);
else if (drawState == 2) else if (drawState == 2)
ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Spell); ptr.getClass().getCreatureStats(ptr).setDrawState(DrawState_Spell);
MWMechanics::NpcStats *ptrNpcStats = &ptr.getClass().getNpcStats(ptr); MWMechanics::CreatureStats *ptrCreatureStats = &ptr.getClass().getCreatureStats(ptr);
ptrNpcStats->setMovementFlag(CreatureStats::Flag_Run, (movementFlags & CreatureStats::Flag_Run) != 0); ptrCreatureStats->setMovementFlag(CreatureStats::Flag_Run, (movementFlags & CreatureStats::Flag_Run) != 0);
ptrNpcStats->setMovementFlag(CreatureStats::Flag_Sneak, (movementFlags & CreatureStats::Flag_Sneak) != 0); ptrCreatureStats->setMovementFlag(CreatureStats::Flag_Sneak, (movementFlags & CreatureStats::Flag_Sneak) != 0);
ptrNpcStats->setMovementFlag(CreatureStats::Flag_ForceJump, (movementFlags & CreatureStats::Flag_ForceJump) != 0); ptrCreatureStats->setMovementFlag(CreatureStats::Flag_ForceJump, (movementFlags & CreatureStats::Flag_ForceJump) != 0);
ptrNpcStats->setMovementFlag(CreatureStats::Flag_ForceMoveJump, (movementFlags & CreatureStats::Flag_ForceMoveJump) != 0); ptrCreatureStats->setMovementFlag(CreatureStats::Flag_ForceMoveJump, (movementFlags & CreatureStats::Flag_ForceMoveJump) != 0);
} }
void DedicatedActor::playAnimation() void DedicatedActor::playAnimation()
@ -138,13 +138,13 @@ void DedicatedActor::setStatsDynamic()
// Only set dynamic stats if they have valid values // Only set dynamic stats if they have valid values
if (creatureStats->mDynamic[0].mBase == -1) return; if (creatureStats->mDynamic[0].mBase == -1) return;
MWMechanics::NpcStats *ptrNpcStats = &ptr.getClass().getNpcStats(ptr); MWMechanics::CreatureStats *ptrCreatureStats = &ptr.getClass().getCreatureStats(ptr);
MWMechanics::DynamicStat<float> value; MWMechanics::DynamicStat<float> value;
for (int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)
{ {
value.readState(creatureStats->mDynamic[i]); value.readState(creatureStats->mDynamic[i]);
ptrNpcStats->setDynamic(i, value); ptrCreatureStats->setDynamic(i, value);
} }
} }

View file

@ -82,18 +82,18 @@ void LocalActor::updatePosition(bool forceUpdate)
void LocalActor::updateAnimFlags(bool forceUpdate) void LocalActor::updateAnimFlags(bool forceUpdate)
{ {
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
MWMechanics::NpcStats ptrNpcStats = ptr.getClass().getNpcStats(ptr); MWMechanics::CreatureStats ptrCreatureStats = ptr.getClass().getCreatureStats(ptr);
using namespace MWMechanics; using namespace MWMechanics;
bool isRunning = ptrNpcStats.getMovementFlag(CreatureStats::Flag_Run); bool isRunning = ptrCreatureStats.getMovementFlag(CreatureStats::Flag_Run);
bool isSneaking = ptrNpcStats.getMovementFlag(CreatureStats::Flag_Sneak); bool isSneaking = ptrCreatureStats.getMovementFlag(CreatureStats::Flag_Sneak);
bool isForceJumping = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceJump); bool isForceJumping = ptrCreatureStats.getMovementFlag(CreatureStats::Flag_ForceJump);
bool isForceMoveJumping = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceMoveJump); bool isForceMoveJumping = ptrCreatureStats.getMovementFlag(CreatureStats::Flag_ForceMoveJump);
isFlying = world->isFlying(ptr); isFlying = world->isFlying(ptr);
MWMechanics::DrawState_ currentDrawState = ptr.getClass().getNpcStats(ptr).getDrawState(); MWMechanics::DrawState_ currentDrawState = ptr.getClass().getCreatureStats(ptr).getDrawState();
if (wasRunning != isRunning || if (wasRunning != isRunning ||
wasSneaking != isSneaking || wasForceJumping != isForceJumping || wasSneaking != isSneaking || wasForceJumping != isForceJumping ||
@ -183,7 +183,7 @@ void LocalActor::updateAttack()
{ {
if (attack.type == Attack::MAGIC) if (attack.type == Attack::MAGIC)
{ {
MWMechanics::CreatureStats &attackerStats = ptr.getClass().getNpcStats(ptr); MWMechanics::CreatureStats &attackerStats = ptr.getClass().getCreatureStats(ptr);
attack.spellId = attackerStats.getSpells().getSelectedSpell(); attack.spellId = attackerStats.getSpells().getSelectedSpell();
attack.success = mwmp::Main::get().getMechanicsHelper()->getSpellSuccess(attack.spellId, ptr); attack.success = mwmp::Main::get().getMechanicsHelper()->getSpellSuccess(attack.spellId, ptr);
} }
@ -206,7 +206,7 @@ void LocalActor::setPtr(const MWWorld::Ptr& newPtr)
refNumIndex = ptr.getCellRef().getRefNum().mIndex; refNumIndex = ptr.getCellRef().getRefNum().mIndex;
mpNum = ptr.getCellRef().getMpNum(); mpNum = ptr.getCellRef().getMpNum();
lastDrawState = ptr.getClass().getNpcStats(ptr).getDrawState(); lastDrawState = ptr.getClass().getCreatureStats(ptr).getDrawState();
oldHealth = ptr.getClass().getCreatureStats(ptr).getHealth(); oldHealth = ptr.getClass().getCreatureStats(ptr).getHealth();
oldMagicka = ptr.getClass().getCreatureStats(ptr).getMagicka(); oldMagicka = ptr.getClass().getCreatureStats(ptr).getMagicka();
oldFatigue = ptr.getClass().getCreatureStats(ptr).getFatigue(); oldFatigue = ptr.getClass().getCreatureStats(ptr).getFatigue();