diff --git a/CreatureMethods.h b/CreatureMethods.h index 901f8d3..a8d796d 100644 --- a/CreatureMethods.h +++ b/CreatureMethods.h @@ -14,6 +14,24 @@ */ namespace LuaCreature { + /** + * Returns `true` if the [Creature] can regenerate health, + * and returns `false` otherwise. + * + * @return bool isRegenerating + */ + int IsRegeneratingHealth(lua_State* L, Creature* creature) + { +#if defined(AZEROTHCORE) + Eluna::Push(L, creature->isRegeneratingHealth()); +#elif defined(TRINITY) + Eluna::Push(L, creature->CanRegenerateHealth()); +#else + Eluna::Push(L, creature->IsRegeneratingHealth()); +#endif + return 1; + } + /** * Sets whether the [Creature] can regenerate health or not. * @@ -37,7 +55,7 @@ namespace LuaCreature * * @return bool reputationDisabled */ - int IsReputationGainDisabled(lua_State *L, Creature *creature) + int IsReputationGainDisabled(lua_State* L, Creature* creature) { Eluna::Push(L, creature->IsReputationGainDisabled()); return 1; @@ -50,7 +68,7 @@ namespace LuaCreature * @param uint32 questID : the ID of a [Quest] * @return bool completesQuest */ - int CanCompleteQuest(lua_State *L, Creature *creature) + int CanCompleteQuest(lua_State* L, Creature* creature) { uint32 quest_id = Eluna::CHECKVAL(L, 2); @@ -69,7 +87,7 @@ namespace LuaCreature * @param bool mustBeDead = false : if `true`, only returns `true` if the [Creature] is also dead. Otherwise, it must be alive. * @return bool targetable */ - int IsTargetableForAttack(lua_State *L, Creature *creature) + int IsTargetableForAttack(lua_State* L, Creature* creature) { bool mustBeDead = Eluna::CHECKVAL(L, 2, false); @@ -90,10 +108,10 @@ namespace LuaCreature * @param bool checkFaction = true : if `true`, the [Creature] must be the same faction as `friend` to assist * @return bool canAssist */ - int CanAssistTo(lua_State *L, Creature *creature) + int CanAssistTo(lua_State* L, Creature* creature) { - Unit *u = Eluna::CHECKOBJ(L, 2); - Unit *enemy = Eluna::CHECKOBJ(L, 3); + Unit* u = Eluna::CHECKOBJ(L, 2); + Unit* enemy = Eluna::CHECKOBJ(L, 3); bool checkfaction = Eluna::CHECKVAL(L, 4, true); Eluna::Push(L, creature->CanAssistTo(u, enemy, checkfaction)); @@ -106,7 +124,7 @@ namespace LuaCreature * * @return bool searchedForAssistance */ - int HasSearchedAssistance(lua_State *L, Creature *creature) + int HasSearchedAssistance(lua_State* L, Creature* creature) { Eluna::Push(L, creature->HasSearchedAssistance()); return 1; @@ -118,9 +136,9 @@ namespace LuaCreature * * @return bool tapped */ - int IsTappedBy(lua_State *L, Creature *creature) + int IsTappedBy(lua_State* L, Creature* creature) { - Player *player = Eluna::CHECKOBJ(L, 2); + Player* player = Eluna::CHECKOBJ(L, 2); #if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->isTappedBy(player)); @@ -136,7 +154,7 @@ namespace LuaCreature * * @return bool hasLootRecipient */ - int HasLootRecipient(lua_State *L, Creature *creature) + int HasLootRecipient(lua_State* L, Creature* creature) { #if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->hasLootRecipient()); @@ -152,7 +170,7 @@ namespace LuaCreature * * @return bool canAggro */ - int CanAggro(lua_State *L, Creature *creature) + int CanAggro(lua_State* L, Creature* creature) { #if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, !creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC)); @@ -169,7 +187,7 @@ namespace LuaCreature * * @return bool canSwim */ - int CanSwim(lua_State *L, Creature *creature) + int CanSwim(lua_State* L, Creature* creature) { Eluna::Push(L, creature->CanSwim()); return 1; @@ -181,7 +199,7 @@ namespace LuaCreature * * @return bool canWalk */ - int CanWalk(lua_State *L, Creature *creature) + int CanWalk(lua_State* L, Creature* creature) { Eluna::Push(L, creature->CanWalk()); return 1; @@ -193,7 +211,7 @@ namespace LuaCreature * * @return bool inEvadeMode */ - int IsInEvadeMode(lua_State *L, Creature *creature) + int IsInEvadeMode(lua_State* L, Creature* creature) { Eluna::Push(L, creature->IsInEvadeMode()); return 1; @@ -205,7 +223,7 @@ namespace LuaCreature * * @return bool isElite */ - int IsElite(lua_State *L, Creature *creature) + int IsElite(lua_State* L, Creature* creature) { #if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->isElite()); @@ -221,7 +239,7 @@ namespace LuaCreature * * @return bool isGuard */ - int IsGuard(lua_State *L, Creature *creature) + int IsGuard(lua_State* L, Creature* creature) { Eluna::Push(L, creature->IsGuard()); return 1; @@ -233,7 +251,7 @@ namespace LuaCreature * * @return bool isCivilian */ - int IsCivilian(lua_State *L, Creature *creature) + int IsCivilian(lua_State* L, Creature* creature) { Eluna::Push(L, creature->IsCivilian()); return 1; @@ -245,7 +263,7 @@ namespace LuaCreature * * @return bool isLeader */ - int IsRacialLeader(lua_State *L, Creature *creature) + int IsRacialLeader(lua_State* L, Creature* creature) { Eluna::Push(L, creature->IsRacialLeader()); return 1; @@ -258,7 +276,7 @@ namespace LuaCreature * @return bool isDungeonBoss */ #if defined(TRINITY) || defined(AZEROTHCORE) - int IsDungeonBoss(lua_State *L, Creature *creature) + int IsDungeonBoss(lua_State* L, Creature* creature) { Eluna::Push(L, creature->IsDungeonBoss()); return 1; @@ -271,7 +289,7 @@ namespace LuaCreature * * @return bool isWorldBoss */ - int IsWorldBoss(lua_State *L, Creature *creature) + int IsWorldBoss(lua_State* L, Creature* creature) { #if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->isWorldBoss()); @@ -288,17 +306,17 @@ namespace LuaCreature * @param uint32 spellId : the ID of a [Spell] * @return bool hasCooldown */ - int HasCategoryCooldown(lua_State *L, Creature *creature) + int HasCategoryCooldown(lua_State* L, Creature* creature) { uint32 spell = Eluna::CHECKVAL(L, 2); #if defined(TRINITY) - if (const SpellInfo *info = sSpellMgr->GetSpellInfo(spell)) + if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell)) Eluna::Push(L, info->GetCategory() && creature->GetSpellHistory()->HasCooldown(spell)); else Eluna::Push(L, false); #elif defined(AZEROTHCORE) - if (const SpellInfo *info = sSpellMgr->GetSpellInfo(spell)) + if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell)) Eluna::Push(L, info->GetCategory() && creature->HasSpellCooldown(spell)); else Eluna::Push(L, false); @@ -315,7 +333,7 @@ namespace LuaCreature * @param uint32 spellId : the ID of a [Spell] * @return bool hasSpell */ - int HasSpell(lua_State *L, Creature *creature) + int HasSpell(lua_State* L, Creature* creature) { uint32 id = Eluna::CHECKVAL(L, 2); @@ -330,7 +348,7 @@ namespace LuaCreature * @param uint32 questId : the ID of a [Quest] * @return bool hasQuest */ - int HasQuest(lua_State *L, Creature *creature) + int HasQuest(lua_State* L, Creature* creature) { uint32 questId = Eluna::CHECKVAL(L, 2); @@ -349,7 +367,7 @@ namespace LuaCreature * @param uint32 spellId : the ID of a [Spell] * @return bool hasCooldown */ - int HasSpellCooldown(lua_State *L, Creature *creature) + int HasSpellCooldown(lua_State* L, Creature* creature) { uint32 spellId = Eluna::CHECKVAL(L, 2); @@ -367,7 +385,7 @@ namespace LuaCreature * * @return bool canFly */ - int CanFly(lua_State *L, Creature *creature) + int CanFly(lua_State* L, Creature* creature) { Eluna::Push(L, creature->CanFly()); return 1; @@ -380,7 +398,7 @@ namespace LuaCreature * * @return bool canFly */ - int IsTrigger(lua_State *L, Creature *creature) + int IsTrigger(lua_State* L, Creature* creature) { Eluna::Push(L, creature->IsTrigger()); return 1; @@ -391,7 +409,7 @@ namespace LuaCreature * * @return bool isDamagedEnough */ - int IsDamageEnoughForLootingAndReward(lua_State *L, Creature *creature) + int IsDamageEnoughForLootingAndReward(lua_State* L, Creature* creature) { Eluna::Push(L, creature->IsDamageEnoughForLootingAndReward()); return 1; @@ -405,9 +423,9 @@ namespace LuaCreature * @param [Unit] target * @param bool force = true : force [Creature] to attack */ - int CanStartAttack(lua_State *L, Creature *creature) // TODO: Implement core side + int CanStartAttack(lua_State* L, Creature* creature) // TODO: Implement core side { - Unit *target = Eluna::CHECKOBJ(L, 2); + Unit* target = Eluna::CHECKOBJ(L, 2); #ifndef AZEROTHCORE bool force = Eluna::CHECKVAL(L, 3, true); Eluna::Push(L, creature->CanStartAttack(target, force)); @@ -423,7 +441,7 @@ namespace LuaCreature * @param uint16 lootMode * @return bool hasLootMode */ - int HasLootMode(lua_State *L, Creature *creature) // TODO: Implement LootMode features + int HasLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features { uint16 lootMode = Eluna::CHECKVAL(L, 2); @@ -440,7 +458,7 @@ namespace LuaCreature * * @return uint32 respawnDelay : the respawn delay, in seconds */ - int GetRespawnDelay(lua_State *L, Creature *creature) + int GetRespawnDelay(lua_State* L, Creature* creature) { Eluna::Push(L, creature->GetRespawnDelay()); return 1; @@ -452,7 +470,7 @@ namespace LuaCreature * * @return float wanderRadius */ - int GetWanderRadius(lua_State *L, Creature *creature) + int GetWanderRadius(lua_State* L, Creature* creature) { #if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->GetWanderDistance()); @@ -468,7 +486,7 @@ namespace LuaCreature * * @return uint32 pathId */ - int GetWaypointPath(lua_State *L, Creature *creature) + int GetWaypointPath(lua_State* L, Creature* creature) { Eluna::Push(L, creature->GetWaypointPath()); return 1; @@ -480,7 +498,7 @@ namespace LuaCreature * * @return uint32 wpId */ - int GetCurrentWaypointId(lua_State *L, Creature *creature) + int GetCurrentWaypointId(lua_State* L, Creature* creature) { #if defined(TRINITY) Eluna::Push(L, creature->GetCurrentWaypointInfo().first); @@ -497,7 +515,7 @@ namespace LuaCreature * * @return [MovementGeneratorType] defaultMovementType */ - int GetDefaultMovementType(lua_State *L, Creature *creature) + int GetDefaultMovementType(lua_State* L, Creature* creature) { Eluna::Push(L, creature->GetDefaultMovementType()); return 1; @@ -509,9 +527,9 @@ namespace LuaCreature * @param [Unit] target * @return float aggroRange */ - int GetAggroRange(lua_State *L, Creature *creature) + int GetAggroRange(lua_State* L, Creature* creature) { - Unit *target = Eluna::CHECKOBJ(L, 2); + Unit* target = Eluna::CHECKOBJ(L, 2); #if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->GetAggroRange(target)); @@ -533,9 +551,9 @@ namespace LuaCreature * @param [Unit] target * @return float attackDistance */ - int GetAttackDistance(lua_State *L, Creature *creature) + int GetAttackDistance(lua_State* L, Creature* creature) { - Unit *target = Eluna::CHECKOBJ(L, 2); + Unit* target = Eluna::CHECKOBJ(L, 2); Eluna::Push(L, creature->GetAttackDistance(target)); return 1; @@ -547,7 +565,7 @@ namespace LuaCreature * * @return [Group] lootRecipientGroup : the group or `nil` */ - int GetLootRecipientGroup(lua_State *L, Creature *creature) + int GetLootRecipientGroup(lua_State* L, Creature* creature) { #if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->GetLootRecipientGroup()); @@ -562,7 +580,7 @@ namespace LuaCreature * * @return [Player] lootRecipient : the player or `nil` */ - int GetLootRecipient(lua_State *L, Creature *creature) + int GetLootRecipient(lua_State* L, Creature* creature) { Eluna::Push(L, creature->GetLootRecipient()); return 1; @@ -577,7 +595,7 @@ namespace LuaCreature * * @return string scriptName */ - int GetScriptName(lua_State *L, Creature *creature) + int GetScriptName(lua_State* L, Creature* creature) { Eluna::Push(L, creature->GetScriptName()); return 1; @@ -592,7 +610,7 @@ namespace LuaCreature * * @return string AIName */ - int GetAIName(lua_State *L, Creature *creature) + int GetAIName(lua_State* L, Creature* creature) { Eluna::Push(L, creature->GetAIName()); return 1; @@ -606,7 +624,7 @@ namespace LuaCreature * * @return uint32 scriptID */ - int GetScriptId(lua_State *L, Creature *creature) + int GetScriptId(lua_State* L, Creature* creature) { Eluna::Push(L, creature->GetScriptId()); return 1; @@ -618,12 +636,12 @@ namespace LuaCreature * @param uint32 spellID * @return uint32 cooldown : the cooldown, in milliseconds */ - int GetCreatureSpellCooldownDelay(lua_State *L, Creature *creature) + int GetCreatureSpellCooldownDelay(lua_State* L, Creature* creature) { uint32 spell = Eluna::CHECKVAL(L, 2); #if defined(TRINITY) - if (SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(spell)) + if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell)) Eluna::Push(L, creature->GetSpellHistory()->GetRemainingCooldown(spellInfo)); else Eluna::Push(L, 0); @@ -643,7 +661,7 @@ namespace LuaCreature * * @return uint32 corpseDelay : the delay, in seconds */ - int GetCorpseDelay(lua_State *L, Creature *creature) + int GetCorpseDelay(lua_State* L, Creature* creature) { Eluna::Push(L, creature->GetCorpseDelay()); return 1; @@ -658,7 +676,7 @@ namespace LuaCreature * @return float z * @return float o */ - int GetHomePosition(lua_State *L, Creature *creature) + int GetHomePosition(lua_State* L, Creature* creature) { float x, y, z, o; #if defined(TRINITY) || defined(AZEROTHCORE) @@ -683,7 +701,7 @@ namespace LuaCreature * @param float z * @param float o */ - int SetHomePosition(lua_State *L, Creature *creature) + int SetHomePosition(lua_State* L, Creature* creature) { float x = Eluna::CHECKVAL(L, 2); float y = Eluna::CHECKVAL(L, 3); @@ -701,9 +719,9 @@ namespace LuaCreature enum SelectAggroTarget { - SELECT_TARGET_RANDOM = 0, // Just selects a random target - SELECT_TARGET_TOPAGGRO, // Selects targes from top aggro to bottom - SELECT_TARGET_BOTTOMAGGRO, // Selects targets from bottom aggro to top + SELECT_TARGET_RANDOM = 0, // Just selects a random target + SELECT_TARGET_TOPAGGRO, // Selects targes from top aggro to bottom + SELECT_TARGET_BOTTOMAGGRO, // Selects targets from bottom aggro to top SELECT_TARGET_NEAREST, SELECT_TARGET_FARTHEST }; @@ -734,7 +752,7 @@ namespace LuaCreature * @param int32 aura = 0 : if positive, the target must have this [Aura]. If negative, the the target must not have this Aura * @return [Unit] target : the target, or `nil` */ - int GetAITarget(lua_State *L, Creature *creature) + int GetAITarget(lua_State* L, Creature* creature) { uint32 targetType = Eluna::CHECKVAL(L, 2); bool playerOnly = Eluna::CHECKVAL(L, 3, false); @@ -743,13 +761,13 @@ namespace LuaCreature int32 aura = Eluna::CHECKVAL(L, 6, 0); #if defined(CMANGOS) - ThreatList const &threatlist = creature->getThreatManager().getThreatList(); + ThreatList const& threatlist = creature->getThreatManager().getThreatList(); #elif defined(MANGOS) - ThreatList const &threatlist = creature->GetThreatManager().getThreatList(); + ThreatList const& threatlist = creature->GetThreatManager().getThreatList(); #elif defined(TRINITY) - auto const &threatlist = creature->GetThreatManager().GetSortedThreatList(); + auto const& threatlist = creature->GetThreatManager().GetSortedThreatList(); #elif defined(AZEROTHCORE) - auto const &threatlist = creature->getThreatManager().getThreatList(); + auto const& threatlist = creature->getThreatManager().getThreatList(); #endif #ifndef TRINITY if (threatlist.empty()) @@ -757,17 +775,17 @@ namespace LuaCreature if (position >= threatlist.size()) return 1; #endif - std::list targetList; + std::list targetList; #if defined(TRINITY) - for (ThreatReference const *itr : threatlist) + for (ThreatReference const* itr : threatlist) #else for (auto itr = threatlist.begin(); itr != threatlist.end(); ++itr) #endif - { + { #if defined(TRINITY) - Unit *target = itr->GetVictim(); + Unit* target = itr->GetVictim(); #else - Unit *target = (*itr)->getTarget(); + Unit* target = (*itr)->getTarget(); #endif if (!target) continue; @@ -794,37 +812,37 @@ namespace LuaCreature switch (targetType) { - case SELECT_TARGET_NEAREST: - case SELECT_TARGET_TOPAGGRO: - { - std::list::const_iterator itr = targetList.begin(); - if (position) - std::advance(itr, position); - Eluna::Push(L, *itr); - } - break; - case SELECT_TARGET_FARTHEST: - case SELECT_TARGET_BOTTOMAGGRO: - { - std::list::reverse_iterator ritr = targetList.rbegin(); - if (position) - std::advance(ritr, position); - Eluna::Push(L, *ritr); - } - break; - case SELECT_TARGET_RANDOM: - { - std::list::const_iterator itr = targetList.begin(); - if (position) - std::advance(itr, urand(0, position)); - else - std::advance(itr, urand(0, targetList.size() - 1)); - Eluna::Push(L, *itr); - } - break; - default: - luaL_argerror(L, 2, "SelectAggroTarget expected"); - break; + case SELECT_TARGET_NEAREST: + case SELECT_TARGET_TOPAGGRO: + { + std::list::const_iterator itr = targetList.begin(); + if (position) + std::advance(itr, position); + Eluna::Push(L, *itr); + } + break; + case SELECT_TARGET_FARTHEST: + case SELECT_TARGET_BOTTOMAGGRO: + { + std::list::reverse_iterator ritr = targetList.rbegin(); + if (position) + std::advance(ritr, position); + Eluna::Push(L, *ritr); + } + break; + case SELECT_TARGET_RANDOM: + { + std::list::const_iterator itr = targetList.begin(); + if (position) + std::advance(itr, urand(0, position)); + else + std::advance(itr, urand(0, targetList.size() - 1)); + Eluna::Push(L, *itr); + } + break; + default: + luaL_argerror(L, 2, "SelectAggroTarget expected"); + break; } return 1; @@ -835,14 +853,14 @@ namespace LuaCreature * * @return table targets */ - int GetAITargets(lua_State *L, Creature *creature) + int GetAITargets(lua_State* L, Creature* creature) { #if defined(TRINITY) - auto const &threatlist = creature->GetThreatManager().GetThreatenedByMeList(); + auto const& threatlist = creature->GetThreatManager().GetThreatenedByMeList(); #elif defined(AZEROTHCORE) - auto const &threatlist = creature->getThreatManager().getThreatList(); +auto const& threatlist = creature->getThreatManager().getThreatList(); #else - ThreatList const &threatlist = creature->GetThreatManager().getThreatList(); + ThreatList const& threatlist = creature->GetThreatManager().getThreatList(); #endif lua_createtable(L, threatlist.size(), 0); int tbl = lua_gettop(L); @@ -850,9 +868,9 @@ namespace LuaCreature for (auto itr = threatlist.begin(); itr != threatlist.end(); ++itr) { #if defined(TRINITY) - Unit *target = itr->second->GetOwner(); + Unit* target = itr->second->GetOwner(); #else - Unit *target = (*itr)->getTarget(); + Unit* target = (*itr)->getTarget(); #endif if (!target) continue; @@ -869,7 +887,7 @@ namespace LuaCreature * * @return int targetsCount */ - int GetAITargetsCount(lua_State *L, Creature *creature) + int GetAITargetsCount(lua_State* L, Creature* creature) { #if defined(TRINITY) Eluna::Push(L, creature->GetThreatManager().GetThreatenedByMeList().size()); @@ -889,7 +907,7 @@ namespace LuaCreature * * @return [NPCFlags] npcFlags */ - int GetNPCFlags(lua_State *L, Creature *creature) + int GetNPCFlags(lua_State* L, Creature* creature) { Eluna::Push(L, creature->GetUInt32Value(UNIT_NPC_FLAGS)); return 1; @@ -903,7 +921,7 @@ namespace LuaCreature * * @return [ExtraFlags] extraFlags */ - int GetExtraFlags(lua_State *L, Creature *creature) + int GetExtraFlags(lua_State* L, Creature* creature) { #if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->GetCreatureTemplate()->flags_extra); @@ -919,7 +937,7 @@ namespace LuaCreature * * @return uint32 shieldBlockValue */ - int GetShieldBlockValue(lua_State *L, Creature *creature) + int GetShieldBlockValue(lua_State* L, Creature* creature) { Eluna::Push(L, creature->GetShieldBlockValue()); return 1; @@ -927,7 +945,7 @@ namespace LuaCreature #endif #if defined(TRINITY) || defined(AZEROTHCORE) - int GetLootMode(lua_State *L, Creature *creature) // TODO: Implement LootMode features + int GetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features { Eluna::Push(L, creature->GetLootMode()); return 1; @@ -939,7 +957,7 @@ namespace LuaCreature * * @return uint32 dbguid */ - int GetDBTableGUIDLow(lua_State *L, Creature *creature) + int GetDBTableGUIDLow(lua_State* L, Creature* creature) { #if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->GetSpawnId()); @@ -955,7 +973,7 @@ namespace LuaCreature * * @param [NPCFlags] flags */ - int SetNPCFlags(lua_State *L, Creature *creature) + int SetNPCFlags(lua_State* L, Creature* creature) { uint32 flags = Eluna::CHECKVAL(L, 2); @@ -963,12 +981,13 @@ namespace LuaCreature return 0; } + /** * Makes the [Creature] able to fly if enabled. * * @param bool disable */ - int SetDisableGravity(lua_State *L, Creature *creature) + int SetDisableGravity(lua_State* L, Creature* creature) { bool disable = Eluna::CHECKVAL(L, 2); @@ -981,7 +1000,7 @@ namespace LuaCreature } #if defined(TRINITY) || defined(AZEROTHCORE) - int SetLootMode(lua_State *L, Creature *creature) // TODO: Implement LootMode features + int SetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features { uint16 lootMode = Eluna::CHECKVAL(L, 2); @@ -995,7 +1014,7 @@ namespace LuaCreature * * @param [DeathState] deathState */ - int SetDeathState(lua_State *L, Creature *creature) + int SetDeathState(lua_State* L, Creature* creature) { int32 state = Eluna::CHECKVAL(L, 2); @@ -1012,7 +1031,7 @@ namespace LuaCreature * * @param bool enable = true : `true` to enable walking, `false` for running */ - int SetWalk(lua_State *L, Creature *creature) // TODO: Move same to Player ? + int SetWalk(lua_State* L, Creature* creature) // TODO: Move same to Player ? { bool enable = Eluna::CHECKVAL(L, 2, true); @@ -1027,7 +1046,7 @@ namespace LuaCreature * @param uint32 off_hand : off hand [Item]'s entry * @param uint32 ranged : ranged [Item]'s entry */ - int SetEquipmentSlots(lua_State *L, Creature *creature) + int SetEquipmentSlots(lua_State* L, Creature* creature) { uint32 main_hand = Eluna::CHECKVAL(L, 2); uint32 off_hand = Eluna::CHECKVAL(L, 3); @@ -1050,7 +1069,7 @@ namespace LuaCreature * * @param bool allow = true : `true` to allow aggro, `false` to disable aggro */ - int SetAggroEnabled(lua_State *L, Creature *creature) + int SetAggroEnabled(lua_State* L, Creature* creature) { bool allow = Eluna::CHECKVAL(L, 2, true); @@ -1074,7 +1093,7 @@ namespace LuaCreature * * @param bool disable = true : `true` to disable reputation, `false` to enable */ - int SetDisableReputationGain(lua_State *L, Creature *creature) + int SetDisableReputationGain(lua_State* L, Creature* creature) { bool disable = Eluna::CHECKVAL(L, 2, true); @@ -1088,7 +1107,7 @@ namespace LuaCreature * This is used by raid bosses to prevent Players from using out-of-combat * actions once the encounter has begun. */ - int SetInCombatWithZone(lua_State * /*L*/, Creature *creature) + int SetInCombatWithZone(lua_State* /*L*/, Creature* creature) { #if defined(AZEROTHCORE) if (creature->IsAIEnabled) @@ -1107,7 +1126,7 @@ namespace LuaCreature * * @param float distance */ - int SetWanderRadius(lua_State *L, Creature *creature) + int SetWanderRadius(lua_State* L, Creature* creature) { float dist = Eluna::CHECKVAL(L, 2); @@ -1124,7 +1143,7 @@ namespace LuaCreature * * @param uint32 delay : the delay, in seconds */ - int SetRespawnDelay(lua_State *L, Creature *creature) + int SetRespawnDelay(lua_State* L, Creature* creature) { uint32 delay = Eluna::CHECKVAL(L, 2); @@ -1137,7 +1156,7 @@ namespace LuaCreature * * @param [MovementGeneratorType] type */ - int SetDefaultMovementType(lua_State *L, Creature *creature) + int SetDefaultMovementType(lua_State* L, Creature* creature) { int32 type = Eluna::CHECKVAL(L, 2); @@ -1150,7 +1169,7 @@ namespace LuaCreature * * @param bool enable = true : `true` to disable searching, `false` to allow */ - int SetNoSearchAssistance(lua_State *L, Creature *creature) + int SetNoSearchAssistance(lua_State* L, Creature* creature) { bool val = Eluna::CHECKVAL(L, 2, true); @@ -1163,7 +1182,7 @@ namespace LuaCreature * * @param bool enable = true : `true` to disable calling for help, `false` to enable */ - int SetNoCallAssistance(lua_State *L, Creature *creature) + int SetNoCallAssistance(lua_State* L, Creature* creature) { bool val = Eluna::CHECKVAL(L, 2, true); @@ -1176,7 +1195,7 @@ namespace LuaCreature * * @param bool enable = true : `true` to enable hovering, `false` to disable */ - int SetHover(lua_State *L, Creature *creature) + int SetHover(lua_State* L, Creature* creature) { bool enable = Eluna::CHECKVAL(L, 2, true); @@ -1206,7 +1225,7 @@ namespace LuaCreature * * @param uint32 delay = 0 : dely to despawn in milliseconds */ - int DespawnOrUnsummon(lua_State *L, Creature *creature) + int DespawnOrUnsummon(lua_State* L, Creature* creature) { uint32 msTimeToDespawn = Eluna::CHECKVAL(L, 2, 0); @@ -1223,7 +1242,7 @@ namespace LuaCreature /** * Respawn this [Creature]. */ - int Respawn(lua_State * /*L*/, Creature *creature) + int Respawn(lua_State* /*L*/, Creature* creature) { creature->Respawn(); return 0; @@ -1232,7 +1251,7 @@ namespace LuaCreature /** * Remove this [Creature]'s corpse. */ - int RemoveCorpse(lua_State * /*L*/, Creature *creature) + int RemoveCorpse(lua_State* /*L*/, Creature* creature) { creature->RemoveCorpse(); return 0; @@ -1241,7 +1260,7 @@ namespace LuaCreature /** * Make the [Creature] start following its waypoint path. */ - int MoveWaypoint(lua_State * /*L*/, Creature *creature) + int MoveWaypoint(lua_State* /*L*/, Creature* creature) { #if defined(TRINITY) || defined(AZEROTHCORE) creature->GetMotionMaster()->MovePath(creature->GetWaypointPath(), true); @@ -1254,7 +1273,7 @@ namespace LuaCreature /** * Make the [Creature] call for assistance in combat from other nearby [Creature]s. */ - int CallAssistance(lua_State * /*L*/, Creature *creature) + int CallAssistance(lua_State* /*L*/, Creature* creature) { creature->CallAssistance(); return 0; @@ -1265,7 +1284,7 @@ namespace LuaCreature * * @param float radius */ - int CallForHelp(lua_State *L, Creature *creature) + int CallForHelp(lua_State* L, Creature* creature) { float radius = Eluna::CHECKVAL(L, 2); @@ -1276,7 +1295,7 @@ namespace LuaCreature /** * Make the [Creature] flee combat to get assistance from a nearby friendly [Creature]. */ - int FleeToGetAssistance(lua_State * /*L*/, Creature *creature) + int FleeToGetAssistance(lua_State* /*L*/, Creature* creature) { creature->DoFleeToGetAssistance(); return 0; @@ -1287,9 +1306,9 @@ namespace LuaCreature * * @param [Unit] target */ - int AttackStart(lua_State *L, Creature *creature) + int AttackStart(lua_State* L, Creature* creature) { - Unit *target = Eluna::CHECKOBJ(L, 2); + Unit* target = Eluna::CHECKOBJ(L, 2); creature->AI()->AttackStart(target); return 0; @@ -1298,7 +1317,7 @@ namespace LuaCreature /** * Save the [Creature] in the database. */ - int SaveToDB(lua_State * /*L*/, Creature *creature) + int SaveToDB(lua_State* /*L*/, Creature* creature) { creature->SaveToDB(); return 0; @@ -1309,7 +1328,7 @@ namespace LuaCreature * * This should be called every update cycle for the Creature's AI. */ - int SelectVictim(lua_State *L, Creature *creature) + int SelectVictim(lua_State* L, Creature* creature) { #if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->SelectVictim()); @@ -1325,7 +1344,7 @@ namespace LuaCreature * @param uint32 entry : the Creature ID to transform into * @param uint32 dataGUIDLow = 0 : use this Creature's model and equipment instead of the defaults */ - int UpdateEntry(lua_State *L, Creature *creature) + int UpdateEntry(lua_State* L, Creature* creature) { uint32 entry = Eluna::CHECKVAL(L, 2); uint32 dataGuidLow = Eluna::CHECKVAL(L, 3, 0); @@ -1342,7 +1361,7 @@ namespace LuaCreature /** * Resets [Creature]'s loot mode to default */ - int ResetLootMode(lua_State * /*L*/, Creature *creature) // TODO: Implement LootMode features + int ResetLootMode(lua_State* /*L*/, Creature* creature) // TODO: Implement LootMode features { creature->ResetLootMode(); return 0; @@ -1353,7 +1372,7 @@ namespace LuaCreature * * @param uint16 lootMode */ - int RemoveLootMode(lua_State *L, Creature *creature) // TODO: Implement LootMode features + int RemoveLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features { uint16 lootMode = Eluna::CHECKVAL(L, 2); @@ -1366,7 +1385,7 @@ namespace LuaCreature * * @param uint16 lootMode */ - int AddLootMode(lua_State *L, Creature *creature) // TODO: Implement LootMode features + int AddLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features { uint16 lootMode = Eluna::CHECKVAL(L, 2); @@ -1429,16 +1448,16 @@ namespace LuaCreature * * @return [CreatureFamily] creatureFamily */ - int GetCreatureFamily(lua_State *L, Creature *creature) + int GetCreatureFamily(lua_State* L, Creature* creature) { uint32 entry = creature->GetEntry(); #if defined(TRINITY) || defined(AZEROTHCORE) - CreatureTemplate const *cInfo = sObjectMgr->GetCreatureTemplate(entry); + CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(entry); if (cInfo) Eluna::Push(L, cInfo->family); #else - CreatureInfo const *cInfo = ObjectMgr::GetCreatureTemplate(entry); + CreatureInfo const* cInfo = ObjectMgr::GetCreatureTemplate(entry); if (cInfo) Eluna::Push(L, cInfo->Family); #endif diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index 13d36f1..9bd1740 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -811,6 +811,7 @@ ElunaRegister CreatureMethods[] = { "SetEquipmentSlots", &LuaCreature::SetEquipmentSlots }, // Boolean + { "IsRegeneratingHealth", &LuaCreature::IsRegeneratingHealth }, #if defined(TRINITY) || defined(AZEROTHCORE) { "IsDungeonBoss", &LuaCreature::IsDungeonBoss }, #endif