Inside3D!
     

Impulse commands
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
redrum



Joined: 28 Mar 2007
Posts: 367
Location: Long Island, New York

PostPosted: Thu Aug 09, 2007 2:03 am    Post subject: Impulse commands Reply with quote

Guys, is there a way to have an impulse command automatically executed after map changes?

Can I edit some engine code to do this?

I'm trying to get frikbots to auto-join after map changes.

Thanks in advance!
_________________
Welcome to the Overlook Hotel 69.113.123.178:27500
Back to top
View user's profile Send private message Send e-mail
Monster



Joined: 07 Jan 2006
Posts: 94
Location: North Carolina

PostPosted: Thu Aug 09, 2007 4:03 am    Post subject: Reply with quote

Use saved1 1. Put it in your autoexec.cfg. I don't know if this will work with Quakeworld, but it works in Netquake.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
redrum



Joined: 28 Mar 2007
Posts: 367
Location: Long Island, New York

PostPosted: Thu Aug 09, 2007 4:26 am    Post subject: Reply with quote

No, does not work for QW.
Is there a work around?
Maybe edit some code?
_________________
Welcome to the Overlook Hotel 69.113.123.178:27500
Back to top
View user's profile Send private message Send e-mail
scar3crow
Inside3D Staff


Joined: 18 Jan 2005
Posts: 837
Location: Las Vegas, NV

PostPosted: Thu Aug 09, 2007 8:46 pm    Post subject: Reply with quote

stuffcmd to the server for the impulse 100 addbot whenever the match starts... might want to have rand() + a few seconds to make it a little random in timing.

just an idea, from a noncoder.

Though shouldnt the bots stay around as clients when the map changes through a changelevel?
Back to top
View user's profile Send private message AIM Address
redrum



Joined: 28 Mar 2007
Posts: 367
Location: Long Island, New York

PostPosted: Fri Aug 10, 2007 2:26 pm    Post subject: Reply with quote

The same bots don't need to transfer from map to map. As long as there are some bots around I'm happy. Smile

Can someone help me out with the stuffcmd code?
_________________
Welcome to the Overlook Hotel 69.113.123.178:27500
Back to top
View user's profile Send private message Send e-mail
redrum



Joined: 28 Mar 2007
Posts: 367
Location: Long Island, New York

PostPosted: Sat Aug 11, 2007 12:07 am    Post subject: Reply with quote

Can someone tell me how to use stuffcmds?
_________________
Welcome to the Overlook Hotel 69.113.123.178:27500
Back to top
View user's profile Send private message Send e-mail
FrikaC
Site Admin


Joined: 08 Oct 2004
Posts: 947

PostPosted: Sat Aug 11, 2007 3:05 am    Post subject: Reply with quote

I wonder why I didn't put that bot return feature in the QW version. Must've been too tired.
Back to top
View user's profile Send private message Send e-mail
scar3crow
Inside3D Staff


Joined: 18 Jan 2005
Posts: 837
Location: Las Vegas, NV

PostPosted: Sat Aug 11, 2007 6:26 am    Post subject: Reply with quote

redrum; quake wiki does a better job than I could, http://wiki.quakesrc.org/index.php/stuffcmd

So just incorporate a stuffcmd on the server start bit that calls impulse 100, in fact you could have it check the map its on and spawn an appropriate bot count.

For example, if the mapname is dm2 or dm3, it spawns 10 bots, but if its dm1, dm4 or dm6 it spawns 2, so on and so forth.
Back to top
View user's profile Send private message AIM Address
redrum



Joined: 28 Mar 2007
Posts: 367
Location: Long Island, New York

PostPosted: Sat Aug 11, 2007 9:25 pm    Post subject: Reply with quote

Thanks, I'll give it a shot!
_________________
Welcome to the Overlook Hotel 69.113.123.178:27500
Back to top
View user's profile Send private message Send e-mail
redrum



Joined: 28 Mar 2007
Posts: 367
Location: Long Island, New York

PostPosted: Sat Aug 11, 2007 10:21 pm    Post subject: Reply with quote

I'm confused. What file am I changing? defs.qc? Sad
_________________
Welcome to the Overlook Hotel 69.113.123.178:27500
Back to top
View user's profile Send private message Send e-mail
redrum



Joined: 28 Mar 2007
Posts: 367
Location: Long Island, New York

PostPosted: Sun Aug 12, 2007 9:24 pm    Post subject: Reply with quote

Ok, I got it to work Smile

I added stuffcmd(self, "impulse 100;\n"); to ClientConnect in client.qc.

I tried to add stuffcmd(self, "impulse 102;\n"); to ClientDisconnect to remove a bot when a client disconnects, but it did not work Sad

I want to do this b/c otherwise if people join then leave eventually there will be too many bots.

Also, if someone could help me with adding a different number of bots depending on which map will be loaded that would be great.

Thanks.
_________________
Welcome to the Overlook Hotel 69.113.123.178:27500
Back to top
View user's profile Send private message Send e-mail
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Mon Aug 13, 2007 12:05 am    Post subject: Reply with quote

For one thing, don't use stuffcmd, as it sends the message to a single client, and if that client isn't the server (where the gamecode is run) it won't do anything.

localcmd("impulse 100\n");

That sends the message to the server. So your method, I think, would add a bot everytime a new client joins. (So if there are 4 clients there are 4 bots as well). If you want an independent number of bots, put it in worldspawn, preferably after a short timer.

But then again, you should probably just call the QC function that impulse 100 calls.
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Back to top
View user's profile Send private message
redrum



Joined: 28 Mar 2007
Posts: 367
Location: Long Island, New York

PostPosted: Mon Aug 13, 2007 12:22 am    Post subject: Reply with quote

Thanks, I think, I'm more confused now than before.

How do I go about adding it to Worldspawn?

I'm just beginning to learn how to do this stuff.

Thanks for the input, I appreciate it.
_________________
Welcome to the Overlook Hotel 69.113.123.178:27500
Back to top
View user's profile Send private message Send e-mail
Orion



Joined: 12 Jan 2007
Posts: 413
Location: Brazil

PostPosted: Mon Aug 13, 2007 3:14 pm    Post subject: Reply with quote

At world.qc you'll find worldspawn. At the very bottom of the function you can do something like this:

Code:

local float bcnt;
bcnt = stof(infokey(world, "bot_num"));
while (bcnt > 0)
{
   localcmd ("impulse 100\n");
   bcnt = bcnt - 1;
}


stof() will convert a string to a float.
To add a certain number of bots automatically, type "serverinfo bot_num #" without quotes at the console, which # is the number of bots, and restart the server to take effect.

Hope this helps! Smile
_________________
There's no signature here. Stop looking for one.
Back to top
View user's profile Send private message
Preach



Joined: 25 Nov 2004
Posts: 122

PostPosted: Mon Aug 13, 2007 3:44 pm    Post subject: Reply with quote

Although the above code is correct for making an impulse execute when the server starts, it's a rather convoluted way of making bots spawn when the server starts. For one thing, because all of those localcmds will be run in the same frame, it's only going to add one bot to the game. A better way of adding bots would be

Code:

local float bcnt, f;
f = cvar("skill");
bcnt = stof(infokey(world, "bot_num"));
while (bcnt > 0)
{
   BotConnect(0, 0, f);
   bcnt = bcnt - 1;
}


BotConnect is the qc function that starts a frikbot. I think it should be safe to do this in worldspawn, as long as it's after BotInit(). But I've not tested it, there could be issues.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group