mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[11942] Add option to NearestCreatureEntryWithLiveState.. GridSearcher to be able to also search for both alive and corpse creatures
This commit is contained in:
parent
fcbde94267
commit
a42a55da84
5 changed files with 10 additions and 9 deletions
|
|
@ -1129,12 +1129,12 @@ namespace MaNGOS
|
||||||
class NearestCreatureEntryWithLiveStateInObjectRangeCheck
|
class NearestCreatureEntryWithLiveStateInObjectRangeCheck
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NearestCreatureEntryWithLiveStateInObjectRangeCheck(WorldObject const& obj,uint32 entry, bool alive, float range)
|
NearestCreatureEntryWithLiveStateInObjectRangeCheck(WorldObject const& obj,uint32 entry, bool onlyAlive, bool onlyDead, float range)
|
||||||
: i_obj(obj), i_entry(entry), i_alive(alive), i_range(range) {}
|
: i_obj(obj), i_entry(entry), i_onlyAlive(onlyAlive), i_onlyDead(onlyDead), i_range(range) {}
|
||||||
WorldObject const& GetFocusObject() const { return i_obj; }
|
WorldObject const& GetFocusObject() const { return i_obj; }
|
||||||
bool operator()(Creature* u)
|
bool operator()(Creature* u)
|
||||||
{
|
{
|
||||||
if (u->GetEntry() == i_entry && (i_alive && u->isAlive() || !i_alive && u->IsCorpse()) && i_obj.IsWithinDistInMap(u, i_range))
|
if (u->GetEntry() == i_entry && (i_onlyAlive && u->isAlive() || i_onlyDead && u->IsCorpse() || !i_onlyAlive && !i_onlyDead) && i_obj.IsWithinDistInMap(u, i_range))
|
||||||
{
|
{
|
||||||
i_range = i_obj.GetDistance(u); // use found unit range as new range limit for next check
|
i_range = i_obj.GetDistance(u); // use found unit range as new range limit for next check
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1145,7 +1145,8 @@ namespace MaNGOS
|
||||||
private:
|
private:
|
||||||
WorldObject const& i_obj;
|
WorldObject const& i_obj;
|
||||||
uint32 i_entry;
|
uint32 i_entry;
|
||||||
bool i_alive;
|
bool i_onlyAlive;
|
||||||
|
bool i_onlyDead;
|
||||||
float i_range;
|
float i_range;
|
||||||
|
|
||||||
// prevent clone this object
|
// prevent clone this object
|
||||||
|
|
|
||||||
|
|
@ -827,7 +827,7 @@ bool ScriptAction::GetScriptProcessTargets(WorldObject* pOrigSource, WorldObject
|
||||||
{
|
{
|
||||||
Creature* pCreatureBuddy = NULL;
|
Creature* pCreatureBuddy = NULL;
|
||||||
|
|
||||||
MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*pSearcher, m_script->buddyEntry, true, m_script->searchRadius);
|
MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*pSearcher, m_script->buddyEntry, true, false, m_script->searchRadius);
|
||||||
MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(pCreatureBuddy, u_check);
|
MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(pCreatureBuddy, u_check);
|
||||||
|
|
||||||
Cell::VisitGridObjects(pSearcher, searcher, m_script->searchRadius);
|
Cell::VisitGridObjects(pSearcher, searcher, m_script->searchRadius);
|
||||||
|
|
|
||||||
|
|
@ -5105,7 +5105,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
||||||
// no target provided or it was not valid, so use closest in range
|
// no target provided or it was not valid, so use closest in range
|
||||||
if (!targetExplicit)
|
if (!targetExplicit)
|
||||||
{
|
{
|
||||||
MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*m_caster, i_spellST->second.targetEntry, i_spellST->second.type != SPELL_TARGET_TYPE_DEAD, range);
|
MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*m_caster, i_spellST->second.targetEntry, i_spellST->second.type != SPELL_TARGET_TYPE_DEAD, i_spellST->second.type == SPELL_TARGET_TYPE_DEAD, range);
|
||||||
MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(p_Creature, u_check);
|
MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(p_Creature, u_check);
|
||||||
|
|
||||||
// Visit all, need to find also Pet* objects
|
// Visit all, need to find also Pet* objects
|
||||||
|
|
|
||||||
|
|
@ -2155,7 +2155,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx)
|
||||||
Creature* pTargetDummy = NULL;
|
Creature* pTargetDummy = NULL;
|
||||||
float fRange = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex));
|
float fRange = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex));
|
||||||
|
|
||||||
MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*m_caster, 28523, true, fRange*2);
|
MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*m_caster, 28523, true, false, fRange*2);
|
||||||
MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(pTargetDummy, u_check);
|
MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(pTargetDummy, u_check);
|
||||||
|
|
||||||
Cell::VisitGridObjects(m_caster, searcher, fRange*2);
|
Cell::VisitGridObjects(m_caster, searcher, fRange*2);
|
||||||
|
|
@ -6778,7 +6778,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx)
|
||||||
float range = 20.0f;
|
float range = 20.0f;
|
||||||
|
|
||||||
// search for a reef cow nearby
|
// search for a reef cow nearby
|
||||||
MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*m_caster, 24797, true, range);
|
MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*m_caster, 24797, true, false, range);
|
||||||
MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(pQuestCow, u_check);
|
MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(pQuestCow, u_check);
|
||||||
|
|
||||||
Cell::VisitGridObjects(m_caster, searcher, range);
|
Cell::VisitGridObjects(m_caster, searcher, range);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11941"
|
#define REVISION_NR "11942"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue