Eluna create workaround for SetReactState

This commit is contained in:
Rochet2
2014-04-29 22:56:02 +03:00
committed by Foereaper
parent 523e6d50e5
commit 6751208eb2
4 changed files with 20 additions and 25 deletions

View File

@@ -80,14 +80,15 @@ namespace LuaCreature
return 1;
}
int HasReactState(lua_State* L, Creature* creature)
int IsCombatAllowed(lua_State* L, Creature* creature)
{
int32 state = sEluna->CHECKVAL<int32>(L, 2);
#ifdef MANGOS
sEluna->Push(L, creature->GetCharmInfo()->HasReactState((ReactStates)state));
if (CreatureAI* ai = creature->AI())
sEluna->Push(L, ai->IsCombatMovement());
else
sEluna->Push(L, false);
#else
sEluna->Push(L, creature->HasReactState((ReactStates)state));
sEluna->Push(L, !creature->HasReactState(REACT_PASSIVE);
#endif
return 1;
}
@@ -270,16 +271,6 @@ namespace LuaCreature
return 1;
}
int GetReactState(lua_State* L, Creature* creature)
{
#ifdef MANGOS
sEluna->Push(L, creature->GetCharmInfo()->GetReactState());
#else
sEluna->Push(L, creature->GetReactState());
#endif
return 1;
}
int GetScriptName(lua_State* L, Creature* creature)
{
sEluna->Push(L, creature->GetScriptName());
@@ -480,14 +471,15 @@ namespace LuaCreature
return 0;
}
int SetReactState(lua_State* L, Creature* creature)
int SetAllowedCombat(lua_State* L, Creature* creature)
{
int32 state = sEluna->CHECKVAL<int32>(L, 2);
bool allow = sEluna->CHECKVAL<bool>(L, 2);
#ifdef MANGOS
creature->GetCharmInfo()->SetReactState((ReactStates)state);
if (CreatureAI* ai = creature->AI())
ai->SetCombatMovement(allow);
#else
creature->SetReactState((ReactStates)state);
creature->SetReactState(allow ? REACT_AGGRESSIVE : REACT_PASSIVE);
#endif
return 0;
}

View File

@@ -1656,7 +1656,13 @@ struct ElunaCreatureAI : ScriptedAI
void UpdateAI(uint32 diff) OVERRIDE
#endif
{
ScriptedAI::UpdateAI(diff);
#ifdef MANGOS
if (IsCombatMovement())
ScriptedAI::UpdateAI(diff);
#else
if (!me->HasReactState(REACT_PASSIVE))
ScriptedAI::UpdateAI(diff);
#endif
int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_AIUPDATE);
if (!bind)
return;

View File

@@ -122,7 +122,6 @@ enum SelectAggroTarget
#undef Opcodes
#define Opcodes OpcodesList
#endif
#define AllowCombat m_isCombatMovement
#else
#ifndef CATA
typedef uint64 ObjectGuid;
@@ -138,7 +137,6 @@ typedef ThreatContainer::StorageType ThreatList;
#ifdef CATA
#define NUM_MSG_TYPES NUM_OPCODE_HANDLERS
#endif
#define AllowCombat _isCombatMovementAllowed
#endif
template<typename T>

View File

@@ -702,7 +702,6 @@ ElunaRegister<Creature> CreatureMethods[] =
{ "GetScriptId", &LuaCreature::GetScriptId }, // :GetScriptId() - Returns creature's script ID
{ "GetAIName", &LuaCreature::GetAIName }, // :GetAIName() - Returns creature's AI name
{ "GetScriptName", &LuaCreature::GetScriptName }, // :GetScriptName() - Returns creature's script name
{ "GetReactState", &LuaCreature::GetReactState }, // :GetReactState() - Returns creature's react state
{ "GetAttackDistance", &LuaCreature::GetAttackDistance }, // :GetAttackDistance(unit) - Returns attack distance to unit
{ "GetAggroRange", &LuaCreature::GetAggroRange }, // :GetAggroRange(unit) - Returns aggro distance to unit
{ "GetDefaultMovementType", &LuaCreature::GetDefaultMovementType }, // :GetDefaultMovementType() - Returns default movement type
@@ -721,7 +720,7 @@ ElunaRegister<Creature> CreatureMethods[] =
// Setters
{ "SetHover", &LuaCreature::SetHover }, // :SetHover([enable]) - Sets hover on or off
// {"SetDisableGravity", &LuaCreature::SetDisableGravity}, // :SetDisableGravity([disable, packetOnly]) - Disables or enables gravity
{ "SetReactState", &LuaCreature::SetReactState }, // :SetReactState(state) - Sets react state
{ "SetAllowedCombat", &LuaCreature::SetAllowedCombat }, // :SetAllowedCombat(allow) - Allows the creature to attack or not
{ "SetNoCallAssistance", &LuaCreature::SetNoCallAssistance }, // :SetNoCallAssistance([noCall]) - Sets call assistance to false or true
{ "SetNoSearchAssistance", &LuaCreature::SetNoSearchAssistance }, // :SetNoSearchAssistance([noSearch]) - Sets assistance searhing to false or true
{ "SetDefaultMovementType", &LuaCreature::SetDefaultMovementType }, // :SetDefaultMovementType(type) - Sets default movement type
@@ -745,7 +744,7 @@ ElunaRegister<Creature> CreatureMethods[] =
{ "HasCategoryCooldown", &LuaCreature::HasCategoryCooldown }, // :HasCategoryCooldown(spellId) - Returns true if the creature has a cooldown for the spell's category
{ "CanWalk", &LuaCreature::CanWalk }, // :CanWalk() - Returns true if the creature can walk
{ "CanSwim", &LuaCreature::CanSwim }, // :CanSwim() - Returns true if the creature can swim
{ "HasReactState", &LuaCreature::HasReactState }, // :HasReactState(state) - Returns true if the creature has react state
{ "IsCombatAllowed", &LuaCreature::IsCombatAllowed }, // :IsCombatAllowed() - Returns true if the creature has combat allowed
// {"CanStartAttack", &LuaCreature::CanStartAttack}, // :CanStartAttack(unit[, force]) - Returns true if the creature can attack the unit
{ "HasSearchedAssistance", &LuaCreature::HasSearchedAssistance }, // :HasSearchedAssistance() - Returns true if the creature has searched assistance
{ "CanAssistTo", &LuaCreature::CanAssistTo }, // :CanAssistTo(unit, enemy[, checkfaction]) - Returns true if the creature can assist unit with enemy