General Code Structure Question

Xalen

Newbie
Joined
Feb 4, 2011
Messages
2
Reaction score
0
Hello there, I have a rather conceptual question for someone with knowledge of HL2 source and its general structure...

  • I need to create 3-4 different 'attributes', which are essentially sliders that range from 0-100.
  • I want these attributes to be directly manipulable via keyboard input(e.g. when the user presses 't' attribute_1 will increase by 1, and when she presses 'g' it will decrease by 1).
  • I want the value of these attributes to have widespread effects throughout the game (e.g. player run speed, weapon damage, and also entity inputs/outputs within Hammer).

My question is: What is the best way to add this kind of functionality on to the HL2 Source. Note I'm not asking how to write the code/logic itself, that should be a piece of cake, but rather how to begin. Where would something like this fit into the code as a whole?

For example, should it be a self-contained logical entity? If so, how could I access direct keyboard input? Should I write it as a new class derived from cbase.h or something similar? If so, how could I use it to send input/outputs to entities in Hammer? Will I need a combination of these two solutions?

Any advice, tutorials, or further questions would be greatly appreciated.

Thanks,
Nick
 
I'm not sure that you'd need an entity for this. It sounds more client-side.
I'm not really familiar with Source programming, but there's probably a way to get key presses from the client. For the entity input/output, maybe you could send a server command with an ent_fire statement.
 
Hey Tschumann,

Thanks for the reply. I was able to find a solution last night after digging through the game_ui entity code a little bit, which does something similar. It provides a good example on how to get a pointer to the player and capture key presses from there.

N
 
Back
Top