Evilfairy
12-01-13, 11:01 PM
IF YOU ARE USING A REPACK YOU CANNOT ADD SCRIPTS. LEARN TO COMPILE YOUR OWN CORE.
So, after a day of working on my script I finally managed to create a multivendor script that:
Works without needing to edit the core (outside of installing the script)
Works without needing to edit the database (outside of setting NPC flags and scriptname)
Is retard proof (provided you follow the instructions)
Known limitations:
Has a limit of 150 items per vendor, and 256 items across all vendors. Adding more than 256 items will break your script
Here it is: C++ code - 347 lines - codepad (http://codepad.org/e6nyvrJJ)
Instructions
1. Download the raw file from http://codepad.org/e6nyvrJJ/raw.cpp
2. Move that file to \src\server\scripts\Custom in your TrinityCore folder
3. Rename the file from raw.cpp to npc_multivendor.cpp (it might just say "raw" instead of "raw.cpp" if you have file extensions hidden, in this case rename it to "npc_multivendor")
4. Change CMakeLists.txt so that it looks something like:
set(scripts_STAT_SRCS
${scripts_STAT_SRCS}
Custom/npc_multivendor.cpp
)
5. Go to \src\server\game\Scripting and open ScriptLoader.cpp
6. Scroll to the bottom of the file and change it to look like this:
#ifdef SCRIPTS
/* This is where custom scripts' loading functions should be declared. */
void AddSC_npc_multivendor();
#endif
void AddCustomScripts()
{
#ifdef SCRIPTS
/* This is where custom scripts should be added. */
AddSC_npc_multivendor();
#endif
}
7. Open your database and find the NPC you want to use as a multivendor in creature_template
7a. If you do not have a vendor created yet, you can run the following code to create one. DO NOT RUN THIS IF YOU ALREADY HAVE AN NPC YOU WANT TO USE AS A VENDOR, YOU DO NOT NEED TO ADD A NEW ONE
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`, `equipment_id`, `mechanic_immune_mask`, `flags_extra`, `ScriptName`, `WDBVerified`) VALUES (700000, 0, 0, 0, 0, 0, 1298, 0, 0, 0, '[QA] Dota Test Vendor', 'Multivendor', NULL, 0, 10, 10, 0, 12, 12, 129, 1, 1.14286, 1, 0, 13, 17, 0, 42, 1, 1500, 0, 1, 512, 2048, 8, 0, 0, 0, 0, 0, 9, 13, 100, 7, 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, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 'npc_multivendor', 12340);
7b. If you already have a creature you wish to use as a vendor, you must set npcflag to 129, and ScriptName to npc_multivendor
8. Edit the script by going to line 243 and reading the instructions there. The shortcut for going to a line in Visual Studio is Ctrl+G.
9. Re-create your CMake files by running CMake and pressing Configure then Generate
10. Remember to delete the "Cache" folder in your WoW installation to avoid problems
And you're done! Please leave any bugs/feedback in this thread and I'll try to address them when I can. The script _should_ be secure as outside of building the SMSG_INVENTORY_LIST packet it uses TrinityCore's own functions to process the item buying and such, but as with all 3rd party scripts if you're seriously bothered about security you should check it yourself.
Peace out~
Evilfairy
So, after a day of working on my script I finally managed to create a multivendor script that:
Works without needing to edit the core (outside of installing the script)
Works without needing to edit the database (outside of setting NPC flags and scriptname)
Is retard proof (provided you follow the instructions)
Known limitations:
Has a limit of 150 items per vendor, and 256 items across all vendors. Adding more than 256 items will break your script
Here it is: C++ code - 347 lines - codepad (http://codepad.org/e6nyvrJJ)
Instructions
1. Download the raw file from http://codepad.org/e6nyvrJJ/raw.cpp
2. Move that file to \src\server\scripts\Custom in your TrinityCore folder
3. Rename the file from raw.cpp to npc_multivendor.cpp (it might just say "raw" instead of "raw.cpp" if you have file extensions hidden, in this case rename it to "npc_multivendor")
4. Change CMakeLists.txt so that it looks something like:
set(scripts_STAT_SRCS
${scripts_STAT_SRCS}
Custom/npc_multivendor.cpp
)
5. Go to \src\server\game\Scripting and open ScriptLoader.cpp
6. Scroll to the bottom of the file and change it to look like this:
#ifdef SCRIPTS
/* This is where custom scripts' loading functions should be declared. */
void AddSC_npc_multivendor();
#endif
void AddCustomScripts()
{
#ifdef SCRIPTS
/* This is where custom scripts should be added. */
AddSC_npc_multivendor();
#endif
}
7. Open your database and find the NPC you want to use as a multivendor in creature_template
7a. If you do not have a vendor created yet, you can run the following code to create one. DO NOT RUN THIS IF YOU ALREADY HAVE AN NPC YOU WANT TO USE AS A VENDOR, YOU DO NOT NEED TO ADD A NEW ONE
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`, `equipment_id`, `mechanic_immune_mask`, `flags_extra`, `ScriptName`, `WDBVerified`) VALUES (700000, 0, 0, 0, 0, 0, 1298, 0, 0, 0, '[QA] Dota Test Vendor', 'Multivendor', NULL, 0, 10, 10, 0, 12, 12, 129, 1, 1.14286, 1, 0, 13, 17, 0, 42, 1, 1500, 0, 1, 512, 2048, 8, 0, 0, 0, 0, 0, 9, 13, 100, 7, 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, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 'npc_multivendor', 12340);
7b. If you already have a creature you wish to use as a vendor, you must set npcflag to 129, and ScriptName to npc_multivendor
8. Edit the script by going to line 243 and reading the instructions there. The shortcut for going to a line in Visual Studio is Ctrl+G.
9. Re-create your CMake files by running CMake and pressing Configure then Generate
10. Remember to delete the "Cache" folder in your WoW installation to avoid problems
And you're done! Please leave any bugs/feedback in this thread and I'll try to address them when I can. The script _should_ be secure as outside of building the SMSG_INVENTORY_LIST packet it uses TrinityCore's own functions to process the item buying and such, but as with all 3rd party scripts if you're seriously bothered about security you should check it yourself.
Peace out~
Evilfairy