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 PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false, false);
8 else
9 PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false, false);
10}
11
12METHOD(OverkillShotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
13{
14 if (WEP_CVAR_SEC(WEP_OVERKILL_SHOTGUN, refire_type) == 1 && (fire & 2)
15 && time >= actor.jump_interval)
16 {
17 // Secondary uses it's own refire timer if refire_type is 1.
18 actor.jump_interval = time + WEP_CVAR_PRI(WEP_BLASTER, refire) * W_WeaponRateFactor(actor);
19 makevectors(actor.v_angle);
20 W_Blaster_Attack(actor, weaponentity);
21 if (actor.(weaponentity).wframe == WFRAME_IDLE
22 || actor.(weaponentity).wframe == WFRAME_FIRE2)
23 {
24 // Set secondary fire animation.
25 actor.(weaponentity).wframe = WFRAME_FIRE2;
27 if (it == actor || (IS_SPEC(it) && it.enemy == actor))
28 wframe_send(it, actor.(weaponentity), WFRAME_FIRE2, autocvar_g_weaponratefactor, true);
29 ));
31 }
32 }
33 if (WEP_CVAR(WEP_OVERKILL_SHOTGUN, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, ammo))
34 { // forced reload
35 thiswep.wr_reload(thiswep, actor, weaponentity);
36 return;
37 }
38
39 if (fire & 1) // Primary attack
40 {
41 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, refire)))
42 return;
43 W_Shotgun_Attack(thiswep, actor, weaponentity, true,
44 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, ammo),
45 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, damage),
46 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, damagefalloff_halflife),
47 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, damagefalloff_mindist),
48 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, damagefalloff_maxdist),
49 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, bullets),
50 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, spread),
51 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, spread_pattern),
52 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, spread_pattern_scale),
53 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, spread_pattern_bias),
54 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, solidpenetration),
55 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, force),
56 WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, damagefalloff_forcehalflife),
57 EFFECT_RIFLE_WEAK
58 );
59 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, animtime), w_ready);
60 return;
61 }
62 if ((fire & 2) && WEP_CVAR_SEC(WEP_OVERKILL_SHOTGUN, refire_type) == 0) // Secondary attack
63 {
64 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(WEP_BLASTER, refire)))
65 return;
66 makevectors(actor.v_angle);
67 W_Blaster_Attack(actor, weaponentity);
68 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_PRI(WEP_BLASTER, animtime), w_ready);
69 }
70}
71
72METHOD(OverkillShotgun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
73{
74 float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, ammo);
75 ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_SHOTGUN.m_id]) >= WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, ammo);
76 return ammo_amount;
77}
78
79METHOD(OverkillShotgun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
80{
81 return true; // Blaster secondary is unlimited.
82}
83
84METHOD(OverkillShotgun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
85{
86 W_Reload(actor, weaponentity, WEP_CVAR_PRI(WEP_OVERKILL_SHOTGUN, ammo), SND_RELOAD); // WEAPONTODO
87}
88
89METHOD(OverkillShotgun, wr_suicidemessage, Notification(entity thiswep))
90{
91 return WEAPON_THINKING_WITH_PORTALS;
92}
93
94METHOD(OverkillShotgun, wr_killmessage, Notification(entity thiswep))
95{
96 return WEAPON_OVERKILL_SHOTGUN_MURDER;
97}
98
99#endif // SVQC
100#ifdef CSQC
101.float prevric;
102
103METHOD(OverkillShotgun, wr_impacteffect, void(entity thiswep, entity actor))
104{
105 vector org2 = w_org + w_backoff * 2;
106 pointparticles(EFFECT_SHOTGUN_IMPACT, org2, w_backoff * 1000, 1);
107 if (!w_issilent && time - actor.prevric > 0.25)
108 {
109 if (w_random < 0.05)
111 actor.prevric = time;
112 }
113}
114
115#endif // CSQC
116#ifdef MENUQC
119
120METHOD(OverkillShotgun, describe, string(OverkillShotgun this))
121{
122 TC(OverkillShotgun, this);
124 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));
125 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));
126 PAR(_("The primary fire consumes %s ammo, although you spawn with an infinite amount of it in %s. "
127 "It has a limited magazine size, so needs reloading after several shots."), COLORED_NAME(ITEM_Shells), COLORED_NAME(MUTATOR_ok));
128 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));
129 PAR(W_Guide_Keybinds(this));
130 PAR(W_Guide_DPS_onlyOneMultishot(this.netname, "primary", "primary_bullets", ""));
131 return PAGE_TEXT;
132}
133
134#endif // MENUQC
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:52
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:152
#define PHYS_INPUT_BUTTON_ATCK2(s)
Definition player.qh:154
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:101
#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, bool is_primary, 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:642
#define PAR(...)
Adds an individually translatable paragraph to PAGE_TEXT without having to deal with strcat and sprin...
Definition string.qh:648
#define PAGE_TEXT_INIT()
Definition string.qh:641
float ammo
Definition sv_turrets.qh:43
#define IS_SPEC(v)
Definition utils.qh:10
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:52
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition vector.qh:8
void wframe_send(entity actor, entity weaponentity, int wepframe, float attackrate, bool restartanim)
Definition all.qc:577
string W_Guide_Keybinds(Weapon wep)
Definition all.qc:824
string W_Guide_DPS_onlyOneMultishot(string name, string fire, string shots, string refire2)
Definition all.qc:989
#define WEP_CVAR_PRI(wep, name)
Definition all.qh:338
WFRAME wframe
Definition all.qh:439
#define WEP_CVAR(wep, name)
Definition all.qh:337
#define WEP_CVAR_SEC(wep, name)
Definition all.qh:339
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 autocvar_g_weaponratefactor
float weapon_load[REGISTRY_MAX(Weapons)]