aboutsummaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authormegamage <none@none>2008-12-10 20:25:47 -0600
committermegamage <none@none>2008-12-10 20:25:47 -0600
commit39083f4ff837d23cc886338fc9bc74df90fe9613 (patch)
tree5c2e0860894a6ac435f6035b9fab166a35c3d278 /src/game
parent0029017e17b9a2fded77e1680cef9dbc3aebacff (diff)
*Add function SummonTrigger and allow to override its AI.
*Remove some trigger scripts. Use default trigger AI and db data instead. *Small fix on eagle boss' electrical storm. --HG-- branch : trunk
Diffstat (limited to 'src/game')
-rw-r--r--src/game/Creature.cpp8
-rw-r--r--src/game/Creature.h3
-rw-r--r--src/game/GameObject.cpp2
-rw-r--r--src/game/Object.cpp19
-rw-r--r--src/game/Object.h2
-rw-r--r--src/game/SpellAuras.cpp7
-rw-r--r--src/game/Unit.h2
7 files changed, 37 insertions, 6 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 3e2a6e72dfd..3afc23c3ba4 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -347,10 +347,10 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data )
m_spells[3] = GetCreatureInfo()->spell4;
// HACK: trigger creature is always not selectable
- if(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER)
+ if(isTrigger())
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
- if(isTotem() || GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER
+ if(isTotem() || isTrigger()
|| GetCreatureType() == CREATURE_TYPE_CRITTER)
SetReactState(REACT_PASSIVE);
else if(isCivilian())
@@ -563,7 +563,7 @@ void Creature::RegenerateHealth()
ModifyHealth(addvalue);
}
-bool Creature::AIM_Initialize()
+bool Creature::AIM_Initialize(CreatureAI* ai)
{
// make sure nothing can change the AI during AI update
if(m_AI_locked)
@@ -578,7 +578,7 @@ bool Creature::AIM_Initialize()
CreatureAI * oldAI = i_AI;
i_motionMaster.Initialize();
- i_AI = FactorySelector::selectAI(this);
+ i_AI = ai ? ai : FactorySelector::selectAI(this);
if (oldAI)
delete oldAI;
return true;
diff --git a/src/game/Creature.h b/src/game/Creature.h
index 457e88cc3e3..9a76b293266 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -426,6 +426,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
bool isTotem() const { return m_isTotem; }
bool isRacialLeader() const { return GetCreatureInfo()->RacialLeader; }
bool isCivilian() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; }
+ bool isTrigger() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER; }
bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; }
bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; }
bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; }
@@ -462,7 +463,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
bool IsInEvadeMode() const;
- bool AIM_Initialize();
+ bool AIM_Initialize(CreatureAI* ai = NULL);
void InitPossessedAI();
void DisablePossessedAI();
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index 7008798b806..e43b703d3cb 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -1277,7 +1277,7 @@ void GameObject::Use(Unit* user)
void GameObject::CastSpell(Unit* target, uint32 spell)
{
//summon world trigger
- Creature *trigger = SummonCreature(12999, GetPositionX(), GetPositionY(), GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 1);
+ Creature *trigger = SummonTrigger(GetPositionX(), GetPositionY(), GetPositionZ(), 0, 1);
if(!trigger) return;
trigger->SetVisibility(VISIBILITY_OFF); //should this be true?
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index 35a021ac7c7..2872f29cdaf 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -1534,6 +1534,25 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float
return go;
}
+Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint32 duration, CreatureAI* (*GetAI)(Creature*))
+{
+ TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
+ Creature* summon = SummonCreature(WORLD_TRIGGER, x, y, z, ang, summonType, 0);
+ if(!summon)
+ return NULL;
+
+ //summon->SetName(GetName());
+ if(GetTypeId()==TYPEID_PLAYER || GetTypeId()==TYPEID_UNIT)
+ {
+ summon->setFaction(((Unit*)this)->getFaction());
+ summon->SetLevel(((Unit*)this)->getLevel());
+ }
+
+ if(GetAI)
+ summon->AIM_Initialize(GetAI(summon));
+ return summon;
+}
+
void WorldObject::GetNearPoint2D(float &x, float &y, float distance2d, float absAngle ) const
{
x = GetPositionX() + (GetObjectSize() + distance2d) * cos(absAngle);
diff --git a/src/game/Object.h b/src/game/Object.h
index 2fcd6692288..a63458e6133 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -28,6 +28,7 @@
#include "GameSystem/GridReference.h"
#include "ObjectDefines.h"
#include "GridDefines.h"
+#include "CreatureAI.h"
#include <set>
#include <string>
@@ -457,6 +458,7 @@ class TRINITY_DLL_SPEC WorldObject : public Object
Map const* GetBaseMap() const;
Creature* SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime);
GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime);
+ Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = NULL);
bool isActive() const { return m_isActive; }
void setActive(bool isActive);
protected:
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index cca1b80a53c..9f8323c735c 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -2079,6 +2079,13 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
}
return;
}
+
+ // electrical storm safe zone
+ if (GetId() == 44007)
+ {
+ m_target->ApplySpellImmune(44007, IMMUNITY_ID, 43657, apply);
+ return;
+ }
break;
}
case SPELLFAMILY_MAGE:
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 258c4f0ffd7..8f06d09029f 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -37,6 +37,8 @@
#include "Database/DBCStructure.h"
#include <list>
+#define WORLD_TRIGGER 12999
+
enum SpellInterruptFlags
{
SPELL_INTERRUPT_FLAG_MOVEMENT = 0x01, // why need this for instant?