Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!
Difference between revisions of "DP SV BOTCLIENT"
From Quake Wiki
(New page: Constants: <pre> float CLIENTTYPE_DISCONNECTED = 0; float CLIENTTYPE_REAL = 1; float CLIENTTYPE_BOT = 2; float CLIENTTYPE_NOTACLIENT = 3; </pre> Builtin definitions: <pre> entity() spawnc...) |
|||
Line 57: | Line 57: | ||
parms work the same on bot clients as they do on real clients, and do carry from level to level | parms work the same on bot clients as they do on real clients, and do carry from level to level | ||
+ | [[Category:DarkPlaces]] |
Latest revision as of 02:10, 25 March 2013
Constants:
float CLIENTTYPE_DISCONNECTED = 0; float CLIENTTYPE_REAL = 1; float CLIENTTYPE_BOT = 2; float CLIENTTYPE_NOTACLIENT = 3;
Builtin definitions:
entity() spawnclient = #454; // like spawn but for client slots (also calls relevant connect/spawn functions), returns world if no clients available float(entity clent) clienttype = #455; // returns one of the CLIENTTYPE_* constants
Spawns a client with no network connection, to allow bots to use client slots with no hacks.
How to use:
// to spawn a bot local entity oldself; oldself = self; self = spawnclient(); if (!self) { bprint("Can not add bot, server full.\ "); self = oldself; return; } self.netname = "Yoyobot"; self.clientcolors = 12 * 16 + 4; // yellow (12) shirt and red (4) pants ClientConnect(); PutClientInServer(); self = oldself; // to remove all bots local entity head; head = find(world, classname, "player"); while (head) { if (clienttype(head) == CLIENTTYPE_BOT) dropclient(head); head = find(head, classname, "player"); } // to identify if a client is a bot (for example in PlayerPreThink) if (clienttype(self) == CLIENTTYPE_BOT) botthink();
See also DP_SV_CLIENTCOLORS DP_SV_CLIENTNAME DP_SV_DROPCLIENT
How it works:
Creates a new client, calls SetNewParms and stores the parms, and returns the client.
//this intentionally does not call SV_SendServerinfo to allow the QuakeC a chance to set the netname and clientcolors fields before actually spawning the bot by calling ClientConnect and PutClientInServer manually
on level change ClientConnect and PutClientInServer are called by the engine to spawn in the bot (this is why clienttype() exists to tell you on the next level what type of client this is).
parms work the same on bot clients as they do on real clients, and do carry from level to level