make weapon death messages translatable
[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_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 void W_Hagar_Explode (void)
7 {
8         self.event_damage = SUB_Null;
9         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);
10
11         remove (self);
12 }
13
14 void W_Hagar_Explode2 (void)
15 {
16         self.event_damage = SUB_Null;
17         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);
18
19         remove (self);
20 }
21
22 void W_Hagar_Touch (void)
23 {
24         PROJECTILE_TOUCH;
25         self.use ();
26 }
27
28 void W_Hagar_Touch2 (void)
29 {
30         PROJECTILE_TOUCH;
31
32         if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
33                 self.use();
34         } else {
35                 self.cnt++;
36                 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
37                 self.angles = vectoangles (self.velocity);
38                 self.owner = world;
39                 self.projectiledeathtype |= HITTYPE_BOUNCE;
40         }
41 }
42
43 void W_Hagar_Attack (void)
44 {
45         local entity missile;
46
47         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
48                 self.ammo_rockets = self.ammo_rockets - autocvar_g_balance_hagar_primary_ammo;
49         W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_primary_damage);
50
51         pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
52
53         missile = spawn ();
54         missile.owner = missile.realowner = self;
55         missile.classname = "missile";
56         missile.bot_dodge = TRUE;
57         missile.bot_dodgerating = autocvar_g_balance_hagar_primary_damage;
58         missile.touch = W_Hagar_Touch;
59         missile.use = W_Hagar_Explode;
60         missile.think = adaptor_think2use_hittype_splash;
61         missile.nextthink = time + autocvar_g_balance_hagar_primary_lifetime;
62         PROJECTILE_MAKETRIGGER(missile);
63         missile.projectiledeathtype = WEP_HAGAR;
64         setorigin (missile, w_shotorg);
65         setsize(missile, '0 0 0', '0 0 0');
66
67         missile.movetype = MOVETYPE_FLY;
68         W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_primary);
69
70         missile.angles = vectoangles (missile.velocity);
71         missile.flags = FL_PROJECTILE;
72
73         CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
74
75         other = missile; MUTATOR_CALLHOOK(EditProjectile);
76 }
77
78 void W_Hagar_Attack2 (void)
79 {
80         local entity missile;
81
82         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
83                 self.ammo_rockets = self.ammo_rockets - autocvar_g_balance_hagar_secondary_ammo;
84         W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_secondary_damage);
85
86         pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
87
88         missile = spawn ();
89         missile.owner = missile.realowner = self;
90         missile.classname = "missile";
91         missile.bot_dodge = TRUE;
92         missile.bot_dodgerating = autocvar_g_balance_hagar_secondary_damage;
93         missile.touch = W_Hagar_Touch2;
94         missile.cnt = 0;
95         missile.use = W_Hagar_Explode2;
96         missile.think = adaptor_think2use_hittype_splash;
97         missile.nextthink = time + autocvar_g_balance_hagar_secondary_lifetime_min + random() * autocvar_g_balance_hagar_secondary_lifetime_rand;
98         PROJECTILE_MAKETRIGGER(missile);
99         missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
100         setorigin (missile, w_shotorg);
101         setsize(missile, '0 0 0', '0 0 0');
102
103         missile.movetype = MOVETYPE_BOUNCEMISSILE;
104         W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_secondary);
105
106         missile.angles = vectoangles (missile.velocity);
107         missile.flags = FL_PROJECTILE;
108
109         CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
110
111         other = missile; MUTATOR_CALLHOOK(EditProjectile);
112 }
113
114 void spawnfunc_weapon_hagar (void)
115 {
116         weapon_defaultspawnfunc(WEP_HAGAR);
117 }
118
119 float w_hagar(float req)
120 {
121         if (req == WR_AIM)
122                 if (random()>0.15)
123                         self.BUTTON_ATCK = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
124                 else
125                 {
126                         // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
127                         self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
128                 }
129         else if (req == WR_THINK)
130         {
131                 if (self.BUTTON_ATCK)
132                 if (weapon_prepareattack(0, autocvar_g_balance_hagar_primary_refire))
133                 {
134                         W_Hagar_Attack();
135                         weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hagar_primary_refire, w_ready);
136                 }
137                 if (self.BUTTON_ATCK2 && autocvar_g_balance_hagar_secondary)
138                 if (weapon_prepareattack(1, autocvar_g_balance_hagar_secondary_refire))
139                 {
140                         W_Hagar_Attack2();
141                         weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hagar_secondary_refire, w_ready);
142                 }
143         }
144         else if (req == WR_PRECACHE)
145         {
146                 precache_model ("models/weapons/g_hagar.md3");
147                 precache_model ("models/weapons/v_hagar.md3");
148                 precache_model ("models/weapons/h_hagar.iqm");
149                 precache_sound ("weapons/hagar_fire.wav");
150         }
151         else if (req == WR_SETUP)
152                 weapon_setup(WEP_HAGAR);
153         else if (req == WR_CHECKAMMO1)
154                 return self.ammo_rockets >= autocvar_g_balance_hagar_primary_ammo;
155         else if (req == WR_CHECKAMMO2)
156                 return self.ammo_rockets >= autocvar_g_balance_hagar_secondary_ammo;
157         return TRUE;
158 };
159 #endif
160 #ifdef CSQC
161 float w_hagar(float req)
162 {
163         if(req == WR_IMPACTEFFECT)
164         {
165                 vector org2;
166                 org2 = w_org + w_backoff * 6;
167                 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
168                 if(!w_issilent)
169                 {
170                         if (w_random<0.15)
171                                 sound(self, CHAN_PROJECTILE, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
172                         else if (w_random<0.7)
173                                 sound(self, CHAN_PROJECTILE, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
174                         else
175                                 sound(self, CHAN_PROJECTILE, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
176                 }
177         }
178         else if(req == WR_PRECACHE)
179         {
180                 precache_sound("weapons/hagexp1.wav");
181                 precache_sound("weapons/hagexp2.wav");
182                 precache_sound("weapons/hagexp3.wav");
183         }
184         else if (req == WR_SUICIDEMESSAGE)
185                 w_deathtypestring = _("%s played with tiny rockets");
186         else if (req == WR_KILLMESSAGE)
187         {
188                 if(w_deathtype & HITTYPE_BOUNCE) // must be secondary; unchecked: SPLASH
189                         w_deathtypestring = _("%s hoped %s's missiles wouldn't bounce");
190                 else // unchecked: SPLASH, SECONDARY
191                         w_deathtypestring = _("%s was pummeled by %s");
192         }
193         return TRUE;
194 }
195 #endif
196 #endif