Xonotic
common.qh File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PROJECTILE_MAKETRIGGER(e)   (e).solid = SOLID_CORPSE; (e).dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE
 
#define PROJECTILE_TOUCH(e, t)   MACRO_BEGIN if (WarpZone_Projectile_Touch(e,t)) return; MACRO_END
 

Functions

void adaptor_think2use_hittype_splash (entity this)
 
 STATIC_INIT (g_projectiles)
 
float W_CheckProjectileDamage (entity inflictor, entity projowner, int deathtype, float exception)
 
bool W_DualWielding (entity player)
 
void W_GiveWeapon (entity e, float wep)
 
void W_PlayStrengthSound (entity player)
 
void W_PrepareExplosionByDamage (entity this, entity attacker, void(entity this) explode)
 
bool WarpZone_Projectile_Touch_ImpactFilter_Callback (entity this, entity toucher)
 

Variables

int autocvar_g_projectiles_damage
 
bool autocvar_g_projectiles_keep_owner
 
float autocvar_sv_strengthsound_antispam_refire_threshold
 
float autocvar_sv_strengthsound_antispam_time
 
float fade_rate
 
float fade_time
 
IntrusiveList g_projectiles
 
const int MIF_ARC = BIT(2)
 
const int MIF_GUIDED_AI = BIT(7)
 
const int MIF_GUIDED_ALL = MIF_GUIDED_MANUAL | MIF_GUIDED_HEAT | MIF_GUIDED_LASER | MIF_GUIDED_AI | MIF_GUIDED_TAG
 
const int MIF_GUIDED_CONFUSABLE = MIF_GUIDED_HEAT | MIF_GUIDED_AI
 
const int MIF_GUIDED_HEAT = BIT(5)
 
const int MIF_GUIDED_LASER = BIT(6)
 
const int MIF_GUIDED_MANUAL = BIT(4)
 
const int MIF_GUIDED_TAG = BIT(7)
 
const int MIF_GUIDED_TRACKING = MIF_GUIDED_HEAT | MIF_GUIDED_LASER | MIF_GUIDED_AI | MIF_GUIDED_TAG
 
const int MIF_PROXY = BIT(3)
 
const int MIF_SPLASH = BIT(1)
 
float misc_bulletcounter
 
int missile_flags
 
int projectiledeathtype
 
entity realowner
 

Macro Definition Documentation

◆ PROJECTILE_MAKETRIGGER

#define PROJECTILE_MAKETRIGGER (   e)    (e).solid = SOLID_CORPSE; (e).dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE

◆ PROJECTILE_TOUCH

#define PROJECTILE_TOUCH (   e,
 
)    MACRO_BEGIN if (WarpZone_Projectile_Touch(e,t)) return; MACRO_END

Definition at line 27 of file common.qh.

Referenced by GrapplingHookTouch(), vehicles_projectile_explode(), and W_Nexball_Touch().

Function Documentation

◆ adaptor_think2use_hittype_splash()

void adaptor_think2use_hittype_splash ( entity  this)

Definition at line 110 of file common.qc.

References HITTYPE_SPLASH, IS_ONGROUND, and projectiledeathtype.

111 {
112  if(!(IS_ONGROUND(this))) // if onground, we ARE touching something, but HITTYPE_SPLASH is to be networked if the damage causing projectile is not touching ANYTHING
114  adaptor_think2use(this);
115 }
const int HITTYPE_SPLASH
automatically set by RadiusDamage
Definition: all.qh:27
#define IS_ONGROUND(s)
Definition: movetypes.qh:16
int projectiledeathtype
Definition: common.qh:20

◆ STATIC_INIT()

STATIC_INIT ( g_projectiles  )

Definition at line 47 of file common.qh.

References IL_NEW.

47 { g_projectiles = IL_NEW(); }
#define IL_NEW()
IntrusiveList g_projectiles
Definition: common.qh:46

◆ W_CheckProjectileDamage()

float W_CheckProjectileDamage ( entity  inflictor,
entity  projowner,
int  deathtype,
float  exception 
)

Definition at line 49 of file common.qc.

References autocvar_g_projectiles_damage.

Referenced by GrapplingHook_Damage().

50 {
51  float is_from_contents = (deathtype == DEATH_SLIME.m_id || deathtype == DEATH_LAVA.m_id);
52  float is_from_owner = (inflictor == projowner);
53  float is_from_exception = (exception != -1);
54 
55  //dprint(strcat("W_CheckProjectileDamage: from_contents ", ftos(is_from_contents), " : from_owner ", ftos(is_from_owner), " : exception ", strcat(ftos(is_from_exception), " (", ftos(exception), "). \n")));
56 
58  {
59  return false; // no damage to projectiles at all, not even with the exceptions
60  }
61  else if(autocvar_g_projectiles_damage == -1)
62  {
63  if(is_from_exception)
64  return (exception); // if exception is detected, allow it to override
65  else
66  return false; // otherwise, no other damage is allowed
67  }
68  else if(autocvar_g_projectiles_damage == 0)
69  {
70  if(is_from_exception)
71  return (exception); // if exception is detected, allow it to override
72  else if(!is_from_contents)
73  return false; // otherwise, only allow damage from contents
74  }
75  else if(autocvar_g_projectiles_damage == 1)
76  {
77  if(is_from_exception)
78  return (exception); // if exception is detected, allow it to override
79  else if(!(is_from_contents || is_from_owner))
80  return false; // otherwise, only allow self damage and damage from contents
81  }
82  else if(autocvar_g_projectiles_damage == 2) // allow any damage, but override for exceptions
83  {
84  if(is_from_exception)
85  return (exception); // if exception is detected, allow it to override
86  }
87 
88  return true; // if none of these return, then allow damage anyway.
89 }
int autocvar_g_projectiles_damage
Definition: common.qh:3
+ Here is the caller graph for this function:

◆ W_DualWielding()

bool W_DualWielding ( entity  player)

Definition at line 20 of file common.qc.

References MAX_WEAPONSLOTS, and weaponentities.

Referenced by IMPULSE(), PlayerThink(), W_ResetGunAlign(), W_SetupShot_Dir_ProjectileSize_Range(), and weapon_prepareattack_do().

21 {
22  int held_weapons = 0;
23  for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
24  {
25  .entity weaponentity = weaponentities[slot];
26  if(player.(weaponentity) && player.(weaponentity).m_switchweapon != WEP_Null)
27  ++held_weapons;
28  }
29 
30  return held_weapons > 1;
31 }
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13
entity weaponentities[MAX_WEAPONSLOTS]
Definition: weapon.qh:14
+ Here is the caller graph for this function:

◆ W_GiveWeapon()

void W_GiveWeapon ( entity  e,
float  wep 
)

◆ W_PlayStrengthSound()

void W_PlayStrengthSound ( entity  player)

Definition at line 44 of file common.qc.

References MUTATOR_CALLHOOK, and W_PlayStrengthSound().

Referenced by W_PlayStrengthSound(), and W_SetupShot_Dir_ProjectileSize_Range().

45 {
47 }
void W_PlayStrengthSound(entity player)
Definition: common.qc:44
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ W_PrepareExplosionByDamage()

void W_PrepareExplosionByDamage ( entity  this,
entity  attacker,
void(entity this explode 
)

Definition at line 91 of file common.qc.

References autocvar_g_projectiles_keep_owner, DAMAGE_NO, func_null(), IS_CLIENT, MUTATOR_CALLHOOK, nextthink, owner, realowner, setthink, takedamage, and time.

92 {
93  this.takedamage = DAMAGE_NO;
94  this.event_damage = func_null;
95 
96  MUTATOR_CALLHOOK(PrepareExplosionByDamage, this, attacker);
97 
99  {
100  this.owner = attacker;
101  this.realowner = attacker;
102  }
103 
104  // do not explode NOW but in the NEXT FRAME!
105  // because recursive calls to RadiusDamage are not allowed
106  this.nextthink = time;
107  setthink(this, explode);
108 }
#define IS_CLIENT(v)
Definition: utils.qh:13
bool autocvar_g_projectiles_keep_owner
Definition: common.qh:4
entity owner
Definition: main.qh:73
float takedamage
Definition: progsdefs.qc:147
float nextthink
Definition: csprogsdefs.qc:121
entity realowner
Definition: common.qh:25
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
#define setthink(e, f)
float time
Definition: csprogsdefs.qc:16
float DAMAGE_NO
Definition: progsdefs.qc:282
var void func_null()
+ Here is the call graph for this function:

◆ WarpZone_Projectile_Touch_ImpactFilter_Callback()

bool WarpZone_Projectile_Touch_ImpactFilter_Callback ( entity  this,
entity  toucher 
)

Definition at line 150 of file common.qc.

References classname, owner, RemoveHook(), SOLID_TRIGGER, SUB_NoImpactCheck(), trace_ent, and UpdateCSQCProjectile().

Referenced by WarpZone_Projectile_Touch().

151 {
152  // owner check
153  if(toucher && toucher == this.owner)
154  return true;
155  if(SUB_NoImpactCheck(this, toucher))
156  {
157  if(this.classname == "nade")
158  return false; // no checks here
159  else if(this.classname == "grapplinghook")
160  RemoveHook(this);
161  else
162  delete(this);
163  return true;
164  }
165  if(trace_ent && trace_ent.solid > SOLID_TRIGGER)
166  UpdateCSQCProjectile(this);
167  return false;
168 }
bool SUB_NoImpactCheck(entity this, entity toucher)
Definition: common.qc:117
string classname
Definition: csprogsdefs.qc:107
entity owner
Definition: main.qh:73
entity trace_ent
Definition: csprogsdefs.qc:40
void UpdateCSQCProjectile(entity e)
const float SOLID_TRIGGER
Definition: csprogsdefs.qc:245
void RemoveHook(entity this)
Definition: hook.qc:96
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ autocvar_g_projectiles_damage

int autocvar_g_projectiles_damage

Definition at line 3 of file common.qh.

Referenced by W_CheckProjectileDamage().

◆ autocvar_g_projectiles_keep_owner

bool autocvar_g_projectiles_keep_owner

Definition at line 4 of file common.qh.

Referenced by W_PrepareExplosionByDamage().

◆ autocvar_sv_strengthsound_antispam_refire_threshold

float autocvar_sv_strengthsound_antispam_refire_threshold

Definition at line 5 of file common.qh.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_sv_strengthsound_antispam_time

float autocvar_sv_strengthsound_antispam_time

Definition at line 6 of file common.qh.

Referenced by MUTATOR_HOOKFUNCTION().

◆ fade_rate

float fade_rate

Definition at line 23 of file common.qh.

◆ fade_time

◆ g_projectiles

◆ MIF_ARC

const int MIF_ARC = BIT(2)

Definition at line 35 of file common.qh.

◆ MIF_GUIDED_AI

const int MIF_GUIDED_AI = BIT(7)

Definition at line 40 of file common.qh.

◆ MIF_GUIDED_ALL

Definition at line 42 of file common.qh.

◆ MIF_GUIDED_CONFUSABLE

const int MIF_GUIDED_CONFUSABLE = MIF_GUIDED_HEAT | MIF_GUIDED_AI

Definition at line 44 of file common.qh.

◆ MIF_GUIDED_HEAT

const int MIF_GUIDED_HEAT = BIT(5)

Definition at line 38 of file common.qh.

◆ MIF_GUIDED_LASER

const int MIF_GUIDED_LASER = BIT(6)

Definition at line 39 of file common.qh.

◆ MIF_GUIDED_MANUAL

const int MIF_GUIDED_MANUAL = BIT(4)

Definition at line 37 of file common.qh.

◆ MIF_GUIDED_TAG

const int MIF_GUIDED_TAG = BIT(7)

Definition at line 41 of file common.qh.

◆ MIF_GUIDED_TRACKING

Definition at line 43 of file common.qh.

◆ MIF_PROXY

const int MIF_PROXY = BIT(3)

Definition at line 36 of file common.qh.

◆ MIF_SPLASH

const int MIF_SPLASH = BIT(1)

Definition at line 34 of file common.qh.

◆ misc_bulletcounter

float misc_bulletcounter

Definition at line 18 of file common.qh.

Referenced by vehicles_spawn().

◆ missile_flags

int missile_flags

Definition at line 33 of file common.qh.

◆ projectiledeathtype

int projectiledeathtype

Definition at line 20 of file common.qh.

Referenced by adaptor_think2use_hittype_splash(), and vehicles_projectile_explode().

◆ realowner