Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
okshotgun.qc
Go to the documentation of this file.
1#include "okshotgun.qh"
2
3#ifdef SVQC
4METHOD(OverkillShotgun, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
5{
6 if (vdist(actor.origin - actor.enemy.origin, >, WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, bot_range)))
7 {
8 PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false, false);
9 }
10 else
11 {
12 PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false, false);
13 }
14}
15
16METHOD(OverkillShotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
17{
18 if ((WEP_CVAR_SEC(WEP_OVERKILL_SHOTGUN, refire_type) == 1) && (fire & 2) && (time >= actor.jump_interval))
19 {
20 // Secondary uses it's own refire timer if refire_type is 1.
21 actor.jump_interval = time + WEP_CVAR_PRI(WEP_BLASTER, refire) * W_WeaponRateFactor(actor);
22 makevectors(actor.v_angle);
23 W_Blaster_Attack(actor, weaponentity);
24 if ((actor.(weaponentity).wframe == WFRAME_IDLE) ||
25 (actor.(weaponentity).wframe == WFRAME_FIRE2))
26 {
27 // Set secondary fire animation.
28 actor.(weaponentity).wframe = WFRAME_FIRE2;
30 if (it == actor || (IS_SPEC(it) && it.enemy == actor))
31 {
32 wframe_send(it, actor.(weaponentity), WFRAME_FIRE2, autocvar_g_weaponratefactor, true);
33 }
34 ));
36 }
37 }
38 if (WEP_CVAR(WEP_OVERKILL_SHOTGUN, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, ammo))
39 {
40 // Forced reload
41 thiswep.wr_reload(thiswep, actor, weaponentity);
42 return;
43 }
44 if (fire & 1) // Primary attack
45 {
46 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, refire)))
47 {
48 return;
49 }
50 W_Shotgun_Attack(thiswep, actor, weaponentity, true,
51 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, ammo),
52 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, damage),
53 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, damagefalloff_halflife),
54 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, damagefalloff_mindist),
55 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, damagefalloff_maxdist),
56 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, bullets),
57 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, spread),
58 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, spread_pattern),
59 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, spread_pattern_scale),
60 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, spread_pattern_bias),
61 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, solidpenetration),
62 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, force),
63 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, damagefalloff_forcehalflife),
64 EFFECT_RIFLE_WEAK);
65 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, animtime), w_ready);
66 return;
67 }
68 if ((fire & 2) && (WEP_CVAR_SEC(WEP_OVERKILL_SHOTGUN, refire_type) == 0)) // Secondary attack
69 {
70 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(WEP_BLASTER, refire)))
71 {
72 return;
73 }
74 makevectors(actor.v_angle);
75 W_Blaster_Attack(actor, weaponentity);
76 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_PRI(WEP_BLASTER, animtime), w_ready);
77 }
78}
79
80METHOD(OverkillShotgun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
81{
82 float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, ammo);
83 ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_SHOTGUN.m_id]) >= WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, ammo);
84 return ammo_amount;
85}
86
87METHOD(OverkillShotgun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
88{
89 return true; // Blaster secondary is unlimited.
90}
91
92METHOD(OverkillShotgun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
93{
94 W_Reload(actor, weaponentity, WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, ammo), SND_RELOAD); // WEAPONTODO
95}
96
97METHOD(OverkillShotgun, wr_suicidemessage, Notification(entity thiswep))
98{
99 return WEAPON_THINKING_WITH_PORTALS;
100}
101
102METHOD(OverkillShotgun, wr_killmessage, Notification(entity thiswep))
103{
104 return WEAPON_OVERKILL_SHOTGUN_MURDER;
105}
106
107#endif
108#ifdef CSQC
109.float prevric;
110
111METHOD(OverkillShotgun, wr_impacteffect, void(entity thiswep, entity actor))
112{
113 vector org2 = w_org + w_backoff * 2;
114 pointparticles(EFFECT_SHOTGUN_IMPACT, org2, w_backoff * 1000, 1);
115 if(!w_issilent && time - actor.prevric > 0.25)
116 {
117 if(w_random < 0.05)
119 actor.prevric = time;
120 }
121}
122
123#endif
124#ifdef MENUQC
127
128METHOD(OverkillShotgun, describe, string(OverkillShotgun this))
129{
130 TC(OverkillShotgun, this);
132 PAR(_("The %s fires a single shotgun round which spreads into multiple pellets upon exiting the barrel, dealing a deadly blow if up close."), COLORED_NAME(this));
133 PAR(_("Like with all %s weapons, the secondary fire shoots a laser which doesn't damage or push enemies, but can be used to push yourself around."), COLORED_NAME(MUTATOR_ok));
134 PAR(_("The primary fire consumes %s ammo, although you spawn with an infinite amount of it in %s. "
135 "It has a limited magazine size, so needs reloading after several shots."), COLORED_NAME(ITEM_Shells), COLORED_NAME(MUTATOR_ok));
136 PAR(_("The %s damage drops off quickly as the range increases, so it is only useful for close combat or sometimes medium range combat."), COLORED_NAME(this));
137 PAR(W_Guide_Keybinds(this));
138 PAR(W_Guide_DPS_onlyOneMultishot(this.netname, "primary", "primary_bullets", ""));
139 return PAGE_TEXT;
140}
141
142#endif
void animdecide_setaction(entity e, float action, float restart)
const int ANIMACTION_SHOOT
bool bot_aim(entity this,.entity weaponentity, float shotspeed, float shotspeedupward, float maxshottime, float applygravity, bool shot_accurate)
void W_Blaster_Attack(entity actor,.entity weaponentity)
Definition blaster.qc:54
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
string netname
Definition powerups.qc:20
#define COLORED_NAME(this)
Definition color.qh:195
#define PHYS_INPUT_BUTTON_ATCK(s)
Definition player.qh:150
#define PHYS_INPUT_BUTTON_ATCK2(s)
Definition player.qh:152
float W_WeaponRateFactor(entity this)
float time
vector w_org
float w_random
vector w_backoff
float w_issilent
#define pointparticles(effect, org, vel, howmany)
Definition effect.qh:7
#define TC(T, sym)
Definition _all.inc:82
#define LAMBDA(...)
Definition misc.qh:34
entity Notification
always last
Definition all.qh:81
float prevric
Definition okshotgun.qc:109
#define METHOD(cname, name, prototype)
Definition oo.qh:269
#define makevectors
Definition post.qh:21
vector
Definition self.qh:92
void W_Shotgun_Attack(Weapon thiswep, entity actor,.entity weaponentity, float isprimary, float ammocount, float damage, float falloff_halflife, float falloff_mindist, float falloff_maxdist, float bullets, float spread, float spread_pattern, float spread_pattern_scale, float spread_pattern_bias, float solidpenetration, float force, float falloff_forcehalflife, entity bullet_trail_effect)
Definition shotgun.qc:8
const float VOL_BASE
Definition sound.qh:36
const int CH_SHOTS
Definition sound.qh:14
const float ATTEN_NORM
Definition sound.qh:30
#define sound(e, c, s, v, a)
Definition sound.qh:52
Sound SND_RIC_RANDOM()
Definition all.inc:33
#define PAGE_TEXT
Definition string.qh:643
#define PAR(...)
Adds an individually translatable paragraph to PAGE_TEXT without having to deal with strcat and sprin...
Definition string.qh:649
#define PAGE_TEXT_INIT()
Definition string.qh:642
float ammo
Definition sv_turrets.qh:43
#define IS_SPEC(v)
Definition utils.qh:10
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:50
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition vector.qh:8
string W_Guide_Keybinds(Weapon wep)
Definition all.qc:836
string W_Guide_DPS_onlyOneMultishot(string name, string fire, string shots, string refire2)
Definition all.qc:1001
#define WEP_CVAR_PRI(wep, name)
Definition all.qh:322
WFRAME wframe
Definition all.qh:414
#define WEP_CVAR(wep, name)
Definition all.qh:321
#define WEP_CVAR_SEC(wep, name)
Definition all.qh:323
void W_Reload(entity actor,.entity weaponentity, float sent_ammo_min, Sound sent_sound)
void weapon_thinkf(entity actor,.entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor,.entity weaponentity, int fire) func)
bool weapon_prepareattack(Weapon thiswep, entity actor,.entity weaponentity, bool secondary, float attacktime)
void w_ready(Weapon thiswep, entity actor,.entity weaponentity, int fire)
float weapon_load[REGISTRY_MAX(Weapons)]