DarkPlaces Engine Dev?

Discuss programming topics for the various GPL'd game engine sources.
Post Reply
marie
Posts: 4
Joined: Fri Apr 11, 2008 2:01 am

DarkPlaces Engine Dev?

Post by marie »

Hi. Are there any forums dedicated to engine development, DarkPlaces specifically? I'm working on learning the DP code to try out some ideas I have.

Right now I'm stuck on filtering model names of entities to find out exactly who is a player, and whether that player is on my team- where can I find what model name characterizes a player, and how would I filter for this in C?


Having found these entities, it would then be possible to do a traceline check to see if they are behind any objects?
traceline(cl.entities[cl.playerentity].state_current.origin, e.origin, FALSE, world);
if (trace_ent == target);
// this ought to do it?


VectorSubtract(cl.entities[cl.playerentity].state_current, e->state_current.origin, vekt);
sqrt(DotProduct(vekt, vekt));
//this should give me the distances between the two entities?

Now how would I find and pick the shortest distance, and make this all into a useable code (how would I write it out) for finding the nearest entity that is a player? Register a new variable, define it in a config or/and default parameters? Sorry I'm very new to coding, and a bit lost. (Seems like the documentation on DarkPlaces is quite scarce!)

Thanks for any help :)
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Post by Baker »

On the player/team part of your question:

There may be a better way and/or different ways in DarkPlaces, but in the standard Quake engine:

1) any entity number less than the maxscoreboard count is a player.

2) To check if a player is on the same team, extract the pants color from the player color value.
Lardarse
Posts: 266
Joined: Sat Nov 05, 2005 1:58 pm
Location: Bristol, UK

Post by Lardarse »

There isn't really a forum as such, but if LordHavoc notices this (and I think that there's a good chacne that he might), then he will be able to respond. The main place to discuss DarkPlaces development is [url=irc://irc.anynet.org/darkplaces]#darkplaces on irc.anynet.org[/url]

Regarding your question, is it not easier to find players by looking for entity.classname == "player" ?

As for finding the nearest teammate... if all you're doing is comparing distances, then the square root is unnecessary. There was a thread around here a while ago that discussed nearest entities. I'll edit it into this post if I find it.
LordHavoc
Posts: 322
Joined: Fri Nov 05, 2004 3:12 am
Location: western Oregon, USA
Contact:

Re: DarkPlaces Engine Dev?

Post by LordHavoc »

marie wrote:Hi. Are there any forums dedicated to engine development, DarkPlaces specifically? I'm working on learning the DP code to try out some ideas I have.

Right now I'm stuck on filtering model names of entities to find out exactly who is a player, and whether that player is on my team- where can I find what model name characterizes a player, and how would I filter for this in C?
First I'd like to ask what you're doing with this? Not much reason for engine code to care about who is and is not a player and what team they are on, at least that I can think of (there are two uses I can think of, both of which with cheating implications).

The only way to find out the team of a player is to look at cl.scores[entnumber - 1] (assuming entnumber is >= 1 && < cl.maxclients), that struct is the scoreboard entry for the player for that entity.

You won't find hardly any code in DarkPlaces that makes assumptions regarding player entities, and what exists is QW specific (for example in gl_rmain.c the r_qwskincache code checks for this case).

The traceline function you're looking for is CL_Move.

Let me know what you have in mind and I can give much more direct tips.
LordHavoc
Posts: 322
Joined: Fri Nov 05, 2004 3:12 am
Location: western Oregon, USA
Contact:

Post by LordHavoc »

Lardarse wrote:There isn't really a forum as such, but if LordHavoc notices this (and I think that there's a good chacne that he might), then he will be able to respond. The main place to discuss DarkPlaces development is [url=irc://irc.anynet.org/darkplaces]#darkplaces on irc.anynet.org[/url]

Regarding your question, is it not easier to find players by looking for entity.classname == "player" ?

As for finding the nearest teammate... if all you're doing is comparing distances, then the square root is unnecessary. There was a thread around here a while ago that discussed nearest entities. I'll edit it into this post if I find it.
entity.classname is not known in the client engine, I think you're thinking of CSQC modding, or ordinary quake modding on the server.
marie
Posts: 4
Joined: Fri Apr 11, 2008 2:01 am

Post by marie »

I often babysit three little boys (ages 11, 9, and 6) who are absolutely terrible at aiming, so I was hoping to make a handicap much like in Goldeneye 007 that helps with finding targets. They tend to aim at the sky, or their feet unwittingly, though they do love the idea of firstpersonshooters and blowing stuff up. They have an N64 and a Gamecube at their dad's, but I sit for their mom who has nothing but laptops. I owe much of my video game interest/prowess to playing with them :)

Ideally, I'd be able to set their aim somewhere in the general vicinity of opponent bots. (This handicapping is for our LAN parties and not for use on public servers of any sort).

I have tried a few other things such as limiting the bounds of the vertical pitch, but this doesn't seem to help much, they really have a hard time finding opponents and proper targets.

I was doing the same thing Lardarse was, mistakenly mixing QuakeC and C.

Again, any help would be greatly appreciated!
LordHavoc
Posts: 322
Joined: Fri Nov 05, 2004 3:12 am
Location: western Oregon, USA
Contact:

Post by LordHavoc »

marie wrote:Ideally, I'd be able to set their aim somewhere in the general vicinity of opponent bots. (This handicapping is for our LAN parties and not for use on public servers of any sort).
There is the sv_aim cvar on servers, which if set to a value like 0.9 will do fairly significant autoaim on pitch only - it shouldn't be hard to add yaw changes to this, please look at VM_SV_aim in svvm_cmds.c - you should be able to just add this line above VectorNormalize (end);

Code: Select all

VectorCopy(dir, end);
Then experiment with sv_aim until a satisfactory value is found, it normally is in the range of 0.9 to 1.0 (1.0 being no autoaim, and smaller values being progressively more).

This won't make their view track someone or anything, it just makes shots 'snap' to the target, and makes use of existing Quake features.
marie
Posts: 4
Joined: Fri Apr 11, 2008 2:01 am

Post by marie »

Hrm, that doesn't seem to work. If the server sets sv_aim .1, a player should then be able to aim and shoot directly over an opponent's head and still hit them? This doesn't seem to be the case at all.

And their view won't be changed by this anyway? I mean, if they are aiming at the floor it won't move their crosshair towards an opponent? That's really what I'm trying to achieve.
LordHavoc
Posts: 322
Joined: Fri Nov 05, 2004 3:12 am
Location: western Oregon, USA
Contact:

Post by LordHavoc »

marie wrote:Hrm, that doesn't seem to work. If the server sets sv_aim .1, a player should then be able to aim and shoot directly over an opponent's head and still hit them? This doesn't seem to be the case at all.
This does depend on whether the mod supports the aim function, most do, but dpmod for example does not.
marie wrote:And their view won't be changed by this anyway? I mean, if they are aiming at the floor it won't move their crosshair towards an opponent? That's really what I'm trying to achieve.
That definitely has to be done in the client, I've seen that when I played Halo 3 at a lan party.

You seem to be on the right track for that, so just resume the questions :)
marie
Posts: 4
Joined: Fri Apr 11, 2008 2:01 am

Post by marie »

I'm still having trouble filtering for player entities.
I initially considered doing find(world, classname, "player"), which won't work, and I suppose fl_client won't help either.
Would a mere IF statement work here? if( ... ) What exactly would this be incorporating cl.scores?

Edit: I confused myself.

Also, what are the necessary parameters and output for CL_Move(); ?

I think I know where to go as soon as I've found & selected the nearest player entity. I'd use AnglesFromVectors with the entity's vector and set the cl.viewangles[PITCH] & cl.viewangles[YAW] with that?

Thanks again! :)
Post Reply