Skip to content

Instantly share code, notes, and snippets.

@Naios
Last active August 29, 2015 14:16
Show Gist options
  • Save Naios/5cd340dab3052d327feb to your computer and use it in GitHub Desktop.
Save Naios/5cd340dab3052d327feb to your computer and use it in GitHub Desktop.

###Code:###

System.out.println("\nShort Example:\n");
final ServerStorage<CreatureTemplate> creatureTemplate = requestServerStorage("world", "creature_template");
final CreatureTemplate maloriak = creatureTemplate.request(ServerStorageKeys.ofCreatureTemplate(41378)).get();
 
creatureTemplate.getChangeTracker().setScope("1", "Some flag changes \n and comment tests");
maloriak.unit_flags().removeFlag(UnitFlags.UNIT_FLAG_DISARMED);
maloriak.unit_flags().addFlag(UnitFlags.UNIT_FLAG_IMMUNE_TO_NPC);
 
creatureTemplate.getChangeTracker().setScope("2", "Set the name");
maloriak.name().set("hey im a test npc");
 
creatureTemplate.getChangeTracker().setScope("3", "Make npc");
final CreatureTemplate newNpc = creatureTemplate.create(ServerStorageKeys.ofCreatureTemplate(3000000));
newNpc.name().set("hey im new here!");
 
// Receive query
System.out.println(createSQLBuilder(creatureTemplate.getChangeTracker()).toString());

###Result:### Mode: LAZY

SET @NPC_MALORIAK            :=   41378;
SET @NPC_UNK_3000000         := 3000000;

SET @UNIT_FLAG_IMMUNE_TO_NPC :=   0x200;

/* *
 * Some flag changes 
 * and comment tests
 */
UPDATE `creature_template` SET `unit_flags` = `unit_flags` | @UNIT_FLAG_IMMUNE_TO_NPC WHERE `entry` = @NPC_MALORIAK;

-- Set the name
UPDATE `creature_template` SET `name` = "hey im a test npc" WHERE `entry` = @NPC_MALORIAK;

-- Make npc
DELETE FROM `creature_template` WHERE `entry` = @NPC_UNK_3000000;
INSERT INTO `creature_template` (`entry`, `difficulty_entry_1`, `difficulty_entry_2`, `difficulty_entry_3`, `KillCredit1`, `KillCredit2`, `modelid1`, `modelid2`, `modelid3`, `modelid4`, `name`, `femaleName`, `subname`, `IconName`, `gossip_menu_id`, `minlevel`, `maxlevel`, `exp`, `exp_unk`, `faction`, `npcflag`, `speed_walk`, `speed_run`, `scale`, `rank`, `dmgschool`, `BaseAttackTime`, `RangeAttackTime`, `BaseVariance`, `RangeVariance`, `unit_class`, `unit_flags`, `unit_flags2`, `dynamicflags`, `family`, `trainer_type`, `trainer_class`, `trainer_race`, `type`, `type_flags`, `type_flags2`, `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`, `HealthModifier`, `HealthModifierExtra`, `ManaModifier`, `ManaModifierExtra`, `ArmorModifier`, `DamageModifier`, `ExperienceModifier`, `RacialLeader`, `questItem1`, `questItem2`, `questItem3`, `questItem4`, `questItem5`, `questItem6`, `movementId`, `RegenHealth`, `mechanic_immune_mask`, `flags_extra`, `ScriptName`, `VerifiedBuild`) VALUES
(3000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, "hey im new here!", "", "", "", 0, 1, 1, 0, 0, 0, 0, 1.0, 1.14286, 1.0, 0, 0, 0, 0, 1.0, 1.0, CLASS_WARRIOR, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", 0, 3, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "", 15995);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment