Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
cl_nades.qc File Reference
#include "cl_nades.qh"
#include <client/draw.qh>
#include <client/hud/hud.qh>
Include dependency graph for cl_nades.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void DrawAmmoNades (vector myPos, vector mySize, bool draw_expanding, float expand_time)
 MUTATOR_HOOKFUNCTION (cl_nades, BuildGameplayTipsString)
 MUTATOR_HOOKFUNCTION (cl_nades, EditProjectile)
 MUTATOR_HOOKFUNCTION (cl_nades, Ent_Projectile)
bool Projectile_isnade (int p)
 REGISTER_MUTATOR (cl_nades, true)

Function Documentation

◆ DrawAmmoNades()

void DrawAmmoNades ( vector myPos,
vector mySize,
bool draw_expanding,
float expand_time )

Definition at line 81 of file cl_nades.qc.

82{
83 float bonusNades = STAT(NADE_BONUS);
84 float bonusProgress = STAT(NADE_BONUS_SCORE);
85 float bonusType = STAT(NADE_BONUS_TYPE);
86 Nade def = REGISTRY_GET(Nades, max(1, bonusType));
87 string nadeIcon = def.m_icon; // use the Normal Nade icon for the random nade, and draw it as rainbow
88 vector nadeColor;
89 if(bonusType)
90 nadeColor = def.m_color;
91 else
92 {
93 nadeColor.x = time % (M_PI * 2);
94 nadeColor.y = 1;
95 nadeColor.z = 1;
96 nadeColor = hsv_to_rgb(nadeColor);
97 }
98
99 vector iconPos, textPos;
100
102 {
103 iconPos = myPos + eX * 2 * mySize.y;
104 textPos = myPos;
105 }
106 else
107 {
108 iconPos = myPos;
109 textPos = myPos + eX * mySize.y;
110 }
111
112 if(bonusNades > 0 || bonusProgress > 0)
113 {
114 DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor);
115
117 drawstring_aspect(textPos, ftos(bonusNades), vec2((2/3) * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
118
119 if(draw_expanding)
120 drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, (bonusType ? '1 1 1' : nadeColor), panel_fg_alpha, DRAWFLAG_NORMAL, expand_time);
121
122 drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, (bonusType ? '1 1 1' : nadeColor), panel_fg_alpha, DRAWFLAG_NORMAL);
123 }
124}
Definition nades.qh:14
string m_icon
Definition nades.qh:18
vector m_color
Definition nades.qh:16
void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag)
Definition draw.qc:110
void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
Definition draw.qc:61
#define drawpic_aspect_skin(pos, pic, sz, color, theAlpha, drawflag)
Definition draw.qh:78
void DrawNadeProgressBar(vector myPos, vector mySize, float progress, vector color)
Definition ammo.qc:25
bool autocvar_hud_panel_ammo_text
Definition ammo.qh:15
bool autocvar_hud_panel_ammo_iconalign
Definition ammo.qh:7
ERASEABLE vector hsv_to_rgb(vector hsv)
Definition color.qh:141
const float DRAWFLAG_NORMAL
float time
float panel_fg_alpha
Definition hud.qh:169
#define STAT(...)
Definition stats.qh:82
#define M_PI
Definition mathlib.qh:108
string ftos(float f)
float max(float f,...)
#define REGISTRY_GET(id, i)
Definition registry.qh:43
vector
Definition self.qh:92
const vector eX
Definition vector.qh:44
#define vec2(...)
Definition vector.qh:90

References autocvar_hud_panel_ammo_iconalign, autocvar_hud_panel_ammo_text, DRAWFLAG_NORMAL, DrawNadeProgressBar(), drawpic_aspect_skin, drawpic_aspect_skin_expanding(), drawstring_aspect(), eX, ftos(), hsv_to_rgb(), Nade::m_color, Nade::m_icon, M_PI, max(), panel_fg_alpha, REGISTRY_GET, STAT, time, vec2, and vector.

◆ MUTATOR_HOOKFUNCTION() [1/3]

MUTATOR_HOOKFUNCTION ( cl_nades ,
BuildGameplayTipsString  )

Definition at line 67 of file cl_nades.qc.

68{
69 if (mut_is_active(MUT_NADES))
70 {
71 string key = getcommandkey(_("drop weapon / throw nade"), "dropweapon");
72 M_ARGV(0, string) = strcat(M_ARGV(0, string),
73 "\n", sprintf(_("^3nades^8 are enabled, press ^3%s^8 to use them"), key), "\n");
74 }
75}
#define getcommandkey(cmd_name, command)
Definition main.qh:137
#define M_ARGV(x, type)
Definition events.qh:17
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))

References getcommandkey, M_ARGV, and strcat().

◆ MUTATOR_HOOKFUNCTION() [2/3]

MUTATOR_HOOKFUNCTION ( cl_nades ,
EditProjectile  )

Definition at line 26 of file cl_nades.qc.

27{
28 if (!mut_is_active(MUT_NADES)) return;
29
30 entity proj = M_ARGV(0, entity);
31
32 if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
33 {
35 proj.mins = '-16 -16 -16';
36 proj.maxs = '16 16 16';
37 }
38
39 entity nade_type = Nade_FromProjectile(proj.cnt);
40 if (nade_type == NADE_TYPE_Null) return;
41
42 if(STAT(NADES_SMALL))
43 {
44 proj.mins = '-8 -8 -8';
45 proj.maxs = '8 8 8';
46 }
47 else
48 {
49 proj.mins = '-16 -16 -16';
50 proj.maxs = '16 16 16';
51 }
52 proj.colormod = nade_type.m_color;
54 settouch(proj, func_null);
55 proj.scale = 1.5;
56 proj.avelocity = randomvec() * 720;
57 proj.alphamod = nade_type.m_alpha;
58
59 if (nade_type == NADE_TYPE_TRANSLOCATE
60 || nade_type == NADE_TYPE_SPAWN
61 || nade_type == NADE_TYPE_MONSTER)
63 else
64 proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
65}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float DPCONTENTS_BOTCLIP
float DPCONTENTS_SOLID
float DPCONTENTS_BODY
float DPCONTENTS_PLAYERCLIP
vector randomvec(void)
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_BOUNCE
Definition movetypes.qh:139
Nade Nade_FromProjectile(int proj)
Definition nades.qh:60
const int PROJECTILE_NAPALM_FOUNTAIN
Definition napalm.qh:26
var void func_null()
void loopsound(entity e, int ch, Sound samp, float vol, float attn)
#define settouch(e, f)
Definition self.qh:73
const float VOL_BASE
Definition sound.qh:36
const int CH_SHOTS_SINGLE
Definition sound.qh:15
const float ATTEN_NORM
Definition sound.qh:30
#define SND_NADE_NAPALM_FLY
Definition all.inc:187

References ATTEN_NORM, CH_SHOTS_SINGLE, DPCONTENTS_BODY, DPCONTENTS_BOTCLIP, DPCONTENTS_PLAYERCLIP, DPCONTENTS_SOLID, entity(), func_null(), loopsound(), M_ARGV, MOVETYPE_BOUNCE, Nade_FromProjectile(), PROJECTILE_NAPALM_FOUNTAIN, randomvec(), set_movetype(), settouch, SND_NADE_NAPALM_FLY, STAT, and VOL_BASE.

◆ MUTATOR_HOOKFUNCTION() [3/3]

MUTATOR_HOOKFUNCTION ( cl_nades ,
Ent_Projectile  )

Definition at line 8 of file cl_nades.qc.

9{
10 entity proj = M_ARGV(0, entity);
11
12 if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
13 {
14 proj.modelindex = 0;
15 proj.traileffect = EFFECT_FIREBALL.m_id;
16 return true;
17 }
18 if (Nade_FromProjectile(proj.cnt) != NADE_TYPE_Null)
19 {
20 setmodel(proj, MDL_PROJECTILE_NADE);
21 entity trail = Nade_TrailEffect(proj.cnt, proj.team);
22 if (trail.eent_eff_name) proj.traileffect = trail.m_id;
23 return true;
24 }
25}
#define setmodel(this, m)
Definition model.qh:26
entity Nade_TrailEffect(int proj, int nade_team)
Definition nades.qc:17

References entity(), M_ARGV, Nade_FromProjectile(), Nade_TrailEffect(), PROJECTILE_NAPALM_FOUNTAIN, and setmodel.

◆ Projectile_isnade()

bool Projectile_isnade ( int p)

Definition at line 77 of file cl_nades.qc.

78{
79 return Nade_FromProjectile(p) != NADE_TYPE_Null;
80}

References Nade_FromProjectile().

Referenced by Projectile_Draw().

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( cl_nades ,
true  )