Forum

Impulse commands

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Impulse commands

Postby redrum » Thu Aug 09, 2007 2:03 am

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: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby Monster » Thu Aug 09, 2007 4:03 am

Use saved1 1. Put it in your autoexec.cfg. I don't know if this will work with Quakeworld, but it works in Netquake.
User avatar
Monster
 
Posts: 101
Joined: Sat Jan 07, 2006 10:27 pm
Location: North Carolina

Postby redrum » Thu Aug 09, 2007 4:26 am

No, does not work for QW.
Is there a work around?
Maybe edit some code?
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby scar3crow » Thu Aug 09, 2007 8:46 pm

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?
User avatar
scar3crow
InsideQC Staff
 
Posts: 1054
Joined: Tue Jan 18, 2005 8:54 pm
Location: Alabama

Postby redrum » Fri Aug 10, 2007 2:26 pm

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: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby redrum » Sat Aug 11, 2007 12:07 am

Can someone tell me how to use stuffcmds?
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby FrikaC » Sat Aug 11, 2007 3:05 am

I wonder why I didn't put that bot return feature in the QW version. Must've been too tired.
FrikaC
Site Admin
 
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Postby scar3crow » Sat Aug 11, 2007 6:26 am

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.
User avatar
scar3crow
InsideQC Staff
 
Posts: 1054
Joined: Tue Jan 18, 2005 8:54 pm
Location: Alabama

Postby redrum » Sat Aug 11, 2007 9:25 pm

Thanks, I'll give it a shot!
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby redrum » Sat Aug 11, 2007 10:21 pm

I'm confused. What file am I changing? defs.qc? :(
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby redrum » Sun Aug 12, 2007 9:24 pm

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: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby Sajt » Mon Aug 13, 2007 12:05 am

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.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby redrum » Mon Aug 13, 2007 12:22 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.
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby Orion » Mon Aug 13, 2007 3:14 pm

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

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! :)
User avatar
Orion
 
Posts: 476
Joined: Fri Jan 12, 2007 6:32 pm
Location: Brazil

Postby Preach » Mon Aug 13, 2007 3:44 pm

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: 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

Next

Return to QuakeC Programming

Who is online

Users browsing this forum: Bing [Bot] and 1 guest