Skip to content

Commit

Permalink
Added RA2 style fast weapon switching to 'weaponswap'
Browse files Browse the repository at this point in the history
  - Automatic BOT management via 'autobot' CVar
    * Automatically add/remove bots based on connected clients
  - Added game setup spectator mode via 'zigintro' CVar
    * New spectator dogtag in pak file
  - Updated .pak file,
    * Added spectator dogtag
    * Removed duplicated sounds from baseq2 pak0.pak
  • Loading branch information
DirtBagXon committed Jul 15, 2020
1 parent d1344a0 commit bb27f2a
Show file tree
Hide file tree
Showing 18 changed files with 254 additions and 29 deletions.
Binary file modified 3zb2/pak10.pak
Binary file not shown.
2 changes: 2 additions & 0 deletions 3zb2/zig.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ exec addbot.cfg
set dmflags 16388
set maxclients 8
set autospawn 3
set autobot 0

set zigmode 1
set zigspawn 1
set zigkiller 1
set zigrapple 0
set zigintro 0
set respawn_protection 1
set ctf 0
set aimfix 1
Expand Down
4 changes: 3 additions & 1 deletion CONFIG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ Console commands
vwep Visible weapon on/off (default on = 1, off = 0)
maplist Set the maplist section name (default = "default")
autospawn Autospawn (default 0, x = number of bots)
autobot Manage bots based on real clients (default 0, x = number of clients)
chedit Chaining mode on/off (default off = 0, on = 1)
zigmode Capture and Hold (ZigFlag) (default off = 0, on = 1)
zigspawn ZigFlag returns home after 60s (default on = 1, off = 0)
zigkiller ZigFlag holder kill gives bonus frag (default on = 1, off = 0)
zgrapple Add CTF grapple to none CTF game s(default off = 0, on = 1)
zigrapple Add CTF grapple to none CTF games (default off = 0, on = 1)
zigintro Add spectator mode on game start (default off = 0, on = 1)
botlist Set the botlist section name (default = "default")
ctf CTF mode on/off (default off = 0, on = 1)
aimfix Enable more accurate aiming (default on = 1, off = 0)
Expand Down
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This is a custom port of the 3rd Zigock Bot II to Quake II - Yamagi Quake II is recommended. \
All warnings (up to GCC9) and unused variables have been addressed in the original source. \
The code also has handpicked backport fixes, enhancements and features applied from various \
sources: `tastyspleen`, `yquake2`, `OpenTDM`, `OpenFFA` and custom.
sources: `tastyspleen`, `yquake2`, `OpenTDM`, `OpenFFA` and many custom.

This was modified for my own use and driven by nostalgia for the Quake II servers of the 90's. \
There are many heavily modified versions of the Quake II engine, this mod tries to keep the look and feel of \
Expand All @@ -17,17 +17,19 @@ On global linux installs, **e.g.** `/usr/share/games`, you may need to specify `

Bot chaining routes are supplied, further routes can be (re)created via the mod command `chedit` (See `CONFIG.txt`)

### ZigMode ZigFlag (Capture and Hold)
### ZigMode ZigFlag (Capture and Hold) - https://zigflag.net

The premise is simple: **Get the flag and keep it** - *plays on standard Deathmatch maps*.

The original `zigmode` was released belated, buggy and only half implemented, I attempted to make this feature a little \
more refined, just for fun. I was trying to keep the look and feel of the original deathmatch, but with a few bells and whistles.
more refined, just for fun. I was trying to keep the look and feel of the original deathmatch, but with a few bells and \
whistles. However `zigflag` turned into a fairly customised game.

* Simple HUD enhancements.
* Automatic bot control.
* Autospawn bots at level start.
* Visual/Audio notifications to Flagholder.
* Flagholder dogtag displayed on scoreboard.
* Customised dogtags displayed on scoreboard.
* Optional Flag respawn feature.
* Optional Flagholder frag bonus.
* Optional Flag sucks health from subdued holder.
Expand All @@ -41,6 +43,8 @@ more refined, just for fun. I was trying to keep the look and feel of the origin

..and many bugfixes was the final outcome of playing around with the code.

A ZigFlag server can sometimes be found running at `quake2://quake.zigflag.net:27910`

The mod also supports skin and model teams with appropriate bonuses and penalties on Flag possession and `FRIENDLY_FIRE`.

The changes subtly alter the game dynamics and improve on the original zigmode game element, IMHO. \
Expand All @@ -61,6 +65,7 @@ set zigmode 1
set zigspawn 1
set zigkiller 1
set zigrapple 0
set zigintro 0
set ctf 0
set aimfix 1
set combathud 1
Expand All @@ -71,6 +76,7 @@ set playerid 1
set weaponswap 1
set botlist default
set autospawn 3
set autobot 0
set vwep 1
set maxclients 16
set respawn_protection 1
Expand Down Expand Up @@ -157,6 +163,9 @@ sudo cp release/game.so /usr/share/games/quake2/3zb2
To start `$` bots automatically, append:

+set autospawn $
+set autobot $

`autobot` will automatically **remove/add** `autospawn` number of bots dependant on `autobot` value of real clients connected

### Spawn bots at the farthest point

Expand Down Expand Up @@ -230,6 +239,10 @@ Option to add grapple to the fray - CTF `pak0.pak` required.

zigrapple 1

Add spectator mode to game start (server mode)

zigintro 1

`Capture and Hold (ZigFlag)` mode for Deathmatch/Team games:

zigmode 1
Expand Down
100 changes: 99 additions & 1 deletion src/bot/func.c
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ void Bot_LevelChange()

SpawnWaitingBots = k;

if (autospawn->value > 0) {
if (autospawn->value > 0 && !autobot->value) {
int delta = autospawn->value - SpawnWaitingBots;
while (delta-- > 0) {
SpawnBotReserving();
Expand Down Expand Up @@ -1147,3 +1147,101 @@ void Cmd_AirStrike(edict_t *ent)
gi.linkentity (viper);
}

/*
===================================
Return the number of real clients
No BOTS
===================================
*/
int RealClients ()
{
int i;
int realclients = 0;
edict_t *ent;

for (i = 0; i < maxclients->value; i++)
{
ent = g_edicts + 1 + i;

if (!ent->inuse)
continue;

if (ent->client && !(ent->svflags & SVF_MONSTER))
{
if(zigintro->value) {
if(ent->client->pers.joined)
realclients++;
}
else
realclients++;
}
}
return realclients;
}

/*
===================================
Return the number of BOT clients
===================================
*/
int BotClients ()
{
int i;
int botclients = 0;
edict_t *ent;

for (i = 0; i < maxclients->value; i++)
{
ent = g_edicts + 1 + i;

if (!ent->inuse)
continue;

if (ent->client && (ent->svflags & SVF_MONSTER))
botclients++;
}
return botclients;
}

/*
===================================
Control Bots in 'autobot'
===================================
*/
void AutoBot ()
{
int clients,bots,i;
int delay = 300;
int buffer = 10 * autospawn->value;
int remaining = timelimit->value * 60 - level.time;
float startup = 15.0f;

clients = RealClients();
bots = BotClients();

if(level.time < startup)
delay = 100;

if(clients > autobot->value && bots > 0 && level.time > startup
&& remaining > 10) {
level.autobotframe = level.framenum;
for (i=0 ; i < bots ; i++)
RemoveBot();
}

if(clients <= autobot->value && bots == 0 && remaining > buffer
&& (level.framenum - level.autobotframe) > delay && !level.intermissiontime) {
for (i=0 ; i < autospawn->value ; i++) {
int delta = autospawn->value - SpawnWaitingBots;
while (delta-- > 0) {
SpawnBotReserving();
}
}
}
}
6 changes: 6 additions & 0 deletions src/g_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,12 @@ void Cmd_InvUse_f (edict_t *ent)
{
gitem_t *it;

if (ent->client->resp.spectator && !ent->client->pers.joined) {
ent->client->pers.joined = true;
spectator_respawn(ent);
return;
}

//ZOID
if (ent->client->menu) {
PMenu_Select(ent);
Expand Down
8 changes: 7 additions & 1 deletion src/g_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ cvar_t *vwep;
cvar_t *maplist;
cvar_t *botlist;
cvar_t *autospawn;
cvar_t *autobot;
cvar_t *zigmode;
cvar_t *zigspawn;
cvar_t *zigkiller;
cvar_t *zigrapple;
cvar_t *zigintro;
cvar_t *spawnbotfar;
cvar_t *respawn_protection;
int flagbounce;
Expand Down Expand Up @@ -397,7 +399,7 @@ CheckDMRules
*/
void CheckDMRules (void)
{
int i;
int i;
gclient_t *cl;

if (level.intermissiontime)
Expand Down Expand Up @@ -754,6 +756,10 @@ void G_RunFrame (void)
}


// autobot control
if(autobot->value && autospawn->value && level.framenum & 8)
AutoBot ();

// see if it is time to end a deathmatch
CheckDMRules ();

Expand Down
4 changes: 2 additions & 2 deletions src/g_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ void VelocityForHead (int damage, vec3_t v)

v[0] = damage * 10.0 * crandom();
v[1] = damage * 10.0 * crandom();
v[2] = 400.0 * crandom();
v[2] = 100.0 * random();

VectorScale (v, 0.7, v);
VectorScale (v, 0.35, v);
}

void VelocityForDamage (int damage, vec3_t v)
Expand Down
4 changes: 4 additions & 0 deletions src/g_save.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,16 @@ void InitGame (void)
maplist = gi.cvar ("maplist", "default", CVAR_SERVERINFO | CVAR_LATCH);
//autospawn
autospawn = gi.cvar ("autospawn", "0", CVAR_SERVERINFO | CVAR_LATCH);
//autobot
autobot = gi.cvar ("autobot", "0", CVAR_SERVERINFO | CVAR_LATCH);
//chain edit flag
chedit = gi.cvar ("chedit", "0", CVAR_LATCH);
//vwep support
vwep = gi.cvar ("vwep", "1", CVAR_LATCH);
//game mode
zigmode = gi.cvar ("zigmode", "0", CVAR_SERVERINFO| CVAR_LATCH);
//game setup
zigintro = gi.cvar ("zigintro", "0", CVAR_LATCH);
//ZOID
//This game.dll only supports deathmatch
if (!deathmatch->value) {
Expand Down
33 changes: 28 additions & 5 deletions src/g_spawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,27 @@ spawn_t spawns[] = {
{NULL, NULL}
};

/*
===============
Set the Observe mode string
===============
*/
void CSObserve()
{
char observe[32];
char tab[4];
char end[16];
char Highlight[MAX_STRING_CHARS];

sprintf(observe, "[");
sprintf(tab, "ENT");
sprintf(end, "] to Join");
HighlightStr(Highlight, tab, MAX_STRING_CHARS);
strcat(observe, Highlight);
strcat(observe, end);
gi.configstring(CS_OBSERVE, observe);
}

/*
===============
ED_CallSpawn
Expand Down Expand Up @@ -1052,6 +1073,7 @@ void SpawnEntities (char *mapname, char *entities, char *spawnpoint)
CTFSetupNavSpawn(); //ナビの設置
if(!chedit->value) G_FindItemLink(); //アイテムのリンク(通常時のみ)

CSObserve();
G_SpawnRouteLink();

if(zigmode->value == 1) zigflag_spawn = 1;
Expand Down Expand Up @@ -1293,10 +1315,10 @@ char *zig_statusbar =
// Chase Cam
"if 16 "
"xv 0 "
"yb -48 "
"xl 260 "
"string \"Chasing:\" "
"xv 170 "
"yb -80 "
"xl 230 "
"string \"Observing:\" "
"xv 160 "
"stat_string 16 "
"endif "

Expand All @@ -1322,7 +1344,7 @@ char *zig_statusbar =
// countdown
"if 30"
"xr -50 "
"yb -60 "
"yb -65 "
"xv 105 "
"stat_string 30 "
"endif "
Expand Down Expand Up @@ -1418,6 +1440,7 @@ void SP_worldspawn (edict_t *ent)
gi.configstring (CS_STATUSBAR, zig_statusbar);
gi.imageindex("i_zig");
gi.imageindex("zigtag");
gi.imageindex("spectag");

} else {
gi.configstring (CS_STATUSBAR, dm_statusbar);
Expand Down
1 change: 1 addition & 0 deletions src/header/bot.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ void Get_WaterState(edict_t *ent);
void Bot_Think (edict_t *self);
void PutBotInServer (edict_t *ent);
void SpawnBotReserving2(int *red,int *blue);
void AutoBot();

//Combat AI
void Combat_Level0(edict_t *ent,int foundedenemy,int enewep,float aim,float distance,int skill);
Expand Down
Loading

0 comments on commit bb27f2a

Please sign in to comment.