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