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