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 26 of file hlac.qc.

27{
28 entity missile;
29
30 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(WEP_HLAC, ammo), weaponentity);
31
32 float spread = WEP_CVAR_PRI(WEP_HLAC, spread_min) + (WEP_CVAR_PRI(WEP_HLAC, spread_add) * actor.(weaponentity).misc_bulletcounter);
33 spread = min(spread,WEP_CVAR_PRI(WEP_HLAC, spread_max));
34 if(IS_DUCKED(actor) && IS_ONGROUND(actor))
35 spread *= WEP_CVAR_PRI(WEP_HLAC, spread_crouchmod);
36
37 W_SetupShot(actor, weaponentity, false, 3, SND_HLAC_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(WEP_HLAC, damage), thiswep.m_id);
38 W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir);
40 {
41 actor.punchangle_x = random() - 0.5;
42 actor.punchangle_y = random() - 0.5;
43 }
44
45 missile = new(hlacbolt);
46 missile.owner = missile.realowner = actor;
47 missile.bot_dodge = true;
48
49 missile.bot_dodgerating = WEP_CVAR_PRI(WEP_HLAC, damage);
50
51 set_movetype(missile, MOVETYPE_FLY);
53
54 setorigin(missile, w_shotorg);
55 setsize(missile, '0 0 0', '0 0 0');
56
57 W_SetupProjVelocity_Basic(missile, WEP_CVAR_PRI(WEP_HLAC, speed), spread);
58 //missile.angles = vectoangles(missile.velocity); // csqc
59
60 settouch(missile, W_HLAC_Touch);
61 setthink(missile, SUB_Remove);
62
63 missile.nextthink = time + WEP_CVAR_PRI(WEP_HLAC, lifetime);
64
65 missile.flags = FL_PROJECTILE;
66 IL_PUSH(g_projectiles, missile);
67 IL_PUSH(g_bot_dodge, missile);
68 missile.projectiledeathtype = thiswep.m_id;
69 missile.weaponentity_fld = weaponentity;
70
71 CSQCProjectile(missile, true, PROJECTILE_HLAC, true);
72
73 MUTATOR_CALLHOOK(EditProjectile, actor, missile);
74}
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:45
float lifetime
Definition powerups.qc:23
#define IS_DUCKED(s)
Definition player.qh:210
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:728
#define WEP_CVAR_PRI(wep, name)
Definition all.qh:322
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 76 of file hlac.qc.

77{
78 entity missile;
79 float spread = WEP_CVAR_SEC(WEP_HLAC, spread);
80
81 if(IS_DUCKED(actor) && IS_ONGROUND(actor))
82 spread *= WEP_CVAR_SEC(WEP_HLAC, spread_crouchmod);
83
84 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);
85 W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir);
86 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(WEP_HLAC, ammo), weaponentity);
87
88 for(int j = WEP_CVAR_SEC(WEP_HLAC, shots); j > 0; --j)
89 {
90 missile = new(hlacbolt);
91 missile.owner = missile.realowner = actor;
92 missile.bot_dodge = true;
93
94 missile.bot_dodgerating = WEP_CVAR_SEC(WEP_HLAC, damage);
95
96 set_movetype(missile, MOVETYPE_FLY);
98
99 setorigin(missile, w_shotorg);
100 setsize(missile, '0 0 0', '0 0 0');
101
102 W_SetupProjVelocity_Basic(missile, WEP_CVAR_SEC(WEP_HLAC, speed), spread);
103 //missile.angles = vectoangles(missile.velocity); // csqc
104
105 settouch(missile, W_HLAC_Touch);
106 setthink(missile, SUB_Remove);
107
108 missile.nextthink = time + WEP_CVAR_SEC(WEP_HLAC, lifetime);
109
110 missile.flags = FL_PROJECTILE;
111 IL_PUSH(g_projectiles, missile);
112 IL_PUSH(g_bot_dodge, missile);
113 missile.missile_flags = MIF_SPLASH;
114 missile.projectiledeathtype = thiswep.m_id | HITTYPE_SECONDARY;
115 missile.weaponentity_fld = weaponentity;
116
117 CSQCProjectile(missile, true, PROJECTILE_HLAC, true);
118
119 MUTATOR_CALLHOOK(EditProjectile, actor, missile);
120 }
121
123 {
124 actor.punchangle_x = random() - 0.5;
125 actor.punchangle_y = random() - 0.5;
126 }
127}
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:323

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 130 of file hlac.qc.

131{
132 if(actor.(weaponentity).m_weapon != actor.(weaponentity).m_switchweapon) // abort immediately if switching
133 {
134 w_ready(thiswep, actor, weaponentity, fire);
135 return;
136 }
137
138 if(PHYS_INPUT_BUTTON_ATCK(actor))
139 {
140 if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
141 if(!(actor.items & IT_UNLIMITED_AMMO))
142 {
143 W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
144 w_ready(thiswep, actor, weaponentity, fire);
145 return;
146 }
147
148 ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR_PRI(WEP_HLAC, refire) * W_WeaponRateFactor(actor);
149 W_HLAC_Attack(thiswep, actor, weaponentity);
150 actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
151 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(WEP_HLAC, refire), W_HLAC_Attack_Frame);
152 }
153 else
154 {
155 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(WEP_HLAC, animtime), w_ready);
156 }
157}
virtual void wr_checkammo1()
(SERVER) checks ammo for weapon primary
Definition weapon.qh:92
const int IT_UNLIMITED_AMMO
Definition item.qh:23
#define PHYS_INPUT_BUTTON_ATCK(s)
Definition player.qh:150
float W_WeaponRateFactor(entity this)
void W_SwitchWeapon_Force(Player this, Weapon w,.entity weaponentity)
Definition selection.qc:246
void W_HLAC_Attack(Weapon thiswep, entity actor,.entity weaponentity)
Definition hlac.qc:26
void W_HLAC_Attack_Frame(Weapon thiswep, entity actor,.entity weaponentity, int fire)
Definition hlac.qc:130
#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{
7 float isprimary;
8
10
11 this.event_damage = func_null;
12
13 isprimary = !(this.projectiledeathtype & HITTYPE_SECONDARY);
14
15 RadiusDamage(this, this.realowner,
16 WEP_CVAR_BOTH(WEP_HLAC, isprimary, damage),
17 WEP_CVAR_BOTH(WEP_HLAC, isprimary, edgedamage),
18 WEP_CVAR_BOTH(WEP_HLAC, isprimary, radius),
19 NULL, NULL,
20 WEP_CVAR_BOTH(WEP_HLAC, isprimary, force),
22
23 delete(this);
24}
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:981
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:324
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().