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)

Variables

bool darkness_fadealpha

Function Documentation

◆ HUD_DarkBlinking()

void HUD_DarkBlinking ( )

Definition at line 113 of file darkness.qc.

114{
115 vector bottomright = vec2(vid_conwidth, vid_conheight);
116 drawfill('0 0 0', bottomright, NADE_TYPE_DARKNESS.m_color, darkness_fadealpha, DRAWFLAG_NORMAL);
117}
#define drawfill(position, size, rgb, alpha, flag)
Definition draw.qh:36
const float DRAWFLAG_NORMAL
bool darkness_fadealpha
Definition darkness.qc:111
noref float vid_conwidth
Definition draw.qh:8
noref float vid_conheight
Definition draw.qh:9
vector
Definition self.qh:92
#define vec2(...)
Definition vector.qh:90

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

Referenced by MUTATOR_HOOKFUNCTION().

◆ MUTATOR_HOOKFUNCTION()

MUTATOR_HOOKFUNCTION ( cl_nades ,
HUD_Draw_overlay  )

Definition at line 119 of file darkness.qc.

120{
121 if (STAT(NADE_DARKNESS_TIME) > time)
122 {
126 }
127 else if (darkness_fadealpha > 0)
129
130 if (darkness_fadealpha > 0)
131 {
133 M_ARGV(1, float) = 0; // alpha_multipl 0, don't draw normal overlay
134 return true;
135 }
136 return false;
137}
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:113
#define STAT(...)
Definition stats.qh:82
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 71 of file darkness.qc.

72{
73 entity fountain = new(nade_darkness_fountain);
74 fountain.owner = this.owner;
75 fountain.realowner = this.realowner;
76 fountain.origin = this.origin;
77 setorigin(fountain, fountain.origin);
79 fountain.nextthink = time;
80 fountain.pushltime = fountain.wait = fountain.ltime = time + autocvar_g_nades_darkness_time;
81 fountain.team = this.team;
82 set_movetype(fountain, MOVETYPE_TOSS);
83 fountain.projectiledeathtype = DEATH_NADE.m_id;
84 fountain.bot_dodge = false;
85 setsize(fountain, '-16 -16 -16', '16 16 16');
86 fountain.nade_special_time = time + 0.3;
87 fountain.angles = this.angles;
88
90 {
91 setmodel(fountain, MDL_PROJECTILE_GRENADE);
92 entity timer = new(nade_timer);
93 setmodel(timer, MDL_NADE_TIMER);
94 setattachment(timer, fountain, "");
95 timer.colormap = this.colormap;
96 timer.glowmod = this.glowmod;
98 timer.nextthink = time;
99 timer.wait = fountain.wait;
100 timer.nade_lifetime = this.nade_lifetime;
101 timer.owner = fountain;
102 timer.skin = 10;
103 }
104 else
105 setmodel(fountain, MDL_Null);
106}
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
float colormap
vector origin
vector glowmod
void nade_darkness_think(entity this)
Definition darkness.qc:5
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:121
float timer
Definition hud.qh:125
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_TOSS
Definition movetypes.qh:135
#define setthink(e, f)
void nade_timer_think(entity this)
Definition sv_nades.qc:23
float nade_lifetime
Definition sv_nades.qh:45
entity realowner

References angles, autocvar_g_nades_darkness_explode, autocvar_g_nades_darkness_time, colormap, entity(), glowmod, 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 5 of file darkness.qc.

6{
9 {
10 delete(this);
11 return;
12 }
13
14 if(time >= this.ltime)
15 {
17 {
18 vector expcol_min = nades_PlayerColor(this.realowner, false);
19 vector expcol_max = nades_PlayerColor(this.realowner, true);
20 entity expef = EFFECT_NADE_EXPLODE;
21 Send_Effect_Except(expef, this.origin + '0 0 1', '0 0 0', 1, expcol_min, expcol_max, NULL);
22 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
23
24 nade_normal_boom(this);
25 }
26 else
27 Send_Effect_Except(EFFECT_SPAWN, this.origin + '0 0 1', '0 0 0', 1, '0.5 0 0.5', '0.5 0 0.5', NULL);
28
29 delete(this);
30 return;
31 }
32
33 this.nextthink = time + 0.1;
34
35 // gaussian
36 float randomr;
37 randomr = random();
38 randomr = exp(-5 * randomr * randomr) * autocvar_g_nades_nade_radius;
39 float randomw;
40 randomw = random() * (2 * M_PI);
41 vector randomp;
42 randomp.x = randomr * cos(randomw);
43 randomp.y = randomr * sin(randomw);
44 randomp.z = 1;
45 Send_Effect(EFFECT_DARKFIELD, this.origin + randomp, '0 0 0', 1);
46
47 if(time >= this.nade_special_time)
48 {
49 this.nade_special_time = time + 0.7;
50 Send_Effect(EFFECT_DARKFIELD, this.origin, '0 0 0', 1);
51 }
52
53
54 float current_dark_time = this.ltime - time - 0.1;
55
56 FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage
57 && !IS_DEAD(it) && GetResource(it, RES_HEALTH) > 0 && current_dark_time > 0 && IS_REAL_CLIENT(it),
58 {
60 {
61 case 0: break; // affect everyone
62 default:
63 case 2: if(SAME_TEAM(it, this.realowner)) continue; // don't affect teammates
64 // fall through (check case 1 condition too)
65 case 1: if(it == this.realowner) continue; // don't affect the player who threw the nade
66 }
67 STAT(NADE_DARKNESS_TIME, it) = time + 0.1;
68 });
69}
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
#define IS_DEAD(s)
Definition player.qh:245
float nextthink
bool autocvar_g_nades_darkness_teamcheck
Definition darkness.qh:8
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:124
void Send_Effect_Except(entity eff, vector eff_loc, vector eff_vel, int eff_cnt, vector eff_col_min, vector eff_col_max, entity ignore)
Definition all.qc:105
#define FOREACH_ENTITY_RADIUS(org, dist, cond, body)
Definition iter.qh:160
float exp(float e)
Definition mathlib.qc:73
#define M_PI
Definition mathlib.qh:108
float cos(float f)
float random(void)
float sin(float f)
float ltime
Definition net.qc:10
void nade_normal_boom(entity this)
Definition normal.qc:4
#define NULL
Definition post.qh:14
#define round_handler_IsActive()
#define round_handler_IsRoundStarted()
const int CH_SHOTS
Definition sound.qh:14
vector nades_PlayerColor(entity this, bool isPants)
Definition sv_nades.qc:13
float autocvar_g_nades_nade_radius
Definition sv_nades.qh:21
float nade_special_time
Definition sv_nades.qh:47
#define SAME_TEAM(a, b)
Definition teams.qh:241
#define IS_REAL_CLIENT(v)
Definition utils.qh:17

References ATTEN_NORM, autocvar_g_nades_darkness_explode, autocvar_g_nades_darkness_teamcheck, autocvar_g_nades_nade_radius, CH_SHOTS, cos(), entity(), exp(), FOREACH_ENTITY_RADIUS, GetResource(), IS_DEAD, IS_REAL_CLIENT, ltime, M_PI, 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_Except(), sin(), sound, STAT, time, vector, and VOL_BASE.

Referenced by nade_darkness_boom().

Variable Documentation

◆ darkness_fadealpha

bool darkness_fadealpha

Definition at line 111 of file darkness.qc.

Referenced by HUD_DarkBlinking(), and MUTATOR_HOOKFUNCTION().