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