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