]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_hlac.qc
fix grenade launcher through floor
[divverent/nexuiz.git] / data / qcsrc / server / w_hlac.qc
1 .float HLAC_bulletcounter;
2 void W_HLAC_Touch (void)
3 {
4         PROJECTILE_TOUCH;
5
6         self.event_damage = SUB_Null;
7
8     RadiusDamage (self, self.owner, cvar("g_balance_hlac_primary_damage"), cvar("g_balance_hlac_primary_edgedamage"), cvar("g_balance_hlac_primary_radius"), world, cvar("g_balance_hlac_primary_force"), self.projectiledeathtype, other);
9
10         remove (self);
11 }
12
13 void W_HLAC_Touch2 (void)
14 {
15         PROJECTILE_TOUCH;
16
17         self.event_damage = SUB_Null;
18
19     RadiusDamage (self, self.owner, cvar("g_balance_hlac_secondary_damage"), cvar("g_balance_hlac_secondary_edgedamage"), cvar("g_balance_hlac_secondary_radius"), world, cvar("g_balance_hlac_secondary_force"), self.projectiledeathtype, other);
20
21         remove (self);
22 }
23
24 void W_HLAC_Attack (void)
25 {
26         local entity missile;
27     float spread;
28
29     if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
30     {
31         self.ammo_cells = self.ammo_cells - cvar("g_balance_hlac_primary_ammo");
32     }
33
34     spread = cvar("g_balance_hlac_primary_spread_min") + (cvar("g_balance_hlac_primary_spread_add") * self.HLAC_bulletcounter);
35     spread = min(spread,cvar("g_balance_hlac_primary_spread_max"));
36     if(self.crouch)
37         spread = spread * cvar("g_balance_hlac_primary_spread_crouchmod");
38
39         W_SetupShot (self, FALSE, 3, "weapons/lasergun_fire.wav");
40         pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
41         if (!g_norecoil)
42         {
43                 self.punchangle_x = random () - 0.5;
44                 self.punchangle_y = random () - 0.5;
45         }
46
47         missile = spawn ();
48         missile.owner = self;
49         missile.classname = "hlacbolt";
50         // missile.dmg = issecondary;
51         missile.bot_dodge = TRUE;
52
53     missile.bot_dodgerating = cvar("g_balance_hlac_primary_damage");
54
55         missile.movetype = MOVETYPE_FLY;
56         missile.solid = SOLID_BBOX;
57
58         setorigin (missile, w_shotorg);
59         setsize(missile, '0 0 0', '0 0 0');
60
61     missile.velocity = (w_shotdir + randomvec() * spread) * cvar("g_balance_hlac_primary_speed");
62
63         W_SetupProjectileVelocity(missile);
64         missile.angles = vectoangles (missile.velocity);
65
66         missile.touch = W_HLAC_Touch;
67         missile.think = SUB_Remove;
68
69     missile.nextthink = time + cvar("g_balance_hlac_primary_lifetime");
70
71         missile.flags = FL_PROJECTILE;
72         missile.projectiledeathtype = WEP_HLAC;
73
74         CSQCProjectile(missile, TRUE, PROJECTILE_HLAC, TRUE);
75 }
76
77 void W_HLAC_Attack2f (void)
78 {
79         local entity missile;
80     float spread;
81
82     spread = cvar("g_balance_hlac_secondary_spread");
83
84
85     if(self.crouch)
86         spread = spread * cvar("g_balance_hlac_secondary_spread_crouchmod");
87
88         W_SetupShot (self, FALSE, 3, "weapons/lasergun_fire.wav");
89         pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
90
91         missile = spawn ();
92         missile.owner = self;
93         missile.classname = "hlacbolt";
94         // missile.dmg = issecondary;
95         missile.bot_dodge = TRUE;
96
97     missile.bot_dodgerating = cvar("g_balance_hlac_secondary_damage");
98
99         missile.movetype = MOVETYPE_FLY;
100         missile.solid = SOLID_BBOX;
101
102         setorigin (missile, w_shotorg);
103         setsize(missile, '0 0 0', '0 0 0');
104
105     missile.velocity = (w_shotdir + randomvec() * spread) * cvar("g_balance_hlac_secondary_speed");
106
107         W_SetupProjectileVelocity(missile);
108         missile.angles = vectoangles (missile.velocity);
109
110         missile.touch = W_HLAC_Touch2;
111         missile.think = SUB_Remove;
112
113     missile.nextthink = time + cvar("g_balance_hlac_secondary_lifetime");
114
115         missile.flags = FL_PROJECTILE;
116         missile.projectiledeathtype = WEP_HLAC | HITTYPE_SECONDARY;
117
118         CSQCProjectile(missile, TRUE, PROJECTILE_HLAC, TRUE);
119 }
120
121 void W_HLAC_Attack2 (void)
122 {
123     float i;
124
125     if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
126     {
127         self.ammo_cells = self.ammo_cells - cvar("g_balance_hlac_secondary_ammo");
128     }
129
130     for(i=cvar("g_balance_hlac_secondary_shots");i>0;--i)
131         W_HLAC_Attack2f();
132
133         if (!g_norecoil)
134         {
135                 self.punchangle_x = random () - 0.5;
136                 self.punchangle_y = random () - 0.5;
137         }
138
139         // ATTACK_FINISHED(self) = time + cvar("g_balance_hlac_secondary_refire");
140 }
141
142
143 // weapon frames
144 void HLAC_fire1_02()
145 {
146         if(self.weapon != self.switchweapon) // abort immediately if switching
147         {
148                 w_ready();
149                 return;
150         }
151
152         if (self.BUTTON_ATCK)
153         {
154                 if (!weapon_action(self.weapon, WR_CHECKAMMO1))
155                 {
156                         W_SwitchWeapon_Force(self, w_getbestweapon(self));
157                         w_ready();
158                         return;
159                 }
160
161                 ATTACK_FINISHED(self) = time + cvar("g_balance_hlac_primary_refire");
162                 W_HLAC_Attack();
163                 self.HLAC_bulletcounter = self.HLAC_bulletcounter + 1;
164         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hlac_primary_refire"), HLAC_fire1_02);
165         }
166         else
167         {
168                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hlac_primary_animtime"), w_ready);
169         }
170 };
171
172 void spawnfunc_weapon_hlac (void)
173 {
174         weapon_defaultspawnfunc(WEP_HLAC);
175 }
176
177 float w_hlac(float req)
178 {
179         if (req == WR_AIM)
180         self.BUTTON_ATCK = bot_aim(cvar("g_balance_hlac_primary_speed"), 0, cvar("g_balance_hlac_primary_lifetime"), FALSE);
181         else if (req == WR_THINK)
182         {
183                 if (self.BUTTON_ATCK)
184                 if (weapon_prepareattack(0, cvar("g_balance_hlac_primary_refire")))
185                 {
186                         self.HLAC_bulletcounter = 0;
187                         W_HLAC_Attack();
188                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hlac_primary_refire"), HLAC_fire1_02);
189                 }
190
191                 if (self.BUTTON_ATCK2)
192                 if (weapon_prepareattack(1, cvar("g_balance_hlac_secondary_refire")))
193                 {
194                         W_HLAC_Attack2();
195                         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_hlac_secondary_animtime"), w_ready);
196                 }
197
198         }
199         else if (req == WR_PRECACHE)
200         {
201         precache_model ("models/weapons/g_hlac.md3");
202                 precache_model ("models/weapons/v_hlac.md3");
203                 precache_model ("models/weapons/h_hlac.dpm");
204                 precache_sound ("weapons/lasergun_fire.wav");
205
206         }
207         else if (req == WR_SETUP)
208                 weapon_setup(WEP_HLAC);
209         else if (req == WR_CHECKAMMO1)
210                 return self.ammo_cells >= cvar("g_balance_hlac_primary_ammo");
211         else if (req == WR_CHECKAMMO2)
212                 return self.ammo_cells >= cvar("g_balance_hlac_secondary_ammo");
213         else if (req == WR_SUICIDEMESSAGE)
214                 w_deathtypestring = "should have used a smaller gun";
215         else if (req == WR_KILLMESSAGE)
216                 w_deathtypestring = "was cut down by";
217         return TRUE;
218 };