]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/overkill/okshotgun.qc
Merge branch 't0uYK8Ne/set_slick_friction' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / overkill / okshotgun.qc
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                         vector a = '0 0 0';
28                         actor.(weaponentity).wframe = WFRAME_FIRE2;
29                         a = actor.(weaponentity).anim_fire2;
30                         a.z *= g_weaponratefactor;
31                         FOREACH_CLIENT(true, LAMBDA(
32                                 if (it == actor || (IS_SPEC(it) && it.enemy == actor))
33                                 {
34                                         wframe_send(it, actor.(weaponentity), a, true);
35                                 }
36                         ));
37                         animdecide_setaction(actor, ANIMACTION_SHOOT, true);
38                 }
39         }
40         if (WEP_CVAR(okshotgun, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR_PRI(okshotgun, ammo))
41         {
42                 // Forced reload
43                 thiswep.wr_reload(thiswep, actor, weaponentity);
44                 return;
45         }
46         if (fire & 1) // Primary attack
47         {
48                 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(okshotgun, refire)))
49                 {
50                         return;
51                 }
52                 W_Shotgun_Attack(thiswep, actor, weaponentity, true,
53                         WEP_CVAR_PRI(okshotgun, ammo),
54                         WEP_CVAR_PRI(okshotgun, damage),
55                         WEP_CVAR_PRI(okshotgun, bullets),
56                         WEP_CVAR_PRI(okshotgun, spread),
57                         WEP_CVAR_PRI(okshotgun, solidpenetration),
58                         WEP_CVAR_PRI(okshotgun, force),
59                         EFFECT_RIFLE_WEAK);
60                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(okshotgun, animtime), w_ready);
61                 return;
62         }
63         if ((fire & 2) && (WEP_CVAR_SEC(okshotgun, refire_type) == 0)) // Secondary attack
64         {
65                 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(okshotgun, refire)))
66                 {
67                         return;
68                 }
69                 BLASTER_SECONDARY_ATTACK(okshotgun, actor, weaponentity);
70                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(okshotgun, animtime), w_ready);
71         }
72 }
73
74 METHOD(OverkillShotgun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
75 {
76         float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(okshotgun, ammo);
77         ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_SHOTGUN.m_id]) >= WEP_CVAR_PRI(okshotgun, ammo);
78         return ammo_amount;
79 }
80
81 METHOD(OverkillShotgun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
82 {
83         return true; // Blaster secondary is unlimited.
84 }
85
86 METHOD(OverkillShotgun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
87 {
88         W_Reload(actor, weaponentity, WEP_CVAR_PRI(okshotgun, ammo), SND_RELOAD); // WEAPONTODO
89 }
90
91 METHOD(OverkillShotgun, wr_suicidemessage, Notification(entity thiswep))
92 {
93         return WEAPON_THINKING_WITH_PORTALS;
94 }
95
96 METHOD(OverkillShotgun, wr_killmessage, Notification(entity thiswep))
97 {
98         return WEAPON_OVERKILL_SHOTGUN_MURDER;
99 }
100
101 #endif
102 #ifdef CSQC
103 .float prevric;
104
105 METHOD(OverkillShotgun, wr_impacteffect, void(entity thiswep, entity actor))
106 {
107         vector org2 = w_org + w_backoff * 2;
108         pointparticles(EFFECT_SHOTGUN_IMPACT, org2, w_backoff * 1000, 1);
109         if(!w_issilent && time - actor.prevric > 0.25)
110         {
111                 if(w_random < 0.05)
112                         sound(actor, CH_SHOTS, SND_RIC_RANDOM(), VOL_BASE, ATTEN_NORM);
113                 actor.prevric = time;
114         }
115 }
116
117 #endif