mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Enable null as CastSpell target and Add IsCasting
Closes https://github.com/ElunaLuaEngine/Eluna/issues/160
This commit is contained in:
@@ -366,6 +366,7 @@ ElunaRegister<Unit> UnitMethods[] =
|
|||||||
{ "IsRooted", &LuaUnit::IsRooted }, // :IsRooted()
|
{ "IsRooted", &LuaUnit::IsRooted }, // :IsRooted()
|
||||||
{ "IsFullHealth", &LuaUnit::IsFullHealth }, // :IsFullHealth() - Returns if the unit is full health
|
{ "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
|
{ "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
|
{ "IsStandState", &LuaUnit::IsStandState }, // :IsStandState() - Returns true if the unit is standing
|
||||||
#ifndef CLASSIC
|
#ifndef CLASSIC
|
||||||
{ "IsOnVehicle", &LuaUnit::IsOnVehicle }, // :IsOnVehicle() - Checks if the unit is on a vehicle
|
{ "IsOnVehicle", &LuaUnit::IsOnVehicle }, // :IsOnVehicle() - Checks if the unit is on a vehicle
|
||||||
|
|||||||
@@ -540,6 +540,21 @@ namespace LuaUnit
|
|||||||
return 1;
|
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.
|
* Returns true if the [Unit] has the given unit state.
|
||||||
*
|
*
|
||||||
@@ -2085,13 +2100,13 @@ namespace LuaUnit
|
|||||||
/**
|
/**
|
||||||
* Makes the [Unit] cast the spell on the target.
|
* 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 uint32 spell : entry of a spell
|
||||||
* @param bool triggered = false : if true the spell is instant and has no cost
|
* @param bool triggered = false : if true the spell is instant and has no cost
|
||||||
*/
|
*/
|
||||||
int CastSpell(Eluna* /*E*/, lua_State* L, Unit* unit)
|
int CastSpell(Eluna* /*E*/, lua_State* L, Unit* unit)
|
||||||
{
|
{
|
||||||
Unit* target = Eluna::CHECKOBJ<Unit>(L, 2);
|
Unit* target = Eluna::CHECKOBJ<Unit>(L, 2, NULL);
|
||||||
uint32 spell = Eluna::CHECKVAL<uint32>(L, 3);
|
uint32 spell = Eluna::CHECKVAL<uint32>(L, 3);
|
||||||
bool triggered = Eluna::CHECKVAL<bool>(L, 4, false);
|
bool triggered = Eluna::CHECKVAL<bool>(L, 4, false);
|
||||||
SpellEntry const* spellEntry = sSpellStore.LookupEntry(spell);
|
SpellEntry const* spellEntry = sSpellStore.LookupEntry(spell);
|
||||||
@@ -2106,7 +2121,7 @@ namespace LuaUnit
|
|||||||
* Casts the [Spell] at target [Unit] with custom basepoints or casters.
|
* Casts the [Spell] at target [Unit] with custom basepoints or casters.
|
||||||
* See also [Unit:CastSpell].
|
* See also [Unit:CastSpell].
|
||||||
*
|
*
|
||||||
* @param [Unit] target
|
* @param [Unit] target = nil
|
||||||
* @param uint32 spell
|
* @param uint32 spell
|
||||||
* @param bool triggered = false
|
* @param bool triggered = false
|
||||||
* @param int32 bp0 = nil : custom basepoints for [Spell] effect 1. If nil, no change is made
|
* @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)
|
int CastCustomSpell(Eluna* /*E*/, lua_State* L, Unit* unit)
|
||||||
{
|
{
|
||||||
Unit* target = Eluna::CHECKOBJ<Unit>(L, 2);
|
Unit* target = Eluna::CHECKOBJ<Unit>(L, 2, NULL);
|
||||||
uint32 spell = Eluna::CHECKVAL<uint32>(L, 3);
|
uint32 spell = Eluna::CHECKVAL<uint32>(L, 3);
|
||||||
bool triggered = Eluna::CHECKVAL<bool>(L, 4, false);
|
bool triggered = Eluna::CHECKVAL<bool>(L, 4, false);
|
||||||
bool has_bp0 = !lua_isnoneornil(L, 5);
|
bool has_bp0 = !lua_isnoneornil(L, 5);
|
||||||
|
|||||||
Reference in New Issue
Block a user