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)
 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, float issecondary)
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 88 of file vortex.qc.

89{
90 entity player = M_ARGV(0, entity);
91
92 // WEAPONTODO
93 if(!WEP_CVAR(WEP_VORTEX, charge) || !WEP_CVAR(WEP_VORTEX, charge_velocity_rate))
94 return;
95
96 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
97 {
98 .entity weaponentity = weaponentities[slot];
99
100 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)))
101 {
102 float xyspeed = vlen(vec2(player.velocity));
103 // add a maximum of charge_velocity_rate when going fast (f = 1), gradually increasing from minspeed (f = 0) to maxspeed
104 xyspeed = min(xyspeed, WEP_CVAR(WEP_VORTEX, charge_maxspeed));
105 float f = (xyspeed - WEP_CVAR(WEP_VORTEX, charge_minspeed)) / (WEP_CVAR(WEP_VORTEX, charge_maxspeed) - WEP_CVAR(WEP_VORTEX, charge_minspeed));
106 // add the extra charge
107 player.(weaponentity).vortex_charge = min(1, player.(weaponentity).vortex_charge + WEP_CVAR(WEP_VORTEX, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH);
108 }
109 }
110}
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:254
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:321
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.

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( vortex_charge ,
true  )

References vortex_charge.

◆ SendCSQCVortexBeamParticle()

void SendCSQCVortexBeamParticle ( entity player,
float charge )

Definition at line 38 of file vortex.qc.

38 {
39 vector v;
41 WriteHeader(MSG_BROADCAST, TE_CSQC_VORTEXBEAMPARTICLE);
42 WriteVector(MSG_BROADCAST, w_shotorg);
43 WriteVector(MSG_BROADCAST, v);
44 WriteByte(MSG_BROADCAST, bound(0, 255 * charge, 255));
46}
vector trace_endpos
#define WriteHeader(to, id)
Definition net.qh:221
vector WarpZone_UnTransformOrigin(entity wz, vector v)
Definition common.qc:545
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
Definition self.qh:92
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)) return '0 0 0';
10
11 float animlimit = WEP_CVAR(WEP_VORTEX, charge_animlimit);
12 float f = min(1, charge / animlimit);
13 vector mycolors = colormapPaletteColor(actor_colors & 0x0F, true);
14 vector g = f * (mycolors * 0.3);
15 if (charge > animlimit)
16 {
17 f = (charge - animlimit) / (1 - animlimit);
18 g += f * (mycolors * 0.7);
19 }
20 // transition color can't be '0 0 0' as it defaults to player model glow color
21 if (g == '0 0 0')
22 g = '0 0 0.000001';
23
24 return g;
25}
#define colormapPaletteColor(c, isPants)
Definition color.qh:5

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

◆ W_Vortex_Attack()

void W_Vortex_Attack ( Weapon thiswep,
entity actor,
.entity weaponentity,
float issecondary )

Definition at line 112 of file vortex.qc.

113{
114 float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, charge;
115
116 mydmg = WEP_CVAR_BOTH(WEP_VORTEX, !issecondary, damage);
117 myforce = WEP_CVAR_BOTH(WEP_VORTEX, !issecondary, force);
118 mymindist = WEP_CVAR_BOTH(WEP_VORTEX, !issecondary, damagefalloff_mindist);
119 mymaxdist = WEP_CVAR_BOTH(WEP_VORTEX, !issecondary, damagefalloff_maxdist);
120 myhalflife = WEP_CVAR_BOTH(WEP_VORTEX, !issecondary, damagefalloff_halflife);
121 myforcehalflife = WEP_CVAR_BOTH(WEP_VORTEX, !issecondary, damagefalloff_forcehalflife);
122 myammo = WEP_CVAR_BOTH(WEP_VORTEX, !issecondary, ammo);
123
124 float dtype = thiswep.m_id;
125 if(WEP_CVAR_BOTH(WEP_VORTEX, !issecondary, armorpierce))
126 dtype |= HITTYPE_ARMORPIERCE;
127
128 float flying;
129 flying = IsFlying(actor); // do this BEFORE to make the trace values from FireRailgunBullet last
130
131 if(WEP_CVAR(WEP_VORTEX, charge))
132 {
133 charge = WEP_CVAR(WEP_VORTEX, charge_mindmg) / mydmg + (1 - WEP_CVAR(WEP_VORTEX, charge_mindmg) / mydmg) * actor.(weaponentity).vortex_charge;
134 actor.(weaponentity).vortex_charge *= WEP_CVAR(WEP_VORTEX, charge_shot_multiplier); // do this AFTER setting mydmg/myforce
135 // O RLY? -- divVerent
136 // YA RLY -- FruitieX
137 }
138 else
139 charge = 1;
140 mydmg *= charge;
141 myforce *= charge;
142
143 W_SetupShot(actor, weaponentity, true, 5, SND_VORTEX_FIRE, CH_WEAPON_A, mydmg, dtype);
144 if(charge > WEP_CVAR(WEP_VORTEX, charge_animlimit) && WEP_CVAR(WEP_VORTEX, charge_animlimit)) // if the Vortex is overcharged, we play an extra sound
145 {
146 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);
147 }
148
149 yoda = 0;
150 impressive_hits = 0;
151 FireRailgunBullet(actor, weaponentity, w_shotorg, w_shotorg + w_shotdir * max_shot_distance, mydmg, false, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, dtype);
152
153 if(yoda && flying)
154 Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
155 if(impressive_hits && actor.vortex_lasthit)
156 {
157 Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_IMPRESSIVE);
158 impressive_hits = 0; // only every second time
159 }
160
161 actor.vortex_lasthit = impressive_hits;
162
163 //beam done on client
165 W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, normalize(v - w_shotorg));
166 SendCSQCVortexBeamParticle(actor, charge);
167
168 W_DecreaseAmmo(thiswep, actor, myammo, weaponentity);
169}
int m_id
Definition weapon.qh:45
bool IsFlying(entity this)
Definition player.qc:836
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:238
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:38
void W_MuzzleFlash(Weapon thiswep, entity actor,.entity weaponentity, vector shotorg, vector shotdir)
Definition all.qc:728
#define WEP_CVAR_BOTH(wep, isprimary, name)
Definition all.qh:324
int max_shot_distance
Definition weapon.qh:203
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 173 of file vortex.qc.

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

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 171 of file vortex.qc.