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