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

Go to the source code of this file.

Functions

void HUD_DarkBlinking ()
 MUTATOR_HOOKFUNCTION (cl_nades, HUD_Draw_overlay)
void nade_darkness_boom (entity this)
void nade_darkness_think (entity this)
bool nade_darkness_think_cond (entity e)

Variables

bool darkness_fadealpha
float nade_current_dark_time

Function Documentation

◆ HUD_DarkBlinking()

void HUD_DarkBlinking ( )

Definition at line 116 of file darkness.qc.

117{
118 drawfill('0 0 0', vec2(vid_conwidth, vid_conheight), NADE_TYPE_DARKNESS.m_color, darkness_fadealpha, DRAWFLAG_NORMAL);
119}
#define drawfill(position, size, rgb, alpha, flag)
Definition draw.qh:36
const float DRAWFLAG_NORMAL
bool darkness_fadealpha
Definition darkness.qc:114
noref float vid_conwidth
Definition draw.qh:7
noref float vid_conheight
Definition draw.qh:8
#define vec2(...)
Definition vector.qh:95

References darkness_fadealpha, drawfill, DRAWFLAG_NORMAL, vec2, vid_conheight, and vid_conwidth.

Referenced by MUTATOR_HOOKFUNCTION().

◆ MUTATOR_HOOKFUNCTION()

MUTATOR_HOOKFUNCTION ( cl_nades ,
HUD_Draw_overlay  )

Definition at line 121 of file darkness.qc.

122{
123 if (STAT(NADE_DARKNESS_TIME) > time)
124 {
128 }
129 else if (darkness_fadealpha > 0)
131
132 if (darkness_fadealpha > 0)
133 {
135 M_ARGV(1, float) = 0; // alpha_multipl 0, don't draw normal overlay
136 return true;
137 }
138 return false;
139}
entity csqcplayer
Definition cl_player.qh:26
#define M_ARGV(x, type)
Definition events.qh:17
float frametime
float time
void HUD_DarkBlinking()
Definition darkness.qc:116
#define STAT(...)
Definition stats.qh:94
float min(float f,...)
float max(float f,...)
const int CH_PAIN
Definition sound.qh:18
const float VOL_BASE
Definition sound.qh:36
const float ATTEN_NORM
Definition sound.qh:30
#define sound(e, c, s, v, a)
Definition sound.qh:52

References ATTEN_NORM, CH_PAIN, csqcplayer, darkness_fadealpha, frametime, HUD_DarkBlinking(), M_ARGV, max(), min(), sound, STAT, time, and VOL_BASE.

◆ nade_darkness_boom()

void nade_darkness_boom ( entity this)

Definition at line 72 of file darkness.qc.

73{
74 entity fountain = new(nade_darkness_fountain);
75 fountain.owner = this.owner;
76 fountain.realowner = this.realowner;
77 fountain.origin = this.origin;
78 fountain.flags = FL_PROJECTILE;
79 IL_PUSH(g_projectiles, fountain);
80 setorigin(fountain, fountain.origin);
82 fountain.nextthink = time;
83 fountain.pushltime = fountain.wait = fountain.ltime = time + autocvar_g_nades_darkness_time;
84 fountain.team = this.team;
85 set_movetype(fountain, MOVETYPE_TOSS);
86 fountain.projectiledeathtype = DEATH_NADE_DARKNESS.m_id;
87 fountain.bot_dodge = false;
88 setsize(fountain, '-16 -16 -16', '16 16 16');
89 fountain.nade_special_time = time + 0.3;
90 fountain.angles = this.angles;
91
93 {
94 setmodel(fountain, MDL_PROJECTILE_GRENADE);
95 entity timer = new(nade_timer);
96 setmodel(timer, MDL_NADE_TIMER);
97 setattachment(timer, fountain, "");
98 timer.colormap = this.colormap;
99 timer.glowmod = this.glowmod;
101 timer.nextthink = time;
102 timer.wait = fountain.wait;
103 timer.nade_lifetime = this.nade_lifetime;
104 timer.owner = fountain;
105 timer.skin = 10;
106 }
107 else
108 setmodel(fountain, MDL_Null);
109}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
entity owner
Definition main.qh:87
int team
Definition main.qh:188
#define setmodel(this, m)
Definition model.qh:26
const int FL_PROJECTILE
Definition constants.qh:77
float colormap
vector origin
vector glowmod
void nade_darkness_think(entity this)
Definition darkness.qc:11
bool autocvar_g_nades_darkness_explode
Definition darkness.qh:7
float autocvar_g_nades_darkness_time
Definition darkness.qh:9
ent angles
Definition ent_cs.qc:146
float timer
Definition hud.qh:125
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_TOSS
Definition movetypes.qh:139
#define setthink(e, f)
IntrusiveList g_projectiles
Definition common.qh:70
void nade_timer_think(entity this)
Definition sv_nades.qc:28
float nade_lifetime
Definition sv_nades.qh:45
entity realowner

References angles, autocvar_g_nades_darkness_explode, autocvar_g_nades_darkness_time, colormap, entity(), FL_PROJECTILE, g_projectiles, glowmod, IL_PUSH(), MOVETYPE_TOSS, nade_darkness_think(), nade_lifetime, nade_timer_think(), origin, owner, realowner, set_movetype(), setmodel, setthink, team, time, and timer.

Referenced by nade_boom().

◆ nade_darkness_think()

void nade_darkness_think ( entity this)

Definition at line 11 of file darkness.qc.

12{
14 {
15 delete(this);
16 return;
17 }
18
19 if (time >= this.ltime)
20 {
22 {
23 vector expcol_min = nades_PlayerColor(this.realowner, false);
24 vector expcol_max = nades_PlayerColor(this.realowner, true);
25 Send_Effect_Core(EFFECT_NADE_EXPLODE, this.origin + '0 0 1', '0 0 0', 1, expcol_min, expcol_max, -1, -1, -1, NULL);
26 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
27
28 nade_normal_boom(this);
29 }
30 else
31 Send_Effect_Core(EFFECT_SPAWN, this.origin + '0 0 1', '0 0 0', 1, '0.5 0 0.5', '0.5 0 0.5', -1, -1, -1, NULL);
32
33 delete(this);
34 return;
35 }
36
37 this.nextthink = time + 0.1;
38
39 // gaussian
40 float randomr = random();
41 randomr = exp(-5 * randomr * randomr) * autocvar_g_nades_darkness_radius;
42 float randomw = random() * (2 * M_PI);
43 vector randomp;
44 randomp.x = randomr * cos(randomw);
45 randomp.y = randomr * sin(randomw);
46 randomp.z = 1;
47 Send_Effect(EFFECT_DARKFIELD, this.origin + randomp, '0 0 0', 1);
48
49 if (time >= this.nade_special_time)
50 {
51 this.nade_special_time = time + 5/16; // 0.3125
52 Send_Effect(EFFECT_DARKFIELD, this.origin, '0 0 0', 1);
53 }
54
58 for (; head; head = head.chain)
59 {
61 {
62 case 0: break; // affect everyone
63 default:
64 case 2: if (SAME_TEAM(head, this.realowner)) continue; // don't affect teammates
65 // fall through (check case 1 condition too)
66 case 1: if (head == this.realowner) continue; // don't affect the player who threw the nade
67 }
68 STAT(NADE_DARKNESS_TIME, head) = this.nextthink;
69 }
70}
float ltime
Definition net.qh:10
float nextthink
float nade_current_dark_time
Definition darkness.qc:5
bool nade_darkness_think_cond(entity e)
Definition darkness.qc:6
float autocvar_g_nades_darkness_radius
Definition darkness.qh:10
bool autocvar_g_nades_darkness_teamcheck
Definition darkness.qh:8
void Send_Effect_Core(entity eff, vector eff_loc, vector eff_vel, int eff_cnt, vector eff_col_min, vector eff_col_max, float eff_alpha_min, float eff_alpha_max, float eff_alpha_fade, entity ignore)
Definition all.qc:74
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:155
entity WarpZone_SearchInRadius(vector org, float rad, float nomonsters, WarpZone_FindRadius_cond_callback_t cb)
Modified findradius aware of warpzones, that only includes entities that meet the "cb" criteria.
Definition common.qc:680
noref entity WarpZone_SearchInRadius_otherent
Free to use in the callback.
Definition common.qh:71
#define MOVE_NOTHING
Definition common.qh:35
float exp(float e)
Definition mathlib.qc:70
#define M_PI
pi
Definition mathlib.qh:114
float cos(float f)
float random(void)
float sin(float f)
void nade_normal_boom(entity this)
Definition normal.qc:4
#define NULL
Definition post.qh:14
#define round_handler_IsActive()
#define round_handler_IsRoundStarted()
vector
Definition self.qh:96
const int CH_SHOTS
Definition sound.qh:14
vector nades_PlayerColor(entity this, bool isPants)
Definition sv_nades.qc:14
float nade_special_time
Definition sv_nades.qh:47
#define SAME_TEAM(a, b)
Definition teams.qh:241

References ATTEN_NORM, autocvar_g_nades_darkness_explode, autocvar_g_nades_darkness_radius, autocvar_g_nades_darkness_teamcheck, CH_SHOTS, cos(), entity(), exp(), ltime, M_PI, MOVE_NOTHING, nade_current_dark_time, nade_darkness_think_cond(), nade_normal_boom(), nade_special_time, nades_PlayerColor(), nextthink, NULL, origin, random(), realowner, round_handler_IsActive, round_handler_IsRoundStarted, SAME_TEAM, Send_Effect(), Send_Effect_Core(), sin(), sound, STAT, time, vector, VOL_BASE, WarpZone_SearchInRadius(), and WarpZone_SearchInRadius_otherent.

Referenced by nade_darkness_boom().

◆ nade_darkness_think_cond()

bool nade_darkness_think_cond ( entity e)

Definition at line 6 of file darkness.qc.

7{
8 return (e != WarpZone_SearchInRadius_otherent && e.takedamage
9 && !IS_DEAD(e) && GetResource(e, RES_HEALTH) > 0 && nade_current_dark_time > 0 && IS_REAL_CLIENT(e));
10}
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
#define IS_DEAD(s)
Definition player.qh:244
#define IS_REAL_CLIENT(v)
Definition utils.qh:17

References entity(), GetResource(), IS_DEAD, IS_REAL_CLIENT, nade_current_dark_time, and WarpZone_SearchInRadius_otherent.

Referenced by nade_darkness_think().

Variable Documentation

◆ darkness_fadealpha

bool darkness_fadealpha

Definition at line 114 of file darkness.qc.

Referenced by HUD_DarkBlinking(), and MUTATOR_HOOKFUNCTION().

◆ nade_current_dark_time

float nade_current_dark_time

Definition at line 5 of file darkness.qc.

Referenced by nade_darkness_think(), and nade_darkness_think_cond().