[Client] Synchronize spellcasting for non-bipedal creatures

pull/253/head
David Cernat 7 years ago
parent c9550fc560
commit 4db64e1721

@ -1038,9 +1038,39 @@ bool CharacterController::updateCreatureState()
const std::string spellid = stats.getSpells().getSelectedSpell();
if (!spellid.empty() && MWBase::Environment::get().getWorld()->startSpellCast(mPtr))
{
/*
Start of tes3mp addition
If this mPtr belongs to a LocalPlayer or LocalActor, get their Attack and prepare
it for sending
*/
mwmp::Attack *localAttack = MechanicsHelper::getLocalAttack(mPtr);
if (localAttack)
{
MechanicsHelper::resetAttack(localAttack);
localAttack->type = mwmp::Attack::MAGIC;
localAttack->pressed = true;
localAttack->shouldSend = true;
}
/*
End of tes3mp addition
*/
MWMechanics::CastSpell cast(mPtr, NULL);
cast.playSpellCastingEffects(spellid);
/*
Start of tes3mp addition
Mark the attack as instant if there is no spellcast animation
*/
if (!mAnimation->hasAnimation("spellcast"))
localAttack->instant = true;
/*
End of tes3mp addition
*/
if (!mAnimation->hasAnimation("spellcast"))
MWBase::Environment::get().getWorld()->castSpell(mPtr); // No "release" text key to use, so cast immediately
else

@ -46,6 +46,7 @@ DedicatedPlayer::DedicatedPlayer(RakNet::RakNetGUID guid) : BasePlayer(guid)
attack.pressed = 0;
creatureStats.mDead = false;
movementFlags = 0;
attack.instant = false;
}
DedicatedPlayer::~DedicatedPlayer()
{

@ -33,6 +33,7 @@ LocalActor::LocalActor()
attack.type = Attack::MELEE;
attack.shouldSend = false;
attack.instant = false;
creatureStats.mDead = false;
}

@ -201,8 +201,14 @@ void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker)
attack.success);
}
}
else
else if (attack.type == attack.MAGIC)
{
if (attack.instant)
{
MWBase::Environment::get().getWorld()->castSpell(attacker);
attack.instant = false;
}
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "SpellId: %s", attack.spellId.c_str());
LOG_APPEND(Log::LOG_VERBOSE, " - success: %d", attack.success);
}

@ -50,6 +50,7 @@ namespace mwmp
bool block;
bool pressed;
bool instant;
bool knockdown;
bool shouldSend;

@ -23,4 +23,6 @@ void PacketActorAttack::Actor(BaseActor &actor, bool send)
RW(actor.attack.pressed, send);
RW(actor.attack.knockdown, send);
RW(actor.attack.block, send);
RW(actor.attack.instant, send);
}

Loading…
Cancel
Save