mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 08:55:32 +01:00
Core/Spells: Implemented casting spells on movement finish from SPELL_EFFECT_JUMP, SPELL_EFFECT_JUMP_DEST and SPELL_EFFECT_CHARGE
This commit is contained in:
@@ -363,7 +363,7 @@ void MotionMaster::MoveJumpTo(float angle, float speedXY, float speedZ)
|
||||
MoveJump(x, y, z, speedXY, speedZ);
|
||||
}
|
||||
|
||||
void MotionMaster::MoveJump(float x, float y, float z, float speedXY, float speedZ, uint32 id)
|
||||
void MotionMaster::MoveJump(float x, float y, float z, float speedXY, float speedZ, uint32 id /*= EVENT_JUMP*/, uint32 arrivalSpellId /*= 0*/, ObjectGuid const& arrivalSpellTargetGuid /*= ObjectGuid::Empty*/)
|
||||
{
|
||||
TC_LOG_DEBUG("misc", "Unit (%s) jump to point (X: %f Y: %f Z: %f)", _owner->GetGUID().ToString().c_str(), x, y, z);
|
||||
if (speedXY <= 0.1f)
|
||||
@@ -377,7 +377,7 @@ void MotionMaster::MoveJump(float x, float y, float z, float speedXY, float spee
|
||||
init.SetParabolic(max_height, 0);
|
||||
init.SetVelocity(speedXY);
|
||||
init.Launch();
|
||||
Mutate(new EffectMovementGenerator(id), MOTION_SLOT_CONTROLLED);
|
||||
Mutate(new EffectMovementGenerator(id, arrivalSpellId, arrivalSpellTargetGuid), MOTION_SLOT_CONTROLLED);
|
||||
}
|
||||
|
||||
void MotionMaster::MoveCirclePath(float x, float y, float z, float radius, bool clockwise, uint8 stepCount)
|
||||
|
||||
@@ -181,9 +181,11 @@ class MotionMaster //: private std::stack<MovementGenerator *>
|
||||
void MoveCharge(PathGenerator const& path, float speed = SPEED_CHARGE);
|
||||
void MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ);
|
||||
void MoveJumpTo(float angle, float speedXY, float speedZ);
|
||||
void MoveJump(Position const& pos, float speedXY, float speedZ, uint32 id = EVENT_JUMP)
|
||||
{ MoveJump(pos.m_positionX, pos.m_positionY, pos.m_positionZ, speedXY, speedZ, id); }
|
||||
void MoveJump(float x, float y, float z, float speedXY, float speedZ, uint32 id = EVENT_JUMP);
|
||||
void MoveJump(Position const& pos, float speedXY, float speedZ, uint32 id = EVENT_JUMP, uint32 arrivalSpellId = 0, ObjectGuid const& arrivalSpellTargetGuid = ObjectGuid::Empty)
|
||||
{
|
||||
MoveJump(pos.m_positionX, pos.m_positionY, pos.m_positionZ, speedXY, speedZ, id, arrivalSpellId, arrivalSpellTargetGuid);
|
||||
}
|
||||
void MoveJump(float x, float y, float z, float speedXY, float speedZ, uint32 id = EVENT_JUMP, uint32 arrivalSpellId = 0, ObjectGuid const& arrivalSpellTargetGuid = ObjectGuid::Empty);
|
||||
void MoveCirclePath(float x, float y, float z, float radius, bool clockwise, uint8 stepCount);
|
||||
void MoveSmoothPath(uint32 pointId, G3D::Vector3 const* pathPoints, size_t pathSize, bool walk);
|
||||
void MoveFall(uint32 id = 0);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "MoveSpline.h"
|
||||
#include "Player.h"
|
||||
#include "CreatureGroups.h"
|
||||
#include "ObjectAccessor.h"
|
||||
|
||||
//----- Point Movement Generator
|
||||
template<class T>
|
||||
@@ -134,6 +135,9 @@ bool EffectMovementGenerator::Update(Unit* unit, uint32)
|
||||
|
||||
void EffectMovementGenerator::Finalize(Unit* unit)
|
||||
{
|
||||
if (_arrivalSpellId)
|
||||
unit->CastSpell(ObjectAccessor::GetUnit(*unit, _arrivalSpellTargetGuid), _arrivalSpellId, true);
|
||||
|
||||
if (unit->GetTypeId() != TYPEID_UNIT)
|
||||
return;
|
||||
|
||||
@@ -147,5 +151,5 @@ void EffectMovementGenerator::Finalize(Unit* unit)
|
||||
}
|
||||
|
||||
if (unit->ToCreature()->AI())
|
||||
unit->ToCreature()->AI()->MovementInform(EFFECT_MOTION_TYPE, m_Id);
|
||||
unit->ToCreature()->AI()->MovementInform(EFFECT_MOTION_TYPE, _id);
|
||||
}
|
||||
|
||||
@@ -63,14 +63,17 @@ class AssistanceMovementGenerator : public PointMovementGenerator<Creature>
|
||||
class EffectMovementGenerator : public MovementGenerator
|
||||
{
|
||||
public:
|
||||
explicit EffectMovementGenerator(uint32 Id) : m_Id(Id) { }
|
||||
EffectMovementGenerator(uint32 id, uint32 arrivalSpellId = 0, ObjectGuid const& arrivalSpellTargetGuid = ObjectGuid::Empty)
|
||||
: _id(id), _arrivalSpellId(arrivalSpellId), _arrivalSpellTargetGuid(arrivalSpellTargetGuid) { }
|
||||
void Initialize(Unit*) override { }
|
||||
void Finalize(Unit*) override;
|
||||
void Reset(Unit*) override { }
|
||||
bool Update(Unit*, uint32) override;
|
||||
MovementGeneratorType GetMovementGeneratorType() const override { return EFFECT_MOTION_TYPE; }
|
||||
private:
|
||||
uint32 m_Id;
|
||||
uint32 _id;
|
||||
uint32 _arrivalSpellId;
|
||||
ObjectGuid _arrivalSpellTargetGuid;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -924,7 +924,7 @@ void Spell::EffectJump(SpellEffIndex /*effIndex*/)
|
||||
|
||||
float speedXY, speedZ;
|
||||
CalculateJumpSpeeds(effectInfo, m_caster->GetExactDist2d(x, y), speedXY, speedZ);
|
||||
m_caster->GetMotionMaster()->MoveJump(x, y, z, speedXY, speedZ);
|
||||
m_caster->GetMotionMaster()->MoveJump(x, y, z, speedXY, speedZ, EVENT_JUMP, effectInfo->TriggerSpell, unitTarget->GetGUID());
|
||||
}
|
||||
|
||||
void Spell::EffectJumpDest(SpellEffIndex /*effIndex*/)
|
||||
@@ -944,7 +944,7 @@ void Spell::EffectJumpDest(SpellEffIndex /*effIndex*/)
|
||||
|
||||
float speedXY, speedZ;
|
||||
CalculateJumpSpeeds(effectInfo, m_caster->GetExactDist2d(x, y), speedXY, speedZ);
|
||||
m_caster->GetMotionMaster()->MoveJump(x, y, z, speedXY, speedZ);
|
||||
m_caster->GetMotionMaster()->MoveJump(x, y, z, speedXY, speedZ, EVENT_JUMP, effectInfo->TriggerSpell);
|
||||
}
|
||||
|
||||
void Spell::CalculateJumpSpeeds(SpellEffectInfo const* effInfo, float dist, float& speedXY, float& speedZ)
|
||||
@@ -4514,6 +4514,9 @@ void Spell::EffectCharge(SpellEffIndex /*effIndex*/)
|
||||
// not all charge effects used in negative spells
|
||||
if (!m_spellInfo->IsPositive() && m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
m_caster->Attack(unitTarget, true);
|
||||
|
||||
if (effectInfo->TriggerSpell)
|
||||
m_caster->CastSpell(unitTarget, effectInfo->TriggerSpell, true, nullptr, nullptr, m_originalCasterGUID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user