Xonotic
sv_keepaway.qh File Reference
+ Include dependency graph for sv_keepaway.qh:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void ka_DamageEvent (entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
 
void ka_DropEvent (entity plyr)
 
void ka_Initialize ()
 
void ka_TouchEvent (entity this, entity toucher)
 
 REGISTER_MUTATOR (ka, false)
 
 void (entity this) havocbot_role_ka_carrier
 

Variables

IntrusiveList g_kaballs
 
const int KA_BALL_COUNT = 1
 
entity ka_Handler
 

Function Documentation

◆ ka_DamageEvent()

void ka_DamageEvent ( entity  this,
entity  inflictor,
entity  attacker,
float  damage,
int  deathtype,
.entity  weaponentity,
vector  hitloc,
vector  force 
)

Definition at line 106 of file sv_keepaway.qc.

References ITEM_DAMAGE_NEEDKILL, and ka_RespawnBall().

Referenced by ka_DropEvent(), and ka_SpawnBall().

107 {
108  if(ITEM_DAMAGE_NEEDKILL(deathtype))
109  ka_RespawnBall(this);
110 }
#define ITEM_DAMAGE_NEEDKILL(dt)
Definition: items.qh:130
void ka_RespawnBall(entity this)
Definition: sv_keepaway.qc:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ka_DropEvent()

void ka_DropEvent ( entity  plyr)

Definition at line 187 of file sv_keepaway.qc.

References ATTEN_NONE, autocvar_g_keepawayball_respawntime, CH_TRIGGER, crandom, DAMAGE_YES, EF_NODRAW, entity(), g_damagedbycontents, IL_PUSH(), ka_DamageEvent(), ka_EventLog(), ka_PlayerReset(), ka_RespawnBall(), ka_TouchEvent(), MOVETYPE_BOUNCE, navigation_dynamicgoal_set(), NULL, set_movetype(), setorigin(), setthink, sound, SPRITERULE_DEFAULT, time, and VOL_BASE.

Referenced by MUTATOR_HOOKFUNCTION().

188 {
189  entity ball = player.ballcarried;
190 
191  if(!ball) { return; }
192 
193  // reset the ball
194  setattachment(ball, NULL, "");
196  ball.wait = time + 1;
197  settouch(ball, ka_TouchEvent);
198  setthink(ball, ka_RespawnBall);
199  ball.nextthink = time + autocvar_g_keepawayball_respawntime;
200  ball.takedamage = DAMAGE_YES;
201  ball.event_damage = ka_DamageEvent;
202  ball.damagedbycontents = true;
204  ball.effects &= ~EF_NODRAW;
205  setorigin(ball, player.origin + '0 0 10');
206  ball.velocity = '0 0 200' + '0 100 0'*crandom() + '100 0 0'*crandom();
207  ball.owner = NULL;
208  navigation_dynamicgoal_set(ball, player);
209 
210  // messages and sounds
211  ka_EventLog("dropped", player);
212  Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_KEEPAWAY_DROPPED, player.netname);
213  Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_KEEPAWAY_DROPPED, player.netname);
214  sound(NULL, CH_TRIGGER, SND_KA_DROPPED, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere)
215 
216  // waypoints
217  WaypointSprite_Spawn(WP_KaBall, 0, 0, ball, '0 0 64', NULL, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER);
218  WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
219  WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier);
220 
221  ka_PlayerReset(player);
222 }
const int SPRITERULE_DEFAULT
IntrusiveList g_damagedbycontents
Definition: damage.qh:155
entity() spawn
const float ATTEN_NONE
Definition: sound.qh:27
void ka_EventLog(string mode, entity actor)
Definition: sv_keepaway.qc:43
void navigation_dynamicgoal_set(entity this, entity dropper)
Definition: navigation.qc:86
float autocvar_g_keepawayball_respawntime
Definition: sv_keepaway.qc:29
float MOVETYPE_BOUNCE
Definition: progsdefs.qc:256
const float EF_NODRAW
Definition: csprogsdefs.qc:305
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
const int CH_TRIGGER
Definition: sound.qh:12
#define NULL
Definition: post.qh:17
#define crandom()
Returns a random number between -1.0 and 1.0.
Definition: math.qh:27
const float VOL_BASE
Definition: sound.qh:36
void ka_TouchEvent(entity this, entity toucher)
Definition: sv_keepaway.qc:112
void ka_RespawnBall(entity this)
Definition: sv_keepaway.qc:49
void ka_DamageEvent(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition: sv_keepaway.qc:106
setorigin(ent, v)
#define setthink(e, f)
#define sound(e, c, s, v, a)
Definition: sound.qh:52
void ka_PlayerReset(entity player)
Definition: sv_keepaway.qc:176
float time
Definition: csprogsdefs.qc:16
void set_movetype(entity this, int mt)
float DAMAGE_YES
Definition: progsdefs.qc:283
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ka_Initialize()

void ka_Initialize ( )

Definition at line 296 of file sv_keepaway.qc.

References g_kaballs, IL_NEW, ka_Handler, ka_Handler_CheckBall(), new_pure, setthink, and time.

Referenced by REGISTER_MUTATOR().

297 {
298  g_kaballs = IL_NEW();
301  ka_Handler.nextthink = time;
302 }
entity ka_Handler
Definition: sv_keepaway.qh:26
#define IL_NEW()
void ka_Handler_CheckBall(entity this)
Definition: sv_keepaway.qc:280
#define new_pure(class)
purely logical entities (.origin doesn't work)
Definition: oo.qh:62
#define setthink(e, f)
float time
Definition: csprogsdefs.qc:16
IntrusiveList g_kaballs
Definition: sv_keepaway.qh:7
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ka_TouchEvent()

void ka_TouchEvent ( entity  this,
entity  toucher 
)

Definition at line 112 of file sv_keepaway.qc.

References ATTEN_NONE, ATTEN_NORM, autocvar_g_keepaway_ballcarrier_effects, autocvar_g_keepawayball_trail_color, CH_TRIGGER, DAMAGE_NO, damagedbycontents, EF_NODRAW, effects, func_null(), g_damagedbycontents, GameRules_scoring_add, GameRules_scoring_vip(), IL_REMOVE(), IS_DEAD, IS_PLAYER, ka_ballcarrier_waypointsprite_visible_for_player(), ka_EventLog(), ka_RespawnBall(), ka_TimeScoring(), MOVETYPE_NONE, navigation_dynamicgoal_unset(), nextthink, NULL, origin, owner, Q3SURFACEFLAG_NOIMPACT, set_movetype(), setorigin(), setthink, sound, SPRITERULE_DEFAULT, takedamage, time, trace_dphitq3surfaceflags, velocity, VOL_BASE, and wait.

Referenced by ka_DropEvent(), ka_RespawnBall(), and ka_SpawnBall().

113 {
114  if (!this || game_stopped)
115  return;
116 
118  { // The ball fell off the map, respawn it since players can't get to it
119  ka_RespawnBall(this);
120  return;
121  }
122  if(toucher.ballcarried) { return; }
123  if(IS_DEAD(toucher)) { return; }
124  if(STAT(FROZEN, toucher)) { return; }
125  if (!IS_PLAYER(toucher))
126  { // The ball just touched an object, most likely the world
127  Send_Effect(EFFECT_BALL_SPARKS, this.origin, '0 0 0', 1);
128  sound(this, CH_TRIGGER, SND_KA_TOUCH, VOL_BASE, ATTEN_NORM);
129  return;
130  }
131  else if(this.wait > time) { return; }
132 
133  // attach the ball to the player
134  this.owner = toucher;
135  toucher.ballcarried = this;
136  GameRules_scoring_vip(toucher, true);
137  setattachment(this, toucher, "");
138  setorigin(this, '0 0 0');
139 
140  // make the ball invisible/unable to do anything/set up time scoring
141  this.velocity = '0 0 0';
143  this.effects |= EF_NODRAW;
144  settouch(this, func_null);
145  setthink(this, ka_TimeScoring);
146  this.nextthink = time + 1;
147  this.takedamage = DAMAGE_NO;
148  this.event_damage = func_null;
149  this.damagedbycontents = false;
152 
153  // apply effects to player
154  toucher.glow_color = autocvar_g_keepawayball_trail_color;
155  toucher.glow_trail = true;
156  toucher.effects |= autocvar_g_keepaway_ballcarrier_effects;
157 
158  // messages and sounds
159  ka_EventLog("pickup", toucher);
160  Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_KEEPAWAY_PICKUP, toucher.netname);
161  Send_Notification(NOTIF_ALL_EXCEPT, toucher, MSG_CENTER, CENTER_KEEPAWAY_PICKUP, toucher.netname);
162  Send_Notification(NOTIF_ONE, toucher, MSG_CENTER, CENTER_KEEPAWAY_PICKUP_SELF);
163  sound(this.owner, CH_TRIGGER, SND_KA_PICKEDUP, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere)
164 
165  // scoring
166  GameRules_scoring_add(toucher, KEEPAWAY_PICKUPS, 1);
167 
168  // waypoints
169  WaypointSprite_AttachCarrier(WP_KaBallCarrier, toucher, RADARICON_FLAGCARRIER);
170  toucher.waypointsprite_attachedforcarrier.waypointsprite_visible_for_player = ka_ballcarrier_waypointsprite_visible_for_player;
171  WaypointSprite_UpdateRule(toucher.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
172  WaypointSprite_Ping(toucher.waypointsprite_attachedforcarrier);
173  WaypointSprite_Kill(this.waypointsprite_attachedforcarrier);
174 }
ERASEABLE void IL_REMOVE(IntrusiveList this, entity it)
Remove any element, anywhere in the list.
float MOVETYPE_NONE
Definition: progsdefs.qc:246
float trace_dphitq3surfaceflags
const int SPRITERULE_DEFAULT
void GameRules_scoring_vip(entity player, bool value)
Mark a player as being 'important' (flag carrier, ball carrier, etc)
Definition: sv_rules.qc:98
IntrusiveList g_damagedbycontents
Definition: damage.qh:155
const float ATTEN_NONE
Definition: sound.qh:27
#define GameRules_scoring_add(client, fld, value)
Definition: sv_rules.qh:78
void ka_EventLog(string mode, entity actor)
Definition: sv_keepaway.qc:43
origin
Definition: ent_cs.qc:114
float effects
Definition: csprogsdefs.qc:111
entity owner
Definition: main.qh:73
const float EF_NODRAW
Definition: csprogsdefs.qc:305
float damagedbycontents
Definition: damage.qh:48
const int CH_TRIGGER
Definition: sound.qh:12
float wait
Definition: subs.qh:39
#define NULL
Definition: post.qh:17
const float VOL_BASE
Definition: sound.qh:36
float takedamage
Definition: progsdefs.qc:147
float Q3SURFACEFLAG_NOIMPACT
#define IS_DEAD(s)
Definition: utils.qh:26
const float ATTEN_NORM
Definition: sound.qh:30
float nextthink
Definition: csprogsdefs.qc:121
void ka_TimeScoring(entity this)
Definition: sv_keepaway.qc:90
void navigation_dynamicgoal_unset(entity this)
Definition: navigation.qc:95
void ka_RespawnBall(entity this)
Definition: sv_keepaway.qc:49
int autocvar_g_keepawayball_trail_color
Definition: sv_keepaway.qc:30
setorigin(ent, v)
int autocvar_g_keepaway_ballcarrier_effects
Definition: sv_keepaway.qc:12
#define setthink(e, f)
#define sound(e, c, s, v, a)
Definition: sound.qh:52
float time
Definition: csprogsdefs.qc:16
vector velocity
Definition: csprogsdefs.qc:103
bool ka_ballcarrier_waypointsprite_visible_for_player(entity this, entity player, entity view)
Definition: sv_keepaway.qc:32
float DAMAGE_NO
Definition: progsdefs.qc:282
void set_movetype(entity this, int mt)
#define IS_PLAYER(v)
Definition: utils.qh:9
var void func_null()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( ka  ,
false   
)

Definition at line 8 of file sv_keepaway.qh.

References GameRules_scoring, ka_Initialize(), MUTATOR_ONADD, MUTATOR_STATIC, SFL_SORT_PRIO_PRIMARY, and SFL_SORT_PRIO_SECONDARY.

9 {
12  {
14  field(SP_KEEPAWAY_PICKUPS, "pickups", 0);
15  field(SP_KEEPAWAY_CARRIERKILLS, "bckills", 0);
16  field(SP_KEEPAWAY_BCTIME, "bctime", SFL_SORT_PRIO_SECONDARY);
17  });
18 
19  ka_Initialize();
20  }
21  return false;
22 }
#define GameRules_scoring(teams, spprio, stprio, fields)
Definition: sv_rules.qh:53
void ka_Initialize()
Definition: sv_keepaway.qc:296
#define MUTATOR_STATIC()
Definition: base.qh:288
const int SFL_SORT_PRIO_SECONDARY
Scoring priority (NOTE: PRIMARY is used for fraglimit)
Definition: scores.qh:126
const int SFL_SORT_PRIO_PRIMARY
Definition: scores.qh:127
#define MUTATOR_ONADD
Definition: base.qh:284
+ Here is the call graph for this function:

◆ void()

void ( entity  this)

Variable Documentation

◆ g_kaballs

◆ KA_BALL_COUNT

const int KA_BALL_COUNT = 1

Definition at line 24 of file sv_keepaway.qh.

Referenced by ka_Handler_CheckBall().

◆ ka_Handler

entity ka_Handler

Definition at line 26 of file sv_keepaway.qh.

Referenced by ka_Initialize().