]> 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 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                 // Ugly hack to reuse the fire mode of the blaster.
23                 makevectors(actor.v_angle);
24                 W_Blaster_Attack(
25                         actor,
26                         weaponentity,
27                         WEP_BLASTER.m_id | HITTYPE_SECONDARY,
28                         WEP_CVAR_SEC(okshotgun, shotangle),
29                         WEP_CVAR_SEC(okshotgun, damage),
30                         WEP_CVAR_SEC(okshotgun, edgedamage),
31                         WEP_CVAR_SEC(okshotgun, radius),
32                         WEP_CVAR_SEC(okshotgun, force),
33                         WEP_CVAR_SEC(okshotgun, speed),
34                         WEP_CVAR_SEC(okshotgun, spread),
35                         WEP_CVAR_SEC(okshotgun, delay),
36                         WEP_CVAR_SEC(okshotgun, lifetime)
37                 );
38                 if ((actor.(weaponentity).wframe == WFRAME_IDLE) ||
39                         (actor.(weaponentity).wframe == WFRAME_FIRE2))
40                 {
41                         // Set secondary fire animation.
42                         vector a = '0 0 0';
43                         actor.(weaponentity).wframe = WFRAME_FIRE2;
44                         a = actor.(weaponentity).anim_fire2;
45                         a.z *= g_weaponratefactor;
46                         FOREACH_CLIENT(true, LAMBDA(
47                                 if (it == actor || (IS_SPEC(it) && it.enemy == actor))
48                                 {
49                                         wframe_send(it, actor.(weaponentity), a, true);
50                                 }
51                         ));
52                         animdecide_setaction(actor, ANIMACTION_SHOOT, true);
53                 }
54         }
55         if (WEP_CVAR(okshotgun, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR_PRI(okshotgun, ammo))
56         {
57                 // Forced reload
58                 thiswep.wr_reload(thiswep, actor, weaponentity);
59                 return;
60         }
61         if (fire & 1) // Primary attack
62         {
63                 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(okshotgun, animtime)))
64                 {
65                         return;
66                 }
67                 W_Shotgun_Attack(thiswep, actor, weaponentity, true,
68                         WEP_CVAR_PRI(okshotgun, ammo),
69                         WEP_CVAR_PRI(okshotgun, damage),
70                         WEP_CVAR_PRI(okshotgun, bullets),
71                         WEP_CVAR_PRI(okshotgun, spread),
72                         WEP_CVAR_PRI(okshotgun, solidpenetration),
73                         WEP_CVAR_PRI(okshotgun, force));
74                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(okshotgun, animtime), w_ready);
75                 return;
76         }
77         if ((fire & 2) && (WEP_CVAR_SEC(okshotgun, refire_type) == 0)) // Secondary attack
78         {
79                 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(okshotgun, refire)))
80                 {
81                         return;
82                 }
83                 // Ugly hack to reuse the fire mode of the blaster.
84                 makevectors(actor.v_angle);
85                 W_Blaster_Attack(
86                         actor,
87                         weaponentity,
88                         WEP_BLASTER.m_id | HITTYPE_SECONDARY,
89                         WEP_CVAR_SEC(okshotgun, shotangle),
90                         WEP_CVAR_SEC(okshotgun, damage),
91                         WEP_CVAR_SEC(okshotgun, edgedamage),
92                         WEP_CVAR_SEC(okshotgun, radius),
93                         WEP_CVAR_SEC(okshotgun, force),
94                         WEP_CVAR_SEC(okshotgun, speed),
95                         WEP_CVAR_SEC(okshotgun, spread),
96                         WEP_CVAR_SEC(okshotgun, delay),
97                         WEP_CVAR_SEC(okshotgun, lifetime)
98                 );
99                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(okshotgun, animtime), w_ready);
100         }
101 }
102
103 METHOD(OverkillShotgun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
104 {
105         float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(okshotgun, ammo);
106         ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_SHOTGUN.m_id]) >= WEP_CVAR_PRI(okshotgun, ammo);
107         return ammo_amount;
108 }
109
110 METHOD(OverkillShotgun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
111 {
112         return true; // Blaster secondary is unlimited.
113 }
114
115 METHOD(OverkillShotgun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
116 {
117         W_Reload(actor, weaponentity, WEP_CVAR_PRI(okshotgun, ammo), SND_RELOAD); // WEAPONTODO
118 }
119
120 METHOD(OverkillShotgun, wr_suicidemessage, Notification(entity thiswep))
121 {
122         return WEAPON_THINKING_WITH_PORTALS;
123 }
124
125 METHOD(OverkillShotgun, wr_killmessage, Notification(entity thiswep))
126 {
127         return WEAPON_OVERKILL_SHOTGUN_MURDER;
128 }
129
130 #endif
131 #ifdef CSQC
132 .float prevric;
133
134 METHOD(OverkillShotgun, wr_impacteffect, void(entity thiswep, entity actor))
135 {
136         vector org2 = w_org + w_backoff * 2;
137         pointparticles(EFFECT_SHOTGUN_IMPACT, org2, w_backoff * 1000, 1);
138         if(!w_issilent && time - actor.prevric > 0.25)
139         {
140                 if(w_random < 0.05)
141                         sound(actor, CH_SHOTS, SND_RIC_RANDOM(), VOL_BASE, ATTEN_NORM);
142                 actor.prevric = time;
143         }
144 }
145
146 #endif