]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/monsters/monster/mage.qc
Purge self from the damage/death mutator hooks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster / mage.qc
index 37c6301fbdbf8fcd5bd8f97620821f88c7f0914c..2401c9011a4eabaa25d9a0ac2eb4d7f9ca453889 100644 (file)
@@ -42,12 +42,14 @@ REGISTER_WEAPON(MAGE_SPIKE, NEW(MageSpike));
 SOUND(MageSpike_FIRE, W_Sound("electro_fire"));
 void M_Mage_Attack_Spike(entity this, vector dir);
 void M_Mage_Attack_Push(entity this);
-METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, .entity weaponentity, int fire)) {
+METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, .entity weaponentity, int fire))
+{
+    TC(MageSpike, thiswep);
     if (fire & 1)
     if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, weaponentity, false, 0.2)) {
         if (!actor.target_range) actor.target_range = autocvar_g_monsters_target_range;
         actor.enemy = Monster_FindTarget(actor);
-        W_SetupShot_Dir(actor, v_forward, false, 0, SND(MageSpike_FIRE), CH_WEAPON_B, 0);
+        W_SetupShot_Dir(actor, v_forward, false, 0, SND_MageSpike_FIRE, CH_WEAPON_B, 0);
        if (!IS_PLAYER(actor)) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin);
         M_Mage_Attack_Spike(actor, w_shotdir);
         weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
@@ -65,6 +67,7 @@ CLASS(OffhandMageTeleport, OffhandWeapon)
     .bool OffhandMageTeleport_key_pressed;
     METHOD(OffhandMageTeleport, offhand_think, void(OffhandMageTeleport this, entity player, bool key_pressed))
     {
+        TC(OffhandMageTeleport, this);
         if (key_pressed && !player.OffhandMageTeleport_key_pressed)
                M_Mage_Attack_Teleport(player, player.enemy);
         player.OffhandMageTeleport_key_pressed = key_pressed;
@@ -157,9 +160,9 @@ void M_Mage_Attack_Spike_Explode(entity this)
        remove (this);
 }
 
-void M_Mage_Attack_Spike_Touch()
+void M_Mage_Attack_Spike_Touch(entity this)
 {
-       PROJECTILE_TOUCH;
+       PROJECTILE_TOUCH(this);
 
        M_Mage_Attack_Spike_Explode(self);
 }
@@ -167,57 +170,57 @@ void M_Mage_Attack_Spike_Touch()
 .float wait;
 
 // copied from W_Seeker_Think
-void M_Mage_Attack_Spike_Think()
-{SELFPARAM();
-       if (time > self.ltime || (self.enemy && self.enemy.health <= 0) || self.owner.health <= 0) {
-               self.projectiledeathtype |= HITTYPE_SPLASH;
-               M_Mage_Attack_Spike_Explode(self);
+void M_Mage_Attack_Spike_Think(entity this)
+{
+       if (time > this.ltime || (this.enemy && this.enemy.health <= 0) || this.owner.health <= 0) {
+               this.projectiledeathtype |= HITTYPE_SPLASH;
+               M_Mage_Attack_Spike_Explode(this);
        }
 
-       float spd = vlen(self.velocity);
+       float spd = vlen(this.velocity);
        spd = bound(
                spd - (autocvar_g_monster_mage_attack_spike_decel) * frametime,
                (autocvar_g_monster_mage_attack_spike_speed_max),
                spd + (autocvar_g_monster_mage_attack_spike_accel) * frametime
        );
 
-       if (self.enemy != world)
-               if (self.enemy.takedamage != DAMAGE_AIM || IS_DEAD(self.enemy))
-                       self.enemy = world;
+       if (this.enemy != world)
+               if (this.enemy.takedamage != DAMAGE_AIM || IS_DEAD(this.enemy))
+                       this.enemy = world;
 
-       if (self.enemy != world)
+       if (this.enemy != world)
        {
-               entity e = self.enemy;
+               entity e = this.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
+               vector desireddir = normalize(eorg - this.origin);
+               vector olddir = normalize(this.velocity); // get my current direction
 
                // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
-               if ((autocvar_g_monster_mage_attack_spike_smart) && vdist(eorg - self.origin, >, autocvar_g_monster_mage_attack_spike_smart_mindist))
+               if ((autocvar_g_monster_mage_attack_spike_smart) && vdist(eorg - this.origin, >, autocvar_g_monster_mage_attack_spike_smart_mindist))
                {
-                       // Is it a better idea (shorter distance) to trace to the target itself?
-                       if ( vlen2(self.origin + olddir * self.wait) < vlen2(eorg - self.origin))
-                               traceline(self.origin, self.origin + olddir * self.wait, false, self);
+                       // Is it a better idea (shorter distance) to trace to the target itthis?
+                       if ( vlen2(this.origin + olddir * this.wait) < vlen2(eorg - this.origin))
+                               traceline(this.origin, this.origin + olddir * this.wait, false, this);
                        else
-                               traceline(self.origin, eorg, false, self);
+                               traceline(this.origin, eorg, false, this);
 
                        // Setup adaptive tracelength
-                       self.wait = bound((autocvar_g_monster_mage_attack_spike_smart_trace_min), vlen(self.origin - trace_endpos), self.wait = (autocvar_g_monster_mage_attack_spike_smart_trace_max));
+                       this.wait = bound((autocvar_g_monster_mage_attack_spike_smart_trace_min), vlen(this.origin - trace_endpos), this.wait = (autocvar_g_monster_mage_attack_spike_smart_trace_max));
 
                        // Calc how important it is that we turn and add this to the desierd (enemy) dir.
                        desireddir = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
                }
 
                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
+               this.velocity = newdir * spd; // make me fly in the new direction at my flight speed
        }
 
        ///////////////
 
-       //self.angles = vectoangles(self.velocity);                     // turn model in the new flight direction
-       self.nextthink = time;// + 0.05; // csqc projectiles
-       UpdateCSQCProjectile(self);
+       //this.angles = vectoangles(this.velocity);                     // turn model in the new flight direction
+       this.nextthink = time;// + 0.05; // csqc projectiles
+       UpdateCSQCProjectile(this);
 }
 
 void M_Mage_Attack_Spike(entity this, vector dir)
@@ -226,7 +229,7 @@ void M_Mage_Attack_Spike(entity this, vector dir)
 
        entity missile = spawn();
        missile.owner = missile.realowner = this;
-       missile.think = M_Mage_Attack_Spike_Think;
+       setthink(missile, M_Mage_Attack_Spike_Think);
        missile.ltime = time + 7;
        missile.nextthink = time;
        missile.solid = SOLID_BBOX;
@@ -237,7 +240,7 @@ void M_Mage_Attack_Spike(entity this, vector dir)
        missile.velocity = dir * 400;
        missile.avelocity = '300 300 300';
        missile.enemy = this.enemy;
-       missile.touch = M_Mage_Attack_Spike_Touch;
+       settouch(missile, M_Mage_Attack_Spike_Touch);
 
        this.mage_spike = missile;
 
@@ -326,7 +329,7 @@ void M_Mage_Attack_Teleport(entity this, entity targ)
 
        Send_Effect(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1);
        Send_Effect(EFFECT_SPAWN_NEUTRAL, newpos, '0 0 0', 1);
-       
+
        setorigin(this, newpos);
 
        vector a = vectoangles(targ.origin - this.origin);
@@ -408,81 +411,91 @@ spawnfunc(monster_mage) { Monster_Spawn(this, MON_MAGE.monsterid); }
 
 #endif // SVQC
 
-               #ifdef SVQC
-               METHOD(Mage, mr_think, bool(Mage thismon, entity actor))
-               {
-                       bool need_help = false;
+#ifdef SVQC
+METHOD(Mage, mr_think, bool(Mage thismon, entity actor))
+{
+    TC(Mage, thismon);
+    bool need_help = false;
 
-                       FOREACH_ENTITY_FLOAT(iscreature, true,
-                       {
-                               if(it != actor)
-                               if(vdist(it.origin - actor.origin, <=, autocvar_g_monster_mage_heal_range))
-                               if(M_Mage_Defend_Heal_Check(actor, it))
-                               {
-                                       need_help = true;
-                                       break;
-                               }
-                       });
+    FOREACH_ENTITY_FLOAT(iscreature, true,
+    {
+        if(it != actor)
+        if(vdist(it.origin - actor.origin, <=, autocvar_g_monster_mage_heal_range))
+        if(M_Mage_Defend_Heal_Check(actor, it))
+        {
+            need_help = true;
+            break;
+        }
+    });
+
+    if(actor.health < (autocvar_g_monster_mage_heal_minhealth) || need_help)
+    if(time >= actor.attack_finished_single[0])
+    if(random() < 0.5)
+        M_Mage_Defend_Heal(actor);
+
+    if(time >= actor.mage_shield_time && actor.armorvalue)
+        M_Mage_Defend_Shield_Remove(actor);
+
+    if(actor.enemy)
+    if(actor.health < actor.max_health)
+    if(time >= actor.mage_shield_delay)
+    if(random() < 0.5)
+        M_Mage_Defend_Shield(actor);
+
+    return true;
+}
 
-                       if(actor.health < (autocvar_g_monster_mage_heal_minhealth) || need_help)
-                       if(time >= actor.attack_finished_single[0])
-                       if(random() < 0.5)
-                               M_Mage_Defend_Heal(actor);
+METHOD(Mage, mr_pain, float(Mage this, entity actor, float damage_take, entity attacker, float deathtype))
+{
+    TC(Mage, this);
+    return damage_take;
+}
 
-                       if(time >= actor.mage_shield_time && actor.armorvalue)
-                               M_Mage_Defend_Shield_Remove(actor);
+METHOD(Mage, mr_death, bool(Mage this, entity actor))
+{
+    TC(Mage, this);
+    setanim(actor, actor.anim_die1, false, true, true);
+    return true;
+}
 
-                       if(actor.enemy)
-                       if(actor.health < actor.max_health)
-                       if(time >= actor.mage_shield_delay)
-                       if(random() < 0.5)
-                               M_Mage_Defend_Shield(actor);
+#endif
+#ifndef MENUQC
+METHOD(Mage, mr_anim, bool(Mage this, entity actor))
+{
+    TC(Mage, this);
+    vector none = '0 0 0';
+    actor.anim_die1 = animfixfps(actor, '4 1 0.5', none); // 2 seconds
+    actor.anim_walk = animfixfps(actor, '1 1 1', none);
+    actor.anim_idle = animfixfps(actor, '0 1 1', none);
+    actor.anim_pain1 = animfixfps(actor, '3 1 2', none); // 0.5 seconds
+    actor.anim_shoot = animfixfps(actor, '2 1 5', none); // analyze models and set framerate
+    actor.anim_run = animfixfps(actor, '5 1 1', none);
+    return true;
+}
+#endif
+#ifdef SVQC
+.float speed;
+spawnfunc(item_health_large);
+METHOD(Mage, mr_setup, bool(Mage this, entity actor))
+{
+    TC(Mage, this);
+    if(!actor.health) actor.health = (autocvar_g_monster_mage_health);
+    if(!actor.speed) { actor.speed = (autocvar_g_monster_mage_speed_walk); }
+    if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_mage_speed_run); }
+    if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_mage_speed_stop); }
+    if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_mage_damageforcescale); }
 
-                       return true;
-               }
-               METHOD(Mage, mr_pain, bool(Mage thismon, entity actor))
-               {
-                       return true;
-               }
-               METHOD(Mage, mr_death, bool(Mage thismon, entity actor))
-               {
-                       setanim(actor, actor.anim_die1, false, true, true);
-                       return true;
-               }
-               #endif
-               #ifndef MENUQC
-               METHOD(Mage, mr_anim, bool(Mage thismon, entity actor))
-               {
-                       vector none = '0 0 0';
-                       actor.anim_die1 = animfixfps(actor, '4 1 0.5', none); // 2 seconds
-                       actor.anim_walk = animfixfps(actor, '1 1 1', none);
-                       actor.anim_idle = animfixfps(actor, '0 1 1', none);
-                       actor.anim_pain1 = animfixfps(actor, '3 1 2', none); // 0.5 seconds
-                       actor.anim_shoot = animfixfps(actor, '2 1 5', none); // analyze models and set framerate
-                       actor.anim_run = animfixfps(actor, '5 1 1', none);
-                       return true;
-               }
-               #endif
-               #ifdef SVQC
-               .float speed;
-               spawnfunc(item_health_large);
-               METHOD(Mage, mr_setup, bool(Mage thismon, entity actor))
-               {
-                       if(!actor.health) actor.health = (autocvar_g_monster_mage_health);
-                       if(!actor.speed) { actor.speed = (autocvar_g_monster_mage_speed_walk); }
-                       if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_mage_speed_run); }
-                       if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_mage_speed_stop); }
-                       if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_mage_damageforcescale); }
+    actor.monster_loot = spawnfunc_item_health_large;
+    actor.monster_attackfunc = M_Mage_Attack;
 
-                       actor.monster_loot = spawnfunc_item_health_large;
-                       actor.monster_attackfunc = M_Mage_Attack;
+    return true;
+}
 
-                       return true;
-               }
-               METHOD(Mage, mr_precache, bool(Mage thismon))
-               {
-                       return true;
-               }
-               #endif
+METHOD(Mage, mr_precache, bool(Mage this))
+{
+    TC(Mage, this);
+    return true;
+}
+#endif
 
 #endif