Xonotic
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.

Functions

bool DoesQ3ARemoveThisEntity (entity this)
 
void fragsfilter_use (entity this, entity actor, entity trigger)
 
int GetAmmoConsumptionQ3 (string netname)
 
void score_use (entity this, entity actor, entity trigger)
 
 spawnfunc (target_init)
 
 spawnfunc (target_give)
 
 spawnfunc (target_score)
 
 spawnfunc (target_fragsFilter)
 
 SPAWNFUNC_ITEM (item_armor_green, ITEM_ArmorMedium) .float wait
 
void target_give_init (entity this)
 
void target_init_use (entity this, entity actor, entity trigger)
 
void target_init_verify (entity this)
 

Variables

float delay
 
string gametype
 
bool notcpm
 
bool notfree
 
bool notsingle
 
bool notta
 
bool notteam
 
bool notvq3
 

Function Documentation

◆ DoesQ3ARemoveThisEntity()

bool DoesQ3ARemoveThisEntity ( entity  this)

Definition at line 282 of file quake3.qc.

References ctf_oneflag, cvar_string(), g_ctf, g_duel, gametype, maxclients, notcpm, notfree, notsingle, notta, notteam, notvq3, strstrofs, and teamplay.

Referenced by SV_OnEntityPreSpawnFunction().

283 {
284  // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
285 
286  // DeFRaG mappers use "notcpm" or "notvq3" to disable an entity in CPM or VQ3 physics
287  // Xonotic is usually played with a CPM-based physics so we default to CPM mode
288  if(cvar_string("g_mod_physics") == "Q3")
289  {
290  if(this.notvq3)
291  return true;
292  }
293  else if(this.notcpm)
294  return true;
295 
296  // Q3 mappers use "notq3a" or "notta" to disable an entity in Q3A or Q3TA
297  // Xonotic has ~equivalent features to Team Arena
298  if(this.notta)
299  return true;
300 
301  // FIXME: singleplayer does not use maxclients 1 as that would prevent bots
302  if(this.notsingle)
303  if(maxclients == 1)
304  return true;
305 
306  if(this.notteam)
307  if(teamplay)
308  return true;
309 
310  if(this.notfree)
311  if(!teamplay)
312  return true;
313 
314  if(this.gametype)
315  {
316  string gametypename;
317  // From ioq3 g_spawn.c: static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester"};
318  gametypename = "ffa";
319  if(teamplay)
320  gametypename = "team";
321  if(g_ctf)
322  gametypename = "ctf";
323  if(g_ctf && ctf_oneflag)
324  gametypename = "oneflag";
325  if(g_duel)
326  gametypename = "tournament";
327  if(maxclients == 1)
328  gametypename = "single";
329  // we do not have the other types (obelisk, harvester)
330  if(strstrofs(this.gametype, gametypename, 0) < 0)
331  return true;
332  }
333 
334  return false;
335 }
bool notteam
Definition: quake3.qc:275
#define g_ctf
Definition: ctf.qh:39
bool notvq3
Definition: quake3.qc:279
float maxclients
Definition: csprogsdefs.qc:21
string gametype
Definition: quake3.qc:281
bool notsingle
Definition: quake3.qc:276
bool notta
Definition: quake3.qc:278
#define strstrofs
Definition: dpextensions.qh:42
float teamplay
Definition: progsdefs.qc:31
bool notfree
Definition: quake3.qc:277
bool ctf_oneflag
Definition: sv_ctf.qh:160
#define g_duel
Definition: duel.qh:28
bool notcpm
Definition: quake3.qc:280
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fragsfilter_use()

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

Definition at line 259 of file quake3.qc.

References IS_PLAYER, and SUB_UseTargets().

Referenced by spawnfunc().

260 {
261  if(!IS_PLAYER(actor))
262  return;
263  if(actor.fragsfilter_cnt >= this.frags)
264  SUB_UseTargets(this, actor, trigger);
265 }
void SUB_UseTargets(entity this, entity actor, entity trigger)
Definition: triggers.qc:366
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAmmoConsumptionQ3()

int GetAmmoConsumptionQ3 ( string  netname)

Definition at line 337 of file quake3.qc.

References cvar(), and strcat().

Referenced by weapon_defaultspawnfunc().

340 {
341  switch (netname)
342  {
343  case "arc": return autocvar_g_balance_arc_beam_ammo;
344  case "devastator": return autocvar_g_balance_devastator_ammo;
345  case "machinegun": return autocvar_g_balance_machinegun_sustained_ammo;
346  case "minelayer": return autocvar_g_balance_minelayer_ammo;
347  case "seeker": return autocvar_g_balance_seeker_tag_ammo;
348  default: return cvar(strcat("g_balance_", netname, "_primary_ammo"));
349  }
350 }
string netname
Definition: powerups.qc:20
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ score_use()

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

Definition at line 244 of file quake3.qc.

References count, and IS_PLAYER.

Referenced by spawnfunc().

245 {
246  if(!IS_PLAYER(actor))
247  return;
248  actor.fragsfilter_cnt += this.count;
249 }
float count
Definition: powerups.qc:22
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the caller graph for this function:

◆ spawnfunc() [1/4]

spawnfunc ( target_init  )

Definition at line 197 of file quake3.qc.

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

198 {
199  this.use = target_init_use;
200  InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
201 }
void target_init_verify(entity this)
Definition: quake3.qc:112
void InitializeEntity(entity e, void(entity this) func, int order)
Definition: world.qc:2146
void target_init_use(entity this, entity actor, entity trigger)
Definition: quake3.qc:130
#define use
Definition: csprogsdefs.qh:50
+ Here is the call graph for this function:

◆ spawnfunc() [2/4]

spawnfunc ( target_give  )

Definition at line 239 of file quake3.qc.

References InitializeEntity(), and target_give_init().

240 {
241  InitializeEntity(this, target_give_init, INITPRIO_FINDTARGET);
242 }
void target_give_init(entity this)
Definition: quake3.qc:204
void InitializeEntity(entity e, void(entity this) func, int order)
Definition: world.qc:2146
+ Here is the call graph for this function:

◆ spawnfunc() [3/4]

spawnfunc ( target_score  )

Definition at line 250 of file quake3.qc.

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

251 {
252  if(!g_cts) { delete(this); return; }
253 
254  if(!this.count)
255  this.count = 1;
256  this.use = score_use;
257 }
#define g_cts
Definition: cts.qh:36
float count
Definition: powerups.qc:22
void score_use(entity this, entity actor, entity trigger)
Definition: quake3.qc:244
#define use
Definition: csprogsdefs.qh:50
+ Here is the call graph for this function:

◆ spawnfunc() [4/4]

spawnfunc ( target_fragsFilter  )

Definition at line 266 of file quake3.qc.

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

267 {
268  if(!g_cts) { delete(this); return; }
269 
270  if(!this.frags)
271  this.frags = 1;
272  this.use = fragsfilter_use;
273 }
#define g_cts
Definition: cts.qh:36
frags
Definition: ent_cs.qc:151
#define use
Definition: csprogsdefs.qh:50
void fragsfilter_use(entity this, entity actor, entity trigger)
Definition: quake3.qc:259
+ Here is the call graph for this function:

◆ SPAWNFUNC_ITEM()

SPAWNFUNC_ITEM ( item_armor_green  ,
ITEM_ArmorMedium   
)

Referenced by Item_SetExpiring(), and spawnfunc().

+ Here is the caller graph for this function:

◆ target_give_init()

void target_give_init ( entity  this)

Definition at line 204 of file quake3.qc.

References g_items, IL_EACH, InitializeEntity(), setthink, spawnflags, target_init_verify(), and time.

Referenced by spawnfunc().

205 {
206  IL_EACH(g_items, it.targetname == this.target,
207  {
208  if (it.classname == "item_buff")
209  {
210  this.netname = cons(this.netname, it.buffdef.netname);
211  this.buffs_finished += it.buffs_finished;
212  }
213  else
214  {
215  this.ammo_rockets += it.ammo_rockets;
216  this.ammo_cells += it.ammo_cells;
217  this.ammo_shells += it.ammo_shells;
218  this.ammo_nails += it.ammo_nails;
219  this.invincible_finished += it.invincible_finished;
220  this.strength_finished += it.strength_finished;
221  this.speed_finished += it.speed_finished;
222  this.invisibility_finished += it.invisibility_finished;
223  this.health += it.health;
224  this.armorvalue += it.armorvalue;
225 
226  this.netname = cons(this.netname, (it.itemdef.m_weapon) ? it.itemdef.m_weapon.netname : it.itemdef.netname);
227  }
228 
229  //remove(it); // removing ents in init functions causes havoc, workaround:
230  setthink(it, SUB_Remove);
231  it.nextthink = time;
232  });
233  this.spawnflags = 2;
234  this.spawnfunc_checked = true;
235  spawnfunc_target_items(this);
236  InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
237 }
void target_init_verify(entity this)
Definition: quake3.qc:112
#define IL_EACH(this, cond, body)
float spawnflags
Definition: progsdefs.qc:191
IntrusiveList g_items
Definition: items.qh:126
void InitializeEntity(entity e, void(entity this) func, int order)
Definition: world.qc:2146
#define setthink(e, f)
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ target_init_use()

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

Definition at line 130 of file quake3.qc.

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_HEALTH, SetResource(), sound, spawnflags, start_ammo_cells, start_ammo_fuel, start_ammo_nails, start_ammo_plasma, start_ammo_rockets, start_ammo_shells, start_armorvalue, start_health, start_weapons, STATUSEFFECT_REMOVE_NORMAL, SUB_UseTargets(), time, VOL_BASE, and WEPSET.

Referenced by spawnfunc().

131 {
132  if (!(this.spawnflags & 1))
133  {
134  SetResource(actor, RES_ARMOR, start_armorvalue);
135  actor.pauserotarmor_finished = time + autocvar_g_balance_pause_armor_rot;
136  }
137 
138  if (!(this.spawnflags & 2))
139  {
141  actor.pauserothealth_finished = time + autocvar_g_balance_pause_health_rot;
142  actor.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
143  }
144 
145  if (!(this.spawnflags & 4))
146  {
147  if(this.spawnflags & 32) // spawn with only melee
148  {
149  SetResource(actor, RES_SHELLS, 0);
150  SetResource(actor, RES_BULLETS, 0);
151  SetResource(actor, RES_ROCKETS, 0);
152  SetResource(actor, RES_CELLS, 0);
153  SetResource(actor, RES_PLASMA, 0);
154  SetResource(actor, RES_FUEL, 0);
155 
156  STAT(WEAPONS, actor) = WEPSET(SHOTGUN);
157  }
158  else
159  {
160  SetResource(actor, RES_SHELLS, start_ammo_shells);
161  SetResource(actor, RES_BULLETS, start_ammo_nails);
162  SetResource(actor, RES_ROCKETS, start_ammo_rockets);
163  SetResource(actor, RES_CELLS, start_ammo_cells);
164  SetResource(actor, RES_PLASMA, start_ammo_plasma);
165  SetResource(actor, RES_FUEL, start_ammo_fuel);
166 
167  STAT(WEAPONS, actor) = start_weapons;
168  }
169  }
170 
171  if (!(this.spawnflags & 8))
172  {
173  FOREACH(StatusEffect, it.instanceOfPowerups,
174  {
175  it.m_remove(it, actor, STATUSEFFECT_REMOVE_NORMAL);
176  });
177  entity heldbuff = buff_FirstFromFlags(actor);
178  if(heldbuff) // TODO: make a dropbuffs function to handle this
179  {
180  int buffid = heldbuff.m_id;
181  Send_Notification(NOTIF_ONE, actor, MSG_MULTI, ITEM_BUFF_DROP, buffid);
182  sound(actor, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM);
183  if(!IS_INDEPENDENT_PLAYER(actor))
184  Send_Notification(NOTIF_ALL_EXCEPT, actor, MSG_INFO, INFO_ITEM_BUFF_LOST, actor.netname, buffid);
186  }
187  }
188 
189  if (!(this.spawnflags & 16))
190  {
191  // We don't have holdables.
192  }
193 
194  SUB_UseTargets(this, actor, trigger);
195 }
void buff_RemoveAll(entity actor, int removal_type)
Definition: sv_buffs.qc:286
#define WEPSET(id)
Definition: all.qh:37
float autocvar_g_balance_pause_armor_rot
Definition: sv_resources.qh:32
float start_ammo_rockets
Definition: world.qh:87
float autocvar_g_balance_pause_health_regen
Definition: sv_resources.qh:35
float start_ammo_fuel
Definition: world.qh:90
WepSet start_weapons
Definition: world.qh:81
#define IS_INDEPENDENT_PLAYER(e)
Definition: client.qh:314
entity() spawn
void SUB_UseTargets(entity this, entity actor, entity trigger)
Definition: triggers.qc:366
Effect is being removed by a function, calls regular removal mechanics.
Definition: all.qh:25
float start_ammo_shells
Definition: world.qh:85
entity buff_FirstFromFlags(entity actor)
Definition: sv_buffs.qc:296
float spawnflags
Definition: progsdefs.qc:191
const float ATTN_NORM
Definition: csprogsdefs.qc:226
RES_HEALTH
Definition: ent_cs.qc:126
void SetResource(entity e, Resource res_type, float amount)
Sets the current amount of resource the given entity will have.
Definition: cl_resources.qc:26
const int CH_TRIGGER
Definition: sound.qh:12
float start_ammo_cells
Definition: world.qh:88
const float VOL_BASE
Definition: sound.qh:36
float autocvar_g_balance_pause_health_rot
Definition: sv_resources.qh:36
float start_health
Definition: world.qh:98
float start_ammo_nails
Definition: world.qh:86
#define sound(e, c, s, v, a)
Definition: sound.qh:52
float time
Definition: csprogsdefs.qc:16
float start_armorvalue
Definition: world.qh:99
float start_ammo_plasma
Definition: world.qh:89
#define FOREACH(list, cond, body)
Definition: iter.qh:19
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ target_init_verify()

void target_init_verify ( entity  this)

Definition at line 112 of file quake3.qc.

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

Referenced by spawnfunc(), and target_give_init().

113 {
114  entity trigger, targ;
115  for(trigger = NULL; (trigger = find(trigger, classname, "trigger_multiple")); )
116  for(targ = NULL; (targ = find(targ, targetname, trigger.target)); )
117  if (targ.classname == "target_init" || targ.classname == "target_give" || targ.classname == "target_items")
118  {
119  trigger.wait = 0;
120  trigger.delay = 0;
121  targ.wait = 0;
122  targ.delay = 0;
123 
124  //setsize(targ, trigger.mins, trigger.maxs);
125  //setorigin(targ, trigger.origin);
126  //remove(trigger);
127  }
128 }
entity() spawn
string classname
Definition: csprogsdefs.qc:107
#define NULL
Definition: post.qh:17
string targetname
Definition: progsdefs.qc:194
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ delay

float delay

Definition at line 109 of file quake3.qc.

◆ gametype

string gametype

Definition at line 281 of file quake3.qc.

Referenced by DoesQ3ARemoveThisEntity().

◆ notcpm

bool notcpm

Definition at line 280 of file quake3.qc.

Referenced by DoesQ3ARemoveThisEntity().

◆ notfree

bool notfree

Definition at line 277 of file quake3.qc.

Referenced by DoesQ3ARemoveThisEntity().

◆ notsingle

bool notsingle

Definition at line 276 of file quake3.qc.

Referenced by DoesQ3ARemoveThisEntity().

◆ notta

bool notta

Definition at line 278 of file quake3.qc.

Referenced by DoesQ3ARemoveThisEntity().

◆ notteam

bool notteam

Definition at line 275 of file quake3.qc.

Referenced by DoesQ3ARemoveThisEntity().

◆ notvq3

bool notvq3

Definition at line 279 of file quake3.qc.

Referenced by DoesQ3ARemoveThisEntity().