Forum

DP Bot Spawning

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

DP Bot Spawning

Postby Junrall » Sat Jan 16, 2010 8:07 am

I'm spawning bots using DP's "spawnclient" and am using the snipet of code example provided within the dpextensions.qc.

When bots spawn I noticed that they aren't facing in the correct direction... actually, all of the bots are facing in the same direction.
Are they somehow ignoring self.angles = spot.angles in PutClientInServer?
Good God! You shot my leg off!
User avatar
Junrall
 
Posts: 191
Joined: Mon Sep 21, 2009 12:27 am
Location: North West Oregon, USA

Postby c0burn » Sat Jan 16, 2010 12:18 pm

Try including http://icculus.org/twilight/darkplaces/files/sv_user.qc in your progs.src above your client.qc, and in PlayerPrePhysics() at the end put

if (clienttype(self) == CLIENTTYPE_BOT)
SV_PlayerPhysics();
c0burn
 
Posts: 208
Joined: Fri Nov 05, 2004 12:48 pm
Location: Liverpool, England

Postby Junrall » Sat Jan 16, 2010 8:18 pm

Hi c0burn and thanks,

I've included sv_user.qc, but am still having the same problem. I've looked through the qc file a bit and am not sure where it would orient the bot to the proper spawning angles. Also, I don't have PlayerPrePhysics() in any of my qc files... did you mean PlayerPreThink?

Here are a few images of what I am seeing:

Image Image
Image
In all images the bot should be facing toward you.

As you hop into the start level and go to these areas you will see that the above bots all face the same direction.

As mentioned in my first post I am using DP's "spawnclient". Is it true that DP treats these bots the same as real clients? Or do I need to plug in some code to get them to face in the proper angles?
Good God! You shot my leg off!
User avatar
Junrall
 
Posts: 191
Joined: Mon Sep 21, 2009 12:27 am
Location: North West Oregon, USA

Postby Spike » Sat Jan 16, 2010 9:16 pm

players have a .v_angle field which logically overwrites their .angles.
.angles only overwrites .v_angles when fixangle is true.
Not sure how bots interact with any of that. Try setting .v_angle.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby c0burn » Sat Jan 16, 2010 9:50 pm

Spike wrote:players have a .v_angle field which logically overwrites their .angles.
.angles only overwrites .v_angles when fixangle is true.
Not sure how bots interact with any of that. Try setting .v_angle.


As they are true clients they should mirror client behaviour. Looks like a bug to me.
c0burn
 
Posts: 208
Joined: Fri Nov 05, 2004 12:48 pm
Location: Liverpool, England

Postby c0burn » Sat Jan 16, 2010 11:39 pm

Change

self.angles = spot.angles;

in PutClientInServer() to

self.angles = self.v_angle = spot.angles;

Fixed it for me.
c0burn
 
Posts: 208
Joined: Fri Nov 05, 2004 12:48 pm
Location: Liverpool, England

Postby Junrall » Sun Jan 17, 2010 1:44 am

c0burn wrote:Change

self.angles = spot.angles;

in PutClientInServer() to

self.angles = self.v_angle = spot.angles;

Fixed it for me.


And for me as well. Thanks!

Well now, that seems odd. Do you still think it is a bug or is it intentional?
Good God! You shot my leg off!
User avatar
Junrall
 
Posts: 191
Joined: Mon Sep 21, 2009 12:27 am
Location: North West Oregon, USA

Postby Wazat » Sun Jan 17, 2010 5:07 am

Junrall wrote:Well now, that seems odd. Do you still think it is a bug or is it intentional?


Could be a bug, or just the natural consequences of how clients work. Human clients have .fixangle, which is auto-handled for them but (apparently) not for bots. Fixangle says to a human client "set your v_angles to your angles". This is apparently not occurring for bots, possibly to give the mod author full control of the bot. Or possibly it's a mistake...

Or possibly it's following a limitation in the framework. When you set the player's v_angle directly in QC, I believe it's set right back again by the client next frame (setting v_angle = someAngle does not affect the client's view). You have to use the camera writebyte to force-change the player's view. I would guess from this that an actual server->client message is triggered by setting .fixangle. However, bots are pseudo clients that have to do such things themselves.

Now that we've confirmed it is an issue with v_angle, a more general fix may be to have your bot code watch for .fixangle to be true, and set v_angles = self.angles when it is (before any code that frame tries to use .v_angles or .angles). Then you won't have to change the spawn code (and possibly lots of other code) to get the bot working.

I'm guessing if the issue is that your bot is using v_angle like any good bot should (emulating a true client), but that v_angle just wasn't being initialized on spawn by the bot code. In other words, your bot is v_angles driven and it sets its angles from that. When the bot spawns, the engine doesn't set its v_angles automatically from fixangle, and then your QC code probably sets the angles from v_angles. This undoes the self.angles = spot.angles spawn code and produces the problem you're seeing.

Fixangle is the only time .v_angle is driven by .angles (the rest of the time it's the other way around). If you watch for .fixangle and act on it, you can emulate clients properly.

The engine seems to leave a lot of stuff for fake clients to handle in the QC (friction for movetype_walk, etc), so this is par for the course. ;)

Hopefully I'm correct in these guesses and being helpful, instead of confusing. Good luck!
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.
Wazat
 
Posts: 771
Joined: Fri Oct 15, 2004 9:50 pm
Location: Middle 'o the desert, USA


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest