mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-01 01:53:47 +00:00
Merge branch 'master' into merge-master
This commit is contained in:
@@ -33,7 +33,6 @@ GuardAI::GuardAI(Creature* creature) : ScriptedAI(creature)
|
||||
void GuardAI::Reset()
|
||||
{
|
||||
ScriptedAI::Reset();
|
||||
me->CastSpell(me, 18950 /*SPELL_INVISIBILITY_AND_STEALTH_DETECTION*/, true);
|
||||
}
|
||||
|
||||
void GuardAI::EnterEvadeMode(EvadeReason /*why*/)
|
||||
|
||||
@@ -81,6 +81,7 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c)
|
||||
|
||||
_currentRangeMode = false;
|
||||
_attackDistance = 0.f;
|
||||
_mainSpellId = 0;
|
||||
}
|
||||
|
||||
bool SmartAI::IsAIControlled() const
|
||||
@@ -1122,6 +1123,7 @@ void SmartAI::SetMainSpell(uint32 spellId)
|
||||
if (maxRange <= NOMINAL_MELEE_RANGE)
|
||||
return;
|
||||
|
||||
_mainSpellId = spellId;
|
||||
_attackDistance = std::max(maxRange - NOMINAL_MELEE_RANGE, 0.0f);
|
||||
_currentRangeMode = true;
|
||||
}
|
||||
@@ -1222,6 +1224,27 @@ void SmartAI::DistancingEnded()
|
||||
_pendingDistancing = 0.f;
|
||||
}
|
||||
|
||||
bool SmartAI::IsMainSpellPrevented(SpellInfo const* spellInfo) const
|
||||
{
|
||||
if (me->HasSpellCooldown(spellInfo->Id))
|
||||
return true;
|
||||
|
||||
if (spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
|
||||
return true;
|
||||
if (spellInfo->PreventionType == SPELL_PREVENTION_TYPE_PACIFY && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void SmartAI::OnSpellCastFinished(SpellInfo const* spell, SpellFinishReason reason)
|
||||
{
|
||||
CreatureAI::OnSpellCastFinished(spell, reason);
|
||||
if (reason == SPELL_FINISHED_CANCELED && _mainSpellId == spell->Id)
|
||||
if (_currentRangeMode && IsMainSpellPrevented(spell))
|
||||
SetCurrentRangeMode(false);
|
||||
}
|
||||
|
||||
void SmartGameObjectAI::SummonedCreatureDies(Creature* summon, Unit* /*killer*/)
|
||||
{
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_SUMMONED_UNIT_DIES, summon);
|
||||
|
||||
@@ -214,6 +214,10 @@ public:
|
||||
|
||||
void DistancingEnded() override;
|
||||
|
||||
bool IsMainSpellPrevented(SpellInfo const* spellInfo) const;
|
||||
|
||||
void OnSpellCastFinished(SpellInfo const* spell, SpellFinishReason reason) override;
|
||||
|
||||
private:
|
||||
bool mIsCharmed;
|
||||
uint32 mFollowCreditType;
|
||||
@@ -265,6 +269,7 @@ private:
|
||||
bool _currentRangeMode;
|
||||
float _attackDistance;
|
||||
float _pendingDistancing;
|
||||
uint32 _mainSpellId;
|
||||
};
|
||||
|
||||
class SmartGameObjectAI : public GameObjectAI
|
||||
|
||||
@@ -3289,6 +3289,13 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_SET_ANIM_TIER:
|
||||
{
|
||||
for (WorldObject* target : targets)
|
||||
if (IsUnit(target))
|
||||
target->ToUnit()->SetAnimTier(AnimTier(e.action.animTier.animTier));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry {} SourceType {}, Event {}, Unhandled Action type {}", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
|
||||
break;
|
||||
@@ -4500,14 +4507,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
if (!IsInPhase(e.event.eventPhaseChange.phasemask))
|
||||
return;
|
||||
|
||||
WorldObject* templastInvoker = GetLastInvoker();
|
||||
if (!templastInvoker)
|
||||
return;
|
||||
|
||||
if (!IsUnit(templastInvoker))
|
||||
return;
|
||||
|
||||
ProcessAction(e, templastInvoker->ToUnit());
|
||||
ProcessAction(e);
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_GAME_EVENT_START:
|
||||
|
||||
@@ -884,6 +884,8 @@ bool SmartAIMgr::CheckUnusedActionParams(SmartScriptHolder const& e)
|
||||
case SMART_ACTION_MOVEMENT_RESUME: return sizeof(SmartAction::move);
|
||||
case SMART_ACTION_WORLD_SCRIPT: return sizeof(SmartAction::worldStateScript);
|
||||
case SMART_ACTION_DISABLE_REWARD: return sizeof(SmartAction::reward);
|
||||
case SMART_ACTION_SET_ANIM_TIER: return sizeof(SmartAction::animTier);
|
||||
case SMART_ACTION_DISMOUNT: return NO_PARAMS;
|
||||
default:
|
||||
LOG_WARN("sql.sql", "SmartAIMgr: entryorguid {} source_type {} id {} action_type {} is using an action with no unused params specified in SmartAIMgr::CheckUnusedActionParams(), please report this.",
|
||||
e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
|
||||
@@ -1893,6 +1895,13 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_SET_ANIM_TIER:
|
||||
if (e.action.animTier.animTier >= uint32(AnimTier::Max))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "SmartAIMgr: Entry {} SourceType {} Event {} Action {} uses invalid animtier %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.animTier.animTier);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case SMART_ACTION_AUTO_ATTACK:
|
||||
return IsSAIBoolValid(e, e.action.autoAttack.attack);
|
||||
case SMART_ACTION_ALLOW_COMBAT_MOVEMENT:
|
||||
|
||||
@@ -721,8 +721,9 @@ enum SMART_ACTION
|
||||
SMART_ACTION_MOVEMENT_RESUME = 236, // timerOverride
|
||||
SMART_ACTION_WORLD_SCRIPT = 237, // eventId, param
|
||||
SMART_ACTION_DISABLE_REWARD = 238, // reputation 0/1, loot 0/1
|
||||
SMART_ACTION_SET_ANIM_TIER = 239, // animtier
|
||||
|
||||
SMART_ACTION_AC_END = 239, // placeholder
|
||||
SMART_ACTION_AC_END = 240, // placeholder
|
||||
};
|
||||
|
||||
enum class SmartActionSummonCreatureFlags
|
||||
@@ -1502,6 +1503,11 @@ struct SmartAction
|
||||
SAIBool reputation;
|
||||
SAIBool loot;
|
||||
} reward;
|
||||
|
||||
struct
|
||||
{
|
||||
uint32 animTier;
|
||||
} animTier;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user