]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/overkill/okshotgun.qc
Merge branch 'master' into Lyberta/StandaloneOverkillWeapons
[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 instagib hack to reuse the fire mode of the laser
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 = actor.(thiswep.ammo_field) >= 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         if (WEP_CVAR_SEC(okshotgun, ammo) == 0)
121         {
122                 return true;
123         }
124         float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(okshotgun, ammo);
125         ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_SHOTGUN.m_id]) >= WEP_CVAR_SEC(okshotgun, ammo);
126         return ammo_amount;
127 }
128
129 METHOD(OverkillShotgun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
130 {
131         W_Reload(actor, weaponentity, WEP_CVAR_PRI(okshotgun, ammo), SND_RELOAD); // WEAPONTODO
132 }
133
134 METHOD(OverkillShotgun, wr_suicidemessage, Notification(entity thiswep))
135 {
136         return WEAPON_THINKING_WITH_PORTALS;
137 }
138
139 METHOD(OverkillShotgun, wr_killmessage, Notification(entity thiswep))
140 {
141         if(w_deathtype & HITTYPE_SECONDARY)
142                 return WEAPON_BLASTER_MURDER;
143         else
144                 return WEAPON_SHOTGUN_MURDER;
145 }
146
147 #endif
148 #ifdef CSQC
149 .float prevric;
150
151 METHOD(OverkillShotgun, wr_impacteffect, void(entity thiswep, entity actor))
152 {
153         vector org2 = w_org + w_backoff * 2;
154         pointparticles(EFFECT_SHOTGUN_IMPACT, org2, w_backoff * 1000, 1);
155         if(!w_issilent && time - actor.prevric > 0.25)
156         {
157                 if(w_random < 0.05)
158                         sound(actor, CH_SHOTS, SND_RIC_RANDOM(), VOL_BASE, ATTEN_NORM);
159                 actor.prevric = time;
160         }
161 }
162
163 #endif