]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_shotgun.qc
leileilol's effect updates
[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         W_Smoke(w_shotorg + v_forward * 8, v_forward, 12);
23         //te_smallflash(w_shotorg);
24
25         // casing code
26         if (cvar("g_casings") >= 1)
27                 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);
28
29         // muzzle flash for 1st person view
30         flash = spawn();
31         setorigin(flash, '53 5 0');
32         setmodel(flash, "models/uziflash.md3"); // precision set below
33         setattachment(flash, self.weaponentity, "bone01");
34         flash.owner = self;
35         flash.viewmodelforclient = self;
36         flash.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient;
37         flash.scale = 1.2;
38         flash.think = SUB_Remove;
39         flash.nextthink = time + 0.06;
40         flash.angles_z = flash.v_angle_z + random() * 180;
41         flash.alpha = 1;
42         flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
43
44 }
45
46 void W_Shotgun_Attack2 (void)
47 {
48         float   sc;
49         float   bullets;
50         float   d;
51         float   f;
52         float   spread;
53
54         bullets = cvar("g_balance_shotgun_secondary_bullets");
55         d = cvar("g_balance_shotgun_secondary_damage");
56         f = cvar("g_balance_shotgun_secondary_force");
57         spread = cvar("g_balance_shotgun_secondary_spread");
58
59         W_SetupShot (self, '11 8 -8', TRUE, 5, "weapons/shotgun_fire.wav");
60         for (sc = 0;sc < bullets;sc = sc + 1)
61                 fireBullet (w_shotorg, w_shotdir, spread, d, f, IT_SHOTGUN, sc < 3);
62         if (cvar("g_use_ammunition"))
63                 self.ammo_shells = self.ammo_shells - cvar("g_balance_shotgun_secondary_ammo");
64
65         W_Smoke(w_shotorg + v_forward * 8, v_forward, 12);
66         //te_smallflash(w_shotorg);
67
68         // casing code
69         if (cvar("g_casings") >= 1)
70                 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);
71 }
72
73 // weapon frames
74 void()  shotgun_fire2_03 =
75 {
76         W_Shotgun_Attack2();
77         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_secondary_animtime"), w_ready);
78 }
79 void()  shotgun_fire2_02 =
80 {
81         W_Shotgun_Attack2();
82         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_secondary_animtime"), shotgun_fire2_03);
83 }
84
85 float(float req) w_shotgun =
86 {
87         if (req == WR_AIM)
88                 if(vlen(self.origin-self.enemy.origin)>200)
89                         self.button0 = bot_aim(1000000, 0, 0.001, FALSE);
90                 else
91                         self.button3 = bot_aim(1000000, 0, 0.001, FALSE);
92         else if (req == WR_THINK)
93         {
94                 if (self.button0)
95                 if (weapon_prepareattack(0, cvar("g_balance_shotgun_primary_refire")))
96                 {
97                         W_Shotgun_Attack();
98                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_primary_animtime"), w_ready);
99                 }
100                 if (self.button3)
101                 if (weapon_prepareattack(1, cvar("g_balance_shotgun_secondary_refire")))
102                 {
103                         W_Shotgun_Attack2();
104                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_secondary_animtime"), shotgun_fire2_02);
105                 }
106         }
107         else if (req == WR_PRECACHE)
108         {
109                 precache_model ("models/tracer.mdl");
110                 precache_model ("models/weapons/g_shotgun.md3");
111                 precache_model ("models/weapons/v_shotgun.md3");
112                 precache_model ("models/weapons/w_shotgun.zym");
113                 precache_sound ("misc/itempickup.wav");
114                 precache_sound ("weapons/ric1.wav");
115                 precache_sound ("weapons/ric2.wav");
116                 precache_sound ("weapons/ric3.wav");
117                 precache_sound ("weapons/shotgun_fire.wav");
118                 precache_sound ("weapons/tink1.wav");
119                 if (cvar("g_casings") >= 1)
120                         precache_model ("models/casing_shell.mdl");
121         }
122         else if (req == WR_SETUP)
123                 weapon_setup(WEP_SHOTGUN, "shotgun", IT_SHELLS);
124         else if (req == WR_CHECKAMMO1)
125                 return self.ammo_shells >= cvar("g_balance_shotgun_primary_ammo");
126         else if (req == WR_CHECKAMMO2)
127                 return self.ammo_shells >= cvar("g_balance_shotgun_secondary_ammo") * 3;
128         else if (req == WR_REGISTER)
129                 weapon_register(WEP_SHOTGUN, min(cvar("g_balance_shotgun_primary_ammo"), cvar("g_balance_shotgun_secondary_ammo")));
130         return TRUE;
131 };