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

Go to the source code of this file.

Macros

#define EV_Nade_Damage(i, o)
 called to adjust nade damage and force on hit

Functions

 MUTATOR_HOOKABLE (Nade_Damage, EV_Nade_Damage)
void nades_Clear (entity player)
 Remove nades that are being thrown.
void nades_GiveBonus (entity player, float score)
 Give a bonus grenade to a player.
void nades_RemovePlayer (entity player)
 Remove nades and bonus nades from a player.
entity nades_spawn_orb (entity this, float orb_lifetime, float orb_rad)
 Spawns an orb for some nade types.
bool orb_send (entity this, entity to, int sf)

Variables

bool autocvar_g_nades
bool autocvar_g_nades_bonus
bool autocvar_g_nades_bonus_client_select
int autocvar_g_nades_bonus_max
bool autocvar_g_nades_bonus_only
bool autocvar_g_nades_bonus_onstrength
int autocvar_g_nades_bonus_score_high
int autocvar_g_nades_bonus_score_low
int autocvar_g_nades_bonus_score_max
int autocvar_g_nades_bonus_score_medium
int autocvar_g_nades_bonus_score_minor
int autocvar_g_nades_bonus_score_spree
int autocvar_g_nades_bonus_score_time
int autocvar_g_nades_bonus_score_time_flagcarrier
string autocvar_g_nades_bonus_type
bool autocvar_g_nades_client_select
float autocvar_g_nades_nade_damage
float autocvar_g_nades_nade_edgedamage
float autocvar_g_nades_nade_force
float autocvar_g_nades_nade_health
float autocvar_g_nades_nade_lifetime
float autocvar_g_nades_nade_maxforce
float autocvar_g_nades_nade_minforce
int autocvar_g_nades_nade_newton_style
float autocvar_g_nades_nade_radius
float autocvar_g_nades_nade_refire
string autocvar_g_nades_nade_type
bool autocvar_g_nades_onspawn
bool autocvar_g_nades_override_dropweapon = true
bool autocvar_g_nades_pickup = true
float autocvar_g_nades_pickup_time = 2
int autocvar_g_nades_spawn_count
float autocvar_g_nades_spawn_destroy_damage = 25
float autocvar_g_nades_spawn_health_respawn
vector autocvar_g_nades_throw_offset
string cvar_cl_nade_type
string cvar_cl_pokenade_type
entity fake_nade
entity nade
entity nade_damage_target
float nade_lifetime
float nade_refire
bool nade_show_particles
float nade_special_time
string pokenade_type
float toss_time

Macro Definition Documentation

◆ EV_Nade_Damage

#define EV_Nade_Damage ( i,
o )
Value:
i(entity, MUTATOR_ARGV_0_entity) \ i(entity, MUTATOR_ARGV_1_entity) \ i(vector, MUTATOR_ARGV_2_vector) \
o(vector, MUTATOR_ARGV_2_vector) \ i(float, MUTATOR_ARGV_3_float) \
o(float, MUTATOR_ARGV_3_float) \
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
vector
Definition self.qh:92

called to adjust nade damage and force on hit

Definition at line 72 of file sv_nades.qh.

72#define EV_Nade_Damage(i, o) \
73 i(entity, MUTATOR_ARGV_0_entity) \
74 i(entity, MUTATOR_ARGV_1_entity) \
75 i(vector, MUTATOR_ARGV_2_vector) \
76 /**/ o(vector, MUTATOR_ARGV_2_vector) \
77 i(float, MUTATOR_ARGV_3_float) \
78 /**/ o(float, MUTATOR_ARGV_3_float) \
79 /**/

Referenced by MUTATOR_HOOKABLE().

Function Documentation

◆ MUTATOR_HOOKABLE()

MUTATOR_HOOKABLE ( Nade_Damage ,
EV_Nade_Damage  )

References EV_Nade_Damage.

◆ nades_Clear()

void nades_Clear ( entity player)

Remove nades that are being thrown.

Definition at line 656 of file sv_nades.qc.

657{
658 if (player.nade)
659 delete(player.nade);
660 if (player.fake_nade)
661 delete(player.fake_nade);
662
663 player.nade = player.fake_nade = NULL;
664 STAT(NADE_TIMER, player) = 0;
665}
#define STAT(...)
Definition stats.qh:82
#define NULL
Definition post.qh:14

References entity(), NULL, and STAT.

Referenced by nades_RemovePlayer().

◆ nades_GiveBonus()

void nades_GiveBonus ( entity player,
float score )

Give a bonus grenade to a player.

Definition at line 445 of file sv_nades.qc.

446{
448 && IS_REAL_CLIENT(player) && IS_PLAYER(player) && STAT(NADE_BONUS, player) < autocvar_g_nades_bonus_max
449 && !IS_DEAD(player) && !STAT(FROZEN, player))
450 {
451 if (STAT(NADE_BONUS_SCORE, player) < 1)
452 STAT(NADE_BONUS_SCORE, player) += score / autocvar_g_nades_bonus_score_max;
453
454 if (STAT(NADE_BONUS_SCORE, player) >= 1)
455 {
456 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_BONUS);
457 play2(player, SND(NADE_BONUS));
458 ++STAT(NADE_BONUS, player);
459 --STAT(NADE_BONUS_SCORE, player);
460 }
461 }
462}
#define IS_DEAD(s)
Definition player.qh:244
#define IS_PLAYER(s)
Definition player.qh:242
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
Definition all.qc:1573
void play2(entity e, string filename)
Definition all.qc:116
#define SND(id)
Definition all.qh:35
bool autocvar_g_nades
Definition sv_nades.qh:5
bool autocvar_g_nades_bonus
Definition sv_nades.qh:27
int autocvar_g_nades_bonus_max
Definition sv_nades.qh:32
int autocvar_g_nades_bonus_score_max
Definition sv_nades.qh:33
#define IS_REAL_CLIENT(v)
Definition utils.qh:17

Referenced by MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ nades_RemovePlayer()

void nades_RemovePlayer ( entity player)

Remove nades and bonus nades from a player.

Definition at line 914 of file sv_nades.qc.

915{
916 nades_Clear(this);
917 nades_RemoveBonus(this);
918 delete(this.nade_spawnloc);
919 this.nade_spawnloc = NULL;
920}
void nades_RemoveBonus(entity player)
Remove all bonus nades from a player.
Definition sv_nades.qc:465
void nades_Clear(entity player)
Remove nades that are being thrown.
Definition sv_nades.qc:656
entity nade_spawnloc
Definition sv_nades.qc:11

References entity(), nade_spawnloc, nades_Clear(), nades_RemoveBonus(), and NULL.

Referenced by CA_CheckWinner(), freezetag_CheckWinner(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), Onslaught_CheckWinner(), and Surv_CheckWinner().

◆ nades_spawn_orb()

entity nades_spawn_orb ( entity this,
float orb_lifetime,
float orb_rad )

Spawns an orb for some nade types.

Definition at line 79 of file sv_nades.qc.

80{
81 // NOTE: this function merely places an orb
82 // you must add a custom touch function to the returned entity if desired
83 entity orb = new(nades_spawn_orb);
84 orb.owner = this.owner;
85 orb.realowner = this.realowner;
86 setorigin(orb, this.origin);
87
88 orb.lifetime = orb_lifetime; // required for timers
89 orb.ltime = time + orb.lifetime;
90 orb.bot_dodge = false;
91 orb.team = this.realowner.team;
92 orb.solid = SOLID_TRIGGER;
93
94 setmodel(orb, MDL_NADE_ORB);
95 orb.skin = 1;
96 orb.radius = orb_rad; // required for fading
97 vector size = '0.5 0.5 0.5' * orb.radius;
98 setsize(orb, -size, size);
99
100 STAT(NADE_BONUS_TYPE, orb) = STAT(NADE_BONUS_TYPE, this);
101 orb.colormod = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, orb)).m_color;
102
103 Net_LinkEntity(orb, true, 0, orb_send);
104
105 orb.reset = SUB_Remove;
106
108 orb.nextthink = time;
109
110 return orb;
111}
entity owner
Definition main.qh:87
#define setmodel(this, m)
Definition model.qh:26
const float SOLID_TRIGGER
float time
vector size
vector origin
void SUB_Remove(entity this)
Remove entity.
Definition defer.qh:13
void Net_LinkEntity(entity e, bool docull, float dt, bool(entity this, entity to, int sendflags) sendfunc)
Definition net.qh:167
bool orb_send(entity this, entity to, int sf)
Definition net.qc:102
#define REGISTRY_GET(id, i)
Definition registry.qh:43
#define setthink(e, f)
void nades_orb_think(entity this)
Definition sv_nades.qc:60
entity nades_spawn_orb(entity this, float orb_lifetime, float orb_rad)
Spawns an orb for some nade types.
Definition sv_nades.qc:79
entity realowner

References entity(), nades_orb_think(), nades_spawn_orb(), Net_LinkEntity(), orb_send(), origin, owner, realowner, REGISTRY_GET, setmodel, setthink, size, SOLID_TRIGGER, STAT, SUB_Remove(), time, and vector.

Referenced by nade_ammo_boom(), nade_entrap_boom(), nade_heal_boom(), nade_veil_boom(), and nades_spawn_orb().

◆ orb_send()

bool orb_send ( entity this,
entity to,
int sf )

Definition at line 102 of file net.qc.

103{
104 sf = 0;
105 float byte_lifetime = this.lifetime * 8 - 1; // range: 0.125..32 in increments of 0.125
106 if (byte_lifetime < 0 || byte_lifetime >= BIT(8) || byte_lifetime != floor(byte_lifetime))
108 float byte_radius = this.radius * 0.2 - 1; // range: 5..1280 in increments of 5
109 if (byte_radius < 0 || byte_radius >= BIT(8) || byte_radius != floor(byte_radius))
111
112 WriteHeader(MSG_ENTITY, Nade_Orb);
114 WriteRegistered(Nades, MSG_ENTITY, REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this)));
115 WriteVector(MSG_ENTITY, this.origin);
116 WriteFloat(MSG_ENTITY, this.ltime);
117 //WriteByte(MSG_ENTITY, (this.ltime - time) * 10.0 + 0.5); // round time delta to a 1/10th of a second
119 WriteFloat(MSG_ENTITY, this.lifetime);
120 else
121 WriteByte(MSG_ENTITY, rint(byte_lifetime));
123 WriteFloat(MSG_ENTITY, this.radius);
124 else
125 WriteByte(MSG_ENTITY, rint(byte_radius));
126
127 return true;
128}
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
float lifetime
Definition powerups.qc:23
float radius
Definition impulse.qh:11
const int SF_NADEORB_LIFETIME_FLOAT
Definition net.qh:5
float ltime
Definition net.qh:10
const int SF_NADEORB_RADIUS_FLOAT
Definition net.qh:6
const int MSG_ENTITY
Definition net.qh:156
#define WriteHeader(to, id)
Definition net.qh:265
#define WriteRegistered(r, to, it)
Definition net.qh:293
float rint(float f)
void WriteByte(float data, float dest, float desto)
float floor(float f)

References BIT, entity(), floor(), lifetime, ltime, MSG_ENTITY, origin, radius, REGISTRY_GET, rint(), SF_NADEORB_LIFETIME_FLOAT, SF_NADEORB_RADIUS_FLOAT, STAT, WriteByte(), WriteHeader, and WriteRegistered.

Referenced by nades_spawn_orb().

Variable Documentation

◆ autocvar_g_nades

bool autocvar_g_nades

◆ autocvar_g_nades_bonus

bool autocvar_g_nades_bonus

Definition at line 27 of file sv_nades.qh.

Referenced by MUTATOR_HOOKFUNCTION(), and nades_GiveBonus().

◆ autocvar_g_nades_bonus_client_select

bool autocvar_g_nades_bonus_client_select

Definition at line 29 of file sv_nades.qh.

Referenced by MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ autocvar_g_nades_bonus_max

int autocvar_g_nades_bonus_max

Definition at line 32 of file sv_nades.qh.

Referenced by nades_GiveBonus().

◆ autocvar_g_nades_bonus_only

bool autocvar_g_nades_bonus_only

Definition at line 31 of file sv_nades.qh.

Referenced by nade_prime().

◆ autocvar_g_nades_bonus_onstrength

bool autocvar_g_nades_bonus_onstrength

Definition at line 30 of file sv_nades.qh.

Referenced by nade_prime().

◆ autocvar_g_nades_bonus_score_high

int autocvar_g_nades_bonus_score_high

Definition at line 38 of file sv_nades.qh.

Referenced by ctf_Handle_Capture(), and kh_WinnerTeam().

◆ autocvar_g_nades_bonus_score_low

int autocvar_g_nades_bonus_score_low

Definition at line 37 of file sv_nades.qh.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_nades_bonus_score_max

int autocvar_g_nades_bonus_score_max

Definition at line 33 of file sv_nades.qh.

Referenced by MUTATOR_HOOKFUNCTION(), and nades_GiveBonus().

◆ autocvar_g_nades_bonus_score_medium

int autocvar_g_nades_bonus_score_medium

Definition at line 39 of file sv_nades.qh.

Referenced by ctf_Handle_Return(), and MUTATOR_HOOKFUNCTION().

◆ autocvar_g_nades_bonus_score_minor

int autocvar_g_nades_bonus_score_minor

Definition at line 36 of file sv_nades.qh.

Referenced by ctf_Handle_Pickup(), MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ autocvar_g_nades_bonus_score_spree

int autocvar_g_nades_bonus_score_spree

Definition at line 40 of file sv_nades.qh.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_nades_bonus_score_time

int autocvar_g_nades_bonus_score_time

Definition at line 34 of file sv_nades.qh.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_nades_bonus_score_time_flagcarrier

int autocvar_g_nades_bonus_score_time_flagcarrier

Definition at line 35 of file sv_nades.qh.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_nades_bonus_type

string autocvar_g_nades_bonus_type

Definition at line 28 of file sv_nades.qh.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_nades_client_select

bool autocvar_g_nades_client_select

Definition at line 25 of file sv_nades.qh.

Referenced by nade_prime().

◆ autocvar_g_nades_nade_damage

float autocvar_g_nades_nade_damage

Definition at line 19 of file sv_nades.qh.

Referenced by nade_normal_boom().

◆ autocvar_g_nades_nade_edgedamage

float autocvar_g_nades_nade_edgedamage

Definition at line 20 of file sv_nades.qh.

Referenced by nade_normal_boom().

◆ autocvar_g_nades_nade_force

float autocvar_g_nades_nade_force

Definition at line 22 of file sv_nades.qh.

Referenced by nade_normal_boom().

◆ autocvar_g_nades_nade_health

float autocvar_g_nades_nade_health

Definition at line 17 of file sv_nades.qh.

Referenced by toss_nade().

◆ autocvar_g_nades_nade_lifetime

float autocvar_g_nades_nade_lifetime

Definition at line 14 of file sv_nades.qh.

Referenced by nade_prime(), and nades_CheckThrow().

◆ autocvar_g_nades_nade_maxforce

float autocvar_g_nades_nade_maxforce

Definition at line 16 of file sv_nades.qh.

Referenced by nades_CheckThrow().

◆ autocvar_g_nades_nade_minforce

float autocvar_g_nades_nade_minforce

Definition at line 15 of file sv_nades.qh.

Referenced by nades_CheckThrow().

◆ autocvar_g_nades_nade_newton_style

int autocvar_g_nades_nade_newton_style

Definition at line 23 of file sv_nades.qh.

Referenced by toss_nade().

◆ autocvar_g_nades_nade_radius

float autocvar_g_nades_nade_radius

Definition at line 21 of file sv_nades.qh.

Referenced by nade_normal_boom().

◆ autocvar_g_nades_nade_refire

float autocvar_g_nades_nade_refire

Definition at line 18 of file sv_nades.qh.

Referenced by MUTATOR_HOOKFUNCTION(), nade_pickup(), nades_CheckThrow(), and toss_nade().

◆ autocvar_g_nades_nade_type

string autocvar_g_nades_nade_type

Definition at line 24 of file sv_nades.qh.

Referenced by nade_prime().

◆ autocvar_g_nades_onspawn

bool autocvar_g_nades_onspawn

Definition at line 8 of file sv_nades.qh.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_nades_override_dropweapon

bool autocvar_g_nades_override_dropweapon = true

Definition at line 6 of file sv_nades.qh.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_nades_pickup

bool autocvar_g_nades_pickup = true

Definition at line 12 of file sv_nades.qh.

Referenced by nade_touch().

◆ autocvar_g_nades_pickup_time

float autocvar_g_nades_pickup_time = 2

Definition at line 13 of file sv_nades.qh.

Referenced by nade_pickup().

◆ autocvar_g_nades_spawn_count

int autocvar_g_nades_spawn_count

Definition at line 9 of file sv_nades.qh.

Referenced by nade_spawn_boom().

◆ autocvar_g_nades_spawn_destroy_damage

float autocvar_g_nades_spawn_destroy_damage = 25

Definition at line 11 of file sv_nades.qh.

Referenced by nade_spawn_DestroyDamage().

◆ autocvar_g_nades_spawn_health_respawn

float autocvar_g_nades_spawn_health_respawn

Definition at line 10 of file sv_nades.qh.

Referenced by nade_spawn_SetSpawnHealth().

◆ autocvar_g_nades_throw_offset

vector autocvar_g_nades_throw_offset

Definition at line 7 of file sv_nades.qh.

Referenced by toss_nade().

◆ cvar_cl_nade_type

string cvar_cl_nade_type

◆ cvar_cl_pokenade_type

string cvar_cl_pokenade_type

Definition at line 51 of file sv_nades.qh.

Referenced by REPLICATE(), and REPLICATE_INIT().

◆ fake_nade

entity fake_nade

Definition at line 44 of file sv_nades.qh.

Referenced by nade_prime(), and spawn_held_nade().

◆ nade

entity nade

Definition at line 43 of file sv_nades.qh.

◆ nade_damage_target

entity nade_damage_target

Definition at line 49 of file sv_nades.qh.

◆ nade_lifetime

float nade_lifetime

Definition at line 45 of file sv_nades.qh.

Referenced by nade_damage(), nade_darkness_boom(), nade_ice_boom(), and nade_timer_think().

◆ nade_refire

float nade_refire

Definition at line 46 of file sv_nades.qh.

Referenced by nade_pickup(), and nades_CheckThrow().

◆ nade_show_particles

bool nade_show_particles

Definition at line 53 of file sv_nades.qh.

Referenced by nade_ammo_touch(), nade_heal_touch(), and nades_orb_think().

◆ nade_special_time

float nade_special_time

◆ pokenade_type

string pokenade_type

Definition at line 48 of file sv_nades.qh.

Referenced by nade_monster_boom(), and nade_prime().

◆ toss_time

float toss_time

Definition at line 52 of file sv_nades.qh.