mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-28 07:32:00 -04:00
[Client] Synchronize spellcasting for non-bipedal creatures
This commit is contained in:
parent
c9550fc560
commit
4db64e1721
@ -1038,9 +1038,39 @@ bool CharacterController::updateCreatureState()
|
|||||||
const std::string spellid = stats.getSpells().getSelectedSpell();
|
const std::string spellid = stats.getSpells().getSelectedSpell();
|
||||||
if (!spellid.empty() && MWBase::Environment::get().getWorld()->startSpellCast(mPtr))
|
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);
|
MWMechanics::CastSpell cast(mPtr, NULL);
|
||||||
cast.playSpellCastingEffects(spellid);
|
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"))
|
if (!mAnimation->hasAnimation("spellcast"))
|
||||||
MWBase::Environment::get().getWorld()->castSpell(mPtr); // No "release" text key to use, so cast immediately
|
MWBase::Environment::get().getWorld()->castSpell(mPtr); // No "release" text key to use, so cast immediately
|
||||||
else
|
else
|
||||||
|
@ -46,6 +46,7 @@ DedicatedPlayer::DedicatedPlayer(RakNet::RakNetGUID guid) : BasePlayer(guid)
|
|||||||
attack.pressed = 0;
|
attack.pressed = 0;
|
||||||
creatureStats.mDead = false;
|
creatureStats.mDead = false;
|
||||||
movementFlags = 0;
|
movementFlags = 0;
|
||||||
|
attack.instant = false;
|
||||||
}
|
}
|
||||||
DedicatedPlayer::~DedicatedPlayer()
|
DedicatedPlayer::~DedicatedPlayer()
|
||||||
{
|
{
|
||||||
|
@ -33,6 +33,7 @@ LocalActor::LocalActor()
|
|||||||
|
|
||||||
attack.type = Attack::MELEE;
|
attack.type = Attack::MELEE;
|
||||||
attack.shouldSend = false;
|
attack.shouldSend = false;
|
||||||
|
attack.instant = false;
|
||||||
|
|
||||||
creatureStats.mDead = false;
|
creatureStats.mDead = false;
|
||||||
}
|
}
|
||||||
|
@ -201,8 +201,14 @@ void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker)
|
|||||||
attack.success);
|
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_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "SpellId: %s", attack.spellId.c_str());
|
||||||
LOG_APPEND(Log::LOG_VERBOSE, " - success: %d", attack.success);
|
LOG_APPEND(Log::LOG_VERBOSE, " - success: %d", attack.success);
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ namespace mwmp
|
|||||||
bool block;
|
bool block;
|
||||||
|
|
||||||
bool pressed;
|
bool pressed;
|
||||||
|
bool instant;
|
||||||
bool knockdown;
|
bool knockdown;
|
||||||
|
|
||||||
bool shouldSend;
|
bool shouldSend;
|
||||||
|
@ -23,4 +23,6 @@ void PacketActorAttack::Actor(BaseActor &actor, bool send)
|
|||||||
RW(actor.attack.pressed, send);
|
RW(actor.attack.pressed, send);
|
||||||
RW(actor.attack.knockdown, send);
|
RW(actor.attack.knockdown, send);
|
||||||
RW(actor.attack.block, send);
|
RW(actor.attack.block, send);
|
||||||
|
|
||||||
|
RW(actor.attack.instant, send);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user