mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 17:27:36 +01:00
Creature/CreatureAI:
- Default range for DoZoneInCombat: 50.0f -> 250.0f. - Add optional second arg to SummonList::DoZoneInCombat to specify range. - Also a bunch of random NULL -> nullptr cleanup.
This commit is contained in:
@@ -46,7 +46,7 @@ void CreatureAI::Talk(uint8 id, WorldObject const* whisperTarget /*= nullptr*/)
|
||||
sCreatureTextMgr->SendChat(me, id, whisperTarget);
|
||||
}
|
||||
|
||||
void CreatureAI::DoZoneInCombat(Creature* creature /*= NULL*/, float maxRangeToNearestTarget /* = 50.0f*/)
|
||||
void CreatureAI::DoZoneInCombat(Creature* creature /*= nullptr*/, float maxRangeToNearestTarget /* = 250.0f*/)
|
||||
{
|
||||
if (!creature)
|
||||
creature = me;
|
||||
@@ -265,7 +265,7 @@ bool CreatureAI::_EnterEvadeMode(EvadeReason /*why*/)
|
||||
me->DeleteThreatList();
|
||||
me->CombatStop(true);
|
||||
me->LoadCreaturesAddon();
|
||||
me->SetLootRecipient(NULL);
|
||||
me->SetLootRecipient(nullptr);
|
||||
me->ResetPlayerDamageReq();
|
||||
me->SetLastDamagedTime(0);
|
||||
me->SetCannotReachTarget(false);
|
||||
|
||||
@@ -112,7 +112,7 @@ class CreatureAI : public UnitAI
|
||||
// Called for reaction at stopping attack at no attackers or targets
|
||||
virtual void EnterEvadeMode(EvadeReason why = EVADE_REASON_OTHER);
|
||||
|
||||
// Called for reaction at enter to combat if not in combat yet (enemy can be NULL)
|
||||
// Called for reaction at enter to combat if not in combat yet (enemy can be nullptr)
|
||||
virtual void EnterCombat(Unit* /*victim*/) { }
|
||||
|
||||
// Called when the creature is killed
|
||||
@@ -157,7 +157,7 @@ class CreatureAI : public UnitAI
|
||||
// Called at reaching home after evade
|
||||
virtual void JustReachedHome() { }
|
||||
|
||||
void DoZoneInCombat(Creature* creature = NULL, float maxRangeToNearestTarget = 50.0f);
|
||||
void DoZoneInCombat(Creature* creature = nullptr, float maxRangeToNearestTarget = 250.0f);
|
||||
|
||||
// Called at text emote receive from player
|
||||
virtual void ReceiveEmote(Player* /*player*/, uint32 /*emoteId*/) { }
|
||||
|
||||
@@ -32,7 +32,7 @@ struct TSpellSummary
|
||||
uint8 Effects; // set of enum SelectEffect
|
||||
} extern* SpellSummary;
|
||||
|
||||
void SummonList::DoZoneInCombat(uint32 entry)
|
||||
void SummonList::DoZoneInCombat(uint32 entry, float maxRangeToNearestTarget)
|
||||
{
|
||||
for (StorageType::iterator i = storage_.begin(); i != storage_.end();)
|
||||
{
|
||||
@@ -41,7 +41,7 @@ void SummonList::DoZoneInCombat(uint32 entry)
|
||||
if (summon && summon->IsAIEnabled
|
||||
&& (!entry || summon->GetEntry() == entry))
|
||||
{
|
||||
summon->AI()->DoZoneInCombat();
|
||||
summon->AI()->DoZoneInCombat(nullptr, maxRangeToNearestTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,11 +183,11 @@ SpellInfo const* ScriptedAI::SelectSpell(Unit* target, uint32 school, uint32 mec
|
||||
{
|
||||
//No target so we can't cast
|
||||
if (!target)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
//Silenced so we can't cast
|
||||
if (me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
//Using the extended script system we first create a list of viable spells
|
||||
SpellInfo const* apSpell[MAX_CREATURE_SPELLS];
|
||||
@@ -195,7 +195,7 @@ SpellInfo const* ScriptedAI::SelectSpell(Unit* target, uint32 school, uint32 mec
|
||||
|
||||
uint32 spellCount = 0;
|
||||
|
||||
SpellInfo const* tempSpell = NULL;
|
||||
SpellInfo const* tempSpell = nullptr;
|
||||
|
||||
//Check if each spell is viable(set it to null if not)
|
||||
for (uint32 i = 0; i < MAX_CREATURE_SPELLS; i++)
|
||||
@@ -251,7 +251,7 @@ SpellInfo const* ScriptedAI::SelectSpell(Unit* target, uint32 school, uint32 mec
|
||||
|
||||
//We got our usable spells so now lets randomly pick one
|
||||
if (!spellCount)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return apSpell[urand(0, spellCount - 1)];
|
||||
}
|
||||
@@ -327,7 +327,7 @@ void ScriptedAI::DoTeleportAll(float x, float y, float z, float o)
|
||||
|
||||
Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 minHPDiff)
|
||||
{
|
||||
Unit* unit = NULL;
|
||||
Unit* unit = nullptr;
|
||||
Trinity::MostHPMissingInRange u_check(me, range, minHPDiff);
|
||||
Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(me, unit, u_check);
|
||||
me->VisitNearbyObject(range, searcher);
|
||||
@@ -357,7 +357,7 @@ std::list<Creature*> ScriptedAI::DoFindFriendlyMissingBuff(float range, uint32 u
|
||||
|
||||
Player* ScriptedAI::GetPlayerAtMinimumRange(float minimumRange)
|
||||
{
|
||||
Player* player = NULL;
|
||||
Player* player = nullptr;
|
||||
|
||||
CellCoord pair(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
|
||||
Cell cell(pair);
|
||||
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void DoZoneInCombat(uint32 entry = 0);
|
||||
void DoZoneInCombat(uint32 entry = 0, float maxRangeToNearestTarget = 250.0f);
|
||||
void RemoveNotExisting();
|
||||
bool HasEntry(uint32 entry) const;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "Transport.h"
|
||||
|
||||
GameObject::GameObject() : WorldObject(false), MapObject(),
|
||||
m_model(NULL), m_goValue(), m_AI(NULL)
|
||||
m_model(nullptr), m_goValue(), m_AI(nullptr)
|
||||
{
|
||||
m_objectType |= TYPEMASK_GAMEOBJECT;
|
||||
m_objectTypeId = TYPEID_GAMEOBJECT;
|
||||
@@ -49,8 +49,8 @@ GameObject::GameObject() : WorldObject(false), MapObject(),
|
||||
m_usetimes = 0;
|
||||
m_spellId = 0;
|
||||
m_cooldownTime = 0;
|
||||
m_goInfo = NULL;
|
||||
m_goData = NULL;
|
||||
m_goInfo = nullptr;
|
||||
m_goData = nullptr;
|
||||
|
||||
m_spawnId = 0;
|
||||
m_rotation = 0;
|
||||
@@ -520,7 +520,7 @@ void GameObject::Update(uint32 diff)
|
||||
radius = goInfo->trap.diameter / 2.f;
|
||||
|
||||
// Pointer to appropriate target if found any
|
||||
Unit* target = NULL;
|
||||
Unit* target = nullptr;
|
||||
|
||||
/// @todo this hack with search required until GO casting not implemented
|
||||
if (Unit* owner = GetOwner())
|
||||
@@ -535,7 +535,7 @@ void GameObject::Update(uint32 diff)
|
||||
else
|
||||
{
|
||||
// Environmental trap: Any player
|
||||
Player* player = NULL;
|
||||
Player* player = nullptr;
|
||||
Trinity::AnyPlayerInObjectRangeCheck checker(this, radius);
|
||||
Trinity::PlayerSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(this, player, checker);
|
||||
VisitNearbyWorldObject(radius, searcher);
|
||||
@@ -595,8 +595,8 @@ void GameObject::Update(uint32 diff)
|
||||
GameObjectTemplate const* goInfo = GetGOInfo();
|
||||
if (goInfo->trap.type == 2 && goInfo->trap.spellId)
|
||||
{
|
||||
/// @todo NULL target won't work for target type 1
|
||||
CastSpell(NULL, goInfo->trap.spellId);
|
||||
/// @todo nullptr target won't work for target type 1
|
||||
CastSpell(nullptr, goInfo->trap.spellId);
|
||||
SetLootState(GO_JUST_DEACTIVATED);
|
||||
}
|
||||
else if (Unit* target = ObjectAccessor::GetUnit(*this, m_lootStateUnitGUID))
|
||||
@@ -1126,7 +1126,7 @@ void GameObject::TriggeringLinkedGameObject(uint32 trapEntry, Unit* target)
|
||||
float range = float(target->GetSpellMaxRangeForTarget(GetOwner(), trapSpell));
|
||||
|
||||
// search nearest linked GO
|
||||
GameObject* trapGO = NULL;
|
||||
GameObject* trapGO = nullptr;
|
||||
{
|
||||
// using original GO distance
|
||||
CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
|
||||
@@ -1146,7 +1146,7 @@ void GameObject::TriggeringLinkedGameObject(uint32 trapEntry, Unit* target)
|
||||
|
||||
GameObject* GameObject::LookupFishingHoleAround(float range)
|
||||
{
|
||||
GameObject* ok = NULL;
|
||||
GameObject* ok = nullptr;
|
||||
|
||||
CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
|
||||
Cell cell(p);
|
||||
@@ -1169,7 +1169,7 @@ void GameObject::ResetDoorOrButton()
|
||||
m_cooldownTime = 0;
|
||||
}
|
||||
|
||||
void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = false */, Unit* user /*=NULL*/)
|
||||
void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = false */, Unit* user /*=nullptr*/)
|
||||
{
|
||||
if (m_lootState != GO_READY)
|
||||
return;
|
||||
@@ -1193,7 +1193,7 @@ void GameObject::SetGoArtKit(uint8 kit)
|
||||
|
||||
void GameObject::SetGoArtKit(uint8 artkit, GameObject* go, ObjectGuid::LowType lowguid)
|
||||
{
|
||||
const GameObjectData* data = NULL;
|
||||
const GameObjectData* data = nullptr;
|
||||
if (go)
|
||||
{
|
||||
go->SetGoArtKit(artkit);
|
||||
@@ -1419,7 +1419,7 @@ void GameObject::Use(Unit* user)
|
||||
|
||||
// cast this spell later if provided
|
||||
spellId = info->goober.spellId;
|
||||
spellCaster = NULL;
|
||||
spellCaster = nullptr;
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -1538,7 +1538,7 @@ void GameObject::Use(Unit* user)
|
||||
|
||||
GameObjectTemplate const* info = GetGOInfo();
|
||||
|
||||
Player* m_ritualOwner = NULL;
|
||||
Player* m_ritualOwner = nullptr;
|
||||
if (m_ritualOwnerGUID)
|
||||
m_ritualOwner = ObjectAccessor::FindPlayer(m_ritualOwnerGUID);
|
||||
|
||||
@@ -1902,7 +1902,7 @@ bool GameObject::IsInRange(float x, float y, float z, float radius) const
|
||||
&& dz < info->maxZ + radius && dz > info->minZ - radius;
|
||||
}
|
||||
|
||||
void GameObject::EventInform(uint32 eventId, WorldObject* invoker /*= NULL*/)
|
||||
void GameObject::EventInform(uint32 eventId, WorldObject* invoker /*= nullptr*/)
|
||||
{
|
||||
if (!eventId)
|
||||
return;
|
||||
@@ -1962,7 +1962,7 @@ void GameObject::UpdateRotationFields(float rotation2 /*=0.0f*/, float rotation3
|
||||
SetFloatValue(GAMEOBJECT_PARENTROTATION+3, rotation3);
|
||||
}
|
||||
|
||||
void GameObject::ModifyHealth(int32 change, Unit* attackerOrHealer /*= NULL*/, uint32 spellId /*= 0*/)
|
||||
void GameObject::ModifyHealth(int32 change, Unit* attackerOrHealer /*= nullptr*/, uint32 spellId /*= 0*/)
|
||||
{
|
||||
if (!m_goValue.Building.MaxHealth || !change)
|
||||
return;
|
||||
@@ -1981,7 +1981,7 @@ void GameObject::ModifyHealth(int32 change, Unit* attackerOrHealer /*= NULL*/, u
|
||||
// Set the health bar, value = 255 * healthPct;
|
||||
SetGoAnimProgress(m_goValue.Building.Health * 255 / m_goValue.Building.MaxHealth);
|
||||
|
||||
Player* player = attackerOrHealer ? attackerOrHealer->GetCharmerOrOwnerPlayerOrPlayerItself() : NULL;
|
||||
Player* player = attackerOrHealer ? attackerOrHealer->GetCharmerOrOwnerPlayerOrPlayerItself() : nullptr;
|
||||
|
||||
// dealing damage, send packet
|
||||
if (player)
|
||||
@@ -2012,7 +2012,7 @@ void GameObject::ModifyHealth(int32 change, Unit* attackerOrHealer /*= NULL*/, u
|
||||
SetDestructibleState(newState, player, false);
|
||||
}
|
||||
|
||||
void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player* eventInvoker /*= NULL*/, bool setHealth /*= false*/)
|
||||
void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player* eventInvoker /*= nullptr*/, bool setHealth /*= false*/)
|
||||
{
|
||||
// the user calling this must know he is already operating on destructible gameobject
|
||||
ASSERT(GetGoType() == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING);
|
||||
@@ -2221,14 +2221,14 @@ void GameObject::UpdateModel()
|
||||
Player* GameObject::GetLootRecipient() const
|
||||
{
|
||||
if (!m_lootRecipient)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
return ObjectAccessor::FindConnectedPlayer(m_lootRecipient);
|
||||
}
|
||||
|
||||
Group* GameObject::GetLootRecipientGroup() const
|
||||
{
|
||||
if (!m_lootRecipientGroup)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
return sGroupMgr->GetGroupByGUID(m_lootRecipientGroup);
|
||||
}
|
||||
|
||||
@@ -2236,7 +2236,7 @@ void GameObject::SetLootRecipient(Unit* unit)
|
||||
{
|
||||
// set the player whose group should receive the right
|
||||
// to loot the creature after it dies
|
||||
// should be set to NULL after the loot disappears
|
||||
// should be set to nullptr after the loot disappears
|
||||
|
||||
if (!unit)
|
||||
{
|
||||
@@ -2382,7 +2382,7 @@ void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* t
|
||||
data->append(fieldBuffer);
|
||||
}
|
||||
|
||||
void GameObject::GetRespawnPosition(float &x, float &y, float &z, float* ori /* = NULL*/) const
|
||||
void GameObject::GetRespawnPosition(float &x, float &y, float &z, float* ori /* = 0.0f*/) const
|
||||
{
|
||||
if (m_spawnId)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user