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 86 of file cl_nades.qc.

87{
88 float bonusNades = STAT(NADE_BONUS);
89 float bonusProgress = STAT(NADE_BONUS_SCORE);
90 float bonusType = STAT(NADE_BONUS_TYPE);
91 Nade def = REGISTRY_GET(Nades, max(1, bonusType));
92 string nadeIcon = def.m_icon; // use the Normal Nade icon for the random nade, and draw it as rainbow
93 vector nadeColor;
94 if (bonusType)
95 nadeColor = def.m_color;
96 else
97 {
98 nadeColor.x = time % (2 * M_PI);
99 nadeColor.y = 1;
100 nadeColor.z = 1;
101 nadeColor = hsv_to_rgb(nadeColor);
102 }
103
104 vector iconPos, textPos;
105
107 {
108 iconPos = myPos + eX * 2 * mySize.y;
109 textPos = myPos;
110 }
111 else
112 {
113 iconPos = myPos;
114 textPos = myPos + eX * mySize.y;
115 }
116
117 if (bonusNades > 0 || bonusProgress > 0)
118 {
119 DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor);
120
122 drawstring_aspect(textPos, ftos(bonusNades), vec2((2/3) * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
123
124 if (draw_expanding)
125 drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, (bonusType ? '1 1 1' : nadeColor), panel_fg_alpha, DRAWFLAG_NORMAL, expand_time);
126
127 drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, (bonusType ? '1 1 1' : nadeColor), panel_fg_alpha, DRAWFLAG_NORMAL);
128 }
129}
Definition nades.qh:14
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:109
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, 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 72 of file cl_nades.qc.

73{
74 if (mut_is_active(MUT_NADES))
75 {
76 string key = getcommandkey(_("drop weapon / throw nade"), "dropweapon");
77 M_ARGV(0, string) = strcat(M_ARGV(0, string),
78 "\n", sprintf(_("^3nades^8 are enabled, press ^3%s^8 to use them"), key), "\n");
79 }
80}
#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 27 of file cl_nades.qc.

28{
29 if (!mut_is_active(MUT_NADES))
30 return;
31
32 entity proj = M_ARGV(0, entity);
33
34 if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
35 {
37 proj.mins = '-16 -16 -16'; // k9er: setsize instead?
38 proj.maxs = '16 16 16';
39 }
40
41 entity nade_type = Nade_FromProjectile(proj.cnt);
42 if (nade_type == NADE_TYPE_Null)
43 return;
44
45 float size;
46 if (STAT(NADES_SMALL))
47 size = 16;
48 else
49 size = 32;
50 proj.mins = '0.5 0.5 0.5' * -size; // k9er: setsize instead?
51 proj.maxs = '0.5 0.5 0.5' * size;
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 switch (nade_type.m_id)
60 {
61 case NADE_TYPE_TRANSLOCATE.m_id:
62 case NADE_TYPE_SPAWN.m_id:
63 case NADE_TYPE_MONSTER.m_id:
65 break;
66 default:
67 proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
68 break;
69 }
70}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float DPCONTENTS_BOTCLIP
float DPCONTENTS_SOLID
float DPCONTENTS_BODY
float DPCONTENTS_PLAYERCLIP
vector size
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:65
const int PROJECTILE_NAPALM_FOUNTAIN
Definition napalm.qh:27
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, size, 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)
23 proj.traileffect = trail.m_id;
24 return true;
25 }
26}
#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 82 of file cl_nades.qc.

83{
84 return Nade_FromProjectile(p) != NADE_TYPE_Null;
85}

References Nade_FromProjectile().

Referenced by Projectile_Draw().

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( cl_nades ,
true  )