Mod Coding - Adding Commands -1 reply

Please wait...


Crazy Coding SP Guy...

50 XP

27th December 2002

0 Uploads

168 Posts

0 Threads

#1 10 years ago


Well, i'm learning and playing a lot with the code and modifying the multiplayer game to work along with my Singleplayer mod, and wondered about something:

Adding new commands. There are lines in many of the files that I can point to: g_main.c::vmMain() Executes g_cmds.c::ClientCommand() Executes g_active.c::ClientThink()

g_active.c::ClientThink() Executes ClientThink_Real() g_active.c::ClientThink_Real() Parses in the Generic Command Switch the GENCMD_* constants from q_shared.h


cg_consolecmds.c::CG_InitConsoleCommands() trap_AddCommand("saberAttackCycle")

ui_shared.c:: bind_t g_bindings[] {"saberAttackCycle", 'l', -1, -1, -1},

So now you see that I've done "some" research here, and found a lot of things on the ends, but nothing in the middle. I've got the Text String for the command added into the CG command buffers, i've got the key binding array to hold the key for the command and I've also got the process that handles the command SaberAttackCycle. Now what if I wanted to add the command SaberAttackCycleDown, to go up or down on the cycle like we do on the weapons and such. i figured i'd have to add a binding, add the Trap_AddCommand(), but there is nothing to convert the string "saberAttackCycleDown" into the GENCMD_SABERATTACKCYCLEDOWN enum i added to the block, so even if I update the ClientThink_Real() switch that processes these constants, i still get a unknown cmd error. So, where exactly would i add the code to process the "saberAttackCycleDown" command to execute the g_cmds.c::Cmd_SaberAttackCycle_f() function with an added parameter for direction? (i know i would write this too, but i need the dots connected in order to get there.

Thanks Jaeden "Sifo Dyas" al'Raec Ruiner

PS - My thoughts leaned towards editing g_cmds.c::ClientCommand() with an appropriate line parsing the string "saberAttackCycleDown" but i'm not positive that will work.


A well-oiled toaster oven

50 XP

26th January 2007

0 Uploads

298 Posts

0 Threads

#2 10 years ago

Look in the g_cmds.c::ClientCommands(), you'll find a bunch of else-if's in that function that parse the command string and execute a function based on it. I would add these lines at g_cmds.c, 3309 else if (Q_stricmp (cmd, "setviewpos") == 0) Cmd_SetViewpos_f( ent ); else if (Q_stricmp (cmd, "stats") == 0) Cmd_Stats_f( ent );


else if (Q_stricmp (cmd, "saberAttackCycle") == 0) Cmd_SaberAttackCycle_f(); // with whatever args you need