AI idea?

Puzzlemaker

Newbie
Joined
Aug 1, 2004
Messages
915
Reaction score
0
Well, I was looking through the SDK stuff, and I found something of interest; the AI does not automatically take cover, or very rarely do, unless they are forced to by making it a standoff, like when you are trying to get past combine barricades. At least, I think thats right, and when I played HL2 again I found that to be pretty much true. They dont like taking cover, popping up, shooting you, and taking cover again very much, even though that would be much more effective then the kamakazi approuch.

So, I was thinking about trying to see if I could mod it a tad, mess with the AI, make them more defensive. However...

First off, I dont know hungarian notation, or whatever its called. Thats the m_fl stuff before each variable. I know what SOME of it is, but not enough.

Second off, I dont know what a lot of the functions do, and the commenting isn't that good; in fact, its terrible. Augh. Is there a site that can tell me what a lot of this does? Like, a list? Or something like the Java API?

I am very interested in mods, but I have never actually wanted to create one, until now, so I really never bothered to look up the technical details.

Note: I already posted this, but in the wrong section, and no admins where moving it... so oh well. Re-posted.
 
Not done much mod coding myself, so here's a bit on notation.

m_xxxxxx = member variable of a class
g_xxxxxx = global variable
x_fxxx / x_flxxx = floating point variable (i think the 2nd is correct there)
x_ixxx = integer variable
x_pxxx pointer variable
x_exxx enumeration variable

Obviously 'x's can be replaced by whatever is appropriate. Usually you capitalise words in variable names. If you have a variable local to a function you can leave off the g_ / m_ (at least i do)

e.g. m_iThinkTime would be an integer member variable, (maybe) relating to the time in miliseconds between each update for an object.
g_pObjects could be a global pointer, to a list of objects.
 
ThinkTime would be a float - Source deals with fractions of seconds :p

-Angry Lawyer
 
Um... And not a double? Dont floats have a bunch of problems with them?

EDIT: And thanks for your help!
 
Double's have the same problems. Perhaps less frequent though. Both are inaccurate data types, with doubles having twice as many bits available to represent the number.

Angry Lawyer: I've not used the SDK, I assumed it delt in miliseconds, guess i was wrong though! :)
 
ah, thanks for your help.

Now... one more question...

If there is a list listing what the classes/functions in the SDK do, that would be nice. Because the commenting is HORRIBLE.

Oh, and what is the URL to the tutorial for making a mod? A bit of a newb to this whole mod-making thing.
 
Hmm. Never known a library to return time as a floating point. Usually seconds, millis, or nanos as an integer (usually long) since 1970, Jan 1, midnight.

Maybe a good project for HL2.net would be to generate such documentation. I haven't had a look, but I hear it doesn't exist.
 
psyno said:
Hmm. Never known a library to return time as a floating point. Usually seconds, millis, or nanos as an integer (usually long) since 1970, Jan 1, midnight.

Maybe a good project for HL2.net would be to generate such documentation. I haven't had a look, but I hear it doesn't exist.
The two most used APIs (in windows) for time measuring is GetTickCount, which is miliseconds since turnon and the PerformanceCounter APIs, which together can measure fractions of miliseconds (if hardware suported). It returns an integer, but you do some dividing to get the time, so perhaps it could be a float in that respect. But yeah, almost all time measurements are integers, not floating point.

I'd be suprised if valve used a float for time, but then having not looked at the source SDK i don't know (can't be bothered to install it just for this).
 
gpGlobals->curtime returns a float. Search for it in the code - whenever they want something to happen in five seconds, they do something like this in one of the functions:

Code:
m_fNextActivate = gpGlobals->curtime + 5.0f

And then in the think function (which gets run every tick):

Code:
if (gpGlobals->curtime >= m_fNextActivate && m_fNextActivate != 0.0f)
{
     m_fNextActivate = 0;
     [do something here]
}

-Angry Lawyer
 
There's no point in using a double when a float would do the job. Memory conservation where ever possible is important.
 
psyno said:
Maybe a good project for HL2.net would be to generate such documentation. I haven't had a look, but I hear it doesn't exist.

Bugger. Ill have to go through by hand then.
 
Back
Top