Changeset 13 for trunk/src/game

Show
Ignore:
Timestamp:
11/19/08 13:23:03 (17 years ago)
Author:
yumileroy
Message:

[svn] * Moved Script grid_searchers to core
* Moved an enum from sc_creature.h to CreatureAI.h

Original author: Neo2003
Date: 2008-10-05 11:56:30-05:00

Location:
trunk/src/game
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/CreatureAI.h

    r2 r13  
    3232#define TIME_INTERVAL_LOOK   5000 
    3333#define VISIBILITY_RANGE    10000 
     34 
     35//Spell targets used by SelectSpell 
     36enum SelectTarget 
     37{ 
     38    SELECT_TARGET_DONTCARE = 0,                             //All target types allowed 
     39 
     40    SELECT_TARGET_SELF,                                     //Only Self casting 
     41 
     42    SELECT_TARGET_SINGLE_ENEMY,                             //Only Single Enemy 
     43    SELECT_TARGET_AOE_ENEMY,                                //Only AoE Enemy 
     44    SELECT_TARGET_ANY_ENEMY,                                //AoE or Single Enemy 
     45 
     46    SELECT_TARGET_SINGLE_FRIEND,                            //Only Single Friend 
     47    SELECT_TARGET_AOE_FRIEND,                               //Only AoE Friend 
     48    SELECT_TARGET_ANY_FRIEND,                               //AoE or Single Friend 
     49}; 
     50 
     51//Spell Effects used by SelectSpell 
     52enum SelectEffect 
     53{ 
     54    SELECT_EFFECT_DONTCARE = 0,                             //All spell effects allowed 
     55    SELECT_EFFECT_DAMAGE,                                   //Spell does damage 
     56    SELECT_EFFECT_HEALING,                                  //Spell does healing 
     57    SELECT_EFFECT_AURA,                                     //Spell applies an aura 
     58}; 
     59 
     60//Selection method used by SelectTarget 
     61enum SelectAggroTarget 
     62{ 
     63    SELECT_TARGET_RANDOM = 0,                               //Just selects a random target 
     64    SELECT_TARGET_TOPAGGRO,                                 //Selects targes from top aggro to bottom 
     65    SELECT_TARGET_BOTTOMAGGRO,                              //Selects targets from bottom aggro to top 
     66}; 
    3467 
    3568class MANGOS_DLL_SPEC CreatureAI 
  • trunk/src/game/GridNotifiers.h

    r6 r13  
    710710    }; 
    711711 
     712    class NearestAssistCreatureInCreatureRangeCheck 
     713    { 
     714        public: 
     715            NearestAssistCreatureInCreatureRangeCheck(Creature* obj,Unit* enemy, float range) 
     716                : i_obj(obj), i_enemy(enemy), i_range(range) {} 
     717 
     718            bool operator()(Creature* u) 
     719            { 
     720                if(u->getFaction() == i_obj->getFaction() && !u->isInCombat() && !u->GetCharmerOrOwnerGUID() && u->IsHostileTo(i_enemy) && u->isAlive()&& i_obj->IsWithinDistInMap(u, i_range) && i_obj->IsWithinLOSInMap(u)) 
     721                { 
     722                    i_range = i_obj->GetDistance(u);         // use found unit range as new range limit for next check 
     723                    return true; 
     724                } 
     725                return false; 
     726            } 
     727            float GetLastRange() const { return i_range; } 
     728        private: 
     729            Creature* const i_obj; 
     730            Unit* const i_enemy; 
     731            float  i_range; 
     732 
     733            // prevent clone this object 
     734            NearestAssistCreatureInCreatureRangeCheck(NearestAssistCreatureInCreatureRangeCheck const&); 
     735    }; 
     736 
    712737    class AnyAssistCreatureInRangeCheck 
    713738    { 
     
    799824        WorldObject const* i_obj; 
    800825        float i_range; 
     826    }; 
     827 
     828    // Searchers used by ScriptedAI 
     829    class MostHPMissingInRange 
     830    { 
     831    public: 
     832        MostHPMissingInRange(Unit const* obj, float range, uint32 hp) : i_obj(obj), i_range(range), i_hp(hp) {} 
     833        bool operator()(Unit* u) 
     834        { 
     835            if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && u->GetMaxHealth() - u->GetHealth() > i_hp) 
     836            { 
     837                i_hp = u->GetMaxHealth() - u->GetHealth(); 
     838                return true; 
     839            } 
     840            return false; 
     841        } 
     842    private: 
     843        Unit const* i_obj; 
     844        float i_range; 
     845        uint32 i_hp; 
     846    }; 
     847 
     848    class FriendlyCCedInRange 
     849    { 
     850    public: 
     851        FriendlyCCedInRange(Unit const* obj, float range) : i_obj(obj), i_range(range) {} 
     852        bool operator()(Unit* u) 
     853        { 
     854            if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && 
     855                (u->isFeared() || u->isCharmed() || u->isFrozen() || u->hasUnitState(UNIT_STAT_STUNDED) || u->hasUnitState(UNIT_STAT_STUNDED) || u->hasUnitState(UNIT_STAT_CONFUSED))) 
     856            { 
     857                return true; 
     858            } 
     859            return false; 
     860        } 
     861    private: 
     862        Unit const* i_obj; 
     863        float i_range; 
     864    }; 
     865 
     866    class FriendlyMissingBuffInRange 
     867    { 
     868    public: 
     869        FriendlyMissingBuffInRange(Unit const* obj, float range, uint32 spellid) : i_obj(obj), i_range(range), i_spell(spellid) {} 
     870        bool operator()(Unit* u) 
     871        { 
     872            if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) &&  
     873                !(u->HasAura(i_spell, 0) || u->HasAura(i_spell, 1) || u->HasAura(i_spell, 2))) 
     874            { 
     875                return true; 
     876            } 
     877            return false; 
     878        } 
     879    private: 
     880        Unit const* i_obj; 
     881        float i_range; 
     882        uint32 i_spell; 
     883    }; 
     884 
     885    class AllFriendlyCreaturesInGrid 
     886    { 
     887    public: 
     888        AllFriendlyCreaturesInGrid(Unit const* obj) : pUnit(obj) {} 
     889        bool operator() (Unit* u) 
     890        { 
     891            if(u->isAlive() && u->GetVisibility() == VISIBILITY_ON && u->IsFriendlyTo(pUnit)) 
     892                return true; 
     893 
     894            return false; 
     895        } 
     896    private: 
     897        Unit const* pUnit; 
     898    }; 
     899 
     900    class AllGameObjectsWithEntryInGrid 
     901    { 
     902    public: 
     903        AllGameObjectsWithEntryInGrid(uint32 ent) : entry(ent) {} 
     904        bool operator() (GameObject* g) 
     905        { 
     906            if(g->GetEntry() == entry) 
     907                return true; 
     908 
     909            return false; 
     910        } 
     911    private: 
     912        uint32 entry; 
     913    }; 
     914 
     915    class AllCreaturesOfEntryInRange 
     916    { 
     917    public: 
     918        AllCreaturesOfEntryInRange(Unit const* obj, uint32 ent, float ran) : pUnit(obj), entry(ent), range(ran) {} 
     919        bool operator() (Unit* u) 
     920        { 
     921            if(u->GetEntry() == entry && pUnit->IsWithinDistInMap(u, range)) 
     922                return true; 
     923 
     924            return false; 
     925        } 
     926    private: 
     927        Unit const* pUnit; 
     928        uint32 entry; 
     929        float range; 
    801930    }; 
    802931