Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
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)
#define PROJECTILE_TOUCH(e, t)

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
int autocvar_g_projectiles_interact
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)
Value:
const int FL_PROJECTILE
Definition constants.qh:85
string classname
float DPCONTENTS_SOLID
float DPCONTENTS_CORPSE
float clipgroup
const float SOLID_CORPSE
float DPCONTENTS_BODY
float dphitcontentsmask
solid
Definition ent_cs.qc:165
#define MACRO_END
Definition macro.qh:7
#define MACRO_BEGIN
Definition macro.qh:6
int autocvar_g_projectiles_interact
Definition common.qh:4

Definition at line 34 of file common.qh.

34#define PROJECTILE_MAKETRIGGER(e) \
35MACRO_BEGIN \
36 (e).solid = SOLID_CORPSE; \
37 (e).dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE; \
38 if (!autocvar_g_projectiles_interact || (autocvar_g_projectiles_interact == 1 && (e).classname != "blasterbolt")) \
39 (e).clipgroup = FL_PROJECTILE; \
40MACRO_END

Referenced by FireGrapplingHook(), M_Golem_Attack_Lightning(), M_Spider_Attack_Web(), nade_napalm_ball(), raptor_bomb_burst(), raptor_bombdrop(), toss_nade(), turret_projectile(), UnsetMovetypeFollow(), vehicles_projectile(), W_Arc_Attack_Bolt(), W_Blaster_Attack(), W_Crylink_Attack(), W_Crylink_Attack2(), W_Devastator_Attack(), W_Electro_Attack_Bolt(), W_Electro_Attack_Orb(), W_Electro_Orb_Follow_Think(), W_Electro_Orb_Stick(), W_Fireball_Attack1(), W_Fireball_Attack2(), W_Hagar_Attack(), W_Hagar_Attack2(), W_Hagar_Attack2_Load_Release(), W_HLAC_Attack(), W_HLAC_Attack2(), W_Hook_Attack2(), W_MineLayer_Attack(), W_MineLayer_Stick(), W_Mortar_Attack(), W_Mortar_Attack2(), W_Nexball_Attack2(), W_OverkillRocketPropelledChainsaw_Attack(), W_Porto_Attack(), and W_RocketMinsta_Attack().

◆ PROJECTILE_TOUCH

Function Documentation

◆ adaptor_think2use_hittype_splash()

void adaptor_think2use_hittype_splash ( entity this)

Definition at line 106 of file common.qc.

107{
108 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
110 adaptor_think2use(this);
111}
const int HITTYPE_SPLASH
Definition all.qh:30
#define IS_ONGROUND(s)
Definition movetypes.qh:16
int projectiledeathtype
Definition common.qh:21

References entity(), HITTYPE_SPLASH, IS_ONGROUND, and projectiledeathtype.

Referenced by M_Spider_Attack_Web(), W_Arc_Attack_Bolt(), W_Electro_Attack_Orb(), W_Electro_Orb_Follow_Think(), W_Electro_Orb_Stick(), W_Hagar_Attack(), W_Hagar_Attack2(), W_Hagar_Attack2_Load_Release(), W_Hook_Attack2(), W_Mortar_Attack2(), W_RocketMinsta_Attack(), and W_Seeker_Fire_Flac().

◆ STATIC_INIT()

STATIC_INIT ( g_projectiles )

Definition at line 59 of file common.qh.

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

References g_projectiles, and IL_NEW.

◆ W_CheckProjectileDamage()

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

Definition at line 45 of file common.qc.

46{
47 float is_from_contents = (deathtype == DEATH_SLIME.m_id || deathtype == DEATH_LAVA.m_id);
48 float is_from_owner = (inflictor == projowner);
49 float is_from_exception = (exception != -1);
50
51 //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")));
52
54 {
55 return false; // no damage to projectiles at all, not even with the exceptions
56 }
58 {
59 if(is_from_exception)
60 return (exception); // if exception is detected, allow it to override
61 else
62 return false; // otherwise, no other damage is allowed
63 }
65 {
66 if(is_from_exception)
67 return (exception); // if exception is detected, allow it to override
68 else if(!is_from_contents)
69 return false; // otherwise, only allow damage from contents
70 }
72 {
73 if(is_from_exception)
74 return (exception); // if exception is detected, allow it to override
75 else if(!(is_from_contents || is_from_owner))
76 return false; // otherwise, only allow self damage and damage from contents
77 }
78 else if(autocvar_g_projectiles_damage == 2) // allow any damage, but override for exceptions
79 {
80 if(is_from_exception)
81 return (exception); // if exception is detected, allow it to override
82 }
83
84 return true; // if none of these return, then allow damage anyway.
85}
int autocvar_g_projectiles_damage
Definition common.qh:3

References autocvar_g_projectiles_damage, and entity().

Referenced by GrapplingHook_Damage(), M_Golem_Attack_Lightning_Damage(), W_Arc_Bolt_Damage(), W_Devastator_Damage(), W_Electro_Orb_Damage(), W_Fireball_Damage(), W_Hagar_Damage(), W_Hook_Damage(), W_MineLayer_Damage(), W_Mortar_Grenade_Damage(), W_OverkillRocketPropelledChainsaw_Damage(), and W_Seeker_Missile_Damage().

◆ W_DualWielding()

bool W_DualWielding ( entity player)

Definition at line 20 of file common.qc.

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:16
entity weaponentities[MAX_WEAPONSLOTS]
Definition weapon.qh:17

References entity(), MAX_WEAPONSLOTS, and weaponentities.

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

◆ W_GiveWeapon()

void W_GiveWeapon ( entity e,
float wep )

References entity(), and toucher.

◆ W_PlayStrengthSound()

void W_PlayStrengthSound ( entity player)

Definition at line 40 of file common.qc.

41{
43}
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
void W_PlayStrengthSound(entity player)
Definition common.qc:40

References entity(), MUTATOR_CALLHOOK, and W_PlayStrengthSound().

Referenced by MUTATOR_HOOKABLE(), MUTATOR_HOOKFUNCTION(), W_PlayStrengthSound(), W_SetupShot_Dir_ProjectileSize_Range(), and W_Shotgun_Melee_Think().

◆ W_PrepareExplosionByDamage()

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

Definition at line 87 of file common.qc.

88{
89 this.takedamage = DAMAGE_NO;
90 this.event_damage = func_null;
91
92 MUTATOR_CALLHOOK(PrepareExplosionByDamage, this, attacker);
93
95 {
96 this.owner = attacker;
97 this.realowner = attacker;
98 }
99
100 // do not explode NOW but in the NEXT FRAME!
101 // because recursive calls to RadiusDamage are not allowed
102 this.nextthink = time;
103 setthink(this, explode);
104}
entity owner
Definition main.qh:87
#define IS_CLIENT(s)
Definition player.qh:242
float time
float nextthink
var void func_null()
#define setthink(e, f)
bool autocvar_g_projectiles_keep_owner
Definition common.qh:5
const int DAMAGE_NO
Definition subs.qh:79
float takedamage
Definition subs.qh:78
entity realowner

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

Referenced by M_Golem_Attack_Lightning_Damage(), nade_damage(), nade_translocate_DestroyDamage(), turret_projectile_damage(), W_Arc_Bolt_Damage(), W_Devastator_Damage(), W_Fireball_Damage(), W_Hagar_Damage(), W_Hook_Damage(), W_MineLayer_Damage(), W_Mortar_Grenade_Damage(), W_OverkillRocketPropelledChainsaw_Damage(), W_Seeker_Missile_Damage(), and walker_rocket_damage().

◆ WarpZone_Projectile_Touch_ImpactFilter_Callback()

bool WarpZone_Projectile_Touch_ImpactFilter_Callback ( entity this,
entity toucher )

Definition at line 151 of file common.qc.

152{
153 if(toucher && toucher == this.owner)
154 return true;
155
156 if(autocvar_g_projectiles_interact == 1 && toucher.classname == "blasterbolt")
157 {
159 // We'll bounce off it due to limitations so let it deflect us
160 // to hide the problem, see PROJECTILE_MAKETRIGGER.
161 gettouch(toucher)(toucher, this);
162 return true;
163 }
164
165 if(SUB_NoImpactCheck(this, toucher))
166 {
167 if(this.classname == "nade")
168 return false; // no checks here
169 else if(this.classname == "grapplinghook")
170 RemoveHook(this);
171 else
172 delete(this);
173 return true;
174 }
175 if(trace_ent && trace_ent.solid > SOLID_TRIGGER)
177 return false;
178}
float movetype
entity trace_ent
const float SOLID_TRIGGER
void UpdateCSQCProjectile(entity e)
const int MOVETYPE_BOUNCEMISSILE
Definition movetypes.qh:140
const int MOVETYPE_BOUNCE
Definition movetypes.qh:139
#define gettouch(e)
Definition self.qh:74
entity entity toucher
Definition self.qh:72
void RemoveHook(entity this)
Definition hook.qc:48
bool SUB_NoImpactCheck(entity this, entity toucher)
Definition common.qc:113

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_interact

int autocvar_g_projectiles_interact

Definition at line 4 of file common.qh.

Referenced by W_Blaster_Touch(), and WarpZone_Projectile_Touch_ImpactFilter_Callback().

◆ autocvar_g_projectiles_keep_owner

bool autocvar_g_projectiles_keep_owner

Definition at line 5 of file common.qh.

Referenced by W_PrepareExplosionByDamage().

◆ autocvar_sv_strengthsound_antispam_refire_threshold

float autocvar_sv_strengthsound_antispam_refire_threshold

Definition at line 6 of file common.qh.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_sv_strengthsound_antispam_time

float autocvar_sv_strengthsound_antispam_time

Definition at line 7 of file common.qh.

Referenced by MUTATOR_HOOKFUNCTION().

◆ fade_rate

float fade_rate

Definition at line 24 of file common.qh.

◆ fade_time

◆ g_projectiles

◆ MIF_ARC

◆ MIF_GUIDED_AI

const int MIF_GUIDED_AI = BIT(7)

Definition at line 52 of file common.qh.

◆ MIF_GUIDED_ALL

Definition at line 54 of file common.qh.

◆ MIF_GUIDED_CONFUSABLE

const int MIF_GUIDED_CONFUSABLE = MIF_GUIDED_HEAT | MIF_GUIDED_AI

Definition at line 56 of file common.qh.

◆ MIF_GUIDED_HEAT

const int MIF_GUIDED_HEAT = BIT(5)

Definition at line 50 of file common.qh.

Referenced by walker_fire_rocket().

◆ MIF_GUIDED_LASER

const int MIF_GUIDED_LASER = BIT(6)

Definition at line 51 of file common.qh.

◆ MIF_GUIDED_MANUAL

const int MIF_GUIDED_MANUAL = BIT(4)

Definition at line 49 of file common.qh.

◆ MIF_GUIDED_TAG

const int MIF_GUIDED_TAG = BIT(7)

Definition at line 53 of file common.qh.

Referenced by W_Seeker_Fire_Missile().

◆ MIF_GUIDED_TRACKING

Definition at line 55 of file common.qh.

◆ MIF_PROXY

const int MIF_PROXY = BIT(3)

◆ MIF_SPLASH

◆ misc_bulletcounter

◆ missile_flags

int missile_flags

Definition at line 45 of file common.qh.

◆ projectiledeathtype

◆ realowner

entity realowner

Definition at line 26 of file common.qh.