AZEROTHCORE compatibility (#271)

* Done Compatible AZEROTHCORE.

* Fix TC build

* Try fix whitespace (trailing and tabs2spaces)

* Remove undefs and TC_LOG defines

* Revert indentation change

* Indentation and style change

* Add more possible SQL types to query

* change bg hooks OnBGEnd parameter type.
This commit is contained in:
ayase
2018-06-06 23:42:46 +08:00
committed by Rochet2
parent 2cedb8c5af
commit 9b5499db9c
31 changed files with 869 additions and 510 deletions

View File

@@ -68,7 +68,7 @@ namespace LuaUnit
*/
int IsRooted(lua_State* L, Unit* unit)
{
#ifdef TRINITY
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->isInRoots() || unit->HasUnitMovementFlag(MOVEMENTFLAG_ROOT));
#endif
#ifdef CMANGOS
@@ -102,10 +102,10 @@ namespace LuaUnit
{
Creature* creature = Eluna::CHECKOBJ<Creature>(L, 2);
#ifndef TRINITY
Eluna::Push(L, unit->isInAccessablePlaceFor(creature));
#else
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->isInAccessiblePlaceFor(creature));
#else
Eluna::Push(L, unit->isInAccessablePlaceFor(creature));
#endif
return 1;
}
@@ -117,10 +117,10 @@ namespace LuaUnit
*/
int IsAuctioneer(lua_State* L, Unit* unit)
{
#ifndef TRINITY
Eluna::Push(L, unit->isAuctioner());
#else
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->IsAuctioner());
#else
Eluna::Push(L, unit->isAuctioner());
#endif
return 1;
}
@@ -425,10 +425,10 @@ namespace LuaUnit
*/
int IsOnVehicle(lua_State* L, Unit* unit)
{
#ifndef TRINITY
Eluna::Push(L, unit->IsBoarded());
#else
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->GetVehicle());
#else
Eluna::Push(L, unit->IsBoarded());
#endif
return 1;
}
@@ -542,7 +542,7 @@ namespace LuaUnit
*/
int IsCasting(lua_State* L, Unit* unit)
{
#ifdef TRINITY
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->HasUnitState(UNIT_STATE_CASTING));
#else
Eluna::Push(L, unit->IsNonMeleeSpellCasted(false));
@@ -559,10 +559,10 @@ namespace LuaUnit
int HasUnitState(lua_State* L, Unit* unit)
{
uint32 state = Eluna::CHECKVAL<uint32>(L, 2);
#ifndef TRINITY
Eluna::Push(L, unit->hasUnitState(state));
#else
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->HasUnitState(state));
#else
Eluna::Push(L, unit->hasUnitState(state));
#endif
return 1;
}
@@ -603,10 +603,10 @@ namespace LuaUnit
*/
int GetOwnerGUID(lua_State* L, Unit* unit)
{
#ifndef TRINITY
Eluna::Push(L, unit->GetOwnerGuid());
#else
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->GetOwnerGUID());
#else
Eluna::Push(L, unit->GetOwnerGuid());
#endif
return 1;
}
@@ -629,10 +629,10 @@ namespace LuaUnit
*/
int GetCreatorGUID(lua_State* L, Unit* unit)
{
#ifndef TRINITY
Eluna::Push(L, unit->GetCreatorGuid());
#else
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->GetCreatorGUID());
#else
Eluna::Push(L, unit->GetCreatorGuid());
#endif
return 1;
}
@@ -644,10 +644,10 @@ namespace LuaUnit
*/
int GetCharmerGUID(lua_State* L, Unit* unit)
{
#ifndef TRINITY
Eluna::Push(L, unit->GetCharmerGuid());
#else
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->GetCharmerGUID());
#else
Eluna::Push(L, unit->GetCharmerGuid());
#endif
return 1;
}
@@ -659,10 +659,10 @@ namespace LuaUnit
*/
int GetCharmGUID(lua_State* L, Unit* unit)
{
#ifndef TRINITY
Eluna::Push(L, unit->GetCharmGuid());
#else
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->GetCharmGUID());
#else
Eluna::Push(L, unit->GetCharmGuid());
#endif
return 1;
}
@@ -674,10 +674,10 @@ namespace LuaUnit
*/
int GetPetGUID(lua_State* L, Unit* unit)
{
#ifndef TRINITY
Eluna::Push(L, unit->GetPetGuid());
#else
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->GetPetGUID());
#else
Eluna::Push(L, unit->GetPetGuid());
#endif
return 1;
}
@@ -689,10 +689,10 @@ namespace LuaUnit
*/
int GetControllerGUID(lua_State* L, Unit* unit)
{
#ifndef TRINITY
Eluna::Push(L, unit->GetCharmerOrOwnerGuid());
#else
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->GetCharmerOrOwnerGUID());
#else
Eluna::Push(L, unit->GetCharmerOrOwnerGuid());
#endif
return 1;
}
@@ -704,10 +704,10 @@ namespace LuaUnit
*/
int GetControllerGUIDS(lua_State* L, Unit* unit)
{
#ifndef TRINITY
Eluna::Push(L, unit->GetCharmerOrOwnerOrOwnGuid());
#else
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->GetCharmerOrOwnerOrOwnGUID());
#else
Eluna::Push(L, unit->GetCharmerOrOwnerOrOwnGuid());
#endif
return 1;
}
@@ -753,10 +753,10 @@ namespace LuaUnit
*/
int GetVictim(lua_State* L, Unit* unit)
{
#ifndef TRINITY
Eluna::Push(L, unit->getVictim());
#else
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->GetVictim());
#else
Eluna::Push(L, unit->getVictim());
#endif
return 1;
}
@@ -851,6 +851,9 @@ namespace LuaUnit
#ifdef TRINITY
if (powerType == -1)
return unit->GetPowerType();
#elif AZEROTHCORE
if (powerType == -1)
return unit->getPowerType();
#else
if (powerType == -1)
return unit->GetPowerType();
@@ -977,6 +980,8 @@ namespace LuaUnit
{
#ifdef TRINITY
Eluna::Push(L, unit->GetPowerType());
#elif AZEROTHCORE
Eluna::Push(L, unit->getPowerType());
#else
Eluna::Push(L, unit->GetPowerType());
#endif
@@ -1001,10 +1006,10 @@ namespace LuaUnit
*/
int GetHealthPct(lua_State* L, Unit* unit)
{
#ifndef TRINITY
Eluna::Push(L, unit->GetHealthPercent());
#else
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->GetHealthPct());
#else
Eluna::Push(L, unit->GetHealthPercent());
#endif
return 1;
}
@@ -1169,10 +1174,10 @@ namespace LuaUnit
int GetAura(lua_State* L, Unit* unit)
{
uint32 spellID = Eluna::CHECKVAL<uint32>(L, 2);
#ifndef TRINITY
Eluna::Push(L, unit->GetAura(spellID, EFFECT_INDEX_0));
#else
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->GetAura(spellID));
#else
Eluna::Push(L, unit->GetAura(spellID, EFFECT_INDEX_0));
#endif
return 1;
}
@@ -1188,14 +1193,18 @@ namespace LuaUnit
float range = Eluna::CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
std::list<Unit*> list;
#ifndef TRINITY
MaNGOS::AnyFriendlyUnitInObjectRangeCheck checker(unit, range);
MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck> searcher(list, checker);
Cell::VisitGridObjects(unit, searcher, range);
#else
#ifdef TRINITY
Trinity::AnyFriendlyUnitInObjectRangeCheck checker(unit, unit, range);
Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(unit, list, checker);
Cell::VisitAllObjects(unit, searcher, range);
#elif AZEROTHCORE
Trinity::AnyFriendlyUnitInObjectRangeCheck checker(unit, unit, range);
Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(unit, list, checker);
unit->VisitNearbyObject(range, searcher);
#else
MaNGOS::AnyFriendlyUnitInObjectRangeCheck checker(unit, range);
MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck> searcher(list, checker);
Cell::VisitGridObjects(unit, searcher, range);
#endif
ElunaUtil::ObjectGUIDCheck guidCheck(unit->GET_GUID());
list.remove_if(guidCheck);
@@ -1225,14 +1234,18 @@ namespace LuaUnit
float range = Eluna::CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
std::list<Unit*> list;
#ifndef TRINITY
MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck checker(unit, range);
MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck> searcher(list, checker);
Cell::VisitGridObjects(unit, searcher, range);
#else
#ifdef TRINITY
Trinity::AnyUnfriendlyUnitInObjectRangeCheck checker(unit, unit, range);
Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(unit, list, checker);
Cell::VisitAllObjects(unit, searcher, range);
#elif AZEROTHCORE
Trinity::AnyUnfriendlyUnitInObjectRangeCheck checker(unit, unit, range);
Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(unit, list, checker);
unit->VisitNearbyObject(range, searcher);
#else
MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck checker(unit, range);
MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck> searcher(list, checker);
Cell::VisitGridObjects(unit, searcher, range);
#endif
ElunaUtil::ObjectGUIDCheck guidCheck(unit->GET_GUID());
list.remove_if(guidCheck);
@@ -1259,10 +1272,10 @@ namespace LuaUnit
*/
int GetVehicleKit(lua_State* L, Unit* unit)
{
#ifndef TRINITY
Eluna::Push(L, unit->GetVehicleInfo());
#else
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->GetVehicleKit());
#else
Eluna::Push(L, unit->GetVehicleInfo());
#endif
return 1;
}
@@ -1282,10 +1295,10 @@ namespace LuaUnit
*/
int GetCritterGUID(lua_State* L, Unit* unit)
{
#ifndef TRINITY
Eluna::Push(L, unit->GetCritterGuid());
#else
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->GetCritterGUID());
#else
Eluna::Push(L, unit->GetCritterGuid());
#endif
return 1;
}
@@ -1373,10 +1386,10 @@ namespace LuaUnit
{
uint64 guid = Eluna::CHECKVAL<uint64>(L, 2);
#ifndef TRINITY
unit->SetOwnerGuid(ObjectGuid(guid));
#else
#if defined TRINITY || AZEROTHCORE
unit->SetOwnerGUID(ObjectGuid(guid));
#else
unit->SetOwnerGuid(ObjectGuid(guid));
#endif
return 0;
}
@@ -1459,10 +1472,10 @@ namespace LuaUnit
bool forced = Eluna::CHECKVAL<bool>(L, 4, false);
if (type >= MAX_MOVE_TYPE)
return luaL_argerror(L, 2, "valid UnitMoveType expected");
#ifndef TRINITY
unit->SetSpeedRate((UnitMoveType)type, rate, forced);
#else
#if defined TRINITY || AZEROTHCORE
unit->SetSpeedRate((UnitMoveType)type, rate);
#else
unit->SetSpeedRate((UnitMoveType)type, rate, forced);
#endif
return 0;
}
@@ -1651,6 +1664,8 @@ namespace LuaUnit
#ifdef TRINITY
unit->SetPowerType((Powers)type);
#elif AZEROTHCORE
unit->setPowerType((Powers)type);
#else
unit->SetPowerType((Powers)type);
#endif
@@ -1713,10 +1728,10 @@ namespace LuaUnit
int SetCreatorGUID(lua_State* L, Unit* unit)
{
uint64 guid = Eluna::CHECKVAL<uint64>(L, 2);
#ifndef TRINITY
unit->SetCreatorGuid(ObjectGuid(guid));
#else
#if defined TRINITY || AZEROTHCORE
unit->SetCreatorGUID(ObjectGuid(guid));
#else
unit->SetCreatorGuid(ObjectGuid(guid));
#endif
return 0;
}
@@ -1729,10 +1744,10 @@ namespace LuaUnit
int SetCharmerGUID(lua_State* L, Unit* unit)
{
uint64 guid = Eluna::CHECKVAL<uint64>(L, 2);
#ifndef TRINITY
unit->SetCharmerGuid(ObjectGuid(guid));
#else
#if defined TRINITY || AZEROTHCORE
unit->SetCharmerGUID(ObjectGuid(guid));
#else
unit->SetCharmerGuid(ObjectGuid(guid));
#endif
return 0;
}
@@ -1745,10 +1760,10 @@ namespace LuaUnit
int SetPetGUID(lua_State* L, Unit* unit)
{
uint64 guid = Eluna::CHECKVAL<uint64>(L, 2);
#ifndef TRINITY
unit->SetPetGuid(ObjectGuid(guid));
#else
#if defined TRINITY || AZEROTHCORE
unit->SetPetGUID(ObjectGuid(guid));
#else
unit->SetPetGuid(ObjectGuid(guid));
#endif
return 0;
}
@@ -1761,10 +1776,10 @@ namespace LuaUnit
int SetWaterWalk(lua_State* L, Unit* unit)
{
bool enable = Eluna::CHECKVAL<bool>(L, 2, true);
#ifndef TRINITY
unit->SetWaterWalk(enable);
#else
#if defined TRINITY || AZEROTHCORE
unit->SetWaterWalking(enable);
#else
unit->SetWaterWalk(enable);
#endif
return 0;
}
@@ -1791,9 +1806,7 @@ namespace LuaUnit
{
bool apply = Eluna::CHECKVAL<bool>(L, 2, true);
#ifndef TRINITY
unit->SetFFAPvP(apply);
#else
#ifdef TRINITY
if (apply)
{
unit->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
@@ -1806,6 +1819,21 @@ namespace LuaUnit
for (Unit::ControlList::iterator itr = unit->m_Controlled.begin(); itr != unit->m_Controlled.end(); ++itr)
(*itr)->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
}
#elif AZEROTHCORE
if (apply)
{
unit->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
for (Unit::ControlSet::iterator itr = unit->m_Controlled.begin(); itr != unit->m_Controlled.end(); ++itr)
(*itr)->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
}
else
{
unit->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
for (Unit::ControlSet::iterator itr = unit->m_Controlled.begin(); itr != unit->m_Controlled.end(); ++itr)
(*itr)->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
}
#else
unit->SetFFAPvP(apply);
#endif
return 0;
}
@@ -1834,10 +1862,10 @@ namespace LuaUnit
int SetCritterGUID(lua_State* L, Unit* unit)
{
uint64 guid = Eluna::CHECKVAL<uint64>(L, 2);
#ifndef TRINITY
unit->SetCritterGuid(ObjectGuid(guid));
#else
#if defined TRINITY || AZEROTHCORE
unit->SetCritterGUID(ObjectGuid(guid));
#else
unit->SetCritterGuid(ObjectGuid(guid));
#endif
return 0;
}
@@ -1858,10 +1886,10 @@ namespace LuaUnit
int SetRooted(lua_State* L, Unit* unit)
{
bool apply = Eluna::CHECKVAL<bool>(L, 2, true);
#ifndef TRINITY
unit->SetRoot(apply);
#else
#if defined TRINITY || AZEROTHCORE
unit->SetControlled(apply, UNIT_STATE_ROOT);
#else
unit->SetRoot(apply);
#endif
return 0;
}
@@ -1874,10 +1902,10 @@ namespace LuaUnit
int SetConfused(lua_State* L, Unit* unit)
{
bool apply = Eluna::CHECKVAL<bool>(L, 2, true);
#ifndef TRINITY
unit->SetConfused(apply);
#else
#if defined TRINITY || AZEROTHCORE
unit->SetControlled(apply, UNIT_STATE_CONFUSED);
#else
unit->SetConfused(apply);
#endif
return 0;
}
@@ -1890,10 +1918,10 @@ namespace LuaUnit
int SetFeared(lua_State* L, Unit* unit)
{
bool apply = Eluna::CHECKVAL<bool>(L, 2, true);
#ifndef TRINITY
unit->SetFeared(apply);
#else
#if defined TRINITY || AZEROTHCORE
unit->SetControlled(apply, UNIT_STATE_FLEEING);
#else
unit->SetFeared(apply);
#endif
return 0;
}
@@ -1919,6 +1947,8 @@ namespace LuaUnit
{
#ifdef TRINITY
unit->GetThreatManager().ClearAllThreat();
#elif AZEROTHCORE
unit->getThreatManager().clearReferences();
#else
unit->GetThreatManager().clearReferences();
#endif
@@ -1945,12 +1975,12 @@ namespace LuaUnit
{
if (unit->IsMounted())
{
#ifndef TRINITY
unit->Unmount();
unit->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
#else
#if defined TRINITY || AZEROTHCORE
unit->Dismount();
unit->RemoveAurasByType(SPELL_AURA_MOUNTED);
#else
unit->Unmount();
unit->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
#endif
}
@@ -2024,7 +2054,7 @@ namespace LuaUnit
return luaL_argerror(L, 3, "valid Language expected");
WorldPacket data;
#ifdef TRINITY
#if defined TRINITY || AZEROTHCORE
ChatHandler::BuildChatPacket(data, ChatMsg(type), Language(lang), unit, target, msg);
#else
ChatHandler::BuildChatPacket(data, ChatMsg(type), msg.c_str(), Language(lang), 0, unit->GET_GUID(), unit->GetName(), target->GET_GUID(), target->GetName());
@@ -2104,10 +2134,10 @@ namespace LuaUnit
float radius = Eluna::CHECKVAL<float>(L, 2);
float x, y, z;
unit->GetPosition(x, y, z);
#ifndef TRINITY
unit->GetMotionMaster()->MoveRandomAroundPoint(x, y, z, radius);
#else
#if defined TRINITY || AZEROTHCORE
unit->GetMotionMaster()->MoveRandom(radius);
#else
unit->GetMotionMaster()->MoveRandomAroundPoint(x, y, z, radius);
#endif
return 0;
}
@@ -2335,7 +2365,7 @@ namespace LuaUnit
#ifdef MANGOS
SpellEntry const* spellEntry = sSpellStore.LookupEntry(spell);
#endif
#ifdef TRINITY
#if defined TRINITY || AZEROTHCORE
SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spell);
#endif
if (!spellEntry)
@@ -2419,6 +2449,9 @@ namespace LuaUnit
#ifdef MANGOS
unit->CastSpell(_x, _y, _z, spell, triggered);
#endif
#ifdef AZEROTHCORE
unit->CastSpell(_x, _y, _z, spell, triggered);
#endif
#ifdef TRINITY
CastSpellExtraArgs args;
if (triggered)
@@ -2502,11 +2535,16 @@ namespace LuaUnit
#endif
#ifdef TRINITY
SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spell);
#endif
#ifdef AZEROTHCORE
SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spell);
#endif
if (!spellEntry)
return 1;
#ifndef TRINITY
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, unit->AddAura(spell, target));
#else
if (!IsSpellAppliesAura(spellEntry) && !IsSpellHaveEffect(spellEntry, SPELL_EFFECT_PERSISTENT_AREA_AURA))
return 1;
@@ -2526,8 +2564,6 @@ namespace LuaUnit
}
}
Eluna::Push(L, target->AddSpellAuraHolder(holder));
#else
Eluna::Push(L, unit->AddAura(spell, target));
#endif
return 1;
}
@@ -2564,10 +2600,10 @@ namespace LuaUnit
{
uint32 state = Eluna::CHECKVAL<uint32>(L, 2);
#ifndef TRINITY
unit->addUnitState(state);
#else
#if defined TRINITY || AZEROTHCORE
unit->AddUnitState(state);
#else
unit->addUnitState(state);
#endif
return 0;
}
@@ -2581,10 +2617,10 @@ namespace LuaUnit
{
uint32 state = Eluna::CHECKVAL<uint32>(L, 2);
#ifndef TRINITY
unit->clearUnitState(state);
#else
#if defined TRINITY || AZEROTHCORE
unit->ClearUnitState(state);
#else
unit->clearUnitState(state);
#endif
return 0;
}
@@ -2644,7 +2680,7 @@ namespace LuaUnit
// flat melee damage without resistence/etc reduction
if (school == MAX_SPELL_SCHOOL)
{
#ifdef TRINITY
#if defined TRINITY || AZEROTHCORE
Unit::DealDamage(unit, target, damage, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, durabilityloss);
unit->SendAttackStateUpdate(HITINFO_AFFECTS_VICTIM, target, 1, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_HIT, 0);
#else
@@ -2656,7 +2692,7 @@ namespace LuaUnit
SpellSchoolMask schoolmask = SpellSchoolMask(1 << school);
#ifdef TRINITY
#if defined TRINITY || AZEROTHCORE
if (Unit::IsDamageReducedByArmor(schoolmask))
damage = Unit::CalcArmorReducedDamage(unit, target, damage, NULL, BASE_ATTACK);
#else
@@ -2705,6 +2741,35 @@ namespace LuaUnit
unit->DealDamageMods(dmgInfo.target, dmgInfo.damage, &dmgInfo.absorb);
#endif
unit->SendSpellNonMeleeDamageLog(&dmgInfo);
unit->DealSpellDamage(&dmgInfo, true);
return 0;
#elif AZEROTHCORE
if (!spell)
{
uint32 absorb = 0;
uint32 resist = 0;
unit->CalcAbsorbResist(unit, target, schoolmask, SPELL_DIRECT_DAMAGE, damage, &absorb, &resist);
if (damage <= absorb + resist)
damage = 0;
else
damage -= absorb + resist;
unit->DealDamageMods(target, damage, &absorb);
Unit::DealDamage(unit, target, damage, NULL, DIRECT_DAMAGE, schoolmask, NULL, false);
unit->SendAttackStateUpdate(HITINFO_AFFECTS_VICTIM, target, 0, schoolmask, damage, absorb, resist, VICTIMSTATE_HIT, 0);
return 0;
}
if (!spell)
return 0;
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell);
if (!spellInfo)
return 0;
SpellNonMeleeDamage dmgInfo(unit, target, spell, spellInfo->GetSchoolMask());
Unit::DealDamageMods(dmgInfo.target, dmgInfo.damage, &dmgInfo.absorb);
unit->SendSpellNonMeleeDamageLog(&dmgInfo);
unit->DealSpellDamage(&dmgInfo, true);
return 0;
@@ -2748,7 +2813,18 @@ namespace LuaUnit
uint32 amount = Eluna::CHECKVAL<uint32>(L, 4);
bool critical = Eluna::CHECKVAL<bool>(L, 5, false);
#ifndef TRINITY
#ifdef TRINITY
if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell))
{
HealInfo healInfo(unit, target, amount, info, info->GetSchoolMask());
unit->HealBySpell(healInfo, critical);
}
#elif AZEROTHCORE
if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell))
{
unit->HealBySpell(target, info, amount, critical);
}
#else
#ifdef CMANGOS
SpellEntry const* spellEntry = GetSpellStore()->LookupEntry<SpellEntry>(spell);
#else
@@ -2756,12 +2832,6 @@ namespace LuaUnit
#endif
if (spellEntry)
unit->DealHeal(target, amount, spellEntry, critical);
#else
if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell))
{
HealInfo healInfo(unit, target, amount, info, info->GetSchoolMask());
unit->HealBySpell(healInfo, critical);
}
#endif
return 0;
}
@@ -2777,10 +2847,10 @@ namespace LuaUnit
Unit* target = Eluna::CHECKOBJ<Unit>(L, 2);
bool durLoss = Eluna::CHECKVAL<bool>(L, 3, true);
#ifndef TRINITY
unit->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, durLoss);
#else
#if defined TRINITY || AZEROTHCORE
Unit::Kill(unit, target, durLoss);
#else
unit->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, durLoss);
#endif
return 0;
}
@@ -2815,6 +2885,13 @@ namespace LuaUnit
#ifdef TRINITY
unit->GetThreatManager().AddThreat(victim, threat, spell ? sSpellMgr->GetSpellInfo(spell) : NULL, true, true);
#elif AZEROTHCORE
uint32 schoolMask = Eluna::CHECKVAL<uint32>(L, 5, 0);
if (schoolMask > SPELL_SCHOOL_MASK_ALL)
{
return luaL_argerror(L, 4, "valid SpellSchoolMask expected");
}
unit->AddThreat(victim, threat, (SpellSchoolMask)schoolMask, spell ? sSpellMgr->GetSpellInfo(spell) : NULL);
#else
#ifdef CMANGOS
SpellEntry const* spellEntry = GetSpellStore()->LookupEntry<SpellEntry>(spell);