From deb1135e3f2c5b2baa97716e80ffd5248f64c6c0 Mon Sep 17 00:00:00 2001 From: James O'Neill Date: Fri, 1 Mar 2024 21:54:31 +0900 Subject: [PATCH 1/2] Add support for "give a" based on the example code provided by Baker7. --- sv_ccmds.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/sv_ccmds.c b/sv_ccmds.c index 138b2c09c..da45fcdef 100644 --- a/sv_ccmds.c +++ b/sv_ccmds.c @@ -216,6 +216,7 @@ static void SV_Give_f(cmd_state_t *cmd) prvm_prog_t *prog = SVVM_prog; const char *t; int v; + int player_items; t = Cmd_Argv(cmd, 1); v = atoi (Cmd_Argv(cmd, 2)); @@ -325,6 +326,52 @@ static void SV_Give_f(cmd_state_t *cmd) PRVM_serveredictfloat(host_client->edict, ammo_cells) = v; } break; + case 'a': + // + // Set the player armour value to the number specified and then adjust the armour type/colour based on the value + // + player_items = PRVM_serveredictfloat(host_client->edict, items); + PRVM_serveredictfloat(host_client->edict, armorvalue) = v; + + // Remove whichever armour item the player currently has + if (gamemode == GAME_ROGUE) { + player_items &= ~(RIT_ARMOR1 | RIT_ARMOR2 | RIT_ARMOR3); + } + else { + player_items &= ~(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3); + } + + if (v > 150) { + // Give red armour + PRVM_serveredictfloat(host_client->edict, armortype) = 0.8; + if (gamemode == GAME_ROGUE) { + player_items |= RIT_ARMOR3; + } + else { + player_items |= IT_ARMOR3; + } + } else if (v > 100) { + // Give yellow armour + PRVM_serveredictfloat(host_client->edict, armortype) = 0.6; + if (gamemode == GAME_ROGUE) { + player_items |= RIT_ARMOR2; + } + else { + player_items |= IT_ARMOR2; + } + } else if (v >= 0) { + // Give green armour + PRVM_serveredictfloat(host_client->edict, armortype) = 0.3; + if (gamemode == GAME_ROGUE) { + player_items |= RIT_ARMOR1; + } + else { + player_items |= IT_ARMOR1; + } + } + + PRVM_serveredictfloat(host_client->edict, items) = player_items; + break; } } From 2df6054df109f4af0a753acc87e8e5716bbfb06f Mon Sep 17 00:00:00 2001 From: James O'Neill Date: Fri, 8 Mar 2024 18:37:05 +0900 Subject: [PATCH 2/2] Try and match formatting guidelines in CONTRIBUTING.md --- sv_ccmds.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/sv_ccmds.c b/sv_ccmds.c index da45fcdef..aa6790e5a 100644 --- a/sv_ccmds.c +++ b/sv_ccmds.c @@ -334,40 +334,37 @@ static void SV_Give_f(cmd_state_t *cmd) PRVM_serveredictfloat(host_client->edict, armorvalue) = v; // Remove whichever armour item the player currently has - if (gamemode == GAME_ROGUE) { + if (gamemode == GAME_ROGUE) player_items &= ~(RIT_ARMOR1 | RIT_ARMOR2 | RIT_ARMOR3); - } - else { + else player_items &= ~(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3); - } - if (v > 150) { + if (v > 150) + { // Give red armour PRVM_serveredictfloat(host_client->edict, armortype) = 0.8; - if (gamemode == GAME_ROGUE) { + if (gamemode == GAME_ROGUE) player_items |= RIT_ARMOR3; - } - else { + else player_items |= IT_ARMOR3; - } - } else if (v > 100) { + } + else if (v > 100) + { // Give yellow armour PRVM_serveredictfloat(host_client->edict, armortype) = 0.6; - if (gamemode == GAME_ROGUE) { + if (gamemode == GAME_ROGUE) player_items |= RIT_ARMOR2; - } - else { + else player_items |= IT_ARMOR2; - } - } else if (v >= 0) { + } + else if (v >= 0) + { // Give green armour PRVM_serveredictfloat(host_client->edict, armortype) = 0.3; - if (gamemode == GAME_ROGUE) { + if (gamemode == GAME_ROGUE) player_items |= RIT_ARMOR1; - } - else { + else player_items |= IT_ARMOR1; - } } PRVM_serveredictfloat(host_client->edict, items) = player_items;