In an effort to convince everyone else to provide step-by-step how we're doing this, here's what I did to create a new command handler. First thing I did was log into my empty world, and create a woodworking table, and set some parameters. Here's a list of commands, with a short explanation of what this means.
First, we create the table object and commands needed to interact with it. This is all done in-game, except for adding the entity_commands directly to your EQ2DB --
Create the Table object
Code: Select all
/spawn create object 2346 1 1 'Woodworking Table'
Add it to the permanent spawns for the zone
Code: Select all
/spawn add new 'Woodworking Table'
...and reload spawns so you have a valid object to work with
Open your MySQL tool, whichever one you do, and run the following query:
Code: Select all
select * from entity_commands where command = 'create';
If you get 0 results, you have to create this entity_command (these are the commands that tie spawns to code handlers, explained later)
To create a new entity_command, run this query in your MySQL tool:
Code: Select all
insert into entity_commands (command_list_id, command_text, distance, command) values (12,'create',10,'create');
(NOTE: if command_list_id 12 is already assigned, choose another... it doesn't matter what this # is)
Once you verify your new entity_command is in the table, go back to your World and run
Then target the new object and run these commands with the new object targeted to set it up for interaction --
Code: Select all
/spawn set command_primary 12
/spawn set show_command_icon 1
/spawn set show_name 1
/reload spawns
This tells the server that when you right-click on the table, show the option "create".
And show the Hand icon on mouse-over
And show the object's name
And reload when done. You now have a new crafting station in your world.
Now we'll add the C++ code to handle the new "create" command assigned to this object. The handler ID we're adding is 256.
Why did I choose 256?
Mostly, it was just to keep things in an orderly, numeric fashion. COMMAND_CREATE_GUILD = 257, and there was no 256... so the logical choice was 256 since it didn't already exist.
In VS2008, load up the World.sln, and open Commands.h. Search for "COMMAND_CREATE_GUILD" and you will notice the handler ID of 257. Since we need a new handler for the "create" command we just made, we insert a line as follows:
Insert it between COMMAND_RELOAD_GUILDS and COMMAND_CREATE_GUILD so it looks like this:
Code: Select all
#define COMMAND_SET_GUILD_OFFICER_NOTE 254
#define COMMAND_RELOAD_GUILDS 255
#define COMMAND_CREATE 256 // JA: crafting table handler "create" command
#define COMMAND_CREATE_GUILD 257
#define COMMAND_GUILDS 258
See the new one in the middle there? Save Commands.h
Open Commands.cpp, and search again for "case COMMAND_CLAIM". We're adding our new code below all the Guild stuff. Since right now this is simply to get code in place to handle the right-click / create commands, the code is generic:
Code: Select all
// JA: Handler for starting Tradeskilling table
case COMMAND_CREATE: {
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You're trying to craft something, eh? TODO! :)");
break;
Save Commands.cpp and compile! If you have no errors, your code is fine.
Now you can log into your world, right click the new table, select 'create' and you should see a message from your new command handler:
"You're trying to craft something, eh? TODO!

"
As we move through this process, that Command will grow, as will other code added to the rest of the World to make crafting tables interactive.
To our coders: I do not expect everyone to be as ridiculous with "documentation" as I am... but please, for the sake of the community, tell us everything you're doing to get Tradeskills implemented. This is a learning process for us all. Thanks!