forked from teamnwah/openmw-tes3coop
[Client] Fix spell casting probability synchronization
This commit is contained in:
parent
721b218cc2
commit
77ce05b7d6
3 changed files with 8 additions and 20 deletions
|
@ -917,14 +917,8 @@ namespace MWMechanics
|
||||||
/*
|
/*
|
||||||
Start of tes3mp change (major)
|
Start of tes3mp change (major)
|
||||||
|
|
||||||
Instead of checking whether the caster is a player or an NPC,
|
Make spell casting fail based on the attack success rated determined
|
||||||
first check whether it's the LocalPlayer or a DedicatedPlayer and calculate
|
in LocalPlayer and LocalActor's updateAttack()
|
||||||
calculate the success chance in clients' LocalPlayer::prepareAttack()
|
|
||||||
|
|
||||||
TODO: Make this make sense for NPCs too
|
|
||||||
|
|
||||||
TODO: See if LocalPlayer being the target and having godmode on
|
|
||||||
can be accounted for like it is in OpenMW's corresponding code
|
|
||||||
*/
|
*/
|
||||||
mwmp::Attack *localAttack = NULL;
|
mwmp::Attack *localAttack = NULL;
|
||||||
mwmp::Attack *dedicatedAttack = MechanicsHelper::getDedicatedAttack(mCaster);
|
mwmp::Attack *dedicatedAttack = MechanicsHelper::getDedicatedAttack(mCaster);
|
||||||
|
@ -944,19 +938,9 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
fail = true;
|
fail = true;
|
||||||
}
|
}
|
||||||
else if (!(mCaster == getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState()))
|
|
||||||
/*
|
/*
|
||||||
End of tes3mp change (major)
|
End of tes3mp change (major)
|
||||||
*/
|
*/
|
||||||
{
|
|
||||||
float successChance = getSpellSuccessChance(spell, mCaster);
|
|
||||||
if (Misc::Rng::roll0to99() >= successChance)
|
|
||||||
{
|
|
||||||
if (mCaster == getPlayer())
|
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicSkillFail}");
|
|
||||||
fail = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fail)
|
if (fail)
|
||||||
{
|
{
|
||||||
|
|
|
@ -241,7 +241,9 @@ void LocalActor::updateAttack()
|
||||||
{
|
{
|
||||||
MWMechanics::CreatureStats &attackerStats = ptr.getClass().getCreatureStats(ptr);
|
MWMechanics::CreatureStats &attackerStats = ptr.getClass().getCreatureStats(ptr);
|
||||||
attack.spellId = attackerStats.getSpells().getSelectedSpell();
|
attack.spellId = attackerStats.getSpells().getSelectedSpell();
|
||||||
attack.success = MechanicsHelper::getSpellSuccess(attack.spellId, ptr);
|
|
||||||
|
if (attack.pressed)
|
||||||
|
attack.success = MechanicsHelper::getSpellSuccess(attack.spellId, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
mwmp::Main::get().getNetworking()->getActorList()->addAttackActor(*this);
|
mwmp::Main::get().getNetworking()->getActorList()->addAttackActor(*this);
|
||||||
|
|
|
@ -525,7 +525,9 @@ void LocalPlayer::updateAttack()
|
||||||
if (attack.type == Attack::MAGIC)
|
if (attack.type == Attack::MAGIC)
|
||||||
{
|
{
|
||||||
attack.spellId = MWBase::Environment::get().getWindowManager()->getSelectedSpell();
|
attack.spellId = MWBase::Environment::get().getWindowManager()->getSelectedSpell();
|
||||||
attack.success = MechanicsHelper::getSpellSuccess(attack.spellId, getPlayerPtr());
|
|
||||||
|
if (attack.pressed)
|
||||||
|
attack.success = MechanicsHelper::getSpellSuccess(attack.spellId, getPlayerPtr());
|
||||||
}
|
}
|
||||||
|
|
||||||
getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->setPlayer(this);
|
getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->setPlayer(this);
|
||||||
|
|
Loading…
Reference in a new issue