2 const vector SHALRATH_MIN = '-36 -36 -24';
3 const vector SHALRATH_MAX = '36 36 50';
6 string SHALRATH_MODEL = "models/monsters/mage.dpm";
10 float autocvar_g_monster_shalrath;
11 float autocvar_g_monster_shalrath_health;
12 float autocvar_g_monster_shalrath_speed;
13 float autocvar_g_monster_shalrath_attack_spike_damage;
14 float autocvar_g_monster_shalrath_attack_spike_radius;
15 float autocvar_g_monster_shalrath_attack_spike_delay;
16 float autocvar_g_monster_shalrath_attack_melee_damage;
17 float autocvar_g_monster_shalrath_attack_melee_delay;
18 float autocvar_g_monster_shalrath_heal_self;
19 float autocvar_g_monster_shalrath_heal_friends;
20 float autocvar_g_monster_shalrath_heal_minhealth;
21 float autocvar_g_monster_shalrath_heal_range;
22 float autocvar_g_monster_shalrath_heal_delay;
23 float autocvar_g_monster_shalrath_shield_time;
24 float autocvar_g_monster_shalrath_shield_delay;
25 float autocvar_g_monster_shalrath_shield_blockpercent;
28 const float shalrath_anim_idle = 0;
29 const float shalrath_anim_walk = 1;
30 const float shalrath_anim_attack = 2;
31 const float shalrath_anim_pain = 3;
32 const float shalrath_anim_death = 4;
33 const float shalrath_anim_run = 5;
38 void() shalrath_shield;
39 void() shalrath_shield_die;
41 void shalrath_think ()
44 float friend_needshelp = FALSE;
48 if(vlen(head.origin - self.origin) < autocvar_g_monster_shalrath_heal_range * self.scale)
49 if((!g_minstagib && head.health < autocvar_g_balance_health_regenstable) || (g_minstagib && head.ammo_cells < start_ammo_cells))
51 friend_needshelp = TRUE;
52 break; // found 1 player near us who is low on health
56 self.think = shalrath_think;
57 self.nextthink = time + self.ticrate;
60 if(time >= self.weaponentity.ltime)
61 shalrath_shield_die();
64 self.nextthink = self.delay;
66 if(self.health < autocvar_g_monster_shalrath_heal_minhealth || friend_needshelp)
67 if(time >= self.attack_finished_single)
72 if not(self.spawnflags & MONSTERFLAG_GIANT) // giants are too big to hold a shield
73 if(self.health < self.max_health)
74 if(time >= self.lastshielded)
78 monster_move(autocvar_g_monster_shalrath_speed, autocvar_g_monster_shalrath_speed, 50, shalrath_anim_walk, shalrath_anim_run, shalrath_anim_idle);
81 void shalrath_attack ()
83 monsters_setframe(shalrath_anim_attack);
84 self.delay = time + 0.2;
85 self.attack_finished_single = time + autocvar_g_monster_shalrath_attack_spike_delay;
86 self.monster_delayedattack = ShalMissile;
89 void shalrathattack_melee ()
91 monster_melee(self.enemy, autocvar_g_monster_shalrath_attack_melee_damage, 0.3, DEATH_MONSTER_MAGE, TRUE);
94 void shalrath_attack_melee ()
96 self.monster_delayedattack = shalrathattack_melee;
97 self.delay = time + 0.2;
98 monsters_setframe(shalrath_anim_attack);
99 self.attack_finished_single = time + autocvar_g_monster_shalrath_attack_melee_delay;
102 float shal_missile ()
111 local vector dir = '0 0 0', vtemp = self.enemy.origin + '0 0 10';
113 if (self.enemy.health <= 0 || self.owner.health <= 0 || time >= self.ltime)
118 dir = normalize(vtemp - self.origin);
119 UpdateCSQCProjectile(self);
120 if (monster_skill == 3)
121 self.velocity = dir * 350;
123 self.velocity = dir * 250;
124 self.nextthink = time + 0.2;
125 self.think = ShalHome;
128 void shal_spike_explode ()
130 self.event_damage = func_null;
132 pointparticles(particleeffectnum("explosion_small"), self.origin, '0 0 0', 1);
133 RadiusDamage (self, self.realowner, autocvar_g_monster_shalrath_attack_spike_damage, autocvar_g_monster_shalrath_attack_spike_damage * 0.5, autocvar_g_monster_shalrath_attack_spike_radius, world, 0, DEATH_MONSTER_MAGE, other);
138 void shal_spike_touchexplode()
142 shal_spike_explode();
147 local entity missile = world;
148 local vector dir = '0 0 0';
149 local float dist = 0;
151 self.effects |= EF_MUZZLEFLASH;
154 missile.owner = missile.realowner = self;
156 self.v_angle = self.angles;
157 makevectors (self.angles);
159 dir = normalize((self.enemy.origin + '0 0 10') - self.origin);
160 dist = vlen (self.enemy.origin - self.origin);
162 missile.think = ShalHome;
163 missile.ltime = time + 7;
164 missile.nextthink = time;
165 missile.solid = SOLID_BBOX;
166 missile.movetype = MOVETYPE_FLYMISSILE;
167 missile.flags = FL_PROJECTILE;
168 setorigin (missile, self.origin + v_forward * 14 + '0 0 30' + v_right * -14);
169 setsize (missile, '0 0 0', '0 0 0');
170 missile.velocity = dir * 400;
171 missile.avelocity = '300 300 300';
172 missile.enemy = self.enemy;
173 missile.touch = shal_spike_touchexplode;
175 CSQCProjectile(missile, TRUE, PROJECTILE_VORE_SPIKE, TRUE);
178 float ShalrathCheckAttack ()
180 vector spot1 = '0 0 0', spot2 = '0 0 0';
182 if (self.health <= 0)
185 // reset delays when we have no enemy
188 self.monster_delayedattack = func_null;
192 if(self.monster_delayedattack && self.delay != -1)
194 if(time < self.delay)
197 self.monster_delayedattack();
199 self.monster_delayedattack = func_null;
202 if(time < self.attack_finished_single)
205 if (vlen(self.enemy.origin - self.origin) <= 120)
207 if (self.attack_melee)
209 monster_sound(self.msound_attack_melee, 0, FALSE); // no delay for attack sounds
215 // see if any entities are in the way of the shot
216 spot1 = self.origin + self.view_ofs;
217 spot2 = self.enemy.origin + self.enemy.view_ofs;
219 traceline (spot1, spot2, FALSE, self);
221 if (trace_ent != self.enemy && trace_fraction < 1)
222 return FALSE; // don't have a clear shot
224 //if (trace_inopen && trace_inwater)
225 // return FALSE; // sight line crossed contents
227 if (self.attack_ranged())
236 if(self.health < self.max_health) // only show our effect if we are healing ourself too
237 pointparticles(particleeffectnum("healing_fx"), self.origin, '0 0 0', 1);
238 self.health = bound(0, self.health + autocvar_g_monster_shalrath_heal_self, self.max_health);
239 WaypointSprite_UpdateHealth(self.sprite, self.health);
240 monsters_setframe(shalrath_anim_attack);
241 self.attack_finished_single = time + autocvar_g_monster_shalrath_heal_delay;
243 for(head = world; (head = findfloat(head, monster_attack, TRUE)); )
246 if not(head.frozen || head.freezetag_frozen)
247 if(vlen(head.origin - self.origin) < autocvar_g_monster_shalrath_heal_range * self.scale)
248 if not(IsDifferentTeam(head, self))
252 if(head.ammo_cells < start_ammo_cells || head.health < g_pickup_healthmedium_max)
253 pointparticles(particleeffectnum(((g_minstagib) ? "ammoregen_fx" : "healing_fx")), head.origin, '0 0 0', 1);
255 head.ammo_cells = bound(0, head.ammo_cells + 1, start_ammo_cells);
257 head.health = bound(0, head.health + autocvar_g_monster_shalrath_heal_friends, g_pickup_healthmedium_max);
261 if(head.health < head.max_health)
262 pointparticles(particleeffectnum("healing_fx"), head.origin, '0 0 0', 1);
263 head.health = bound(0, head.health + autocvar_g_monster_shalrath_heal_friends, head.max_health);
264 WaypointSprite_UpdateHealth(head.sprite, head.health);
270 void shalrath_shield_die()
272 if not(self.weaponentity)
273 return; // why would this be called without a shield?
277 remove(self.weaponentity);
279 self.weaponentity = world;
282 void shalrath_shield()
284 if(self.weaponentity)
285 return; // already have a shield
287 self.weaponentity = spawn();
288 self.weaponentity.owner = self.weaponentity.realowner = self;
289 setmodel(self.weaponentity, "models/onslaught/generator_shield.md3");
290 setattachment(self.weaponentity, self, "");
291 self.weaponentity.classname = "shield";
292 self.weaponentity.ltime = time + autocvar_g_monster_shalrath_shield_time;
293 self.weaponentity.health = 70;
294 self.weaponentity.alpha = 0.5;
295 self.weaponentity.scale = self.scale * 0.6;
296 self.weaponentity.effects = EF_ADDITIVE;
297 self.weaponentity.solid = SOLID_NOT;
298 self.weaponentity.movetype = MOVETYPE_NOCLIP;
299 self.weaponentity.avelocity = '7 0 11';
301 self.lastshielded = time + autocvar_g_monster_shalrath_shield_delay;
303 monsters_setframe(shalrath_anim_attack);
304 self.attack_finished_single = time + 1;
306 self.armorvalue = autocvar_g_monster_shalrath_shield_blockpercent / 100;
311 Monster_CheckDropCvars ("shalrath");
313 self.think = monster_dead_think;
314 self.nextthink = time + self.ticrate;
315 self.ltime = time + 5;
316 monsters_setframe(shalrath_anim_death);
318 monster_hook_death(); // for post-death mods
321 void shalrath_spawn ()
324 self.health = autocvar_g_monster_shalrath_health * self.scale;
326 self.damageforcescale = 0.003;
327 self.classname = "monster_shalrath";
328 self.checkattack = ShalrathCheckAttack;
329 self.attack_ranged = shal_missile;
330 self.attack_melee = shalrath_attack_melee;
331 self.nextthink = time + random() * 0.5 + 0.1;
332 self.think = shalrath_think;
334 monsters_setframe(shalrath_anim_walk);
336 monster_setupsounds("shalrath");
338 monster_hook_spawn(); // for post-spawn mods
341 void spawnfunc_monster_shalrath ()
343 if not(autocvar_g_monster_shalrath) { remove(self); return; }
345 self.monster_spawnfunc = spawnfunc_monster_shalrath;
347 if(Monster_CheckAppearFlags(self))
350 if not (monster_initialize(
351 "Mage", MONSTER_MAGE,
352 SHALRATH_MIN, SHALRATH_MAX,
354 shalrath_die, shalrath_spawn))
361 // compatibility with old spawns
362 void spawnfunc_monster_vore () { spawnfunc_monster_shalrath(); }