From 8e8b5b7515e3bec8af1a71836ee48a533850f31f Mon Sep 17 00:00:00 2001 From: Dino <8dino2@gmail.com> Date: Fri, 1 Sep 2023 00:07:19 -0400 Subject: [PATCH] Save point --- actionlite/CMakeLists.txt | 4 +- actionlite/a_game.cpp | 1057 +++++++++++++++++++++++++++++++++++++ actionlite/a_game.h | 60 +++ actionlite/a_team.cpp | 389 +++++--------- actionlite/a_team.h | 12 +- actionlite/g_cmds.cpp | 12 +- actionlite/g_local.h | 27 +- actionlite/p_weapon.cpp | 10 +- actionlite/q_std.h | 2 +- 9 files changed, 1305 insertions(+), 268 deletions(-) create mode 100644 actionlite/a_game.cpp create mode 100644 actionlite/a_game.h diff --git a/actionlite/CMakeLists.txt b/actionlite/CMakeLists.txt index 840b01a..3497dc6 100644 --- a/actionlite/CMakeLists.txt +++ b/actionlite/CMakeLists.txt @@ -109,8 +109,8 @@ set(GAME_SRC set(CMAKE_CXX_FLAGS "-lm -ldl -fPIE -pie -lfmt" CACHE STRING "compile flags" FORCE) add_compile_options(-DKEX_Q2_GAME -DKEX_Q2GAME_EXPORTS -DNO_FMT_SOURCE -DKEX_Q2GAME_DYNAMIC) add_library(game SHARED ${GAME_SRC} ) -target_include_directories(game PUBLIC /usr/local/Cellar/jsoncpp/1.9.5/include /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/) -#target_include_directories(game PUBLIC /usr/include/jsoncpp) +#target_include_directories(game PUBLIC /usr/local/Cellar/jsoncpp/1.9.5/include /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/) +target_include_directories(game PUBLIC /usr/include/jsoncpp) set_target_properties(game PROPERTIES POSITION_INDEPENDENT_CODE ON diff --git a/actionlite/a_game.cpp b/actionlite/a_game.cpp new file mode 100644 index 0000000..6b6a895 --- /dev/null +++ b/actionlite/a_game.cpp @@ -0,0 +1,1057 @@ +#include "g_local.h" +#include "cgf_sfx_glass.h" + +#define MAX_MAP_ROTATION 1000 // just in case... +#define MAX_STR_LEN 1000 +#define MAX_TOTAL_MOTD_LINES 30 + +char *map_rotation[MAX_MAP_ROTATION]; +int num_maps, cur_map, rand_map, num_allvotes; // num_allvotes added by Igor[Rock] + +char motd_lines[MAX_TOTAL_MOTD_LINES][40]; +int motd_num_lines; + +/* + * ReadConfigFile() + * Config file format is backwards compatible with Action's, but doesn't need + * the "###" designator at end of sections. + * -Fireblade + */ +void ReadConfigFile() +{ + FILE *config_file; + char buf[MAX_STR_LEN], reading_section[MAX_STR_LEN], inipath[MAX_STR_LEN]; + int lines_into_section = -1; + cvar_t *ininame; + + ininame = gi.cvar("ininame", "action.ini", CVAR_NOFLAGS); + if (ininame->string && *(ininame->string)) + sprintf(inipath, "%s/%s", GAMEVERSION, ininame->string); + else + sprintf(inipath, "%s/%s", GAMEVERSION, "action.ini"); + + config_file = fopen(inipath, "r"); + if (config_file == NULL) { + gi.Com_PrintFmt("Unable to read %s\n", inipath); + return; + } + + while (fgets(buf, MAX_STR_LEN - 10, config_file) != NULL) { + int bs; + + bs = strlen(buf); + while (buf[bs - 1] == '\r' || buf[bs - 1] == '\n') { + buf[bs - 1] = 0; + bs--; + } + + if ((buf[0] == '/' && buf[1] == '/') || buf[0] == 0) { + continue; + } + + if (buf[0] == '[') { + char *p; + + p = strchr(buf, ']'); + if (p == NULL) + continue; + *p = 0; + strcpy(reading_section, buf + 1); + lines_into_section = 0; + continue; + } + if (buf[0] == '#' && buf[1] == '#' && buf[2] == '#') { + lines_into_section = -1; + continue; + } + if (lines_into_section > -1) { + if (!strcmp(reading_section, "team1")) { + if (lines_into_section == 0) { + Q_strlcpy(teams[TEAM1].name, buf, sizeof(teams[TEAM1].name)); + } else if (lines_into_section == 1) { + Q_strlcpy(teams[TEAM1].skin, buf, sizeof(teams[TEAM1].skin)); + } + } else if (!strcmp(reading_section, "team2")) { + if (lines_into_section == 0) { + Q_strlcpy(teams[TEAM2].name, buf, sizeof(teams[TEAM2].name)); + } else if (lines_into_section == 1) { + Q_strlcpy(teams[TEAM2].skin, buf, sizeof(teams[TEAM2].skin)); + } + } else if (!strcmp(reading_section, "team3")) { + if (lines_into_section == 0) { + Q_strlcpy(teams[TEAM3].name, buf, sizeof(teams[TEAM3].name)); + } else if (lines_into_section == 1) { + Q_strlcpy(teams[TEAM3].skin, buf, sizeof(teams[TEAM3].skin)); + } + } else if (!strcmp(reading_section, "maplist")) { + map_rotation[num_maps] = (char *) gi.TagMalloc(strlen(buf) + 1, TAG_GAME); + strcpy(map_rotation[num_maps], buf); + num_maps++; + } + lines_into_section++; + } + } + + snprintf(teams[TEAM1].skin_index, sizeof(teams[TEAM1].skin_index), "../players/%s_i", teams[TEAM1].skin); + snprintf(teams[TEAM2].skin_index, sizeof(teams[TEAM2].skin_index), "../players/%s_i", teams[TEAM2].skin); + snprintf(teams[TEAM3].skin_index, sizeof(teams[TEAM3].skin_index), "../players/%s_i", teams[TEAM3].skin); + + cur_map = 0; + srand(time(NULL)); + rand_map = (num_maps > 1) ? (rand() % (num_maps - 1) + 1) : 1; + + fclose(config_file); +} + +void ReadMOTDFile() +{ + FILE *motd_file; + char buf[1000]; + char motdpath[MAX_STR_LEN]; + int lbuf; + cvar_t *motdname; + + motdname = gi.cvar("motdname", "motd.txt", 0); + if (motdname->string && *(motdname->string)) + sprintf(motdpath, "%s/%s", GAMEVERSION, motdname->string); + else + sprintf(motdpath, "%s/%s", GAMEVERSION, "motd.txt"); + + motd_file = fopen(motdpath, "r"); + if (motd_file == NULL) + return; + + motd_num_lines = 0; + while (fgets(buf, 900, motd_file) != NULL) { + lbuf = strlen(buf); + while (lbuf > 0 && (buf[lbuf - 1] == '\r' || buf[lbuf - 1] == '\n')) { + buf[lbuf - 1] = 0; + lbuf--; + } + + if(!lbuf) + continue; + + if (lbuf > 39) + buf[39] = 0; + + strcpy(motd_lines[motd_num_lines++], buf); + + if (motd_num_lines >= MAX_TOTAL_MOTD_LINES) + break; + } + + fclose(motd_file); +} + +// AQ2:TNG Deathwatch - Ohh, lovely MOTD - edited it +void PrintMOTD(edict_t * ent) +{ + int mapnum, i, lines = 0; + int max_lines = MAX_TOTAL_MOTD_LINES; + char msg_buf[1024], *server_type; + + + //Welcome Message. This shows the Version Number and website URL, followed by an empty line + strcpy(msg_buf, TNG_TITLE " v" VERSION "\n" "https://github.com/actionquake/quake2-rerelease-dll" "\n\n"); + lines = 3; + + /* + As long as we don't skip the MOTD, we want to print all information + */ + if (!skipmotd->value) { + // This line will show the hostname. If not set, the default name will be "Unnamed TNG Server" (used to be "unnamed") + if (hostname->string[0] && strcmp(hostname->string, "Unnamed TNG Server")) + { + Q_strncatz(msg_buf, hostname->string, strlen(msg_buf)+40); + strcat(msg_buf, "\n"); + lines++; + } + + /* + Now all the settings + */ + + // Check what game type it is + if (teamplay->value) + { + if (teamdm->value) // Is it TeamDM? + { + if (teamCount == 3) + server_type = "3 Team Deathmatch"; + else + server_type = "Team Deathmatch"; + } + } + else // So it's not Teamplay? + { + server_type = "Deathmatch (Free For All)"; + sprintf(msg_buf + strlen(msg_buf), "Game Type: %s\n", server_type); + } + lines++; + + // Adding an empty line + strcat(msg_buf, "\n"); + lines++; + + /* + Now for the map rules, such as Timelimit, Roundlimit, etc + */ + if (fraglimit->integer) // What is the fraglimit? + sprintf(msg_buf + strlen(msg_buf), "Fraglimit: %d", fraglimit->integer); + else + strcat(msg_buf, "Fraglimit: none"); + + if (timelimit->integer) // What is the timelimit? + sprintf(msg_buf + strlen(msg_buf), " Timelimit: %d\n", timelimit->integer); + else + strcat(msg_buf, " Timelimit: none\n"); + lines++; + + // If we're in Teamplay, and not CTF, we want to see what the roundlimit and roundtimelimit is + if (gameSettings & GS_ROUNDBASED) + { + if ((int)roundlimit->value) // What is the roundlimit? + sprintf(msg_buf + strlen(msg_buf), "Roundlimit: %d", (int)roundlimit->value); + else + strcat(msg_buf, "Roundlimit: none"); + lines++; + } + + /* + Check for the number of weapons and items people can carry + */ + if ((int)unique_weapons->value != 1 || (int)unique_items->value != 1) { + sprintf(msg_buf + strlen(msg_buf), "Max number of spec weapons: %d items: %d\n", + (int) unique_weapons->value, (int) unique_items->value); + lines++; + } + + /* + What can we use with the Bandolier? + */ + if (tgren->value > 0 || !(ir->value)) { + char grenade_num[32]; + + // Show the number of grenades with the Bandolier + if (tgren->value > 0) + sprintf(grenade_num, "%d grenade%s", (int)tgren->value, (int)tgren->value == 1 ? "" : "s"); + + sprintf(msg_buf + strlen(msg_buf), "Bandolier w/ %s%s%s\n", + !(ir->value) ? "no IR" : "", + (tgren->value > 0 && !(ir->value)) ? " & " : "", + tgren->value > 0 ? grenade_num : ""); + lines++; + } + + /* + Is allitem and/or allweapon enabled? + */ + if (allitem->value || allweapon->value) { + sprintf(msg_buf + strlen(msg_buf), "Players receive %s%s%s\n", + allweapon->value ? "all weapons" : "", + (allweapon->value && allitem->value) ? " & " : "", + allitem->value ? "all items" : ""); + lines++; + } + + /* + * Are we using limchasecam? + */ + if (limchasecam->value) { + if ((int) limchasecam->value == 2) + sprintf(msg_buf + strlen(msg_buf), "Chase Cam Disallowed\n"); + else + sprintf(msg_buf + strlen(msg_buf), "Chase Cam Restricted\n"); + lines++; + } + + /* + * Are the dmflags set to disallow Friendly Fire? + */ + if (teamplay->value && !g_friendly_fire->integer) { + sprintf(msg_buf + strlen(msg_buf), "Friendly Fire Enabled\n"); + lines++; + } + + /* + Are we using any types of voting? + */ + if (use_mapvote->value || use_cvote->value || use_kickvote->value) { + sprintf(msg_buf + strlen(msg_buf), "Vote Types: %s%s%s%s%s\n", + use_mapvote->value ? "Map" : "", (use_mapvote->value + && use_cvote->value) ? " & " : "", + use_cvote->value ? "Config" : "", ((use_mapvote->value && use_kickvote->value) + || (use_cvote->value + && use_kickvote->value)) ? " & " : "", + use_kickvote->value ? "Kick" : ""); + lines++; // lines+=3; + } + + /* + Map Locations + */ + if (ml_count != 0) { + sprintf(msg_buf + strlen(msg_buf), "\n%d Locations, by: %s\n", ml_count, ml_creator); + lines++; + } + /* + If actionmaps, put a blank line then the maps list + */ + if (actionmaps->value && num_maps > 0) + { + int chars_on_line = 0, len_mr; + + if (vrot->value) // Using Vote Rotation? + strcat(msg_buf, "\nRunning these maps in vote order:\n"); + else if (rrot->value) // Using Random Rotation? + strcat(msg_buf, "\nRunning the following maps randomly:\n"); + else + strcat(msg_buf, "\nRunning the following maps in order:\n"); + + lines += 2; + + for (mapnum = 0; mapnum < num_maps; mapnum++) + { + len_mr = strlen(*(map_rotation + mapnum)); + if ((chars_on_line + len_mr + 2) > 39) { + Q_strncatz(msg_buf, "\n", sizeof(msg_buf)); + lines++; + if (lines >= max_lines) + break; + chars_on_line = 0; + } + Q_strncatz(msg_buf, *(map_rotation + mapnum), sizeof(msg_buf)); + chars_on_line += len_mr; + if (mapnum < (num_maps - 1)) { + Q_strncatz(msg_buf, ", ", sizeof(msg_buf)); + chars_on_line += 2; + } + } + + if (lines < max_lines) { + Q_strncatz(msg_buf, "\n", sizeof(msg_buf)); + lines++; + } + } + + //If we're in teamplay, we want to inform people that they can open the menu with TAB + if (teamplay->value && lines < max_lines && !auto_menu->value) { + Q_strncatz(msg_buf, "\nHit TAB to open the Team selection menu", sizeof(msg_buf)); + lines++; + } + } + + /* + Insert action/motd.txt contents (whole MOTD gets truncated after 30 lines) + */ + + if (motd_num_lines && lines < max_lines-1) + { + Q_strncatz(msg_buf, "\n", sizeof(msg_buf)); + lines++; + for (i = 0; i < motd_num_lines; i++) { + Q_strncatz(msg_buf, motd_lines[i], sizeof(msg_buf)); + lines++; + if (lines >= max_lines) + break; + Q_strncatz(msg_buf, "\n", sizeof(msg_buf)); + } + } + + if (!auto_menu->value || ent->client->pers.menu_shown) { + gi.LocCenter_Print(ent, "%s", msg_buf); + } else { + gi.LocClient_Print(ent, PRINT_LOW, "%s", msg_buf); + } +} + +// stuffcmd: forces a player to execute a command. +void stuffcmd(edict_t * ent, char *c) +{ + gi.WriteByte(svc_stufftext); + gi.WriteString(c); + gi.unicast(ent, true); +} + + +void unicastSound(edict_t *ent, int soundIndex, float volume) +{ + int mask = MASK_ENTITY_CHANNEL; + + if (volume != 1.0) + mask |= MASK_VOLUME; + + gi.WriteByte(svc_sound); + gi.WriteByte((byte)mask); + gi.WriteByte((byte)soundIndex); + if (mask & MASK_VOLUME) + gi.WriteByte((byte)(volume * 255)); + + // hack when first person spectating, the sound source must be the spectated player + if (ent->client->chase_mode == 2 && ent->client->chase_target) { + gi.WriteShort(((ent->client->chase_target - g_edicts - 1) << 3) + CHAN_NO_PHS_ADD); + } else { + gi.WriteShort(((ent - g_edicts - 1) << 3) + CHAN_NO_PHS_ADD); + } + + gi.unicast (ent, true); +} +// AQ2:TNG END + +/******************************************************************************** +* +* zucc: following are EjectBlooder, EjectShell, AddSplat, and AddDecal +* code. All from actionquake, some had to be modified to fit Axshun or fix +* bugs. +* +*/ + +int decals = 0; +int shells = 0; +int splats = 0; + +//blooder used for bleeding + +void BlooderTouch(edict_t * self, edict_t * other, cplane_t * plane, csurface_t * surf) +{ + if( (other == self->owner) || other->client ) // Don't stop on players. + return; + self->think = G_FreeEdict; + self->nextthink = level.time + 1_ms; +} + +void EjectBlooder(edict_t * self, vec3_t start, vec3_t veloc) +{ + edict_t *blooder; + vec3_t forward; + int spd = 0; + + blooder = G_Spawn(); + VectorCopy(veloc, forward); + VectorCopy(start, blooder->s.origin); + VectorCopy(start, blooder->old_origin); + spd = 0; + VectorScale(forward, spd, blooder->velocity); + blooder->solid = SOLID_NOT; + blooder->movetype = MOVETYPE_BLOOD; // Allow dripping blood to make a splat. + blooder->s.modelindex = level.model_null; + blooder->s.effects |= EF_GIB; + blooder->owner = self; + blooder->touch = BlooderTouch; + blooder->nextthink = level.time + 32_ms; + blooder->think = G_FreeEdict; + blooder->classname = "blooder"; + + gi.linkentity(blooder); +} + +// zucc - Adding EjectShell code from action quake, modified for Axshun. +/********* SHELL EJECTION **************/ + +void PlaceHolder( edict_t * ent ); // p_weapon.c + +void ShellTouch(edict_t * self, edict_t * other, cplane_t * plane, csurface_t * surf) +{ + if (self->owner->client->curr_weap == M3_NUM) + gi.sound(self, CHAN_WEAPON, gi.soundindex("weapons/shellhit1.wav"), 1, ATTN_STATIC, 0); + else if (random() < 0.5) + gi.sound(self, CHAN_WEAPON, gi.soundindex("weapons/tink1.wav"), 0.2, ATTN_STATIC, 0); + else + gi.sound(self, CHAN_WEAPON, gi.soundindex("weapons/tink2.wav"), 0.2, ATTN_STATIC, 0); +} + +void ShellDie(edict_t * self) +{ + G_FreeEdict(self); + --shells; +} + +static void RemoveOldestShell( void ) +{ + int i = 0; + edict_t *it = NULL, *found = NULL; + + for( i = 0; i < globals.num_edicts; i ++ ) + { + it = &g_edicts[i]; + if( it->inuse && it->classname && (Q_stricmp( it->classname, "shell" ) == 0) ) + { + if( (! found) || (it->freetime < found->freetime) ) + found = it; + } + } + + if( found ) + ShellDie( found ); +} + +// zucc fixed this so it works with the sniper rifle and checks handedness +// had to add the toggle feature to handle the akimbos correctly, if 1 +// it sets up for ejecting the shell from the left akimbo weapon, if 2 +// it fires right handed akimbo + +void EjectShell(edict_t * self, vec3_t start, int toggle) +{ + edict_t *shell; + vec3_t forward, right, up; + float r; + float fix = 1.0; + int left = 0; + + if (sv_shelloff->value) + return; + + if( (shelllimit->value > 0) && (shells >= shelllimit->value) ) + RemoveOldestShell(); + + shell = G_Spawn(); + ++shells; + + AngleVectors(self->client->v_angle, forward, right, up); + + if (self->client->pers.hand == LEFT_HANDED) { + left = 1; + fix = -1.0; + } else if (self->client->pers.hand == CENTER_HANDED) + fix = 0; + + // zucc spent a fair amount of time hacking these until they look ok, + // several of them could be improved however. + + if (self->client->curr_weap == MK23_NUM) { + VectorMA(start, left ? -7 : .4, right, start); + VectorMA(start, left ? 5 : 2, forward, start); + VectorMA(start, left ? -10 : -8, up, start); + } else if (self->client->curr_weap == M4_NUM) { + VectorMA(start, left ? -10 : 5, right, start); + VectorMA(start, left ? 6 : 12, forward, start); + VectorMA(start, left ? -9 : -11, up, start); + } else if (self->client->curr_weap == MP5_NUM) { + VectorMA(start, left ? -10 : 6, right, start); + VectorMA(start, left ? 6 : 8, forward, start); + VectorMA(start, left ? -9 : -10, up, start); + } else if (self->client->curr_weap == SNIPER_NUM) { + VectorMA(start, fix * 11, right, start); + VectorMA(start, 2, forward, start); + VectorMA(start, -11, up, start); + + } else if (self->client->curr_weap == M3_NUM) { + VectorMA(start, left ? -9 : 3, right, start); + VectorMA(start, left ? 4 : 4, forward, start); + VectorMA(start, left ? -1 : -1, up, start); + } + + else if (self->client->curr_weap == DUAL_NUM) { + if (self->client->pers.hand == LEFT_HANDED) + VectorMA(start, ((toggle == 1) ? 8 : -8), right, start); + else + VectorMA(start, ((toggle == 1) ? -4 : 4), right, start); + VectorMA(start, 6, forward, start); + VectorMA(start, -9, up, start); + + } + + if ((forward[2] >= -1) && (forward[2] < -0.99)) { + VectorMA(start, 5, forward, start); + VectorMA(start, -0.5, up, start); + } else if ((forward[2] >= -0.99) && (forward[2] < -0.98)) { + VectorMA(start, 5, forward, start); + VectorMA(start, -.1, up, start); + } else if ((forward[2] >= -0.98) && (forward[2] < -0.97)) { + VectorMA(start, 5.1, forward, start); + VectorMA(start, 0.3, up, start); + } else if ((forward[2] >= -0.97) && (forward[2] < -0.96)) { + VectorMA(start, 5.2, forward, start); + VectorMA(start, 0.7, up, start); + } else if ((forward[2] >= -0.96) && (forward[2] < -0.95)) { + VectorMA(start, 5.2, forward, start); + VectorMA(start, 1.1, up, start); + } else if ((forward[2] >= -0.95) && (forward[2] < -0.94)) { + VectorMA(start, 5.3, forward, start); + VectorMA(start, 1.5, up, start); + } else if ((forward[2] >= -0.94) && (forward[2] < -0.93)) { + VectorMA(start, 5.4, forward, start); + VectorMA(start, 1.9, up, start); + } else if ((forward[2] >= -0.93) && (forward[2] < -0.92)) { + VectorMA(start, 5.5, forward, start); + VectorMA(start, 2.3, up, start); + } else if ((forward[2] >= -0.92) && (forward[2] < -0.91)) { + VectorMA(start, 5.6, forward, start); + VectorMA(start, 2.7, up, start); + } else if ((forward[2] >= -0.91) && (forward[2] < -0.9)) { + VectorMA(start, 5.7, forward, start); + VectorMA(start, 3.1, up, start); + } else if ((forward[2] >= -0.9) && (forward[2] < -0.85)) { + VectorMA(start, 5.8, forward, start); + VectorMA(start, 3.5, up, start); + } else if ((forward[2] >= -0.85) && (forward[2] < -0.8)) { + VectorMA(start, 6, forward, start); + VectorMA(start, 4, up, start); + } else if ((forward[2] >= -0.8) && (forward[2] < -0.6)) { + VectorMA(start, 6.5, forward, start); + VectorMA(start, 4.5, up, start); + } else if ((forward[2] >= -0.6) && (forward[2] < -0.4)) { + VectorMA(start, 8, forward, start); + VectorMA(start, 5.5, up, start); + } else if ((forward[2] >= -0.4) && (forward[2] < -0.2)) { + VectorMA(start, 9.5, forward, start); + VectorMA(start, 6, up, start); + } else if ((forward[2] >= -0.2) && (forward[2] < 0)) { + VectorMA(start, 11, forward, start); + VectorMA(start, 6.5, up, start); + } else if ((forward[2] >= 0) && (forward[2] < 0.2)) { + VectorMA(start, 12, forward, start); + VectorMA(start, 7, up, start); + } else if ((forward[2] >= 0.2) && (forward[2] < 0.4)) { + VectorMA(start, 14, forward, start); + VectorMA(start, 6.5, up, start); + } else if ((forward[2] >= 0.4) && (forward[2] < 0.6)) { + VectorMA(start, 16, forward, start); + VectorMA(start, 6, up, start); + } else if ((forward[2] >= 0.6) && (forward[2] < 0.8)) { + VectorMA(start, 18, forward, start); + VectorMA(start, 5, up, start); + } else if ((forward[2] >= 0.8) && (forward[2] < 0.85)) { + VectorMA(start, 18, forward, start); + VectorMA(start, 4, up, start); + } else if ((forward[2] >= 0.85) && (forward[2] < 0.9)) { + VectorMA(start, 18, forward, start); + VectorMA(start, 2.5, up, start); + } else if ((forward[2] >= 0.9) && (forward[2] < 0.91)) { + VectorMA(start, 18.2, forward, start); + VectorMA(start, 2.2, up, start); + } else if ((forward[2] >= 0.91) && (forward[2] < 0.92)) { + VectorMA(start, 18.4, forward, start); + VectorMA(start, 1.9, up, start); + } else if ((forward[2] >= 0.92) && (forward[2] < 0.93)) { + VectorMA(start, 18.6, forward, start); + VectorMA(start, 1.6, up, start); + } else if ((forward[2] >= 0.93) && (forward[2] < 0.94)) { + VectorMA(start, 18.8, forward, start); + VectorMA(start, 1.3, up, start); + } else if ((forward[2] >= 0.94) && (forward[2] < 0.95)) { + VectorMA(start, 19, forward, start); + VectorMA(start, 1, up, start); + } else if ((forward[2] >= 0.95) && (forward[2] < 0.96)) { + VectorMA(start, 19.2, forward, start); + VectorMA(start, 0.7, up, start); + } else if ((forward[2] >= 0.96) && (forward[2] < 0.97)) { + VectorMA(start, 19.4, forward, start); + VectorMA(start, 0.4, up, start); + } else if ((forward[2] >= 0.97) && (forward[2] < 0.98)) { + VectorMA(start, 19.6, forward, start); + VectorMA(start, -0.2, up, start); + } else if ((forward[2] >= 0.98) && (forward[2] < 0.99)) { + VectorMA(start, 19.8, forward, start); + VectorMA(start, -0.6, up, start); + } else if ((forward[2] >= 0.99) && (forward[2] <= 1)) { + VectorMA(start, 20, forward, start); + VectorMA(start, -1, up, start); + } + + VectorCopy(start, shell->s.origin); + VectorCopy(start, shell->old_origin); + if (fix == 0) // we want some velocity on those center handed ones + fix = 1; + if (self->client->curr_weap == SNIPER_NUM) + VectorMA(shell->velocity, fix * (-35 + random() * -60), right, shell->velocity); + else if (self->client->curr_weap == DUAL_NUM) { + if (self->client->pers.hand == LEFT_HANDED) + VectorMA(shell->velocity, + (toggle == 1 ? 1 : -1) * (35 + random() * 60), right, shell->velocity); + else + VectorMA(shell->velocity, + (toggle == 1 ? -1 : 1) * (35 + random() * 60), right, shell->velocity); + } else + VectorMA(shell->velocity, fix * (35 + random() * 60), right, shell->velocity); + VectorMA(shell->avelocity, 500, right, shell->avelocity); + if (self->client->curr_weap == SNIPER_NUM) + VectorMA(shell->velocity, 60 + 40, up, shell->velocity); + else + VectorMA(shell->velocity, 60 + random() * 90, up, shell->velocity); + + shell->movetype = MOVETYPE_BOUNCE; + shell->solid = SOLID_BBOX; + + if( (self->client->curr_weap == M3_NUM) || (self->client->curr_weap == HC_NUM) ) + shell->s.modelindex = gi.modelindex("models/weapons/shell/tris2.md2"); + else if( (self->client->curr_weap == SNIPER_NUM) || (self->client->curr_weap == M4_NUM) ) + shell->s.modelindex = gi.modelindex("models/weapons/shell/tris3.md2"); + else + shell->s.modelindex = gi.modelindex("models/weapons/shell/tris.md2"); + + r = random(); + if (r < 0.1) + shell->s.frame = 0; + else if (r < 0.2) + shell->s.frame = 1; + else if (r < 0.3) + shell->s.frame = 2; + else if (r < 0.5) + shell->s.frame = 3; + else if (r < 0.6) + shell->s.frame = 4; + else if (r < 0.7) + shell->s.frame = 5; + else if (r < 0.8) + shell->s.frame = 6; + else if (r < 0.9) + shell->s.frame = 7; + else + shell->s.frame = 8; + + shell->owner = self; + shell->touch = ShellTouch; + shell->nextthink = level.framenum + (shelllife->value - (shells * 0.05)) * HZ; + shell->think = shelllife->value ? ShellDie : PlaceHolder; + shell->classname = "shell"; + shell->freetime = level.time; // Used to determine oldest spawned shell. + + gi.linkentity(shell); +} + +/* + ================== + FindEdictByClassnum + ================== + */ +edict_t *FindEdictByClassnum(char *classname, int classnum) +{ + int i; + edict_t *it; + + for (i = 0; i < globals.num_edicts; i++) + { + it = &g_edicts[i]; + if (it->classname && (it->classnum == classnum) && (Q_stricmp(it->classname, classname) == 0)) + return it; + } + + return NULL; + +} + +/********* Bulletholes/wall stuff ***********/ + +void UpdateAttachedPos( edict_t *self ) +{ + vec3_t fwd, right, up; + + if( (self->wait && (level.framenum >= self->wait)) || ! self->movetarget->inuse ) + { + G_FreeEdict(self); + return; + } + + self->nextthink = level.framenum + 1; + + if( self < self->movetarget ) + { + // If the object we're attached to hasn't been updated yet this frame, + // we need to move ahead one frame's worth so we stay aligned with it. + VectorScale( self->movetarget->velocity, FRAMETIME, self->s.origin ); + VectorAdd( self->movetarget->s.origin, self->s.origin, self->s.origin ); + VectorScale( self->movetarget->avelocity, FRAMETIME, self->s.angles ); + VectorAdd( self->movetarget->s.angles, self->s.angles, self->s.angles ); + } + else + { + VectorCopy( self->movetarget->s.origin, self->s.origin ); + VectorCopy( self->movetarget->s.angles, self->s.angles ); + } + + AngleVectors( self->s.angles, fwd, right, up ); // At this point, this is the angles of the entity we attached to. + self->s.origin[0] += fwd[0] * self->move_origin[0] + right[0] * self->move_origin[1] + up[0] * self->move_origin[2]; + self->s.origin[1] += fwd[1] * self->move_origin[0] + right[1] * self->move_origin[1] + up[1] * self->move_origin[2]; + self->s.origin[2] += fwd[2] * self->move_origin[0] + right[2] * self->move_origin[1] + up[2] * self->move_origin[2]; + VectorAdd( self->s.angles, self->move_angles, self->s.angles ); + VectorCopy( self->movetarget->velocity, self->velocity ); + VectorCopy( self->movetarget->avelocity, self->avelocity ); +} + +// Decal/splat/knife attached to some moving entity. +void AttachedThink( edict_t *self ) +{ + UpdateAttachedPos( self ); + gi.linkentity( self ); +} + +// Attach a splat/decal/knife to a moving entity. +void AttachToEntity( edict_t *self, edict_t *onto ) +{ + vec3_t fwd, right, up, offset; + + self->wait = self->nextthink; // Use old nextthink as despawn framenum (0 is never). + self->movetype = MOVETYPE_NONE; + + self->movetarget = onto; + AngleVectors( onto->s.angles, fwd, right, up ); + VectorSubtract( self->s.origin, onto->s.origin, offset ); + self->move_origin[0] = DotProduct( offset, fwd ); + self->move_origin[1] = DotProduct( offset, right ); + self->move_origin[2] = DotProduct( offset, up ); + VectorSubtract( self->s.angles, onto->s.angles, self->move_angles ); + + self->think = AttachedThink; + + UpdateAttachedPos( self ); +} + +qboolean CanBeAttachedTo( const edict_t *ent ) +{ + return (ent && ( (Q_strnicmp( ent->classname, "func_door", 9 ) == 0) + || (Q_stricmp( ent->classname, "func_plat" ) == 0) + || (Q_stricmp( ent->classname, "func_rotating" ) == 0) + || (Q_stricmp( ent->classname, "func_train" ) == 0) + || (Q_stricmp( ent->classname, "func_button" ) == 0) )); +} + +void AddDecal(edict_t * self, trace_t * tr) +{ + edict_t *decal, *dec; + qboolean attached; + + if (bholelimit->value < 1) + return; + + attached = CanBeAttachedTo(tr->ent); + + decal = bholelife->value ? G_Spawn() : G_Spawn_Decal(); + if( ! decal ) + return; + + ++decals; + + if (decals > bholelimit->value) + decals = 1; + + dec = FindEdictByClassnum("decal", decals); + + if( dec ) + { + dec->think = G_FreeEdict; + dec->nextthink = level.framenum + FRAMEDIV; + } + + decal->solid = SOLID_NOT; + decal->movetype = MOVETYPE_NONE; + decal->s.modelindex = gi.modelindex("models/objects/holes/hole1/hole.md2"); + VectorCopy(tr->endpos, decal->s.origin); + VectorCopy(tr->endpos, decal->old_origin); + vectoangles(tr->plane.normal, decal->s.angles); + decal->s.angles[ROLL] = crandom() * 180.f; + + decal->owner = self; + decal->touch = NULL; + decal->nextthink = bholelife->value ? (level.framenum + bholelife->value * HZ) : 0; + decal->think = bholelife->value ? G_FreeEdict : PlaceHolder; + decal->classname = "decal"; + decal->classnum = decals; + + if ((tr->ent) && (0 == Q_stricmp("func_explosive", tr->ent->classname))) { + CGF_SFX_AttachDecalToGlass(tr->ent, decal); + } + else if( attached ) + AttachToEntity( decal, tr->ent ); + + gi.linkentity(decal); +} + +void AddSplat(edict_t * self, vec3_t point, trace_t * tr) +{ + edict_t *splat, *spt; + float r; + qboolean attached; + + if (splatlimit->value < 1) + return; + + attached = CanBeAttachedTo(tr->ent); + + splat = splatlife->value ? G_Spawn() : G_Spawn_Decal(); + if( ! splat ) + return; + + ++splats; + + if (splats > splatlimit->value) + splats = 1; + + spt = FindEdictByClassnum("splat", splats); + + if( spt ) + { + spt->think = G_FreeEdict; + spt->nextthink = level.framenum + FRAMEDIV; + } + + splat->solid = SOLID_NOT; + splat->movetype = MOVETYPE_NONE; + + r = random(); + if (r > .67) + splat->s.modelindex = gi.modelindex("models/objects/splats/splat1/splat.md2"); + else if (r > .33) + splat->s.modelindex = gi.modelindex("models/objects/splats/splat2/splat.md2"); + else + splat->s.modelindex = gi.modelindex("models/objects/splats/splat3/splat.md2"); + + VectorCopy(point, splat->s.origin); + VectorCopy(point, splat->old_origin); + + vectoangles(tr->plane.normal, splat->s.angles); + splat->s.angles[ROLL] = crandom() * 180.f; + + splat->owner = self; + splat->touch = NULL; + splat->nextthink = level.framenum + splatlife->value * HZ; + splat->think = splatlife->value ? G_FreeEdict : PlaceHolder; + splat->classname = "splat"; + splat->classnum = splats; + + if ((tr->ent) && (0 == Q_stricmp("func_explosive", tr->ent->classname))) { + CGF_SFX_AttachDecalToGlass(tr->ent, splat); + } + else if( attached ) + AttachToEntity( splat, tr->ent ); + + gi.linkentity(splat); +} + +/* %-variables for chat msgs */ + +void GetWeaponName( edict_t *ent, char *buf ) +{ + if( IS_ALIVE(ent) && ent->client->weapon ) + { + strcpy( buf, ent->client->weapon->pickup_name ); + return; + } + + strcpy( buf, "no weapon" ); +} + +void GetItemName( edict_t *ent, char *buf ) +{ + int i, itemNum; + + if( IS_ALIVE(ent) ) + { + for( i = 0; i < ITEM_COUNT; i ++ ) + { + itemNum = ITEM_FIRST + i; + if( INV_AMMO( ent, itemNum ) ) + { + strcpy( buf, GET_ITEM(itemNum)->pickup_name ); + return; + } + } + } + + strcpy( buf, "no item" ); +} + +void GetHealth( edict_t *ent, char *buf ) +{ + if( IS_ALIVE(ent) ) + sprintf( buf, "%d", ent->health ); + else + sprintf( buf, "0" ); +} + +void GetAmmo( edict_t *ent, char *buf ) +{ + int ammo; + + if( IS_ALIVE(ent) && ent->client->weapon ) + { + switch( ent->client->curr_weap ) + { + case MK23_NUM: + sprintf( buf, "%d round%s (%d extra mag%s)", + ent->client->mk23_rds, ent->client->mk23_rds == 1 ? "" : "s", + ent->client->inventory[ent->client->ammo_index], + ent->client->inventory[ent->client->ammo_index] == 1 ? "" : "s"); + return; + case MP5_NUM: + sprintf( buf, "%d round%s (%d extra mag%s)", + ent->client->mp5_rds, ent->client->mp5_rds == 1 ? "" : "s", + ent->client->inventory[ent->client->ammo_index], + ent->client->inventory[ent->client->ammo_index] == 1 ? "" : "s"); + return; + case M4_NUM: + sprintf( buf, "%d round%s (%d extra mag%s)", + ent->client->m4_rds, ent->client->m4_rds == 1 ? "" : "s", + ent->client->inventory[ent->client->ammo_index], + ent->client->inventory[ent->client->ammo_index] == 1 ? "" : "s"); + return; + case M3_NUM: + sprintf( buf, "%d shell%s (%d extra shell%s)", + ent->client->shot_rds, ent->client->shot_rds == 1 ? "" : "s", + ent->client->inventory[ent->client->ammo_index], + ent->client->inventory[ent->client->ammo_index] == 1 ? "" : "s"); + return; + case HC_NUM: + sprintf( buf, "%d shell%s (%d extra shell%s)", + ent->client->cannon_rds, ent->client->cannon_rds == 1 ? "" : "s", + ent->client->inventory[ent->client->ammo_index], + ent->client->inventory[ent->client->ammo_index] == 1 ? "" : "s"); + return; + case SNIPER_NUM: + sprintf( buf, "%d round%s (%d extra round%s)", + ent->client->sniper_rds, ent->client->sniper_rds == 1 ? "" : "s", + ent->client->inventory[ent->client->ammo_index], + ent->client->inventory[ent->client->ammo_index] == 1 ? "" : "s"); + return; + case DUAL_NUM: + sprintf( buf, "%d round%s (%d extra mag%s)", + ent->client->dual_rds, ent->client->dual_rds == 1 ? "" : "s", + ent->client->inventory[ent->client->ammo_index], + ent->client->inventory[ent->client->ammo_index] == 1 ? "" : "s"); + return; + case KNIFE_NUM: + ammo = INV_AMMO( ent, KNIFE_NUM ); + sprintf( buf, "%d kni%s", ammo, (ammo == 1) ? "fe" : "ves" ); + return; + case GRENADE_NUM: + ammo = INV_AMMO( ent, GRENADE_NUM ); + sprintf( buf, "%d grenade%s", ammo, (ammo == 1) ? "" : "s" ); + return; + } + } + + strcpy( buf, "no ammo" ); +} + +void GetNearbyTeammates( edict_t *self, char *buf ) +{ + edict_t *nearby_teammates[8]; + size_t nearby_teammates_num = 0, l; + edict_t *ent = NULL; + + while ((ent = findradius(ent, self->s.origin, 1500)) != NULL) { + if (ent == self || !ent->client || !CanDamage(ent, self) || !OnSameTeam(ent, self)) + continue; + + nearby_teammates[nearby_teammates_num++] = ent; + if (nearby_teammates_num >= 8) + break; + } + + if (nearby_teammates_num == 0) { + strcpy(buf, "nobody"); + return; + } + + strcpy(buf, nearby_teammates[0]->client->pers.netname); + for (l = 1; l < nearby_teammates_num; l++) + { + if (l == nearby_teammates_num - 1) + Q_strncatz(buf, " and ", PARSE_BUFSIZE); + else + Q_strncatz(buf, ", ", PARSE_BUFSIZE); + + Q_strncatz( buf, nearby_teammates[l]->client->pers.netname, PARSE_BUFSIZE ); + } +} diff --git a/actionlite/a_game.h b/actionlite/a_game.h new file mode 100644 index 0000000..217b643 --- /dev/null +++ b/actionlite/a_game.h @@ -0,0 +1,60 @@ +// AQ2:TNG Deathwatch - Updated the Version variables to show TNG Stuff +#ifndef VERSION +#define VERSION "0.1" +#endif +#define TNG_TITLE "AQ2: The Next Generation Plus" +// AQ2:TNG Deathwatch End +//AQ2:TNG Slicer This is the max players writen on last killed target +//SLIC2 +#define MAX_LAST_KILLED 8 +//AQ2:TNG END + +extern char *map_rotation[]; +extern int num_maps, cur_map, rand_map, num_allvotes; // num_allvotes added by Igor[Rock] + +void ReadConfigFile (); +void ReadMOTDFile (); +void PrintMOTD (edict_t *ent); +void stuffcmd (edict_t *ent, char *s); +void unicastSound(edict_t *ent, int soundIndex, float volume); + +int KickDoor (trace_t * tr_old, edict_t * ent, vec3_t forward); + +// Prototypes of base Q2 functions that weren't included in any Q2 header +bool loc_CanSee (edict_t *, edict_t *); +void ParseSayText (edict_t *, char *, size_t size); + +void AttachToEntity( edict_t *self, edict_t *onto ); +bool CanBeAttachedTo( const edict_t *ent ); + +//PG BUND - BEGIN +//void ParseSayText(edict_t *, char *); +void GetWeaponName (edict_t * ent, char *buf); +void GetItemName (edict_t * ent, char *buf); +void GetHealth (edict_t * ent, char *buf); +void GetAmmo (edict_t * ent, char *buf); +void GetNearbyTeammates (edict_t * self, char *buf); + +void ResetScores (bool playerScores); +void AddKilledPlayer (edict_t * self, edict_t * ent); +void VideoCheckClient (edict_t * ent); +//AQ2:TNG END +//TempFile +void GetLastLoss (edict_t * self, char *buf, char team); + +// Firing styles (where shots originate from) +#define ACTION_FIRING_CENTER 0 +#define ACTION_FIRING_CLASSIC 1 +#define ACTION_FIRING_CLASSIC_HIGH 2 + +// maxs[2] of a player when crouching (we modify it from the normal 4) +// ...also the modified viewheight -FB 7/18/99 +#define CROUCHING_MAXS2 16 +#define CROUCHING_VIEWHEIGHT 8 +#define STANDING_VIEWHEIGHT 22 + +//a_team.c +void MakeAllLivePlayersObservers( void ); + +//a_cmds.c +void Cmd_NextMap_f( edict_t * ent ); diff --git a/actionlite/a_team.cpp b/actionlite/a_team.cpp index 6cc44db..2288aed 100644 --- a/actionlite/a_team.cpp +++ b/actionlite/a_team.cpp @@ -122,50 +122,17 @@ void PrintMatchRules () { char rulesmsg[256]; - // Espionage rules - if (esp->value) { - if (espsettings.mode == ESPMODE_ATL) { - if (teamCount == TEAM2) { - Com_sprintf( rulesmsg, sizeof( rulesmsg ), "%s leader: %s (%s)\n\n%s leader: %s (%s)\n\nFrag the other team's leader to win!\n", - teams[TEAM1].name, teams[TEAM1].leader->client->pers.netname, teams[TEAM1].leader_name, - teams[TEAM2].name, teams[TEAM2].leader->client->pers.netname, teams[TEAM2].leader_name ); - } else if (teamCount == TEAM3) { - Com_sprintf( rulesmsg, sizeof( rulesmsg ), "%s leader: %s (%s)\n\n%s leader: %s (%s)\n\n%s leader: %s (%s)\n\nFrag the other team's leaders to win!\n", - teams[TEAM1].name, teams[TEAM1].leader->client->pers.netname, teams[TEAM1].leader_name, - teams[TEAM2].name, teams[TEAM2].leader->client->pers.netname, teams[TEAM2].leader_name, - teams[TEAM3].name, teams[TEAM3].leader->client->pers.netname, teams[TEAM3].leader_name ); - } - } else if (espsettings.mode == ESPMODE_ETV) { - Com_sprintf( rulesmsg, sizeof( rulesmsg ), "\n\n%s: Escort your leader %s to the %s! Don't get them killed!\n\n%s: DO NOT let %s get to the %s! Use lethal force!", - teams[TEAM1].name, teams[TEAM1].leader->client->pers.netname, espsettings.target_name, teams[TEAM2].name, teams[TEAM1].leader->client->pers.netname, espsettings.target_name ); - } - } - // CTF rules - else if (ctf->value) { - if (capturelimit->value) { - Com_sprintf( rulesmsg, sizeof( rulesmsg ), "%s versus: %s\n\nCapture the other team's flag!\nNo capturelimit set!\n", - teams[TEAM1].name, teams[TEAM2].name ); - } else { - Com_sprintf( rulesmsg, sizeof( rulesmsg ), "%s versus: %s\n\nCapture the other team's flag!\nThe first team to %s captures wins!\n", - teams[TEAM1].name, teams[TEAM2].name, capturelimit->string ); - } - } - else if (dom->value) { - // I'll fill this in later - Com_sprintf( rulesmsg, sizeof( rulesmsg ), "%s versus: %s\n\nCapture all of the checkpoints!\nNo capturelimit set!\n", - teams[TEAM1].name, teams[TEAM2].name ); - } - else if (!deathmatch->value) { + if (!deathmatch->value) { if (teamCount == TEAM2) { - Com_sprintf( rulesmsg, sizeof( rulesmsg ), "%s versus: %s\n\nFrag the other team!\n", + snprintf( rulesmsg, sizeof( rulesmsg ), "%s versus: %s\n\nFrag the other team!\n", teams[TEAM1].name, teams[TEAM2].name ); } else if (teamCount == TEAM3) { - Com_sprintf( rulesmsg, sizeof( rulesmsg ), "%s versus %s versus %s\n\nFrag the other team!\n", + snprintf( rulesmsg, sizeof( rulesmsg ), "%s versus %s versus %s\n\nFrag the other team!\n", teams[TEAM1].name, teams[TEAM2].name, teams[TEAM3].name ); } } else { // If nothing else matches, just say glhf - Com_sprintf( rulesmsg, sizeof( rulesmsg ), "Frag 'em all! Good luck and have fun!\n"); + snprintf( rulesmsg, sizeof( rulesmsg ), "Frag 'em all! Good luck and have fun!\n"); } CenterPrintAll(rulesmsg); } @@ -190,10 +157,10 @@ void JoinTeamAuto (edict_t * ent, pmenu_t * p) score2 = teams[TEAM2].score; score3 = teams[TEAM3].score; - if(ctf->value) { - CTFCalcScores(); - GetCTFScores(&score1, &score2); - } + // if(ctf->value) { + // CTFCalcScores(); + // GetCTFScores(&score1, &score2); + // } /* there are many different things to consider when selecting a team */ if (num1 > num2 || (num1 == num2 && score1 > score2)) @@ -241,164 +208,102 @@ void LeaveTeams (edict_t * ent, pmenu_t * p) void SelectWeapon2(edict_t *ent, pmenu_t *p) { - ent->client->pers.chosenWeapon = GET_ITEM(MP5_NUM); + ent->client->pers.chosenWeapon = GetItemByIndex(IT_WEAPON_MP5); PMenu_Close(ent); - if(!item_kit_mode->value){ - OpenItemMenu(ent); - } else { - OpenItemKitMenu(ent); - } + OpenItemMenu(ent); unicastSound(ent, gi.soundindex("weapons/mp5slide.wav"), 1.0); } void SelectWeapon3(edict_t *ent, pmenu_t *p) { - ent->client->pers.chosenWeapon = GET_ITEM(M3_NUM); + ent->client->pers.chosenWeapon = GetItemByIndex(IT_WEAPON_M3); PMenu_Close(ent); - if(!item_kit_mode->value){ - OpenItemMenu(ent); - } else { - OpenItemKitMenu(ent); - } + OpenItemMenu(ent); unicastSound(ent, gi.soundindex("weapons/m3in.wav"), 1.0); } void SelectWeapon4(edict_t *ent, pmenu_t *p) { - ent->client->pers.chosenWeapon = GET_ITEM(HC_NUM); + ent->client->pers.chosenWeapon = GetItemByIndex(IT_WEAPON_HANDCANNON); PMenu_Close(ent); - if(!item_kit_mode->value){ - OpenItemMenu(ent); - } else { - OpenItemKitMenu(ent); - } + OpenItemMenu(ent); unicastSound(ent, gi.soundindex("weapons/cclose.wav"), 1.0); } void SelectWeapon5(edict_t *ent, pmenu_t *p) { - ent->client->pers.chosenWeapon = GET_ITEM(SNIPER_NUM); + ent->client->pers.chosenWeapon = GetItemByIndex(IT_WEAPON_SNIPER); PMenu_Close(ent); - if(!item_kit_mode->value){ - OpenItemMenu(ent); - } else { - OpenItemKitMenu(ent); - } + OpenItemMenu(ent); unicastSound(ent, gi.soundindex("weapons/ssgbolt.wav"), 1.0); } void SelectWeapon6(edict_t *ent, pmenu_t *p) { - ent->client->pers.chosenWeapon = GET_ITEM(M4_NUM); + ent->client->pers.chosenWeapon = GetItemByIndex(IT_WEAPON_M4); PMenu_Close(ent); - if(!item_kit_mode->value){ - OpenItemMenu(ent); - } else { - OpenItemKitMenu(ent); - } + OpenItemMenu(ent); unicastSound(ent, gi.soundindex("weapons/m4a1slide.wav"), 1.0); } void SelectWeapon0(edict_t *ent, pmenu_t *p) { - ent->client->pers.chosenWeapon = GET_ITEM(KNIFE_NUM); + ent->client->pers.chosenWeapon = GetItemByIndex(IT_WEAPON_KNIFE); PMenu_Close(ent); - if(!item_kit_mode->value){ - OpenItemMenu(ent); - } else { - OpenItemKitMenu(ent); - } + OpenItemMenu(ent); unicastSound(ent, gi.soundindex("weapons/swish.wav"), 1.0); } void SelectWeapon9(edict_t *ent, pmenu_t *p) { - ent->client->pers.chosenWeapon = GET_ITEM(DUAL_NUM); + ent->client->pers.chosenWeapon = GetItemByIndex(IT_WEAPON_DUALMK23); PMenu_Close(ent); - if(!item_kit_mode->value){ - OpenItemMenu(ent); - } else { - OpenItemKitMenu(ent); - } + OpenItemMenu(ent); unicastSound(ent, gi.soundindex("weapons/mk23slide.wav"), 1.0); } void SelectItem1(edict_t *ent, pmenu_t *p) { - ent->client->pers.chosenItem = GET_ITEM(KEV_NUM); - if(item_kit_mode->value){ - // This is so it clears the chosenItem2 if a previous kit was chosen - ent->client->pers.chosenItem2 = NULL; - } + ent->client->pers.chosenItem = GetItemByIndex(IT_ITEM_VEST); PMenu_Close(ent); unicastSound(ent, gi.soundindex("misc/veston.wav"), 1.0); } void SelectItem2(edict_t *ent, pmenu_t *p) { - ent->client->pers.chosenItem = GET_ITEM(LASER_NUM); + ent->client->pers.chosenItem = GetItemByIndex(IT_ITEM_LASERSIGHT); PMenu_Close(ent); unicastSound(ent, gi.soundindex("misc/lasersight.wav"), 1.0); } void SelectItem3(edict_t *ent, pmenu_t *p) { - ent->client->pers.chosenItem = GET_ITEM(SLIP_NUM); + ent->client->pers.chosenItem = GetItemByIndex(IT_ITEM_SLIPPERS); PMenu_Close(ent); unicastSound(ent, gi.soundindex("misc/veston.wav"), 1.0); } void SelectItem4(edict_t *ent, pmenu_t *p) { - ent->client->pers.chosenItem = GET_ITEM(SIL_NUM); + ent->client->pers.chosenItem = GetItemByIndex(IT_ITEM_QUIET); PMenu_Close(ent); unicastSound(ent, gi.soundindex("misc/screw.wav"), 1.0); } void SelectItem5(edict_t *ent, pmenu_t *p) { - ent->client->pers.chosenItem = GET_ITEM(BAND_NUM); + ent->client->pers.chosenItem = GetItemByIndex(IT_ITEM_BANDOLIER); PMenu_Close(ent); unicastSound(ent, gi.soundindex("misc/veston.wav"), 1.0); } void SelectItem6(edict_t *ent, pmenu_t *p) { - ent->client->pers.chosenItem = GET_ITEM(HELM_NUM); + ent->client->pers.chosenItem = GetItemByIndex(IT_ITEM_HELM); PMenu_Close(ent); unicastSound(ent, gi.soundindex("misc/veston.wav"), 1.0); } -// Commando kit -void SelectKit1(edict_t *ent, pmenu_t *p) -{ - ent->client->pers.chosenItem = GET_ITEM(BAND_NUM); - ent->client->pers.chosenItem2 = GET_ITEM(HELM_NUM); - - PMenu_Close(ent); - unicastSound(ent, gi.soundindex("misc/veston.wav"), 1.0); -} - -// Stealth kit -void SelectKit2(edict_t *ent, pmenu_t *p) -{ - ent->client->pers.chosenItem = GET_ITEM(SLIP_NUM); - ent->client->pers.chosenItem2= GET_ITEM(SIL_NUM); - - PMenu_Close(ent); - unicastSound(ent, gi.soundindex("misc/screw.wav"), 1.0); -} - -// Assassin kit -void SelectKit3(edict_t *ent, pmenu_t *p) -{ - ent->client->pers.chosenItem = GET_ITEM(LASER_NUM); - ent->client->pers.chosenItem2= GET_ITEM(SIL_NUM); - - PMenu_Close(ent); - unicastSound(ent, gi.soundindex("misc/lasersight.wav"), 1.0); -} - // newrand returns n, where 0 >= n < top int newrand (int top) { @@ -408,13 +313,13 @@ int newrand (int top) void SelectRandomWeapon(edict_t *ent, pmenu_t *p) { menu_list_weapon weapon_list[7] = { - { .num = MP5_NUM, .sound = "weapons/mp5slide.wav", .name = MP5_NAME }, - { .num = M3_NUM, .sound = "weapons/m3in.wav", .name = M3_NAME }, - { .num = HC_NUM, .sound = "weapons/cclose.wav", .name = HC_NAME }, - { .num = SNIPER_NUM, .sound = "weapons/ssgbolt.wav", .name = SNIPER_NAME }, - { .num = M4_NUM, .sound = "weapons/m4a1slide.wav", .name = M4_NAME }, - { .num = KNIFE_NUM, .sound = "weapons/swish.wav", .name = KNIFE_NAME }, - { .num = DUAL_NUM, .sound = "weapons/mk23slide.wav", .name = DUAL_NAME } + { .num = IT_WEAPON_MP5, .sound = "weapons/mp5slide.wav", .name = MP5_NAME }, + { .num = IT_WEAPON_M3, .sound = "weapons/m3in.wav", .name = M3_NAME }, + { .num = IT_WEAPON_HANDCANNON, .sound = "weapons/cclose.wav", .name = HC_NAME }, + { .num = IT_WEAPON_SNIPER, .sound = "weapons/ssgbolt.wav", .name = SNIPER_NAME }, + { .num = IT_WEAPON_M4, .sound = "weapons/m4a1slide.wav", .name = M4_NAME }, + { .num = IT_WEAPON_KNIFE, .sound = "weapons/swish.wav", .name = KNIFE_NAME }, + { .num = IT_WEAPON_DUALMK23, .sound = "weapons/mk23slide.wav", .name = DUAL_NAME } }; int rand = newrand(7); @@ -428,15 +333,11 @@ void SelectRandomWeapon(edict_t *ent, pmenu_t *p) } } - ent->client->pers.chosenWeapon = GET_ITEM(selected_weapon.num); + ent->client->pers.chosenWeapon = GetItemByIndex(selected_weapon.num); unicastSound(ent, gi.soundindex(selected_weapon.sound), 1.0); - gi.centerprintf(ent, "You selected %s", selected_weapon.name); + gi.LocCenter_Print(ent, "You selected %s", selected_weapon.name); PMenu_Close(ent); - if(!item_kit_mode->value){ - OpenItemMenu(ent); - } else { - OpenItemKitMenu(ent); - } + OpenItemMenu(ent); } void SelectRandomItem(edict_t *ent, pmenu_t *p) @@ -445,27 +346,27 @@ void SelectRandomItem(edict_t *ent, pmenu_t *p) // Create array with limited items on certain weapons to not have silly kombos menu_list_item item_list[6] = { - { .num = KEV_NUM, .sound = "misc/veston.wav", .name = KEV_NAME }, - { .num = SLIP_NUM, .sound = "misc/veston.wav", .name = SLIP_NAME }, - { .num = BAND_NUM, .sound = "misc/veston.wav", .name = BAND_NAME }, - { .num = HELM_NUM, .sound = "misc/veston.wav", .name = HELM_NAME }, + { .num = IT_ITEM_VEST, .sound = "misc/veston.wav", .name = KEV_NAME }, + { .num = IT_ITEM_SLIPPERS, .sound = "misc/veston.wav", .name = SLIP_NAME }, + { .num = IT_ITEM_BANDOLIER, .sound = "misc/veston.wav", .name = BAND_NAME }, + { .num = IT_ITEM_HELM, .sound = "misc/veston.wav", .name = HELM_NAME }, }; int listCount = 4; - menu_list_item item_sil = { .num = SIL_NUM, .sound = "misc/screw.wav", .name = SIL_NAME }; - menu_list_item item_las = { .num = LASER_NUM, .sound = "misc/lasersight.wav", .name = LASER_NAME }; + menu_list_item item_sil = { .num = IT_ITEM_SLIPPERS, .sound = "misc/screw.wav", .name = SIL_NAME }; + menu_list_item item_las = { .num = IT_ITEM_LASERSIGHT, .sound = "misc/lasersight.wav", .name = LASER_NAME }; - if (selected_weapon == SNIPER_NUM) + if (selected_weapon == IT_WEAPON_SNIPER) { item_list[4] = item_sil; listCount = 5; } - if (selected_weapon == M4_NUM) + if (selected_weapon == IT_WEAPON_M4) { item_list[4] = item_las; listCount = 5; } - if (selected_weapon == MP5_NUM) + if (selected_weapon == IT_WEAPON_MP5) { item_list[4] = item_sil; item_list[5] = item_las; @@ -476,22 +377,22 @@ void SelectRandomItem(edict_t *ent, pmenu_t *p) menu_list_item selected_item = item_list[rand]; if (ent->client->pers.chosenItem) { - while (selected_item.num == ent->client->pers.chosenItem->typeNum && selected_item.num < SIL_NUM) + while (selected_item.num == ent->client->pers.chosenItem->typeNum && selected_item.num < IT_ITEM_SLIPPERS) { rand = newrand(listCount); selected_item = item_list[rand]; } } else { - while (selected_item.num < SIL_NUM) + while (selected_item.num < IT_ITEM_SLIPPERS) { rand = newrand(listCount); selected_item = item_list[rand]; } } - ent->client->pers.chosenItem = GET_ITEM(selected_item.num); + ent->client->pers.chosenItem = GetItemByIndex(selected_item.num); unicastSound(ent, gi.soundindex(selected_item.sound), 1.0); - gi.centerprintf(ent, "You selected %s", selected_item.name); + gi.LocCenter_Print(ent, "You selected %s", selected_item.name); PMenu_Close(ent); } @@ -499,13 +400,13 @@ void SelectRandomWeaponAndItem(edict_t *ent, pmenu_t *p) { // WEAPON menu_list_weapon weapon_list[7] = { - { .num = MP5_NUM, .sound = "weapons/mp5slide.wav", .name = MP5_NAME }, - { .num = M3_NUM, .sound = "weapons/m3in.wav", .name = M3_NAME }, - { .num = HC_NUM, .sound = "weapons/cclose.wav", .name = HC_NAME }, - { .num = SNIPER_NUM, .sound = "weapons/ssgbolt.wav", .name = SNIPER_NAME }, - { .num = M4_NUM, .sound = "weapons/m4a1slide.wav", .name = M4_NAME }, - { .num = KNIFE_NUM, .sound = "weapons/swish.wav", .name = KNIFE_NAME }, - { .num = DUAL_NUM, .sound = "weapons/mk23slide.wav", .name = DUAL_NAME } + { .num = IT_WEAPON_MP5, .sound = "weapons/mp5slide.wav", .name = MP5_NAME }, + { .num = IT_WEAPON_M3, .sound = "weapons/m3in.wav", .name = M3_NAME }, + { .num = IT_WEAPON_HANDCANNON, .sound = "weapons/cclose.wav", .name = HC_NAME }, + { .num = IT_WEAPON_SNIPER, .sound = "weapons/ssgbolt.wav", .name = SNIPER_NAME }, + { .num = IT_WEAPON_M4, .sound = "weapons/m4a1slide.wav", .name = M4_NAME }, + { .num = IT_WEAPON_KNIFE, .sound = "weapons/swish.wav", .name = KNIFE_NAME }, + { .num = IT_WEAPON_DUALMK23, .sound = "weapons/mk23slide.wav", .name = DUAL_NAME } }; int rand = newrand(7); @@ -519,33 +420,33 @@ void SelectRandomWeaponAndItem(edict_t *ent, pmenu_t *p) } } - ent->client->pers.chosenWeapon = GET_ITEM(selected_weapon.num); + ent->client->pers.chosenWeapon = GetItemByIndex(selected_weapon.num); unicastSound(ent, gi.soundindex(selected_weapon.sound), 1.0); // ITEM // Create array with limited items on certain weapons to not have silly kombos menu_list_item item_list[6] = { - { .num = KEV_NUM, .sound = "misc/veston.wav", .name = KEV_NAME }, - { .num = SLIP_NUM, .sound = "misc/veston.wav", .name = SLIP_NAME }, - { .num = BAND_NUM, .sound = "misc/veston.wav", .name = BAND_NAME }, - { .num = HELM_NUM, .sound = "misc/veston.wav", .name = HELM_NAME }, + { .num = IT_ITEM_VEST, .sound = "misc/veston.wav", .name = KEV_NAME }, + { .num = IT_ITEM_SLIPPERS, .sound = "misc/veston.wav", .name = SLIP_NAME }, + { .num = IT_ITEM_BANDOLIER, .sound = "misc/veston.wav", .name = BAND_NAME }, + { .num = IT_ITEM_HELM, .sound = "misc/veston.wav", .name = HELM_NAME }, }; int listCount = 4; - menu_list_item item_sil = { .num = SIL_NUM, .sound = "misc/screw.wav", .name = SIL_NAME }; - menu_list_item item_las = { .num = LASER_NUM, .sound = "misc/lasersight.wav", .name = LASER_NAME }; + menu_list_item item_sil = { .num = IT_ITEM_SLIPPERS, .sound = "misc/screw.wav", .name = SIL_NAME }; + menu_list_item item_las = { .num = IT_ITEM_LASERSIGHT, .sound = "misc/lasersight.wav", .name = LASER_NAME }; - if (selected_weapon.num == SNIPER_NUM) + if (selected_weapon.num == IT_WEAPON_SNIPER) { item_list[4] = item_sil; listCount = 5; } - if (selected_weapon.num == M4_NUM) + if (selected_weapon.num == IT_WEAPON_M4) { item_list[4] = item_las; listCount = 5; } - if (selected_weapon.num == MP5_NUM) + if (selected_weapon.num == IT_WEAPON_MP5) { item_list[4] = item_sil; item_list[5] = item_las; @@ -567,9 +468,9 @@ void SelectRandomWeaponAndItem(edict_t *ent, pmenu_t *p) gi.cprintf(ent, PRINT_HIGH, "%i %s\n", item_list[i].num, item_list[i].name); } - ent->client->pers.chosenItem = GET_ITEM(selected_item.num); + ent->client->pers.chosenItem = GetItemByIndex(selected_item.num); unicastSound(ent, gi.soundindex(selected_item.sound), 1.0); - gi.centerprintf(ent, "You selected %s and %s", selected_weapon.name, selected_item.name); + gi.LocCenter_Print(ent, "You selected %s and %s", selected_weapon.name, selected_item.name); PMenu_Close(ent); } @@ -795,7 +696,7 @@ void killPlayer( edict_t *ent, bool suicidePunish ) if (attacker && attacker != ent && attacker->client) { char deathmsg[128]; - Com_sprintf( deathmsg, sizeof( deathmsg ), "%s ph34rs %s so much %s committed suicide! :)\n", + snprintf( deathmsg, sizeof( deathmsg ), "%s ph34rs %s so much %s committed suicide! :)\n", ent->client->pers.netname, attacker->client->pers.netname, ent->client->pers.gender ? "she" : "he"); @@ -856,13 +757,13 @@ void AssignSkin (edict_t * ent, const char *s, bool nickChanged) switch (ent->client->resp.team) { case TEAM1: - Com_sprintf(skin, sizeof(skin), "%s\\%s%s", ent->client->pers.netname, t, CTF_TEAM1_SKIN); + snprintf(skin, sizeof(skin), "%s\\%s%s", ent->client->pers.netname, t, CTF_TEAM1_SKIN); break; case TEAM2: - Com_sprintf(skin, sizeof(skin), "%s\\%s%s", ent->client->pers.netname, t, CTF_TEAM2_SKIN); + snprintf(skin, sizeof(skin), "%s\\%s%s", ent->client->pers.netname, t, CTF_TEAM2_SKIN); break; default: - Com_sprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, default_skin); + snprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, default_skin); break; } } @@ -876,25 +777,25 @@ void AssignSkin (edict_t * ent, const char *s, bool nickChanged) switch (ent->client->resp.team) { case TEAM1: - Com_sprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, teams[TEAM1].skin); + snprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, teams[TEAM1].skin); if (IS_LEADER(ent)){ - Com_sprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, teams[TEAM1].leader_skin); + snprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, teams[TEAM1].leader_skin); } break; case TEAM2: - Com_sprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, teams[TEAM2].skin); + snprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, teams[TEAM2].skin); if ((espsettings.mode == 0) && IS_LEADER(ent)){ - Com_sprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, teams[TEAM2].leader_skin); + snprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, teams[TEAM2].leader_skin); } break; case TEAM3: - Com_sprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, teams[TEAM3].skin); + snprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, teams[TEAM3].skin); if ((espsettings.mode == 0) && IS_LEADER(ent)){ - Com_sprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, teams[TEAM3].leader_skin); + snprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, teams[TEAM3].leader_skin); } break; default: - Com_sprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, default_skin); + snprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, default_skin); break; } //gi.dprintf("I assigned skin %s to %s\n", skin, ent->client->pers.netname); @@ -906,10 +807,10 @@ void AssignSkin (edict_t * ent, const char *s, bool nickChanged) case TEAM1: case TEAM2: case TEAM3: - Com_sprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, teams[ent->client->resp.team].skin); + snprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, teams[ent->client->resp.team].skin); break; default: - Com_sprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, (teamplay->value ? default_skin : s)); + snprintf(skin, sizeof(skin), "%s\\%s", ent->client->pers.netname, (teamplay->value ? default_skin : s)); break; } } @@ -1047,7 +948,7 @@ void JoinTeam (edict_t * ent, int desired_team, int skip_menuclose) if (skip_menuclose) gi.cprintf(ent, PRINT_HIGH, "Cannot join %s (locked)\n", TeamName(desired_team)); else - gi.centerprintf(ent, "Cannot join %s (locked)", TeamName(desired_team)); + gi.LocCenter_Print(ent, "Cannot join %s (locked)", TeamName(desired_team)); return; } @@ -1056,7 +957,7 @@ void JoinTeam (edict_t * ent, int desired_team, int skip_menuclose) { if(eventeams->value && desired_team != NOTEAM) { if(!IsAllowedToJoin(ent, desired_team)) { - gi.centerprintf(ent, "Cannot join %s (has too many players)", TeamName(desired_team)); + gi.LocCenter_Print(ent, "Cannot join %s (has too many players)", TeamName(desired_team)); return; } } @@ -1207,12 +1108,12 @@ typedef struct menuentry_s void OpenItemMenu (edict_t * ent) { menuentry_t *menuEntry, menu_items[] = { - { KEV_NUM, SelectItem1 }, - { LASER_NUM, SelectItem2 }, - { SLIP_NUM, SelectItem3 }, - { SIL_NUM, SelectItem4 }, - { BAND_NUM, SelectItem5 }, - { HELM_NUM, SelectItem6 } + { IT_ITEM_VEST, SelectItem1 }, + { IT_ITEM_LASERSIGHT, SelectItem2 }, + { IT_ITEM_SLIPPERS, SelectItem3 }, + { IT_ITEM_SLIPPERS, SelectItem4 }, + { IT_ITEM_BANDOLIER, SelectItem5 }, + { IT_ITEM_HELM, SelectItem6 } }; int i, count, pos = 4; @@ -1248,7 +1149,7 @@ void OpenItemMenu (edict_t * ent) void OpenItemKitMenu (edict_t * ent) { menuentry_t *kitmenuEntry, kit_menu_items[] = { - { KEV_NUM, SelectItem1 }, + { IT_ITEM_VEST, SelectItem1 }, { C_KIT_NUM, SelectKit1 }, { S_KIT_NUM, SelectKit2 }, { A_KIT_NUM, SelectKit3 } @@ -1287,13 +1188,13 @@ void OpenWeaponMenu (edict_t * ent) } menuentry_t *menuEntry, menu_items[] = { - { MP5_NUM, SelectWeapon2 }, - { M3_NUM, SelectWeapon3 }, - { HC_NUM, SelectWeapon4 }, - { SNIPER_NUM, SelectWeapon5 }, - { M4_NUM, SelectWeapon6 }, - { KNIFE_NUM, SelectWeapon0 }, - { DUAL_NUM, SelectWeapon9 } + { IT_WEAPON_MP5, SelectWeapon2 }, + { IT_WEAPON_M3, SelectWeapon3 }, + { IT_WEAPON_HANDCANNON, SelectWeapon4 }, + { IT_WEAPON_SNIPER, SelectWeapon5 }, + { IT_WEAPON_M4, SelectWeapon6 }, + { IT_WEAPON_KNIFE, SelectWeapon0 }, + { IT_WEAPON_DUALMK23, SelectWeapon9 } }; int i, count, pos = 4; @@ -1319,15 +1220,11 @@ void OpenWeaponMenu (edict_t * ent) } PMenu_Open(ent, weapmenu, 4, sizeof(weapmenu) / sizeof(pmenu_t)); - return; + reurn; } } - if(!item_kit_mode->value){ OpenItemMenu(ent); - } else { - OpenItemKitMenu(ent); - } } // AQ2:TNG Deathwatch - Updated this for the new menu @@ -1450,20 +1347,20 @@ void CleanLevel () continue; switch (ent->typeNum) { case MK23_NUM: - case MP5_NUM: - case M4_NUM: - case M3_NUM: - case HC_NUM: - case SNIPER_NUM: - case DUAL_NUM: - case KNIFE_NUM: + case IT_WEAPON_MP5: + case IT_WEAPON_M4: + case IT_WEAPON_M3: + case IT_WEAPON_HANDCANNON: + case IT_WEAPON_SNIPER: + case IT_WEAPON_DUALMK23: + case IT_WEAPON_KNIFE: case GRENADE_NUM: - case SIL_NUM: - case SLIP_NUM: - case BAND_NUM: - case KEV_NUM: - case LASER_NUM: - case HELM_NUM: + case IT_ITEM_SLIPPERS: + case IT_ITEM_SLIPPERS: + case IT_ITEM_BANDOLIER: + case IT_ITEM_VEST: + case IT_ITEM_LASERSIGHT: + case IT_ITEM_HELM: case MK23_ANUM: case MP5_ANUM: case M4_ANUM: @@ -1560,7 +1457,7 @@ void CenterPrintAll (const char *msg) { ent = &g_edicts[1 + i]; if (ent->inuse) - gi.centerprintf (ent, "%s", msg); + gi.LocCenter_Print (ent, "%s", msg); } } @@ -1767,19 +1664,19 @@ static void SpawnPlayers(void) // make sure teamplay spawners always have some weapon, warmup starts only after weapon selected if (!ent->client->pers.chosenWeapon) { - if (WPF_ALLOWED(MP5_NUM)) { - ent->client->pers.chosenWeapon = GET_ITEM(MP5_NUM); + if (WPF_ALLOWED(IT_WEAPON_MP5)) { + ent->client->pers.chosenWeapon = GetItemByIndex(IT_WEAPON_MP5); } else if (WPF_ALLOWED(MK23_NUM)) { - ent->client->pers.chosenWeapon = GET_ITEM(MK23_NUM); - } else if (WPF_ALLOWED(KNIFE_NUM)) { - ent->client->pers.chosenWeapon = GET_ITEM(KNIFE_NUM); + ent->client->pers.chosenWeapon = GetItemByIndex(MK23_NUM); + } else if (WPF_ALLOWED(IT_WEAPON_KNIFE)) { + ent->client->pers.chosenWeapon = GetItemByIndex(IT_WEAPON_KNIFE); } else { - ent->client->pers.chosenWeapon = GET_ITEM(MK23_NUM); + ent->client->pers.chosenWeapon = GetItemByIndex(MK23_NUM); } } if (!ent->client->pers.chosenItem) { - ent->client->pers.chosenItem = GET_ITEM(KEV_NUM); + ent->client->pers.chosenItem = GetItemByIndex(IT_ITEM_VEST); } // Random weapons and items mode. @@ -1845,7 +1742,7 @@ void RunWarmup () ent->client->latched_buttons = 0; PutClientInServer(ent); AddToTransparentList(ent); - gi.centerprintf(ent, "WARMUP"); + gi.LocCenter_Print(ent, "WARMUP"); } } #ifdef USE_AQTION @@ -2396,7 +2293,7 @@ int CheckTeamRules (void) tnow = time(NULL); now = localtime(&tnow); strftime( ltm, 64, "%Y%m%d-%H%M%S", now ); - Com_sprintf( mvdstring, sizeof(mvdstring), "mvdrecord %s-%s\n", ltm, level.mapname ); + snprintf( mvdstring, sizeof(mvdstring), "mvdrecord %s-%s\n", ltm, level.mapname ); gi.AddCommandString( mvdstring ); gi.bprintf( PRINT_HIGH, "Starting MVD recording to file %s-%s.mvd2\n", ltm, level.mapname ); } @@ -2647,10 +2544,10 @@ void A_NewScoreboardMessage(edict_t * ent) // print teams for (i = TEAM1; i <= teamCount; i++) { - Com_sprintf( buf, sizeof( buf ), "xv 44 yv %d string2 \"%3d %-11.11s Frg Tim Png\"", line++ * lineh, teams[i].score, teams[i].name ); + snprintf( buf, sizeof( buf ), "xv 44 yv %d string2 \"%3d %-11.11s Frg Tim Png\"", line++ * lineh, teams[i].score, teams[i].name ); Q_strncatz( string, buf, sizeof( string ) ); - Com_sprintf( buf, sizeof( buf ), "xv 44 yv %d string2 \"%s\" ", + snprintf( buf, sizeof( buf ), "xv 44 yv %d string2 \"%s\" ", line++ * lineh, "\x9D\x9E\x9E\x9E\x9E\x9E\x9E\x9E\x9E\x9E\x9E\x9E\x9E\x9E\x9F \x9D\x9E\x9F \x9D\x9E\x9F \x9D\x9E\x9F" ); @@ -2674,7 +2571,7 @@ void A_NewScoreboardMessage(edict_t * ent) cl_ent = g_edicts + 1 + (cl - game.clients); alive = IS_ALIVE(cl_ent); - Com_sprintf( buf, sizeof( buf ), "xv 44 yv %d string%c \"%-15s %3d %3d %3d\"", + snprintf( buf, sizeof( buf ), "xv 44 yv %d string%c \"%-15s %3d %3d %3d\"", line++ * lineh, (alive && dead ? '2' : ' '), cl->pers.netname, @@ -2689,7 +2586,7 @@ void A_NewScoreboardMessage(edict_t * ent) // show the amount of excess players if (total[i] > MAX_PLAYERS_PER_TEAM) { - Com_sprintf( buf, sizeof( buf ), "xv 44 yv %d string \" ..and %d more\"", line++ * lineh, total[i] - MAX_PLAYERS_PER_TEAM + 1 ); + snprintf( buf, sizeof( buf ), "xv 44 yv %d string \" ..and %d more\"", line++ * lineh, total[i] - MAX_PLAYERS_PER_TEAM + 1 ); Q_strncatz( string, buf, sizeof( string ) ); } @@ -2829,9 +2726,9 @@ void A_ScoreboardMessage (edict_t * ent, edict_t * killer) for (i = TEAM1, line_x = base_x + headerOffset; i <= teamCount; i++, line_x += rowWidth) { if (matchmode->value) - Com_sprintf(temp, sizeof(temp), "%4i/%2i/%-2d", totalscore[i], total[i], totalsubs[i]); + snprintf(temp, sizeof(temp), "%4i/%2i/%-2d", totalscore[i], total[i], totalsubs[i]); else - Com_sprintf(temp, sizeof(temp), "%4i/%2i", totalscore[i], total[i]); + snprintf(temp, sizeof(temp), "%4i/%2i", totalscore[i], total[i]); sprintf( string + len, "xv %i string \"%s\" ", @@ -3172,7 +3069,7 @@ void A_ScoreboardMessage (edict_t * ent, edict_t * killer) if( j ) strcat( string, " " ); - if( field == 'F' ) Com_sprintf( buf, sizeof(buf), "%5i", min( 99999, cl->resp.score ) ); + if( field == 'F' ) snprintf( buf, sizeof(buf), "%5i", min( 99999, cl->resp.score ) ); else if( field == 'T' ) { if( matchmode->value ) @@ -3182,21 +3079,21 @@ void A_ScoreboardMessage (edict_t * ent, edict_t * killer) suffix = 'C'; else if( cl->resp.subteam ) suffix = 'S'; - Com_sprintf( buf, sizeof(buf), " %c%c", (cl->resp.team ? (cl->resp.team + '0') : ' '), suffix ); + snprintf( buf, sizeof(buf), " %c%c", (cl->resp.team ? (cl->resp.team + '0') : ' '), suffix ); } else - Com_sprintf( buf, sizeof(buf), " %c", (cl->resp.team ? (cl->resp.team + '0') : ' ') ); + snprintf( buf, sizeof(buf), " %c", (cl->resp.team ? (cl->resp.team + '0') : ' ') ); } - else if( field == 'N' ) Com_sprintf( buf, sizeof(buf), "%-15s", cl->pers.netname ); + else if( field == 'N' ) snprintf( buf, sizeof(buf), "%-15s", cl->pers.netname ); else if( field == 'M' ) { int minutes = (level.framenum - cl->resp.enterframe) / (60 * HZ); if( minutes < 60 ) - Com_sprintf( buf, sizeof(buf), "%4i", minutes ); + snprintf( buf, sizeof(buf), "%4i", minutes ); else if( minutes < 600 ) - Com_sprintf( buf, sizeof(buf), "%1i:%02i", minutes / 60, minutes % 60 ); + snprintf( buf, sizeof(buf), "%1i:%02i", minutes / 60, minutes % 60 ); else - Com_sprintf( buf, sizeof(buf), "%3ih", min( 999, minutes / 60 ) ); + snprintf( buf, sizeof(buf), "%3ih", min( 999, minutes / 60 ) ); } else if( field == 'P' ) { @@ -3205,14 +3102,14 @@ void A_ScoreboardMessage (edict_t * ent, edict_t * killer) strcpy( buf, " BOT" ); else #endif - Com_sprintf( buf, sizeof(buf), "%4i", min( 9999, cl->ping ) ); + snprintf( buf, sizeof(buf), "%4i", min( 9999, cl->ping ) ); } - else if( field == 'C' ) Com_sprintf( buf, sizeof(buf), "%4i", min( 9999, cl->resp.ctf_caps ) ); - else if( field == 'S' ) Com_sprintf( buf, sizeof(buf), "%5i", min( 99999, cl->resp.score ) ); - else if( field == 'K' ) Com_sprintf( buf, sizeof(buf), "%5i", min( 99999, cl->resp.kills) ); - else if( field == 'D' ) Com_sprintf( buf, sizeof(buf), "%6i", min( 999999, cl->resp.deaths) ); - else if( field == 'I' ) Com_sprintf( buf, sizeof(buf), "%6i", min( 999999, cl->resp.damage_dealt) ); - else if( field == 'A' ) Com_sprintf( buf, sizeof(buf), "%3.f", cl->resp.shotsTotal ? (double) cl->resp.hitsTotal * 100.0 / (double) cl->resp.shotsTotal : 0. ); + else if( field == 'C' ) snprintf( buf, sizeof(buf), "%4i", min( 9999, cl->resp.ctf_caps ) ); + else if( field == 'S' ) snprintf( buf, sizeof(buf), "%5i", min( 99999, cl->resp.score ) ); + else if( field == 'K' ) snprintf( buf, sizeof(buf), "%5i", min( 99999, cl->resp.kills) ); + else if( field == 'D' ) snprintf( buf, sizeof(buf), "%6i", min( 999999, cl->resp.deaths) ); + else if( field == 'I' ) snprintf( buf, sizeof(buf), "%6i", min( 999999, cl->resp.damage_dealt) ); + else if( field == 'A' ) snprintf( buf, sizeof(buf), "%3.f", cl->resp.shotsTotal ? (double) cl->resp.hitsTotal * 100.0 / (double) cl->resp.shotsTotal : 0. ); else sprintf( buf, "%c", sb[ j ] ); strcat( string, buf ); diff --git a/actionlite/a_team.h b/actionlite/a_team.h index 8801754..2b82900 100644 --- a/actionlite/a_team.h +++ b/actionlite/a_team.h @@ -1,9 +1,13 @@ #include "g_local.h" -#define NOTEAM 0 -#define TEAM1 1 -#define TEAM2 2 -#define TEAM3 3 +enum aqteam_t +{ + NOTEAM, + TEAM1, + TEAM2, + TEAM3 +}; + #define MAX_TEAMS 3 #define TEAM_TOP (MAX_TEAMS+1) diff --git a/actionlite/g_cmds.cpp b/actionlite/g_cmds.cpp index 7a4c0e6..6db50dc 100644 --- a/actionlite/g_cmds.cpp +++ b/actionlite/g_cmds.cpp @@ -99,7 +99,7 @@ void LaserSightThink(edict_t * self) VectorCopy(endp, tr.endpos); } - vectoangles(tr.plane.normal, self->s.angles); + vectoangles(self->s.angles); VectorCopy(tr.endpos, self->s.origin); self->s.modelindex = (tr.surface && (tr.surface->flags & SURF_SKY)) ? level.model_null : level.model_lsight; @@ -157,7 +157,7 @@ void Cmd_Reload_f(edict_t * ent) // this gives them a chance to break off from reloading to fire the weapon - zucc if (ent->client->ps.gunframe >= 48) { ent->client->fast_reload = 1; - (ent->client->pers.weapon->ammo)--; + ent->client->pers.weapon->ammo--; } else { ent->client->reload_attempts++; } @@ -206,8 +206,8 @@ void Cmd_Reload_f(edict_t * ent) } } ent->client->ps.fov = 90; - if (ent->client->weapon) - ent->client->ps.gunindex = gi.modelindex(ent->client->weapon->view_model); + if (ent->client->pers.weapon) + ent->client->ps.gunindex = gi.modelindex(ent->client->pers.weapon->view_model); break; case IT_WEAPON_DUALMK23: if (ent->client->dual_rds == ent->client->dual_max) @@ -221,7 +221,7 @@ void Cmd_Reload_f(edict_t * ent) if (ent->client->pers.weapon->ammo == 1) { gitem_t *it; - it = GET_ITEM(MK23_NUM); + it = GetItemByIndex(IT_WEAPON_MK23); it->use(ent, it); ent->client->autoreloading = true; return; @@ -266,8 +266,6 @@ void Cmd_Reload_f(edict_t * ent) // Action Add End //====================================================================== - - void SelectNextItem(edict_t *ent, item_flags_t itflags) { gclient_t *cl; diff --git a/actionlite/g_local.h b/actionlite/g_local.h index 2b88077..04fbb19 100644 --- a/actionlite/g_local.h +++ b/actionlite/g_local.h @@ -6,6 +6,9 @@ #include "bg_local.h" +#include "a_team.h" +#include "a_game.h" + // the "gameversion" client command will print this plus compile date constexpr const char *GAMEVERSION = "action"; @@ -775,8 +778,9 @@ enum movetype_t { MOVETYPE_WALLBOUNCE, // RAFAEL // ROGUE - MOVETYPE_NEWTOSS // PGM - for deathball + MOVETYPE_NEWTOSS, // PGM - for deathball // ROGUE + MOVETYPE_BLOOD // Action }; // edict->flags @@ -1191,6 +1195,7 @@ struct level_locals_t gtime_t next_match_report; // Action add + int32_t model_null; int32_t model_lsight; }; @@ -2800,9 +2805,29 @@ struct client_respawn_t // ZOID // Action Add + aqteam_t team; int32_t sniper_mode; }; +// Action Add +#define MAX_LOCATIONS_IN_BASE 256 // Max amount of locations +extern int ml_count; +extern placedata_t locationbase[]; +extern char ml_creator[101]; + +struct team_t +{ + char name[20]; + char skin[MAX_SKINLEN]; + char skin_index[MAX_QPATH]; + int23_t score, total; + int23_t ready, locked; + int23_t pauses_used, wantReset; + cvar_t *teamscore; +}; + +// Action ADd + // [Paril-KEX] seconds until we are fully invisible after // making a racket constexpr gtime_t INVISIBILITY_TIME = 2_sec; diff --git a/actionlite/p_weapon.cpp b/actionlite/p_weapon.cpp index 5d01598..35aff08 100644 --- a/actionlite/p_weapon.cpp +++ b/actionlite/p_weapon.cpp @@ -2796,13 +2796,11 @@ void Weapon_Dual(edict_t* ent) Weapon_Generic(ent, 6, 10, 32, 40, 65, 68, pause_frames, fire_frames, Dual_Fire); } - - //zucc #define FRAME_PREPARETHROW_FIRST (FRAME_DEACTIVATE_LAST +1) -#define FRAME_IDLE2_FIRST (FRAME_PREPARETHROW_LAST +1) -#define FRAME_THROW_FIRST (FRAME_IDLE2_LAST +1) +#define FRAME_IDLE2_FIRST (FRAME_PREPARETHROW_LAST +1) +#define FRAME_THROW_FIRST (FRAME_IDLE2_LAST +1) #define FRAME_STOPTHROW_FIRST (FRAME_THROW_LAST +1) #define FRAME_NEWKNIFE_FIRST (FRAME_STOPTHROW_LAST +1) @@ -2820,9 +2818,7 @@ Weapon_Generic_Knife(edict_t* ent, int FRAME_ACTIVATE_LAST, return; // not on client, so VWep animations could do wacky things //FIREBLADE - if (ent->client->weaponstate == WEAPON_FIRING && - ((ent->solid == SOLID_NOT && ent->deadflag != DEAD_DEAD) - || lights_camera_action)) + if (ent->client->weaponstate == WEAPON_FIRING && !IS_ALIVE(ent) || lights_camera_action) { ent->client->weaponstate = WEAPON_READY; } diff --git a/actionlite/q_std.h b/actionlite/q_std.h index b63e35b..7d7b673 100644 --- a/actionlite/q_std.h +++ b/actionlite/q_std.h @@ -34,7 +34,7 @@ namespace fmt = std; #define FMT_STRING(s) s #else -#include +//#include #endif struct g_fmt_data_t {