mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Eluna fix previous commit (tested TC wotlk)
This commit is contained in:
@@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
/***
|
/***
|
||||||
* Non-[Player] controlled [Unit]s.
|
* Non-[Player] controlled [Unit]s.
|
||||||
|
*
|
||||||
|
* Inherits [Object], [WorldObject], [Unit]
|
||||||
*/
|
*/
|
||||||
namespace LuaCreature
|
namespace LuaCreature
|
||||||
{
|
{
|
||||||
@@ -43,7 +45,7 @@ namespace LuaCreature
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns `true` if the [Creature] completes the [Quest] with the ID `quest_id`,
|
* Returns `true` if the [Creature] completes the [Quest] with the ID `questID`,
|
||||||
* and returns `false` otherwise.
|
* and returns `false` otherwise.
|
||||||
*
|
*
|
||||||
* @param uint32 questID : the ID of a [Quest]
|
* @param uint32 questID : the ID of a [Quest]
|
||||||
@@ -149,11 +151,16 @@ namespace LuaCreature
|
|||||||
* Returns `true` if the [Creature] can start attacking nearby hostile [Unit]s,
|
* Returns `true` if the [Creature] can start attacking nearby hostile [Unit]s,
|
||||||
* and returns `false` otherwise.
|
* and returns `false` otherwise.
|
||||||
*
|
*
|
||||||
* @return bool canInitiateAttack
|
* @return bool canAggro
|
||||||
*/
|
*/
|
||||||
int CanAggro(lua_State* L, Creature* creature)
|
int CanAggro(lua_State* L, Creature* creature)
|
||||||
{
|
{
|
||||||
Eluna::Push(L, creature->CanInitiateAttack());
|
#ifdef TRINITY
|
||||||
|
Eluna::Push(L, !creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC));
|
||||||
|
#else
|
||||||
|
// Eluna::Push(L, creature->CanInitiateAttack());
|
||||||
|
Eluna::Push(L, !creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE));
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,6 +345,12 @@ namespace LuaCreature
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TRINITY
|
#ifdef TRINITY
|
||||||
|
/**
|
||||||
|
* Returns `true` if the [Creature] is an invisible trigger,
|
||||||
|
* and returns `false` otherwise.
|
||||||
|
*
|
||||||
|
* @return bool canFly
|
||||||
|
*/
|
||||||
int IsTrigger(lua_State* L, Creature* creature)
|
int IsTrigger(lua_State* L, Creature* creature)
|
||||||
{
|
{
|
||||||
Eluna::Push(L, creature->IsTrigger());
|
Eluna::Push(L, creature->IsTrigger());
|
||||||
@@ -396,6 +409,34 @@ namespace LuaCreature
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TRINITY
|
||||||
|
/**
|
||||||
|
* Returns the current waypoint path ID of the [Creature].
|
||||||
|
*
|
||||||
|
* @return uint32 pathId
|
||||||
|
*/
|
||||||
|
int GetWaypointPath(lua_State* L, Creature* creature)
|
||||||
|
{
|
||||||
|
Eluna::Push(L, creature->GetWaypointPath());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current waypoint ID of the [Creature].
|
||||||
|
*
|
||||||
|
* @return uint32 wpId
|
||||||
|
*/
|
||||||
|
int GetCurrentWaypointId(lua_State* L, Creature* creature)
|
||||||
|
{
|
||||||
|
#ifdef TRINITY
|
||||||
|
Eluna::Push(L, creature->GetCurrentWaypointID());
|
||||||
|
#else
|
||||||
|
Eluna::Push(L, creature->GetMotionMaster()->getLastReachedWaypoint());
|
||||||
|
#endif
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the default movement type for this [Creature].
|
* Returns the default movement type for this [Creature].
|
||||||
*
|
*
|
||||||
@@ -475,7 +516,7 @@ namespace LuaCreature
|
|||||||
*
|
*
|
||||||
* This is used by the core to apply C++ scripts to the Creature.
|
* This is used by the core to apply C++ scripts to the Creature.
|
||||||
*
|
*
|
||||||
* It is not used by Eluna.
|
* It is not used by Eluna. Eluna will override AI scripts.
|
||||||
*
|
*
|
||||||
* @return string scriptName
|
* @return string scriptName
|
||||||
*/
|
*/
|
||||||
@@ -488,9 +529,9 @@ namespace LuaCreature
|
|||||||
/**
|
/**
|
||||||
* Returns the [Creature]'s AI name.
|
* Returns the [Creature]'s AI name.
|
||||||
*
|
*
|
||||||
* This is used by the core to override the Creature's default AI.
|
* This is used by the core to assign the Creature's default AI.
|
||||||
*
|
*
|
||||||
* If the Creature is scripted by Eluna, this field is overriden.
|
* If the Creature is scripted by Eluna, the AI is overriden.
|
||||||
*
|
*
|
||||||
* @return string AIName
|
* @return string AIName
|
||||||
*/
|
*/
|
||||||
@@ -503,7 +544,7 @@ namespace LuaCreature
|
|||||||
/**
|
/**
|
||||||
* Returns the [Creature]'s script ID.
|
* Returns the [Creature]'s script ID.
|
||||||
*
|
*
|
||||||
* Every script name is assigned a unique ID by the core.
|
* Every C++ script name is assigned a unique ID by the core.
|
||||||
* This returns the ID for this [Creature]'s script name.
|
* This returns the ID for this [Creature]'s script name.
|
||||||
*
|
*
|
||||||
* @return uint32 scriptID
|
* @return uint32 scriptID
|
||||||
@@ -575,10 +616,10 @@ namespace LuaCreature
|
|||||||
* target = creature:GetAITarget(4, true, 3, 50, 24328)
|
* target = creature:GetAITarget(4, true, 3, 50, 24328)
|
||||||
*
|
*
|
||||||
* @param SelectAggroTarget targetType : how the threat list should be sorted
|
* @param SelectAggroTarget targetType : how the threat list should be sorted
|
||||||
* @param bool playerOnly: if `true`, skips targets that aren't [Player]s
|
* @param bool playerOnly = false : if `true`, skips targets that aren't [Player]s
|
||||||
* @param uint32 position: if `targetType` is not random, used as an offset into the threat list
|
* @param uint32 position = 0 : used as an offset into the threat list. If `targetType` is random, used as the number of players from top of aggro to choose from
|
||||||
* @param float distance: if positive, the maximum distance for the target. If negative, the minimum distance
|
* @param float distance = 0.0 : if positive, the maximum distance for the target. If negative, the minimum distance
|
||||||
* @param int32 aura if positive, the target must have this [Aura]. If negative, the the target must not have this Aura
|
* @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`
|
* @return Unit target : the target, or `nil`
|
||||||
*/
|
*/
|
||||||
int GetAITarget(lua_State* L, Creature* creature)
|
int GetAITarget(lua_State* L, Creature* creature)
|
||||||
@@ -651,6 +692,8 @@ namespace LuaCreature
|
|||||||
std::list<Unit*>::const_iterator itr = targetList.begin();
|
std::list<Unit*>::const_iterator itr = targetList.begin();
|
||||||
if (position)
|
if (position)
|
||||||
std::advance(itr, urand(0, position));
|
std::advance(itr, urand(0, position));
|
||||||
|
else
|
||||||
|
std::advance(itr, urand(0, targetList.size()-1));
|
||||||
Eluna::Push(L, *itr);
|
Eluna::Push(L, *itr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -760,6 +803,34 @@ namespace LuaCreature
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes the [Creature] able to fly if enabled.
|
||||||
|
*
|
||||||
|
* @param bool enable = true
|
||||||
|
*/
|
||||||
|
int SetDisableGravity(lua_State* L, Creature* creature)
|
||||||
|
{
|
||||||
|
bool enable = Eluna::CHECKVAL<bool>(L, 2, true);
|
||||||
|
|
||||||
|
#ifdef TRINITY
|
||||||
|
creature->SetDisableGravity(!enable);
|
||||||
|
#else
|
||||||
|
creature->SetLevitate(enable);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef TRINITY
|
||||||
|
int SetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features
|
||||||
|
{
|
||||||
|
uint16 lootMode = Eluna::CHECKVAL<uint16>(L, 2);
|
||||||
|
|
||||||
|
creature->SetLootMode(lootMode);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the [Creature]'s death state to `deathState`.
|
* Sets the [Creature]'s death state to `deathState`.
|
||||||
*
|
*
|
||||||
@@ -780,7 +851,7 @@ namespace LuaCreature
|
|||||||
/**
|
/**
|
||||||
* Sets whether the [Creature] is currently walking or running.
|
* Sets whether the [Creature] is currently walking or running.
|
||||||
*
|
*
|
||||||
* @param bool enable: `true` to enable walking, `false` for running
|
* @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 ?
|
||||||
{
|
{
|
||||||
@@ -793,20 +864,23 @@ namespace LuaCreature
|
|||||||
/**
|
/**
|
||||||
* Sets whether the [Creature] can be aggroed by movement or not.
|
* Sets whether the [Creature] can be aggroed by movement or not.
|
||||||
*
|
*
|
||||||
* @param bool allow: `true` to allow aggro, `false` to disable aggro
|
* @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<bool>(L, 2);
|
bool allow = Eluna::CHECKVAL<bool>(L, 2, true);
|
||||||
|
|
||||||
|
#ifdef TRINITY
|
||||||
if (allow)
|
if (allow)
|
||||||
{
|
creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC);
|
||||||
creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE);
|
else
|
||||||
}
|
creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC);
|
||||||
|
#else
|
||||||
|
if (allow)
|
||||||
|
creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE);
|
||||||
else
|
else
|
||||||
{
|
|
||||||
creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE);
|
creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE);
|
||||||
}
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -814,7 +888,7 @@ namespace LuaCreature
|
|||||||
/**
|
/**
|
||||||
* Sets whether the [Creature] gives reputation or not.
|
* Sets whether the [Creature] gives reputation or not.
|
||||||
*
|
*
|
||||||
* @param bool disable: `true` to disable reputation, `false` to enable
|
* @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)
|
||||||
{
|
{
|
||||||
@@ -878,7 +952,7 @@ namespace LuaCreature
|
|||||||
/**
|
/**
|
||||||
* Sets whether the [Creature] can search for assistance at low health or not.
|
* Sets whether the [Creature] can search for assistance at low health or not.
|
||||||
*
|
*
|
||||||
* @param bool enable: `true` to disable searching, `false` to allow
|
* @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)
|
||||||
{
|
{
|
||||||
@@ -891,7 +965,7 @@ namespace LuaCreature
|
|||||||
/**
|
/**
|
||||||
* Sets whether the [Creature] can call nearby enemies for help in combat or not.
|
* Sets whether the [Creature] can call nearby enemies for help in combat or not.
|
||||||
*
|
*
|
||||||
* @param bool enable: `true` to disable calling for help, `false` to enable
|
* @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)
|
||||||
{
|
{
|
||||||
@@ -902,18 +976,27 @@ namespace LuaCreature
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether the creature is hovering or not.
|
* Sets whether the creature is hovering / levitating or not.
|
||||||
*
|
*
|
||||||
* @param bool enable: `true` to enable hovering, `false` to disable
|
* @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<bool>(L, 2, true);
|
bool enable = Eluna::CHECKVAL<bool>(L, 2, true);
|
||||||
|
|
||||||
#ifndef TRINITY
|
#ifdef TRINITY
|
||||||
creature->SetLevitate(enable);
|
|
||||||
#else
|
|
||||||
creature->SetHover(enable);
|
creature->SetHover(enable);
|
||||||
|
#else
|
||||||
|
// Copy paste from Aura::HandleAuraHover
|
||||||
|
// TODO: implement core side properly
|
||||||
|
WorldPacket data;
|
||||||
|
if (enable)
|
||||||
|
data.Initialize(SMSG_MOVE_SET_HOVER, 8 + 4);
|
||||||
|
else
|
||||||
|
data.Initialize(SMSG_MOVE_UNSET_HOVER, 8 + 4);
|
||||||
|
data << creature->GetPackGUID();
|
||||||
|
data << uint32(0);
|
||||||
|
creature->SendMessageToSet(&data, true);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -922,6 +1005,8 @@ namespace LuaCreature
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Despawn this [Creature].
|
* Despawn this [Creature].
|
||||||
|
*
|
||||||
|
* @param uint32 delay = 0 : dely to despawn in milliseconds
|
||||||
*/
|
*/
|
||||||
int DespawnOrUnsummon(lua_State* L, Creature* creature)
|
int DespawnOrUnsummon(lua_State* L, Creature* creature)
|
||||||
{
|
{
|
||||||
@@ -1038,7 +1123,7 @@ namespace LuaCreature
|
|||||||
* Transform the [Creature] into another Creature.
|
* Transform the [Creature] into another Creature.
|
||||||
*
|
*
|
||||||
* @param uint32 entry : the Creature ID to transform into
|
* @param uint32 entry : the Creature ID to transform into
|
||||||
* @param uint32 dataGUIDLow: use this Creature's model and equipment instead of the defaults
|
* @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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1471,11 +1471,11 @@ struct ElunaCreatureAI : ScriptedAI
|
|||||||
void UpdateAI(uint32 diff) override
|
void UpdateAI(uint32 diff) override
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifndef TRINITY
|
#ifdef TRINITY
|
||||||
if (IsCombatMovement())
|
if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
|
||||||
ScriptedAI::UpdateAI(diff);
|
ScriptedAI::UpdateAI(diff);
|
||||||
#else
|
#else
|
||||||
if (!me->HasReactState(REACT_PASSIVE))
|
if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE))
|
||||||
ScriptedAI::UpdateAI(diff);
|
ScriptedAI::UpdateAI(diff);
|
||||||
#endif
|
#endif
|
||||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_AIUPDATE, return);
|
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_AIUPDATE, return);
|
||||||
|
|||||||
@@ -722,9 +722,9 @@ ElunaRegister<Creature> CreatureMethods[] =
|
|||||||
{ "GetDefaultMovementType", &LuaCreature::GetDefaultMovementType },
|
{ "GetDefaultMovementType", &LuaCreature::GetDefaultMovementType },
|
||||||
{ "GetRespawnDelay", &LuaCreature::GetRespawnDelay },
|
{ "GetRespawnDelay", &LuaCreature::GetRespawnDelay },
|
||||||
{ "GetWanderRadius", &LuaCreature::GetWanderRadius },
|
{ "GetWanderRadius", &LuaCreature::GetWanderRadius },
|
||||||
|
{ "GetCurrentWaypointId", &LuaCreature::GetCurrentWaypointId },
|
||||||
#ifdef TRINITY
|
#ifdef TRINITY
|
||||||
{ "GetWaypointPath", &LuaCreature::GetWaypointPath },
|
{ "GetWaypointPath", &LuaCreature::GetWaypointPath },
|
||||||
{ "GetCurrentWaypointId", &LuaCreature::GetCurrentWaypointId },
|
|
||||||
{ "GetLootMode", &LuaCreature::GetLootMode },
|
{ "GetLootMode", &LuaCreature::GetLootMode },
|
||||||
#endif
|
#endif
|
||||||
{ "GetLootRecipient", &LuaCreature::GetLootRecipient },
|
{ "GetLootRecipient", &LuaCreature::GetLootRecipient },
|
||||||
@@ -736,9 +736,7 @@ ElunaRegister<Creature> CreatureMethods[] =
|
|||||||
|
|
||||||
// Setters
|
// Setters
|
||||||
{ "SetHover", &LuaCreature::SetHover },
|
{ "SetHover", &LuaCreature::SetHover },
|
||||||
#ifdef TRINITY
|
|
||||||
{ "SetDisableGravity", &LuaCreature::SetDisableGravity },
|
{ "SetDisableGravity", &LuaCreature::SetDisableGravity },
|
||||||
#endif
|
|
||||||
{ "SetAggroEnabled", &LuaCreature::SetAggroEnabled },
|
{ "SetAggroEnabled", &LuaCreature::SetAggroEnabled },
|
||||||
{ "SetNoCallAssistance", &LuaCreature::SetNoCallAssistance },
|
{ "SetNoCallAssistance", &LuaCreature::SetNoCallAssistance },
|
||||||
{ "SetNoSearchAssistance", &LuaCreature::SetNoSearchAssistance },
|
{ "SetNoSearchAssistance", &LuaCreature::SetNoSearchAssistance },
|
||||||
|
|||||||
Reference in New Issue
Block a user