*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:
@@ -122,7 +122,7 @@ Unit(), i_AI(NULL), i_AI_possessed(NULL),
|
||||
lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0),
|
||||
m_lootMoney(0), m_lootRecipient(0),
|
||||
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_AlreadyCallAssistence(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false),
|
||||
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_DYNAMIC_FLAGS,GetCreatureInfo()->dynamicflags);
|
||||
|
||||
SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool));
|
||||
SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(GetCreatureInfo()->armor));
|
||||
SetModifierValue(UNIT_MOD_RESISTANCE_HOLY, BASE_VALUE, float(GetCreatureInfo()->resistance1));
|
||||
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)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1410,8 +1417,6 @@ bool Creature::LoadFromDB(uint32 guid, Map *map)
|
||||
SetHealth(m_deathState == ALIVE ? curhealth : 0);
|
||||
SetPower(POWER_MANA,data->curmana);
|
||||
|
||||
SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool));
|
||||
|
||||
// checked at creature_template loading
|
||||
m_defaultMovementType = MovementGeneratorType(data->movementType);
|
||||
|
||||
|
||||
@@ -426,6 +426,8 @@ class TRINITY_DLL_SPEC Creature : public Unit
|
||||
bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; }
|
||||
bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; }
|
||||
bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; }
|
||||
bool isAggressive() const { return m_isAggressive; }
|
||||
void SetAggressive(bool agg) { m_isAggressive = agg; }
|
||||
///// TODO RENAME THIS!!!!!
|
||||
bool isCanTrainingOf(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;
|
||||
bool m_isPet; // set only in Pet::Pet
|
||||
bool m_isTotem; // set only in Totem::Totem
|
||||
bool m_isAggressive;
|
||||
void RegenerateMana();
|
||||
void RegenerateHealth();
|
||||
uint32 m_regenTimer;
|
||||
|
||||
@@ -72,7 +72,7 @@ inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c)
|
||||
pl->UpdateVisibilityOf(c);
|
||||
|
||||
// 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() )
|
||||
c->AI()->MoveInLineOfSight(pl);
|
||||
@@ -81,13 +81,13 @@ inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c)
|
||||
|
||||
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() )
|
||||
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() )
|
||||
c2->AI()->MoveInLineOfSight(c1);
|
||||
|
||||
+3
-2
@@ -1466,7 +1466,8 @@ bool Pet::addSpell(uint16 spell_id, uint16 active, PetSpellState state, uint16 s
|
||||
}
|
||||
|
||||
// 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);
|
||||
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))
|
||||
CastSpell(this, spell_id, true);
|
||||
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)
|
||||
ToggleAutocast(spell_id, true);
|
||||
|
||||
@@ -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
|
||||
else if(spellInfo_1->SpellFamilyName == SPELLFAMILY_POTION)
|
||||
{
|
||||
if(spellId_spec_1 || spellId_spec_2))
|
||||
if(spellId_spec_1 || spellId_spec_2)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,9 @@ void Totem::Summon(Unit* owner)
|
||||
case TOTEM_STATUE: CastSpell(GetOwner(), GetSpell(), true); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if(GetEntry() == SENTRY_TOTEM_ENTRY)
|
||||
SetAggressive(true);
|
||||
}
|
||||
|
||||
void Totem::UnSummon()
|
||||
|
||||
+2
-1
@@ -8491,7 +8491,8 @@ void Unit::CombatStart(Unit* target)
|
||||
if(!target->IsStandState() && !target->hasUnitState(UNIT_STAT_STUNNED))
|
||||
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);
|
||||
|
||||
SetInCombatWith(target);
|
||||
|
||||
Reference in New Issue
Block a user