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

Go to the source code of this file.

Functions

void W_HLAC_Attack (Weapon thiswep, entity actor,.entity weaponentity)
void W_HLAC_Attack2 (Weapon thiswep, entity actor,.entity weaponentity)
void W_HLAC_Attack_Frame (Weapon thiswep, entity actor,.entity weaponentity, int fire)
void W_HLAC_Touch (entity this, entity toucher)

Function Documentation

◆ W_HLAC_Attack()

void W_HLAC_Attack ( Weapon thiswep,
entity actor,
.entity weaponentity )

Definition at line 27 of file hlac.qc.

28{
29 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(WEP_HLAC, ammo), weaponentity);
30
31 float spread = WEP_CVAR_PRI(WEP_HLAC, spread_min) + (WEP_CVAR_PRI(WEP_HLAC, spread_add) * actor.(weaponentity).misc_bulletcounter);
32 spread = min(spread, WEP_CVAR_PRI(WEP_HLAC, spread_max));
33 if (IS_DUCKED(actor) && IS_ONGROUND(actor))
34 spread *= WEP_CVAR_PRI(WEP_HLAC, spread_crouchmod);
35
36 W_SetupShot(actor, weaponentity, false, 3, SND_HLAC_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(WEP_HLAC, damage), thiswep.m_id);
37 W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir);
39 {
40 actor.punchangle.x = random() - 0.5;
41 actor.punchangle.y = random() - 0.5;
42 }
43
44 entity missile = new(hlacbolt);
45 missile.owner = missile.realowner = actor;
46 missile.bot_dodge = true;
47
48 missile.bot_dodgerating = WEP_CVAR_PRI(WEP_HLAC, damage);
49
50 set_movetype(missile, MOVETYPE_FLY);
52
53 setorigin(missile, w_shotorg);
54 setsize(missile, '0 0 0', '0 0 0');
55
56 W_SetupProjVelocity_Basic(missile, WEP_CVAR_PRI(WEP_HLAC, speed), spread);
57 //missile.angles = vectoangles(missile.velocity); // csqc
58
59 settouch(missile, W_HLAC_Touch);
60 setthink(missile, SUB_Remove);
61
62 missile.nextthink = time + WEP_CVAR_PRI(WEP_HLAC, lifetime);
63
64 missile.flags = FL_PROJECTILE;
65 IL_PUSH(g_projectiles, missile);
66 IL_PUSH(g_bot_dodge, missile);
67 missile.projectiledeathtype = thiswep.m_id;
68 missile.weaponentity_fld = weaponentity;
69
70 CSQCProjectile(missile, true, PROJECTILE_HLAC, true);
71
72 MUTATOR_CALLHOOK(EditProjectile, actor, missile);
73}
IntrusiveList g_bot_dodge
Definition api.qh:150
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
int m_id
Definition weapon.qh:43
float lifetime
Definition powerups.qc:23
#define IS_DUCKED(s)
Definition player.qh:212
const int FL_PROJECTILE
Definition constants.qh:85
float time
void CSQCProjectile(entity e, float clientanimate, int type, float docull)
void SUB_Remove(entity this)
Remove entity.
Definition defer.qh:13
float speed
Definition dynlight.qc:9
void W_HLAC_Touch(entity this, entity toucher)
Definition hlac.qc:5
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
float random(void)
float min(float f,...)
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_FLY
Definition movetypes.qh:134
#define IS_ONGROUND(s)
Definition movetypes.qh:16
const int PROJECTILE_HLAC
#define setthink(e, f)
#define settouch(e, f)
Definition self.qh:73
IntrusiveList g_projectiles
Definition common.qh:58
#define PROJECTILE_MAKETRIGGER(e)
Definition common.qh:34
float misc_bulletcounter
Definition common.qh:19
const int CH_WEAPON_A
Definition sound.qh:7
float ammo
Definition sv_turrets.qh:43
bool autocvar_g_norecoil
Definition tracing.qh:16
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
#define W_SetupProjVelocity_Basic(ent, pspeed, pspread)
Definition tracing.qh:49
void W_MuzzleFlash(Weapon thiswep, entity actor,.entity weaponentity, vector shotorg, vector shotdir)
Definition all.qc:715
#define WEP_CVAR_PRI(wep, name)
Definition all.qh:338
void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use,.entity weaponentity)

References ammo, autocvar_g_norecoil, CH_WEAPON_A, CSQCProjectile(), entity(), FL_PROJECTILE, g_bot_dodge, g_projectiles, IL_PUSH(), IS_DUCKED, IS_ONGROUND, lifetime, Weapon::m_id, min(), misc_bulletcounter, MOVETYPE_FLY, MUTATOR_CALLHOOK, PROJECTILE_HLAC, PROJECTILE_MAKETRIGGER, random(), set_movetype(), setthink, settouch, speed, SUB_Remove(), time, W_DecreaseAmmo(), W_HLAC_Touch(), W_MuzzleFlash(), W_SetupProjVelocity_Basic, W_SetupShot, w_shotdir, w_shotorg, and WEP_CVAR_PRI.

Referenced by W_HLAC_Attack_Frame().

◆ W_HLAC_Attack2()

void W_HLAC_Attack2 ( Weapon thiswep,
entity actor,
.entity weaponentity )

Definition at line 75 of file hlac.qc.

76{
77 float spread = WEP_CVAR_SEC(WEP_HLAC, spread);
78
79 if (IS_DUCKED(actor) && IS_ONGROUND(actor))
80 spread *= WEP_CVAR_SEC(WEP_HLAC, spread_crouchmod);
81
82 W_SetupShot(actor, weaponentity, false, 3, SND_HLAC_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(WEP_HLAC, damage) * WEP_CVAR_SEC(WEP_HLAC, shots), thiswep.m_id | HITTYPE_SECONDARY);
83 W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir);
84 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(WEP_HLAC, ammo), weaponentity);
85
86 entity missile;
87 for (int j = WEP_CVAR_SEC(WEP_HLAC, shots); j > 0; --j)
88 {
89 missile = new(hlacbolt);
90 missile.owner = missile.realowner = actor;
91 missile.bot_dodge = true;
92
93 missile.bot_dodgerating = WEP_CVAR_SEC(WEP_HLAC, damage);
94
95 set_movetype(missile, MOVETYPE_FLY);
97
98 setorigin(missile, w_shotorg);
99 setsize(missile, '0 0 0', '0 0 0');
100
101 W_SetupProjVelocity_Basic(missile, WEP_CVAR_SEC(WEP_HLAC, speed), spread);
102 //missile.angles = vectoangles(missile.velocity); // csqc
103
104 settouch(missile, W_HLAC_Touch);
105 setthink(missile, SUB_Remove);
106
107 missile.nextthink = time + WEP_CVAR_SEC(WEP_HLAC, lifetime);
108
109 missile.flags = FL_PROJECTILE;
110 IL_PUSH(g_projectiles, missile);
111 IL_PUSH(g_bot_dodge, missile);
112 missile.missile_flags = MIF_SPLASH;
113 missile.projectiledeathtype = thiswep.m_id | HITTYPE_SECONDARY;
114 missile.weaponentity_fld = weaponentity;
115
116 CSQCProjectile(missile, true, PROJECTILE_HLAC, true);
117
118 MUTATOR_CALLHOOK(EditProjectile, actor, missile);
119 }
120
122 {
123 actor.punchangle.x = random() - 0.5;
124 actor.punchangle.y = random() - 0.5;
125 }
126}
const int HITTYPE_SECONDARY
Definition all.qh:29
const int MIF_SPLASH
Definition common.qh:46
#define WEP_CVAR_SEC(wep, name)
Definition all.qh:339

References ammo, autocvar_g_norecoil, CH_WEAPON_A, CSQCProjectile(), entity(), FL_PROJECTILE, g_bot_dodge, g_projectiles, HITTYPE_SECONDARY, IL_PUSH(), IS_DUCKED, IS_ONGROUND, lifetime, Weapon::m_id, MIF_SPLASH, MOVETYPE_FLY, MUTATOR_CALLHOOK, PROJECTILE_HLAC, PROJECTILE_MAKETRIGGER, random(), set_movetype(), setthink, settouch, speed, SUB_Remove(), time, W_DecreaseAmmo(), W_HLAC_Touch(), W_MuzzleFlash(), W_SetupProjVelocity_Basic, W_SetupShot, w_shotdir, w_shotorg, and WEP_CVAR_SEC.

◆ W_HLAC_Attack_Frame()

void W_HLAC_Attack_Frame ( Weapon thiswep,
entity actor,
.entity weaponentity,
int fire )

Definition at line 129 of file hlac.qc.

130{
131 if (actor.(weaponentity).m_weapon != actor.(weaponentity).m_switchweapon) // abort immediately if switching
132 {
133 w_ready(thiswep, actor, weaponentity, fire);
134 return;
135 }
136
137 if (PHYS_INPUT_BUTTON_ATCK(actor))
138 {
139 if (!thiswep.wr_checkammo1(thiswep, actor, weaponentity)
140 && !(actor.items & IT_UNLIMITED_AMMO))
141 {
142 W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
143 w_ready(thiswep, actor, weaponentity, fire);
144 return;
145 }
146
147 ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR_PRI(WEP_HLAC, refire) * W_WeaponRateFactor(actor);
148 W_HLAC_Attack(thiswep, actor, weaponentity);
149 ++actor.(weaponentity).misc_bulletcounter;
150 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(WEP_HLAC, refire), W_HLAC_Attack_Frame);
151 }
152 else
153 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(WEP_HLAC, animtime), w_ready);
154}
virtual void wr_checkammo1()
(SERVER) checks ammo for weapon primary
Definition weapon.qh:100
const int IT_UNLIMITED_AMMO
Definition item.qh:23
#define PHYS_INPUT_BUTTON_ATCK(s)
Definition player.qh:152
float W_WeaponRateFactor(entity this)
void W_SwitchWeapon_Force(Player this, Weapon w,.entity weaponentity)
Definition selection.qc:237
void W_HLAC_Attack(Weapon thiswep, entity actor,.entity weaponentity)
Definition hlac.qc:27
void W_HLAC_Attack_Frame(Weapon thiswep, entity actor,.entity weaponentity, int fire)
Definition hlac.qc:129
#define w_getbestweapon(ent, wepent)
Definition selection.qh:23
void weapon_thinkf(entity actor,.entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor,.entity weaponentity, int fire) func)
void w_ready(Weapon thiswep, entity actor,.entity weaponentity, int fire)
#define ATTACK_FINISHED(ent, w)

References ATTACK_FINISHED, entity(), IT_UNLIMITED_AMMO, misc_bulletcounter, PHYS_INPUT_BUTTON_ATCK, time, w_getbestweapon, W_HLAC_Attack(), W_HLAC_Attack_Frame(), w_ready(), W_SwitchWeapon_Force(), W_WeaponRateFactor(), weapon_thinkf(), WEP_CVAR_PRI, and Weapon::wr_checkammo1().

Referenced by W_HLAC_Attack_Frame().

◆ W_HLAC_Touch()

void W_HLAC_Touch ( entity this,
entity toucher )

Definition at line 5 of file hlac.qc.

6{
8
9 this.event_damage = func_null;
10
11 bool is_primary = !(this.projectiledeathtype & HITTYPE_SECONDARY);
12 RadiusDamage(this, this.realowner,
13 WEP_CVAR_BOTH(WEP_HLAC, is_primary, damage),
14 WEP_CVAR_BOTH(WEP_HLAC, is_primary, edgedamage),
15 WEP_CVAR_BOTH(WEP_HLAC, is_primary, radius),
16 NULL,
17 NULL,
18 WEP_CVAR_BOTH(WEP_HLAC, is_primary, force),
22 );
23
24 delete(this);
25}
float radius
Definition impulse.qh:11
float RadiusDamage(entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity cantbe, entity mustbe, float forceintensity, int deathtype,.entity weaponentity, entity directhitentity)
Definition damage.qc:943
var void func_null()
#define NULL
Definition post.qh:14
entity entity toucher
Definition self.qh:72
int projectiledeathtype
Definition common.qh:21
#define PROJECTILE_TOUCH(e, t)
Definition common.qh:28
entity realowner
#define WEP_CVAR_BOTH(wep, isprimary, name)
Definition all.qh:340
entity weaponentity_fld

References entity(), func_null(), HITTYPE_SECONDARY, NULL, PROJECTILE_TOUCH, projectiledeathtype, radius, RadiusDamage(), realowner, toucher, weaponentity_fld, and WEP_CVAR_BOTH.

Referenced by W_HLAC_Attack(), and W_HLAC_Attack2().