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