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