1 #ifdef REGISTER_MONSTER
4 /* function */ m_knight,
5 /* spawnflags */ MONSTER_SIZE_BROKEN,
6 /* mins,maxs */ '-20 -20 -32', '20 20 41',
7 /* model */ "hknight.mdl",
8 /* netname */ "knight",
9 /* fullname */ _("Knight")
12 #define KNIGHT_SETTINGS(monster) \
13 MON_ADD_CVAR(monster, health) \
14 MON_ADD_CVAR(monster, attack_melee_damage) \
15 MON_ADD_CVAR(monster, attack_inferno_damage) \
16 MON_ADD_CVAR(monster, attack_inferno_damagetime) \
17 MON_ADD_CVAR(monster, attack_inferno_chance) \
18 MON_ADD_CVAR(monster, attack_fireball_damage) \
19 MON_ADD_CVAR(monster, attack_fireball_edgedamage) \
20 MON_ADD_CVAR(monster, attack_fireball_damagetime) \
21 MON_ADD_CVAR(monster, attack_fireball_force) \
22 MON_ADD_CVAR(monster, attack_fireball_radius) \
23 MON_ADD_CVAR(monster, attack_fireball_chance) \
24 MON_ADD_CVAR(monster, attack_spike_damage) \
25 MON_ADD_CVAR(monster, attack_spike_edgedamage) \
26 MON_ADD_CVAR(monster, attack_spike_force) \
27 MON_ADD_CVAR(monster, attack_spike_radius) \
28 MON_ADD_CVAR(monster, attack_spike_chance) \
29 MON_ADD_CVAR(monster, attack_jump_damage) \
30 MON_ADD_CVAR(monster, attack_jump_distance) \
31 MON_ADD_CVAR(monster, attack_jump_chance) \
32 MON_ADD_CVAR(monster, speed_stop) \
33 MON_ADD_CVAR(monster, speed_run) \
34 MON_ADD_CVAR(monster, speed_walk)
37 KNIGHT_SETTINGS(knight)
41 const float knight_anim_stand = 0;
42 const float knight_anim_walk = 1;
43 const float knight_anim_run = 2;
44 const float knight_anim_pain = 3;
45 const float knight_anim_death1 = 4;
46 const float knight_anim_death2 = 5;
47 const float knight_anim_charge1 = 6;
48 const float knight_anim_magic1 = 7;
49 const float knight_anim_magic2 = 8;
50 const float knight_anim_charge2 = 9;
51 const float knight_anim_slice = 10;
52 const float knight_anim_smash = 11;
53 const float knight_anim_wattack = 12;
54 const float knight_anim_magic3 = 13;
63 traceline((self.absmin + self.absmax) * 0.5, (self.enemy.absmin + self.enemy.absmax) * 0.5, TRUE, world);
64 if (trace_fraction != 1)
65 return; // not visible
67 self.enemy.effects |= EF_MUZZLEFLASH;
68 sound(self.enemy, CHAN_AUTO, "player/lava.wav", 1, ATTN_NORM);
70 if(vlen(self.enemy.origin - self.origin) <= 2000)
71 Fire_AddDamage(self.enemy, self, MON_CVAR(knight, attack_inferno_damage) * monster_skill, MON_CVAR(knight, attack_inferno_damagetime), DEATH_MONSTER_KNIGHT_INFERNO);
74 void knight_fireball_explode()
79 pointparticles(particleeffectnum("fireball_explode"), self.origin, '0 0 0', 1);
81 RadiusDamage(self, self.realowner, MON_CVAR(knight, attack_fireball_damage), MON_CVAR(knight, attack_fireball_edgedamage), MON_CVAR(knight, attack_fireball_force), world, MON_CVAR(knight, attack_fireball_radius), self.projectiledeathtype, world);
83 for(e = world; (e = findfloat(e, takedamage, DAMAGE_AIM)); ) if(vlen(e.origin - self.origin) <= MON_CVAR(knight, attack_inferno_damage))
84 Fire_AddDamage(e, self, 5 * monster_skill, MON_CVAR(knight, attack_fireball_damagetime), self.projectiledeathtype);
90 void knight_fireball_touch()
94 knight_fireball_explode();
97 void knight_fireball()
99 entity missile = spawn();
100 vector dir = normalize((self.enemy.origin + '0 0 10') - self.origin);
102 monster_makevectors(self.enemy);
104 self.effects |= EF_MUZZLEFLASH;
105 sound(self, CHAN_WEAPON, "weapons/fireball2.wav", 1, ATTN_NORM);
107 missile.owner = missile.realowner = self;
108 missile.solid = SOLID_TRIGGER;
109 missile.movetype = MOVETYPE_FLYMISSILE;
110 missile.projectiledeathtype = DEATH_MONSTER_KNIGHT_FBALL;
111 setsize(missile, '-6 -6 -6', '6 6 6');
112 setorigin(missile, self.origin + self.view_ofs + v_forward * 14);
113 missile.flags = FL_PROJECTILE;
114 missile.velocity = dir * 400;
115 missile.avelocity = '300 300 300';
116 missile.nextthink = time + 5;
117 missile.think = knight_fireball_explode;
118 missile.enemy = self.enemy;
119 missile.touch = knight_fireball_touch;
120 CSQCProjectile(missile, TRUE, PROJECTILE_FIREMINE, TRUE);
123 void knight_spike_explode()
127 pointparticles(particleeffectnum("TE_WIZSPIKE"), self.origin, '0 0 0', 1);
129 RadiusDamage (self, self.realowner, MON_CVAR(knight, attack_spike_damage), MON_CVAR(knight, attack_spike_edgedamage), MON_CVAR(knight, attack_spike_force), world, MON_CVAR(knight, attack_spike_radius), DEATH_MONSTER_KNIGHT_SPIKE, other);
134 void knight_spike_touch()
138 knight_spike_explode();
144 vector dir = normalize((self.enemy.origin + '0 0 10') - self.origin);
146 self.effects |= EF_MUZZLEFLASH;
149 missile.owner = missile.realowner = self;
150 missile.solid = SOLID_TRIGGER;
151 missile.movetype = MOVETYPE_FLYMISSILE;
152 setsize (missile, '0 0 0', '0 0 0');
153 setorigin(missile, self.origin + '0 0 10' + v_forward * 14);
154 missile.scale = self.scale;
155 missile.flags = FL_PROJECTILE;
156 missile.velocity = dir * 400;
157 missile.avelocity = '300 300 300';
158 missile.nextthink = time + 5;
159 missile.think = knight_spike_explode;
160 missile.enemy = self.enemy;
161 missile.touch = knight_spike_touch;
162 CSQCProjectile(missile, TRUE, PROJECTILE_CRYLINK, TRUE);
167 self.knight_cycles += 1;
170 if(self.knight_cycles <= 7)
171 defer(0.1, knight_spikes);
174 float knight_attack_ranged()
176 if not(self.flags & FL_ONGROUND)
179 self.knight_cycles = 0;
181 RandomSelection_Init();
182 RandomSelection_Add(world, 1, "", MON_CVAR(knight, attack_fireball_chance), 1);
183 RandomSelection_Add(world, 2, "", MON_CVAR(knight, attack_inferno_chance), 1);
184 RandomSelection_Add(world, 3, "", MON_CVAR(knight, attack_spike_chance), 1);
185 if(self.health >= 100) RandomSelection_Add(world, 4, "", ((vlen(self.enemy.origin - self.origin) > MON_CVAR(knight, attack_jump_distance)) ? 1 : MON_CVAR(knight, attack_jump_chance)), 1);
187 switch(RandomSelection_chosen_float)
191 monsters_setframe(knight_anim_magic2);
192 self.attack_finished_single = time + 2;
193 defer(0.4, knight_fireball);
199 self.attack_finished_single = time + 3;
200 defer(0.5, knight_inferno);
205 monsters_setframe(knight_anim_magic3);
206 self.attack_finished_single = time + 3;
207 defer(0.4, knight_spikes);
213 float er = vlen(self.enemy.origin - self.origin);
215 if(er >= 400 && er < 1200)
216 if(findtrajectorywithleading(self.origin, self.mins, self.maxs, self.enemy, 1000, 0, 10, 0, self))
218 self.velocity = findtrajectory_velocity;
219 Damage(self.enemy, self, self, MON_CVAR(knight, attack_jump_damage) * monster_skill, DEATH_MONSTER_KNIGHT_CRUSH, self.enemy.origin, normalize(self.enemy.origin - self.origin));
220 self.attack_finished_single = time + 2;
230 float knight_attack(float attack_type)
234 case MONSTER_ATTACK_MELEE:
238 anim = knight_anim_slice;
239 else if(random() < 0.6)
240 anim = knight_anim_smash;
242 anim = knight_anim_wattack;
244 monsters_setframe(anim);
245 self.attack_finished_single = time + 0.7;
246 monster_melee(self.enemy, MON_CVAR(knight, attack_melee_damage), 0.3, DEATH_MONSTER_KNIGHT_MELEE, TRUE);
250 case MONSTER_ATTACK_RANGED:
252 if(knight_attack_ranged())
260 void spawnfunc_monster_knight()
262 self.classname = "monster_knight";
264 self.monster_spawnfunc = spawnfunc_monster_knight;
266 if(Monster_CheckAppearFlags(self))
269 if not(monster_initialize(MON_KNIGHT, FALSE)) { remove(self); return; }
272 // compatibility with old spawns
273 void spawnfunc_monster_hell_knight() { spawnfunc_monster_knight(); }
275 float m_knight(float req)
281 monster_move(MON_CVAR(knight, speed_run), MON_CVAR(knight, speed_walk), MON_CVAR(knight, speed_stop), knight_anim_run, knight_anim_walk, knight_anim_stand);
286 float chance = random();
287 monsters_setframe((random() > 0.5) ? knight_anim_death1 : knight_anim_death2);
288 if(chance < 0.10 || self.flags & MONSTERFLAG_MINIBOSS)
291 self.superweapons_finished = time + autocvar_g_balance_superweapons_time + 5; // give the player a few seconds to find the weapon
292 self.weapon = WEP_FIREBALL;
298 if not(self.health) self.health = MON_CVAR(knight, health);
300 self.monster_attackfunc = knight_attack;
301 monsters_setframe(knight_anim_stand);
307 precache_sound ("player/lava.wav");
312 MON_CONFIG_SETTINGS(KNIGHT_SETTINGS(knight))
322 float m_knight(float req)
333 precache_model ("models/monsters/hknight.mdl");
342 #endif // REGISTER_MONSTER