Changeset 265 for trunk

Show
Ignore:
Timestamp:
11/21/08 08:48:46 (17 years ago)
Author:
yumileroy
Message:

*Add m_isAggressive. Only aggressive creatures will call AttackStart? and MoveInLineOfSight?.
*Set melee dmg school for summoned creatures.
*Fix some compiling errors.

Original author: megamage
Date: 2008-11-20 18:54:50-06:00

Location:
trunk/src/game
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Creature.cpp

    r260 r265  
    123123m_lootMoney(0), m_lootRecipient(0), 
    124124m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f), 
    125 m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false), 
     125m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false), m_isAggressive(true), 
    126126m_regenTimer(2000), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0), 
    127127m_AlreadyCallAssistence(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false), 
     
    294294    SetUInt32Value(UNIT_DYNAMIC_FLAGS,GetCreatureInfo()->dynamicflags); 
    295295 
     296    SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool)); 
    296297    SetModifierValue(UNIT_MOD_ARMOR,             BASE_VALUE, float(GetCreatureInfo()->armor)); 
    297298    SetModifierValue(UNIT_MOD_RESISTANCE_HOLY,   BASE_VALUE, float(GetCreatureInfo()->resistance1)); 
     
    323324    if(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER) 
    324325        SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); 
     326 
     327    if(isTotem() || isCivilian() || GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER 
     328        || GetCreatureType() == CREATURE_TYPE_CRITTER) 
     329        m_isAggressive = false; 
     330    else 
     331        m_isAggressive = true; 
    325332 
    326333    return true; 
     
    14111418    SetPower(POWER_MANA,data->curmana); 
    14121419 
    1413     SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool)); 
    1414  
    14151420    // checked at creature_template loading 
    14161421    m_defaultMovementType = MovementGeneratorType(data->movementType); 
  • trunk/src/game/Creature.h

    r260 r265  
    427427        bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; } 
    428428        bool canFly()  const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; } 
     429        bool isAggressive() const { return m_isAggressive; } 
     430        void SetAggressive(bool agg) { m_isAggressive = agg; } 
    429431        ///// TODO RENAME THIS!!!!! 
    430432        bool isCanTrainingOf(Player* player, bool msg) const; 
     
    637639        bool m_isPet;                                       // set only in Pet::Pet 
    638640        bool m_isTotem;                                     // set only in Totem::Totem 
     641        bool m_isAggressive; 
    639642        void RegenerateMana(); 
    640643        void RegenerateHealth(); 
  • trunk/src/game/GridNotifiersImpl.h

    r186 r265  
    7373 
    7474    // Creature AI reaction 
    75     if(!c->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) 
     75    if(c->isAggressive() && !c->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) 
    7676    { 
    7777        if( c->AI() && c->IsWithinSightDist(pl) /*c->AI()->IsVisible(pl)*/ && !c->IsInEvadeMode() ) 
     
    8282inline void CreatureCreatureRelocationWorker(Creature* c1, Creature* c2) 
    8383{ 
    84     if(!c1->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) 
     84    if(c1->isAggressive() && !c1->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) 
    8585    { 
    8686        if( c1->AI() && c1->IsWithinSightDist(c2) /*c1->AI()->IsVisible(c2)*/ && !c1->IsInEvadeMode() ) 
     
    8888    } 
    8989 
    90     if(!c2->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) 
     90    if(c2->isAggressive() && !c2->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) 
    9191    { 
    9292        if( c2->AI() && c1->IsWithinSightDist(c2) /*c2->AI()->IsVisible(c1)*/ && !c2->IsInEvadeMode() ) 
  • trunk/src/game/Pet.cpp

    r262 r265  
    14671467 
    14681468    // same spells don't have autocast option 
    1469     if (spellInfo->AttributesEx & SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET) active = ACT_CAST; 
     1469    if (spellInfo->AttributesEx & SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET) 
     1470        active = ACT_CAST; 
    14701471 
    14711472    PetSpellMap::iterator itr = m_spells.find(spell_id); 
     
    15431544        CastSpell(this, spell_id, true); 
    15441545    else if(state == PETSPELL_NEW) 
    1545         m_charmInfo->AddSpellToAB(oldspell_id, spell_id, active); 
     1546        m_charmInfo->AddSpellToAB(oldspell_id, spell_id, (ActiveStates)active); 
    15461547 
    15471548    if(newspell->active == ACT_ENABLED) 
  • trunk/src/game/SpellMgr.cpp

    r264 r265  
    10731073    else if(spellInfo_1->SpellFamilyName == SPELLFAMILY_POTION) 
    10741074    { 
    1075         if(spellId_spec_1 || spellId_spec_2)) 
     1075        if(spellId_spec_1 || spellId_spec_2) 
    10761076            return false; 
    10771077    } 
  • trunk/src/game/Totem.cpp

    r126 r265  
    9898        default: break; 
    9999    } 
     100 
     101    if(GetEntry() == SENTRY_TOTEM_ENTRY) 
     102        SetAggressive(true); 
    100103} 
    101104 
  • trunk/src/game/Unit.cpp

    r264 r265  
    84928492        target->SetStandState(PLAYER_STATE_NONE); 
    84938493 
    8494     if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER && ((Creature*)target)->AI()) 
     8494    if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER 
     8495        && ((Creature*)target)->isAggressive() && ((Creature*)target)->AI()) 
    84958496        ((Creature*)target)->AI()->AttackStart(this); 
    84968497