Skip to content

Commit

Permalink
CTF: Fix bonus attacker for defending his flag not working as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
rtxa committed Jan 8, 2024
1 parent 3178248 commit dc9ada0
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions valve/addons/amxmodx/scripting/agmodx_ctf.sma
Original file line number Diff line number Diff line change
Expand Up @@ -514,18 +514,20 @@ public OnPlayerKilled(victim, attacker) {
new entFlag = GetFlagCarriedByPlayer(victim);
new areTeamMates = hl_get_user_team(attacker) == hl_get_user_team(victim);

// Bonus player for defending his flag
if (IsPlayer(attacker) && victim != attacker && !areTeamMates) {
new Float:playerOrigin[3];
// Bonus attacker for defending his flag from the enemy
if (IsPlayer(attacker) && victim != attacker && !areTeamMates && !Player_IsCarryingFlag(victim)) {
new Float:flagOrigin[3];
pev(attacker, pev_origin, playerOrigin);
if (hl_get_user_team(attacker) == BLUE_TEAM) {
pev(gFlagBlue, pev_origin, flagOrigin);
} else {
pev(gFlagRed, pev_origin, flagOrigin);
}

new Float:victimOrigin[3];
pev(victim, pev_origin, victimOrigin);

if (get_distance_f(playerOrigin, flagOrigin) < 192) {
// Give points only if enemy is close to the flag within a radius of 192 units
if (get_distance_f(victimOrigin, flagOrigin) < 192) {
AddPoints(attacker, get_pcvar_num(gCvarDefendPoints));
}
}
Expand Down
Binary file added valve/sound/ctf/blueflagreturned.wav
Binary file not shown.
Binary file added valve/sound/ctf/blueflagstolen.wav
Binary file not shown.
Binary file added valve/sound/ctf/bluescores.wav
Binary file not shown.
Binary file added valve/sound/ctf/enemyhaveflag.wav
Binary file not shown.
Binary file added valve/sound/ctf/redflagreturned.wav
Binary file not shown.
Binary file added valve/sound/ctf/redflagstolen.wav
Binary file not shown.
Binary file added valve/sound/ctf/redscores.wav
Binary file not shown.
Binary file added valve/sound/ctf/teamhaveflag.wav
Binary file not shown.
Binary file added valve/sound/ctf/youhaveflag.wav
Binary file not shown.

0 comments on commit dc9ada0

Please sign in to comment.