View previous topic :: View next topic |
Author |
Message |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Thu Aug 09, 2007 2:03 am Post subject: Impulse commands |
|
|
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 |
|
 |
Monster

Joined: 07 Jan 2006 Posts: 94 Location: North Carolina
|
Posted: Thu Aug 09, 2007 4:03 am Post subject: |
|
|
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 |
|
 |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Thu Aug 09, 2007 4:26 am Post subject: |
|
|
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 |
|
 |
scar3crow Inside3D Staff

Joined: 18 Jan 2005 Posts: 837 Location: Las Vegas, NV
|
Posted: Thu Aug 09, 2007 8:46 pm Post subject: |
|
|
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 |
|
 |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Fri Aug 10, 2007 2:26 pm Post subject: |
|
|
The same bots don't need to transfer from map to map. As long as there are some bots around I'm happy.
Can someone help me out with the stuffcmd code? _________________ Welcome to the Overlook Hotel 69.113.123.178:27500 |
|
Back to top |
|
 |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Sat Aug 11, 2007 12:07 am Post subject: |
|
|
Can someone tell me how to use stuffcmds? _________________ Welcome to the Overlook Hotel 69.113.123.178:27500 |
|
Back to top |
|
 |
FrikaC Site Admin

Joined: 08 Oct 2004 Posts: 947
|
Posted: Sat Aug 11, 2007 3:05 am Post subject: |
|
|
I wonder why I didn't put that bot return feature in the QW version. Must've been too tired. |
|
Back to top |
|
 |
scar3crow Inside3D Staff

Joined: 18 Jan 2005 Posts: 837 Location: Las Vegas, NV
|
Posted: Sat Aug 11, 2007 6:26 am Post subject: |
|
|
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 |
|
 |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Sat Aug 11, 2007 9:25 pm Post subject: |
|
|
Thanks, I'll give it a shot! _________________ Welcome to the Overlook Hotel 69.113.123.178:27500 |
|
Back to top |
|
 |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Sat Aug 11, 2007 10:21 pm Post subject: |
|
|
I'm confused. What file am I changing? defs.qc?  _________________ Welcome to the Overlook Hotel 69.113.123.178:27500 |
|
Back to top |
|
 |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Sun Aug 12, 2007 9:24 pm Post subject: |
|
|
Ok, I got it to work
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
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 |
|
 |
Sajt
Joined: 16 Oct 2004 Posts: 1026
|
Posted: Mon Aug 13, 2007 12:05 am Post subject: |
|
|
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 |
|
 |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Mon Aug 13, 2007 12:22 am Post subject: |
|
|
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 |
|
 |
Orion

Joined: 12 Jan 2007 Posts: 413 Location: Brazil
|
Posted: Mon Aug 13, 2007 3:14 pm Post subject: |
|
|
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!  _________________ There's no signature here. Stop looking for one. |
|
Back to top |
|
 |
Preach
Joined: 25 Nov 2004 Posts: 122
|
Posted: Mon Aug 13, 2007 3:44 pm Post subject: |
|
|
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 |
|
 |
|