1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-06-21 23:11:35 +00:00

[Client] Don't tie spellcasting for dedicated players/actors to anim end

When Koncord implemented spellcasting, he made it so only the act of initiating a spellcast was synchronized, leaving it to other clients to actually cast a spell for a dedicated player or actor once their spellcasting animation was over. This had led to a lot of desyncs and has always been inconsistent with the handling of attacks, so I've belatedly gone ahead and prevented the end of a spellcasting animation from having any effect for dedicated players and actors, making them cast a spell when an appropriate Cast packet is received from them instead.

Additionally, the logged messages in MechanicsHelper's handling of attacking and casting have been moved around slightly.
This commit is contained in:
David Cernat 2019-11-28 10:34:34 +02:00
parent 7815c8bdaf
commit 06b4a4f97c
2 changed files with 10 additions and 10 deletions

View file

@ -1094,8 +1094,11 @@ void CharacterController::handleTextKey(const std::string &groupname, const std:
// the same animation for all range types, so there are 3 "release" keys on the same time, one for each range type.
&& evt.compare(off, len, mAttackType + " release") == 0)
{
MWBase::Environment::get().getWorld()->castSpell(mPtr, mCastingManualSpell);
mCastingManualSpell = false;
if (mPtr == getPlayer() || mwmp::Main::get().getCellController()->isLocalActor(mPtr))
{
MWBase::Environment::get().getWorld()->castSpell(mPtr, mCastingManualSpell);
mCastingManualSpell = false;
}
}
else if (groupname == "shield" && evt.compare(off, len, "block hit") == 0)

View file

@ -273,6 +273,8 @@ void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker)
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Processing attack from %s of type %i",
attacker.getClass().getName(attacker).c_str(), attack.type);
LOG_APPEND(TimedLog::LOG_VERBOSE, "- pressed: %s", attack.pressed ? "true" : "false");
if (!attack.pressed)
{
LOG_APPEND(TimedLog::LOG_VERBOSE, "- success: %s", attack.success ? "true" : "false");
@ -281,8 +283,6 @@ void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker)
LOG_APPEND(TimedLog::LOG_VERBOSE, "- damage: %f", attack.damage);
}
LOG_APPEND(TimedLog::LOG_VERBOSE, "- pressed: %s", attack.pressed ? "true" : "false");
MWMechanics::CreatureStats &attackerStats = attacker.getClass().getCreatureStats(attacker);
MWWorld::Ptr victim;
@ -422,13 +422,13 @@ void MechanicsHelper::processCast(Cast cast, const MWWorld::Ptr& caster)
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Processing cast from %s of type %i",
caster.getClass().getName(caster).c_str(), cast.type);
LOG_APPEND(TimedLog::LOG_VERBOSE, "- pressed: %s", cast.pressed ? "true" : "false");
if (!cast.pressed)
{
LOG_APPEND(TimedLog::LOG_VERBOSE, "- success: %s", cast.success ? "true" : "false");
}
LOG_APPEND(TimedLog::LOG_VERBOSE, "- pressed: %s", cast.pressed ? "true" : "false");
MWMechanics::CreatureStats &casterStats = caster.getClass().getCreatureStats(caster);
MWWorld::Ptr victim;
@ -452,11 +452,8 @@ void MechanicsHelper::processCast(Cast cast, const MWWorld::Ptr& caster)
{
casterStats.getSpells().setSelectedSpell(cast.spellId);
if (cast.instant)
{
if (cast.success)
MWBase::Environment::get().getWorld()->castSpell(caster);
cast.instant = false;
}
LOG_APPEND(TimedLog::LOG_VERBOSE, "- spellId: %s", cast.spellId.c_str());
}