]> 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 .float okshotgun_primarytime;
7
8 METHOD(OverkillShotgun, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
9 {
10         if (vdist(actor.origin - actor.enemy.origin, >, WEP_CVAR_PRI(okshotgun, bot_range)))
11         {
12                 PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
13         }
14         else
15         {
16                 PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
17         }
18 }
19
20 METHOD(OverkillShotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
21 {
22         if (WEP_CVAR(okshotgun, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR_PRI(okshotgun, ammo)) // forced reload
23         {
24                 thiswep.wr_reload(thiswep, actor, weaponentity);
25                 return;
26         }
27         if (fire & 1) // Primary attack
28         {
29                 if (time >= actor.(weaponentity).okshotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary
30                 {
31                         if (weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(okshotgun, animtime)))
32                         {
33                                 W_Shotgun_Attack(thiswep, actor, weaponentity, true,
34                                         WEP_CVAR_PRI(okshotgun, ammo),
35                                         WEP_CVAR_PRI(okshotgun, damage),
36                                         WEP_CVAR_PRI(okshotgun, bullets),
37                                         WEP_CVAR_PRI(okshotgun, spread),
38                                         WEP_CVAR_PRI(okshotgun, solidpenetration),
39                                         WEP_CVAR_PRI(okshotgun, force));
40                                 actor.(weaponentity).okshotgun_primarytime = time + WEP_CVAR_PRI(okshotgun, refire) * W_WeaponRateFactor(actor);
41                                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(okshotgun, animtime), w_ready);
42                         }
43                 }
44         }
45         else if (fire & 2) // Secondary attack
46         {
47                 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(okshotgun, refire)))
48                 {
49                         return;
50                 }
51                 // ugly instagib hack to reuse the fire mode of the laser
52                 makevectors(actor.v_angle);
53                 Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack
54                 actor.(weaponentity).m_weapon = WEP_BLASTER;
55                 W_Blaster_Attack(
56                         actor,
57                         weaponentity,
58                         WEP_BLASTER.m_id | HITTYPE_SECONDARY,
59                         WEP_CVAR_SEC(okshotgun, shotangle),
60                         WEP_CVAR_SEC(okshotgun, damage),
61                         WEP_CVAR_SEC(okshotgun, edgedamage),
62                         WEP_CVAR_SEC(okshotgun, radius),
63                         WEP_CVAR_SEC(okshotgun, force),
64                         WEP_CVAR_SEC(okshotgun, speed),
65                         WEP_CVAR_SEC(okshotgun, spread),
66                         WEP_CVAR_SEC(okshotgun, delay),
67                         WEP_CVAR_SEC(okshotgun, lifetime)
68                 );
69                 actor.(weaponentity).m_weapon = oldwep;
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 = actor.(thiswep.ammo_field) >= 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         if (WEP_CVAR_SEC(okshotgun, ammo) == 0)
84         {
85                 return true;
86         }
87         float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(okshotgun, ammo);
88         ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_SHOTGUN.m_id]) >= WEP_CVAR_SEC(okshotgun, ammo);
89         return ammo_amount;
90 }
91
92 METHOD(OverkillShotgun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
93 {
94         W_Reload(actor, weaponentity, WEP_CVAR_PRI(okshotgun, ammo), SND_RELOAD); // WEAPONTODO
95 }
96
97 METHOD(OverkillShotgun, wr_suicidemessage, Notification(entity thiswep))
98 {
99         return WEAPON_THINKING_WITH_PORTALS;
100 }
101
102 METHOD(OverkillShotgun, wr_killmessage, Notification(entity thiswep))
103 {
104         if(w_deathtype & HITTYPE_SECONDARY)
105                 return WEAPON_BLASTER_MURDER;
106         else
107                 return WEAPON_SHOTGUN_MURDER;
108 }
109
110 #endif
111 #ifdef CSQC
112 .float prevric;
113
114 METHOD(OverkillShotgun, wr_impacteffect, void(entity thiswep, entity actor))
115 {
116         vector org2 = w_org + w_backoff * 2;
117         pointparticles(EFFECT_SHOTGUN_IMPACT, org2, w_backoff * 1000, 1);
118         if(!w_issilent && time - actor.prevric > 0.25)
119         {
120                 if(w_random < 0.05)
121                         sound(actor, CH_SHOTS, SND_RIC_RANDOM(), VOL_BASE, ATTEN_NORM);
122                 actor.prevric = time;
123         }
124 }
125
126 #endif