aboutsummaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authormegamage <none@none>2008-10-17 21:44:37 -0500
committermegamage <none@none>2008-10-17 21:44:37 -0500
commitbac1fb628e6c9d27f5f51e426e55d1d89920e763 (patch)
tree75918572ae9cc4a0c58827b93a2b646e25996bef /src/game
parent16dcd3727935841c94982165ef240d53d3b06db9 (diff)
[svn] Merge branch r50 with trunk.
--HG-- branch : trunk
Diffstat (limited to 'src/game')
-rw-r--r--src/game/SharedDefines.h81
-rw-r--r--src/game/Spell.cpp126
-rw-r--r--src/game/SpellEffects.cpp29
3 files changed, 179 insertions, 57 deletions
diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h
index b9348b5f568..4d001b37183 100644
--- a/src/game/SharedDefines.h
+++ b/src/game/SharedDefines.h
@@ -773,51 +773,118 @@ enum SpellImmunity
enum Targets
{
TARGET_SELF = 1,
+ //TARGET_UNIT_CASTER
TARGET_RANDOM_ENEMY_CHAIN_IN_AREA = 2, // only one spell has that, but regardless, it's a target type after all
+ //TARGET_UNIT_NEARBY_ENEMY
+ TARGET_UNIT_SINGLE_UNKNOWN = 3,
+ TARGET_UNIT_NEARBY_ALLY = 4,
TARGET_PET = 5,
+ //TARGET_UNIT_PET
TARGET_CHAIN_DAMAGE = 6,
+ //TARGET_UNIT_TARGET_ENEMY
+ TARGET_UNIT_AREA_ENTRY = 7,
TARGET_AREAEFFECT_CUSTOM = 8,
+ //TARGET_UNIT_AREA_ENTRY_GROUND
TARGET_INNKEEPER_COORDINATES = 9, // uses in teleport to innkeeper spells
+ //TARGET_DEST_HOME
+ TARGET_UNIT_TARGET_DEST_CASTER = 11, // teleport target to caster
TARGET_ALL_ENEMY_IN_AREA = 15,
+ //TARGET_UNIT_AREA_ENEMY
TARGET_ALL_ENEMY_IN_AREA_INSTANT = 16,
+ //TARGET_UNIT_AREA_ENEMY_GROUND
TARGET_TABLE_X_Y_Z_COORDINATES = 17, // uses in teleport spells and some other
+ //TARGET_DEST_TABLE
TARGET_EFFECT_SELECT = 18, // highly depends on the spell effect
+ //TARGET_DEST_CASTER_GROUND
TARGET_ALL_PARTY_AROUND_CASTER = 20,
+ //TARGET_UNIT_PARTY_CASTER
TARGET_SINGLE_FRIEND = 21,
+ //TARGET_UNIT_TARGET_ALLY
TARGET_ALL_AROUND_CASTER = 22, // used only in TargetA, target selection dependent from TargetB
+ //TARGET_DEST_CASTER
TARGET_GAMEOBJECT = 23,
+ //TARGET_OBJECT_OPEN
TARGET_IN_FRONT_OF_CASTER = 24,
+ //TARGET_UNIT_CONE_ENEMY
TARGET_DUELVSPLAYER = 25,
+ //TARGET_UNIT_SINGLE
TARGET_GAMEOBJECT_ITEM = 26,
+ //TARGET_OBJECT_ITEM_PICKLOCK
TARGET_MASTER = 27,
+ //TARGET_UNIT_MASTER
TARGET_ALL_ENEMY_IN_AREA_CHANNELED = 28,
+ //TARGET_UNIT_AREA_ENEMY_CHANNEL
+ TARGET_UNIT_AREA_ALLY_CHANNEL = 29, // 28,29 only used for effect 27, if interrupt channel, pstAA cancel
TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER = 30, // in TargetB used only with TARGET_ALL_AROUND_CASTER and in self casting range in TargetA
+ //TARGET_UNIT_AREA_ALLY
TARGET_ALL_FRIENDLY_UNITS_IN_AREA = 31,
+ //TARGET_UNIT_AREA_ALLY_GROUND
TARGET_MINION = 32,
+ //TARGET_DEST_SUMMON
TARGET_ALL_PARTY = 33,
+ //TARGET_UNIT_AREA_PARTY
TARGET_ALL_PARTY_AROUND_CASTER_2 = 34, // used in Tranquility
+ //TARGET_UNIT_AREA_PARTY_GROUND
TARGET_SINGLE_PARTY = 35,
+ //TARGET_UNIT_TARGET_PARTY
+ TARGET_DEST_CASTER_RANDOM_UNKNOWN = 36, //unknown
TARGET_AREAEFFECT_PARTY = 37,
+ //TARGET_UNIT_PARTY_TARGET
TARGET_SCRIPT = 38,
+ //TARGET_UNIT_NEARBY_ENTRY
TARGET_SELF_FISHING = 39,
- TARGET_TOTEM_EARTH = 41,
- TARGET_TOTEM_WATER = 42,
- TARGET_TOTEM_AIR = 43,
- TARGET_TOTEM_FIRE = 44,
+ //TARGET_UNIT_CASTER_FISHING
+ TARGET_OBJECT_USE = 40,
+ TARGET_DEST_CASTER_FRONT_LEFT = 41, //earth totem
+ TARGET_DEST_CASTER_BACK_LEFT = 42, //water totem
+ TARGET_DEST_CASTER_BACK_RIGHT = 43, //air totem
+ TARGET_DEST_CASTER_FRONT_RIGHT = 44, //fire totem
TARGET_CHAIN_HEAL = 45,
+ //TARGET_UNIT_CHAINHEAL
TARGET_SCRIPT_COORDINATES = 46,
- TARGET_DYNAMIC_OBJECT = 47,
- TARGET_SUMMON = 48,
+ //TARGET_DEST_TABLE_UNKNOWN
+ TARGET_DEST_CASTER_FRONT = 47,
+ TARGET_DEST_CASTER_BACK = 48,
+ TARGET_DEST_CASTER_RIGHT = 49,
+ TARGET_DEST_CASTER_LEFT = 50,
+ TARGET_OBJECT_AREA = 51,
TARGET_AREAEFFECT_CUSTOM_2 = 52,
+ //TARGET_DUMMY
TARGET_CURRENT_ENEMY_COORDINATES = 53, // set unit coordinates as dest, only 16 target B imlemented
+ //TARGET_DEST_TARGET_ENEMY
+ TARGET_UNIT_CONE_ENEMY_UNKNOWN = 54,
+ TARGET_DEST_CASTER_FRONT_LEAP = 55, // for a leap spell
TARGET_RANDOM_RAID_MEMBER = 56,
+ //TARGET_UNIT_AREA_RAID
TARGET_SINGLE_FRIEND_2 = 57,
+ //TARGET_UNIT_TARGET_RAID
+ TARGET_UNIT_CONE_ALLY = 59,
+ TARGET_UNIT_AREA_SCRIPT = 60,
TARGET_AREAEFFECT_PARTY_AND_CLASS = 61,
+ //TARGET_UNIT_CLASS_TARGET
+ TARGET_TEST = 62, // for a test spell
TARGET_DUELVSPLAYER_COORDINATES = 63,
- TARGET_BEHIND_VICTIM = 65, // uses in teleport behind spells
+ //TARGET_DEST_TARGET_ENEMY_UNKNOWN
+ TARGET_DEST_TARGET_FRONT = 64,
+ TARGET_DEST_TARGET_BACK = 65, // uses in teleport behind spells
+ TARGET_DEST_TARGET_RIGHT = 66,
+ TARGET_DEST_TARGET_LEFT = 67,
+ TARGET_DEST_TARGET_ENEMY_UNKNOWN2 = 70,
+ TARGET_DEST_CASTER_RANDOM = 72,
+ TARGET_DEST_CASTER_RADIUS = 73,
+ TARGET_DEST_TARGET_RANDOM = 74,
+ TARGET_DEST_TARGET_RADIUS = 75,
+ TARGET_DEST_CHANNEL = 76,
TARGET_SINGLE_ENEMY = 77,
+ //TARGET_UNIT_CHANNEL
+ TARGET_DEST_CASTER_FRONT_UNKNOWN = 78,
+ TARGET_DEST_TABLE_UNKNOWN2 = 80,
+ TARGET_DEST_DEST_RANDOM = 86,
TARGET_SELF2 = 87,
+ //TARGET_DEST_DEST
+ TARGET_UNIT_AREA_ALL_CHANNEL = 88,
TARGET_NONCOMBAT_PET = 90,
+ //TARGET_UNIT_MINIPET
};
enum SpellMissInfo
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 5dbe5c7c9ea..1b4dbd20894 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -1183,16 +1183,114 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
uint32 unMaxTargets = m_spellInfo->MaxAffectedTargets;
switch(cur)
{
- case TARGET_TOTEM_EARTH:
- case TARGET_TOTEM_WATER:
- case TARGET_TOTEM_AIR:
- case TARGET_TOTEM_FIRE:
- case TARGET_SELF:
+ // destination around caster
+ case TARGET_DEST_CASTER_FRONT_LEFT:
+ case TARGET_DEST_CASTER_BACK_LEFT:
+ case TARGET_DEST_CASTER_BACK_RIGHT:
+ case TARGET_DEST_CASTER_FRONT_RIGHT:
+ case TARGET_DEST_CASTER_FRONT:
+ case TARGET_DEST_CASTER_BACK:
+ case TARGET_DEST_CASTER_RIGHT:
+ case TARGET_DEST_CASTER_LEFT:
+ case TARGET_DEST_CASTER_RANDOM:
+ case TARGET_DEST_CASTER_RADIUS:
+ {
+ float x, y, z, angle, dist;
+
+ if (m_spellInfo->EffectRadiusIndex[i])
+ dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
+ else
+ dist = 3.0f;//do we need this?
+ if (cur == TARGET_DEST_CASTER_RANDOM)
+ dist *= rand_norm(); // This case we need to consider caster size
+ else
+ dist -= m_caster->GetObjectSize(); // Size is calculated in GetNearPoint(), but we do not need it
+ //need a new function to remove this repeated work
+
+ switch(cur)
+ {
+ case TARGET_DEST_CASTER_FRONT_LEFT: angle = -M_PI/4; break;
+ case TARGET_DEST_CASTER_BACK_LEFT: angle = -3*M_PI/4; break;
+ case TARGET_DEST_CASTER_BACK_RIGHT: angle = 3*M_PI/4; break;
+ case TARGET_DEST_CASTER_FRONT_RIGHT:angle = M_PI/4; break;
+ case TARGET_DEST_CASTER_FRONT: angle = 0.0f; break;
+ case TARGET_DEST_CASTER_BACK: angle = M_PI; break;
+ case TARGET_DEST_CASTER_RIGHT: angle = M_PI/2; break;
+ case TARGET_DEST_CASTER_LEFT: angle = -M_PI/2; break;
+ default: angle = rand_norm()*2*M_PI; break;
+ }
+
+ m_caster->GetClosePoint(x, y, z, 0, dist, angle);
+ m_targets.setDestination(x, y, z); // do not know if has ground visual
+ TagUnitMap.push_back(m_caster); // may remove this in the future, if unitmap is empty, push m_caster
+ }break;
+
+ // destination around target
+ case TARGET_DEST_TARGET_FRONT:
+ case TARGET_DEST_TARGET_BACK:
+ case TARGET_DEST_TARGET_RIGHT:
+ case TARGET_DEST_TARGET_LEFT:
+ case TARGET_DEST_TARGET_RANDOM:
+ case TARGET_DEST_TARGET_RADIUS:
+ {
+ Unit *target = m_targets.getUnitTarget();
+ if(!target)
+ {
+ sLog.outError("SPELL: no unit target for spell ID %u\n", m_spellInfo->Id);
+ break;
+ }
+
+ float x, y, z, angle, dist;
+
+ if (m_spellInfo->EffectRadiusIndex[i])
+ dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
+ else
+ dist = 3.0f;//do we need this?
+ if (cur == TARGET_DEST_TARGET_RANDOM)
+ dist *= rand_norm(); // This case we need to consider caster size
+ else
+ dist -= target->GetObjectSize(); // Size is calculated in GetNearPoint(), but we do not need it
+ //need a new function to remove this repeated work
+
+ switch(cur)
+ {
+ case TARGET_DEST_TARGET_FRONT: angle = 0.0f; break;
+ case TARGET_DEST_TARGET_BACK: angle = M_PI; break;
+ case TARGET_DEST_TARGET_RIGHT: angle = M_PI/2; break;
+ case TARGET_DEST_TARGET_LEFT: angle = -M_PI/2; break;
+ default: angle = rand_norm()*2*M_PI; break;
+ }
+
+ target->GetClosePoint(x, y, z, 0, dist, angle);
+ m_targets.setDestination(x, y, z); // do not know if has ground visual
+ TagUnitMap.push_back(m_caster); // may remove this in the future, if unitmap is empty, push m_caster
+ }break;
+
+ // destination around destination
+ case TARGET_DEST_DEST_RANDOM:
+ {
+ if(!(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION))
+ {
+ sLog.outError("SPELL: no destination for spell ID %u\n", m_spellInfo->Id);
+ break;
+ }
+ float x, y, z, dist, px, py, pz;
+ dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
+ x = m_targets.m_destX;
+ y = m_targets.m_destY;
+ z = m_targets.m_destZ;
+ m_caster->GetRandomPoint(x, y, z, dist, px, py, pz);
+ m_targets.setDestination(px, py, pz);
+ TagUnitMap.push_back(m_caster);
+ }break;
case TARGET_SELF2:
- case TARGET_DYNAMIC_OBJECT:
+ {
+ TagUnitMap.push_back(m_caster);
+ }break;
+
+ case TARGET_SELF:
case TARGET_AREAEFFECT_CUSTOM:
case TARGET_AREAEFFECT_CUSTOM_2:
- case TARGET_SUMMON:
{
TagUnitMap.push_back(m_caster);
break;
@@ -1865,20 +1963,6 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
else
sLog.outError( "SPELL: unknown target coordinates for spell ID %u\n", m_spellInfo->Id );
}break;
- case TARGET_BEHIND_VICTIM:
- {
- Unit *pTarget = m_caster->getVictim();
- if(!pTarget && m_caster->GetTypeId() == TYPEID_PLAYER)
- pTarget = ObjectAccessor::GetUnit(*m_caster, ((Player*)m_caster)->GetSelection());
-
- if(pTarget)
- {
- float _target_x, _target_y, _target_z;
- pTarget->GetClosePoint(_target_x, _target_y, _target_z, m_caster->GetObjectSize(), CONTACT_DISTANCE, M_PI);
- if(pTarget->IsWithinLOS(_target_x,_target_y,_target_z))
- m_targets.setDestination(_target_x, _target_y, _target_z);
- }
- }break;
default:
break;
}
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index c8f5c91156a..bf9d1b9f9bf 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -1919,35 +1919,6 @@ void Spell::EffectTeleportUnits(uint32 i)
((Player*)unitTarget)->TeleportTo(st->target_mapId,st->target_X,st->target_Y,st->target_Z,st->target_Orientation,unitTarget==m_caster ? TELE_TO_SPELL : 0);
break;
}
- case TARGET_BEHIND_VICTIM:
- {
- // Get selected target for player (or victim for units)
- Unit *pTarget = NULL;
- if(m_caster->GetTypeId() == TYPEID_PLAYER)
- pTarget = ObjectAccessor::GetUnit(*m_caster, ((Player*)m_caster)->GetSelection());
- else
- pTarget = m_caster->getVictim();
- // No target present - return
- if (!pTarget)
- return;
- // Init dest coordinates
- uint32 mapid = m_caster->GetMapId();
- float x = m_targets.m_destX;
- float y = m_targets.m_destY;
- float z = m_targets.m_destZ;
- float orientation = pTarget->GetOrientation();
- // Teleport
- if(unitTarget->GetTypeId() == TYPEID_PLAYER)
- ((Player*)unitTarget)->TeleportTo(mapid, x, y, z, orientation, TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0));
- else
- {
- MapManager::Instance().GetMap(mapid, m_caster)->CreatureRelocation((Creature*)unitTarget, x, y, z, orientation);
- WorldPacket data;
- unitTarget->BuildTeleportAckMsg(&data, x, y, z, orientation);
- unitTarget->SendMessageToSet(&data, false);
- }
- return;
- }
default:
{
// If not exist data for dest location - return