OK weapons: Removed unused stuff from shotgun and machinegun.
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / overkill / okshotgun.qc
1 #include "okshotgun.qh"
2
3 #ifdef SVQC
4 spawnfunc(weapon_okshotgun) { weapon_defaultspawnfunc(this, WEP_OVERKILL_SHOTGUN); }
5
6 METHOD(OverkillShotgun, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
7 {
8         if (vdist(actor.origin - actor.enemy.origin, >, WEP_CVAR_PRI(okshotgun, bot_range)))
9         {
10                 PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
11         }
12         else
13         {
14                 PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
15         }
16 }
17
18 METHOD(OverkillShotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
19 {
20         if ((WEP_CVAR_SEC(okshotgun, refire_type) == 1) && (fire & 2) && (time >= actor.jump_interval))
21         {
22                 // Secondary uses it's own refire timer if refire_type is 1.
23                 actor.jump_interval = time + WEP_CVAR_SEC(okshotgun, refire) * W_WeaponRateFactor(actor);
24                 // Ugly hack to reuse the fire mode of the blaster.
25                 makevectors(actor.v_angle);
26                 Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack
27                 actor.(weaponentity).m_weapon = WEP_BLASTER;
28                 W_Blaster_Attack(
29                         actor,
30                         weaponentity,
31                         WEP_BLASTER.m_id | HITTYPE_SECONDARY,
32                         WEP_CVAR_SEC(okshotgun, shotangle),
33                         WEP_CVAR_SEC(okshotgun, damage),
34                         WEP_CVAR_SEC(okshotgun, edgedamage),
35                         WEP_CVAR_SEC(okshotgun, radius),
36                         WEP_CVAR_SEC(okshotgun, force),
37                         WEP_CVAR_SEC(okshotgun, speed),
38                         WEP_CVAR_SEC(okshotgun, spread),
39                         WEP_CVAR_SEC(okshotgun, delay),
40                         WEP_CVAR_SEC(okshotgun, lifetime)
41                 );
42                 actor.(weaponentity).m_weapon = oldwep;
43                 if ((actor.(weaponentity).wframe == WFRAME_IDLE) ||
44                         (actor.(weaponentity).wframe == WFRAME_FIRE2))
45                 {
46                         // Set secondary fire animation.
47                         vector a = '0 0 0';
48                         actor.(weaponentity).wframe = WFRAME_FIRE2;
49                         a = actor.(weaponentity).anim_fire2;
50                         a.z *= g_weaponratefactor;
51                         FOREACH_CLIENT(true, LAMBDA(
52                                 if (it == actor || (IS_SPEC(it) && it.enemy == actor))
53                                 {
54                                         wframe_send(it, actor.(weaponentity), a, true);
55                                 }
56                         ));
57                         animdecide_setaction(actor, ANIMACTION_SHOOT, true);
58                 }
59         }
60         if (WEP_CVAR(okshotgun, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR_PRI(okshotgun, ammo))
61         {
62                 // Forced reload
63                 thiswep.wr_reload(thiswep, actor, weaponentity);
64                 return;
65         }
66         if (fire & 1) // Primary attack
67         {
68                 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(okshotgun, animtime)))
69                 {
70                         return;
71                 }
72                 W_Shotgun_Attack(thiswep, actor, weaponentity, true,
73                         WEP_CVAR_PRI(okshotgun, ammo),
74                         WEP_CVAR_PRI(okshotgun, damage),
75                         WEP_CVAR_PRI(okshotgun, bullets),
76                         WEP_CVAR_PRI(okshotgun, spread),
77                         WEP_CVAR_PRI(okshotgun, solidpenetration),
78                         WEP_CVAR_PRI(okshotgun, force));
79                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(okshotgun, animtime), w_ready);
80                 return;
81         }
82         if ((fire & 2) && (WEP_CVAR_SEC(okshotgun, refire_type) == 0)) // Secondary attack
83         {
84                 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(okshotgun, refire)))
85                 {
86                         return;
87                 }
88                 // Ugly hack to reuse the fire mode of the blaster.
89                 makevectors(actor.v_angle);
90                 Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack
91                 actor.(weaponentity).m_weapon = WEP_BLASTER;
92                 W_Blaster_Attack(
93                         actor,
94                         weaponentity,
95                         WEP_BLASTER.m_id | HITTYPE_SECONDARY,
96                         WEP_CVAR_SEC(okshotgun, shotangle),
97                         WEP_CVAR_SEC(okshotgun, damage),
98                         WEP_CVAR_SEC(okshotgun, edgedamage),
99                         WEP_CVAR_SEC(okshotgun, radius),
100                         WEP_CVAR_SEC(okshotgun, force),
101                         WEP_CVAR_SEC(okshotgun, speed),
102                         WEP_CVAR_SEC(okshotgun, spread),
103                         WEP_CVAR_SEC(okshotgun, delay),
104                         WEP_CVAR_SEC(okshotgun, lifetime)
105                 );
106                 actor.(weaponentity).m_weapon = oldwep;
107                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(okshotgun, animtime), w_ready);
108         }
109 }
110
111 METHOD(OverkillShotgun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
112 {
113         float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(okshotgun, ammo);
114         ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_SHOTGUN.m_id]) >= WEP_CVAR_PRI(okshotgun, ammo);
115         return ammo_amount;
116 }
117
118 METHOD(OverkillShotgun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
119 {
120         return true; // Blaster secondary is unlimited.
121 }
122
123 METHOD(OverkillShotgun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
124 {
125         W_Reload(actor, weaponentity, WEP_CVAR_PRI(okshotgun, ammo), SND_RELOAD); // WEAPONTODO
126 }
127
128 METHOD(OverkillShotgun, wr_suicidemessage, Notification(entity thiswep))
129 {
130         return WEAPON_THINKING_WITH_PORTALS;
131 }
132
133 METHOD(OverkillShotgun, wr_killmessage, Notification(entity thiswep))
134 {
135         if(w_deathtype & HITTYPE_SECONDARY)
136                 return WEAPON_BLASTER_MURDER;
137         else
138                 return WEAPON_SHOTGUN_MURDER;
139 }
140
141 #endif
142 #ifdef CSQC
143 .float prevric;
144
145 METHOD(OverkillShotgun, wr_impacteffect, void(entity thiswep, entity actor))
146 {
147         vector org2 = w_org + w_backoff * 2;
148         pointparticles(EFFECT_SHOTGUN_IMPACT, org2, w_backoff * 1000, 1);
149         if(!w_issilent && time - actor.prevric > 0.25)
150         {
151                 if(w_random < 0.05)
152                         sound(actor, CH_SHOTS, SND_RIC_RANDOM(), VOL_BASE, ATTEN_NORM);
153                 actor.prevric = time;
154         }
155 }
156
157 #endif