Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
clientkill.qc File Reference
Include dependency graph for clientkill.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void ClientKill (entity this)
void ClientKill_Now (entity this)
void ClientKill_Now_TeamChange (entity this)
void ClientKill_Silent (entity this, float _delay)
void ClientKill_TeamChange (entity this, float targetteam)
void KillIndicator_Think (entity this)

Variables

float clientkill_nexttime
float clientkilltime
float lip

Function Documentation

◆ ClientKill()

void ClientKill ( entity this)

Definition at line 227 of file clientkill.qc.

228{
229 if (game_stopped || this.player_blocked)
230 return;
231
232 ClientKill_TeamChange(this, 0);
233}
void ClientKill_TeamChange(entity this, float targetteam)
Definition clientkill.qc:95
float game_stopped
Definition stats.qh:81
bool player_blocked
Definition client.qh:332

References ClientKill_TeamChange(), entity(), game_stopped, and player_blocked.

◆ ClientKill_Now()

void ClientKill_Now ( entity this)

Definition at line 37 of file clientkill.qc.

38{
39 if (this.vehicle)
40 {
43 {
44 this.vehicle_health = -1;
45 Damage(this, this, this, 1 , DEATH_KILL.m_id, DMG_NOWEP, this.origin, '0 0 0');
46 }
47 }
48
49 if (this.killindicator && !wasfreed(this.killindicator))
50 delete(this.killindicator);
51
52 this.killindicator = NULL;
53
56 // SetPlayerTeam() already killed if team changed, auto-selecting the current team shouldn't kill.
57 else if (!IS_SPEC(this) && !IS_OBSERVER(this) && MUTATOR_CALLHOOK(ClientKill_Now, this) == false)
58 Damage(this, this, this, 100000, DEATH_KILL.m_id, DMG_NOWEP, this.origin, '0 0 0');
59
60 // now I am sure the player IS dead
61}
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
void ClientKill_Now(entity this)
Definition clientkill.qc:37
void ClientKill_Now_TeamChange(entity this)
Definition clientkill.qc:18
int killindicator_teamchange
Definition clientkill.qh:8
entity killindicator
Definition clientkill.qh:7
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition damage.qc:503
#define DMG_NOWEP
Definition damage.qh:104
#define NULL
Definition post.qh:14
void vehicles_exit(entity vehic, bool eject)
const float vehicle_health
const int VHEF_RELEASE
User pressed exit key 3 times fast (not implemented) or vehicle is dying.
entity vehicle
Entity to disply the shild effect on damage.
#define IS_OBSERVER(v)
Definition utils.qh:11
#define IS_SPEC(v)
Definition utils.qh:10

References ClientKill_Now(), ClientKill_Now_TeamChange(), Damage(), DMG_NOWEP, entity(), IS_OBSERVER, IS_SPEC, killindicator, killindicator_teamchange, MUTATOR_CALLHOOK, NULL, vehicle, vehicle_health, vehicles_exit(), and VHEF_RELEASE.

Referenced by ClientKill_Now(), ClientKill_TeamChange(), KillIndicator_Think(), and MUTATOR_HOOKABLE().

◆ ClientKill_Now_TeamChange()

void ClientKill_Now_TeamChange ( entity this)

Definition at line 18 of file clientkill.qc.

19{
20 if (this.killindicator_teamchange == -2)
21 {
23 // shouldn't get here because of condition in ClientCommand_spectate()
24 Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime);
25
26 PutObserverInServer(this, false, true);
30 }
31 else
33
35}
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
Definition all.qc:1573
void PutObserverInServer(entity this, bool is_forced, bool use_spawnpoint)
putting a client as observer in the server
Definition client.qc:261
bool autocvar_sv_spectate
Definition client.qh:57
float autocvar_g_maxplayers_spectator_blocktime
Definition client.qh:45
bool TeamBalance_QueuedPlayersTagIn(entity ignore)
Joins queued player(s) to team(s) with a shortage, this should be more robust than only replacing the...
Definition teamplay.qc:775
void TeamBalance_RemoveExcessPlayers(entity ignore)
Definition teamplay.qc:712
bool SetPlayerTeam(entity player, int team_index, int type)
Sets the team of the player.
Definition teamplay.qc:255
bool autocvar_g_balance_teams_remove
Definition teamplay.qh:10
@ TEAM_CHANGE_MANUAL
Player has manually selected their team.
Definition teamplay.qh:115
int Team_TeamToIndex(int team_num)
Converts team value into team index.
Definition teams.qh:184

References autocvar_g_balance_teams_remove, autocvar_g_maxplayers_spectator_blocktime, autocvar_sv_spectate, entity(), killindicator_teamchange, PutObserverInServer(), Send_Notification(), SetPlayerTeam(), TEAM_CHANGE_MANUAL, Team_TeamToIndex(), TeamBalance_QueuedPlayersTagIn(), and TeamBalance_RemoveExcessPlayers().

Referenced by ClientKill_Now(), and PlayerDamage().

◆ ClientKill_Silent()

void ClientKill_Silent ( entity this,
float _delay )

Definition at line 213 of file clientkill.qc.

214{
215 // overrides queued silent killindicators
216 if (!this.killindicator || this.killindicator.count != 1)
217 this.killindicator = new(killindicator);
218 this.killindicator.owner = this;
220 this.killindicator.nextthink = time + (this.lip) * 0.05;
221 this.killindicator.cnt = ceil(_delay);
222 this.killindicator.count = 1; // this is used to indicate that it should be silent
223 this.lip = 0;
224}
void KillIndicator_Think(entity this)
Definition clientkill.qc:62
float time
float ceil(float f)
#define setthink(e, f)
float lip
Definition subs.qh:40

References ceil(), entity(), killindicator, KillIndicator_Think(), lip, setthink, and time.

Referenced by MUTATOR_HOOKFUNCTION().

◆ ClientKill_TeamChange()

void ClientKill_TeamChange ( entity this,
float targetteam )

Definition at line 95 of file clientkill.qc.

96{
97 if (game_stopped)
98 return;
99
100 float killtime = autocvar_g_balance_kill_delay;
101
102 if (MUTATOR_CALLHOOK(ClientKill, this, killtime))
103 return;
104 killtime = M_ARGV(1, float);
105
107 killtime = min(killtime, 1);
108
109 if (targetteam == -1)
110 {
111 if (this.team <= 0)
112 {
113 // Defer autoselect to Join(), after any queued players were joined, to avoid 2 players on same team
114 // when the first player(s) chose specific teams and the last player chose autoselect (they skip the queue).
115 this.team_selected = -1; // don't stop at ShowTeamSelection()
116 return;
117 }
118
119 /* Decide the team now because the "best" team could change during g_balance_kill_delay.
120 * This lets balancing code consider this player to be on the team they're about to change to,
121 * so we won't need to cancel the change after informing the player it's happening,
122 * and so we don't need to handle that in other code such as TeamBalance_QueuedPlayersTagIn().
123 * Also so we can notify immediately when already on a best team instead of counting down for nothing.
124 */
126 targetteam = Team_IndexToTeam(TeamBalance_FindBestTeam(balance, this, true));
127 TeamBalance_Destroy(balance);
128 if (targetteam == this.team)
129 {
130 Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_TEAMCHANGE_ALREADYBEST);
131 return;
132 }
133 }
134 this.killindicator_teamchange = targetteam;
135
136 // this.killindicator.count == 1 means that the kill indicator was spawned by ClientKill_Silent
137 if(killtime <= 0 && this.killindicator && this.killindicator.count == 1)
138 {
139 ClientKill_Now(this); // allow instant kill in this case
140 return;
141 }
142
143 if (!this.killindicator)
144 {
145 if (!IS_DEAD(this))
146 {
147 killtime = max(killtime, this.clientkill_nexttime - time);
148 float antispam_delay = autocvar_g_balance_kill_antispam;
150 antispam_delay = min(antispam_delay, 2);
151 this.clientkill_nexttime = time + killtime + antispam_delay;
152 }
153
154 if (killtime <= 0 || !IS_PLAYER(this) || IS_DEAD(this))
155 {
156 ClientKill_Now(this);
157 }
158 else
159 {
160 float starttime = max(time, clientkilltime);
161
162 this.killindicator = new(killindicator);
163 this.killindicator.owner = this;
164 this.killindicator.scale = 0.5;
165 setattachment(this.killindicator, this, "");
166 setorigin(this.killindicator, '0 0 52');
168 this.killindicator.nextthink = starttime + (this.lip) * 0.05;
169 clientkilltime = max(clientkilltime, this.killindicator.nextthink + 0.05);
170 this.killindicator.cnt = ceil(killtime);
171 this.killindicator.count = bound(0, ceil(killtime), 10);
172 //sprint(this, strcat("^1You'll be dead in ", ftos(this.killindicator.cnt), " seconds\n"));
173
174 IL_EACH(g_clones, it.enemy == this && !(it.effects & CSQCMODEL_EF_RESPAWNGHOST) && !it.killindicator,
175 {
176 it.killindicator = new(killindicator);
177 it.killindicator.owner = it;
178 it.killindicator.scale = 0.5;
179 setattachment(it.killindicator, it, "");
180 setorigin(it.killindicator, '0 0 52');
181 setthink(it.killindicator, KillIndicator_Think);
182 it.killindicator.nextthink = starttime + (it.lip) * 0.05;
183 //clientkilltime = max(clientkilltime, it.killindicator.nextthink + 0.05);
184 it.killindicator.cnt = ceil(killtime);
185 });
186 this.lip = 0;
187 }
188 }
189 if (this.killindicator)
190 {
191 Notification notif;
192 if (targetteam == 0) // just die
193 {
194 this.killindicator.colormod = '0 0 0';
195 notif = CENTER_TEAMCHANGE_SUICIDE;
196 }
197 else if (targetteam == -2) // spectate
198 {
199 this.killindicator.colormod = '0.5 0.5 0.5';
200 notif = CENTER_TEAMCHANGE_SPECTATE;
201 }
202 else
203 {
204 this.killindicator.colormod = Team_ColorRGB(targetteam);
205 notif = APP_TEAM_NUM(targetteam, CENTER_TEAMCHANGE);
206 }
207 if (IS_REAL_CLIENT(this) && this.killindicator.cnt > 0)
208 Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, notif, this.killindicator.cnt);
209 }
210
211}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
int team
Definition main.qh:188
float clientkill_nexttime
Definition clientkill.qc:94
float clientkilltime
Definition clientkill.qc:93
float autocvar_g_balance_kill_delay
Definition clientkill.qh:3
float autocvar_g_balance_kill_antispam
Definition clientkill.qh:4
#define M_ARGV(x, type)
Definition events.qh:17
#define IS_DEAD(s)
Definition player.qh:245
#define IS_PLAYER(s)
Definition player.qh:243
#define CSQCMODEL_EF_RESPAWNGHOST
#define IL_EACH(this, cond, body)
#define ClientKill
Definition _all.inc:250
float bound(float min, float value, float max)
float min(float f,...)
float max(float f,...)
entity Notification
always last
Definition all.qh:81
#define APP_TEAM_NUM(num, prefix)
Definition all.qh:84
#define round_handler_IsActive()
#define round_handler_IsRoundStarted()
int team_selected
Definition client.qh:75
IntrusiveList g_clones
Definition player.qh:45
void TeamBalance_Destroy(entity balance)
Destroy the team balance entity.
Definition teamplay.qc:599
entity TeamBalance_CheckAllowedTeams(entity for_whom)
Checks whether the player can join teams according to global configuration and mutator settings.
Definition teamplay.qc:459
int TeamBalance_FindBestTeam(entity balance, entity player, bool ignore_player)
Finds the team that will make the game most balanced if the player joins it.
Definition teamplay.qc:944
vector Team_ColorRGB(int teamid)
Definition teams.qh:76
int Team_IndexToTeam(int index)
Converts team index into team value.
Definition teams.qh:169
#define IS_REAL_CLIENT(v)
Definition utils.qh:17

References APP_TEAM_NUM, autocvar_g_balance_kill_antispam, autocvar_g_balance_kill_delay, bound(), ceil(), ClientKill, clientkill_nexttime, ClientKill_Now(), clientkilltime, CSQCMODEL_EF_RESPAWNGHOST, entity(), g_clones, game_stopped, IL_EACH, IS_DEAD, IS_PLAYER, IS_REAL_CLIENT, killindicator, killindicator_teamchange, KillIndicator_Think(), lip, M_ARGV, max(), min(), MUTATOR_CALLHOOK, round_handler_IsActive, round_handler_IsRoundStarted, Send_Notification(), setthink, team, Team_ColorRGB(), Team_IndexToTeam(), team_selected, TeamBalance_CheckAllowedTeams(), TeamBalance_Destroy(), TeamBalance_FindBestTeam(), and time.

Referenced by ClientCommand_clientversion(), ClientCommand_selectteam(), ClientCommand_spectate(), and ClientKill().

◆ KillIndicator_Think()

void KillIndicator_Think ( entity this)

Definition at line 62 of file clientkill.qc.

63{
64 if (game_stopped || (this.owner.alpha < 0 && !this.owner.vehicle))
65 {
66 this.owner.killindicator = NULL;
67 delete(this);
68 return;
69 }
70
71 if (this.cnt <= 0)
72 {
74 return;
75 }
76
77 // count == 1 means that it's silent
78 if (this.count != 1)
79 {
80 if (this.cnt <= 10)
81 setmodel(this, MDL_NUM(this.cnt));
82 if (IS_REAL_CLIENT(this.owner))
83 {
84 if (this.cnt <= 10)
85 Send_Notification(NOTIF_ONE, this.owner, MSG_ANNCE, Announcer_PickNumber(CNT_KILL, this.cnt));
86 }
87 }
88 this.nextthink = time + 1;
89 this.cnt -= 1;
90}
float cnt
Definition powerups.qc:24
float count
Definition powerups.qc:22
entity owner
Definition main.qh:87
#define setmodel(this, m)
Definition model.qh:26
Notification Announcer_PickNumber(int type, int num)
Definition util.qc:1827
const int CNT_KILL
Definition util.qh:254
float nextthink
Model MDL_NUM(int i)
Definition all.inc:229

References Announcer_PickNumber(), ClientKill_Now(), cnt, CNT_KILL, count, entity(), game_stopped, IS_REAL_CLIENT, MDL_NUM(), nextthink, NULL, owner, Send_Notification(), setmodel, and time.

Referenced by ClientKill_Silent(), and ClientKill_TeamChange().

Variable Documentation

◆ clientkill_nexttime

float clientkill_nexttime

Definition at line 94 of file clientkill.qc.

Referenced by ClientKill_TeamChange().

◆ clientkilltime

float clientkilltime

Definition at line 93 of file clientkill.qc.

Referenced by ClientKill_TeamChange().

◆ lip

float lip

Definition at line 92 of file clientkill.qc.