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

Go to the source code of this file.

Functions

 MUTATOR_HOOKFUNCTION (oknex_charge, GetPressedKeys)
 REGISTER_MUTATOR (oknex_charge, true)
void W_OverkillNex_Attack (Weapon thiswep, entity actor,.entity weaponentity, float issecondary)

Variables

float oknex_chargepool_pauseregen_finished
float oknex_lasthit

Function Documentation

◆ MUTATOR_HOOKFUNCTION()

MUTATOR_HOOKFUNCTION ( oknex_charge ,
GetPressedKeys  )

Definition at line 33 of file oknex.qc.

34{
35 entity player = M_ARGV(0, entity);
36
37 // WEAPONTODO
38 if(!WEP_CVAR(WEP_OVERKILL_NEX, charge) || !WEP_CVAR(WEP_OVERKILL_NEX, charge_velocity_rate))
39 return;
40
41 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
42 {
43 .entity weaponentity = weaponentities[slot];
44
45 if (player.(weaponentity).m_weapon == WEP_OVERKILL_NEX && WEP_CVAR(WEP_OVERKILL_NEX, charge) && WEP_CVAR(WEP_OVERKILL_NEX, charge_velocity_rate) && vdist(vec2(player.velocity), >, WEP_CVAR(WEP_OVERKILL_NEX, charge_minspeed)))
46 {
47 float xyspeed = vlen(vec2(player.velocity));
48 // add a maximum of charge_velocity_rate when going fast (f = 1), gradually increasing from minspeed (f = 0) to maxspeed
49 xyspeed = min(xyspeed, WEP_CVAR(WEP_OVERKILL_NEX, charge_maxspeed));
50 float f = (xyspeed - WEP_CVAR(WEP_OVERKILL_NEX, charge_minspeed)) / (WEP_CVAR(WEP_OVERKILL_NEX, charge_maxspeed) - WEP_CVAR(WEP_OVERKILL_NEX, charge_minspeed));
51 // add the extra charge
52 player.(weaponentity).oknex_charge = min(1, player.(weaponentity).oknex_charge + WEP_CVAR(WEP_OVERKILL_NEX, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH);
53 }
54 }
55}
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 oknex_charge
Definition wepent.qh:8

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

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( oknex_charge ,
true  )

References oknex_charge.

◆ W_OverkillNex_Attack()

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

Definition at line 57 of file oknex.qc.

58{
59 float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, charge;
60
61 mydmg = WEP_CVAR_BOTH(WEP_OVERKILL_NEX, !issecondary, damage);
62 myforce = WEP_CVAR_BOTH(WEP_OVERKILL_NEX, !issecondary, force);
63 mymindist = WEP_CVAR_BOTH(WEP_OVERKILL_NEX, !issecondary, damagefalloff_mindist);
64 mymaxdist = WEP_CVAR_BOTH(WEP_OVERKILL_NEX, !issecondary, damagefalloff_maxdist);
65 myhalflife = WEP_CVAR_BOTH(WEP_OVERKILL_NEX, !issecondary, damagefalloff_halflife);
66 myforcehalflife = WEP_CVAR_BOTH(WEP_OVERKILL_NEX, !issecondary, damagefalloff_forcehalflife);
67 myammo = WEP_CVAR_BOTH(WEP_OVERKILL_NEX, !issecondary, ammo);
68
69 float flying;
70 flying = IsFlying(actor); // do this BEFORE to make the trace values from FireRailgunBullet last
71
72 if (WEP_CVAR(WEP_OVERKILL_NEX, charge))
73 {
74 charge = WEP_CVAR(WEP_OVERKILL_NEX, charge_mindmg) / mydmg + (1 - WEP_CVAR(WEP_OVERKILL_NEX, charge_mindmg) / mydmg) * actor.(weaponentity).oknex_charge;
75 actor.(weaponentity).oknex_charge *= WEP_CVAR(WEP_OVERKILL_NEX, charge_shot_multiplier); // do this AFTER setting mydmg/myforce
76 // O RLY? -- divVerent
77 // YA RLY -- FruitieX
78 }
79 else
80 {
81 charge = 1;
82 }
83 mydmg *= charge;
84 myforce *= charge;
85
86 W_SetupShot(actor, weaponentity, true, 5, SND_OK_NEX_FIRE, CH_WEAPON_A, mydmg, thiswep.m_id);
87 if(charge > WEP_CVAR(WEP_OVERKILL_NEX, charge_animlimit) && WEP_CVAR(WEP_OVERKILL_NEX, charge_animlimit)) // if the OverkillNex is overcharged, we play an extra sound
88 {
89 sound(actor, CH_WEAPON_B, SND_OK_NEX_CHARGE, VOL_BASE * (charge - 0.5 * WEP_CVAR(WEP_OVERKILL_NEX, charge_animlimit)) / (1 - 0.5 * WEP_CVAR(WEP_OVERKILL_NEX, charge_animlimit)), ATTN_NORM);
90 }
91
92 yoda = 0;
94 FireRailgunBullet(actor, weaponentity, w_shotorg, w_shotorg + w_shotdir * max_shot_distance, mydmg, true, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, thiswep.m_id);
95
96 if(yoda && flying)
97 Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
98 if(impressive_hits && actor.oknex_lasthit)
99 {
100 Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_IMPRESSIVE);
101 impressive_hits = 0; // only every second time
102 }
103
104 actor.oknex_lasthit = impressive_hits;
105
106 //beam and muzzle flash done on client
107 SendCSQCVortexBeamParticle(actor, charge);
108
109 W_DecreaseAmmo(thiswep, actor, myammo, weaponentity);
110}
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
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
vector w_shotorg
Definition tracing.qh:19
#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
#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(), impressive_hits, IsFlying(), Weapon::m_id, max_shot_distance, oknex_charge, Send_Notification(), SendCSQCVortexBeamParticle(), sound, VOL_BASE, W_DecreaseAmmo(), W_SetupShot, w_shotdir, w_shotorg, WEP_CVAR, WEP_CVAR_BOTH, and yoda.

Variable Documentation

◆ oknex_chargepool_pauseregen_finished

float oknex_chargepool_pauseregen_finished

Definition at line 112 of file oknex.qc.

◆ oknex_lasthit

float oknex_lasthit

Definition at line 5 of file oknex.qc.