[Client] Calculate spell success in more appropriate place

Previously, creatures with fast spellcasting animations would cast their spells before their success had actually been calculated, causing them to fail.
pull/541/head
David Cernat 5 years ago
parent 95967ea289
commit 190c404b38

@ -1057,7 +1057,7 @@ namespace MWMechanics
Start of tes3mp change (major)
Make spell casting fail based on the attack success rated determined
in LocalPlayer and LocalActor's updateAttack()
in LocalPlayer and LocalActor's updateAttackOrCast()
*/
mwmp::Cast *localCast = NULL;
mwmp::Cast *dedicatedCast = MechanicsHelper::getDedicatedCast(mCaster);
@ -1065,7 +1065,10 @@ namespace MWMechanics
if (dedicatedCast)
dedicatedCast->pressed = false;
else
{
localCast = MechanicsHelper::getLocalCast(mCaster);
localCast->success = MechanicsHelper::getSpellSuccess(mId, mCaster);
}
// Check success
if ((localCast && localCast->success == false) ||

@ -265,15 +265,6 @@ void LocalActor::updateAttackOrCast()
}
else if (cast.shouldSend)
{
if (cast.type == Cast::REGULAR)
{
MWMechanics::CreatureStats &casterStats = ptr.getClass().getCreatureStats(ptr);
cast.spellId = casterStats.getSpells().getSelectedSpell();
if (cast.pressed)
cast.success = MechanicsHelper::getSpellSuccess(cast.spellId, ptr);
}
mwmp::Main::get().getNetworking()->getActorList()->addCastActor(*this);
cast.shouldSend = false;
}

@ -609,14 +609,6 @@ void LocalPlayer::updateAttackOrCast()
}
else if (cast.shouldSend)
{
if (cast.type == Cast::REGULAR)
{
cast.spellId = MWBase::Environment::get().getWindowManager()->getSelectedSpell();
if (cast.pressed)
cast.success = MechanicsHelper::getSpellSuccess(cast.spellId, getPlayerPtr());
}
getNetworking()->getPlayerPacket(ID_PLAYER_CAST)->setPlayer(this);
getNetworking()->getPlayerPacket(ID_PLAYER_CAST)->Send();

Loading…
Cancel
Save