aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/updates/3233_world_scripts_naxx.sql28
-rw-r--r--sql/updates/3257_world_creature_addon_(waypoint).sql2
-rw-r--r--sql/updates/3257_world_waypoint_data_converter.sql6
-rw-r--r--src/bindings/scripts/include/precompiled.h3
-rw-r--r--src/bindings/scripts/include/sc_creature.cpp26
-rw-r--r--src/bindings/scripts/include/sc_creature.h24
-rw-r--r--src/bindings/scripts/include/sc_instance.h13
-rw-r--r--src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp2
-rw-r--r--src/bindings/scripts/scripts/zone/azjol_nerub/ahnkahet/instance_ahnkahet.cpp2
-rw-r--r--src/bindings/scripts/scripts/zone/azjol_nerub/azjol_nerub/instance_azjol_nerub.cpp2
-rw-r--r--src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp4
-rw-r--r--src/bindings/scripts/scripts/zone/black_temple/instance_black_temple.cpp2
-rw-r--r--src/bindings/scripts/scripts/zone/blackrock_depths/instance_blackrock_depths.cpp2
-rw-r--r--src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp2
-rw-r--r--src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp2
-rw-r--r--src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp2
-rw-r--r--src/bindings/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp2
-rw-r--r--src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp2
-rw-r--r--src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp129
-rw-r--r--src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp7
-rw-r--r--src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp4
-rw-r--r--src/bindings/scripts/scripts/zone/naxxramas/instance_naxxramas.cpp20
-rw-r--r--src/bindings/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp2
-rw-r--r--src/bindings/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp2
-rw-r--r--src/bindings/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp2
-rw-r--r--src/bindings/scripts/scripts/zone/utgarde_keep/utgarde_keep/instance_utgarde_keep.cpp2
-rw-r--r--src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp2
-rw-r--r--src/game/AggressorAI.h2
-rw-r--r--src/game/Creature.cpp27
-rw-r--r--src/game/Creature.h9
-rw-r--r--src/game/CreatureAI.cpp2
-rw-r--r--src/game/CreatureAI.h2
-rw-r--r--src/game/InstanceData.cpp41
-rw-r--r--src/game/InstanceData.h21
-rw-r--r--src/game/InstanceSaveMgr.cpp8
-rw-r--r--src/game/Level2.cpp71
-rw-r--r--src/game/Map.cpp2
-rw-r--r--src/game/NullCreatureAI.h18
-rw-r--r--src/game/SpellMgr.cpp30
-rw-r--r--src/game/TemporarySummon.h2
-rw-r--r--src/game/UnitAI.cpp1
-rw-r--r--src/game/WaypointManager.cpp21
-rw-r--r--src/game/WaypointManager.h11
-rw-r--r--src/game/WaypointMovementGenerator.cpp6
-rw-r--r--src/game/WaypointMovementGenerator.h4
-rw-r--r--src/shared/Database/SQLStorage.cpp4
46 files changed, 308 insertions, 270 deletions
diff --git a/sql/updates/3233_world_scripts_naxx.sql b/sql/updates/3233_world_scripts_naxx.sql
index d84a4462537..8b8140c17fe 100644
--- a/sql/updates/3233_world_scripts_naxx.sql
+++ b/sql/updates/3233_world_scripts_naxx.sql
@@ -1,5 +1,7 @@
-DELETE FROM `spell_linked_spell` WHERE `spell_trigger` IN (-28169);
+DELETE FROM `spell_linked_spell` WHERE `spell_trigger` IN (-28169,28732,54097);
INSERT INTO `spell_linked_spell` (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES
+( 28732,-28798, 1, 'Widow\'s Embrace - Frenzy'),
+( 54097,-54100, 1, 'Widow\'s Embrace - Frenzy (H)'),
(-28169, 28206, 0, 'Mutating Injection - Mutagen Explosion'),
(-28169, 28240, 0, 'Mutating Injection - Poison Cloud');
@@ -26,19 +28,33 @@ DELETE FROM `npc_spellclick_spells` WHERE `npc_entry` IN (29912);
INSERT INTO `npc_spellclick_spells` (`npc_entry`, `spell_id`, `quest_id`, `cast_flags`) VALUES
(29912, 55479, 0, 1); # Obedience Crystal - Force Obedience
-DELETE FROM `spell_script_target` WHERE `entry` IN (55479);
+DELETE FROM `spell_script_target` WHERE `entry` IN
+(28732,54097,55479,
+27892,27893,27928,27929,27935,27936);
INSERT INTO `spell_script_target` (`entry`, `type`, `targetEntry`) VALUES
-(55479, 1, 16803); # Force Obedience - Death Knight Understudy
+(28732, 1, 15953), # Widow's Embrace
+(54097, 1, 15953), # Widow's Embrace
+(55479, 1, 16803), # Force Obedience - Death Knight Understudy
+# (29105, 1, 16803), # Hopeless - Death Knight Understudy
+(27892, 1, 16060), # To Anchor 1 - Gothik
+(27893, 1, 16060), # To Anchor 2 - Gothik
+(27928, 1, 16060), # To Anchor 1 - Gothik
+(27929, 1, 16060), # To Anchor 2 - Gothik
+(27935, 1, 16060), # To Anchor 1 - Gothik
+(27936, 1, 16060); # To Anchor 2 - Gothik
+
INSERT INTO creature_template (entry, spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8) VALUES
-(16803, 0, 0, 0, 61696, 29060, 29061, 0, 0), # Death Knight Understudy
-(29941, 0, 0, 0, 61696, 29060, 29061, 0, 0), # Death Knight Understudy (H)
(16573, 15284, 28991, 28969, 34970, 28864, 0, 0, 0), # Crypt Guard
(29256, 15284, 28991, 56098, 34970, 28864, 0, 0, 0), # Crypt Guard (H)
+(16506, 54095, 28732, 0, 0, 0, 0, 0, 0), # Naxxramas Worshipper
+(29274, 54096, 54097, 0, 0, 0, 0, 0, 0), # Naxxramas Worshipper (H)
(16984, 15496, 0, 0, 0, 0, 0, 0, 0), # Plagued Warrior
(29632, 15496, 0, 0, 0, 0, 0, 0, 0), # Plagued Warrior (H)
(16290, 28156, 0, 0, 0, 0, 0, 0, 0), # Fallout Slime
-(29388, 54367, 0, 0, 0, 0, 0, 0, 0) # Fallout Slime (H)
+(29388, 54367, 0, 0, 0, 0, 0, 0, 0), # Fallout Slime (H)
+(16803, 0, 0, 0, 61696, 29060, 29061, 0, 0), # Death Knight Understudy
+(29941, 0, 0, 0, 61696, 29060, 29061, 0, 0) # Death Knight Understudy (H)
ON DUPLICATE KEY UPDATE
spell1 = VALUES(spell1),
spell2 = VALUES(spell2),
diff --git a/sql/updates/3257_world_creature_addon_(waypoint).sql b/sql/updates/3257_world_creature_addon_(waypoint).sql
new file mode 100644
index 00000000000..1398baf1ccd
--- /dev/null
+++ b/sql/updates/3257_world_creature_addon_(waypoint).sql
@@ -0,0 +1,2 @@
+ALTER TABLE creature_template_addon DROP COLUMN path_id;
+ALTER TABLE creature_addon DROP COLUMN path_id; \ No newline at end of file
diff --git a/sql/updates/3257_world_waypoint_data_converter.sql b/sql/updates/3257_world_waypoint_data_converter.sql
new file mode 100644
index 00000000000..3533f948747
--- /dev/null
+++ b/sql/updates/3257_world_waypoint_data_converter.sql
@@ -0,0 +1,6 @@
+ALTER TABLE waypoint_data ADD COLUMN id_old int(10) unsigned NOT NULL default '0' COMMENT 'Creature GUID' AFTER wpguid;
+UPDATE waypoint_data SET id_old=id;
+UPDATE waypoint_data,creature_addon SET waypoint_data.id=creature_addon.guid*10 WHERE creature_addon.path_id > 0 AND creature_addon.path_id=waypoint_data.id_old;
+UPDATE waypoint_data SET id = 1343801 WHERE id_old = 2084;
+UPDATE waypoint_scripts SET datalong = 1343801 WHERE id = 515;
+ALTER TABLE waypoint_data DROP COLUMN id_old; \ No newline at end of file
diff --git a/src/bindings/scripts/include/precompiled.h b/src/bindings/scripts/include/precompiled.h
index 2c36cc924e0..fa676f460ef 100644
--- a/src/bindings/scripts/include/precompiled.h
+++ b/src/bindings/scripts/include/precompiled.h
@@ -12,10 +12,11 @@
#include "GridNotifiersImpl.h"
#include "Unit.h"
#include "GameObject.h"
-#include "TemporarySummon.h"
#include "sc_creature.h"
#include "sc_gossip.h"
#include "sc_instance.h"
+#include "AggressorAI.h"
+#include "NullCreatureAI.h"
#ifdef WIN32
#include <windows.h>
diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp
index e5a6eb958e0..0b874773ffc 100644
--- a/src/bindings/scripts/include/sc_creature.cpp
+++ b/src/bindings/scripts/include/sc_creature.cpp
@@ -9,6 +9,7 @@
#include "Item.h"
#include "Spell.h"
#include "ObjectMgr.h"
+#include "TemporarySummon.h"
// Spell summary for ScriptedAI::SelectSpell
struct TSpellSummary {
@@ -56,7 +57,10 @@ void SummonList::DespawnAll()
{
erase(begin());
summon->SetVisibility(VISIBILITY_OFF);
- summon->setDeathState(JUST_DIED);
+ if(summon->HasSummonMask(SUMMON_MASK_SUMMON) && !summon->isPet())
+ ((TempSummon*)summon)->UnSummon();
+ else
+ summon->setDeathState(JUST_DIED);
summon->RemoveCorpse();
}
}
@@ -109,26 +113,6 @@ void ScriptedAI::UpdateAI(const uint32 diff)
}
}
-void ScriptedAI::EnterEvadeMode()
-{
- //m_creature->InterruptNonMeleeSpells(true);
- m_creature->RemoveAllAuras();
- m_creature->DeleteThreatList();
- m_creature->CombatStop();
- m_creature->LoadCreaturesAddon();
- m_creature->SetLootRecipient(NULL);
-
- if(m_creature->isAlive())
- m_creature->GetMotionMaster()->MoveTargetedHome();
-
- Reset();
-}
-
-void ScriptedAI::JustRespawned()
-{
- Reset();
-}
-
void ScriptedAI::DoStartMovement(Unit* victim, float distance, float angle)
{
if (!victim)
diff --git a/src/bindings/scripts/include/sc_creature.h b/src/bindings/scripts/include/sc_creature.h
index 26bf5fb400b..0fb716bbe0e 100644
--- a/src/bindings/scripts/include/sc_creature.h
+++ b/src/bindings/scripts/include/sc_creature.h
@@ -58,9 +58,6 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
void AttackStart(Unit *);
void AttackStart(Unit *, bool melee);
- //Called at stoping attack by any attacker
- void EnterEvadeMode();
-
// Called at any Damage from any attacker (before damage apply)
void DamageTaken(Unit *done_by, uint32 &damage) {}
@@ -85,9 +82,6 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
// Called when spell hits a target
void SpellHitTarget(Unit* target, const SpellEntry*) {}
- // Called when creature is spawned or respawned (for reseting variables)
- void JustRespawned();
-
//Called at waypoint reached or PointMovement end
void MovementInform(uint32 type, uint32 id){}
@@ -204,30 +198,16 @@ struct TRINITY_DLL_DECL Scripted_NoMovementAI : public ScriptedAI
void AttackStart(Unit *);
};
-struct TRINITY_DLL_DECL NullCreatureAI : public ScriptedAI
-{
- NullCreatureAI(Creature* c) : ScriptedAI(c) {}
- ~NullCreatureAI() {}
-
- void Reset() {}
- void EnterCombat(Unit*) {}
- void MoveInLineOfSight(Unit *) {}
- void AttackStart(Unit *) {}
- void EnterEvadeMode() {}
-
- void UpdateAI(const uint32) {}
-};
-
struct TRINITY_DLL_DECL BossAI : public ScriptedAI
{
BossAI(Creature *c, uint32 id) : ScriptedAI(c), bossId(id)
- , summons(me), instance((ScriptedInstance*)c->GetInstanceData())
+ , summons(me), instance(c->GetInstanceData())
{}
uint32 bossId;
EventMap events;
SummonList summons;
- ScriptedInstance *instance;
+ InstanceData *instance;
void JustSummoned(Creature *summon);
void SummonedCreatureDespawn(Creature *summon);
diff --git a/src/bindings/scripts/include/sc_instance.h b/src/bindings/scripts/include/sc_instance.h
index cdf0e03aa37..0620e89af07 100644
--- a/src/bindings/scripts/include/sc_instance.h
+++ b/src/bindings/scripts/include/sc_instance.h
@@ -17,20 +17,7 @@
class TRINITY_DLL_DECL ScriptedInstance : public InstanceData
{
public:
-
ScriptedInstance(Map *map) : InstanceData(map) {}
- ~ScriptedInstance() {}
-
- //All-purpose data storage 64 bit
- virtual uint64 GetData64(uint32 Data) { return 0; }
- virtual void SetData64(uint32 Data, uint64 Value) { }
-
- // Called every instance update
- virtual void Update(uint32) {}
-
- // Save and Load instance data to the database
- const char* Save() { return NULL; }
- void Load(const char* in) { }
};
#endif
diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp
index 3cfb0af2fa1..37194a89b21 100644
--- a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp
+++ b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp
@@ -191,7 +191,7 @@ struct TRINITY_DLL_DECL instance_shadow_labyrinth : public ScriptedInstance
return 0;
}
- const char* Save()
+ std::string GetSaveData()
{
return str_data.c_str();
}
diff --git a/src/bindings/scripts/scripts/zone/azjol_nerub/ahnkahet/instance_ahnkahet.cpp b/src/bindings/scripts/scripts/zone/azjol_nerub/ahnkahet/instance_ahnkahet.cpp
index 41cb91f86b7..595a05a727f 100644
--- a/src/bindings/scripts/scripts/zone/azjol_nerub/ahnkahet/instance_ahnkahet.cpp
+++ b/src/bindings/scripts/scripts/zone/azjol_nerub/ahnkahet/instance_ahnkahet.cpp
@@ -129,7 +129,7 @@ struct TRINITY_DLL_DECL instance_ahnkahet : public ScriptedInstance
return 0;
}
- const char* Save()
+ std::string GetSaveData()
{
OUT_SAVE_INST_DATA;
diff --git a/src/bindings/scripts/scripts/zone/azjol_nerub/azjol_nerub/instance_azjol_nerub.cpp b/src/bindings/scripts/scripts/zone/azjol_nerub/azjol_nerub/instance_azjol_nerub.cpp
index bd3fccd98d9..7e0252f2009 100644
--- a/src/bindings/scripts/scripts/zone/azjol_nerub/azjol_nerub/instance_azjol_nerub.cpp
+++ b/src/bindings/scripts/scripts/zone/azjol_nerub/azjol_nerub/instance_azjol_nerub.cpp
@@ -117,7 +117,7 @@ struct TRINITY_DLL_DECL instance_azjol_nerub : public ScriptedInstance
return 0;
}
- const char* Save()
+ std::string GetSaveData()
{
OUT_SAVE_INST_DATA;
diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp
index fdfdef396bb..ff90f7e6a81 100644
--- a/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp
+++ b/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp
@@ -53,7 +53,9 @@ EndScriptData */
struct TRINITY_DLL_DECL molten_flameAI : public NullCreatureAI
{
- molten_flameAI(Creature *c) : NullCreatureAI(c)
+ molten_flameAI(Creature *c) : NullCreatureAI(c) {}
+
+ void InitializeAI()
{
float x, y, z;
me->GetNearPoint(me, x, y, z, 1, 50, M_PI*2*rand_norm());
diff --git a/src/bindings/scripts/scripts/zone/black_temple/instance_black_temple.cpp b/src/bindings/scripts/scripts/zone/black_temple/instance_black_temple.cpp
index 43646746505..bf5d62a7b86 100644
--- a/src/bindings/scripts/scripts/zone/black_temple/instance_black_temple.cpp
+++ b/src/bindings/scripts/scripts/zone/black_temple/instance_black_temple.cpp
@@ -303,7 +303,7 @@ struct TRINITY_DLL_DECL instance_black_temple : public ScriptedInstance
return 0;
}
- const char* Save()
+ std::string GetSaveData()
{
return str_data.c_str();
}
diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/instance_blackrock_depths.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/instance_blackrock_depths.cpp
index 6e26f3a0c03..d9f3ecd808a 100644
--- a/src/bindings/scripts/scripts/zone/blackrock_depths/instance_blackrock_depths.cpp
+++ b/src/bindings/scripts/scripts/zone/blackrock_depths/instance_blackrock_depths.cpp
@@ -265,7 +265,7 @@ struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance
return 0;
}
- const char* Save()
+ std::string GetSaveData()
{
return str_data.c_str();
}
diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp
index 0dfa99198ac..cdcd6cb6b66 100644
--- a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp
+++ b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp
@@ -279,7 +279,7 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance
}else debug_log("TSCR: Instance Hyjal: UpdateWorldState, but PlayerList is empty!");
}
- const char* Save()
+ std::string GetSaveData()
{
return str_data.c_str();
}
diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp
index 6c4ae72aec1..8aa759a87c8 100644
--- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp
+++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp
@@ -236,7 +236,7 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
}
return 0;
}
- const char* Save()
+ std::string GetSaveData()
{
OUT_SAVE_INST_DATA;
std::ostringstream stream;
diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp
index 6d01da7f625..d375d073c35 100644
--- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp
+++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp
@@ -209,7 +209,7 @@ struct TRINITY_DLL_DECL instance_steam_vault : public ScriptedInstance
return 0;
}
- const char* Save()
+ std::string GetSaveData()
{
OUT_SAVE_INST_DATA;
std::ostringstream stream;
diff --git a/src/bindings/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp b/src/bindings/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp
index 34943449b1e..4c90fdf49a8 100644
--- a/src/bindings/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp
+++ b/src/bindings/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp
@@ -144,7 +144,7 @@ struct TRINITY_DLL_DECL instance_gruuls_lair : public ScriptedInstance
return 0;
}
- const char* Save()
+ std::string GetSaveData()
{
OUT_SAVE_INST_DATA;
std::ostringstream stream;
diff --git a/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp b/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp
index e8dccdd62a4..62ad6fcf42c 100644
--- a/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp
+++ b/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp
@@ -247,7 +247,7 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance
}
}
- const char* Save()
+ std::string GetSaveData()
{
return str_data.c_str();
}
diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp
index 5ec67a8920b..9ee594b02b5 100644
--- a/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp
+++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp
@@ -1,4 +1,6 @@
-/* Copyright (C) 2006 - 2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
+/*
+ * Copyright (C) 2008 - 2009 Trinity <http://www.trinitycore.org/>
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -14,83 +16,63 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* ScriptData
-SDName: Boss_Faerlina
-SD%Complete: 50
-SDComment:
-SDCategory: Naxxramas
-EndScriptData */
-
#include "precompiled.h"
+#include "def_naxxramas.h"
-#define SAY_GREET -1533009
-#define SAY_AGGRO1 -1533010
-#define SAY_AGGRO2 -1533011
-#define SAY_AGGRO3 -1533012
-#define SAY_AGGRO4 -1533013
-#define SAY_SLAY1 -1533014
-#define SAY_SLAY2 -1533015
-#define SAY_DEATH -1533016
+#define SAY_GREET -1533009
+#define SAY_AGGRO RAND(-1533010,-1533011,-1533012,-1533013)
+#define SAY_SLAY RAND(-1533014,-1533015)
+#define SAY_DEATH -1533016
//#define SOUND_RANDOM_AGGRO 8955 //soundId containing the 4 aggro sounds, we not using this
-#define SPELL_POSIONBOLT_VOLLEY 28796
-#define H_SPELL_POSIONBOLT_VOLLEY 54098
-#define SPELL_ENRAGE 28798
-#define H_SPELL_ENRAGE 54100
-#define SPELL_RAINOFFIRE 28794 //Not sure if targeted AoEs work if casted directly upon a player
+#define SPELL_POSION_BOLT_VOLLEY HEROIC(28796,54098)
+#define SPELL_RAIN_OF_FIRE HEROIC(28794,54099)
+#define SPELL_FRENZY HEROIC(28798,54100)
+#define SPELL_WIDOWS_EMBRACE HEROIC(28732,54097)
-struct TRINITY_DLL_DECL boss_faerlinaAI : public ScriptedAI
+enum Events
{
- boss_faerlinaAI(Creature *c) : ScriptedAI(c) {}
+ EVENT_POSION = 1,
+ EVENT_FIRE,
+ EVENT_FRENZY,
+};
- uint32 PoisonBoltVolley_Timer;
- uint32 RainOfFire_Timer;
- uint32 Enrage_Timer;
- bool HasTaunted;
+struct TRINITY_DLL_DECL boss_faerlinaAI : public BossAI
+{
+ boss_faerlinaAI(Creature *c) : BossAI(c, BOSS_FAERLINA), greet(false) {}
- void Reset()
- {
- PoisonBoltVolley_Timer = 8000;
- RainOfFire_Timer = 16000;
- Enrage_Timer = 60000;
- HasTaunted = false;
- }
+ bool greet;
void EnterCombat(Unit *who)
{
- switch (rand()%4)
- {
- case 0: DoScriptText(SAY_AGGRO1, m_creature); break;
- case 1: DoScriptText(SAY_AGGRO2, m_creature); break;
- case 2: DoScriptText(SAY_AGGRO3, m_creature); break;
- case 3: DoScriptText(SAY_AGGRO4, m_creature); break;
- }
+ _EnterCombat();
+ DoScriptText(SAY_AGGRO, me);
+ events.ScheduleEvent(EVENT_POSION, 10000 + rand()%15000);
+ events.ScheduleEvent(EVENT_FIRE, 5000 + rand()%15000);
+ events.ScheduleEvent(EVENT_FRENZY, 60000 + rand()%20000);
}
void MoveInLineOfSight(Unit *who)
{
- if (!HasTaunted && m_creature->IsWithinDistInMap(who, 60.0f))
- {
- DoScriptText(SAY_GREET, m_creature);
- HasTaunted = true;
-
+ if(!greet)
+ {
+ DoScriptText(SAY_GREET, me);
+ greet = true;
}
- ScriptedAI::MoveInLineOfSight(who);
+ BossAI::MoveInLineOfSight(who);
}
void KilledUnit(Unit* victim)
{
- switch (rand()%2)
- {
- case 0: DoScriptText(SAY_SLAY1, m_creature); break;
- case 1: DoScriptText(SAY_SLAY2, m_creature); break;
- }
+ if(!(rand()%3))
+ DoScriptText(SAY_SLAY, me);
}
void JustDied(Unit* Killer)
{
- DoScriptText(SAY_DEATH, m_creature);
+ _JustDied();
+ DoScriptText(SAY_DEATH, me);
}
void UpdateAI(const uint32 diff)
@@ -98,31 +80,33 @@ struct TRINITY_DLL_DECL boss_faerlinaAI : public ScriptedAI
if (!UpdateVictim())
return;
- //PoisonBoltVolley_Timer
- if (PoisonBoltVolley_Timer < diff)
- {
- DoCast(m_creature->getVictim(),SPELL_POSIONBOLT_VOLLEY);
- PoisonBoltVolley_Timer = 11000;
- }else PoisonBoltVolley_Timer -= diff;
+ events.Update(diff);
- //RainOfFire_Timer
- if (RainOfFire_Timer < diff)
+ while(uint32 eventId = events.ExecuteEvent())
{
- if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
- DoCast(target,SPELL_RAINOFFIRE);
- RainOfFire_Timer = 16000;
- }else RainOfFire_Timer -= diff;
-
- //Enrage_Timer
- if (Enrage_Timer < diff)
- {
- DoCast(m_creature,SPELL_ENRAGE);
- Enrage_Timer = 61000;
- }else Enrage_Timer -= diff;
+ switch(eventId)
+ {
+ case EVENT_POSION:
+ if(!me->HasAura(SPELL_WIDOWS_EMBRACE))
+ DoCastAOE(SPELL_POSION_BOLT_VOLLEY);
+ events.ScheduleEvent(EVENT_POSION, 10000 + rand()%15000);
+ return;
+ case EVENT_FIRE:
+ if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
+ DoCast(target, SPELL_RAIN_OF_FIRE);
+ events.ScheduleEvent(EVENT_FIRE, 5000 + rand()%15000);
+ return;
+ case EVENT_FRENZY:
+ DoCast(me,SPELL_FRENZY);
+ events.ScheduleEvent(EVENT_FRENZY, 60000 + rand()%20000);
+ return;
+ }
+ }
DoMeleeAttackIfReady();
}
};
+
CreatureAI* GetAI_boss_faerlina(Creature *_Creature)
{
return new boss_faerlinaAI (_Creature);
@@ -136,4 +120,3 @@ void AddSC_boss_faerlina()
newscript->GetAI = &GetAI_boss_faerlina;
newscript->RegisterSelf();
}
-
diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp
index a05685264d6..7886fad94cc 100644
--- a/src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp
+++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp
@@ -39,12 +39,6 @@ struct TRINITY_DLL_DECL boss_patchwerkAI : public BossAI
bool Enraged;
- void Reset()
- {
- _Reset();
- Enraged = false;
- }
-
void KilledUnit(Unit* Victim)
{
if(!(rand()%5))
@@ -60,6 +54,7 @@ struct TRINITY_DLL_DECL boss_patchwerkAI : public BossAI
void EnterCombat(Unit *who)
{
_EnterCombat();
+ Enraged = false;
DoScriptText(SAY_AGGRO, me);
events.ScheduleEvent(EVENT_HATEFUL, 1200);
events.ScheduleEvent(EVENT_BERSERK, 360000);
diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp
index 120220172cd..67fcaee7de3 100644
--- a/src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp
+++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp
@@ -42,7 +42,7 @@
#define SPELL_UNBALANCING_STRIKE 26613
#define SPELL_DISRUPTING_SHOUT HEROIC(29107,55543)
#define SPELL_JAGGED_KNIFE 55550
-#define SPELL_HOPELESS 29105
+#define SPELL_HOPELESS 29125
enum Events
{
@@ -66,7 +66,7 @@ struct TRINITY_DLL_DECL boss_razuviousAI : public BossAI
{
_JustDied();
DoPlaySoundToSet(me, SOUND_DEATH);
- me->CastSpell(me, SPELL_HOPELESS, true);
+ me->CastSpell(me, SPELL_HOPELESS, true); // TODO: this may affect other creatures
}
void EnterCombat(Unit *who)
diff --git a/src/bindings/scripts/scripts/zone/naxxramas/instance_naxxramas.cpp b/src/bindings/scripts/scripts/zone/naxxramas/instance_naxxramas.cpp
index 4dc189723f3..23f44f5daf8 100644
--- a/src/bindings/scripts/scripts/zone/naxxramas/instance_naxxramas.cpp
+++ b/src/bindings/scripts/scripts/zone/naxxramas/instance_naxxramas.cpp
@@ -77,9 +77,9 @@ inline uint32 GetEruptionSection(float x, float y)
return 3;
}
-struct TRINITY_DLL_DECL instance_naxxramas : public ScriptedInstance
+struct TRINITY_DLL_DECL instance_naxxramas : public InstanceData
{
- instance_naxxramas(Map *map) : ScriptedInstance(map)
+ instance_naxxramas(Map *map) : InstanceData(map)
, Sapphiron(NULL)
{
SetBossNumber(MAX_BOSS_NUMBER);
@@ -88,12 +88,14 @@ struct TRINITY_DLL_DECL instance_naxxramas : public ScriptedInstance
std::set<GameObject*> HeiganEruption[4];
Creature *Sapphiron;
+ std::set<Creature*> Worshipper;
void OnCreatureCreate(Creature *creature, bool add)
{
switch(creature->GetEntry())
{
case 15989: Sapphiron = add ? creature : NULL; break;
+ case 16506: if(add) Worshipper.insert(creature); else Worshipper.erase(creature); break;
}
}
@@ -117,6 +119,20 @@ struct TRINITY_DLL_DECL instance_naxxramas : public ScriptedInstance
AddDoor(go, add);
}
+ void SetBossState(uint32 id, EncounterState state)
+ {
+ InstanceData::SetBossState(id, state);
+ switch(id)
+ {
+ case BOSS_FAERLINA:
+ if(state == NOT_STARTED)
+ for(std::set<Creature*>::iterator itr = Worshipper.begin(); itr != Worshipper.end(); ++itr)
+ if(!(*itr)->isAlive())
+ (*itr)->Respawn();
+ break;
+ }
+ }
+
void SetData(uint32 id, uint32 value)
{
switch(id)
diff --git a/src/bindings/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp b/src/bindings/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp
index caf18778abb..30f843badb0 100644
--- a/src/bindings/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp
+++ b/src/bindings/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp
@@ -185,7 +185,7 @@ struct TRINITY_DLL_DECL instance_shadowfang_keep : public ScriptedInstance
return 0;
}
- const char* Save()
+ std::string GetSaveData()
{
return str_data.c_str();
}
diff --git a/src/bindings/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp b/src/bindings/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp
index f8bba5acf21..597103b62cf 100644
--- a/src/bindings/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp
+++ b/src/bindings/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp
@@ -236,7 +236,7 @@ struct TRINITY_DLL_DECL instance_sunwell_plateau : public ScriptedInstance
{
}
- const char* Save()
+ std::string GetSaveData()
{
OUT_SAVE_INST_DATA;
std::ostringstream stream;
diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp
index 66e595ab729..55ef8c60bbd 100644
--- a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp
+++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp
@@ -129,7 +129,7 @@ struct TRINITY_DLL_DECL instance_the_eye : public ScriptedInstance
return 0;
}
- const char* Save()
+ std::string GetSaveData()
{
OUT_SAVE_INST_DATA;
std::ostringstream stream;
diff --git a/src/bindings/scripts/scripts/zone/utgarde_keep/utgarde_keep/instance_utgarde_keep.cpp b/src/bindings/scripts/scripts/zone/utgarde_keep/utgarde_keep/instance_utgarde_keep.cpp
index d6f5828d295..d483006642d 100644
--- a/src/bindings/scripts/scripts/zone/utgarde_keep/utgarde_keep/instance_utgarde_keep.cpp
+++ b/src/bindings/scripts/scripts/zone/utgarde_keep/utgarde_keep/instance_utgarde_keep.cpp
@@ -231,7 +231,7 @@ struct TRINITY_DLL_DECL instance_utgarde_keep : public ScriptedInstance
return 0;
}
- const char* Save()
+ std::string GetSaveData()
{
OUT_SAVE_INST_DATA;
diff --git a/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp b/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp
index 4ebf541515b..8ff01927908 100644
--- a/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp
+++ b/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp
@@ -179,7 +179,7 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance
instance->SendToPlayers(&data);
}
- const char* Save()
+ std::string GetSaveData()
{
std::ostringstream ss;
ss << "S " << BossKilled << " " << ChestLooted << " " << QuestMinute;
diff --git a/src/game/AggressorAI.h b/src/game/AggressorAI.h
index 94a6b0b3bf1..2c43ccf82b7 100644
--- a/src/game/AggressorAI.h
+++ b/src/game/AggressorAI.h
@@ -37,7 +37,7 @@ class TRINITY_DLL_DECL AggressorAI : public CreatureAI
typedef std::vector<uint32> SpellVct;
-class TRINITY_DLL_DECL SpellAI : public CreatureAI
+class TRINITY_DLL_SPEC SpellAI : public CreatureAI
{
public:
explicit SpellAI(Creature *c) : CreatureAI(c) {}
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index a47afda5cd2..85109997390 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -175,7 +175,7 @@ void Creature::AddToWorld()
{
ObjectAccessor::Instance().AddObject(this);
Unit::AddToWorld();
- SearchFormation();
+ SearchFormationAndPath();
AIM_Initialize();
}
}
@@ -194,7 +194,7 @@ void Creature::RemoveFromWorld()
}
}
-void Creature::SearchFormation()
+void Creature::SearchFormationAndPath()
{
if(isSummon())
return;
@@ -203,9 +203,28 @@ void Creature::SearchFormation()
if(!lowguid)
return;
+ bool usePath = (GetDefaultMovementType() == WAYPOINT_MOTION_TYPE);
CreatureGroupInfoType::iterator frmdata = CreatureGroupMap.find(lowguid);
if(frmdata != CreatureGroupMap.end())
+ {
+ if(usePath && lowguid != frmdata->second->leaderGUID)
+ {
+ SetDefaultMovementType(IDLE_MOTION_TYPE);
+ usePath = false;
+ }
formation_mgr.AddCreatureToGroup(frmdata->second->leaderGUID, this);
+ }
+
+ if(usePath)
+ {
+ if(WaypointMgr.GetPath(lowguid * 10))
+ SetWaypointPathId(lowguid * 10);
+ else
+ {
+ sLog.outErrorDb("Creature DBGUID %u has waypoint motion type, but it does not have a waypoint path!", lowguid);
+ SetDefaultMovementType(IDLE_MOTION_TYPE);
+ }
+ }
}
void Creature::RemoveCorpse()
@@ -2081,10 +2100,6 @@ bool Creature::LoadCreaturesAddon(bool reload)
if (cainfo->move_flags != 0)
SetUnitMovementFlags(cainfo->move_flags);
- //Load Path
- if (cainfo->path_id != 0)
- m_path_id = cainfo->path_id;
-
if(cainfo->auras)
{
for (CreatureDataAddonAura const* cAura = cainfo->auras; cAura->spell_id; ++cAura)
diff --git a/src/game/Creature.h b/src/game/Creature.h
index b90642547dd..f57f0592da5 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -315,7 +315,6 @@ struct CreatureDataAddonAura
struct CreatureDataAddon
{
uint32 guidOrEntry;
- uint32 path_id;
uint32 mount;
uint32 bytes0;
uint32 bytes1;
@@ -692,13 +691,13 @@ class TRINITY_DLL_SPEC Creature : public Unit
uint32 GetGlobalCooldown() const { return m_GlobalCooldown; }
- uint32 GetWaypointPath(){return m_path_id;}
- void LoadPath(uint32 pathid) { m_path_id = pathid; }
+ uint32 GetWaypointPathId() const { return m_pathId; }
+ void SetWaypointPathId(uint32 pathid) { m_pathId = pathid; }
uint32 GetCurrentWaypointID(){return m_waypointID;}
void UpdateWaypointID(uint32 wpID){m_waypointID = wpID;}
- void SearchFormation();
+ void SearchFormationAndPath();
CreatureGroup *GetFormation() {return m_formation;}
void SetFormation(CreatureGroup *formation) {m_formation = formation;}
@@ -759,7 +758,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
private:
//WaypointMovementGenerator vars
uint32 m_waypointID;
- uint32 m_path_id;
+ uint32 m_pathId;
//Formation var
CreatureGroup *m_formation;
diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp
index 123fa1182a1..8633ee2e1f4 100644
--- a/src/game/CreatureAI.cpp
+++ b/src/game/CreatureAI.cpp
@@ -112,6 +112,8 @@ void CreatureAI::EnterEvadeMode()
if(me->isAlive())
me->GetMotionMaster()->MoveTargetedHome();
+
+ Reset();
}
inline bool SelectTargetHelper(const Unit * me, const Unit * target, const bool &playerOnly, const float &dist, const int32 &aura)
diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h
index 7568b815394..605e904c71a 100644
--- a/src/game/CreatureAI.h
+++ b/src/game/CreatureAI.h
@@ -124,7 +124,7 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI
//virtual void AttackedBy(Unit* attacker);
// Called when creature is spawned or respawned (for reseting variables)
- virtual void JustRespawned() {}
+ virtual void JustRespawned() { Reset(); }
// Called at waypoint reached or point movement finished
virtual void MovementInform(uint32 /*MovementType*/, uint32 /*Data*/) {}
diff --git a/src/game/InstanceData.cpp b/src/game/InstanceData.cpp
index 80e728f7b3c..96c10f7b85c 100644
--- a/src/game/InstanceData.cpp
+++ b/src/game/InstanceData.cpp
@@ -26,8 +26,9 @@
void InstanceData::SaveToDB()
{
- if(!Save()) return;
- std::string data = Save();
+ std::string data = GetSaveData();
+ if(data.empty())
+ return;
CharacterDatabase.escape_string(data);
CharacterDatabase.PExecute("UPDATE instance SET data = '%s' WHERE id = '%d'", data.c_str(), instance->GetInstanceId());
}
@@ -124,13 +125,41 @@ void InstanceData::SetBossState(uint32 id, EncounterState state)
if(id < bosses.size())
{
BossInfo *bossInfo = &bosses[id];
- if(bossInfo->state == state)
- return;
-
- bossInfo->state = state;
+ if(bossInfo->state == TO_BE_DECIDED) // loading
+ bossInfo->state = state;
+ else
+ {
+ if(bossInfo->state == state)
+ return;
+ bossInfo->state = state;
+ SaveToDB();
+ }
+
for(uint32 type = 0; type < MAX_DOOR_TYPES; ++type)
for(DoorSet::iterator i = bossInfo->door[type].begin(); i != bossInfo->door[type].end(); ++i)
UpdateDoorState(*i);
}
}
+std::string InstanceData::LoadBossState(const char * data)
+{
+ if(!data) return NULL;
+ std::istringstream loadStream(data);
+ uint32 buff;
+ uint32 bossId = 0;
+ for(std::vector<BossInfo>::iterator i = bosses.begin(); i != bosses.end(); ++i, ++bossId)
+ {
+ loadStream >> buff;
+ if(buff < TO_BE_DECIDED)
+ SetBossState(bossId, (EncounterState)buff);
+ }
+ return loadStream.str();
+}
+
+std::string InstanceData::GetBossSaveData()
+{
+ std::ostringstream saveStream;
+ for(std::vector<BossInfo>::iterator i = bosses.begin(); i != bosses.end(); ++i)
+ saveStream << (uint32)i->state << " ";
+ return saveStream.str();
+}
diff --git a/src/game/InstanceData.h b/src/game/InstanceData.h
index d68cb7ff7f8..91f589384a0 100644
--- a/src/game/InstanceData.h
+++ b/src/game/InstanceData.h
@@ -37,7 +37,8 @@ enum EncounterState
IN_PROGRESS = 1,
FAIL = 2,
DONE = 3,
- SPECIAL = 4
+ SPECIAL = 4,
+ TO_BE_DECIDED = 5,
};
typedef std::set<GameObject*> DoorSet;
@@ -51,7 +52,7 @@ enum DoorType
struct BossInfo
{
- BossInfo() : state(NOT_STARTED) {}
+ BossInfo() : state(TO_BE_DECIDED) {}
EncounterState state;
DoorSet door[MAX_DOOR_TYPES];
};
@@ -85,10 +86,10 @@ class TRINITY_DLL_SPEC InstanceData
virtual void Initialize() {}
//On load
- virtual void Load(const char* /*data*/) {}
+ virtual void Load(const char * data) { LoadBossState(data); }
//When save is needed, this function generates the data
- virtual const char* Save() { return ""; }
+ virtual std::string GetSaveData() { return GetBossSaveData(); }
void SaveToDB();
@@ -121,7 +122,7 @@ class TRINITY_DLL_SPEC InstanceData
//use HandleGameObject(GUID,boolen,NULL); in any other script
void HandleGameObject(uint64 GUID, bool open, GameObject *go = NULL);
- void SetBossState(uint32 id, EncounterState state);
+ virtual void SetBossState(uint32 id, EncounterState state);
protected:
void LoadDoorData(const DoorData *data);
@@ -129,14 +130,8 @@ class TRINITY_DLL_SPEC InstanceData
void AddDoor(GameObject *door, bool add);
void UpdateDoorState(GameObject *door);
- std::string GetBossSave()
- {
- std::ostringstream saveStream;
- for(std::vector<BossInfo>::iterator i = bosses.begin(); i != bosses.end(); ++i)
- saveStream << (uint32)i->state << " ";
- return saveStream.str();
- }
-
+ std::string LoadBossState(const char * data);
+ std::string GetBossSaveData();
private:
std::vector<BossInfo> bosses;
DoorInfoMap doors;
diff --git a/src/game/InstanceSaveMgr.cpp b/src/game/InstanceSaveMgr.cpp
index 131d26e90f7..7e2ad67c518 100644
--- a/src/game/InstanceSaveMgr.cpp
+++ b/src/game/InstanceSaveMgr.cpp
@@ -165,11 +165,11 @@ void InstanceSave::SaveToDB()
if(map)
{
assert(map->IsDungeon());
- InstanceData *iData = ((InstanceMap *)map)->GetInstanceData();
- if(iData && iData->Save())
+ if(InstanceData *iData = ((InstanceMap*)map)->GetInstanceData())
{
- data = iData->Save();
- CharacterDatabase.escape_string(data);
+ data = iData->GetSaveData();
+ if(!data.empty())
+ CharacterDatabase.escape_string(data);
}
}
diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp
index bc83aa7a352..782b0f9c44e 100644
--- a/src/game/Level2.cpp
+++ b/src/game/Level2.cpp
@@ -1288,7 +1288,7 @@ bool ChatHandler::HandleNpcAddMoveCommand(const char* args)
// update movement type
WorldDatabase.PExecuteLog("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE,lowguid);
- if(pCreature && pCreature->GetWaypointPath())
+ if(pCreature && pCreature->GetWaypointPathId())
{
pCreature->SetDefaultMovementType(WAYPOINT_MOTION_TYPE);
pCreature->GetMotionMaster()->Initialize();
@@ -1609,7 +1609,7 @@ bool ChatHandler::HandleNpcSetMoveTypeCommand(const char* args)
{
// update movement type
if(doNotDelete == false)
- pCreature->LoadPath(0);
+ pCreature->SetWaypointPathId(0);
pCreature->SetDefaultMovementType(move_type);
pCreature->GetMotionMaster()->Initialize();
@@ -2639,7 +2639,7 @@ bool ChatHandler::HandleWpAddCommand(const char* args)
if (!path_number)
{
if(target)
- pathid = target->GetWaypointPath();
+ pathid = target->GetWaypointPathId();
else
{
QueryResult *result = WorldDatabase.PQuery( "SELECT MAX(id) FROM waypoint_data");
@@ -2694,7 +2694,6 @@ bool ChatHandler::HandleWpLoadPathCommand(const char *args)
if(*args)
path_number = strtok((char*)args, " ");
-
uint32 pathid = 0;
uint32 guidlow = 0;
Creature* target = getSelectedCreature();
@@ -2725,6 +2724,7 @@ bool ChatHandler::HandleWpLoadPathCommand(const char *args)
return true;
}
+ /*
guidlow = target->GetDBTableGUIDLow();
QueryResult *result = WorldDatabase.PQuery( "SELECT guid FROM creature_addon WHERE guid = '%u'",guidlow);
@@ -2735,10 +2735,11 @@ bool ChatHandler::HandleWpLoadPathCommand(const char *args)
}
else
WorldDatabase.PExecute("INSERT INTO creature_addon(guid,path_id) VALUES ('%u','%u')", guidlow, pathid);
+ */
WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE, guidlow);
- target->LoadPath(pathid);
+ target->SetWaypointPathId(pathid);
target->SetDefaultMovementType(WAYPOINT_MOTION_TYPE);
target->GetMotionMaster()->Initialize();
target->MonsterSay("Path loaded.",0,0);
@@ -2746,20 +2747,19 @@ bool ChatHandler::HandleWpLoadPathCommand(const char *args)
return true;
}
-
bool ChatHandler::HandleReloadAllPaths(const char* args)
{
-if(!*args)
- return false;
+ if(!*args)
+ return false;
-uint32 id = atoi(args);
+ uint32 id = atoi(args);
-if(!id)
- return false;
+ if(!id)
+ return false;
PSendSysMessage("%s%s|r|cff00ffff%u|r", "|cff00ff00", "Loading Path: ", id);
WaypointMgr.UpdatePath(id);
- return true;
+ return true;
}
bool ChatHandler::HandleWpUnLoadPathCommand(const char *args)
@@ -2773,24 +2773,39 @@ bool ChatHandler::HandleWpUnLoadPathCommand(const char *args)
return true;
}
- if(target->GetCreatureAddon())
+ if(target->GetWaypointPathId())
{
- if(target->GetCreatureAddon()->path_id != 0)
+ uint32 pathId = target->GetDBTableGUIDLow() * 10;
+ if(target->GetWaypointPathId() == pathId)
{
- WorldDatabase.PExecute("DELETE FROM creature_addon WHERE guid = %u", target->GetGUIDLow());
- target->UpdateWaypointID(0);
- WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", IDLE_MOTION_TYPE, guidlow);
- target->LoadPath(0);
- target->SetDefaultMovementType(IDLE_MOTION_TYPE);
- target->GetMotionMaster()->MoveTargetedHome();
- target->GetMotionMaster()->Initialize();
- target->MonsterSay("Path unloaded.",0,0);
- return true;
+ for(uint32 i = 1; i < 11; ++i)
+ {
+ if(i == 10)
+ {
+ PSendSysMessage("%s%s|r", "|cffff33ff", "Target cannot have more than 9 script paths. Unloading failed.");
+ break;
+ }
+
+ if(WaypointMgr.GetPath(++pathId))
+ continue;
+
+ WorldDatabase.PExecute("UPDATE waypoint_data SET id = %u WHERE id = %u", pathId, target->GetDBTableGUIDLow() * 10);
+ WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", IDLE_MOTION_TYPE, guidlow);
+ target->SetWaypointPathId(0);
+ target->UpdateWaypointID(0);
+ target->SetDefaultMovementType(IDLE_MOTION_TYPE);
+ target->GetMotionMaster()->Initialize();
+ target->GetMotionMaster()->MoveTargetedHome();
+ PSendSysMessage("Path unloaded.");
+ break;
+ }
}
- PSendSysMessage("%s%s|r", "|cffff33ff", "Target have no loaded path.");
- return true;
+ else
+ PSendSysMessage("%s%s|r", "|cffff33ff", "Target has path but that path is not its default path. Unloading failed.");
}
- PSendSysMessage("%s%s|r", "|cffff33ff", "Target have no loaded path.");
+ else
+ PSendSysMessage("%s%s|r", "|cffff33ff", "Target has no loaded path.");
+
return true;
}
@@ -3264,7 +3279,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
return false;
}
- pathid = target->GetWaypointPath();
+ pathid = target->GetWaypointPathId();
}
else
@@ -4629,7 +4644,7 @@ bool ChatHandler::HandleNpcAddFormationCommand(const char* args)
group_member->groupAI = 0;
CreatureGroupMap[lowguid] = group_member;
- pCreature->SearchFormation();
+ pCreature->SearchFormationAndPath();
WorldDatabase.PExecuteLog("INSERT INTO `creature_formations` (`leaderGUID`, `memberGUID`, `dist`, `angle`, `groupAI`) VALUES ('%u','%u','%f', '%f', '%u')",
leaderGUID, lowguid, group_member->follow_dist, group_member->follow_angle, group_member->groupAI);
diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index 3884f39f5a4..3280970750b 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -2503,7 +2503,7 @@ void InstanceMap::CreateInstanceData(bool load)
{
Field* fields = result->Fetch();
const char* data = fields[0].GetString();
- if(data)
+ if(data && data != "")
{
sLog.outDebug("Loading instance data for `%s` with id %u", objmgr.GetScriptName(i_script_id), i_InstanceId);
i_data->Load(data);
diff --git a/src/game/NullCreatureAI.h b/src/game/NullCreatureAI.h
index f8a5d8480f0..347f52228b4 100644
--- a/src/game/NullCreatureAI.h
+++ b/src/game/NullCreatureAI.h
@@ -28,35 +28,41 @@ class TRINITY_DLL_DECL PassiveAI : public CreatureAI
{
public:
explicit PassiveAI(Creature *c) : CreatureAI(c) {}
- ~PassiveAI() {}
void MoveInLineOfSight(Unit *) {}
void AttackStart(Unit *) {}
-
void UpdateAI(const uint32);
+
static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; }
};
-class TRINITY_DLL_DECL PossessedAI : public PassiveAI
+class TRINITY_DLL_DECL PossessedAI : public CreatureAI
{
public:
- explicit PossessedAI(Creature *c) : PassiveAI(c) {}
+ explicit PossessedAI(Creature *c) : CreatureAI(c) {}
+ void MoveInLineOfSight(Unit *) {}
void AttackStart(Unit *target);
void UpdateAI(const uint32);
void EnterEvadeMode() {}
void JustDied(Unit*);
void KilledUnit(Unit* victim);
+
+ static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; }
};
-class TRINITY_DLL_DECL NullCreatureAI : public PassiveAI
+class TRINITY_DLL_DECL NullCreatureAI : public CreatureAI
{
public:
- explicit NullCreatureAI(Creature *c) : PassiveAI(c) {}
+ explicit NullCreatureAI(Creature *c) : CreatureAI(c) {}
+ void MoveInLineOfSight(Unit *) {}
+ void AttackStart(Unit *) {}
void UpdateAI(const uint32) {}
void EnterEvadeMode() {}
+
+ static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; }
};
class TRINITY_DLL_DECL CritterAI : public PassiveAI
diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp
index 9b1cb798849..4e5a4744e9a 100644
--- a/src/game/SpellMgr.cpp
+++ b/src/game/SpellMgr.cpp
@@ -2431,31 +2431,32 @@ void SpellMgr::LoadSpellCustomAttr()
case 45976: // Muru Portal Channel
case 39365: // Thundering Storm
case 41071: // Raise Dead (HACK)
- case 28542: // Life Drain - Sapphiron
spellInfo->MaxAffectedTargets = 1;
break;
case 41376: // Spite
case 39992: // Needle Spine
- case 29576: //Multi-Shot
- case 40816: //Saber Lash
- case 37790: //Spread Shot
- case 46771: //Flame Sear
- case 45248: //Shadow Blades
+ case 29576: // Multi-Shot
+ case 40816: // Saber Lash
+ case 37790: // Spread Shot
+ case 46771: // Flame Sear
+ case 45248: // Shadow Blades
case 41303: // Soul Drain
case 54172: // Divine Storm (heal)
- case 29213: // Curse of the Plaguebringer
+ case 29213: // Curse of the Plaguebringer - Noth
+ case 28542: // Life Drain - Sapphiron
spellInfo->MaxAffectedTargets = 3;
break;
case 38310: //Multi-Shot
spellInfo->MaxAffectedTargets = 4;
break;
case 42005: // Bloodboil
- case 38296: //Spitfire Totem
- case 37676: //Insidious Whisper
- case 46009: //Negative Energy
- case 45641: //Fire Bloom
- case 54937: //Glyph of Holy Light
- case 55665: // Life Drain - Sapphiron
+ case 38296: // Spitfire Totem
+ case 37676: // Insidious Whisper
+ case 46009: // Negative Energy
+ case 45641: // Fire Bloom
+ case 54937: // Glyph of Holy Light
+ case 55665: // Life Drain - Sapphiron (H)
+ case 28796: // Poison Bolt Volly - Faerlina
spellInfo->MaxAffectedTargets = 5;
break;
case 40827: // Sinful Beam
@@ -2463,7 +2464,8 @@ void SpellMgr::LoadSpellCustomAttr()
case 40860: // Vile Beam
case 40861: // Wicked Beam
case 57669: // Replenishment
- case 54835: // Curse of the Plaguebringer
+ case 54835: // Curse of the Plaguebringer - Noth (H)
+ case 54098: // Poison Bolt Volly - Faerlina (H)
spellInfo->MaxAffectedTargets = 10;
break;
case 8122: case 8124: case 10888: case 10890: // Psychic Scream
diff --git a/src/game/TemporarySummon.h b/src/game/TemporarySummon.h
index 09e7f22afb0..e089c77c96e 100644
--- a/src/game/TemporarySummon.h
+++ b/src/game/TemporarySummon.h
@@ -23,7 +23,7 @@
#include "Creature.h"
-class TempSummon : public Creature
+class TRINITY_DLL_SPEC TempSummon : public Creature
{
public:
explicit TempSummon(SummonPropertiesEntry const *properties, Unit *owner);
diff --git a/src/game/UnitAI.cpp b/src/game/UnitAI.cpp
index c991c75603d..76460bd8cc0 100644
--- a/src/game/UnitAI.cpp
+++ b/src/game/UnitAI.cpp
@@ -19,6 +19,7 @@
*/
#include "UnitAI.h"
+#include "Unit.h"
#include "SpellAuras.h"
void UnitAI::AttackStart(Unit *victim)
diff --git a/src/game/WaypointManager.cpp b/src/game/WaypointManager.cpp
index a677fd5b6d2..26be14d89fa 100644
--- a/src/game/WaypointManager.cpp
+++ b/src/game/WaypointManager.cpp
@@ -24,12 +24,12 @@
#include "ProgressBar.h"
#include "MapManager.h"
-UNORDERED_MAP<uint32, WaypointPath*> waypoint_map;
+WaypointPathMap WaypointPathHolder;
WaypointStore WaypointMgr;
void WaypointStore::Free()
{
- waypoint_map.clear();
+ WaypointPathHolder.clear();
}
void WaypointStore::Load()
@@ -37,7 +37,7 @@ void WaypointStore::Load()
QueryResult *result = WorldDatabase.PQuery("SELECT MAX(`id`) FROM `waypoint_data`");
if(!result)
{
- sLog.outError(" an error occured while loading the table `waypoint_data` ( maybe it doesn't exist ?)\n");
+ sLog.outError("an error occured while loading the table `waypoint_data` (maybe it doesn't exist ?)");
exit(1); // Stop server at loading non exited table or not accessable table
}
@@ -47,7 +47,7 @@ void WaypointStore::Load()
result = WorldDatabase.PQuery("SELECT `id`,`point`,`position_x`,`position_y`,`position_z`,`move_flag`,`delay`,`action`,`action_chance` FROM `waypoint_data` ORDER BY `id`, `point`");
if(!result)
{
- sLog.outErrorDb("The table `creature_addon` is empty or corrupted");
+ sLog.outErrorDb("The table `waypoint_data` is empty or corrupted");
return;
}
@@ -87,22 +87,21 @@ void WaypointStore::Load()
path_data->push_back(wp);
- if(id != last_id)
- waypoint_map[id] = path_data;
+ if(id != last_id)
+ WaypointPathHolder[id] = path_data;
last_id = id;
} while(result->NextRow()) ;
-
delete result;
}
void WaypointStore::UpdatePath(uint32 id)
{
-
- if(waypoint_map.find(id)!= waypoint_map.end())
- waypoint_map[id]->clear();
+ // TODO: this will cause memory leak
+ if(WaypointPathHolder.find(id) != WaypointPathHolder.end())
+ WaypointPathHolder[id]->clear();
QueryResult *result;
@@ -145,7 +144,7 @@ void WaypointStore::UpdatePath(uint32 id)
}while (result->NextRow());
- waypoint_map[id] = path_data;
+ WaypointPathHolder[id] = path_data;
delete result;
}
diff --git a/src/game/WaypointManager.h b/src/game/WaypointManager.h
index 85f8b765d45..a8f2d5746e9 100644
--- a/src/game/WaypointManager.h
+++ b/src/game/WaypointManager.h
@@ -34,7 +34,9 @@ struct WaypointData
};
typedef std::vector<WaypointData*> WaypointPath;
-extern UNORDERED_MAP<uint32, WaypointPath*> waypoint_map;
+typedef UNORDERED_MAP<uint32, WaypointPath*> WaypointPathMap;
+
+extern WaypointPathMap WaypointPathHolder;
class WaypointStore
{
@@ -48,9 +50,10 @@ class WaypointStore
WaypointPath* GetPath(uint32 id)
{
- if(waypoint_map.find(id) != waypoint_map.end())
- return waypoint_map[id];
- else return 0;
+ WaypointPathMap::iterator itr = WaypointPathHolder.find(id);
+ if(itr != WaypointPathHolder.end())
+ return itr->second;
+ return NULL;
}
inline uint32 GetRecordsCount() { return records; }
diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp
index ae7ef0bce00..effc78d8026 100644
--- a/src/game/WaypointMovementGenerator.cpp
+++ b/src/game/WaypointMovementGenerator.cpp
@@ -100,7 +100,7 @@ WaypointMovementGenerator<Creature>::Initialize(Creature &u)
//i_nextMoveTime.Reset(0);
StopedByPlayer = false;
if(!path_id)
- path_id = u.GetWaypointPath();
+ path_id = u.GetWaypointPathId();
waypoints = WaypointMgr.GetPath(path_id);
i_currentNode = 0;
if(waypoints && waypoints->size())
@@ -226,7 +226,7 @@ template bool WaypointMovementGenerator<Player>::Update(Player &, const uint32 &
template void WaypointMovementGenerator<Player>::MovementInform(Player &);
//----------------------------------------------------//
-void FlightPathMovementGenerator::LoadPath(Player &)
+void FlightPathMovementGenerator::SetWaypointPathId(Player &)
{
objmgr.GetTaxiPathNodes(i_pathId, i_path,i_mapIds);
}
@@ -252,7 +252,7 @@ void FlightPathMovementGenerator::Initialize(Player &player)
player.addUnitState(UNIT_STAT_IN_FLIGHT);
player.SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT);
player.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2);
- LoadPath(player);
+ SetWaypointPathId(player);
Traveller<Player> traveller(player);
// do not send movement, it was sent already
i_destinationHolder.SetDestination(traveller, i_path[i_currentNode].x, i_path[i_currentNode].y, i_path[i_currentNode].z, false);
diff --git a/src/game/WaypointMovementGenerator.h b/src/game/WaypointMovementGenerator.h
index 9804c150d63..9c93486a675 100644
--- a/src/game/WaypointMovementGenerator.h
+++ b/src/game/WaypointMovementGenerator.h
@@ -50,7 +50,7 @@ class TRINITY_DLL_SPEC PathMovementBase
bool MovementInProgress(void) const { return i_currentNode < i_path.Size(); }
- void LoadPath(T &);
+ void SetWaypointPathId(T &);
void ReloadPath(T &);
uint32 GetCurrentNode() const { return i_currentNode; }
@@ -104,7 +104,7 @@ public PathMovementBase<Player>
bool Update(Player &, const uint32 &);
MovementGeneratorType GetMovementGeneratorType() { return FLIGHT_MOTION_TYPE; }
- void LoadPath(Player &);
+ void SetWaypointPathId(Player &);
void ReloadPath(Player &) { /* don't reload flight path */ }
Path& GetPath() { return i_path; }
diff --git a/src/shared/Database/SQLStorage.cpp b/src/shared/Database/SQLStorage.cpp
index 8561afc4a33..67091174c77 100644
--- a/src/shared/Database/SQLStorage.cpp
+++ b/src/shared/Database/SQLStorage.cpp
@@ -29,9 +29,9 @@ extern DatabaseMysql WorldDatabase;
const char CreatureInfosrcfmt[]="iiiiiisssiiiiiiiiiiffiffiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiiiiiiisiifflliiis";
const char CreatureInfodstfmt[]="iiiiiisssiiiiiiiiiiffiffiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiiiiiiisiifflliiii";
-const char CreatureDataAddonInfofmt[]="iiiiiiiis";
+const char CreatureDataAddonInfofmt[]="iiiiiiis";
const char CreatureModelfmt[]="iffbi";
-const char CreatureInfoAddonInfofmt[]="iiiiiiiis";
+const char CreatureInfoAddonInfofmt[]="iiiiiiis";
const char EquipmentInfofmt[]="iiii";
const char GameObjectInfosrcfmt[]="iiisssiifiiiiiiiiiiiiiiiiiiiiiiiis";
const char GameObjectInfodstfmt[]="iiisssiifiiiiiiiiiiiiiiiiiiiiiiiii";