Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
sv_tka.qc File Reference
#include "sv_tka.qh"
#include <common/checkextension.qh>
#include <common/effects/all.qh>
Include dependency graph for sv_tka.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BALL_XYDIST   24
#define BALL_XYSPEED   100

Functions

void havocbot_goalrating_tkaball (entity this, float ratingscale, float ratingscale_sameteam, vector org)
void havocbot_role_tka_carrier (entity this)
void havocbot_role_tka_collector (entity this)
 if (!IS_PLAYER(frag_attacker)||!IS_PLAYER(frag_target)) return
 if (frag_attacker.ballcarried)
 MODEL (TKA_BALL, "models/orbs/orbblue.md3")
 MUTATOR_HOOKFUNCTION (tka, GiveFragsForKill)
 MUTATOR_HOOKFUNCTION (tka, PlayerDies)
 MUTATOR_HOOKFUNCTION (tka, PlayerPreThink)
 MUTATOR_HOOKFUNCTION (tka, PlayerUseKey)
 MUTATOR_HOOKFUNCTION (tka, reset_map_global)
 MUTATOR_HOOKFUNCTION (tka, Scores_CountFragsRemaining)
bool tka_ballcarrier_waypointsprite_visible_for_player (entity this, entity player, entity view)
void tka_BallThink_Carried (entity this)
 runs (only) while a player is carrying the ball
void tka_DropEvent (entity player)
void tka_EventLog (string mode, entity actor)
void tka_Handler_CheckBall (entity this)
void tka_PlayerReset (entity player)
void tka_RemoveBalls ()
void tka_RespawnBall (entity this)
void tka_SpawnBalls ()
void tka_TouchEvent (entity this, entity toucher)
bool tka_waypointsprite_visible_for_bot (entity this, entity e, bool dropped)

Variables

vector autocvar_g_tka_ballcarrier_damage
vector autocvar_g_tka_ballcarrier_force
float autocvar_g_tka_ballcarrier_highspeed
int autocvar_g_tka_ballcarrier_maxballs
vector autocvar_g_tka_noncarrier_damage
vector autocvar_g_tka_noncarrier_force
bool autocvar_g_tka_noncarrier_warn
int autocvar_g_tka_score_bckill
int autocvar_g_tka_score_killac
bool autocvar_g_tka_score_team
int autocvar_g_tka_score_timepoints
int autocvar_g_tkaball_count
float autocvar_g_tkaball_damageforcescale
int autocvar_g_tkaball_effects
float autocvar_g_tkaball_respawntime
int autocvar_g_tkaball_tracking
int autocvar_g_tkaball_trail_color
entity ballcarried
float float2int_decimal_fld
entity frag_target = M_ARGV(2, entity)
entity previous_owner
bool pushable

Macro Definition Documentation

◆ BALL_XYDIST

#define BALL_XYDIST   24

◆ BALL_XYSPEED

#define BALL_XYSPEED   100

Function Documentation

◆ havocbot_goalrating_tkaball()

void havocbot_goalrating_tkaball ( entity this,
float ratingscale,
float ratingscale_sameteam,
vector org )

Definition at line 315 of file sv_tka.qc.

316{
317 entity ball = NULL, ball_carried = NULL;
318
319 // stops at last ball, prefers ball without carrier
320 IL_EACH(g_tkaballs, it.owner != this,
321 {
322 if (it.owner)
323 {
324 if (!tka_waypointsprite_visible_for_bot(this, it.owner, false))
325 continue;
326 ball_carried = it.owner;
327 }
328 else
329 {
330 if (!tka_waypointsprite_visible_for_bot(this, it, true))
331 continue;
332 ball = it;
333 }
334 });
335
336 if (ball)
337 navigation_routerating(this, ball, ratingscale, 2000);
338 else if (ball_carried)
339 {
340 if (DIFF_TEAM(ball_carried, this))
341 navigation_routerating(this, ball_carried, ratingscale, 2000);
342 else
343 navigation_routerating(this, ball_carried, ratingscale_sameteam, 2000);
344 }
345}
void navigation_routerating(entity this, entity e, float f, float rangebias)
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define IL_EACH(this, cond, body)
#define NULL
Definition post.qh:14
IntrusiveList g_tkaballs
Definition sv_tka.qh:13
#define DIFF_TEAM(a, b)
Definition teams.qh:242

References entity(), g_tkaballs, IL_EACH, NULL, org, and vector.

Referenced by havocbot_role_tka_collector().

◆ havocbot_role_tka_carrier()

void havocbot_role_tka_carrier ( entity this)

Definition at line 347 of file sv_tka.qc.

348{
349 if (IS_DEAD(this))
350 return;
351
353 {
355 havocbot_goalrating_items(this, 10000, this.origin, 10000);
356 havocbot_goalrating_enemyplayers(this, 10000, this.origin, 10000);
357 havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
359
361 }
362
363 if (!this.ballcarried)
364 {
365 this.havocbot_role = havocbot_role_tka_collector;
367 }
368}
void havocbot_goalrating_waypoints(entity this, float ratingscale, vector org, float sradius)
Definition roles.qc:16
void navigation_goalrating_start(entity this)
void navigation_goalrating_timeout_set(entity this)
Definition navigation.qc:20
bool navigation_goalrating_timeout(entity this)
Definition navigation.qc:44
void navigation_goalrating_timeout_expire(entity this, float seconds)
Definition navigation.qc:36
void navigation_goalrating_end(entity this)
#define IS_DEAD(s)
Definition player.qh:245
vector origin
entity ballcarried
void havocbot_goalrating_items(entity this, float ratingscale, vector org, float sradius)
Definition roles.qc:106
void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org, float sradius)
Definition roles.qc:176
void havocbot_role_tka_collector(entity this)
Definition sv_tka.qc:370

References ballcarried, entity(), havocbot_goalrating_enemyplayers(), havocbot_goalrating_items(), havocbot_goalrating_waypoints(), havocbot_role_tka_collector(), IS_DEAD, navigation_goalrating_end(), navigation_goalrating_start(), navigation_goalrating_timeout(), navigation_goalrating_timeout_expire(), navigation_goalrating_timeout_set(), and origin.

Referenced by havocbot_role_tka_collector(), and void().

◆ havocbot_role_tka_collector()

void havocbot_role_tka_collector ( entity this)

Definition at line 370 of file sv_tka.qc.

371{
372 if (IS_DEAD(this))
373 return;
374
376 {
378 havocbot_goalrating_items(this, 10000, this.origin, 10000);
379 havocbot_goalrating_enemyplayers(this, 500, this.origin, 10000);
380 havocbot_goalrating_tkaball(this, 8000, 4000, this.origin);
382
384 }
385
386 if (this.ballcarried)
387 {
388 this.havocbot_role = havocbot_role_tka_carrier;
390 }
391}
void havocbot_goalrating_tkaball(entity this, float ratingscale, float ratingscale_sameteam, vector org)
Definition sv_tka.qc:315
void havocbot_role_tka_carrier(entity this)
Definition sv_tka.qc:347

References ballcarried, entity(), havocbot_goalrating_enemyplayers(), havocbot_goalrating_items(), havocbot_goalrating_tkaball(), havocbot_role_tka_carrier(), IS_DEAD, navigation_goalrating_end(), navigation_goalrating_start(), navigation_goalrating_timeout(), navigation_goalrating_timeout_expire(), navigation_goalrating_timeout_set(), and origin.

Referenced by havocbot_role_tka_carrier(), and void().

◆ if() [1/2]

if ( ! IS_PLAYERfrag_attacker)||!IS_PLAYER(frag_target)

References frag_target.

◆ if() [2/2]

if ( frag_attacker. ballcarried)

Definition at line 493 of file sv_tka.qc.

494 {
495 if (frag_target == frag_attacker) // damage done to themselves
496 {
499 }
500 else if (frag_target.ballcarried) // damage done to other ballcarriers
501 {
504 }
505 else // damage done to noncarriers
506 {
509 }
510 }
#define M_ARGV(x, type)
Definition events.qh:17
vector
Definition self.qh:92
entity frag_target
Definition sv_ctf.qc:2321
vector autocvar_g_tka_ballcarrier_force
Definition sv_tka.qc:12
vector autocvar_g_tka_ballcarrier_damage
Definition sv_tka.qc:11

References autocvar_g_tka_ballcarrier_damage, autocvar_g_tka_ballcarrier_force, frag_target, M_ARGV, and vector.

◆ MODEL()

MODEL ( TKA_BALL ,
"models/orbs/orbblue.md3"  )

◆ MUTATOR_HOOKFUNCTION() [1/6]

MUTATOR_HOOKFUNCTION ( tka ,
GiveFragsForKill  )

Definition at line 431 of file sv_tka.qc.

432{
433 M_ARGV(2, float) = 0; // no frags counted in keepaway
434 return true; // you deceptive little bugger ;3 This needs to be true in order for this function to even count.
435}

References M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [2/6]

MUTATOR_HOOKFUNCTION ( tka ,
PlayerDies  )

Definition at line 398 of file sv_tka.qc.

399{
400 entity frag_attacker = M_ARGV(1, entity);
402
403 if(frag_attacker != frag_target && IS_PLAYER(frag_attacker) && DIFF_TEAM(frag_attacker, frag_target))
404 {
405 bool team_has_ball = false;
406 IL_EACH(g_tkaballs, it.owner != frag_attacker && SAME_TEAM(it.owner, frag_attacker),
407 {
408 team_has_ball = true;
409 break;
410 });
411 if(frag_target.ballcarried) // add to amount of times killing carrier
412 {
413 GameRules_scoring_add(frag_attacker, TKA_CARRIERKILLS, 1);
414 if(autocvar_g_tka_score_bckill) // add bckills to the score
416 }
417 else if(!frag_attacker.ballcarried && !(autocvar_g_tka_score_team && team_has_ball))
418 {
420 Send_Notification(NOTIF_ONE_ONLY, frag_attacker, MSG_CENTER, CENTER_KEEPAWAY_WARN);
421 }
422
423 if(frag_attacker.ballcarried || (autocvar_g_tka_score_team && team_has_ball)) // add to amount of kills while ballcarrier (or if team scoring is enabled)
425 }
426
427 while (frag_target.ballcarried)
428 tka_DropEvent(frag_target); // a player with ball(s) has died, drop them
429}
#define IS_PLAYER(s)
Definition player.qh:243
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
Definition all.qc:1573
#define GameRules_scoring_add(client, fld, value)
Definition sv_rules.qh:85
#define GameRules_scoring_add_team(client, fld, value)
Definition sv_rules.qh:89
bool autocvar_g_tka_noncarrier_warn
Definition sv_tka.qc:15
int autocvar_g_tka_score_bckill
Definition sv_tka.qc:17
int autocvar_g_tka_score_killac
Definition sv_tka.qc:18
bool autocvar_g_tka_score_team
Definition sv_tka.qc:19
void tka_DropEvent(entity player)
Definition sv_tka.qc:187
#define SAME_TEAM(a, b)
Definition teams.qh:241

References autocvar_g_tka_noncarrier_warn, autocvar_g_tka_score_bckill, autocvar_g_tka_score_killac, autocvar_g_tka_score_team, DIFF_TEAM, entity(), frag_target, g_tkaballs, GameRules_scoring_add, GameRules_scoring_add_team, IL_EACH, IS_PLAYER, M_ARGV, SAME_TEAM, Send_Notification(), and tka_DropEvent().

◆ MUTATOR_HOOKFUNCTION() [3/6]

MUTATOR_HOOKFUNCTION ( tka ,
PlayerPreThink  )

Definition at line 443 of file sv_tka.qc.

444{
445 entity player = M_ARGV(0, entity);
446
447 // clear the item used for the ball in keepaway
448 STAT(TKA_BALLSTATUS, player) = 0;
449
450 // if the player has the ball, make sure they have the item for it (Used for HUD primarily)
451 if(player.ballcarried)
452 STAT(TKA_BALLSTATUS, player) |= TKA_BALL_CARRYING;
453
454 IL_EACH(g_tkaballs, true,
455 {
456 if(!it.owner)
457 STAT(TKA_BALLSTATUS, player) |= TKA_BALL_DROPPED;
458 else
459 {
460 // TODO: teamless carrier?
461 switch(it.owner.team)
462 {
463 case NUM_TEAM_1: STAT(TKA_BALLSTATUS, player) |= TKA_BALL_TAKEN_RED; break;
464 case NUM_TEAM_2: STAT(TKA_BALLSTATUS, player) |= TKA_BALL_TAKEN_BLUE; break;
465 case NUM_TEAM_3: STAT(TKA_BALLSTATUS, player) |= TKA_BALL_TAKEN_YELLOW; break;
466 case NUM_TEAM_4: STAT(TKA_BALLSTATUS, player) |= TKA_BALL_TAKEN_PINK; break;
467 }
468 }
469 });
470}
#define STAT(...)
Definition stats.qh:82
const int NUM_TEAM_2
Definition teams.qh:14
const int NUM_TEAM_4
Definition teams.qh:16
const int NUM_TEAM_3
Definition teams.qh:15
const int NUM_TEAM_1
Definition teams.qh:13
const int TKA_BALL_CARRYING
Definition tka.qh:66
const int TKA_BALL_TAKEN_YELLOW
Definition tka.qh:64
const int TKA_BALL_TAKEN_RED
Definition tka.qh:62
const int TKA_BALL_DROPPED
Definition tka.qh:67
const int TKA_BALL_TAKEN_PINK
Definition tka.qh:65
const int TKA_BALL_TAKEN_BLUE
Definition tka.qh:63

References entity(), g_tkaballs, IL_EACH, M_ARGV, NUM_TEAM_1, NUM_TEAM_2, NUM_TEAM_3, NUM_TEAM_4, PlayerPreThink, STAT, TKA_BALL_CARRYING, TKA_BALL_DROPPED, TKA_BALL_TAKEN_BLUE, TKA_BALL_TAKEN_PINK, TKA_BALL_TAKEN_RED, and TKA_BALL_TAKEN_YELLOW.

◆ MUTATOR_HOOKFUNCTION() [4/6]

MUTATOR_HOOKFUNCTION ( tka ,
PlayerUseKey  )

Definition at line 472 of file sv_tka.qc.

473{
474 entity player = M_ARGV(0, entity);
475
476 if(MUTATOR_RETURNVALUE == 0)
477 if(player.ballcarried)
478 {
479 tka_DropEvent(player);
480 return true;
481 }
482}
#define MUTATOR_RETURNVALUE
Definition base.qh:328

References entity(), M_ARGV, MUTATOR_RETURNVALUE, PlayerUseKey(), and tka_DropEvent().

◆ MUTATOR_HOOKFUNCTION() [5/6]

MUTATOR_HOOKFUNCTION ( tka ,
reset_map_global  )

Definition at line 77 of file sv_tka.qc.

78{
79 FOREACH_CLIENT(true,
80 {
81 it.float2int_decimal_fld = 0;
82 });
83 return true;
84}
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:50

References FOREACH_CLIENT.

◆ MUTATOR_HOOKFUNCTION() [6/6]

MUTATOR_HOOKFUNCTION ( tka ,
Scores_CountFragsRemaining  )

Definition at line 437 of file sv_tka.qc.

438{
439 // announce remaining frags, but only when timed scoring is off
441}
int autocvar_g_tka_score_timepoints
Definition sv_tka.qc:20

References autocvar_g_tka_score_timepoints.

◆ tka_ballcarrier_waypointsprite_visible_for_player()

bool tka_ballcarrier_waypointsprite_visible_for_player ( entity this,
entity player,
entity view )

Definition at line 28 of file sv_tka.qc.

29{
30 if(view.ballcarried && IS_SPEC(player))
31 return false; // we don't want spectators of the ballcarrier to see the attached waypoint on the top of their screen
32 if(IS_SPEC(player) || warmup_stage || SAME_TEAM(player, this.owner))
33 return true;
34 if(IS_INVISIBLE(this.owner))
35 return false; // hide the waypointsprite if the owner is invisible
36
38}
entity owner
Definition main.qh:87
bool warmup_stage
Definition main.qh:120
int autocvar_g_tkaball_tracking
Definition sv_tka.qc:26
#define IS_INVISIBLE(v)
Definition utils.qh:27
#define IS_SPEC(v)
Definition utils.qh:10

References autocvar_g_tkaball_tracking, entity(), IS_INVISIBLE, IS_SPEC, owner, SAME_TEAM, and warmup_stage.

Referenced by tka_TouchEvent().

◆ tka_BallThink_Carried()

void tka_BallThink_Carried ( entity this)

runs (only) while a player is carrying the ball

Definition at line 87 of file sv_tka.qc.

88{
91 GameRules_scoring_add(this.owner, TKA_BCTIME, frametime);
92
93 this.nextthink = time;
94
95 // animate, this is ~copied from KH
96#define BALL_XYSPEED 100 // KH 45
97#define BALL_XYDIST 24 // KH 24
98 makevectors(vec3(0, (360 * this.cnt / this.owner.ballcarried.cnt) + (time % 360) * BALL_XYSPEED, 0));
99 setorigin(this, vec3(v_forward.x * BALL_XYDIST, v_forward.y * BALL_XYDIST, this.origin.z));
100
101 // sync any invisibility effect
102 this.alpha = this.owner.alpha;
103}
float cnt
Definition powerups.qc:24
float alpha
Definition items.qc:13
float frametime
float time
float nextthink
vector v_forward
#define makevectors
Definition post.qh:21
float float2int_decimal_fld
#define BALL_XYSPEED
#define BALL_XYDIST
#define GameRules_scoring_add_team_float2int(client, fld, value, float_field, score_factor)
Definition sv_rules.qh:87
#define vec3(_x, _y, _z)
Definition vector.qh:95

References alpha, autocvar_g_tka_score_timepoints, BALL_XYDIST, BALL_XYSPEED, cnt, entity(), float2int_decimal_fld, frametime, GameRules_scoring_add, GameRules_scoring_add_team_float2int, makevectors, nextthink, owner, time, v_forward, and vec3.

Referenced by tka_TouchEvent().

◆ tka_DropEvent()

void tka_DropEvent ( entity player)

Definition at line 187 of file sv_tka.qc.

188{
189 entity ball;
190 ball = player.ballcarried;
191
192 if(!ball) { return; }
193
194 // reset the ball
195 setattachment(ball, NULL, "");
197 ball.previous_owner = player;
198 ball.wait = time + 0.5; // same as for thrown weapons
200 ball.nextthink = time + autocvar_g_tkaball_respawntime;
201 ball.takedamage = DAMAGE_YES;
202 ball.scale = 1; // it's smaller while carried
203 ball.alpha = 1; // in case the carrier had an invisibility effect
204 ball.solid = SOLID_TRIGGER; // before setorigin to ensure area grid linking
205 setorigin(ball, player.origin + ball.origin + '0 0 10'); // include attachment offset to reduce jump
206 nudgeoutofsolid_OrFallback(ball); // a ball has a horizontally bigger bbox than a player
207 ball.velocity = '0 0 200' + '0 100 0'*crandom() + '100 0 0'*crandom();
208 ball.owner = NULL;
209 navigation_dynamicgoal_set(ball, player);
210
211 // messages and sounds
212 tka_EventLog("dropped", player);
213 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_KEEPAWAY_DROPPED, player.netname);
214 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_KEEPAWAY_DROPPED, player.netname);
215 sound(NULL, CH_TRIGGER, SND_KA_DROPPED, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere)
216
217 // waypoints
219 {
220 WaypointSprite_Spawn(WP_KaBall, 0, 0, ball, '0 0 64', NULL, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER);
221 WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
222 WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier);
223 }
224
225 if (ball.ballcarried) // >1 ball was chained, first one was just dropped
226 {
227 player.ballcarried = ball.ballcarried; // move the next one up
228 ball.ballcarried = NULL; // prevent infinite loop
229 }
230 else // no balls remaining so remove bc status
231 tka_PlayerReset(player);
232}
void navigation_dynamicgoal_set(entity this, entity dropper)
Definition navigation.qc:87
const float SOLID_TRIGGER
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_BOUNCE
Definition movetypes.qh:139
#define crandom()
Returns a random number between -1.0 and 1.0.
Definition random.qh:32
#define setthink(e, f)
const int CH_TRIGGER
Definition sound.qh:12
const float VOL_BASE
Definition sound.qh:36
const float ATTEN_NONE
Definition sound.qh:27
#define sound(e, c, s, v, a)
Definition sound.qh:52
const int DAMAGE_YES
Definition subs.qh:80
void tka_EventLog(string mode, entity actor)
Definition sv_tka.qc:40
void tka_RespawnBall(entity this)
Definition sv_tka.qc:47
float autocvar_g_tkaball_respawntime
Definition sv_tka.qc:24
void tka_PlayerReset(entity player)
Definition sv_tka.qc:180
void WaypointSprite_Ping(entity e)
entity WaypointSprite_Spawn(entity spr, float _lifetime, float maxdistance, entity ref, vector ofs, entity showto, float t, entity own,.entity ownfield, float hideable, entity icon)
void WaypointSprite_UpdateRule(entity e, float t, float r)
const int SPRITERULE_DEFAULT
entity waypointsprite_attachedforcarrier

References ATTEN_NONE, autocvar_g_tkaball_respawntime, autocvar_g_tkaball_tracking, CH_TRIGGER, crandom, DAMAGE_YES, entity(), MOVETYPE_BOUNCE, navigation_dynamicgoal_set(), NULL, Send_Notification(), set_movetype(), setthink, SOLID_TRIGGER, sound, SPRITERULE_DEFAULT, time, tka_EventLog(), tka_PlayerReset(), tka_RespawnBall(), VOL_BASE, warmup_stage, waypointsprite_attachedforcarrier, WaypointSprite_Ping(), WaypointSprite_Spawn(), and WaypointSprite_UpdateRule().

Referenced by MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ tka_EventLog()

void tka_EventLog ( string mode,
entity actor )

Definition at line 40 of file sv_tka.qc.

41{
43 GameLogEcho(strcat(":tka:", mode, ((actor != NULL) ? (strcat(":", ftos(actor.team), ":", ftos(actor.playerid))) : "")));
44}
void GameLogEcho(string s)
Definition gamelog.qc:15
bool autocvar_sv_eventlog
Definition gamelog.qh:3
string ftos(float f)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))

References autocvar_sv_eventlog, entity(), ftos(), GameLogEcho(), NULL, and strcat().

Referenced by tka_DropEvent(), and tka_TouchEvent().

◆ tka_Handler_CheckBall()

void tka_Handler_CheckBall ( entity this)

Definition at line 282 of file sv_tka.qc.

283{
284 if(time < game_starttime)
285 {
286 if (!IL_EMPTY(g_tkaballs))
288 }
289 else
290 {
291 if (IL_EMPTY(g_tkaballs))
293 }
294
295 this.nextthink = time;
296}
float game_starttime
Definition stats.qh:82
#define IL_EMPTY(this)
void tka_RemoveBalls()
Definition sv_tka.qc:238
void tka_SpawnBalls()
Definition sv_tka.qc:250

References entity(), g_tkaballs, game_starttime, IL_EMPTY, nextthink, time, tka_RemoveBalls(), and tka_SpawnBalls().

◆ tka_PlayerReset()

void tka_PlayerReset ( entity player)

Definition at line 180 of file sv_tka.qc.

181{
182 player.ballcarried = NULL;
183 GameRules_scoring_vip(player, false);
184 WaypointSprite_Kill(player.waypointsprite_attachedforcarrier);
185}
#define GameRules_scoring_vip(player, value)
Definition sv_rules.qh:78
void WaypointSprite_Kill(entity wp)

References entity(), GameRules_scoring_vip, NULL, and WaypointSprite_Kill().

Referenced by tka_DropEvent(), and tka_RemoveBalls().

◆ tka_RemoveBalls()

void tka_RemoveBalls ( )

Definition at line 238 of file sv_tka.qc.

239{
240 IL_EACH(g_tkaballs, true,
241 {
242 if (it.owner) // it was attached
243 tka_PlayerReset(it.owner);
244 else
246 delete(it);
247 });
248}
void WaypointSprite_DetachCarrier(entity carrier)

References g_tkaballs, IL_EACH, tka_PlayerReset(), and WaypointSprite_DetachCarrier().

Referenced by tka_Handler_CheckBall().

◆ tka_RespawnBall()

void tka_RespawnBall ( entity this)

Definition at line 47 of file sv_tka.qc.

48{
49 if(game_stopped) return;
50 vector oldballorigin = this.origin;
51
53 setorigin(this, SelectSpawnPoint(this, true).origin);
54
56 this.velocity = '0 0 200';
57 this.angles = '0 0 0';
62
63 Send_Effect(EFFECT_KA_BALL_RESPAWN, oldballorigin, '0 0 0', 1);
64 Send_Effect(EFFECT_KA_BALL_RESPAWN, this.origin, '0 0 0', 1);
65
67 {
68 WaypointSprite_Spawn(WP_KaBall, 0, 0, this, '0 0 64', NULL, this.team, this, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER);
70 }
71
72 sound(this, CH_TRIGGER, SND_KA_RESPAWN, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere)
73}
int team
Definition main.qh:188
float game_stopped
Definition stats.qh:81
float Q3SURFACEFLAG_SKY
float DPCONTENTS_SKY
float DPCONTENTS_DONOTENTER
float DPCONTENTS_SOLID
float DPCONTENTS_CORPSE
vector velocity
float DPCONTENTS_BODY
float effects
float DPCONTENTS_PLAYERCLIP
float DPCONTENTS_SLIME
float DPCONTENTS_LAVA
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:124
ent angles
Definition ent_cs.qc:121
entity SelectSpawnPoint(entity this, bool anypoint)
int autocvar_g_tkaball_effects
Definition sv_tka.qc:23
float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance)
Definition world.qc:1231

References angles, ATTEN_NONE, autocvar_g_tkaball_effects, autocvar_g_tkaball_respawntime, autocvar_g_tkaball_tracking, CH_TRIGGER, DPCONTENTS_BODY, DPCONTENTS_CORPSE, DPCONTENTS_DONOTENTER, DPCONTENTS_LAVA, DPCONTENTS_PLAYERCLIP, DPCONTENTS_SKY, DPCONTENTS_SLIME, DPCONTENTS_SOLID, effects, entity(), game_stopped, MoveToRandomMapLocation(), MOVETYPE_BOUNCE, navigation_dynamicgoal_set(), nextthink, NULL, origin, Q3SURFACEFLAG_SKY, SelectSpawnPoint(), Send_Effect(), set_movetype(), setthink, sound, team, time, tka_RespawnBall(), vector, velocity, VOL_BASE, warmup_stage, waypointsprite_attachedforcarrier, WaypointSprite_Ping(), and WaypointSprite_Spawn().

Referenced by tka_DropEvent(), tka_RespawnBall(), tka_SpawnBalls(), and tka_TouchEvent().

◆ tka_SpawnBalls()

void tka_SpawnBalls ( )

Definition at line 250 of file sv_tka.qc.

251{
252 int i = 0;
253 do // never allow less than 1 ball to spawn
254 {
255 entity e = new(keepawayball);
256 setmodel(e, MDL_TKA_BALL);
257 // 20 20 20 was too big, player is only 16 16 24... gotta cheat with the Z (20) axis so that the particle isn't cut off
258 // bones_was_here: that was WITH sv_legacy_bbox_expand 1 and FL_ITEM (mins -= '15 15 1'; maxs += '15 15 1')
259 // it's round so should have a symmetrical bbox, same height as pickup items so it can't be jumped over in any physics
260 setsize(e, '-24 -24 -24', '24 24 24');
261 e.damageforcescale = autocvar_g_tkaball_damageforcescale;
262 e.takedamage = DAMAGE_YES;
263 e.solid = SOLID_TRIGGER;
265 e.glow_color = autocvar_g_tkaball_trail_color;
266 e.glow_trail = true;
267 e.flags = FL_ITEM;
268 IL_PUSH(g_items, e);
269 e.pushable = true;
271 e.owner = NULL;
274
276
277 ++i;
278 }
279 while (i < autocvar_g_tkaball_count);
280}
void navigation_dynamicgoal_init(entity this, bool initially_static)
Definition navigation.qc:77
#define setmodel(this, m)
Definition model.qh:26
const int FL_ITEM
Definition constants.qh:77
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define settouch(e, f)
Definition self.qh:73
IntrusiveList g_items
Definition items.qh:125
int autocvar_g_tkaball_trail_color
Definition sv_tka.qc:25
int autocvar_g_tkaball_count
Definition sv_tka.qc:21
void tka_TouchEvent(entity this, entity toucher)
Definition sv_tka.qc:105
float autocvar_g_tkaball_damageforcescale
Definition sv_tka.qc:22

References autocvar_g_tkaball_count, autocvar_g_tkaball_damageforcescale, autocvar_g_tkaball_trail_color, DAMAGE_YES, entity(), FL_ITEM, g_items, g_tkaballs, IL_PUSH(), MOVETYPE_BOUNCE, navigation_dynamicgoal_init(), NULL, set_movetype(), setmodel, settouch, SOLID_TRIGGER, tka_RespawnBall(), and tka_TouchEvent().

Referenced by tka_Handler_CheckBall().

◆ tka_TouchEvent()

void tka_TouchEvent ( entity this,
entity toucher )

Definition at line 105 of file sv_tka.qc.

106{
107 if (!this || game_stopped)
108 return;
109
111 { // The ball fell off the map, respawn it since players can't get to it
112 tka_RespawnBall(this);
113 return;
114 }
115 if(IS_INDEPENDENT_PLAYER(toucher)) { return; }
116 if(IS_DEAD(toucher)) { return; }
117 if (!IS_PLAYER(toucher))
118 { // The ball just touched an object, most likely the world
119 Send_Effect(EFFECT_BALL_SPARKS, this.origin, '0 0 0', 1);
120 sound(this, CH_TRIGGER, SND_KA_TOUCH, VOL_BASE, ATTEN_NORM);
121 return;
122 }
123 else if(this.wait > time && this.previous_owner == toucher)
124 return;
125
126 if (toucher.ballcarried) // multiple balls exist
127 {
128 if (toucher.ballcarried.cnt >= autocvar_g_tka_ballcarrier_maxballs)
129 return;
130 this.ballcarried = toucher.ballcarried; // new ball will be inserted at start of chain
131 this.cnt = toucher.ballcarried.cnt + 1; // for orbit animation offset
132 }
133 else
134 this.cnt = 1;
135
136 // attach the ball to the player
137 this.owner = toucher;
138 toucher.ballcarried = this;
140 setattachment(this, toucher, "");
141 this.solid = SOLID_NOT; // before setorigin to ensure area grid unlinking
142 setorigin(this, '0 0 0');
143
144 // make the ball unable to do anything, set up time scoring
145 this.velocity = '0 0 0';
147 this.scale = 12/16; // somewhat smaller while carried
149 this.nextthink = time;
150 this.takedamage = DAMAGE_NO;
152
153 // messages and sounds
154 tka_EventLog("pickup", toucher);
155 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_KEEPAWAY_PICKUP, toucher.netname);
156 Send_Notification(NOTIF_ALL_EXCEPT, toucher, MSG_CENTER, CENTER_KEEPAWAY_PICKUP, toucher.netname);
157 Send_Notification(NOTIF_ONE, toucher, MSG_CENTER, CENTER_KEEPAWAY_PICKUP_SELF);
158 sound(this.owner, CH_TRIGGER, SND_KA_PICKEDUP, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere)
159
160 // scoring
161 GameRules_scoring_add(toucher, TKA_PICKUPS, 1);
162
163 // waypoints
164 WaypointSprite_AttachCarrier(WP_Null, toucher, RADARICON_FLAGCARRIER);
165 toucher.waypointsprite_attachedforcarrier.colormod = colormapPaletteColor(toucher.team - 1, 0);
166 toucher.waypointsprite_attachedforcarrier.waypointsprite_visible_for_player = tka_ballcarrier_waypointsprite_visible_for_player;
167 WaypointSprite_UpdateRule(toucher.waypointsprite_attachedforcarrier, toucher.team, SPRITERULE_TEAMPLAY);
168 if(toucher.team == NUM_TEAM_1)
169 WaypointSprite_UpdateSprites(toucher.waypointsprite_attachedforcarrier, WP_TkaBallCarrierRed, WP_KaBallCarrier, WP_TkaBallCarrierRed);
170 else if(toucher.team == NUM_TEAM_2)
171 WaypointSprite_UpdateSprites(toucher.waypointsprite_attachedforcarrier, WP_TkaBallCarrierBlue, WP_KaBallCarrier, WP_TkaBallCarrierBlue);
172 else if(toucher.team == NUM_TEAM_3)
173 WaypointSprite_UpdateSprites(toucher.waypointsprite_attachedforcarrier, WP_TkaBallCarrierYellow, WP_KaBallCarrier, WP_TkaBallCarrierYellow);
174 else if(toucher.team == NUM_TEAM_4)
175 WaypointSprite_UpdateSprites(toucher.waypointsprite_attachedforcarrier, WP_TkaBallCarrierPink, WP_KaBallCarrier, WP_TkaBallCarrierPink);
176 WaypointSprite_Ping(toucher.waypointsprite_attachedforcarrier);
178}
void navigation_dynamicgoal_unset(entity this)
Definition navigation.qc:96
float wait
Definition items.qc:17
#define colormapPaletteColor(c, isPants)
Definition color.qh:5
const float SOLID_NOT
float trace_dphitq3surfaceflags
float Q3SURFACEFLAG_NOIMPACT
solid
Definition ent_cs.qc:165
const int MOVETYPE_NONE
Definition movetypes.qh:129
float scale
Definition projectile.qc:14
entity entity toucher
Definition self.qh:72
#define IS_INDEPENDENT_PLAYER(e)
Definition client.qh:312
const float ATTEN_NORM
Definition sound.qh:30
const int DAMAGE_NO
Definition subs.qh:79
float takedamage
Definition subs.qh:78
entity previous_owner
int autocvar_g_tka_ballcarrier_maxballs
Definition sv_tka.qc:9
bool tka_ballcarrier_waypointsprite_visible_for_player(entity this, entity player, entity view)
Definition sv_tka.qc:28
void tka_BallThink_Carried(entity this)
runs (only) while a player is carrying the ball
Definition sv_tka.qc:87
void WaypointSprite_UpdateSprites(entity e, entity _m1, entity _m2, entity _m3)
entity WaypointSprite_AttachCarrier(entity spr, entity carrier, entity icon)
const int SPRITERULE_TEAMPLAY

References ATTEN_NONE, ATTEN_NORM, autocvar_g_tka_ballcarrier_maxballs, ballcarried, CH_TRIGGER, cnt, colormapPaletteColor, DAMAGE_NO, entity(), game_stopped, GameRules_scoring_add, GameRules_scoring_vip, IS_DEAD, IS_INDEPENDENT_PLAYER, IS_PLAYER, MOVETYPE_NONE, navigation_dynamicgoal_unset(), nextthink, NULL, NUM_TEAM_1, NUM_TEAM_2, NUM_TEAM_3, NUM_TEAM_4, origin, owner, previous_owner, Q3SURFACEFLAG_NOIMPACT, scale, Send_Effect(), Send_Notification(), set_movetype(), setthink, solid, SOLID_NOT, sound, SPRITERULE_TEAMPLAY, takedamage, time, tka_ballcarrier_waypointsprite_visible_for_player(), tka_BallThink_Carried(), tka_EventLog(), tka_RespawnBall(), toucher, trace_dphitq3surfaceflags, velocity, VOL_BASE, wait, WaypointSprite_AttachCarrier(), waypointsprite_attachedforcarrier, WaypointSprite_Kill(), WaypointSprite_Ping(), WaypointSprite_UpdateRule(), and WaypointSprite_UpdateSprites().

Referenced by tka_SpawnBalls().

◆ tka_waypointsprite_visible_for_bot()

bool tka_waypointsprite_visible_for_bot ( entity this,
entity e,
bool dropped )

Definition at line 303 of file sv_tka.qc.

304{
305 entity ball_wp = e.waypointsprite_attachedforcarrier;
306 if (!ball_wp)
307 if (dropped || !ball_wp.waypointsprite_visible_for_player(ball_wp, this, WaypointSprite_getviewentity(this)))
308 { // has no waypoint, or waypoint not visible
309 if (!checkpvs(this.origin + this.view_ofs, e)) // ball cannot be seen
310 return false;
311 }
312 return true;
313}
float checkpvs(vector viewpos, entity viewee)
vector view_ofs
Definition progsdefs.qc:151
entity WaypointSprite_getviewentity(entity e)

References checkpvs(), entity(), origin, view_ofs, and WaypointSprite_getviewentity().

Variable Documentation

◆ autocvar_g_tka_ballcarrier_damage

vector autocvar_g_tka_ballcarrier_damage

Definition at line 11 of file sv_tka.qc.

Referenced by if().

◆ autocvar_g_tka_ballcarrier_force

vector autocvar_g_tka_ballcarrier_force

Definition at line 12 of file sv_tka.qc.

Referenced by if().

◆ autocvar_g_tka_ballcarrier_highspeed

float autocvar_g_tka_ballcarrier_highspeed

Definition at line 10 of file sv_tka.qc.

◆ autocvar_g_tka_ballcarrier_maxballs

int autocvar_g_tka_ballcarrier_maxballs

Definition at line 9 of file sv_tka.qc.

Referenced by tka_TouchEvent().

◆ autocvar_g_tka_noncarrier_damage

vector autocvar_g_tka_noncarrier_damage

Definition at line 13 of file sv_tka.qc.

◆ autocvar_g_tka_noncarrier_force

vector autocvar_g_tka_noncarrier_force

Definition at line 14 of file sv_tka.qc.

◆ autocvar_g_tka_noncarrier_warn

bool autocvar_g_tka_noncarrier_warn

Definition at line 15 of file sv_tka.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_tka_score_bckill

int autocvar_g_tka_score_bckill

Definition at line 17 of file sv_tka.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_tka_score_killac

int autocvar_g_tka_score_killac

Definition at line 18 of file sv_tka.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_tka_score_team

bool autocvar_g_tka_score_team

Definition at line 19 of file sv_tka.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_tka_score_timepoints

int autocvar_g_tka_score_timepoints

Definition at line 20 of file sv_tka.qc.

Referenced by MUTATOR_HOOKFUNCTION(), and tka_BallThink_Carried().

◆ autocvar_g_tkaball_count

int autocvar_g_tkaball_count

Definition at line 21 of file sv_tka.qc.

Referenced by tka_SpawnBalls().

◆ autocvar_g_tkaball_damageforcescale

float autocvar_g_tkaball_damageforcescale

Definition at line 22 of file sv_tka.qc.

Referenced by tka_SpawnBalls().

◆ autocvar_g_tkaball_effects

int autocvar_g_tkaball_effects

Definition at line 23 of file sv_tka.qc.

Referenced by tka_RespawnBall().

◆ autocvar_g_tkaball_respawntime

float autocvar_g_tkaball_respawntime

Definition at line 24 of file sv_tka.qc.

Referenced by tka_DropEvent(), and tka_RespawnBall().

◆ autocvar_g_tkaball_tracking

int autocvar_g_tkaball_tracking

◆ autocvar_g_tkaball_trail_color

int autocvar_g_tkaball_trail_color

Definition at line 25 of file sv_tka.qc.

Referenced by tka_SpawnBalls().

◆ ballcarried

entity ballcarried

Definition at line 6 of file sv_tka.qc.

◆ float2int_decimal_fld

float float2int_decimal_fld

Definition at line 76 of file sv_tka.qc.

◆ frag_target

entity frag_target = M_ARGV(2, entity)

Definition at line 487 of file sv_tka.qc.

◆ previous_owner

entity previous_owner

Definition at line 7 of file sv_tka.qc.

◆ pushable

bool pushable

Definition at line 234 of file sv_tka.qc.