+#ifndef MAGE_H
+#define MAGE_H
+
#ifndef MENUQC
-bool M_Mage(int);
+MODEL(MON_MAGE, "models/monsters/mage.dpm");
#endif
-REGISTER_MONSTER_SIMPLE(
-/* MON_##id */ MAGE,
-/* spawnflags */ MON_FLAG_MELEE | MON_FLAG_RANGED,
-/* mins,maxs */ '-36 -36 -24', '36 36 50',
-/* model */ "mage.dpm",
-/* netname */ "mage",
-/* fullname */ _("Mage")
-) {
+
+CLASS(Mage, Monster)
+ ATTRIB(Mage, spawnflags, int, MON_FLAG_MELEE | MON_FLAG_RANGED);
+ ATTRIB(Mage, mins, vector, '-36 -36 -24');
+ ATTRIB(Mage, maxs, vector, '36 36 50');
#ifndef MENUQC
- this.monster_func = M_Mage;
- this.monster_func(MR_PRECACHE);
+ ATTRIB(Mage, m_model, Model, MDL_MON_MAGE);
+#endif
+ ATTRIB(Mage, netname, string, "mage");
+ ATTRIB(Mage, monster_name, string, _("Mage"));
+ENDCLASS(Mage)
+
+REGISTER_MONSTER(MAGE, NEW(Mage)) {
+#ifndef MENUQC
+ MON_ACTION(this, MR_PRECACHE);
#endif
}
+#include "../../weapons/all.qh"
+
+CLASS(MageSpike, PortoLaunch)
+/* flags */ ATTRIB(MageSpike, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse */ ATTRIB(MageSpike, impulse, int, 9);
+/* refname */ ATTRIB(MageSpike, netname, string, "magespike");
+/* wepname */ ATTRIB(MageSpike, message, string, _("Mage spike"));
+ENDCLASS(MageSpike)
+REGISTER_WEAPON(MAGE_SPIKE, NEW(MageSpike));
+
+#endif
+
+#ifdef IMPLEMENTATION
+
#ifdef SVQC
+
+void M_Mage_Attack_Spike(vector dir);
+METHOD(MageSpike, wr_think, bool(entity thiswep, bool fire1, bool fire2)) {
+ SELFPARAM();
+ if (fire1)
+ if (weapon_prepareattack(0, WEP_CVAR_PRI(electro, refire))) {
+ if (!self.target_range) self.target_range = autocvar_g_monsters_target_range;
+ self.enemy = Monster_FindTarget(self);
+ W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
+ M_Mage_Attack_Spike(w_shotdir);
+ weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
+ }
+ return true;
+}
+
float autocvar_g_monster_mage_health;
float autocvar_g_monster_mage_damageforcescale = 0.5;
float autocvar_g_monster_mage_attack_spike_damage;
{SELFPARAM();
self.event_damage = func_null;
- sound(self, CH_SHOTS, W_Sound("grenade_impact"), VOL_BASE, ATTEN_NORM);
+ sound(self, CH_SHOTS, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
self.realowner.mage_spike = world;
// copied from W_Seeker_Think
void M_Mage_Attack_Spike_Think()
{SELFPARAM();
- entity e;
- vector desireddir, olddir, newdir, eorg;
- float turnrate;
- float dist;
- float spd;
-
- if (time > self.ltime || self.enemy.health <= 0 || self.owner.health <= 0)
- {
+ if (time > self.ltime || (self.enemy && self.enemy.health <= 0) || self.owner.health <= 0) {
self.projectiledeathtype |= HITTYPE_SPLASH;
M_Mage_Attack_Spike_Explode();
}
- spd = vlen(self.velocity);
+ float spd = vlen(self.velocity);
spd = bound(
spd - (autocvar_g_monster_mage_attack_spike_decel) * frametime,
(autocvar_g_monster_mage_attack_spike_speed_max),
if (self.enemy != world)
{
- e = self.enemy;
- eorg = 0.5 * (e.absmin + e.absmax);
- turnrate = (autocvar_g_monster_mage_attack_spike_turnrate); // how fast to turn
- desireddir = normalize(eorg - self.origin);
- olddir = normalize(self.velocity); // get my current direction
- dist = vlen(eorg - self.origin);
+ entity e = self.enemy;
+ vector eorg = 0.5 * (e.absmin + e.absmax);
+ float turnrate = (autocvar_g_monster_mage_attack_spike_turnrate); // how fast to turn
+ vector desireddir = normalize(eorg - self.origin);
+ vector olddir = normalize(self.velocity); // get my current direction
+ float dist = vlen(eorg - self.origin);
// Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
if ((autocvar_g_monster_mage_attack_spike_smart) && (dist > (autocvar_g_monster_mage_attack_spike_smart_mindist)))
desireddir = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
}
- newdir = normalize(olddir + desireddir * turnrate); // take the average of the 2 directions; not the best method but simple & easy
+ vector newdir = normalize(olddir + desireddir * turnrate); // take the average of the 2 directions; not the best method but simple & easy
self.velocity = newdir * spd; // make me fly in the new direction at my flight speed
}
- else
- dist = 0;
///////////////
UpdateCSQCProjectile(self);
}
-void M_Mage_Attack_Spike()
-{SELFPARAM();
- entity missile;
- vector dir = normalize((self.enemy.origin + '0 0 10') - self.origin);
+void M_Mage_Attack_Spike(vector dir);
+void M_Mage_Attack_Spike_Aim()
+{
+ SELFPARAM();
+ return M_Mage_Attack_Spike(normalize((self.enemy.origin + '0 0 10') - self.origin));
+}
+void M_Mage_Attack_Spike(vector dir)
+{
+ SELFPARAM();
makevectors(self.angles);
- missile = spawn ();
+ entity missile = spawn();
missile.owner = missile.realowner = self;
missile.think = M_Mage_Attack_Spike_Think;
missile.ltime = time + 7;
missile.movetype = MOVETYPE_FLYMISSILE;
missile.flags = FL_PROJECTILE;
setorigin(missile, self.origin + v_forward * 14 + '0 0 30' + v_right * -14);
- setsize (missile, '0 0 0', '0 0 0');
+ setsize(missile, '0 0 0', '0 0 0');
missile.velocity = dir * 400;
missile.avelocity = '300 300 300';
missile.enemy = self.enemy;
void M_Mage_Attack_Push()
{SELFPARAM();
- sound(self, CH_SHOTS, W_Sound("tagexp1"), 1, ATTEN_NORM);
+ sound(self, CH_SHOTS, SND_TAGEXP1, 1, ATTEN_NORM);
RadiusDamage (self, self, (autocvar_g_monster_mage_attack_push_damage), (autocvar_g_monster_mage_attack_push_damage), (autocvar_g_monster_mage_attack_push_radius), world, world, (autocvar_g_monster_mage_attack_push_force), DEATH_MONSTER_MAGE, self.enemy);
Send_Effect(EFFECT_TE_EXPLOSION, self.origin, '0 0 0', 1);
setanim(self, self.anim_shoot, true, true, true);
self.attack_finished_single = time + (autocvar_g_monster_mage_attack_spike_delay);
self.anim_finished = time + 1;
- Monster_Delay(1, 0, 0.2, M_Mage_Attack_Spike);
+ Monster_Delay(1, 0, 0.2, M_Mage_Attack_Spike_Aim);
return true;
}
}
#endif // SVQC
-bool M_Mage(int req)
-{SELFPARAM();
- switch(req)
- {
#ifdef SVQC
- case MR_THINK:
+ METHOD(Mage, mr_think, bool(Monster thismon))
{
+ SELFPARAM();
entity head;
bool need_help = false;
return true;
}
- case MR_PAIN:
+ METHOD(Mage, mr_pain, bool(Monster thismon))
{
return true;
}
- case MR_DEATH:
+ METHOD(Mage, mr_death, bool(Monster thismon))
{
+ SELFPARAM();
setanim(self, self.anim_die1, false, true, true);
return true;
}
#endif
#ifndef MENUQC
- case MR_ANIM:
+ METHOD(Mage, mr_anim, bool(Monster thismon))
{
+ SELFPARAM();
vector none = '0 0 0';
self.anim_die1 = animfixfps(self, '4 1 0.5', none); // 2 seconds
self.anim_walk = animfixfps(self, '1 1 1', none);
}
#endif
#ifdef SVQC
- case MR_SETUP:
+ METHOD(Mage, mr_setup, bool(Monster thismon))
{
+ SELFPARAM();
if(!self.health) self.health = (autocvar_g_monster_mage_health);
if(!self.speed) { self.speed = (autocvar_g_monster_mage_speed_walk); }
if(!self.speed2) { self.speed2 = (autocvar_g_monster_mage_speed_run); }
return true;
}
- case MR_PRECACHE:
+ METHOD(Mage, mr_precache, bool(Monster thismon))
{
- precache_sound (W_Sound("grenade_impact"));
- precache_sound (W_Sound("tagexp1"));
return true;
}
#endif
- }
- return true;
-}
+#endif