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