aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormegamage <none@none>2009-04-15 12:05:59 -0500
committermegamage <none@none>2009-04-15 12:05:59 -0500
commit8e910aca6b84f407d16f8db9cbe6d3ec093ba57f (patch)
treee6e3307c4d8ec7e83aec79347818afab1704e512 /src
parent80892196951a0bd6559341d03dde764c88c4d296 (diff)
parent57b33b244f281119e41f83f8b8655bb0042ec24d (diff)
*Merge.
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/bindings/scripts/include/sc_creature.h2
-rw-r--r--src/game/Creature.cpp2
-rw-r--r--src/game/CreatureAI.cpp24
-rw-r--r--src/game/CreatureAI.h3
-rw-r--r--src/game/Spell.cpp9
-rw-r--r--src/game/SpellAuras.cpp11
-rw-r--r--src/game/SpellAuras.h2
7 files changed, 23 insertions, 30 deletions
diff --git a/src/bindings/scripts/include/sc_creature.h b/src/bindings/scripts/include/sc_creature.h
index 61a82bb6dd5..03194e9a3a9 100644
--- a/src/bindings/scripts/include/sc_creature.h
+++ b/src/bindings/scripts/include/sc_creature.h
@@ -108,7 +108,7 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
//*************
//Called at creature reset either by death or evade
- virtual void Reset() = 0;
+ void Reset() {}
//Called at creature aggro either by MoveInLOS or Attack Start
virtual void Aggro(Unit*) = 0;
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 71631e4bdbc..f03fe50aaff 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -618,7 +618,7 @@ bool Creature::AIM_Initialize(CreatureAI* ai)
i_AI = ai ? ai : FactorySelector::selectAI(this);
if(oldAI) delete oldAI;
IsAIEnabled = true;
- i_AI->Reset();
+ i_AI->InitializeAI();
return true;
}
diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp
index fdd145737ab..59df2e866f2 100644
--- a/src/game/CreatureAI.cpp
+++ b/src/game/CreatureAI.cpp
@@ -23,6 +23,7 @@
#include "Player.h"
#include "Pet.h"
#include "SpellAuras.h"
+#include "World.h"
void UnitAI::AttackStart(Unit *victim)
{
@@ -104,22 +105,15 @@ void CreatureAI::DoZoneInCombat(Unit* pUnit)
void CreatureAI::MoveInLineOfSight(Unit *who)
{
- if(!me->getVictim() && me->canStartAttack(who))
- AttackStart(who);
+ if(me->getVictim())
+ return;
- if (who->isInCombat() && who->getVictim() && me->GetCreatureType()==CREATURE_TYPE_HUMANOID && me->IsFriendlyTo(who))
- {
- if (me->GetDistanceZ(who) <= 2 && me->IsWithinLOSInMap(who))
- {
- float attackRadius = (me->GetAttackDistance(who) *0.5);
- if (me->IsWithinDistInMap(who, attackRadius))
- {
- Unit* target = NULL;
- target = who->getVictim();
- AttackStart(target);
- }
- }
- }
+ if(me->canStartAttack(who))
+ AttackStart(who);
+ else if(who->getVictim() && me->IsFriendlyTo(who)
+ && me->IsWithinDistInMap(who, sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS))
+ && me->canAttack(who->getVictim()))
+ AttackStart(who->getVictim());
}
bool CreatureAI::UpdateVictim()
diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h
index 6d7026a9766..c968f07532a 100644
--- a/src/game/CreatureAI.h
+++ b/src/game/CreatureAI.h
@@ -79,7 +79,8 @@ class TRINITY_DLL_SPEC UnitAI
virtual void AttackStart(Unit *);
virtual void UpdateAI(const uint32 diff) = 0;
- // Initialize
+ virtual void InitializeAI() { Reset(); }
+
virtual void Reset() {};
// Called when unit is charmed
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 82293f91f34..25149245037 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -2045,14 +2045,7 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
if(m_spellInfo->Id == 5246) //Intimidating Shout
TagUnitMap.remove(m_targets.getUnitTarget());
- // remove random units from the map
- std::list<Unit*>::iterator itr;
- while(TagUnitMap.size() > unMaxTargets)
- {
- itr = TagUnitMap.begin();
- advance(itr, urand(0, TagUnitMap.size() - 1));
- TagUnitMap.erase(itr);
- }
+ Trinity::RandomResizeList(TagUnitMap, unMaxTargets);
/*if(m_spellInfo->Id==57669) //Replenishment (special target selection)
{
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 08ce7a59844..b70da73b6b1 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -454,7 +454,7 @@ Aura::~Aura()
AuraEffect::AuraEffect(Aura * parentAura, uint8 effIndex, int32 * currentBasePoints , Unit * caster, Item* castItem) :
m_parentAura(parentAura), m_spellmod(NULL), m_periodicTimer(0), m_isPeriodic(false), m_isAreaAura(false), m_isPersistent(false),
-m_target(parentAura->GetTarget())
+m_target(parentAura->GetTarget()), m_tickNumber(0)
{
m_spellProto = parentAura->GetSpellProto();
m_effIndex = effIndex;
@@ -696,6 +696,8 @@ void AuraEffect::Update(uint32 diff)
m_periodicTimer -= diff;
if(m_periodicTimer <= 0) // tick also at m_periodicTimer==0 to prevent lost last tick in case max m_duration == (max m_periodicTimer)*N
{
+ ++m_tickNumber;
+
// update before applying (aura can be removed in TriggerSpell or PeriodicTick calls)
m_periodicTimer += m_amplitude;
@@ -5668,7 +5670,7 @@ void AuraEffect::PeriodicTick()
break;
}
}
- m_amount += 100;
+ m_amount = 100 * m_tickNumber;
}break;
default:
break;
@@ -5700,11 +5702,12 @@ void AuraEffect::PeriodicTick()
// Curse of Agony damage-per-tick calculation
if (GetSpellProto()->SpellFamilyName==SPELLFAMILY_WARLOCK && (GetSpellProto()->SpellFamilyFlags[0] & 0x400) && GetSpellProto()->SpellIconID==544)
{
+ uint32 totalTick = GetParentAura()->GetAuraMaxDuration() / m_amplitude;
// 1..4 ticks, 1/2 from normal tick damage
- if (GetParentAura()->GetAuraDuration()>=((GetParentAura()->GetAuraMaxDuration()-m_amplitude)*2/3))
+ if(m_tickNumber <= totalTick / 3)
pdamage = pdamage/2;
// 9..12 ticks, 3/2 from normal tick damage
- else if(GetParentAura()->GetAuraDuration()<((GetParentAura()->GetAuraMaxDuration()-m_amplitude)/3))
+ else if(m_tickNumber > totalTick * 2 / 3)
pdamage += (pdamage+1)/2; // +1 prevent 0.5 damage possible lost at 1..4 ticks
// 5..8 ticks have normal tick damage
}
diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h
index fe9c18d19b5..14d43070fe1 100644
--- a/src/game/SpellAuras.h
+++ b/src/game/SpellAuras.h
@@ -338,6 +338,7 @@ class TRINITY_DLL_SPEC AuraEffect
int32 GetAuraAmplitude(){return m_amplitude;}
virtual void Update(uint32 diff);
+ uint32 GetTickNumber() const { return m_tickNumber; }
bool IsAreaAura() const { return m_isAreaAura; }
bool IsPeriodic() const { return m_isPeriodic; }
bool IsPersistent() const { return m_isPersistent; }
@@ -366,6 +367,7 @@ class TRINITY_DLL_SPEC AuraEffect
Unit * const m_target;
SpellEntry const *m_spellProto;
+ uint32 m_tickNumber;
uint8 m_effIndex;
AuraType m_auraName;