Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
darkness.qc
Go to the documentation of this file.
1#include "darkness.qh"
2
3#ifdef SVQC
4
6{
8 {
9 delete(this);
10 return;
11 }
12
13 if (time >= this.ltime)
14 {
16 {
17 vector expcol_min = nades_PlayerColor(this.realowner, false);
18 vector expcol_max = nades_PlayerColor(this.realowner, true);
19 Send_Effect_Except(EFFECT_NADE_EXPLODE, this.origin + '0 0 1', '0 0 0', 1, expcol_min, expcol_max, NULL);
20 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
21
22 nade_normal_boom(this);
23 }
24 else
25 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);
26
27 delete(this);
28 return;
29 }
30
31 this.nextthink = time + 0.1;
32
33 // gaussian
34 float randomr = random();
35 randomr = exp(-5 * randomr * randomr) * autocvar_g_nades_darkness_radius;
36 float randomw = random() * (2 * M_PI);
37 vector randomp;
38 randomp.x = randomr * cos(randomw);
39 randomp.y = randomr * sin(randomw);
40 randomp.z = 1;
41 Send_Effect(EFFECT_DARKFIELD, this.origin + randomp, '0 0 0', 1);
42
43 if (time >= this.nade_special_time)
44 {
45 this.nade_special_time = time + 0.7;
46 Send_Effect(EFFECT_DARKFIELD, this.origin, '0 0 0', 1);
47 }
48
49 float current_dark_time = this.ltime - time - 0.1;
50
51 FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_darkness_radius, it != this && it.takedamage
52 && !IS_DEAD(it) && GetResource(it, RES_HEALTH) > 0 && current_dark_time > 0 && IS_REAL_CLIENT(it),
53 {
55 {
56 case 0: break; // affect everyone
57 default:
58 case 2: if (SAME_TEAM(it, this.realowner)) continue; // don't affect teammates
59 // fall through (check case 1 condition too)
60 case 1: if (it == this.realowner) continue; // don't affect the player who threw the nade
61 }
62 STAT(NADE_DARKNESS_TIME, it) = time + 0.1;
63 });
64}
65
67{
68 entity fountain = new(nade_darkness_fountain);
69 fountain.owner = this.owner;
70 fountain.realowner = this.realowner;
71 fountain.origin = this.origin;
72 fountain.flags = FL_PROJECTILE;
73 IL_PUSH(g_projectiles, fountain);
74 setorigin(fountain, fountain.origin);
76 fountain.nextthink = time;
77 fountain.pushltime = fountain.wait = fountain.ltime = time + autocvar_g_nades_darkness_time;
78 fountain.team = this.team;
79 set_movetype(fountain, MOVETYPE_TOSS);
80 fountain.projectiledeathtype = DEATH_NADE_DARKNESS.m_id;
81 fountain.bot_dodge = false;
82 setsize(fountain, '-16 -16 -16', '16 16 16');
83 fountain.nade_special_time = time + 0.3;
84 fountain.angles = this.angles;
85
87 {
88 setmodel(fountain, MDL_PROJECTILE_GRENADE);
89 entity timer = new(nade_timer);
90 setmodel(timer, MDL_NADE_TIMER);
91 setattachment(timer, fountain, "");
92 timer.colormap = this.colormap;
93 timer.glowmod = this.glowmod;
95 timer.nextthink = time;
96 timer.wait = fountain.wait;
97 timer.nade_lifetime = this.nade_lifetime;
98 timer.owner = fountain;
99 timer.skin = 10;
100 }
101 else
102 setmodel(fountain, MDL_Null);
103}
104
105#endif // SVQC
106#ifdef CSQC
107
109
111{
112 drawfill('0 0 0', vec2(vid_conwidth, vid_conheight), NADE_TYPE_DARKNESS.m_color, darkness_fadealpha, DRAWFLAG_NORMAL);
113}
114
115MUTATOR_HOOKFUNCTION(cl_nades, HUD_Draw_overlay)
116{
117 if (STAT(NADE_DARKNESS_TIME) > time)
118 {
122 }
123 else if (darkness_fadealpha > 0)
125
126 if (darkness_fadealpha > 0)
127 {
129 M_ARGV(1, float) = 0; // alpha_multipl 0, don't draw normal overlay
130 return true;
131 }
132 return false;
133}
134#endif // CSQC
135#ifdef MENUQC
136#include "darkness.qh"
137
138METHOD(DarknessNade, describe, string(DarknessNade this))
139{
140 TC(DarknessNade, this);
142 PAR(_("The %s detonates after a short delay, creating a dark field which temporarily blinds enemies who enter it."), COLORED_NAME(this));
143 PAR(_("This is sort of the opposite of the %s."), COLORED_NAME(NADE_TYPE_VEIL));
144 return PAGE_TEXT;
145}
146#endif // MENUQC
#define MUTATOR_HOOKFUNCTION(...)
Definition base.qh:335
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
entity csqcplayer
Definition cl_player.qh:26
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
#define drawfill(position, size, rgb, alpha, flag)
Definition draw.qh:36
entity owner
Definition main.qh:87
int team
Definition main.qh:188
#define COLORED_NAME(this)
Definition color.qh:195
#define setmodel(this, m)
Definition model.qh:26
#define M_ARGV(x, type)
Definition events.qh:17
float ltime
Definition net.qh:10
#define IS_DEAD(s)
Definition player.qh:244
const int FL_PROJECTILE
Definition constants.qh:85
const float DRAWFLAG_NORMAL
float frametime
float time
float nextthink
float colormap
vector origin
vector glowmod
void nade_darkness_boom(entity this)
Definition darkness.qc:66
bool darkness_fadealpha
Definition darkness.qc:108
void HUD_DarkBlinking()
Definition darkness.qc:110
void nade_darkness_think(entity this)
Definition darkness.qc:5
float autocvar_g_nades_darkness_radius
Definition darkness.qh:10
bool autocvar_g_nades_darkness_teamcheck
Definition darkness.qh:8
bool autocvar_g_nades_darkness_explode
Definition darkness.qh:7
float autocvar_g_nades_darkness_time
Definition darkness.qh:9
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:120
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:101
ent angles
Definition ent_cs.qc:121
float timer
Definition hud.qh:125
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define FOREACH_ENTITY_RADIUS(org, dist, cond, body)
Definition iter.qh:160
#define TC(T, sym)
Definition _all.inc:82
noref float vid_conwidth
Definition draw.qh:8
noref float vid_conheight
Definition draw.qh:9
#define STAT(...)
Definition stats.qh:82
float exp(float e)
Definition mathlib.qc:74
#define M_PI
Definition mathlib.qh:108
float cos(float f)
float random(void)
float sin(float f)
float min(float f,...)
float max(float f,...)
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_TOSS
Definition movetypes.qh:135
void nade_normal_boom(entity this)
Definition normal.qc:4
#define METHOD(cname, name, prototype)
Definition oo.qh:269
#define NULL
Definition post.qh:14
#define round_handler_IsActive()
#define round_handler_IsRoundStarted()
#define setthink(e, f)
vector
Definition self.qh:92
IntrusiveList g_projectiles
Definition common.qh:58
const int CH_PAIN
Definition sound.qh:18
const float VOL_BASE
Definition sound.qh:36
const int CH_SHOTS
Definition sound.qh:14
const float ATTEN_NORM
Definition sound.qh:30
#define sound(e, c, s, v, a)
Definition sound.qh:52
#define PAGE_TEXT
Definition string.qh:642
#define PAR(...)
Adds an individually translatable paragraph to PAGE_TEXT without having to deal with strcat and sprin...
Definition string.qh:648
#define PAGE_TEXT_INIT()
Definition string.qh:641
vector nades_PlayerColor(entity this, bool isPants)
Definition sv_nades.qc:13
void nade_timer_think(entity this)
Definition sv_nades.qc:27
float nade_lifetime
Definition sv_nades.qh:45
float nade_special_time
Definition sv_nades.qh:47
#define SAME_TEAM(a, b)
Definition teams.qh:241
entity realowner
#define IS_REAL_CLIENT(v)
Definition utils.qh:17
#define vec2(...)
Definition vector.qh:90