Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
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_Handler_CheckBall (entity this)
void ka_TouchEvent (entity this, entity toucher)
 REGISTER_MUTATOR (ka, false)
 void (entity this) havocbot_role_ka_carrier

Variables

IntrusiveList g_kaballs

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 108 of file sv_keepaway.qc.

109{
110 if(ITEM_DAMAGE_NEEDKILL(deathtype))
111 ka_RespawnBall(this);
112}
#define ITEM_DAMAGE_NEEDKILL(dt)
Definition items.qh:129
void ka_RespawnBall(entity this)

References entity(), ITEM_DAMAGE_NEEDKILL, ka_RespawnBall(), and vector.

Referenced by ka_DropEvent(), and ka_SpawnBalls().

◆ ka_DropEvent()

void ka_DropEvent ( entity plyr)

Definition at line 191 of file sv_keepaway.qc.

192{
193 entity ball = player.ballcarried;
194
195 if(!ball) { return; }
196
197 // reset the ball
198 setattachment(ball, NULL, "");
200 ball.previous_owner = player;
201 ball.wait = time + 0.5; // same as for thrown weapons
203 ball.nextthink = time + autocvar_g_keepawayball_respawntime;
204 ball.takedamage = DAMAGE_YES;
205 ball.event_damage = ka_DamageEvent;
206 ball.damagedbycontents = true;
208 ball.scale = 1; // it's smaller while carried
209 ball.alpha = 1; // in case the carrier had an invisibility effect
210 ball.solid = SOLID_TRIGGER; // before setorigin to ensure area grid linking
211 setorigin(ball, player.origin + ball.origin + '0 0 10'); // include attachment offset to reduce jump
212 nudgeoutofsolid_OrFallback(ball); // a ball has a horizontally bigger bbox than a player
213 ball.velocity = '0 0 200' + '0 100 0'*crandom() + '100 0 0'*crandom();
214 ball.owner = NULL;
215 navigation_dynamicgoal_set(ball, player);
216
217 // messages and sounds
218 ka_EventLog("dropped", player);
219 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_KEEPAWAY_DROPPED, player.netname);
220 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_KEEPAWAY_DROPPED, player.netname);
221 sound(NULL, CH_TRIGGER, SND_KA_DROPPED, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere)
222
223 // waypoints
225 {
226 WaypointSprite_Spawn(WP_KaBall, 0, 0, ball, '0 0 64', NULL, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER);
227 WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
228 WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier);
229 }
230
231 if (ball.ballcarried) // >1 ball was chained, first one was just dropped
232 {
233 player.ballcarried = ball.ballcarried; // move the next one up
234 ball.ballcarried = NULL; // prevent infinite loop
235 }
236 else // no balls remaining so remove bc status
237 ka_PlayerReset(player);
238}
void navigation_dynamicgoal_set(entity this, entity dropper)
Definition navigation.qc:87
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
bool warmup_stage
Definition main.qh:120
const float SOLID_TRIGGER
float time
IntrusiveList g_damagedbycontents
Definition damage.qh:135
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_BOUNCE
Definition movetypes.qh:139
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
Definition all.qc:1573
#define NULL
Definition post.qh:14
#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
int autocvar_g_keepawayball_tracking
void ka_DamageEvent(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
float autocvar_g_keepawayball_respawntime
void ka_PlayerReset(entity player)
void ka_EventLog(string mode, entity actor)
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_keepawayball_respawntime, autocvar_g_keepawayball_tracking, CH_TRIGGER, crandom, DAMAGE_YES, entity(), g_damagedbycontents, IL_PUSH(), ka_DamageEvent(), ka_EventLog(), ka_PlayerReset(), ka_RespawnBall(), MOVETYPE_BOUNCE, navigation_dynamicgoal_set(), NULL, Send_Notification(), set_movetype(), setthink, SOLID_TRIGGER, sound, SPRITERULE_DEFAULT, time, VOL_BASE, warmup_stage, waypointsprite_attachedforcarrier, WaypointSprite_Ping(), WaypointSprite_Spawn(), and WaypointSprite_UpdateRule().

Referenced by MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ ka_Handler_CheckBall()

void ka_Handler_CheckBall ( entity this)

Definition at line 291 of file sv_keepaway.qc.

292{
293 if(time < game_starttime)
294 {
295 if (!IL_EMPTY(g_kaballs))
297 }
298 else
299 {
300 if (IL_EMPTY(g_kaballs))
301 ka_SpawnBalls(); // ;)
302 }
303
304 this.nextthink = time;
305}
float game_starttime
Definition stats.qh:82
float nextthink
#define IL_EMPTY(this)
void ka_SpawnBalls()
void ka_RemoveBalls()
IntrusiveList g_kaballs
Definition sv_keepaway.qh:8

References entity(), g_kaballs, game_starttime, IL_EMPTY, ka_RemoveBalls(), ka_SpawnBalls(), nextthink, and time.

Referenced by REGISTER_MUTATOR().

◆ ka_TouchEvent()

void ka_TouchEvent ( entity this,
entity toucher )

Definition at line 114 of file sv_keepaway.qc.

115{
116 if (!this || game_stopped)
117 return;
118
120 { // The ball fell off the map, respawn it since players can't get to it
121 ka_RespawnBall(this);
122 return;
123 }
124 // TODO: mutator hook to prevent picking up objectives
125 if(IS_INDEPENDENT_PLAYER(toucher)) { return; }
126 if(IS_DEAD(toucher)) { return; }
127 if (!IS_PLAYER(toucher))
128 { // The ball just touched an object, most likely the world
129 Send_Effect(EFFECT_BALL_SPARKS, this.origin, '0 0 0', 1);
130 sound(this, CH_TRIGGER, SND_KA_TOUCH, VOL_BASE, ATTEN_NORM);
131 return;
132 }
133 else if(this.wait > time && this.previous_owner == toucher)
134 return;
135
136 if (toucher.ballcarried) // multiple balls exist
137 {
139 return;
140 this.ballcarried = toucher.ballcarried; // new ball will be inserted at start of chain
141 this.cnt = toucher.ballcarried.cnt + 1; // for orbit animation offset
142 }
143 else
144 this.cnt = 1;
145
146 // attach the ball to the player
147 this.owner = toucher;
148 toucher.ballcarried = this;
150 setattachment(this, toucher, "");
151 this.solid = SOLID_NOT; // before setorigin to ensure area grid unlinking
152 setorigin(this, '0 0 0');
153
154 // make the ball unable to do anything, set up time scoring
155 this.velocity = '0 0 0';
157 this.scale = 12/16; // somewhat smaller while carried
159 this.nextthink = time;
160 this.takedamage = DAMAGE_NO;
161 this.event_damage = func_null;
162 this.damagedbycontents = false;
165
166 // messages and sounds
167 ka_EventLog("pickup", toucher);
168 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_KEEPAWAY_PICKUP, toucher.netname);
169 Send_Notification(NOTIF_ALL_EXCEPT, toucher, MSG_CENTER, CENTER_KEEPAWAY_PICKUP, toucher.netname);
170 Send_Notification(NOTIF_ONE, toucher, MSG_CENTER, CENTER_KEEPAWAY_PICKUP_SELF);
171 sound(this.owner, CH_TRIGGER, SND_KA_PICKEDUP, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere)
172
173 // scoring
174 GameRules_scoring_add(toucher, KEEPAWAY_PICKUPS, 1);
175
176 // waypoints
177 WaypointSprite_AttachCarrier(WP_KaBallCarrier, toucher, RADARICON_FLAGCARRIER);
178 toucher.waypointsprite_attachedforcarrier.waypointsprite_visible_for_player = ka_ballcarrier_waypointsprite_visible_for_player;
179 WaypointSprite_UpdateRule(toucher.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
180 WaypointSprite_Ping(toucher.waypointsprite_attachedforcarrier);
182}
void navigation_dynamicgoal_unset(entity this)
Definition navigation.qc:96
float cnt
Definition powerups.qc:24
float wait
Definition items.qc:17
entity owner
Definition main.qh:87
#define IS_DEAD(s)
Definition player.qh:245
#define IS_PLAYER(s)
Definition player.qh:243
float game_stopped
Definition stats.qh:81
vector velocity
const float SOLID_NOT
float trace_dphitq3surfaceflags
vector origin
float Q3SURFACEFLAG_NOIMPACT
float damagedbycontents
Definition damage.qh:45
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:124
solid
Definition ent_cs.qc:165
ERASEABLE void IL_REMOVE(IntrusiveList this, entity it)
Remove any element, anywhere in the list.
const int MOVETYPE_NONE
Definition movetypes.qh:129
var void func_null()
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 ballcarried
int autocvar_g_keepaway_ballcarrier_maxballs
void ka_BallThink_Carried(entity this)
runs (only) while a player is carrying the ball
entity previous_owner
bool ka_ballcarrier_waypointsprite_visible_for_player(entity this, entity player, entity view)
#define GameRules_scoring_vip(player, value)
Definition sv_rules.qh:78
#define GameRules_scoring_add(client, fld, value)
Definition sv_rules.qh:85
void WaypointSprite_Kill(entity wp)
entity WaypointSprite_AttachCarrier(entity spr, entity carrier, entity icon)

References ATTEN_NONE, ATTEN_NORM, autocvar_g_keepaway_ballcarrier_maxballs, ballcarried, CH_TRIGGER, cnt, DAMAGE_NO, damagedbycontents, entity(), func_null(), g_damagedbycontents, game_stopped, GameRules_scoring_add, GameRules_scoring_vip, IL_REMOVE(), IS_DEAD, IS_INDEPENDENT_PLAYER, IS_PLAYER, ka_ballcarrier_waypointsprite_visible_for_player(), ka_BallThink_Carried(), ka_EventLog(), ka_RespawnBall(), MOVETYPE_NONE, navigation_dynamicgoal_unset(), nextthink, NULL, origin, owner, previous_owner, Q3SURFACEFLAG_NOIMPACT, scale, Send_Effect(), Send_Notification(), set_movetype(), setthink, solid, SOLID_NOT, sound, SPRITERULE_DEFAULT, takedamage, time, toucher, trace_dphitq3surfaceflags, velocity, VOL_BASE, wait, WaypointSprite_AttachCarrier(), waypointsprite_attachedforcarrier, WaypointSprite_Kill(), WaypointSprite_Ping(), and WaypointSprite_UpdateRule().

Referenced by ka_SpawnBalls().

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( ka ,
false  )

Definition at line 9 of file sv_keepaway.qh.

10{
13 {
15 {
16 field(SP_KEEPAWAY_PICKUPS, "pickups", 0);
17 field(SP_KEEPAWAY_CARRIERKILLS, "bckills", 0);
18 field(SP_KEEPAWAY_BCTIME, "bctime", SFL_SORT_PRIO_SECONDARY);
19 });
20
21 g_kaballs = IL_NEW();
22 entity ka_Handler = new_pure(ka_Handler);
23 setthink(ka_Handler, ka_Handler_CheckBall);
25 }
26 return false;
27}
#define MUTATOR_ONADD
Definition base.qh:309
#define MUTATOR_STATIC()
Definition base.qh:313
const int SFL_SORT_PRIO_SECONDARY
Scoring priority (NOTE: PRIMARY is used for fraglimit) NOTE: SFL_SORT_PRIO_SECONDARY value must be lo...
Definition scores.qh:133
const int SFL_SORT_PRIO_PRIMARY
Definition scores.qh:134
const int INITPRIO_SETLOCATION
Definition constants.qh:98
#define IL_NEW()
#define new_pure(class)
purely logical entities (not linked to the area grid)
Definition oo.qh:67
void ka_Handler_CheckBall(entity this)
#define GameRules_scoring(teams, spprio, stprio, fields)
Definition sv_rules.qh:58
void InitializeEntity(entity e, void(entity this) func, int order)
Definition world.qc:2209

References entity(), g_kaballs, GameRules_scoring, IL_NEW, InitializeEntity(), INITPRIO_SETLOCATION, ka_Handler_CheckBall(), MUTATOR_ONADD, MUTATOR_STATIC, new_pure, setthink, SFL_SORT_PRIO_PRIMARY, and SFL_SORT_PRIO_SECONDARY.

◆ void()

Variable Documentation

◆ g_kaballs