]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_shotgun.qc
disable weapon throwing in mode 1 of weapon_stay, add a g_weapon_throwable cvar ...
[divverent/nexuiz.git] / data / qcsrc / server / w_shotgun.qc
1 void W_Shotgun_Attack (void)
2 {
3         float   sc;
4         float   ammoamount;
5         float   bullets;
6         float   d;
7         float   f;
8         float   spread;
9         float   bulletspeed;
10         float   bulletconstant;
11         local entity flash;
12
13         ammoamount = cvar("g_balance_shotgun_primary_ammo");
14         bullets = cvar("g_balance_shotgun_primary_bullets");
15         d = cvar("g_balance_shotgun_primary_damage");
16         f = cvar("g_balance_shotgun_primary_force");
17         spread = cvar("g_balance_shotgun_primary_spread");
18         bulletspeed = cvar("g_balance_shotgun_primary_speed");
19         bulletconstant = cvar("g_balance_shotgun_primary_bulletconstant");
20
21         W_SetupShot (self, cvar("g_antilag_bullets") && bulletspeed >= cvar("g_antilag_bullets"), 5, "weapons/shotgun_fire.wav", cvar("g_balance_shotgun_primary_damage"));
22         for (sc = 0;sc < bullets;sc = sc + 1)
23                 fireBallisticBullet(w_shotorg, w_shotdir, spread, bulletspeed, 5, d, 0, f, WEP_SHOTGUN, 0, 1, bulletconstant);
24         endFireBallisticBullet();
25         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
26                 self.ammo_shells = self.ammo_shells - ammoamount;
27
28         pointparticles(particleeffectnum("shotgun_muzzleflash"), w_shotorg, w_shotdir * 1000, cvar("g_balance_shotgun_primary_ammo"));
29
30         // casing code
31         if (cvar("g_casings") >= 1)
32                 for (sc = 0;sc < ammoamount;sc = sc + 1)
33                         SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 30) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 1, self);
34
35         // muzzle flash for 1st person view
36         flash = spawn();
37         setmodel(flash, "models/uziflash.md3"); // precision set below
38         flash.think = SUB_Remove;
39         flash.nextthink = time + 0.06;
40         flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
41         W_AttachToShotorg(flash, '5 0 0');
42
43 }
44
45 void W_Shotgun_Attack2 (void)
46 {
47         float   sc;
48         float   ammoamount;
49         float   bullets;
50         float   d;
51         float   f;
52         float   spread;
53         float   bulletspeed;
54         float   bulletconstant;
55         local entity flash;
56
57         ammoamount = cvar("g_balance_shotgun_secondary_ammo");
58         bullets = cvar("g_balance_shotgun_secondary_bullets");
59         d = cvar("g_balance_shotgun_secondary_damage");
60         f = cvar("g_balance_shotgun_secondary_force");
61         spread = cvar("g_balance_shotgun_secondary_spread");
62         bulletspeed = cvar("g_balance_shotgun_secondary_speed");
63         bulletconstant = cvar("g_balance_shotgun_secondary_bulletconstant");
64
65         W_SetupShot (self, cvar("g_antilag_bullets") && bulletspeed >= cvar("g_antilag_bullets"), 5, "weapons/shotgun_fire.wav", cvar("g_balance_shotgun_secondary_damage"));
66         for (sc = 0;sc < bullets;sc = sc + 1)
67                 fireBallisticBullet(w_shotorg, w_shotdir, spread, bulletspeed, 5, d, 0, f, WEP_SHOTGUN | HITTYPE_SECONDARY, 0, 1, bulletconstant);
68         endFireBallisticBullet();
69         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
70                 self.ammo_shells = self.ammo_shells - ammoamount;
71
72         pointparticles(particleeffectnum("shotgun_muzzleflash"), w_shotorg, w_shotdir * 1000, cvar("g_balance_shotgun_secondary_ammo"));
73
74         // casing code
75         if (cvar("g_casings") >= 1)
76                 for (sc = 0;sc < ammoamount;sc = sc + 1)
77                         SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 30) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 1, self);
78
79         flash = spawn();
80         setmodel(flash, "models/uziflash.md3"); // precision set below
81         flash.scale = 1.2;
82         flash.think = SUB_Remove;
83         flash.nextthink = time + 0.06;
84         flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
85         W_AttachToShotorg(flash, '5 0 0');
86 }
87
88 // weapon frames
89 void shotgun_fire2_03()
90 {
91         W_Shotgun_Attack2();
92         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_shotgun_secondary_animtime"), w_ready);
93 }
94 void shotgun_fire2_02()
95 {
96         W_Shotgun_Attack2();
97         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_shotgun_secondary_animtime"), shotgun_fire2_03);
98 }
99
100 void spawnfunc_weapon_shotgun(); // defined in t_items.qc
101
102 float w_shotgun(float req)
103 {
104         if (req == WR_AIM)
105                 if(vlen(self.origin-self.enemy.origin)>200)
106                         self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE);
107                 else
108                         self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE);
109         else if (req == WR_THINK)
110         {
111                 if (self.BUTTON_ATCK)
112                 if (weapon_prepareattack(0, cvar("g_balance_shotgun_primary_refire")))
113                 {
114                         W_Shotgun_Attack();
115                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_primary_animtime"), w_ready);
116                 }
117                 if (self.BUTTON_ATCK2)
118                 if (weapon_prepareattack(1, cvar("g_balance_shotgun_secondary_refire")))
119                 {
120                         W_Shotgun_Attack2();
121                         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_shotgun_secondary_animtime"), shotgun_fire2_02);
122                 }
123         }
124         else if (req == WR_PRECACHE)
125         {
126                 precache_model ("models/uziflash.md3");
127                 precache_model ("models/weapons/g_shotgun.md3");
128                 precache_model ("models/weapons/v_shotgun.md3");
129                 precache_model ("models/weapons/h_shotgun.dpm");
130                 precache_sound ("misc/itempickup.wav");
131                 precache_sound ("weapons/shotgun_fire.wav");
132         }
133         else if (req == WR_SETUP)
134                 weapon_setup(WEP_SHOTGUN);
135         else if (req == WR_CHECKAMMO1)
136                 return self.ammo_shells >= cvar("g_balance_shotgun_primary_ammo");
137         else if (req == WR_CHECKAMMO2)
138                 return self.ammo_shells >= cvar("g_balance_shotgun_secondary_ammo") * 3;
139         else if (req == WR_SUICIDEMESSAGE)
140                 w_deathtypestring = "did the impossible";
141         else if (req == WR_KILLMESSAGE)
142         {
143                 w_deathtypestring = "was gunned by"; // unchecked: SECONDARY
144         }
145         return TRUE;
146 };