by PsychoJim on Thu Nov 10, 2011 11:08 am
Hey guys thanks for your replies, much appreciated.
LordDZ, I've been there and completed a few of the tutorials (Making a Mod, My First Mod, Mini-mod tutorial) but really these only cover the bare essentials and I don't really know where to go from there.
Jordash, my main objective here is to use the Source SDK to create a psychology experiment. Basically, I have previously used python to create simple interfaces that measure things like reaction time and rate of responding. So, there would be a button that the participant could press in response to certain stimuli, and I would record when the button was pressed, which would give me both total number of presses and also exactly at what points in time the presses were made. My goal is to transfer this kind of thing to a virtual 3D environment.
For example then, let's say the game starts, and exactly 30s later the player fires their weapon. I would like it to be recorded in a standard .txt file something like "weapon fired: 30000ms". Let's say they then picked up a crowbar a short while later, something like this should be recorded: "pickup crowbar: 36852ms". I don't need my timing to be too precise, but correct to the nearest 100ms would be desirable. As for the .txt file itself, initially it would all be run on a local machine, so I would be able to access it without any difficulty.
So, I need to start a timer when the game starts. In python, this would be very easy, just write the current time, as read from the system clock, to a variable, e.g. startTime = time.time(). Then later when any event happens, you just read the time again, subtract the start time, and you have the time of the event's occurrence relative to the start of the game, e.g. timeNow = time.time(); elapsedTime = timeNow - startTime. Including this as part of the function bound to the button press would allow the time of every button press to be recorded.
To achieve this in HL2 though, I need to find exactly at what point in the source code I need to insert my C++ code so that these actions are performed at the correct point. So where in the source code do I need to place my code so that when the game starts, the start time is recorded?
So, really my aim is to try and learn a bit more about the various events/methods/whatever in the source code, so I know what does what. For example I managed to find out about OnPlayerPickup, so is there some resource or reference that describes the rest of the elements in the source code? Is there something like OnGameStart for instance?
Thanks again for your input.