mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-23 05:36:23 +00:00
Merge branch 'azerothcore:master' into Playerbot
This commit is contained in:
@@ -106,7 +106,7 @@ float UnitAI::DoGetSpellMaxRange(uint32 spellId, bool positive)
|
||||
return spellInfo ? spellInfo->GetMaxRange(positive) : 0;
|
||||
}
|
||||
|
||||
void UnitAI::DoAddAuraToAllHostilePlayers(uint32 spellid)
|
||||
SpellCastResult UnitAI::DoAddAuraToAllHostilePlayers(uint32 spellid)
|
||||
{
|
||||
if (me->IsInCombat())
|
||||
{
|
||||
@@ -114,13 +114,22 @@ void UnitAI::DoAddAuraToAllHostilePlayers(uint32 spellid)
|
||||
for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
|
||||
{
|
||||
if (Unit* unit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid()))
|
||||
{
|
||||
if (unit->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
me->AddAura(spellid, unit);
|
||||
return SPELL_CAST_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
return SPELL_FAILED_BAD_TARGETS;
|
||||
}
|
||||
}
|
||||
|
||||
return SPELL_FAILED_CUSTOM_ERROR;
|
||||
}
|
||||
|
||||
void UnitAI::DoCastToAllHostilePlayers(uint32 spellid, bool triggered)
|
||||
SpellCastResult UnitAI::DoCastToAllHostilePlayers(uint32 spellid, bool triggered)
|
||||
{
|
||||
if (me->IsInCombat())
|
||||
{
|
||||
@@ -128,13 +137,19 @@ void UnitAI::DoCastToAllHostilePlayers(uint32 spellid, bool triggered)
|
||||
for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
|
||||
{
|
||||
if (Unit* unit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid()))
|
||||
{
|
||||
if (unit->GetTypeId() == TYPEID_PLAYER)
|
||||
me->CastSpell(unit, spellid, triggered);
|
||||
return me->CastSpell(unit, spellid, triggered);
|
||||
}
|
||||
else
|
||||
return SPELL_FAILED_BAD_TARGETS;
|
||||
}
|
||||
}
|
||||
|
||||
return SPELL_FAILED_CUSTOM_ERROR;
|
||||
}
|
||||
|
||||
void UnitAI::DoCast(uint32 spellId)
|
||||
SpellCastResult UnitAI::DoCast(uint32 spellId)
|
||||
{
|
||||
Unit* target = nullptr;
|
||||
|
||||
@@ -149,10 +164,11 @@ void UnitAI::DoCast(uint32 spellId)
|
||||
break;
|
||||
case AITARGET_ENEMY:
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
bool playerOnly = spellInfo->HasAttribute(SPELL_ATTR3_ONLY_ON_PLAYER);
|
||||
//float range = GetSpellMaxRange(spellInfo, false);
|
||||
target = SelectTarget(SelectTargetMethod::Random, 0, spellInfo->GetMaxRange(false), playerOnly);
|
||||
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId))
|
||||
{
|
||||
bool playerOnly = spellInfo->HasAttribute(SPELL_ATTR3_ONLY_ON_PLAYER);
|
||||
target = SelectTarget(SelectTargetMethod::Random, 0, spellInfo->GetMaxRange(false), playerOnly);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AITARGET_ALLY:
|
||||
@@ -163,59 +179,63 @@ void UnitAI::DoCast(uint32 spellId)
|
||||
break;
|
||||
case AITARGET_DEBUFF:
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
bool playerOnly = spellInfo->HasAttribute(SPELL_ATTR3_ONLY_ON_PLAYER);
|
||||
float range = spellInfo->GetMaxRange(false);
|
||||
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId))
|
||||
{
|
||||
bool playerOnly = spellInfo->HasAttribute(SPELL_ATTR3_ONLY_ON_PLAYER);
|
||||
float range = spellInfo->GetMaxRange(false);
|
||||
|
||||
DefaultTargetSelector targetSelector(me, range, playerOnly, -(int32)spellId);
|
||||
if (!(spellInfo->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_VICTIM)
|
||||
&& targetSelector(me->GetVictim()))
|
||||
target = me->GetVictim();
|
||||
else
|
||||
target = SelectTarget(SelectTargetMethod::Random, 0, targetSelector);
|
||||
DefaultTargetSelector targetSelector(me, range, playerOnly, -(int32)spellId);
|
||||
if (!(spellInfo->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_VICTIM)
|
||||
&& targetSelector(me->GetVictim()))
|
||||
target = me->GetVictim();
|
||||
else
|
||||
target = SelectTarget(SelectTargetMethod::Random, 0, targetSelector);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (target)
|
||||
me->CastSpell(target, spellId, false);
|
||||
|
||||
return SPELL_FAILED_BAD_TARGETS;
|
||||
}
|
||||
|
||||
void UnitAI::DoCast(Unit* victim, uint32 spellId, bool triggered)
|
||||
SpellCastResult UnitAI::DoCast(Unit* victim, uint32 spellId, bool triggered)
|
||||
{
|
||||
if (!victim || (me->HasUnitState(UNIT_STATE_CASTING) && !triggered))
|
||||
return;
|
||||
if (!victim)
|
||||
return SPELL_FAILED_BAD_TARGETS;
|
||||
|
||||
me->CastSpell(victim, spellId, triggered);
|
||||
if (me->HasUnitState(UNIT_STATE_CASTING) && !triggered)
|
||||
return SPELL_FAILED_SPELL_IN_PROGRESS;
|
||||
|
||||
return me->CastSpell(victim, spellId, triggered);
|
||||
}
|
||||
|
||||
void UnitAI::DoCastVictim(uint32 spellId, bool triggered)
|
||||
SpellCastResult UnitAI::DoCastVictim(uint32 spellId, bool triggered)
|
||||
{
|
||||
if (!me->GetVictim() || (me->HasUnitState(UNIT_STATE_CASTING) && !triggered))
|
||||
return;
|
||||
if (Unit* victim = me->GetVictim())
|
||||
return DoCast(victim, spellId, triggered);
|
||||
|
||||
me->CastSpell(me->GetVictim(), spellId, triggered);
|
||||
return SPELL_FAILED_BAD_TARGETS;
|
||||
}
|
||||
|
||||
void UnitAI::DoCastAOE(uint32 spellId, bool triggered)
|
||||
SpellCastResult UnitAI::DoCastAOE(uint32 spellId, bool triggered)
|
||||
{
|
||||
if (!triggered && me->HasUnitState(UNIT_STATE_CASTING))
|
||||
return;
|
||||
return SPELL_FAILED_SPELL_IN_PROGRESS;
|
||||
|
||||
me->CastSpell((Unit*)nullptr, spellId, triggered);
|
||||
return me->CastSpell((Unit*)nullptr, spellId, triggered);
|
||||
}
|
||||
|
||||
void UnitAI::DoCastRandomTarget(uint32 spellId, uint32 threatTablePosition, float dist, bool playerOnly, bool triggered)
|
||||
SpellCastResult UnitAI::DoCastRandomTarget(uint32 spellId, uint32 threatTablePosition, float dist, bool playerOnly, bool triggered)
|
||||
{
|
||||
if (!triggered && me->HasUnitState(UNIT_STATE_CASTING))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Unit* target = SelectTarget(SelectTargetMethod::Random, threatTablePosition, dist, playerOnly))
|
||||
{
|
||||
me->CastSpell(target, spellId, triggered);
|
||||
return DoCast(target, spellId, triggered);
|
||||
}
|
||||
|
||||
return SPELL_FAILED_BAD_TARGETS;
|
||||
}
|
||||
|
||||
#define UPDATE_TARGET(a) {if (AIInfo->target<a) AIInfo->target=a;}
|
||||
|
||||
@@ -317,14 +317,14 @@ public:
|
||||
|
||||
void AttackStartCaster(Unit* victim, float dist);
|
||||
|
||||
void DoAddAuraToAllHostilePlayers(uint32 spellid);
|
||||
void DoCast(uint32 spellId);
|
||||
void DoCast(Unit* victim, uint32 spellId, bool triggered = false);
|
||||
inline void DoCastSelf(uint32 spellId, bool triggered = false) { DoCast(me, spellId, triggered); }
|
||||
void DoCastToAllHostilePlayers(uint32 spellid, bool triggered = false);
|
||||
void DoCastVictim(uint32 spellId, bool triggered = false);
|
||||
void DoCastAOE(uint32 spellId, bool triggered = false);
|
||||
void DoCastRandomTarget(uint32 spellId, uint32 threatTablePosition = 0, float dist = 0.0f, bool playerOnly = true, bool triggered = false);
|
||||
SpellCastResult DoAddAuraToAllHostilePlayers(uint32 spellid);
|
||||
SpellCastResult DoCast(uint32 spellId);
|
||||
SpellCastResult DoCast(Unit* victim, uint32 spellId, bool triggered = false);
|
||||
SpellCastResult DoCastSelf(uint32 spellId, bool triggered = false) { return DoCast(me, spellId, triggered); }
|
||||
SpellCastResult DoCastToAllHostilePlayers(uint32 spellid, bool triggered = false);
|
||||
SpellCastResult DoCastVictim(uint32 spellId, bool triggered = false);
|
||||
SpellCastResult DoCastAOE(uint32 spellId, bool triggered = false);
|
||||
SpellCastResult DoCastRandomTarget(uint32 spellId, uint32 threatTablePosition = 0, float dist = 0.0f, bool playerOnly = true, bool triggered = false);
|
||||
|
||||
float DoGetSpellMaxRange(uint32 spellId, bool positive = false);
|
||||
|
||||
|
||||
@@ -1417,6 +1417,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
||||
trans->Append(stmt);
|
||||
|
||||
WorldDatabase.CommitTransaction(trans);
|
||||
sScriptMgr->OnCreatureSaveToDB(this);
|
||||
}
|
||||
|
||||
void Creature::SelectLevel(bool changelevel)
|
||||
|
||||
@@ -1062,6 +1062,7 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask, bool
|
||||
}
|
||||
|
||||
WorldDatabase.CommitTransaction(trans);
|
||||
sScriptMgr->OnGameObjectSaveToDB(this);
|
||||
}
|
||||
|
||||
bool GameObject::LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap)
|
||||
|
||||
@@ -38,6 +38,16 @@ void ScriptMgr::OnCreatureRemoveWorld(Creature* creature)
|
||||
});
|
||||
}
|
||||
|
||||
void ScriptMgr::OnCreatureSaveToDB(Creature* creature)
|
||||
{
|
||||
ASSERT(creature);
|
||||
|
||||
ExecuteScript<AllCreatureScript>([&](AllCreatureScript* script)
|
||||
{
|
||||
script->OnCreatureSaveToDB(creature);
|
||||
});
|
||||
}
|
||||
|
||||
void ScriptMgr::Creature_SelectLevel(const CreatureTemplate* cinfo, Creature* creature)
|
||||
{
|
||||
ExecuteScript<AllCreatureScript>([&](AllCreatureScript* script)
|
||||
|
||||
@@ -37,3 +37,13 @@ void ScriptMgr::OnGameObjectRemoveWorld(GameObject* go)
|
||||
script->OnGameObjectRemoveWorld(go);
|
||||
});
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGameObjectSaveToDB(GameObject* go)
|
||||
{
|
||||
ASSERT(go);
|
||||
|
||||
ExecuteScript<AllGameObjectScript>([&](AllGameObjectScript* script)
|
||||
{
|
||||
script->OnGameObjectSaveToDB(go);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -562,6 +562,13 @@ public:
|
||||
*/
|
||||
virtual void OnCreatureRemoveWorld(Creature* /*creature*/) { }
|
||||
|
||||
/**
|
||||
* @brief This hook runs after creature has been saved to DB
|
||||
*
|
||||
* @param creature Contains information about the Creature
|
||||
*/
|
||||
virtual void OnCreatureSaveToDB(Creature* /*creature*/) { }
|
||||
|
||||
/**
|
||||
* @brief This hook called when a player opens a gossip dialog with the creature.
|
||||
*
|
||||
@@ -644,7 +651,12 @@ public:
|
||||
* @param go Contains information about the GameObject
|
||||
*/
|
||||
virtual void OnGameObjectAddWorld(GameObject* /*go*/) { }
|
||||
|
||||
/**
|
||||
* @brief This hook runs after the game object iis saved to the database
|
||||
*
|
||||
* @param go Contains information about the GameObject
|
||||
*/
|
||||
virtual void OnGameObjectSaveToDB(GameObject* /*go*/) { }
|
||||
/**
|
||||
* @brief This hook runs after remove game object in world
|
||||
*
|
||||
@@ -2433,6 +2445,10 @@ public: /* AllCreatureScript */
|
||||
//listener function (OnAllCreatureUpdate) is called by OnCreatureUpdate
|
||||
//void OnAllCreatureUpdate(Creature* creature, uint32 diff);
|
||||
void Creature_SelectLevel(const CreatureTemplate* cinfo, Creature* creature);
|
||||
void OnCreatureSaveToDB(Creature* creature);
|
||||
|
||||
public: /* AllGameobjectScript */
|
||||
void OnGameObjectSaveToDB(GameObject* go);
|
||||
|
||||
public: /* AllMapScript */
|
||||
void OnBeforeCreateInstanceScript(InstanceMap* instanceMap, InstanceScript* instanceData, bool load, std::string data, uint32 completedEncounterMask);
|
||||
|
||||
Reference in New Issue
Block a user