aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormegamage <none@none>2009-04-11 22:41:15 -0500
committermegamage <none@none>2009-04-11 22:41:15 -0500
commitdda2fdff33a6d12d6e8f2913fbb439d9b670890f (patch)
treeb8f581a7489ce71492ecc15a782ff08e9a5e75f6 /src
parent1d640d02726683e73c455ddda3354cf77925a957 (diff)
*Implement spell Disengage and Death Grip.
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/MotionMaster.cpp14
-rw-r--r--src/game/MotionMaster.h3
-rw-r--r--src/game/Object.cpp7
-rw-r--r--src/game/Object.h1
-rw-r--r--src/game/Spell.h1
-rw-r--r--src/game/SpellEffects.cpp59
-rw-r--r--src/game/SpellMgr.cpp9
-rw-r--r--src/game/Unit.cpp55
-rw-r--r--src/game/Unit.h6
9 files changed, 122 insertions, 33 deletions
diff --git a/src/game/MotionMaster.cpp b/src/game/MotionMaster.cpp
index 6d7a40da045..b299fbfd40a 100644
--- a/src/game/MotionMaster.cpp
+++ b/src/game/MotionMaster.cpp
@@ -305,7 +305,7 @@ MotionMaster::MovePoint(uint32 id, float x, float y, float z)
}
}
-void MotionMaster::MoveJumpFrom(float srcX, float srcY, float speedXY, float speedZ)
+void MotionMaster::MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ)
{
//this function may make players fall below map
if(i_owner->GetTypeId()==TYPEID_PLAYER)
@@ -317,6 +317,18 @@ void MotionMaster::MoveJumpFrom(float srcX, float srcY, float speedXY, float spe
MoveJump(x, y, z, speedXY, speedZ);
}
+void MotionMaster::MoveJumpTo(float angle, float speedXY, float speedZ)
+{
+ //this function may make players fall below map
+ if(i_owner->GetTypeId()==TYPEID_PLAYER)
+ return;
+
+ float x, y, z;
+ float dist = speedXY * speedZ * 0.1f;
+ i_owner->GetClosePoint(x, y, z, i_owner->GetObjectSize(), dist, angle);
+ MoveJump(x, y, z, speedXY, speedZ);
+}
+
void MotionMaster::MoveJump(float x, float y, float z, float speedXY, float speedZ)
{
uint32 moveFlag = MOVEFLAG_JUMP | MOVEFLAG_WALK;
diff --git a/src/game/MotionMaster.h b/src/game/MotionMaster.h
index 38a2b58825f..ea71495d216 100644
--- a/src/game/MotionMaster.h
+++ b/src/game/MotionMaster.h
@@ -141,7 +141,8 @@ class TRINITY_DLL_SPEC MotionMaster //: private std::stack<MovementGenerator *>
void MoveFleeing(Unit* enemy);
void MovePoint(uint32 id, float x,float y,float z);
void MoveCharge(float x, float y, float z, float speed = SPEED_CHARGE);
- void MoveJumpFrom(float srcX, float srcY, float speedXY, float speedZ);
+ void MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ);
+ void MoveJumpTo(float angle, float speedXY, float speedZ);
void MoveJump(float x, float y, float z, float speedXY, float speedZ);
void MoveTaxiFlight(uint32 path, uint32 pathnode);
void MoveDistract(uint32 time);
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index 7ac0ff8c8a6..5c6ecf83a02 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -1246,6 +1246,13 @@ float WorldObject::GetDistance2d(float x, float y) const
return ( dist > 0 ? dist : 0);
}
+float WorldObject::GetExactDistance2d(const float x, const float y) const
+{
+ float dx = GetPositionX() - x;
+ float dy = GetPositionY() - y;
+ return sqrt((dx*dx) + (dy*dy));
+}
+
float WorldObject::GetDistance(const float x, const float y, const float z) const
{
float dx = GetPositionX() - x;
diff --git a/src/game/Object.h b/src/game/Object.h
index 2fd45b45688..af165c853a2 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -455,6 +455,7 @@ class TRINITY_DLL_SPEC WorldObject : public Object
float GetDistanceSq(const float &x, const float &y, const float &z) const;
float GetDistance2d(const WorldObject* obj) const;
float GetDistance2d(const float x, const float y) const;
+ float GetExactDistance2d(const float x, const float y) const;
float GetDistanceZ(const WorldObject* obj) const;
bool IsInMap(const WorldObject* obj) const
{
diff --git a/src/game/Spell.h b/src/game/Spell.h
index 7c52a4e8bb3..e75bfb31eb9 100644
--- a/src/game/Spell.h
+++ b/src/game/Spell.h
@@ -278,6 +278,7 @@ class Spell
void EffectSummonWild(uint32 i);
void EffectHealMechanical(uint32 i);
void EffectJump(uint32 i);
+ void EffectJump2(uint32 i);
void EffectTeleUnitsFaceCaster(uint32 i);
void EffectLearnSkill(uint32 i);
void EffectAddHonor(uint32 i);
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index d860d548d7f..2697ee74604 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -105,7 +105,7 @@ pEffect SpellEffects[TOTAL_SPELL_EFFECTS]=
&Spell::EffectDispel, // 38 SPELL_EFFECT_DISPEL
&Spell::EffectUnused, // 39 SPELL_EFFECT_LANGUAGE
&Spell::EffectDualWield, // 40 SPELL_EFFECT_DUAL_WIELD
- &Spell::EffectUnused, // 41 SPELL_EFFECT_JUMP
+ &Spell::EffectJump, // 41 SPELL_EFFECT_JUMP
&Spell::EffectJump, // 42 SPELL_EFFECT_JUMP2
&Spell::EffectTeleUnitsFaceCaster, // 43 SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER
&Spell::EffectLearnSkill, // 44 SPELL_EFFECT_SKILL_STEP
@@ -202,7 +202,7 @@ pEffect SpellEffects[TOTAL_SPELL_EFFECTS]=
&Spell::EffectNULL, //135 SPELL_EFFECT_CALL_PET
&Spell::EffectHealPct, //136 SPELL_EFFECT_HEAL_PCT
&Spell::EffectEnergisePct, //137 SPELL_EFFECT_ENERGIZE_PCT
- &Spell::EffectNULL, //138 SPELL_EFFECT_138 Leap
+ &Spell::EffectJump2, //138 SPELL_EFFECT_138 Leap
&Spell::EffectUnused, //139 SPELL_EFFECT_CLEAR_QUEST (misc - is quest ID)
&Spell::EffectForceCast, //140 SPELL_EFFECT_FORCE_CAST
&Spell::EffectNULL, //141 SPELL_EFFECT_141 damage and reduce speed?
@@ -1864,7 +1864,7 @@ void Spell::EffectDummy(uint32 i)
return;
}
// Death Coil
- if(m_spellInfo->SpellFamilyFlags[0] & 0x002000)
+ else if(m_spellInfo->SpellFamilyFlags[0] & 0x002000)
{
if(m_caster->IsFriendlyTo(unitTarget))
{
@@ -1881,6 +1881,12 @@ void Spell::EffectDummy(uint32 i)
}
return;
}
+ // Death Grip
+ else if(m_spellInfo->Id == 49560)
+ {
+ unitTarget->CastSpell(m_caster, damage, true);
+ return;
+ }
break;
}
@@ -2218,7 +2224,16 @@ void Spell::EffectJump(uint32 i)
return;
}
- m_caster->NearTeleportTo(x,y,z,o,true);
+ //m_caster->NearTeleportTo(x,y,z,o,true);
+ float speedZ;
+ if(m_spellInfo->EffectMiscValue[i])
+ speedZ = float(m_spellInfo->EffectMiscValue[i])/10;
+ else if(m_spellInfo->EffectMiscValueB[i])
+ speedZ = float(m_spellInfo->EffectMiscValueB[i])/10;
+ else
+ speedZ = 10.0f;
+ float speedXY = m_caster->GetExactDistance2d(x, y) * 10.0f / speedZ;
+ m_caster->GetMotionMaster()->MoveJump(x, y, z, speedXY, speedZ);
}
void Spell::EffectTeleportUnits(uint32 i)
@@ -5748,26 +5763,28 @@ void Spell::EffectKnockBack(uint32 i)
}
float speedxy = float(m_spellInfo->EffectMiscValue[i])/10;
- float speedz = float(damage/-10);
+ float speedz = float(damage/10);
- if(unitTarget->GetTypeId() == TYPEID_UNIT)
- {
- unitTarget->GetMotionMaster()->MoveJumpFrom(x, y, speedxy, -speedz);
- return;
- }
-
- float vcos, vsin;
- unitTarget->GetSinCos(x, y, vsin, vcos);
+ unitTarget->KnockbackFrom(x, y, speedxy, speedz);
+}
- WorldPacket data(SMSG_MOVE_KNOCK_BACK, (8+4+4+4+4+4));
- data.append(unitTarget->GetPackGUID());
- data << uint32(0); // Sequence
- data << float(vcos); // x direction
- data << float(vsin); // y direction
- data << float(speedxy); // Horizontal speed
- data << float(speedz); // Z Movement speed (vertical)
+void Spell::EffectJump2(uint32 i)
+{
+ if(!unitTarget)
+ return;
- ((Player*)unitTarget)->GetSession()->SendPacket(&data);
+ float speedxy = float(m_spellInfo->EffectMiscValue[i])/10;
+ float speedz = float(damage/10);
+ if(!speedxy)
+ {
+ if(m_targets.getUnitTarget())
+ unitTarget->JumpTo(m_targets.getUnitTarget(), speedz);
+ }
+ else
+ {
+ //1891: Disengage
+ unitTarget->JumpTo(speedxy, speedz, m_spellInfo->SpellIconID != 1891);
+ }
}
void Spell::EffectSendTaxi(uint32 i)
diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp
index ee2632caa12..7134dbb4dba 100644
--- a/src/game/SpellMgr.cpp
+++ b/src/game/SpellMgr.cpp
@@ -39,18 +39,10 @@ SpellMgr::SpellMgr()
case SPELL_EFFECT_PERSISTENT_AREA_AURA: //27
case SPELL_EFFECT_SUMMON: //28
case SPELL_EFFECT_TRIGGER_MISSILE: //32
- //case SPELL_EFFECT_SUMMON_WILD: //41 not 303
- //case SPELL_EFFECT_SUMMON_GUARDIAN: //42 not 303
case SPELL_EFFECT_TRANS_DOOR: //50 summon object
case SPELL_EFFECT_SUMMON_PET: //56
case SPELL_EFFECT_ADD_FARSIGHT: //72
- //case SPELL_EFFECT_SUMMON_POSSESSED: //73
- //case SPELL_EFFECT_SUMMON_TOTEM: //74
case SPELL_EFFECT_SUMMON_OBJECT_WILD: //76
- //case SPELL_EFFECT_SUMMON_TOTEM_SLOT1: //87
- //case SPELL_EFFECT_SUMMON_TOTEM_SLOT2: //88
- //case SPELL_EFFECT_SUMMON_TOTEM_SLOT3: //89
- //case SPELL_EFFECT_SUMMON_TOTEM_SLOT4: //90
//case SPELL_EFFECT_SUMMON_CRITTER: //97 not 303
case SPELL_EFFECT_SUMMON_OBJECT_SLOT1: //104
case SPELL_EFFECT_SUMMON_OBJECT_SLOT2: //105
@@ -84,6 +76,7 @@ SpellMgr::SpellMgr()
case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY:
case SPELL_EFFECT_APPLY_AREA_AURA_PET:
case SPELL_EFFECT_APPLY_AREA_AURA_OWNER:
+ case SPELL_EFFECT_JUMP2: //42
EffectTargetType[i] = SPELL_REQUIRE_CASTER;
break;
default:
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 2d55920d0f1..0ba580d77ab 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -13303,6 +13303,61 @@ void Unit::SetPhaseMask(uint32 newPhaseMask, bool update)
summon->SetPhaseMask(newPhaseMask,true);
}
+void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ)
+{
+ if(GetTypeId() == TYPEID_UNIT)
+ {
+ GetMotionMaster()->MoveKnockbackFrom(x, y, speedXY, speedZ);
+ }
+ else
+ {
+ float vcos, vsin;
+ GetSinCos(x, y, vsin, vcos);
+
+ WorldPacket data(SMSG_MOVE_KNOCK_BACK, (8+4+4+4+4+4));
+ data.append(GetPackGUID());
+ data << uint32(0); // Sequence
+ data << float(vcos); // x direction
+ data << float(vsin); // y direction
+ data << float(speedXY); // Horizontal speed
+ data << float(-speedZ); // Z Movement speed (vertical)
+
+ ((Player*)this)->GetSession()->SendPacket(&data);
+ }
+}
+
+void Unit::JumpTo(float speedXY, float speedZ, bool forward)
+{
+ float angle = forward ? 0 : M_PI;
+ if(GetTypeId() == TYPEID_UNIT)
+ {
+ GetMotionMaster()->MoveJumpTo(angle, speedXY, speedZ);
+ }
+ else
+ {
+ float vcos = cos(angle+GetOrientation());
+ float vsin = sin(angle+GetOrientation());
+
+ WorldPacket data(SMSG_MOVE_KNOCK_BACK, (8+4+4+4+4+4));
+ data.append(GetPackGUID());
+ data << uint32(0); // Sequence
+ data << float(vcos); // x direction
+ data << float(vsin); // y direction
+ data << float(speedXY); // Horizontal speed
+ data << float(-speedZ); // Z Movement speed (vertical)
+
+ ((Player*)this)->GetSession()->SendPacket(&data);
+ }
+}
+
+void Unit::JumpTo(WorldObject *obj, float speedZ)
+{
+ float x, y, z;
+ obj->GetContactPoint(this, x, y, z);
+ float speedXY = GetExactDistance2d(x, y) * 10.0f / speedZ;
+ GetMotionMaster()->MoveJump(x, y, z, speedXY, speedZ);
+}
+
void Unit::NearTeleportTo( float x, float y, float z, float orientation, bool casting /*= false*/ )
{
if(GetTypeId() == TYPEID_PLAYER)
diff --git a/src/game/Unit.h b/src/game/Unit.h
index af902dba15a..ace61563c0f 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1145,6 +1145,10 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false);
+ void KnockbackFrom(float x, float y, float speedXY, float speedZ);
+ void JumpTo(float speedXY, float speedZ, bool forward = true);
+ void JumpTo(WorldObject *obj, float speedZ);
+
void SendMonsterStop();
void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 Time, Player* player = NULL);
void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 MoveFlags, uint32 time, float speedZ, Player *player = NULL);
@@ -1153,8 +1157,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime = 0, Player* player = NULL);
void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL);
- virtual void MoveOutOfRange(Player &) { };
-
bool isAlive() const { return (m_deathState == ALIVE); };
bool isDead() const { return ( m_deathState == DEAD || m_deathState == CORPSE ); };
DeathState getDeathState() { return m_deathState; };