*Add m_isAggressive. Only aggressive creatures will call AttackStart and MoveInLineOfSight.

*Set melee dmg school for summoned creatures.
*Fix some compiling errors.

--HG--
branch : trunk
This commit is contained in:
megamage
2008-11-20 18:54:50 -06:00
parent 182c997573
commit 2c95ee4b31
7 changed files with 23 additions and 10 deletions
+8 -3
View File
@@ -122,7 +122,7 @@ Unit(), i_AI(NULL), i_AI_possessed(NULL),
lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0), lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0),
m_lootMoney(0), m_lootRecipient(0), m_lootMoney(0), m_lootRecipient(0),
m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f), m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f),
m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false), m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false), m_isAggressive(true),
m_regenTimer(2000), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0), m_regenTimer(2000), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0),
m_AlreadyCallAssistence(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false), m_AlreadyCallAssistence(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false),
m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),m_creatureInfo(NULL), m_DBTableGuid(0) m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),m_creatureInfo(NULL), m_DBTableGuid(0)
@@ -293,6 +293,7 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data )
SetUInt32Value(UNIT_FIELD_FLAGS,GetCreatureInfo()->unit_flags); SetUInt32Value(UNIT_FIELD_FLAGS,GetCreatureInfo()->unit_flags);
SetUInt32Value(UNIT_DYNAMIC_FLAGS,GetCreatureInfo()->dynamicflags); SetUInt32Value(UNIT_DYNAMIC_FLAGS,GetCreatureInfo()->dynamicflags);
SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool));
SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(GetCreatureInfo()->armor)); SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(GetCreatureInfo()->armor));
SetModifierValue(UNIT_MOD_RESISTANCE_HOLY, BASE_VALUE, float(GetCreatureInfo()->resistance1)); SetModifierValue(UNIT_MOD_RESISTANCE_HOLY, BASE_VALUE, float(GetCreatureInfo()->resistance1));
SetModifierValue(UNIT_MOD_RESISTANCE_FIRE, BASE_VALUE, float(GetCreatureInfo()->resistance2)); SetModifierValue(UNIT_MOD_RESISTANCE_FIRE, BASE_VALUE, float(GetCreatureInfo()->resistance2));
@@ -323,6 +324,12 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data )
if(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER) if(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER)
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
if(isTotem() || isCivilian() || GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER
|| GetCreatureType() == CREATURE_TYPE_CRITTER)
m_isAggressive = false;
else
m_isAggressive = true;
return true; return true;
} }
@@ -1410,8 +1417,6 @@ bool Creature::LoadFromDB(uint32 guid, Map *map)
SetHealth(m_deathState == ALIVE ? curhealth : 0); SetHealth(m_deathState == ALIVE ? curhealth : 0);
SetPower(POWER_MANA,data->curmana); SetPower(POWER_MANA,data->curmana);
SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool));
// checked at creature_template loading // checked at creature_template loading
m_defaultMovementType = MovementGeneratorType(data->movementType); m_defaultMovementType = MovementGeneratorType(data->movementType);
+3
View File
@@ -426,6 +426,8 @@ class TRINITY_DLL_SPEC Creature : public Unit
bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; } bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; }
bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; } bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; }
bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; } bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; }
bool isAggressive() const { return m_isAggressive; }
void SetAggressive(bool agg) { m_isAggressive = agg; }
///// TODO RENAME THIS!!!!! ///// TODO RENAME THIS!!!!!
bool isCanTrainingOf(Player* player, bool msg) const; bool isCanTrainingOf(Player* player, bool msg) const;
bool isCanIneractWithBattleMaster(Player* player, bool msg) const; bool isCanIneractWithBattleMaster(Player* player, bool msg) const;
@@ -636,6 +638,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
uint8 m_emoteState; uint8 m_emoteState;
bool m_isPet; // set only in Pet::Pet bool m_isPet; // set only in Pet::Pet
bool m_isTotem; // set only in Totem::Totem bool m_isTotem; // set only in Totem::Totem
bool m_isAggressive;
void RegenerateMana(); void RegenerateMana();
void RegenerateHealth(); void RegenerateHealth();
uint32 m_regenTimer; uint32 m_regenTimer;
+3 -3
View File
@@ -72,7 +72,7 @@ inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c)
pl->UpdateVisibilityOf(c); pl->UpdateVisibilityOf(c);
// Creature AI reaction // Creature AI reaction
if(!c->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) if(c->isAggressive() && !c->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
{ {
if( c->AI() && c->IsWithinSightDist(pl) /*c->AI()->IsVisible(pl)*/ && !c->IsInEvadeMode() ) if( c->AI() && c->IsWithinSightDist(pl) /*c->AI()->IsVisible(pl)*/ && !c->IsInEvadeMode() )
c->AI()->MoveInLineOfSight(pl); c->AI()->MoveInLineOfSight(pl);
@@ -81,13 +81,13 @@ inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c)
inline void CreatureCreatureRelocationWorker(Creature* c1, Creature* c2) inline void CreatureCreatureRelocationWorker(Creature* c1, Creature* c2)
{ {
if(!c1->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) if(c1->isAggressive() && !c1->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
{ {
if( c1->AI() && c1->IsWithinSightDist(c2) /*c1->AI()->IsVisible(c2)*/ && !c1->IsInEvadeMode() ) if( c1->AI() && c1->IsWithinSightDist(c2) /*c1->AI()->IsVisible(c2)*/ && !c1->IsInEvadeMode() )
c1->AI()->MoveInLineOfSight(c2); c1->AI()->MoveInLineOfSight(c2);
} }
if(!c2->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) if(c2->isAggressive() && !c2->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
{ {
if( c2->AI() && c1->IsWithinSightDist(c2) /*c2->AI()->IsVisible(c1)*/ && !c2->IsInEvadeMode() ) if( c2->AI() && c1->IsWithinSightDist(c2) /*c2->AI()->IsVisible(c1)*/ && !c2->IsInEvadeMode() )
c2->AI()->MoveInLineOfSight(c1); c2->AI()->MoveInLineOfSight(c1);
+3 -2
View File
@@ -1466,7 +1466,8 @@ bool Pet::addSpell(uint16 spell_id, uint16 active, PetSpellState state, uint16 s
} }
// same spells don't have autocast option // same spells don't have autocast option
if (spellInfo->AttributesEx & SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET) active = ACT_CAST; if (spellInfo->AttributesEx & SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET)
active = ACT_CAST;
PetSpellMap::iterator itr = m_spells.find(spell_id); PetSpellMap::iterator itr = m_spells.find(spell_id);
if (itr != m_spells.end()) if (itr != m_spells.end())
@@ -1542,7 +1543,7 @@ bool Pet::addSpell(uint16 spell_id, uint16 active, PetSpellState state, uint16 s
if (IsPassiveSpell(spell_id)) if (IsPassiveSpell(spell_id))
CastSpell(this, spell_id, true); CastSpell(this, spell_id, true);
else if(state == PETSPELL_NEW) else if(state == PETSPELL_NEW)
m_charmInfo->AddSpellToAB(oldspell_id, spell_id, active); m_charmInfo->AddSpellToAB(oldspell_id, spell_id, (ActiveStates)active);
if(newspell->active == ACT_ENABLED) if(newspell->active == ACT_ENABLED)
ToggleAutocast(spell_id, true); ToggleAutocast(spell_id, true);
+1 -1
View File
@@ -1072,7 +1072,7 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2, bool
// if both elixirs are not battle/guardian/potions/flasks then always stack // if both elixirs are not battle/guardian/potions/flasks then always stack
else if(spellInfo_1->SpellFamilyName == SPELLFAMILY_POTION) else if(spellInfo_1->SpellFamilyName == SPELLFAMILY_POTION)
{ {
if(spellId_spec_1 || spellId_spec_2)) if(spellId_spec_1 || spellId_spec_2)
return false; return false;
} }
+3
View File
@@ -97,6 +97,9 @@ void Totem::Summon(Unit* owner)
case TOTEM_STATUE: CastSpell(GetOwner(), GetSpell(), true); break; case TOTEM_STATUE: CastSpell(GetOwner(), GetSpell(), true); break;
default: break; default: break;
} }
if(GetEntry() == SENTRY_TOTEM_ENTRY)
SetAggressive(true);
} }
void Totem::UnSummon() void Totem::UnSummon()
+2 -1
View File
@@ -8491,7 +8491,8 @@ void Unit::CombatStart(Unit* target)
if(!target->IsStandState() && !target->hasUnitState(UNIT_STAT_STUNNED)) if(!target->IsStandState() && !target->hasUnitState(UNIT_STAT_STUNNED))
target->SetStandState(PLAYER_STATE_NONE); target->SetStandState(PLAYER_STATE_NONE);
if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER && ((Creature*)target)->AI()) if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER
&& ((Creature*)target)->isAggressive() && ((Creature*)target)->AI())
((Creature*)target)->AI()->AttackStart(this); ((Creature*)target)->AI()->AttackStart(this);
SetInCombatWith(target); SetInCombatWith(target);