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

Go to the source code of this file.

Macros

#define FRAGSFILTER_REMOVER   BIT(0)
#define FRAGSFILTER_RESET   BIT(3)
#define FRAGSFILTER_RUNONCE   BIT(1)
#define FRAGSFILTER_SILENT   BIT(2)
#define PRINT_BLUETEAM   BIT(1)
#define PRINT_BROADCAST   BIT(3)
#define PRINT_PRIVATE   BIT(2)
#define PRINT_REDTEAM   BIT(0)

Functions

bool DoesQ3ARemoveThisEntity (entity this)
void fragsfilter_use (entity this, entity actor, entity trigger)
void score_use (entity this, entity actor, entity trigger)
 spawnfunc (target_fragsFilter)
 spawnfunc (target_give)
 spawnfunc (target_init)
 spawnfunc (target_print)
 spawnfunc (target_score)
 spawnfunc (target_smallprint)
 SPAWNFUNC_Q3 (weapon_shotgun, ammo_shells, q3compat==Q3COMPAT_ARENA ? WEP_MACHINEGUN :WEP_SHOTGUN, q3compat==Q3COMPAT_ARENA ? 8 :1) SPAWNFUNC_Q3(weapon_machinegun
void target_give_init (entity this)
void target_init_use (entity this, entity actor, entity trigger)
void target_init_verify (entity this)
void target_print_message (entity this, entity actor)
void target_print_use (entity this, entity actor, entity trigger)

Variables

 ammo_bullets
float delay
string gametype
string not_gametype
 q3compat == Q3COMPAT_ARENA ? WEP_SHOTGUN : WEP_MACHINEGUN

Macro Definition Documentation

◆ FRAGSFILTER_REMOVER

#define FRAGSFILTER_REMOVER   BIT(0)

Definition at line 266 of file quake3.qc.

Referenced by fragsfilter_use().

◆ FRAGSFILTER_RESET

#define FRAGSFILTER_RESET   BIT(3)

Definition at line 269 of file quake3.qc.

Referenced by fragsfilter_use().

◆ FRAGSFILTER_RUNONCE

#define FRAGSFILTER_RUNONCE   BIT(1)

Definition at line 267 of file quake3.qc.

◆ FRAGSFILTER_SILENT

#define FRAGSFILTER_SILENT   BIT(2)

Definition at line 268 of file quake3.qc.

Referenced by fragsfilter_use().

◆ PRINT_BLUETEAM

#define PRINT_BLUETEAM   BIT(1)

Definition at line 300 of file quake3.qc.

Referenced by target_print_use().

◆ PRINT_BROADCAST

#define PRINT_BROADCAST   BIT(3)

Definition at line 302 of file quake3.qc.

Referenced by target_print_use().

◆ PRINT_PRIVATE

#define PRINT_PRIVATE   BIT(2)

Definition at line 301 of file quake3.qc.

Referenced by target_print_use().

◆ PRINT_REDTEAM

#define PRINT_REDTEAM   BIT(0)

Definition at line 299 of file quake3.qc.

Referenced by target_print_use().

Function Documentation

◆ DoesQ3ARemoveThisEntity()

bool DoesQ3ARemoveThisEntity ( entity this)

Definition at line 360 of file quake3.qc.

361{
362 // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
363
364 if (!this.classname)
365 return true;
366
367 // DeFRaG mappers use "notcpm" or "notvq3" to disable an entity in CPM or VQ3 physics
368 // Xonotic is usually played with a CPM-based physics so we default to CPM mode
369 if(cvar_string("g_mod_physics") == "Q3")
370 {
371 if(stof(GetField_fullspawndata(this, "notvq3", false)))
372 return true;
373 }
374 else if(stof(GetField_fullspawndata(this, "notcpm", false)))
375 return true;
376
377 // Q3 mappers use "notq3a" or "notta" to disable an entity in Q3A or Q3TA
378 // Xonotic has ~equivalent features to Team Arena
379 if(stof(GetField_fullspawndata(this, "notta", false)))
380 return true;
381
382 // FIXME: singleplayer does not use maxclients 1 as that would prevent bots,
383 // this is the case in Q3 also, it uses another method to block clients.
384 // Only accessible in VQ3, via the `spmap` command.
385 if(stof(GetField_fullspawndata(this, "notsingle", false)))
386 if(maxclients == 1 && IS_GAMETYPE(DEATHMATCH))
387 return true;
388
389 if(stof(GetField_fullspawndata(this, "notteam", false)))
390 if(teamplay)
391 return true;
392
393 if(stof(GetField_fullspawndata(this, "notfree", false)))
394 if(!teamplay)
395 return true;
396
397 if(this.gametype || this.not_gametype)
398 {
399 // Q3 checks these with strstr(): case-sensitive, no gametype can be a substring of another,
400 // any separator is allowed (conventions are: spaces, commas, or commas with spaces).
401 // QL's entities.def says they're space delineated.
402
403 // Q3 gametype entity fields: ffa tournament single team ctf oneflag obelisk harvester (game/g_spawn.c)
404 // Q3 arena file 'type' key: ffa tourney ctf oneflag overload harvester (ui/ui_gameinfo.c)
405
406 // QL gametype entity fields: ffa duel tdm ca ft rr ctf ad dom har 1f race ob
407 // QL arena file 'type' key: ffa duel tdm ca ft rr ctf ad dom har oneflag race
408
409 string gametypename_q3, gametypename_ql;
410
411 // One of these will apply if our gametype has no Q3/QL equivalent
412 if(teamplay)
413 {
414 gametypename_q3 = "team";
415 gametypename_ql = "tdm";
416 }
417 else
418 gametypename_q3 = gametypename_ql = "ffa";
419
420 if(g_ctf)
421 {
422 if (cvar("g_ctf_oneflag"))
423 {
424 gametypename_q3 = "oneflag";
425 gametypename_ql = "1f";
426 }
427 else
428 gametypename_q3 = gametypename_ql = "ctf";
429 }
430 else if(g_duel)
431 {
432 gametypename_q3 = "tournament";
433 gametypename_ql = "duel";
434 }
435 else if(IS_GAMETYPE(DEATHMATCH) && maxclients == 1)
436 gametypename_q3 = "single";
437 else if(g_ca)
438 gametypename_ql = "ql";
439 else if(IS_GAMETYPE(FREEZETAG))
440 gametypename_ql = "ft";
441 else if(IS_GAMETYPE(DOMINATION))
442 gametypename_ql = "dom";
443 else if(g_race || g_cts)
444 gametypename_ql = "race";
445
446 if(this.gametype)
447 if(strstrofs(this.gametype, gametypename_q3, 0) < 0
448 && strstrofs(this.gametype, gametypename_ql, 0) < 0)
449 return true;
450
451 // Only supported by QL
452 if(strstrofs(this.not_gametype, gametypename_ql, 0) >= 0)
453 return true;
454 }
455
456 return false;
457}
#define g_ca
Definition clanarena.qh:51
entity gametype
Definition main.qh:43
#define g_race
Definition race.qh:48
string classname
float maxclients
#define g_ctf
Definition ctf.qh:39
#define g_cts
Definition cts.qh:36
#define strstrofs
#define g_duel
Definition duel.qh:32
float stof(string val,...)
float cvar(string name)
const string cvar_string(string name)
string not_gametype
Definition quake3.qc:359
string GetField_fullspawndata(entity e, string fieldname, bool vfspath)
Retrieves the value of a map entity field from fullspawndata.
Definition main.qc:451
bool teamplay
Definition teams.qh:59

References classname, cvar(), cvar_string(), entity(), g_ca, g_ctf, g_cts, g_duel, g_race, gametype, GetField_fullspawndata(), maxclients, not_gametype, stof(), strstrofs, and teamplay.

Referenced by SV_OnEntityPreSpawnFunction().

◆ fragsfilter_use()

void fragsfilter_use ( entity this,
entity actor,
entity trigger )

Definition at line 271 of file quake3.qc.

272{
273 if(!IS_PLAYER(actor))
274 return;
275 if(actor.fragsfilter_cnt >= this.frags)
276 {
278 actor.fragsfilter_cnt = 0;
279 else if(this.spawnflags & FRAGSFILTER_REMOVER)
280 actor.fragsfilter_cnt -= this.frags;
281 SUB_UseTargets(this, actor, trigger);
282 }
283 else if(!(this.spawnflags & FRAGSFILTER_SILENT))
284 {
285 int req_frags = this.frags - actor.fragsfilter_cnt;
286 centerprint(actor, sprintf("%d more frag%s needed", req_frags, req_frags > 1 ? "s" : ""));
287 play2(actor, SND(TALK));
288 }
289}
int spawnflags
Definition ammo.qh:15
#define IS_PLAYER(s)
Definition player.qh:243
int frags
Definition ent_cs.qh:71
void SUB_UseTargets(entity this, entity actor, entity trigger)
Definition triggers.qc:344
void centerprint(string text,...)
#define FRAGSFILTER_SILENT
Definition quake3.qc:268
#define FRAGSFILTER_RESET
Definition quake3.qc:269
#define FRAGSFILTER_REMOVER
Definition quake3.qc:266
void play2(entity e, string filename)
Definition all.qc:116
#define SND(id)
Definition all.qh:35

References centerprint(), entity(), frags, FRAGSFILTER_REMOVER, FRAGSFILTER_RESET, FRAGSFILTER_SILENT, IS_PLAYER, play2(), SND, spawnflags, and SUB_UseTargets().

Referenced by spawnfunc().

◆ score_use()

void score_use ( entity this,
entity actor,
entity trigger )

Definition at line 251 of file quake3.qc.

252{
253 if(!IS_PLAYER(actor))
254 return;
255 actor.fragsfilter_cnt += this.count;
256}
float count
Definition powerups.qc:22

References count, entity(), and IS_PLAYER.

Referenced by spawnfunc().

◆ spawnfunc() [1/6]

spawnfunc ( target_fragsFilter )

Definition at line 290 of file quake3.qc.

291{
292 if(!g_cts) { delete(this); return; }
293
294 if(!this.frags)
295 this.frags = 1;
296 this.use = fragsfilter_use;
297}
#define use
void fragsfilter_use(entity this, entity actor, entity trigger)
Definition quake3.qc:271

References frags, fragsfilter_use(), g_cts, and use.

◆ spawnfunc() [2/6]

spawnfunc ( target_give )

Definition at line 246 of file quake3.qc.

247{
249}
const int INITPRIO_FINDTARGET
Definition constants.qh:96
void target_give_init(entity this)
Definition quake3.qc:211
void InitializeEntity(entity e, void(entity this) func, int order)
Definition world.qc:2209

References InitializeEntity(), INITPRIO_FINDTARGET, and target_give_init().

◆ spawnfunc() [3/6]

spawnfunc ( target_init )

Definition at line 204 of file quake3.qc.

205{
206 this.use = target_init_use;
208}
void target_init_verify(entity this)
Definition quake3.qc:121
void target_init_use(entity this, entity actor, entity trigger)
Definition quake3.qc:139

References InitializeEntity(), INITPRIO_FINDTARGET, target_init_use(), target_init_verify(), and use.

◆ spawnfunc() [4/6]

spawnfunc ( target_print )

Definition at line 347 of file quake3.qc.

348{
349 this.use = target_print_use;
350}
void target_print_use(entity this, entity actor, entity trigger)
Definition quake3.qc:310

References target_print_use(), and use.

◆ spawnfunc() [5/6]

spawnfunc ( target_score )

Definition at line 257 of file quake3.qc.

258{
259 if(!g_cts) { delete(this); return; }
260
261 if(!this.count)
262 this.count = 1;
263 this.use = score_use;
264}
void score_use(entity this, entity actor, entity trigger)
Definition quake3.qc:251

References count, g_cts, score_use(), and use.

◆ spawnfunc() [6/6]

spawnfunc ( target_smallprint )

Definition at line 353 of file quake3.qc.

354{
355 spawnfunc_target_print(this);
356}

◆ SPAWNFUNC_Q3()

SPAWNFUNC_Q3 ( weapon_shotgun ,
ammo_shells ,
q3compat = Q3COMPAT_ARENA ? WEP_MACHINEGUN : WEP_SHOTGUN,
q3compat = Q3COMPAT_ARENA ? 8 : 1 )

References ammo_shells, q3compat, and Q3COMPAT_ARENA.

◆ target_give_init()

void target_give_init ( entity this)

Definition at line 211 of file quake3.qc.

212{
213 IL_EACH(g_items, it.targetname == this.target,
214 {
215 if (it.classname == "item_buff")
216 {
217 this.netname = cons(this.netname, it.buffdef.netname);
218 this.buffs_finished += it.buffs_finished;
219 }
220 else
221 {
222 this.ammo_rockets += it.ammo_rockets;
223 this.ammo_cells += it.ammo_cells;
224 this.ammo_shells += it.ammo_shells;
225 this.ammo_nails += it.ammo_nails;
226 this.invincible_finished += it.invincible_finished;
227 this.strength_finished += it.strength_finished;
228 this.speed_finished += it.speed_finished;
229 this.invisibility_finished += it.invisibility_finished;
230 this.health += it.health;
231 this.armorvalue += it.armorvalue;
232
233 this.netname = cons(this.netname, (it.itemdef.m_weapon) ? it.itemdef.m_weapon.netname : it.itemdef.netname);
234 }
235
236 //remove(it); // removing ents in init functions causes havoc, workaround:
237 setthink(it, SUB_Remove);
238 it.nextthink = time;
239 });
240 this.spawnflags = 2;
241 this.spawnfunc_checked = true;
242 spawnfunc_target_items(this);
244}
float time
void SUB_Remove(entity this)
Remove entity.
Definition defer.qh:13
#define IL_EACH(this, cond, body)
#define setthink(e, f)
IntrusiveList g_items
Definition items.qh:125
bool spawnfunc_checked
Definition spawnfunc.qh:8

References entity(), g_items, IL_EACH, setthink, SUB_Remove(), and time.

Referenced by spawnfunc().

◆ target_init_use()

void target_init_use ( entity this,
entity actor,
entity trigger )

Definition at line 139 of file quake3.qc.

140{
141 if (!(this.spawnflags & 1))
142 {
144 actor.pauserotarmor_finished = time + autocvar_g_balance_pause_armor_rot;
145 }
146
147 if (!(this.spawnflags & 2))
148 {
149 SetResource(actor, RES_HEALTH, start_health);
150 actor.pauserothealth_finished = time + autocvar_g_balance_pause_health_rot;
151 actor.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
152 }
153
154 if (!(this.spawnflags & 4))
155 {
156 if(this.spawnflags & 32) // spawn with only melee
157 {
158 SetResource(actor, RES_SHELLS, 0);
159 SetResource(actor, RES_BULLETS, 0);
160 SetResource(actor, RES_ROCKETS, 0);
161 SetResource(actor, RES_CELLS, 0);
162 SetResource(actor, RES_FUEL, 0);
163
164 STAT(WEAPONS, actor) = WEPSET(SHOTGUN);
165 }
166 else
167 {
168 SetResource(actor, RES_SHELLS, start_ammo_shells);
169 SetResource(actor, RES_BULLETS, start_ammo_nails);
170 SetResource(actor, RES_ROCKETS, start_ammo_rockets);
171 SetResource(actor, RES_CELLS, start_ammo_cells);
172 SetResource(actor, RES_FUEL, start_ammo_fuel);
173
174 STAT(WEAPONS, actor) = start_weapons;
175 }
176 }
177
178 if (!(this.spawnflags & 8))
179 {
180 FOREACH(StatusEffects, it.instanceOfPowerupStatusEffect,
181 {
182 it.m_remove(it, actor, STATUSEFFECT_REMOVE_NORMAL);
183 });
184 entity heldbuff = buff_FirstFromFlags(actor);
185 if(heldbuff) // TODO: make a dropbuffs function to handle this
186 {
187 int buffid = heldbuff.m_id;
188 Send_Notification(NOTIF_ONE, actor, MSG_MULTI, ITEM_BUFF_DROP, buffid);
189 sound(actor, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM);
190 if(!IS_INDEPENDENT_PLAYER(actor))
191 Send_Notification(NOTIF_ALL_EXCEPT, actor, MSG_INFO, INFO_ITEM_BUFF_LOST, actor.netname, buffid);
193 }
194 }
195
196 if (!(this.spawnflags & 16))
197 {
198 // We don't have holdables.
199 }
200
201 SUB_UseTargets(this, actor, trigger);
202}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
void SetResource(entity e, Resource res_type, float amount)
Sets the current amount of resource the given entity will have.
const float ATTN_NORM
RES_ARMOR
Definition ent_cs.qc:130
#define FOREACH(list, cond, body)
Definition iter.qh:19
#define STAT(...)
Definition stats.qh:82
@ STATUSEFFECT_REMOVE_NORMAL
Effect is being removed by a function, calls regular removal mechanics.
Definition all.qh:28
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
Definition all.qc:1573
#define IS_INDEPENDENT_PLAYER(e)
Definition client.qh:312
const int CH_TRIGGER
Definition sound.qh:12
const float VOL_BASE
Definition sound.qh:36
#define sound(e, c, s, v, a)
Definition sound.qh:52
entity buff_FirstFromFlags(entity actor)
Definition sv_buffs.qc:293
void buff_RemoveAll(entity actor, int removal_type)
Definition sv_buffs.qc:284
float autocvar_g_balance_pause_armor_rot
float autocvar_g_balance_pause_health_rot
float autocvar_g_balance_pause_health_regen
#define WEPSET(id)
Definition all.qh:45
WepSet start_weapons
Definition world.qh:80
float start_ammo_shells
Definition world.qh:84
float start_ammo_fuel
Definition world.qh:88
float start_ammo_cells
Definition world.qh:87
float start_ammo_rockets
Definition world.qh:86
float start_armorvalue
Definition world.qh:97
float start_health
Definition world.qh:96
float start_ammo_nails
Definition world.qh:85

References ATTN_NORM, autocvar_g_balance_pause_armor_rot, autocvar_g_balance_pause_health_regen, autocvar_g_balance_pause_health_rot, buff_FirstFromFlags(), buff_RemoveAll(), CH_TRIGGER, entity(), FOREACH, IS_INDEPENDENT_PLAYER, RES_ARMOR, Send_Notification(), SetResource(), sound, spawnflags, start_ammo_cells, start_ammo_fuel, start_ammo_nails, start_ammo_rockets, start_ammo_shells, start_armorvalue, start_health, start_weapons, STAT, STATUSEFFECT_REMOVE_NORMAL, SUB_UseTargets(), time, VOL_BASE, and WEPSET.

Referenced by spawnfunc().

◆ target_init_verify()

void target_init_verify ( entity this)

Definition at line 121 of file quake3.qc.

122{
123 entity trigger, targ;
124 for(trigger = NULL; (trigger = find(trigger, classname, "trigger_multiple")); )
125 for(targ = NULL; (targ = find(targ, targetname, trigger.target)); )
126 if (targ.classname == "target_init" || targ.classname == "target_give" || targ.classname == "target_items")
127 {
128 trigger.wait = 0;
129 trigger.delay = 0;
130 targ.wait = 0;
131 targ.delay = 0;
132
133 //setsize(targ, trigger.mins, trigger.maxs);
134 //setorigin(targ, trigger.origin);
135 //remove(trigger);
136 }
137}
entity find(entity start,.string field, string match)
#define NULL
Definition post.qh:14
string targetname
Definition triggers.qh:56

References classname, entity(), find(), NULL, target_init_verify(), targetname, and this.

Referenced by spawnfunc(), and target_init_verify().

◆ target_print_message()

void target_print_message ( entity this,
entity actor )

Definition at line 304 of file quake3.qc.

305{
306 centerprint(actor, this.message);
307 play2(actor, SND(TALK));
308}
string message
Definition powerups.qc:19

References centerprint(), entity(), message, play2(), and SND.

Referenced by target_print_use().

◆ target_print_use()

void target_print_use ( entity this,
entity actor,
entity trigger )

Definition at line 310 of file quake3.qc.

311{
312 if(!IS_PLAYER(actor))
313 return;
314
315 if(this.message == "")
316 return;
317
318 bool priv, red, blue;
319 if(!(q3compat & Q3COMPAT_DEFI)) // Q3 spawnflags
320 {
321 priv = boolean(this.spawnflags & PRINT_PRIVATE);
322 red = boolean(this.spawnflags & PRINT_REDTEAM);
323 blue = boolean(this.spawnflags & PRINT_BLUETEAM);
324 }
325 else // Q3DF spawnflags
326 {
327 priv = !boolean(this.spawnflags & PRINT_BROADCAST);
328 red = blue = false;
329 }
330
331 if(priv)
332 {
333 target_print_message(this, actor);
334 }
335 else
336 {
337 FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && ((!red && !blue) || (red && it.team == NUM_TEAM_1) || (blue && it.team == NUM_TEAM_2)), target_print_message(this, it));
338 }
339}
#define boolean(value)
Definition bool.qh:9
#define PRINT_BLUETEAM
Definition quake3.qc:300
#define PRINT_PRIVATE
Definition quake3.qc:301
void target_print_message(entity this, entity actor)
Definition quake3.qc:304
#define PRINT_BROADCAST
Definition quake3.qc:302
q3compat
Definition quake3.qc:59
#define PRINT_REDTEAM
Definition quake3.qc:299
#define Q3COMPAT_DEFI
Definition quake3.qh:5
const int NUM_TEAM_2
Definition teams.qh:14
const int NUM_TEAM_1
Definition teams.qh:13
#define IS_REAL_CLIENT(v)
Definition utils.qh:17
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:50

References boolean, entity(), FOREACH_CLIENT, IS_PLAYER, IS_REAL_CLIENT, message, NUM_TEAM_1, NUM_TEAM_2, PRINT_BLUETEAM, PRINT_BROADCAST, PRINT_PRIVATE, PRINT_REDTEAM, q3compat, Q3COMPAT_DEFI, spawnflags, and target_print_message().

Referenced by spawnfunc().

Variable Documentation

◆ ammo_bullets

ammo_bullets

Definition at line 58 of file quake3.qc.

◆ delay

float delay

Definition at line 118 of file quake3.qc.

◆ gametype

string gametype

Definition at line 358 of file quake3.qc.

◆ not_gametype

string not_gametype

Definition at line 359 of file quake3.qc.

Referenced by DoesQ3ARemoveThisEntity().

◆ q3compat