[SQL] Add a Stable Master to Fairbreeze Village (updated 2014-06-28)

NOTE: I don’t update this regularly and it is possible that the DB might change. If you get errors on import and no appropriate archive exists, feel free to fix the errors and post your corrections. Think of it as a learning experience.

Let me introduce you to Syrela…

Syrela is a Stable Master who has decided to set up shop at Fairbreeze Village in Eversong Woods. This is great news for all the Hunters who wore out their shoes running to Silvermoon / Ruins of Silvermoon to swap their pet.

This SQL removes the NPC

you should run this before updating your database so you won’t have GUID collision

– Removes custom NPC Stable Master from Fairbreeze Village in Eversong Woods

– Remove the old template and spawn
SET @old_ct_entry=(SELECT entry FROM creature_template WHERE name=‘Syrela’ AND subname=‘Stable Master’);

DELETE IGNORE FROM creature_template WHERE entry=@old_ct_entry;
DELETE IGNORE FROM creature WHERE id=@old_ct_entry;

This SQL adds the NPC

you should run this after updating your database to replace her

Current Version

[ul][li]Updated to reflect the removal of faction_A, faction_H and WDBVerified fields[/li][/ul]

– Adds a Stable Master to Fairbreeze Village in Eversong Woods

– Note: This is for newer databases that use the faction field instead of faction_A, faction_H
– and VerifiedBuild instead of WDBVerified

– Remove the old template and spawn. This is here as a precaution so you won’t duplicate the NPC
SET @old_ct_entry=(SELECT entry FROM creature_template WHERE name=‘Syrela’ AND subname=‘Stable Master’);

DELETE IGNORE FROM creature_template WHERE entry=@old_ct_entry;
DELETE IGNORE FROM creature WHERE id=@old_ct_entry;

– Dynamically create a new template and spawn to avoid clashing with real NPCs.
– Since this is a custom NPC it shouldn’t matter if the ENTRY / GUID are different after DB updates
SET @max_ct_entry=(SELECT MAX(entry) FROM creature_template);
SET @max_cr_guid=(SELECT MAX(guid) FROM creature);

– Creature template
INSERT INTO creature_template
(entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, modelid4, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, faction, npcflag, speed_walk, speed_run, scale, rank, mindmg, maxdmg, dmgschool, attackpower, dmg_multiplier, baseattacktime, rangeattacktime, unit_class, unit_flags, unit_flags2, dynamicflags, family, trainer_type, trainer_spell, trainer_class, trainer_race, minrangedmg, maxrangedmg, rangedattackpower, type, type_flags, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, InhabitType, HoverHeight, Health_mod, Mana_mod, Armor_mod, RacialLeader, questItem1, questItem2, questItem3, questItem4, questItem5, questItem6, movementId, RegenHealth, mechanic_immune_mask, flags_extra, ScriptName, VerifiedBuild)
VALUES
(@max_ct_entry+1,‘0’,‘0’,‘0’,‘0’,‘0’,‘16802’,‘0’,‘0’,‘0’,‘Syrela’,‘Stable Master’,NULL,‘9821’,‘15’,‘15’,‘0’,‘1604’,‘4194305’,‘1’,‘1.14286’,‘1’,‘0’,‘20’,‘27’,‘0’,‘30’,‘1’,‘1500’,‘0’,‘8’,‘4608’,‘2048’,‘8’,‘0’,‘0’,‘0’,‘0’,‘0’,‘12’,‘18’,‘8’,‘7’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘’,‘1’,‘3’,‘1’,‘1’,‘1’,‘1’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘0’,‘1’,‘0’,‘2’,‘’,‘12340’);

– Creature spawn
INSERT INTO creature
(guid, id, map, spawnMask, phaseMask, modelid, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, spawndist, currentwaypoint, curhealth, curmana, MovementType, npcflag, unit_flags, dynamicflags)
VALUES
(@max_cr_guid+1,@max_ct_entry+1,‘530’,‘1’,‘1’,‘0’,‘1’,‘8702.508789’,‘-6681.481934’,‘70.893869’,‘5.985420’,‘300’,‘0’,‘0’,‘285’,‘382’,‘0’,‘0’,‘0’,‘0’);

Old Versions:

These versions are here for archive. If you’re running an older core you’ll want

to use these because DB fields may be different.

Archive_1

[ul][li]Use this if your creature_template table has the fields faction_A and faction_H[/li][/ul]

-- Adds a Stable Master to Fairbreeze Village in Eversong Woods

-- Remove the old template and spawn. This is here as a precaution so you won't duplicate the NPC
SET @old_ct_entry=(SELECT `entry` FROM `creature_template` WHERE `name`='Syrela' AND `subname`='Stable Master');

DELETE IGNORE FROM `creature_template` WHERE entry=@old_ct_entry;
DELETE IGNORE FROM `creature` WHERE `id`=@old_ct_entry;

-- Dynamically create a new template and spawn to avoid clashing with real NPCs.
-- Since this is a custom NPC it shouldn't matter if the ENTRY / GUID are different after DB updates
SET @max_ct_entry=(SELECT MAX(`entry`) FROM `creature_template`);
SET @max_cr_guid=(SELECT MAX(`guid`) FROM `creature`);

-- Creature template
INSERT INTO `creature_template`
 (`entry`, `difficulty_entry_1`, `difficulty_entry_2`, `difficulty_entry_3`, `KillCredit1`, `KillCredit2`, `modelid1`, `modelid2`, `modelid3`, `modelid4`, `name`, `subname`, `IconName`, `gossip_menu_id`, `minlevel`, `maxlevel`, `exp`, `faction_A`, `faction_H`, `npcflag`, `speed_walk`, `speed_run`, `scale`, `rank`, `mindmg`, `maxdmg`, `dmgschool`, `attackpower`, `dmg_multiplier`, `baseattacktime`, `rangeattacktime`, `unit_class`, `unit_flags`, `unit_flags2`, `dynamicflags`, `family`, `trainer_type`, `trainer_spell`, `trainer_class`, `trainer_race`, `minrangedmg`, `maxrangedmg`, `rangedattackpower`, `type`, `type_flags`, `lootid`, `pickpocketloot`, `skinloot`, `resistance1`, `resistance2`, `resistance3`, `resistance4`, `resistance5`, `resistance6`, `spell1`, `spell2`, `spell3`, `spell4`, `spell5`, `spell6`, `spell7`, `spell8`, `PetSpellDataId`, `VehicleId`, `mingold`, `maxgold`, `AIName`, `MovementType`, `InhabitType`, `HoverHeight`, `Health_mod`, `Mana_mod`, `Armor_mod`, `RacialLeader`, `questItem1`, `questItem2`, `questItem3`, `questItem4`, `questItem5`, `questItem6`, `movementId`, `RegenHealth`, `mechanic_immune_mask`, `flags_extra`, `ScriptName`, `WDBVerified`)
VALUES
 (@max_ct_entry+1,'0','0','0','0','0','16802','0','0','0','Syrela','Stable Master',NULL,'9821','15','15','0','1604','1604','4194305','1','1.14286','1','0','20','27','0','30','1','1500','0','8','4608','2048','8','0','0','0','0','0','12','18','8','7','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','1','3','1','1','1','1','0','0','0','0','0','0','0','0','1','0','2','','12340');

-- Creature spawn
INSERT INTO `creature`
 (`guid`, `id`, `map`, `spawnMask`, `phaseMask`, `modelid`, `equipment_id`, `position_x`, `position_y`, `position_z`, `orientation`, `spawntimesecs`, `spawndist`, `currentwaypoint`, `curhealth`, `curmana`, `MovementType`, `npcflag`, `unit_flags`, `dynamicflags`)
VALUES
 (@max_cr_guid+1,@max_ct_entry+1,'530','1','1','0','1','8702.508789','-6681.481934','70.893869','5.985420','300','0','0','285','382','0','0','0','0');