forked from mirror/openmw-tes3mp
[Client] Initialize Creatures as LocalActors
This commit is contained in:
parent
661da98941
commit
841e6a63f8
3 changed files with 29 additions and 19 deletions
|
@ -254,6 +254,16 @@ void Cell::initializeLocalActors()
|
|||
|
||||
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)
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
#include "../mwbase/soundmanager.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
#include "../mwmechanics/mechanicsmanagerimp.hpp"
|
||||
#include "../mwmechanics/movement.hpp"
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
|
||||
#include "../mwrender/animation.hpp"
|
||||
|
||||
|
@ -95,17 +95,17 @@ void DedicatedActor::setAnimFlags()
|
|||
using namespace MWMechanics;
|
||||
|
||||
if (drawState == 0)
|
||||
ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Nothing);
|
||||
ptr.getClass().getCreatureStats(ptr).setDrawState(DrawState_Nothing);
|
||||
else if (drawState == 1)
|
||||
ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Weapon);
|
||||
ptr.getClass().getCreatureStats(ptr).setDrawState(DrawState_Weapon);
|
||||
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);
|
||||
ptrNpcStats->setMovementFlag(CreatureStats::Flag_Run, (movementFlags & CreatureStats::Flag_Run) != 0);
|
||||
ptrNpcStats->setMovementFlag(CreatureStats::Flag_Sneak, (movementFlags & CreatureStats::Flag_Sneak) != 0);
|
||||
ptrNpcStats->setMovementFlag(CreatureStats::Flag_ForceJump, (movementFlags & CreatureStats::Flag_ForceJump) != 0);
|
||||
ptrNpcStats->setMovementFlag(CreatureStats::Flag_ForceMoveJump, (movementFlags & CreatureStats::Flag_ForceMoveJump) != 0);
|
||||
MWMechanics::CreatureStats *ptrCreatureStats = &ptr.getClass().getCreatureStats(ptr);
|
||||
ptrCreatureStats->setMovementFlag(CreatureStats::Flag_Run, (movementFlags & CreatureStats::Flag_Run) != 0);
|
||||
ptrCreatureStats->setMovementFlag(CreatureStats::Flag_Sneak, (movementFlags & CreatureStats::Flag_Sneak) != 0);
|
||||
ptrCreatureStats->setMovementFlag(CreatureStats::Flag_ForceJump, (movementFlags & CreatureStats::Flag_ForceJump) != 0);
|
||||
ptrCreatureStats->setMovementFlag(CreatureStats::Flag_ForceMoveJump, (movementFlags & CreatureStats::Flag_ForceMoveJump) != 0);
|
||||
}
|
||||
|
||||
void DedicatedActor::playAnimation()
|
||||
|
@ -138,13 +138,13 @@ void DedicatedActor::setStatsDynamic()
|
|||
// Only set dynamic stats if they have valid values
|
||||
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;
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
value.readState(creatureStats->mDynamic[i]);
|
||||
ptrNpcStats->setDynamic(i, value);
|
||||
ptrCreatureStats->setDynamic(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,18 +82,18 @@ void LocalActor::updatePosition(bool forceUpdate)
|
|||
void LocalActor::updateAnimFlags(bool forceUpdate)
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
MWMechanics::NpcStats ptrNpcStats = ptr.getClass().getNpcStats(ptr);
|
||||
MWMechanics::CreatureStats ptrCreatureStats = ptr.getClass().getCreatureStats(ptr);
|
||||
|
||||
using namespace MWMechanics;
|
||||
|
||||
bool isRunning = ptrNpcStats.getMovementFlag(CreatureStats::Flag_Run);
|
||||
bool isSneaking = ptrNpcStats.getMovementFlag(CreatureStats::Flag_Sneak);
|
||||
bool isForceJumping = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceJump);
|
||||
bool isForceMoveJumping = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceMoveJump);
|
||||
bool isRunning = ptrCreatureStats.getMovementFlag(CreatureStats::Flag_Run);
|
||||
bool isSneaking = ptrCreatureStats.getMovementFlag(CreatureStats::Flag_Sneak);
|
||||
bool isForceJumping = ptrCreatureStats.getMovementFlag(CreatureStats::Flag_ForceJump);
|
||||
bool isForceMoveJumping = ptrCreatureStats.getMovementFlag(CreatureStats::Flag_ForceMoveJump);
|
||||
|
||||
isFlying = world->isFlying(ptr);
|
||||
|
||||
MWMechanics::DrawState_ currentDrawState = ptr.getClass().getNpcStats(ptr).getDrawState();
|
||||
MWMechanics::DrawState_ currentDrawState = ptr.getClass().getCreatureStats(ptr).getDrawState();
|
||||
|
||||
if (wasRunning != isRunning ||
|
||||
wasSneaking != isSneaking || wasForceJumping != isForceJumping ||
|
||||
|
@ -183,7 +183,7 @@ void LocalActor::updateAttack()
|
|||
{
|
||||
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.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;
|
||||
mpNum = ptr.getCellRef().getMpNum();
|
||||
|
||||
lastDrawState = ptr.getClass().getNpcStats(ptr).getDrawState();
|
||||
lastDrawState = ptr.getClass().getCreatureStats(ptr).getDrawState();
|
||||
oldHealth = ptr.getClass().getCreatureStats(ptr).getHealth();
|
||||
oldMagicka = ptr.getClass().getCreatureStats(ptr).getMagicka();
|
||||
oldFatigue = ptr.getClass().getCreatureStats(ptr).getFatigue();
|
||||
|
|
Loading…
Reference in a new issue