This commit is contained in:
Axel Cocat
2021-10-06 10:21:28 +02:00
2 changed files with 60 additions and 65 deletions

View File

@@ -2522,49 +2522,47 @@ namespace LuaPlayer
} }
/** /**
* Repairs [Item] at specified position. Returns total repair cost * Repairs [Item] at specified position.
* *
* @param uint16 position * @param uint16 position
* @param bool cost = true * @param bool cost = true
* @param float discountMod * @param float discountMod = 1.0
* @param bool guildBank = false
* @return uint32 totalCost
*/ */
int DurabilityRepair(lua_State* L, Player* player) int DurabilityRepair(lua_State* L, Player* player)
{ {
uint16 position = Eluna::CHECKVAL<uint16>(L, 2); uint16 position = Eluna::CHECKVAL<uint16>(L, 2);
bool cost = Eluna::CHECKVAL<bool>(L, 3, true); bool takeCost = Eluna::CHECKVAL<bool>(L, 3, true);
float discountMod = Eluna::CHECKVAL<float>(L, 4); float discountMod = Eluna::CHECKVAL<float>(L, 4, 1.0f);
bool guildBank = Eluna::CHECKVAL<bool>(L, 5, false);
#ifdef CLASSIC #ifdef CLASSIC
Eluna::Push(L, player->DurabilityRepair(position, cost, discountMod)); player->DurabilityRepair(position, takeCost, discountMod);
#elif defined(TRINITY)
player->DurabilityRepair(position, takeCost, discountMod);
#else #else
Eluna::Push(L, player->DurabilityRepair(position, cost, discountMod, guildBank)); player->DurabilityRepair(position, takeCost, discountMod, false);
#endif #endif
return 1; return 0;
} }
/** /**
* Repairs all [Item]s. Returns total repair cost * Repairs all [Item]s.
* *
* @param bool cost = true * @param bool takeCost = true
* @param float discountMod = 1 * @param float discountMod = 1.0
* @param bool guidBank = false * @param bool guidBank = false
* @return uint32 totalCost
*/ */
int DurabilityRepairAll(lua_State* L, Player* player) int DurabilityRepairAll(lua_State* L, Player* player)
{ {
bool cost = Eluna::CHECKVAL<bool>(L, 2, true); bool takeCost = Eluna::CHECKVAL<bool>(L, 2, true);
float discountMod = Eluna::CHECKVAL<float>(L, 3, 1.0f); float discountMod = Eluna::CHECKVAL<float>(L, 3, 1.0f);
bool guildBank = Eluna::CHECKVAL<bool>(L, 4, false); bool guildBank = Eluna::CHECKVAL<bool>(L, 4, false);
#ifdef CLASSIC #ifdef CLASSIC
Eluna::Push(L, player->DurabilityRepairAll(cost, discountMod)); player->DurabilityRepairAll(takeCost, discountMod);
#else #else
Eluna::Push(L, player->DurabilityRepairAll(cost, discountMod, guildBank)); player->DurabilityRepairAll(takeCost, discountMod, guildBank);
#endif #endif
return 1; return 0;
} }
/** /**

View File

@@ -2824,14 +2824,16 @@ namespace LuaUnit
#elif AZEROTHCORE #elif AZEROTHCORE
if (!spell) if (!spell)
{ {
uint32 absorb = 0; DamageInfo dmgInfo(unit, target, damage, nullptr, schoolmask, SPELL_DIRECT_DAMAGE);
uint32 resist = 0; unit->CalcAbsorbResist(dmgInfo);
unit->CalcAbsorbResist(unit, target, schoolmask, SPELL_DIRECT_DAMAGE, damage, &absorb, &resist);
if (damage <= absorb + resist) if (!dmgInfo.GetDamage())
damage = 0; damage = 0;
else else
damage -= absorb + resist; damage = dmgInfo.GetDamage();
uint32 absorb = dmgInfo.GetAbsorb();
uint32 resist = dmgInfo.GetResist();
unit->DealDamageMods(target, damage, &absorb); unit->DealDamageMods(target, damage, &absorb);
Unit::DealDamage(unit, target, damage, NULL, DIRECT_DAMAGE, schoolmask, NULL, false); 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); unit->SendAttackStateUpdate(HITINFO_AFFECTS_VICTIM, target, 0, schoolmask, damage, absorb, resist, VICTIMSTATE_HIT, 0);
@@ -2845,7 +2847,7 @@ namespace LuaUnit
if (!spellInfo) if (!spellInfo)
return 0; return 0;
SpellNonMeleeDamage dmgInfo(unit, target, spell, spellInfo->GetSchoolMask()); SpellNonMeleeDamage dmgInfo(unit, target, spellInfo, spellInfo->GetSchoolMask());
Unit::DealDamageMods(dmgInfo.target, dmgInfo.damage, &dmgInfo.absorb); Unit::DealDamageMods(dmgInfo.target, dmgInfo.damage, &dmgInfo.absorb);
unit->SendSpellNonMeleeDamageLog(&dmgInfo); unit->SendSpellNonMeleeDamageLog(&dmgInfo);
unit->DealSpellDamage(&dmgInfo, true); unit->DealSpellDamage(&dmgInfo, true);
@@ -2890,17 +2892,12 @@ namespace LuaUnit
uint32 amount = Eluna::CHECKVAL<uint32>(L, 4); uint32 amount = Eluna::CHECKVAL<uint32>(L, 4);
bool critical = Eluna::CHECKVAL<bool>(L, 5, false); bool critical = Eluna::CHECKVAL<bool>(L, 5, false);
#ifdef TRINITY #if defined TRINITY || AZEROTHCORE
if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell)) if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell))
{ {
HealInfo healInfo(unit, target, amount, info, info->GetSchoolMask()); HealInfo healInfo(unit, target, amount, info, info->GetSchoolMask());
unit->HealBySpell(healInfo, critical); unit->HealBySpell(healInfo, critical);
} }
#elif AZEROTHCORE
if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell))
{
unit->HealBySpell(target, info, amount, critical);
}
#else #else
#ifdef CMANGOS #ifdef CMANGOS
SpellEntry const* spellEntry = GetSpellStore()->LookupEntry<SpellEntry>(spell); SpellEntry const* spellEntry = GetSpellStore()->LookupEntry<SpellEntry>(spell);