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