3 const vector SHALRATH_MIN = '-36 -36 -24';
4 const vector SHALRATH_MAX = '36 36 50';
7 string SHALRATH_MODEL = "models/monsters/mage.dpm";
13 float autocvar_g_monster_shalrath;
14 float autocvar_g_monster_shalrath_health;
15 float autocvar_g_monster_shalrath_speed;
16 float autocvar_g_monster_shalrath_attack_spike_damage;
17 float autocvar_g_monster_shalrath_attack_spike_radius;
18 float autocvar_g_monster_shalrath_attack_spike_delay;
19 float autocvar_g_monster_shalrath_attack_melee_damage;
20 float autocvar_g_monster_shalrath_attack_melee_delay;
21 float autocvar_g_monster_shalrath_heal_self;
22 float autocvar_g_monster_shalrath_heal_friends;
23 float autocvar_g_monster_shalrath_heal_minhealth;
24 float autocvar_g_monster_shalrath_heal_range;
25 float autocvar_g_monster_shalrath_heal_delay;
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;
39 void shalrath_think ()
42 float friend_needshelp = FALSE;
46 if(vlen(head.origin - self.origin) < autocvar_g_monster_shalrath_heal_range * self.scale)
47 if((!g_minstagib && head.health < autocvar_g_balance_health_regenstable) || (g_minstagib && head.ammo_cells < start_ammo_cells))
49 friend_needshelp = TRUE;
50 break; // found 1 player near us who is low on health
54 self.think = shalrath_think;
55 self.nextthink = time + self.ticrate;
58 self.nextthink = self.delay;
60 if(self.health < autocvar_g_monster_shalrath_heal_minhealth || friend_needshelp)
61 if(time >= self.attack_finished_single)
65 monster_move(autocvar_g_monster_shalrath_speed, autocvar_g_monster_shalrath_speed, 50, shalrath_anim_walk, shalrath_anim_run, shalrath_anim_idle);
68 void shalrath_attack ()
70 monsters_setframe(shalrath_anim_attack);
71 self.delay = time + 0.2;
72 self.attack_finished_single = time + autocvar_g_monster_shalrath_attack_spike_delay;
73 self.monster_delayedattack = ShalMissile;
76 void shalrathattack_melee ()
78 monster_melee(self.enemy, autocvar_g_monster_shalrath_attack_melee_damage, 0.3, DEATH_MONSTER_MAGE, TRUE);
81 void shalrath_attack_melee ()
83 self.monster_delayedattack = shalrathattack_melee;
84 self.delay = time + 0.2;
85 monsters_setframe(shalrath_anim_attack);
86 self.attack_finished_single = time + autocvar_g_monster_shalrath_attack_melee_delay;
98 local vector dir = '0 0 0', vtemp = self.enemy.origin + '0 0 10';
100 if (self.enemy.health <= 0 || self.owner.health <= 0 || time >= self.ltime)
105 dir = normalize(vtemp - self.origin);
106 UpdateCSQCProjectile(self);
107 if (monster_skill == 3)
108 self.velocity = dir * 350;
110 self.velocity = dir * 250;
111 self.nextthink = time + 0.2;
112 self.think = ShalHome;
115 void shal_spike_explode ()
117 self.event_damage = func_null;
119 pointparticles(particleeffectnum("explosion_small"), self.origin, '0 0 0', 1);
120 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);
125 void shal_spike_touchexplode()
129 shal_spike_explode();
134 local entity missile = world;
135 local vector dir = '0 0 0';
136 local float dist = 0;
138 self.effects |= EF_MUZZLEFLASH;
141 missile.owner = missile.realowner = self;
143 self.v_angle = self.angles;
144 makevectors (self.angles);
146 dir = normalize((self.enemy.origin + '0 0 10') - self.origin);
147 dist = vlen (self.enemy.origin - self.origin);
149 missile.think = ShalHome;
150 missile.ltime = time + 7;
151 missile.nextthink = time;
152 missile.solid = SOLID_BBOX;
153 missile.movetype = MOVETYPE_FLYMISSILE;
154 missile.flags = FL_PROJECTILE;
155 setorigin (missile, self.origin + v_forward * 14 + '0 0 30' + v_right * -14);
156 setsize (missile, '0 0 0', '0 0 0');
157 missile.velocity = dir * 400;
158 missile.avelocity = '300 300 300';
159 missile.enemy = self.enemy;
160 missile.touch = shal_spike_touchexplode;
162 CSQCProjectile(missile, TRUE, PROJECTILE_VORE_SPIKE, TRUE);
165 float ShalrathCheckAttack ()
167 vector spot1 = '0 0 0', spot2 = '0 0 0';
169 if (self.health <= 0 || self.enemy == world || self.enemy.health < 1)
172 if(self.monster_delayedattack && self.delay != -1)
174 if(time < self.delay)
177 self.monster_delayedattack();
179 self.monster_delayedattack = func_null;
182 if(time < self.attack_finished_single)
185 if (vlen(self.enemy.origin - self.origin) <= 120)
187 if (self.attack_melee)
189 monster_sound(self.msound_attack_melee, 0, FALSE); // no delay for attack sounds
195 // see if any entities are in the way of the shot
196 spot1 = self.origin + self.view_ofs;
197 spot2 = self.enemy.origin + self.enemy.view_ofs;
199 traceline (spot1, spot2, FALSE, self);
201 if (trace_ent != self.enemy && trace_fraction < 1)
202 return FALSE; // don't have a clear shot
204 //if (trace_inopen && trace_inwater)
205 // return FALSE; // sight line crossed contents
207 if (self.attack_ranged())
216 if(self.health < self.max_health) // only show our effect if we are healing ourself too
217 pointparticles(particleeffectnum("healing_fx"), self.origin, '0 0 0', 1);
218 self.health = bound(0, self.health + autocvar_g_monster_shalrath_heal_self, self.max_health);
219 WaypointSprite_UpdateHealth(self.sprite, self.health);
220 monsters_setframe(shalrath_anim_attack);
221 self.attack_finished_single = time + autocvar_g_monster_shalrath_heal_delay;
223 for(head = world; (head = findfloat(head, monster_attack, TRUE)); )
226 if not(head.frozen || head.freezetag_frozen)
227 if(vlen(head.origin - self.origin) < autocvar_g_monster_shalrath_heal_range * self.scale)
228 if not(IsDifferentTeam(head, self))
232 if(head.ammo_cells < start_ammo_cells || head.health < g_pickup_healthmedium_max)
233 pointparticles(particleeffectnum(((g_minstagib) ? "ammoregen_fx" : "healing_fx")), head.origin, '0 0 0', 1);
235 head.ammo_cells = bound(0, head.ammo_cells + 1, start_ammo_cells);
237 head.health = bound(0, head.health + autocvar_g_monster_shalrath_heal_friends, g_pickup_healthmedium_max);
241 if(head.health < head.max_health)
242 pointparticles(particleeffectnum("healing_fx"), head.origin, '0 0 0', 1);
243 head.health = bound(0, head.health + autocvar_g_monster_shalrath_heal_friends, head.max_health);
244 WaypointSprite_UpdateHealth(head.sprite, head.health);
252 Monster_CheckDropCvars ("shalrath");
254 self.think = Monster_Fade;
255 self.nextthink = time + 5;
256 monsters_setframe(shalrath_anim_death);
258 monster_hook_death(); // for post-death mods
261 void shalrath_spawn ()
264 self.health = autocvar_g_monster_shalrath_health * self.scale;
266 self.damageforcescale = 0.003;
267 self.classname = "monster_shalrath";
268 self.checkattack = ShalrathCheckAttack;
269 self.attack_ranged = shal_missile;
270 self.attack_melee = shalrath_attack_melee;
271 self.nextthink = time + random() * 0.5 + 0.1;
272 self.think = shalrath_think;
273 self.sprite_height = 65;
275 monsters_setframe(shalrath_anim_walk);
277 monster_hook_spawn(); // for post-spawn mods
280 void spawnfunc_monster_shalrath ()
282 if not(autocvar_g_monster_shalrath) { remove(self); return; }
284 self.monster_spawnfunc = spawnfunc_monster_shalrath;
286 if(Monster_CheckAppearFlags(self))
289 if not (monster_initialize(
290 "Mage", MONSTER_MAGE,
291 SHALRATH_MIN, SHALRATH_MAX,
293 shalrath_die, shalrath_spawn))
300 // compatibility with old spawns
301 void spawnfunc_monster_vore () { spawnfunc_monster_shalrath(); }