]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_shotgun.qc
added muzzleflash effects for all weapons (most emit light, all emit
[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         local entity flash;
10
11         bullets = cvar("g_balance_shotgun_primary_bullets");
12         d = cvar("g_balance_shotgun_primary_damage");
13         f = cvar("g_balance_shotgun_primary_force");
14         spread = cvar("g_balance_shotgun_primary_spread");
15
16         W_SetupShot (self, '11 8 -8', TRUE, 5, "weapons/shotgun_fire.wav");
17         for (sc = 0;sc < bullets;sc = sc + 1)
18                 fireBullet (w_shotorg, w_shotdir, spread, d, f, IT_SHOTGUN, sc < 3);
19         if (cvar("g_use_ammunition"))
20                 self.ammo_shells = self.ammo_shells - cvar("g_balance_shotgun_primary_ammo");
21
22         pointparticles(particleeffectnum("shotgun_muzzleflash"), w_shotorg + v_forward * 6, v_forward * 1000, cvar("g_balance_shotgun_primary_ammo"));
23         //W_Smoke(w_shotorg + v_forward * 8, v_forward, 12);
24         //te_smallflash(w_shotorg);
25
26         // casing code
27         if (cvar("g_casings") >= 1)
28                 SpawnCasing (w_shotorg, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 - 30) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 1);
29
30         // muzzle flash for 1st person view
31         flash = spawn();
32         setorigin(flash, '53 5 0');
33         setmodel(flash, "models/uziflash.md3"); // precision set below
34         setattachment(flash, self.weaponentity, "bone01");
35         flash.owner = self;
36         flash.viewmodelforclient = self;
37         flash.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient;
38         flash.scale = 1.2;
39         flash.think = SUB_Remove;
40         flash.nextthink = time + 0.06;
41         flash.angles_z = flash.v_angle_z + random() * 180;
42         flash.alpha = 1;
43         flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
44
45 }
46
47 void W_Shotgun_Attack2 (void)
48 {
49         float   sc;
50         float   bullets;
51         float   d;
52         float   f;
53         float   spread;
54         local entity flash;
55
56         bullets = cvar("g_balance_shotgun_secondary_bullets");
57         d = cvar("g_balance_shotgun_secondary_damage");
58         f = cvar("g_balance_shotgun_secondary_force");
59         spread = cvar("g_balance_shotgun_secondary_spread");
60
61         W_SetupShot (self, '11 8 -8', TRUE, 5, "weapons/shotgun_fire.wav");
62         for (sc = 0;sc < bullets;sc = sc + 1)
63                 fireBullet (w_shotorg, w_shotdir, spread, d, f, IT_SHOTGUN, sc < 3);
64         if (cvar("g_use_ammunition"))
65                 self.ammo_shells = self.ammo_shells - cvar("g_balance_shotgun_secondary_ammo");
66
67         pointparticles(particleeffectnum("shotgun_muzzleflash"), w_shotorg + v_forward * 6, v_forward * 1000, cvar("g_balance_shotgun_secondary_ammo"));
68         //W_Smoke(w_shotorg + v_forward * 8, v_forward, 12);
69         //te_smallflash(w_shotorg);
70
71         // casing code
72         if (cvar("g_casings") >= 1)
73                 SpawnCasing (w_shotorg, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 - 30) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 1);
74
75         flash = spawn();
76         setorigin(flash, '53 5 0');
77         setmodel(flash, "models/uziflash.md3"); // precision set below
78         setattachment(flash, self.weaponentity, "bone01");
79         flash.owner = self;
80         flash.viewmodelforclient = self;
81         flash.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient;
82         flash.scale = 1.2;
83         flash.think = SUB_Remove;
84         flash.nextthink = time + 0.06;
85         flash.angles_z = flash.v_angle_z + random() * 180;
86         flash.alpha = 1;
87         flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
88 }
89
90 // weapon frames
91 void()  shotgun_fire2_03 =
92 {
93         W_Shotgun_Attack2();
94         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_secondary_animtime"), w_ready);
95 }
96 void()  shotgun_fire2_02 =
97 {
98         W_Shotgun_Attack2();
99         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_secondary_animtime"), shotgun_fire2_03);
100 }
101
102 float(float req) w_shotgun =
103 {
104         if (req == WR_AIM)
105                 if(vlen(self.origin-self.enemy.origin)>200)
106                         self.button0 = bot_aim(1000000, 0, 0.001, FALSE);
107                 else
108                         self.button3 = bot_aim(1000000, 0, 0.001, FALSE);
109         else if (req == WR_THINK)
110         {
111                 if (self.button0)
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.button3)
118                 if (weapon_prepareattack(1, cvar("g_balance_shotgun_secondary_refire")))
119                 {
120                         W_Shotgun_Attack2();
121                         weapon_thinkf(WFRAME_FIRE1, 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/tracer.mdl");
128                 precache_model ("models/weapons/g_shotgun.md3");
129                 precache_model ("models/weapons/v_shotgun.md3");
130                 precache_model ("models/weapons/w_shotgun.zym");
131                 precache_sound ("misc/itempickup.wav");
132                 precache_sound ("weapons/ric1.wav");
133                 precache_sound ("weapons/ric2.wav");
134                 precache_sound ("weapons/ric3.wav");
135                 precache_sound ("weapons/shotgun_fire.wav");
136                 precache_sound ("weapons/tink1.wav");
137                 if (cvar("g_casings") >= 1)
138                         precache_model ("models/casing_shell.mdl");
139         }
140         else if (req == WR_SETUP)
141                 weapon_setup(WEP_SHOTGUN, "shotgun", IT_SHELLS);
142         else if (req == WR_CHECKAMMO1)
143                 return self.ammo_shells >= cvar("g_balance_shotgun_primary_ammo");
144         else if (req == WR_CHECKAMMO2)
145                 return self.ammo_shells >= cvar("g_balance_shotgun_secondary_ammo") * 3;
146         else if (req == WR_REGISTER)
147                 weapon_register(WEP_SHOTGUN, min(cvar("g_balance_shotgun_primary_ammo"), cvar("g_balance_shotgun_secondary_ammo")));
148         return TRUE;
149 };