Core/Spells: ported CastSpell unclusterfucking from 3.3.5 branch
This commit is contained in:
1 parent
7e637971ee
commit
754c138f89
157 files changed
+1195
-1223
No files matched your search
@@ -1056,162 +1056,48 @@ void Unit::CastStop(uint32 except_spellid)
|
||||
InterruptSpell(CurrentSpellTypes(i), false);
|
||||
}
|
||||
|
||||
void Unit::CastSpell(SpellCastTargets const& targets, SpellInfo const* spellInfo, CustomSpellValues const* value, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster)
|
||||
void Unit::CastSpell(SpellCastTargets const& targets, uint32 spellId, CastSpellExtraArgs const& args)
|
||||
{
|
||||
if (!spellInfo)
|
||||
SpellInfo const* info = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (!info)
|
||||
{
|
||||
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell by caster: %s %u)", (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
|
||||
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell %u by caster %s", spellId, GetGUID().ToString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
Spell* spell = new Spell(this, spellInfo, triggerFlags, originalCaster);
|
||||
Spell* spell = new Spell(this, info, args.TriggerFlags, args.OriginalCaster);
|
||||
for (auto const& pair : args.SpellValueOverrides)
|
||||
spell->SetSpellValue(pair.first, pair.second);
|
||||
|
||||
if (value)
|
||||
for (CustomSpellValues::const_iterator itr = value->begin(); itr != value->end(); ++itr)
|
||||
spell->SetSpellValue(itr->first, itr->second);
|
||||
|
||||
spell->m_CastItem = castItem;
|
||||
spell->prepare(&targets, triggeredByAura);
|
||||
spell->m_CastItem = args.CastItem;
|
||||
spell->prepare(targets, args.TriggeringAura);
|
||||
}
|
||||
|
||||
void Unit::CastSpell(Unit* victim, uint32 spellId, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster)
|
||||
{
|
||||
CastSpell(victim, spellId, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
|
||||
void Unit::CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags /*= TRIGGER_NONE*/, Item* castItem /*= nullptr*/, AuraEffect const* triggeredByAura /*= nullptr*/, ObjectGuid originalCaster /*= ObjectGuid::Empty*/)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (!spellInfo)
|
||||
{
|
||||
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
|
||||
return;
|
||||
}
|
||||
|
||||
CastSpell(victim, spellInfo, triggerFlags, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
|
||||
void Unit::CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem/*= nullptr*/, AuraEffect const* triggeredByAura /*= nullptr*/, ObjectGuid originalCaster /*= ObjectGuid::Empty*/)
|
||||
{
|
||||
CastSpell(victim, spellInfo, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
|
||||
void Unit::CastSpell(Unit* victim, SpellInfo const* spellInfo, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster)
|
||||
void Unit::CastSpell(WorldObject* target, uint32 spellId, CastSpellExtraArgs const& args)
|
||||
{
|
||||
SpellCastTargets targets;
|
||||
targets.SetUnitTarget(victim);
|
||||
CastSpell(targets, spellInfo, nullptr, triggerFlags, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
|
||||
void Unit::CastCustomSpell(Unit* target, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster)
|
||||
{
|
||||
CustomSpellValues values;
|
||||
if (bp0)
|
||||
values.AddSpellMod(SPELLVALUE_BASE_POINT0, *bp0);
|
||||
if (bp1)
|
||||
values.AddSpellMod(SPELLVALUE_BASE_POINT1, *bp1);
|
||||
if (bp2)
|
||||
values.AddSpellMod(SPELLVALUE_BASE_POINT2, *bp2);
|
||||
CastCustomSpell(spellId, values, target, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
|
||||
void Unit::CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* target, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster)
|
||||
{
|
||||
CustomSpellValues values;
|
||||
values.AddSpellMod(mod, value);
|
||||
CastCustomSpell(spellId, values, target, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
|
||||
void Unit::CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* target, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster)
|
||||
{
|
||||
CustomSpellValues values;
|
||||
values.AddSpellMod(mod, value);
|
||||
CastCustomSpell(spellId, values, target, triggerFlags, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
|
||||
void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const& value, Unit* victim, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (!spellInfo)
|
||||
if (target)
|
||||
{
|
||||
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
|
||||
return;
|
||||
if (Unit* unitTarget = target->ToUnit())
|
||||
targets.SetUnitTarget(unitTarget);
|
||||
else if (GameObject* goTarget = target->ToGameObject())
|
||||
targets.SetGOTarget(goTarget);
|
||||
else
|
||||
{
|
||||
TC_LOG_ERROR("entities.unit", "CastSpell: Invalid target %s passed to spell cast by %s", target->GetGUID().ToString().c_str(), GetGUID().ToString().c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
SpellCastTargets targets;
|
||||
targets.SetUnitTarget(victim);
|
||||
|
||||
CastSpell(targets, spellInfo, &value, triggerFlags, castItem, triggeredByAura, originalCaster);
|
||||
CastSpell(targets, spellId, args);
|
||||
}
|
||||
|
||||
void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster)
|
||||
void Unit::CastSpell(Position const& dest, uint32 spellId, CastSpellExtraArgs const& args)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (!spellInfo)
|
||||
{
|
||||
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
|
||||
return;
|
||||
}
|
||||
SpellCastTargets targets;
|
||||
targets.SetDst(x, y, z, GetOrientation());
|
||||
|
||||
CastSpell(targets, spellInfo, nullptr, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
|
||||
targets.SetDst(dest);
|
||||
CastSpell(targets, spellId, args);
|
||||
}
|
||||
|
||||
void Unit::CastSpell(float x, float y, float z, uint32 spellId, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (!spellInfo)
|
||||
{
|
||||
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
|
||||
return;
|
||||
}
|
||||
SpellCastTargets targets;
|
||||
targets.SetDst(x, y, z, GetOrientation());
|
||||
|
||||
CastSpell(targets, spellInfo, nullptr, triggerFlags, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
|
||||
void Unit::CastSpell(float x, float y, float z, float o, uint32 spellId, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (!spellInfo)
|
||||
{
|
||||
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
|
||||
return;
|
||||
}
|
||||
SpellCastTargets targets;
|
||||
targets.SetDst(x, y, z, o);
|
||||
|
||||
CastSpell(targets, spellInfo, nullptr, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
|
||||
void Unit::CastSpell(float x, float y, float z, float o, uint32 spellId, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (!spellInfo)
|
||||
{
|
||||
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
|
||||
return;
|
||||
}
|
||||
SpellCastTargets targets;
|
||||
targets.SetDst(x, y, z, o);
|
||||
|
||||
CastSpell(targets, spellInfo, nullptr, triggerFlags, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
|
||||
void Unit::CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castItem, AuraEffect* triggeredByAura, ObjectGuid originalCaster)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (!spellInfo)
|
||||
{
|
||||
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
|
||||
return;
|
||||
}
|
||||
SpellCastTargets targets;
|
||||
targets.SetGOTarget(go);
|
||||
|
||||
CastSpell(targets, spellInfo, nullptr, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
|
||||
void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType, bool crit)
|
||||
{
|
||||
@@ -2171,7 +2057,7 @@ void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extr
|
||||
}
|
||||
else
|
||||
{
|
||||
CastSpell(victim, meleeAttackSpellId, true, nullptr, meleeAttackAuraEffect);
|
||||
CastSpell(victim, meleeAttackSpellId, meleeAttackAuraEffect);
|
||||
|
||||
uint32 hitInfo = HITINFO_AFFECTS_VICTIM | HITINFO_NO_ANIMATION;
|
||||
if (attType == OFF_ATTACK)
|
||||
@@ -3031,7 +2917,7 @@ void Unit::_UpdateAutoRepeatSpell()
|
||||
|
||||
// we want to shoot
|
||||
Spell* spell = new Spell(this, autoRepeatSpellInfo, TRIGGERED_FULL_MASK);
|
||||
spell->prepare(&(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_targets));
|
||||
spell->prepare(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_targets);
|
||||
|
||||
// all went good, reset attack
|
||||
resetAttackTimer(RANGED_ATTACK);
|
||||
@@ -5849,7 +5735,7 @@ void Unit::ModifyAuraState(AuraStateType flag, bool apply)
|
||||
if (!spellInfo || !spellInfo->IsPassive())
|
||||
continue;
|
||||
if (spellInfo->CasterAuraState == uint32(flag))
|
||||
CastSpell(this, itr->first, true, nullptr);
|
||||
CastSpell(this, itr->first, true);
|
||||
}
|
||||
}
|
||||
else if (Pet* pet = ToCreature()->ToPet())
|
||||
@@ -5862,7 +5748,7 @@ void Unit::ModifyAuraState(AuraStateType flag, bool apply)
|
||||
if (!spellInfo || !spellInfo->IsPassive())
|
||||
continue;
|
||||
if (spellInfo->CasterAuraState == uint32(flag))
|
||||
CastSpell(this, itr->first, true, nullptr);
|
||||
CastSpell(this, itr->first, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10340,7 +10226,7 @@ void CharmInfo::InitPossessCreateSpells()
|
||||
if (spellInfo)
|
||||
{
|
||||
if (spellInfo->IsPassive())
|
||||
_unit->CastSpell(_unit, spellInfo, true);
|
||||
_unit->CastSpell(_unit, spellInfo->Id, true);
|
||||
else
|
||||
AddSpellToActionBar(spellInfo, ACT_PASSIVE, i % MAX_UNIT_ACTION_BAR_INDEX);
|
||||
}
|
||||
@@ -10373,7 +10259,7 @@ void CharmInfo::InitCharmCreateSpells()
|
||||
|
||||
if (spellInfo->IsPassive())
|
||||
{
|
||||
_unit->CastSpell(_unit, spellInfo, true);
|
||||
_unit->CastSpell(_unit, spellInfo->Id, true);
|
||||
_charmspells[x].SetActionAndType(spellId, ACT_PASSIVE);
|
||||
}
|
||||
else
|
||||
@@ -13147,7 +13033,12 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
|
||||
}
|
||||
|
||||
if (IsInMap(caster))
|
||||
caster->CastCustomSpell(itr->second.spellId, SpellValueMod(SPELLVALUE_BASE_POINT0+i), seatId + 1, target, flags, nullptr, nullptr, origCasterGUID);
|
||||
{
|
||||
CastSpellExtraArgs args(flags);
|
||||
args.OriginalCaster = origCasterGUID;
|
||||
args.SpellValueOverrides.AddMod(SpellValueMod(SPELLVALUE_BASE_POINT0 + i), seatId + 1);
|
||||
caster->CastSpell(target, itr->second.spellId, args);
|
||||
}
|
||||
else // This can happen during Player::_LoadAuras
|
||||
{
|
||||
int32 bp0[MAX_SPELL_EFFECTS];
|
||||
@@ -13161,7 +13052,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
|
||||
else
|
||||
{
|
||||
if (IsInMap(caster))
|
||||
caster->CastSpell(target, spellEntry, flags, nullptr, nullptr, origCasterGUID);
|
||||
caster->CastSpell(target, spellEntry->Id, CastSpellExtraArgs().SetOriginalCaster(origCasterGUID));
|
||||
else
|
||||
Aura::TryRefreshStackOrCreate(spellEntry, MAX_EFFECT_MASK, this, clicker, nullptr, nullptr, origCasterGUID);
|
||||
}
|
||||
@@ -13178,7 +13069,9 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
|
||||
|
||||
void Unit::EnterVehicle(Unit* base, int8 seatId)
|
||||
{
|
||||
CastCustomSpell(VEHICLE_SPELL_RIDE_HARDCODED, SPELLVALUE_BASE_POINT0, seatId + 1, base, TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE);
|
||||
CastSpellExtraArgs args(TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE);
|
||||
args.SpellValueOverrides.AddBP0(seatId + 1);
|
||||
CastSpell(base, VEHICLE_SPELL_RIDE_HARDCODED, args);
|
||||
}
|
||||
|
||||
void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* aurApp)
|
||||
|
||||
Reference in new issue
Block a user