Impulse commands
Moderator: InsideQC Admins
39 posts
• Page 1 of 3 • 1, 2, 3
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!
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: The-Overlook-Hotel.game-server.cc
-

redrum - Posts: 410
- Joined: Wed Mar 28, 2007 11:35 pm
- Location: Long Island, New York
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?
just an idea, from a noncoder.
Though shouldnt the bots stay around as clients when the map changes through a changelevel?
-

scar3crow - InsideQC Staff
- Posts: 1054
- Joined: Tue Jan 18, 2005 8:54 pm
- Location: Alabama
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?
Can someone help me out with the stuffcmd code?
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
-

redrum - Posts: 410
- Joined: Wed Mar 28, 2007 11:35 pm
- Location: Long Island, New York
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.
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.
-

scar3crow - InsideQC Staff
- Posts: 1054
- Joined: Tue Jan 18, 2005 8:54 pm
- Location: Alabama
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.
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: The-Overlook-Hotel.game-server.cc
-

redrum - Posts: 410
- Joined: Wed Mar 28, 2007 11:35 pm
- Location: Long Island, New York
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.
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.
- Sajt
- Posts: 1215
- Joined: Sat Oct 16, 2004 3:39 am
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.
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: The-Overlook-Hotel.game-server.cc
-

redrum - Posts: 410
- Joined: Wed Mar 28, 2007 11:35 pm
- Location: Long Island, New York
At world.qc you'll find worldspawn. At the very bottom of the function you can do something like this:
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!
- Code: Select all
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!
-

Orion - Posts: 476
- Joined: Fri Jan 12, 2007 6:32 pm
- Location: Brazil
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
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.
- Code: Select all
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.
- Preach
- Posts: 122
- Joined: Thu Nov 25, 2004 7:20 pm
39 posts
• Page 1 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 1 guest
