Xonotic
okshotgun.qc
Go to the documentation of this file.
1 #include "okshotgun.qh"
2 
3 #ifdef SVQC
4 METHOD(OverkillShotgun, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
5 {
6  if (vdist(actor.origin - actor.enemy.origin, >, WEP_CVAR_PRI(okshotgun, bot_range)))
7  {
8  PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
9  }
10  else
11  {
12  PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
13  }
14 }
15 
16 METHOD(OverkillShotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
17 {
18  if ((WEP_CVAR_SEC(okshotgun, 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_SEC(okshotgun, refire) * W_WeaponRateFactor(actor);
22  BLASTER_SECONDARY_ATTACK(okshotgun, actor, weaponentity);
23  if ((actor.(weaponentity).wframe == WFRAME_IDLE) ||
24  (actor.(weaponentity).wframe == WFRAME_FIRE2))
25  {
26  // Set secondary fire animation.
27  actor.(weaponentity).wframe = WFRAME_FIRE2;
28  FOREACH_CLIENT(true, LAMBDA(
29  if (it == actor || (IS_SPEC(it) && it.enemy == actor))
30  {
31  wframe_send(it, actor.(weaponentity), WFRAME_FIRE2, autocvar_g_weaponratefactor, true);
32  }
33  ));
35  }
36  }
37  if (WEP_CVAR(okshotgun, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR_PRI(okshotgun, ammo))
38  {
39  // Forced reload
40  thiswep.wr_reload(thiswep, actor, weaponentity);
41  return;
42  }
43  if (fire & 1) // Primary attack
44  {
45  if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(okshotgun, refire)))
46  {
47  return;
48  }
49  W_Shotgun_Attack(thiswep, actor, weaponentity, true,
50  WEP_CVAR_PRI(okshotgun, ammo),
51  WEP_CVAR_PRI(okshotgun, damage),
52  WEP_CVAR_PRI(okshotgun, bullets),
53  WEP_CVAR_PRI(okshotgun, spread),
54  WEP_CVAR_PRI(okshotgun, solidpenetration),
55  WEP_CVAR_PRI(okshotgun, force),
56  EFFECT_RIFLE_WEAK);
57  weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(okshotgun, animtime), w_ready);
58  return;
59  }
60  if ((fire & 2) && (WEP_CVAR_SEC(okshotgun, refire_type) == 0)) // Secondary attack
61  {
62  if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(okshotgun, refire)))
63  {
64  return;
65  }
66  BLASTER_SECONDARY_ATTACK(okshotgun, actor, weaponentity);
67  weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(okshotgun, animtime), w_ready);
68  }
69 }
70 
71 METHOD(OverkillShotgun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
72 {
73  float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(okshotgun, ammo);
74  ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_SHOTGUN.m_id]) >= WEP_CVAR_PRI(okshotgun, ammo);
75  return ammo_amount;
76 }
77 
78 METHOD(OverkillShotgun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
79 {
80  return true; // Blaster secondary is unlimited.
81 }
82 
83 METHOD(OverkillShotgun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
84 {
85  W_Reload(actor, weaponentity, WEP_CVAR_PRI(okshotgun, ammo), SND_RELOAD); // WEAPONTODO
86 }
87 
88 METHOD(OverkillShotgun, wr_suicidemessage, Notification(entity thiswep))
89 {
90  return WEAPON_THINKING_WITH_PORTALS;
91 }
92 
93 METHOD(OverkillShotgun, wr_killmessage, Notification(entity thiswep))
94 {
95  return WEAPON_OVERKILL_SHOTGUN_MURDER;
96 }
97 
98 #endif
99 #ifdef CSQC
100 .float prevric;
101 
102 METHOD(OverkillShotgun, wr_impacteffect, void(entity thiswep, entity actor))
103 {
104  vector org2 = w_org + w_backoff * 2;
105  pointparticles(EFFECT_SHOTGUN_IMPACT, org2, w_backoff * 1000, 1);
106  if(!w_issilent && time - actor.prevric > 0.25)
107  {
108  if(w_random < 0.05)
110  actor.prevric = time;
111  }
112 }
113 
114 #endif
#define WEP_CVAR_PRI(wepname, name)
Definition: all.qh:300
#define PHYS_INPUT_BUTTON_ATCK2(s)
Definition: player.qh:148
bool bot_aim(entity this,.entity weaponentity, float shotspeed, float shotspeedupward, float maxshottime, float applygravity)
#define WEP_CVAR_SEC(wepname, name)
Definition: all.qh:301
float weapon_load[REGISTRY_MAX(Weapons)]
Definition: weaponsystem.qh:29
entity() spawn
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
void w_ready(Weapon thiswep, entity actor,.entity weaponentity, int fire)
#define WEP_CVAR(wepname, name)
Definition: all.qh:299
Sound SND_RIC_RANDOM()
Definition: all.inc:84
#define LAMBDA(...)
Definition: misc.qh:37
#define METHOD(cname, name, prototype)
Definition: oo.qh:257
float ammo
Definition: sv_turrets.qh:44
#define IS_SPEC(v)
Definition: utils.qh:10
bool weapon_prepareattack(Weapon thiswep, entity actor,.entity weaponentity, bool secondary, float attacktime)
void animdecide_setaction(entity e, float action, float restart)
Definition: animdecide.qc:338
#define pointparticles
Definition: csprogsdefs.qh:13
const float VOL_BASE
Definition: sound.qh:36
#define PHYS_INPUT_BUTTON_ATCK(s)
Definition: player.qh:146
const int ANIMACTION_SHOOT
Definition: animdecide.qh:145
const float ATTEN_NORM
Definition: sound.qh:30
const int CH_SHOTS
Definition: sound.qh:14
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition: vector.qh:8
entity Notification
always last
Definition: all.qh:82
void weapon_thinkf(entity actor,.entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor,.entity weaponentity, int fire) func)
#define sound(e, c, s, v, a)
Definition: sound.qh:52
float time
Definition: csprogsdefs.qc:16
float W_WeaponRateFactor(entity this)
Definition: weaponsystem.qc:33
void W_Reload(entity actor,.entity weaponentity, float sent_ammo_min, Sound sent_sound)