total newb looking for some help with modding

Chat about various topics.

total newb looking for some help with modding

Postby PsychoJim on Wed Nov 09, 2011 5:54 pm

Hello all. I am totally new to modding, and need some help and advice.

I have had the Orange Box now for a couple of months, and during that time have been learning how to create maps in Valve Hammer editor.

However now to achieve what I want to do, I really need to start editing the source code, so I need to learn modding. I have figured out how to create a new mod using Visual Studio, but that's pretty much all.

Basically I am just searching Half-Life 2 forums to see if I can find anyone out there who might be willing to give me some pointers and walk me through the first steps of learning to mod. From what I've seen throughout the posts on this forum it seems this might be a good place to seek advice. So are there any modders out there who might be willing to help me out?

Thanks!
PsychoJim
Member
Member
 
Joined: Tue Aug 23, 2011 12:58 pm

Re: total newb looking for some help with modding

Postby LordDz on Wed Nov 09, 2011 7:30 pm

User avatar
LordDz
May Contain Skills
May Contain Skills
 
Joined: Mon Sep 01, 2008 12:28 pm
Location: Hammer Crash Logs

Re: total newb looking for some help with modding

Postby PsychoJim on Wed Nov 09, 2011 7:35 pm

I thought it might help if I provide some specifics with what I am looking for.
First, I need the mod to open a .txt file on game start, which events in the game can be recorded to.
Secondly, I need to take a reading from the system clock on game start, so that the precise timing of in game events can be recorded (and also events can be triggered after a specific amount of time has elapsed since game start).
Thirdly I need to record game events, such as when a weapon is fired or an object picked up, in the .txt file that was created at the start of the game.

I know that I can create segments of code in C++, and insert these at appropriate points in the source code, so that they trigger at the right moment. For instance I know that if I was to insert the appropriate code at some point in the function OnPlayerPickup, that this could record when an object is picked up.

My real problem is not knowing exactly where in the source to place my code. For example, there are multiple instances of OnPlayerPickup throughout a number of files such as props.cpp, and I'm not sure exactly which to use.
PsychoJim
Member
Member
 
Joined: Tue Aug 23, 2011 12:58 pm

Re: total newb looking for some help with modding

Postby Jordash on Thu Nov 10, 2011 12:34 am

The steam coding forums will be better for a coding related question http://forums.steampowered.com/forums/f ... .php?f=195 (when it's not down)

Though don't expect them to do it for you, they will likely just push you in the right direction.

Also when you describe what you want to happen you should include the overall objective, not just the method you think is correct. For example you talk about the system clock, but the code has it's own timer, unless you literally want the time for some reason that should suffice, and if you really do need the time, say why exactly, people can help you easier if they know what you are trying to achieve. The same with recording the game events, why do you want this? do you need the game to read the document? or for it to automatically send it to you whenever someone plays? otherwise it is just a random txt file on a computer you can't access. By all means include these steps you think you need to take still, but someone familiar with the code might be able to find a more efficient way to do what you want.

It's good to see you've found OnPlayerPickup though, the code uses a heirachy system, it starts off base code which has information all the entities using it will need. So one of the OnPlayerPickups will be one that is used by all props, or even all entities, then the next level might be all physics entities (ragdoll, physics, debris) then a set for each of those. The only way you can tell is by looking at the C++ file of each reference and following its #include functions backwards.
User avatar
Jordash
Been Here A While
Been Here A While
 
Joined: Mon Sep 21, 2009 10:36 am
Location: Perth, Australia

Re: total newb looking for some help with modding

Postby 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.
PsychoJim
Member
Member
 
Joined: Tue Aug 23, 2011 12:58 pm

Re: total newb looking for some help with modding

Postby PsychoJim on Thu Nov 10, 2011 11:36 am

would it be GameStartFrame() in Game_client.cpp?
PsychoJim
Member
Member
 
Joined: Tue Aug 23, 2011 12:58 pm

Re: total newb looking for some help with modding

Postby Jordash on Thu Nov 10, 2011 12:18 pm

Ok, that actually sounds really cool. The source engine uses 'gpGlobals->curtime' which will give you the game time in seconds (I think, you'll have to test), you don't have to start it or anything and you can access it from any class. Since you're familiar with python I'm sure you know how to subtract and store figures from that to get what you desire. It's very accurate too.

http://developer.valvesoftware.com/wiki ... em#Writing should have all you need on the txt front
User avatar
Jordash
Been Here A While
Been Here A While
 
Joined: Mon Sep 21, 2009 10:36 am
Location: Perth, Australia

Re: total newb looking for some help with modding

Postby PsychoJim on Thu Nov 10, 2011 4:34 pm

ok cool, just did a google search on that, so gpGlobals->curtime basically then tells you the current time since the game started? So you could for instance use that command in conjunction with OnPlayerPickup to record the time at which that object was picked up? This is very helpful, thanks.
PsychoJim
Member
Member
 
Joined: Tue Aug 23, 2011 12:58 pm

Re: total newb looking for some help with modding

Postby zombie@computer on Thu Nov 10, 2011 7:20 pm

yep, curtime is the amount of seconds since the start of the game.
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: total newb looking for some help with modding

Postby PsychoJim on Fri Nov 11, 2011 2:09 pm

So, where can I find a resource that explains the various terms within the source code?
Once you know that they exist, functions such as OnPlayerPickup() and Curtime might seem intuitively obvious based on their names, but where did you guys obtain this knowledge in the first place?
What I'm really looking for is some kind of guide or tutorial that bridges the gap between setting up your first mod and actually acquiring the skills to do something with that mod beyond just changing the speed of the rocket launcher...
PsychoJim
Member
Member
 
Joined: Tue Aug 23, 2011 12:58 pm

Re: total newb looking for some help with modding

Postby Gary on Fri Nov 11, 2011 3:54 pm

A lot is from experience. A lot can also be learned from reading the VDC.
Have a question related to modding or something I posted? Something that needs staff attention? I haven't been active lately, but feel free to PM me or message me on Steam(link below)

User avatar
Gary
Interlopers Staff
Interlopers Staff
 
Joined: Wed Dec 16, 2009 12:40 am
Location: USA, FL

Re: total newb looking for some help with modding

Postby stoopdapoop on Sat Nov 12, 2011 8:25 am

spent a very very very long time reading chunks of the existing code before I felt comfortable writing any of my own.

Just try to think existing objects that do (or may do) something similar to what you're trying to do. If you can't think of anything, break it down into parts and try to think of what existing code might do those smaller things.
I'm Brown
Image
User avatar
stoopdapoop
Veteran
Veteran
 
Joined: Sun Aug 21, 2005 2:14 am
Location: Ann Arbor, MI

Re: total newb looking for some help with modding

Postby PsychoJim on Wed Nov 16, 2011 2:32 pm

thanks for the further replies everyone.
stoopdapoop, when you say you "spent a very very very long time reading chunks of the existing code" exactly how much time do you mean here? It might help me to set more realistic targets if I know how long it's taken others to get good at modding.
PsychoJim
Member
Member
 
Joined: Tue Aug 23, 2011 12:58 pm

Re: total newb looking for some help with modding

Postby PsychoJim on Tue Nov 22, 2011 9:03 pm

Ok so I'm taking a step back with this and trying to break it down into the basics.
The first thing I need to do is to get the game to open a text file, and to write to this text file when an in-game event occurs.

I have tried then taking a snippet of code like this:
FileHandle_t fh = filesystem->Open( "MyLogFile.txt", "a+", "MOD");
if (fh)
{
char* text = "Player picked up object";
filesystem->Write(text, V_strlen(text), fh);
filesystem->Close(fh);
}

Then I searched within the source code for terms such as OnPlayerPickup or OnTakeDamage, and inserted the above code at these points. My hope was that this would open the log file and write to it when an object was picked up or the player took damage, for instance. However this approach has not worked. No log file has been created, and no error messages have come up to indicate that there is anything wrong with my code.

If anyone could steer me in the right direction it would really be a massive help. Thanks!
PsychoJim
Member
Member
 
Joined: Tue Aug 23, 2011 12:58 pm

Re: total newb looking for some help with modding

Postby Jordash on Wed Nov 23, 2011 12:30 pm

Maybe you need the file to already exist, you're just telling it to open, I'm not sure if the file system would create a file if it didn't find something it was looking for.
User avatar
Jordash
Been Here A While
Been Here A While
 
Joined: Mon Sep 21, 2009 10:36 am
Location: Perth, Australia
Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users

cron