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;
25 const float shalrath_anim_idle = 0;
26 const float shalrath_anim_walk = 1;
27 const float shalrath_anim_attack = 2;
28 const float shalrath_anim_pain = 3;
29 const float shalrath_anim_death = 4;
30 const float shalrath_anim_run = 5;
36 void shalrath_think ()
39 float friend_needshelp = FALSE;
43 if(vlen(head.origin - self.origin) < autocvar_g_monster_shalrath_heal_range * self.scale)
44 if((!g_minstagib && head.health < autocvar_g_balance_health_regenstable) || (g_minstagib && head.ammo_cells < start_ammo_cells))
46 friend_needshelp = TRUE;
47 break; // found 1 player near us who is low on health
51 self.think = shalrath_think;
52 self.nextthink = time + self.ticrate;
55 self.nextthink = self.delay;
57 if(self.health < autocvar_g_monster_shalrath_heal_minhealth || friend_needshelp)
58 if(time >= self.attack_finished_single)
62 monster_move(autocvar_g_monster_shalrath_speed, autocvar_g_monster_shalrath_speed, 50, shalrath_anim_walk, shalrath_anim_run, shalrath_anim_idle);
65 void shalrath_attack ()
67 monsters_setframe(shalrath_anim_attack);
68 self.delay = time + 0.2;
69 self.attack_finished_single = time + autocvar_g_monster_shalrath_attack_spike_delay;
70 self.monster_delayedattack = ShalMissile;
73 void shalrathattack_melee ()
75 monster_melee(self.enemy, autocvar_g_monster_shalrath_attack_melee_damage, 0.3, DEATH_MONSTER_MAGE, TRUE);
78 void shalrath_attack_melee ()
80 self.monster_delayedattack = shalrathattack_melee;
81 self.delay = time + 0.2;
82 monsters_setframe(shalrath_anim_attack);
83 self.attack_finished_single = time + autocvar_g_monster_shalrath_attack_melee_delay;
95 local vector dir = '0 0 0', vtemp = self.enemy.origin + '0 0 10';
97 if (self.enemy.health <= 0 || self.owner.health <= 0 || time >= self.ltime)
102 dir = normalize(vtemp - self.origin);
103 UpdateCSQCProjectile(self);
104 if (monster_skill == 3)
105 self.velocity = dir * 350;
107 self.velocity = dir * 250;
108 self.nextthink = time + 0.2;
109 self.think = ShalHome;
112 void shal_spike_explode ()
114 self.event_damage = func_null;
116 pointparticles(particleeffectnum("explosion_small"), self.origin, '0 0 0', 1);
117 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);
122 void shal_spike_touchexplode()
126 shal_spike_explode();
131 local entity missile = world;
132 local vector dir = '0 0 0';
133 local float dist = 0;
135 self.effects |= EF_MUZZLEFLASH;
138 missile.owner = missile.realowner = self;
140 self.v_angle = self.angles;
141 makevectors (self.angles);
143 dir = normalize((self.enemy.origin + '0 0 10') - self.origin);
144 dist = vlen (self.enemy.origin - self.origin);
146 missile.think = ShalHome;
147 missile.ltime = time + 7;
148 missile.nextthink = time;
149 missile.solid = SOLID_BBOX;
150 missile.movetype = MOVETYPE_FLYMISSILE;
151 missile.flags = FL_PROJECTILE;
152 setorigin (missile, self.origin + v_forward * 14 + '0 0 30' + v_right * -14);
153 setsize (missile, '0 0 0', '0 0 0');
154 missile.velocity = dir * 400;
155 missile.avelocity = '300 300 300';
156 missile.enemy = self.enemy;
157 missile.touch = shal_spike_touchexplode;
159 CSQCProjectile(missile, TRUE, PROJECTILE_VORE_SPIKE, TRUE);
162 float ShalrathCheckAttack ()
164 vector spot1 = '0 0 0', spot2 = '0 0 0';
166 if (self.health <= 0)
169 // reset delays when we have no enemy
172 self.monster_delayedattack = func_null;
176 if(self.monster_delayedattack && self.delay != -1)
178 if(time < self.delay)
181 self.monster_delayedattack();
183 self.monster_delayedattack = func_null;
186 if(time < self.attack_finished_single)
189 if (vlen(self.enemy.origin - self.origin) <= 120)
191 if (self.attack_melee)
193 monster_sound(self.msound_attack_melee, 0, FALSE); // no delay for attack sounds
199 // see if any entities are in the way of the shot
200 spot1 = self.origin + self.view_ofs;
201 spot2 = self.enemy.origin + self.enemy.view_ofs;
203 traceline (spot1, spot2, FALSE, self);
205 if (trace_ent != self.enemy && trace_fraction < 1)
206 return FALSE; // don't have a clear shot
208 //if (trace_inopen && trace_inwater)
209 // return FALSE; // sight line crossed contents
211 if (self.attack_ranged())
220 if(self.health < self.max_health) // only show our effect if we are healing ourself too
221 pointparticles(particleeffectnum("healing_fx"), self.origin, '0 0 0', 1);
222 self.health = bound(0, self.health + autocvar_g_monster_shalrath_heal_self, self.max_health);
223 WaypointSprite_UpdateHealth(self.sprite, self.health);
224 monsters_setframe(shalrath_anim_attack);
225 self.attack_finished_single = time + autocvar_g_monster_shalrath_heal_delay;
227 for(head = world; (head = findfloat(head, monster_attack, TRUE)); )
230 if not(head.frozen || head.freezetag_frozen)
231 if(vlen(head.origin - self.origin) < autocvar_g_monster_shalrath_heal_range * self.scale)
232 if not(IsDifferentTeam(head, self))
236 if(head.ammo_cells < start_ammo_cells || head.health < g_pickup_healthmedium_max)
237 pointparticles(particleeffectnum(((g_minstagib) ? "ammoregen_fx" : "healing_fx")), head.origin, '0 0 0', 1);
239 head.ammo_cells = bound(0, head.ammo_cells + 1, start_ammo_cells);
241 head.health = bound(0, head.health + autocvar_g_monster_shalrath_heal_friends, g_pickup_healthmedium_max);
245 if(head.health < head.max_health)
246 pointparticles(particleeffectnum("healing_fx"), head.origin, '0 0 0', 1);
247 head.health = bound(0, head.health + autocvar_g_monster_shalrath_heal_friends, head.max_health);
248 WaypointSprite_UpdateHealth(head.sprite, head.health);
256 Monster_CheckDropCvars ("shalrath");
258 self.think = monster_dead_think;
259 self.nextthink = time + self.ticrate;
260 self.ltime = time + 5;
261 monsters_setframe(shalrath_anim_death);
263 monster_hook_death(); // for post-death mods
266 void shalrath_spawn ()
269 self.health = autocvar_g_monster_shalrath_health * self.scale;
271 self.damageforcescale = 0.003;
272 self.classname = "monster_shalrath";
273 self.checkattack = ShalrathCheckAttack;
274 self.attack_ranged = shal_missile;
275 self.attack_melee = shalrath_attack_melee;
276 self.nextthink = time + random() * 0.5 + 0.1;
277 self.think = shalrath_think;
279 monsters_setframe(shalrath_anim_walk);
281 monster_setupsounds("shalrath");
283 monster_hook_spawn(); // for post-spawn mods
286 void spawnfunc_monster_shalrath ()
288 if not(autocvar_g_monster_shalrath) { remove(self); return; }
290 self.monster_spawnfunc = spawnfunc_monster_shalrath;
292 if(Monster_CheckAppearFlags(self))
295 if not (monster_initialize(
296 "Mage", MONSTER_MAGE,
297 SHALRATH_MIN, SHALRATH_MAX,
299 shalrath_die, shalrath_spawn))
306 // compatibility with old spawns
307 void spawnfunc_monster_vore () { spawnfunc_monster_shalrath(); }