diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index 1324997..2a295f0 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -366,6 +366,7 @@ ElunaRegister UnitMethods[] = { "IsRooted", &LuaUnit::IsRooted }, // :IsRooted() { "IsFullHealth", &LuaUnit::IsFullHealth }, // :IsFullHealth() - Returns if the unit is full health { "HasAura", &LuaUnit::HasAura }, // :HasAura(spellId) - Returns true if the unit has the aura from the spell + { "IsCasting", &LuaUnit::IsCasting }, { "IsStandState", &LuaUnit::IsStandState }, // :IsStandState() - Returns true if the unit is standing #ifndef CLASSIC { "IsOnVehicle", &LuaUnit::IsOnVehicle }, // :IsOnVehicle() - Checks if the unit is on a vehicle diff --git a/UnitMethods.h b/UnitMethods.h index 674d565..44eb03b 100644 --- a/UnitMethods.h +++ b/UnitMethods.h @@ -539,7 +539,22 @@ namespace LuaUnit Eluna::Push(L, unit->HasAura(spell)); return 1; } - + + /** + * Returns true if the [Unit] is casting a spell + * + * @return bool isCasting + */ + int IsCasting(Eluna* /*E*/, lua_State* L, Unit* unit) + { +#ifndef TRINITY + Eluna::Push(L, unit->hasUnitState(UNIT_STATE_CASTING)); +#else + Eluna::Push(L, unit->HasUnitState(UNIT_STATE_CASTING)); +#endif + return 1; + } + /** * Returns true if the [Unit] has the given unit state. * @@ -2072,7 +2087,7 @@ namespace LuaUnit #endif return 0; } - + /** * Unmorphs the [Unit] setting it's display ID back to the native display ID. */ @@ -2081,17 +2096,17 @@ namespace LuaUnit unit->DeMorph(); return 0; } - + /** * Makes the [Unit] cast the spell on the target. * - * @param [Unit] target : can be self or another unit + * @param [Unit] target = nil : can be self or another unit * @param uint32 spell : entry of a spell * @param bool triggered = false : if true the spell is instant and has no cost */ int CastSpell(Eluna* /*E*/, lua_State* L, Unit* unit) { - Unit* target = Eluna::CHECKOBJ(L, 2); + Unit* target = Eluna::CHECKOBJ(L, 2, NULL); uint32 spell = Eluna::CHECKVAL(L, 3); bool triggered = Eluna::CHECKVAL(L, 4, false); SpellEntry const* spellEntry = sSpellStore.LookupEntry(spell); @@ -2106,7 +2121,7 @@ namespace LuaUnit * Casts the [Spell] at target [Unit] with custom basepoints or casters. * See also [Unit:CastSpell]. * - * @param [Unit] target + * @param [Unit] target = nil * @param uint32 spell * @param bool triggered = false * @param int32 bp0 = nil : custom basepoints for [Spell] effect 1. If nil, no change is made @@ -2117,7 +2132,7 @@ namespace LuaUnit */ int CastCustomSpell(Eluna* /*E*/, lua_State* L, Unit* unit) { - Unit* target = Eluna::CHECKOBJ(L, 2); + Unit* target = Eluna::CHECKOBJ(L, 2, NULL); uint32 spell = Eluna::CHECKVAL(L, 3); bool triggered = Eluna::CHECKVAL(L, 4, false); bool has_bp0 = !lua_isnoneornil(L, 5);