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

Go to the source code of this file.

Functions

 MUTATOR_HOOKFUNCTION (vortex_charge, GetPressedKeys)
 NET_HANDLE (TE_CSQC_VORTEXBEAMPARTICLE, bool isNew)
 REGISTER_MUTATOR (vortex_charge, true)
void SendCSQCVortexBeamParticle (entity player, float charge)
vector vortex_glowcolor (int actor_colors, float charge)
void W_Vortex_Attack (Weapon thiswep, entity actor,.entity weaponentity, bool is_secondary)
void W_Vortex_Charge (entity actor,.entity weaponentity, float dt)

Variables

float vortex_chargepool_pauseregen_finished

Function Documentation

◆ MUTATOR_HOOKFUNCTION()

MUTATOR_HOOKFUNCTION ( vortex_charge ,
GetPressedKeys  )

Definition at line 89 of file vortex.qc.

90{
91 entity player = M_ARGV(0, entity);
92
93 // WEAPONTODO
94 if (!WEP_CVAR(WEP_VORTEX, charge) || !WEP_CVAR(WEP_VORTEX, charge_velocity_rate))
95 return;
96
97 for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
98 {
99 .entity weaponentity = weaponentities[slot];
100
101 if (player.(weaponentity).m_weapon == WEP_VORTEX && WEP_CVAR(WEP_VORTEX, charge) && WEP_CVAR(WEP_VORTEX, charge_velocity_rate) && vdist(vec2(player.velocity), >, WEP_CVAR(WEP_VORTEX, charge_minspeed)))
102 {
103 float xyspeed = vlen(vec2(player.velocity));
104 // add a maximum of charge_velocity_rate when going fast (f = 1), gradually increasing from minspeed (f = 0) to maxspeed
105 xyspeed = min(xyspeed, WEP_CVAR(WEP_VORTEX, charge_maxspeed));
106 float f = (xyspeed - WEP_CVAR(WEP_VORTEX, charge_minspeed)) / (WEP_CVAR(WEP_VORTEX, charge_maxspeed) - WEP_CVAR(WEP_VORTEX, charge_minspeed));
107 // add the extra charge
108 player.(weaponentity).vortex_charge = min(1, player.(weaponentity).vortex_charge + WEP_CVAR(WEP_VORTEX, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH);
109 }
110 }
111}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define M_ARGV(x, type)
Definition events.qh:17
#define PHYS_INPUT_TIMELENGTH
Definition player.qh:253
float vlen(vector v)
float min(float f,...)
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition vector.qh:8
#define vec2(...)
Definition vector.qh:90
#define WEP_CVAR(wep, name)
Definition all.qh:337
const int MAX_WEAPONSLOTS
Definition weapon.qh:16
entity weaponentities[MAX_WEAPONSLOTS]
Definition weapon.qh:17
float vortex_charge
Definition wepent.qh:6

References entity(), GetPressedKeys(), M_ARGV, MAX_WEAPONSLOTS, min(), PHYS_INPUT_TIMELENGTH, vdist, vec2, vlen(), vortex_charge, weaponentities, and WEP_CVAR.

◆ NET_HANDLE()

NET_HANDLE ( TE_CSQC_VORTEXBEAMPARTICLE ,
bool isNew )

Definition at line 50 of file vortex.qc.

51{
53 vector endpos = ReadVector();
54 float charge = ReadByte() / 255.0;
55 int myowner = ReadByte();
56
57 int eff_flags = PARTICLES_USEALPHA | PARTICLES_USEFADE;
58
59 //pointparticles(EFFECT_VORTEX_MUZZLEFLASH, shotorg, normalize(endpos - shotorg) * 1000, 1);
60
61 charge = sqrt(charge); // divide evenly among trail spacing and alpha
64 {
65 float mycolors = entcs_GetClientColors(myowner - 1);
66 vector rgb = vortex_glowcolor(mycolors, max(0.25, charge));
67 // in the event of charging being turned off, fall back to player colours
68 if (rgb == '0 0 0')
69 rgb = colormapPaletteColor(mycolors & 0x0F, true);
71 eff_flags |= PARTICLES_USECOLOR;
72 }
73
74 if (!MUTATOR_CALLHOOK(Particles_VortexBeam, shotorg, endpos))
75 {
77 WarpZone_TrailParticles_WithMultiplier(NULL, particleeffectnum(EFFECT_VORTEX_BEAM_OLD), shotorg, endpos, 1, eff_flags);
78 else
79 WarpZone_TrailParticles_WithMultiplier(NULL, particleeffectnum(EFFECT_VORTEX_BEAM), shotorg, endpos, 1, eff_flags);
80 }
81 return true;
82}
vector shotorg
Definition aim.qh:10
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
#define colormapPaletteColor(c, isPants)
Definition color.qh:5
vector particles_colormin
float particles_alphamax
vector particles_colormax
float PARTICLES_USEALPHA
float particles_alphamin
float PARTICLES_USECOLOR
float particles_fade
float PARTICLES_USEFADE
#define particleeffectnum(e)
Definition effect.qh:3
int entcs_GetClientColors(int i)
Definition ent_cs.qh:115
#define ReadVector()
Definition net.qh:350
int ReadByte()
void WarpZone_TrailParticles_WithMultiplier(entity own, float eff, vector org, vector end, float f, int boxflags)
Definition common.qc:489
float sqrt(float f)
float max(float f,...)
#define NULL
Definition post.qh:14
vector
Definition self.qh:92
bool teamplay
Definition teams.qh:59
vector vortex_glowcolor(int actor_colors, float charge)
Definition vortex.qc:7
bool autocvar_cl_particles_oldvortexbeam
Definition vortex.qh:88
int autocvar_cl_tracers_teamcolor
Definition weapon.qh:249

References autocvar_cl_particles_oldvortexbeam, autocvar_cl_tracers_teamcolor, colormapPaletteColor, entcs_GetClientColors(), max(), MUTATOR_CALLHOOK, NULL, particleeffectnum, particles_alphamax, particles_alphamin, particles_colormax, particles_colormin, particles_fade, PARTICLES_USEALPHA, PARTICLES_USECOLOR, PARTICLES_USEFADE, ReadByte(), ReadVector, shotorg, sqrt(), teamplay, vector, vortex_glowcolor(), and WarpZone_TrailParticles_WithMultiplier().

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( vortex_charge ,
true  )

References vortex_charge.

◆ SendCSQCVortexBeamParticle()

void SendCSQCVortexBeamParticle ( entity player,
float charge )

Definition at line 37 of file vortex.qc.

38{
40 WriteHeader(MSG_BROADCAST, TE_CSQC_VORTEXBEAMPARTICLE);
41 WriteVector(MSG_BROADCAST, w_shotorg);
42 WriteVector(MSG_BROADCAST, v);
43 WriteByte(MSG_BROADCAST, bound(0, 255 * charge, 255));
45}
vector trace_endpos
#define WriteHeader(to, id)
Definition net.qh:265
vector WarpZone_UnTransformOrigin(entity wz, vector v)
Definition common.qc:544
entity WarpZone_trace_transform
Definition common.qh:37
float bound(float min, float value, float max)
void WriteByte(float data, float dest, float desto)
float MSG_BROADCAST
Definition menudefs.qc:55
#define etof(e)
Definition misc.qh:25
vector w_shotorg
Definition tracing.qh:19

References bound(), entity(), etof, MSG_BROADCAST, trace_endpos, vector, w_shotorg, WarpZone_trace_transform, WarpZone_UnTransformOrigin(), WriteByte(), and WriteHeader.

Referenced by W_OverkillNex_Attack(), and W_Vortex_Attack().

◆ vortex_glowcolor()

vector vortex_glowcolor ( int actor_colors,
float charge )

Definition at line 7 of file vortex.qc.

8{
9 if (!WEP_CVAR(WEP_VORTEX, charge))
10 return '0 0 0';
11
12 float animlimit = WEP_CVAR(WEP_VORTEX, charge_animlimit);
13 float f = min(1, charge / animlimit);
14 vector mycolors = colormapPaletteColor(actor_colors & 0x0F, true);
15 vector g = f * (mycolors * 0.3);
16 if (charge > animlimit)
17 {
18 f = (charge - animlimit) / (1 - animlimit);
19 g += f * (mycolors * 0.7);
20 }
21 // transition color can't be '0 0 0' as it defaults to player model glow color
22 if (g == '0 0 0')
23 g = '0 0 0.000001';
24
25 return g;
26}

References colormapPaletteColor, min(), vector, and WEP_CVAR.

Referenced by NET_HANDLE().

◆ W_Vortex_Attack()

void W_Vortex_Attack ( Weapon thiswep,
entity actor,
.entity weaponentity,
bool is_secondary )

Definition at line 113 of file vortex.qc.

114{
115 float mydmg = WEP_CVAR_BOTH(WEP_VORTEX, !is_secondary, damage);
116 float myforce = WEP_CVAR_BOTH(WEP_VORTEX, !is_secondary, force);
117
118 float dtype = thiswep.m_id;
119 if (WEP_CVAR_BOTH(WEP_VORTEX, !is_secondary, armorpierce))
120 dtype |= HITTYPE_ARMORPIERCE;
121
122 float flying = IsFlying(actor); // do this BEFORE to make the trace values from FireRailgunBullet last
123
124 float charge;
125 if (WEP_CVAR(WEP_VORTEX, charge))
126 {
127 charge = WEP_CVAR(WEP_VORTEX, charge_mindmg) / mydmg + (1 - WEP_CVAR(WEP_VORTEX, charge_mindmg) / mydmg) * actor.(weaponentity).vortex_charge;
128 actor.(weaponentity).vortex_charge *= WEP_CVAR(WEP_VORTEX, charge_shot_multiplier); // do this AFTER setting mydmg/myforce
129 // O RLY? -- divVerent
130 // YA RLY -- FruitieX
131 }
132 else
133 charge = 1;
134 mydmg *= charge;
135 myforce *= charge;
136
137 W_SetupShot(actor, weaponentity, true, 5, SND_VORTEX_FIRE, CH_WEAPON_A, mydmg, dtype);
138 if (WEP_CVAR(WEP_VORTEX, charge_animlimit) && charge > WEP_CVAR(WEP_VORTEX, charge_animlimit)) // if the Vortex is overcharged, we play an extra sound
139 sound(actor, CH_WEAPON_B, SND_VORTEX_CHARGE, VOL_BASE * (charge - 0.5 * WEP_CVAR(WEP_VORTEX, charge_animlimit)) / (1 - 0.5 * WEP_CVAR(WEP_VORTEX, charge_animlimit)), ATTN_NORM);
140
141 yoda = 0;
142 impressive_hits = 0;
144 mydmg,
145 false,
146 myforce,
147 WEP_CVAR_BOTH(WEP_VORTEX, !is_secondary, damagefalloff_mindist),
148 WEP_CVAR_BOTH(WEP_VORTEX, !is_secondary, damagefalloff_maxdist),
149 WEP_CVAR_BOTH(WEP_VORTEX, !is_secondary, damagefalloff_halflife),
150 WEP_CVAR_BOTH(WEP_VORTEX, !is_secondary, damagefalloff_forcehalflife),
151 dtype
152 );
153
154 if (yoda && flying)
155 Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
156 if (impressive_hits && actor.vortex_lasthit)
157 {
158 Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_IMPRESSIVE);
159 impressive_hits = 0; // only every second time
160 }
161
162 actor.vortex_lasthit = impressive_hits;
163
164 //beam done on client
166 W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, normalize(v - w_shotorg));
167 SendCSQCVortexBeamParticle(actor, charge);
168
169 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_BOTH(WEP_VORTEX, !is_secondary, ammo), weaponentity);
170}
int m_id
Definition weapon.qh:43
bool IsFlying(entity this)
Definition player.qc:843
const float ATTN_NORM
float yoda
Definition damage.qh:48
int impressive_hits
Definition damage.qh:49
const int HITTYPE_ARMORPIERCE
Definition all.qh:32
vector normalize(vector v)
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
Definition all.qc:1573
const float VOL_BASE
Definition sound.qh:36
const int CH_WEAPON_A
Definition sound.qh:7
#define sound(e, c, s, v, a)
Definition sound.qh:52
const int CH_WEAPON_B
Definition sound.qh:8
float ammo
Definition sv_turrets.qh:43
void FireRailgunBullet(entity this,.entity weaponentity, vector start, vector end, float bdamage, bool headshot_notify, float bforce, float mindist, float maxdist, float halflifedist, float forcehalflifedist, int deathtype)
Definition tracing.qc:231
vector w_shotdir
Definition tracing.qh:20
#define W_SetupShot(ent, wepent, antilag, recoil, snd, chan, maxdamage, deathtype)
Definition tracing.qh:34
void SendCSQCVortexBeamParticle(entity player, float charge)
Definition vortex.qc:37
void W_MuzzleFlash(Weapon thiswep, entity actor,.entity weaponentity, vector shotorg, vector shotdir)
Definition all.qc:715
#define WEP_CVAR_BOTH(wep, isprimary, name)
Definition all.qh:340
int max_shot_distance
Definition weapon.qh:245
void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use,.entity weaponentity)

References ammo, ATTN_NORM, CH_WEAPON_A, CH_WEAPON_B, entity(), FireRailgunBullet(), HITTYPE_ARMORPIERCE, impressive_hits, IsFlying(), Weapon::m_id, max_shot_distance, normalize(), Send_Notification(), SendCSQCVortexBeamParticle(), sound, trace_endpos, vector, VOL_BASE, vortex_charge, W_DecreaseAmmo(), W_MuzzleFlash(), W_SetupShot, w_shotdir, w_shotorg, WarpZone_trace_transform, WarpZone_UnTransformOrigin(), WEP_CVAR, WEP_CVAR_BOTH, and yoda.

◆ W_Vortex_Charge()

void W_Vortex_Charge ( entity actor,
.entity weaponentity,
float dt )

Definition at line 174 of file vortex.qc.

175{
176 if (WEP_CVAR(WEP_VORTEX, charge) && actor.(weaponentity).vortex_charge < WEP_CVAR(WEP_VORTEX, charge_limit))
177 actor.(weaponentity).vortex_charge = min(1, actor.(weaponentity).vortex_charge + WEP_CVAR(WEP_VORTEX, charge_rate) * dt);
178}

References entity(), min(), vortex_charge, and WEP_CVAR.

Referenced by PlayerThink().

Variable Documentation

◆ vortex_chargepool_pauseregen_finished

float vortex_chargepool_pauseregen_finished

Definition at line 172 of file vortex.qc.