forked from mirror/openmw-tes3mp
Reduce using of the CPU
This commit is contained in:
parent
56959ebfda
commit
799842b5da
3 changed files with 16 additions and 11 deletions
|
@ -597,8 +597,9 @@ namespace MWClass
|
|||
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||
{
|
||||
mwmp::Main::get().getLocalPlayer()->GetAttack()->success = true;
|
||||
if (mwmp::Main::get().getNetworking()->isDedicatedPlayer(victim))
|
||||
mwmp::Main::get().getLocalPlayer()->GetAttack()->target =mwmp::Players::GetPlayer(victim)->guid;
|
||||
mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::GetPlayer(victim);
|
||||
if (dedicatedPlayer != nullptr)
|
||||
mwmp::Main::get().getLocalPlayer()->GetAttack()->target = dedicatedPlayer->guid;
|
||||
}
|
||||
|
||||
if(Misc::Rng::roll0to99() >= hitchance)
|
||||
|
@ -733,10 +734,11 @@ namespace MWClass
|
|||
float knockdownTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified()
|
||||
* gmst.iKnockDownOddsMult->getInt() * 0.01f + gmst.iKnockDownOddsBase->getInt();
|
||||
|
||||
bool isDedicated = mwmp::Main::get().getNetworking()->isDedicatedPlayer(attacker);
|
||||
mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::GetPlayer(attacker);
|
||||
bool isDedicated = dedicatedPlayer != nullptr;
|
||||
bool _knockdown = false;
|
||||
if(isDedicated)
|
||||
_knockdown = mwmp::Players::GetPlayer(attacker)->GetAttack()->knockdown;
|
||||
_knockdown = dedicatedPlayer->GetAttack()->knockdown;
|
||||
|
||||
if ((!isDedicated && ishealth && agilityTerm <= damage && knockdownTerm <= Misc::Rng::roll0to99()) || _knockdown)
|
||||
{
|
||||
|
@ -843,12 +845,13 @@ namespace MWClass
|
|||
}
|
||||
|
||||
|
||||
if (attacker == MWMechanics::getPlayer() && mwmp::Main::get().getNetworking()->isDedicatedPlayer(ptr))
|
||||
mwmp::DedicatedPlayer *victimPlayer = mwmp::Players::GetPlayer(ptr);
|
||||
if (attacker == MWMechanics::getPlayer() && victimPlayer != nullptr)
|
||||
{
|
||||
mwmp::Attack *_atk = mwmp::Main::get().getLocalPlayer()->GetAttack();
|
||||
_atk->damage = damage;
|
||||
_atk->attacker = mwmp::Main::get().getLocalPlayer()->guid;
|
||||
_atk->target = mwmp::Players::GetPlayer(ptr)->guid;
|
||||
_atk->target = victimPlayer->guid;
|
||||
_atk->knockdown = getCreatureStats(ptr).getKnockedDown();
|
||||
mwmp::Main::get().getLocalPlayer()->sendAttack(mwmp::Attack::MELEE); // todo: make this sensitive to different weapon types
|
||||
}
|
||||
|
|
|
@ -116,12 +116,13 @@ namespace MWMechanics
|
|||
x = std::min(iBlockMaxChance, std::max(iBlockMinChance, x));
|
||||
|
||||
|
||||
bool isDedicated = mwmp::Main::get().getNetworking()->isDedicatedPlayer(blocker);
|
||||
mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::GetPlayer(blocker);
|
||||
bool isDedicated = dedicatedPlayer != nullptr;
|
||||
if (attacker == MWMechanics::getPlayer())
|
||||
mwmp::Main::get().getLocalPlayer()->GetAttack()->block = false;
|
||||
|
||||
if ((!isDedicated && Misc::Rng::roll0to99() < x) ||
|
||||
(isDedicated && mwmp::Players::GetPlayer(blocker)->GetAttack()->block == 1))
|
||||
(isDedicated && dedicatedPlayer->GetAttack()->block == 1))
|
||||
{
|
||||
if (attacker == MWMechanics::getPlayer())
|
||||
mwmp::Main::get().getLocalPlayer()->GetAttack()->block = true;
|
||||
|
|
|
@ -797,13 +797,14 @@ namespace MWMechanics
|
|||
// Check success
|
||||
float successChance = getSpellSuccessChance(spell, mCaster);
|
||||
|
||||
bool isDedicated = mwmp::Main::get().getNetworking()->isDedicatedPlayer(mCaster);
|
||||
mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::GetPlayer(mCaster);
|
||||
bool isDedicated = dedicatedPlayer != nullptr;
|
||||
|
||||
if (isDedicated)
|
||||
mwmp::Players::GetPlayer(mCaster)->GetAttack()->pressed = false;
|
||||
dedicatedPlayer->GetAttack()->pressed = false;
|
||||
|
||||
if ((!isDedicated && !mwmp::Main::get().getLocalPlayer()->GetAttack()->success) ||
|
||||
(isDedicated && mwmp::Players::GetPlayer(mCaster)->GetAttack()->success == 0))
|
||||
(isDedicated && dedicatedPlayer->GetAttack()->success == 0))
|
||||
{
|
||||
if (mCaster == getPlayer())
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue