Forum Thread
Search
by member
  Posts  
capturing Half-Life player movement (Forums : Coding & Scripting : capturing Half-Life player movement) Post Reply
Thread Options
Oct 14 2009, 3:54am Anchor

Hi.  I'm new to modding.  I have a question regarding Half-Life (not HL2, just HL1).  I know the pm_shared folder (with the pm_*.c files) are used to capture a player's movement.  My issue is that the pm_* are all C files, and I want to do C++, but pretty much all the .h files are written in C++.  For example, if a player moves forward, I want the screen to display "moving forward" by using the UTIL_HUDMESSAGE function in util.h/util.cpp to display text to the HUD.  Since util.h is C++, I cannot do a #include "util.h" in the .C files without the compiler complaining.  Anyways, I was wondering if anyone has a solution to my problem.  I have thought of a couple possible workarounds, but I haven't been able to make it work:
1) convert the pm_*.C files into pm_*.CPP files. I'm not really familiar with going C to C++. I know it's not as simple as changing the file extension.  I know there's methods such as Extern "C", but there's a lot of other bugs I couldn't figure out, plus, I'm not very knowledgeable with the Extern "C" method.
2) have a CPP file that #include the C files, but then I'm back at square 1 where I have to figure out if the player decides to move
3) determine when the user presses a "movement" key on the keyboard through one of the CPP files.  This seems like the only method, but not 100% ideal because I want to be able to do stuff when the player ACTUALLY moves, not when he's running in front of a wall.

If #3 is the only "feasible" method, can someone point me in the right direction as to where to find the function that captures a player's keyboard stroke?  Or if there's any other suggestions or solutions, I will greatly appreciate it.  Thanks.

PS - I'm using Windows XP, and my compiler is Visual Studio .NET 2003.  Thanks again!

Edited by: jonjacko

Reply to Thread

Only registered members can share their thoughts. So come on! Join the community today (totally free) and join in the conversation.