]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/w_hagar.qc
First phase, second part.
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_hagar.qc
1 #ifdef REGISTER_WEAPON
2 REGISTER_WEAPON(HAGAR, w_hagar, IT_ROCKETS, 8, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "hagar", "hagar", _("Hagar"))
3 #else
4 #ifdef SVQC
5 // NO bounce protection, as bounces are limited!
6
7 void W_Hagar_Explode (void)
8 {
9         self.event_damage = SUB_Null;
10         RadiusDamage (self, self.realowner, autocvar_g_balance_hagar_primary_damage, autocvar_g_balance_hagar_primary_edgedamage, autocvar_g_balance_hagar_primary_radius, world, autocvar_g_balance_hagar_primary_force, self.projectiledeathtype, other);
11
12         remove (self);
13 }
14
15 void W_Hagar_Explode2 (void)
16 {
17         self.event_damage = SUB_Null;
18         RadiusDamage (self, self.realowner, autocvar_g_balance_hagar_secondary_damage, autocvar_g_balance_hagar_secondary_edgedamage, autocvar_g_balance_hagar_secondary_radius, world, autocvar_g_balance_hagar_secondary_force, self.projectiledeathtype, other);
19
20         remove (self);
21 }
22
23 void W_Hagar_Touch (void)
24 {
25         PROJECTILE_TOUCH;
26         self.use ();
27 }
28
29 void W_Hagar_Touch2 (void)
30 {
31         PROJECTILE_TOUCH;
32
33         if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
34                 self.use();
35         } else {
36                 self.cnt++;
37                 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
38                 self.angles = vectoangles (self.velocity);
39                 self.owner = world;
40                 self.projectiledeathtype |= HITTYPE_BOUNCE;
41         }
42 }
43
44 void W_Hagar_Attack (void)
45 {
46         local entity missile;
47
48         // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
49         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
50         {
51                 if(autocvar_g_balance_hagar_reload_ammo)
52                 {
53                         self.clip_load -= autocvar_g_balance_hagar_primary_ammo;
54                         self.weapon_load[WEP_HAGAR] = self.clip_load;
55                 }
56                 else
57                         self.ammo_rockets -= autocvar_g_balance_hagar_primary_ammo;
58         }
59
60         W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_primary_damage);
61
62         pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
63
64         missile = spawn ();
65         missile.owner = missile.realowner = self;
66         missile.classname = "missile";
67         missile.bot_dodge = TRUE;
68         missile.bot_dodgerating = autocvar_g_balance_hagar_primary_damage;
69         missile.touch = W_Hagar_Touch;
70         missile.use = W_Hagar_Explode;
71         missile.think = adaptor_think2use_hittype_splash;
72         missile.nextthink = time + autocvar_g_balance_hagar_primary_lifetime;
73         PROJECTILE_MAKETRIGGER(missile);
74         missile.projectiledeathtype = WEP_HAGAR;
75         setorigin (missile, w_shotorg);
76         setsize(missile, '0 0 0', '0 0 0');
77
78         missile.movetype = MOVETYPE_FLY;
79         W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_primary);
80
81         missile.angles = vectoangles (missile.velocity);
82         missile.flags = FL_PROJECTILE;
83
84         CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
85
86         other = missile; MUTATOR_CALLHOOK(EditProjectile);
87 }
88
89 void W_Hagar_Attack2 (void)
90 {
91         local entity missile;
92
93         // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
94         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
95         {
96                 if(autocvar_g_balance_hagar_reload_ammo)
97                 {
98                         self.clip_load -= autocvar_g_balance_hagar_secondary_ammo;
99                         self.weapon_load[WEP_HAGAR] = self.clip_load;
100                 }
101                 else
102                         self.ammo_rockets -= autocvar_g_balance_hagar_secondary_ammo;
103         }
104
105         W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_secondary_damage);
106
107         pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
108
109         missile = spawn ();
110         missile.owner = missile.realowner = self;
111         missile.classname = "missile";
112         missile.bot_dodge = TRUE;
113         missile.bot_dodgerating = autocvar_g_balance_hagar_secondary_damage;
114         missile.touch = W_Hagar_Touch2;
115         missile.cnt = 0;
116         missile.use = W_Hagar_Explode2;
117         missile.think = adaptor_think2use_hittype_splash;
118         missile.nextthink = time + autocvar_g_balance_hagar_secondary_lifetime_min + random() * autocvar_g_balance_hagar_secondary_lifetime_rand;
119         PROJECTILE_MAKETRIGGER(missile);
120         missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
121         setorigin (missile, w_shotorg);
122         setsize(missile, '0 0 0', '0 0 0');
123
124         missile.movetype = MOVETYPE_BOUNCEMISSILE;
125         W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_secondary);
126
127         missile.angles = vectoangles (missile.velocity);
128         missile.flags = FL_PROJECTILE;
129
130         CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
131
132         other = missile; MUTATOR_CALLHOOK(EditProjectile);
133 }
134
135 void spawnfunc_weapon_hagar (void)
136 {
137         weapon_defaultspawnfunc(WEP_HAGAR);
138 }
139
140 float w_hagar(float req)
141 {
142         float ammo_amount;
143         if (req == WR_AIM)
144                 if (random()>0.15)
145                         self.BUTTON_ATCK = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
146                 else
147                 {
148                         // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
149                         self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
150                 }
151         else if (req == WR_THINK)
152         {
153                 if(autocvar_g_balance_hagar_reload_ammo && self.clip_load < min(autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_secondary_ammo)) // forced reload
154                         weapon_action(self.weapon, WR_RELOAD);
155                 else if (self.BUTTON_ATCK)
156                 {
157                         if (weapon_prepareattack(0, autocvar_g_balance_hagar_primary_refire))
158                         {
159                                 W_Hagar_Attack();
160                                 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hagar_primary_refire, w_ready);
161                         }
162                 }
163                 else if (self.BUTTON_ATCK2 && autocvar_g_balance_hagar_secondary)
164                 {
165                         if (weapon_prepareattack(1, autocvar_g_balance_hagar_secondary_refire))
166                         {
167                                 W_Hagar_Attack2();
168                                 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hagar_secondary_refire, w_ready);
169                         }
170                 }
171         }
172         else if (req == WR_PRECACHE)
173         {
174                 precache_model ("models/weapons/g_hagar.md3");
175                 precache_model ("models/weapons/v_hagar.md3");
176                 precache_model ("models/weapons/h_hagar.iqm");
177                 precache_sound ("weapons/hagar_fire.wav");
178                 precache_sound ("weapons/reload.wav");
179         }
180         else if (req == WR_SETUP)
181         {
182                 weapon_setup(WEP_HAGAR);
183         }
184         else if (req == WR_CHECKAMMO1)
185         {
186                 ammo_amount = self.ammo_rockets >= autocvar_g_balance_hagar_primary_ammo;
187                 ammo_amount += self.weapon_load[WEP_HAGAR] >= autocvar_g_balance_hagar_primary_ammo;
188                 return ammo_amount;
189         }
190         else if (req == WR_CHECKAMMO2)
191         {
192                 ammo_amount = self.ammo_rockets >= autocvar_g_balance_hagar_secondary_ammo;
193                 ammo_amount += self.weapon_load[WEP_HAGAR] >= autocvar_g_balance_hagar_secondary_ammo;
194                 return ammo_amount;
195         }
196         else if (req == WR_RELOAD)
197         {
198                 W_Reload(ammo_rockets, min(autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_secondary_ammo), autocvar_g_balance_hagar_reload_ammo, autocvar_g_balance_hagar_reload_time, "weapons/reload.wav");
199         }
200         return TRUE;
201 };
202 #endif
203 #ifdef CSQC
204 float w_hagar(float req)
205 {
206         if(req == WR_IMPACTEFFECT)
207         {
208                 vector org2;
209                 org2 = w_org + w_backoff * 6;
210                 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
211                 if(!w_issilent)
212                 {
213                         if (w_random<0.15)
214                                 sound(self, CHAN_PROJECTILE, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
215                         else if (w_random<0.7)
216                                 sound(self, CHAN_PROJECTILE, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
217                         else
218                                 sound(self, CHAN_PROJECTILE, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
219                 }
220         }
221         else if(req == WR_PRECACHE)
222         {
223                 precache_sound("weapons/hagexp1.wav");
224                 precache_sound("weapons/hagexp2.wav");
225                 precache_sound("weapons/hagexp3.wav");
226         }
227         else if (req == WR_SUICIDEMESSAGE)
228                 w_deathtypestring = _("%s played with tiny rockets");
229         else if (req == WR_KILLMESSAGE)
230         {
231                 if(w_deathtype & HITTYPE_BOUNCE) // must be secondary; unchecked: SPLASH
232                         w_deathtypestring = _("%s hoped %s's missiles wouldn't bounce");
233                 else // unchecked: SPLASH, SECONDARY
234                         w_deathtypestring = _("%s was pummeled by %s");
235         }
236         return TRUE;
237 }
238 #endif
239 #endif