Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for a "give a" command to give player armour #136

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions sv_ccmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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;
}
}

Expand Down