mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-21 18:09:39 +00:00
Allow script-induced dynamic stat changes
This commit is contained in:
parent
ae00f12c87
commit
18cd964d21
3 changed files with 32 additions and 9 deletions
|
@ -62,14 +62,14 @@ void LocalPlayer::updateDynamicStats(bool forceUpdate)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = GetPlayerPtr();
|
MWWorld::Ptr player = GetPlayerPtr();
|
||||||
|
|
||||||
MWMechanics::CreatureStats *creatureClass = &player.getClass().getCreatureStats(player);
|
MWMechanics::CreatureStats *ptrCreatureStats = &player.getClass().getCreatureStats(player);
|
||||||
MWMechanics::DynamicStat<float> health(creatureClass->getHealth());
|
MWMechanics::DynamicStat<float> health(ptrCreatureStats->getHealth());
|
||||||
MWMechanics::DynamicStat<float> magicka(creatureClass->getMagicka());
|
MWMechanics::DynamicStat<float> magicka(ptrCreatureStats->getMagicka());
|
||||||
MWMechanics::DynamicStat<float> fatigue(creatureClass->getFatigue());
|
MWMechanics::DynamicStat<float> fatigue(ptrCreatureStats->getFatigue());
|
||||||
|
|
||||||
static MWMechanics::DynamicStat<float> oldHealth(creatureClass->getHealth());
|
static MWMechanics::DynamicStat<float> oldHealth(ptrCreatureStats->getHealth());
|
||||||
static MWMechanics::DynamicStat<float> oldMagicka(creatureClass->getMagicka());
|
static MWMechanics::DynamicStat<float> oldMagicka(ptrCreatureStats->getMagicka());
|
||||||
static MWMechanics::DynamicStat<float> oldFatigue(creatureClass->getFatigue());
|
static MWMechanics::DynamicStat<float> oldFatigue(ptrCreatureStats->getFatigue());
|
||||||
|
|
||||||
static float timer = 0;
|
static float timer = 0;
|
||||||
|
|
||||||
|
@ -233,6 +233,21 @@ void LocalPlayer::setCell()
|
||||||
updateCell(true);
|
updateCell(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LocalPlayer::setDynamicStats()
|
||||||
|
{
|
||||||
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
|
MWWorld::Ptr player = world->getPlayerPtr();
|
||||||
|
|
||||||
|
MWMechanics::CreatureStats *ptrCreatureStats = &player.getClass().getCreatureStats(player);
|
||||||
|
|
||||||
|
MWMechanics::DynamicStat<float> dynamicStat;
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; ++i)
|
||||||
|
{
|
||||||
|
dynamicStat.readState(CreatureStats()->mDynamic[i]);
|
||||||
|
ptrCreatureStats->setDynamic(i, dynamicStat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LocalPlayer::updateInventory(bool forceUpdate)
|
void LocalPlayer::updateInventory(bool forceUpdate)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,6 +31,7 @@ namespace mwmp
|
||||||
|
|
||||||
void setPosition();
|
void setPosition();
|
||||||
void setCell();
|
void setCell();
|
||||||
|
void setDynamicStats();
|
||||||
|
|
||||||
void SetClass();
|
void SetClass();
|
||||||
void SendClass();
|
void SendClass();
|
||||||
|
|
|
@ -339,8 +339,15 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
|
||||||
{
|
{
|
||||||
if (id == myid)
|
if (id == myid)
|
||||||
{
|
{
|
||||||
getLocalPlayer()->updateDynamicStats(true);
|
if (packet->length == myPacket->headerSize())
|
||||||
myPacket->Send(getLocalPlayer(), serverAddr);
|
{
|
||||||
|
getLocalPlayer()->updateDynamicStats(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
myPacket->Packet(&bsIn, getLocalPlayer(), false);
|
||||||
|
getLocalPlayer()->setDynamicStats();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (pl != 0)
|
else if (pl != 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue