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