]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/monsters/sv_monsters.qc
#define use use1
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / sv_monsters.qc
index 10725c0d6b40e1fb01efc34a3bf2fa891709b855..def29e969df9a8b373d50121deb37f77065877dc 100644 (file)
@@ -48,7 +48,7 @@ void monster_dropitem(entity this)
        if(e && e.monster_loot)
        {
                e.noalign = true;
-               WITH(entity, self, e, e.monster_loot(e));
+               WITHSELF(e, e.monster_loot(e));
                e.gravity = 1;
                e.movetype = MOVETYPE_TOSS;
                e.reset = SUB_Remove;
@@ -90,7 +90,7 @@ bool Monster_ValidTarget(entity this, entity targ)
        || (!IS_VEHICLE(targ) && (IS_DEAD(targ) || IS_DEAD(this) || targ.health <= 0 || this.health <= 0))
        || (this.monster_follow == targ || targ.monster_follow == this)
        || (!IS_VEHICLE(targ) && (targ.flags & FL_NOTARGET))
-       || (!autocvar_g_monsters_typefrag && targ.BUTTON_CHAT)
+       || (!autocvar_g_monsters_typefrag && PHYS_INPUT_BUTTON_CHAT(targ))
        || (SAME_TEAM(targ, this))
        || (STAT(FROZEN, targ))
        || (targ.alpha != 0 && targ.alpha < 0.5)
@@ -138,7 +138,7 @@ entity Monster_FindTarget(entity mon)
                        if(closest_target)
                        {
                                vector closest_target_center = CENTER_OR_VIEWOFS(closest_target);
-                               if(vlen(ent_center - head_center) < vlen(ent_center - closest_target_center))
+                               if(vlen2(ent_center - head_center) < vlen2(ent_center - closest_target_center))
                                        { closest_target = head; }
                        }
                        else { closest_target = head; }
@@ -211,6 +211,7 @@ void Monster_Delay_Action(entity this)
 
 void Monster_Delay_Action_self()
 {
+    SELFPARAM();
        Monster_Delay_Action(self);
 }
 
@@ -429,9 +430,7 @@ void Monster_Attack_Check(entity this, entity targ)
        || (time < this.attack_finished_single[0])
        ) { return; }
 
-       float targ_vlen = vlen(targ.origin - this.origin);
-
-       if(targ_vlen <= this.attack_range)
+       if(vdist(targ.origin - this.origin, <=, this.attack_range))
        {
                bool attack_success = this.monster_attackfunc(MONSTER_ATTACK_MELEE, this, targ);
                if(attack_success == 1)
@@ -440,7 +439,7 @@ void Monster_Attack_Check(entity this, entity targ)
                        return;
        }
 
-       if(targ_vlen > this.attack_range)
+       if(vdist(targ.origin - this.origin, >, this.attack_range))
        {
                float attack_success = this.monster_attackfunc(MONSTER_ATTACK_RANGED, this, targ);
                if(attack_success == 1)
@@ -549,9 +548,9 @@ void Monster_Dead_Fade(entity this)
        }
 }
 
-void Monster_Use()
-{SELFPARAM();
-       if(Monster_ValidTarget(this, activator)) { this.enemy = activator; }
+void Monster_Use(entity this, entity actor, entity trigger)
+{
+       if(Monster_ValidTarget(this, actor)) { this.enemy = actor; }
 }
 
 vector Monster_Move_Target(entity this, entity targ)
@@ -569,7 +568,7 @@ vector Monster_Move_Target(entity this, entity targ)
                        || (this.enemy.flags & FL_NOTARGET)
                        || (this.enemy.alpha < 0.5 && this.enemy.alpha != 0)
                        || (this.enemy.takedamage == DAMAGE_NO)
-                       || (vlen(this.origin - targ_origin) > this.target_range)
+                       || (vdist(this.origin - targ_origin, >, this.target_range))
                        || ((trace_fraction < 1) && (trace_ent != this.enemy)))
                {
                        this.enemy = world;
@@ -858,7 +857,7 @@ void Monster_Move(entity this, float runspeed, float walkspeed, float stpspeed)
        if(!(this.spawnflags & MONSTERFLAG_FLY_VERTICAL) && !(this.flags & FL_SWIM))
                this.moveto_z = this.origin_z;
 
-       if(vlen(this.origin - this.moveto) > 100)
+       if(vdist(this.origin - this.moveto, >, 100))
        {
                float do_run = (this.enemy || this.monster_moveto);
                if(IS_ONGROUND(this) || ((this.flags & FL_FLY) || (this.flags & FL_SWIM)))
@@ -867,7 +866,7 @@ void Monster_Move(entity this, float runspeed, float walkspeed, float stpspeed)
                if(time > this.pain_finished) // TODO: use anim_finished instead!
                if(!this.state)
                if(time > this.anim_finished)
-               if(vlen(this.velocity) > 10)
+               if(vdist(this.velocity, >, 10))
                        setanim(this, ((do_run) ? this.anim_run : this.anim_walk), true, false, false);
                else
                        setanim(this, this.anim_idle, true, false, false);
@@ -884,7 +883,7 @@ void Monster_Move(entity this, float runspeed, float walkspeed, float stpspeed)
                if(time > this.anim_finished)
                if(time > this.pain_finished)
                if(!this.state)
-               if(vlen(this.velocity) <= 30)
+               if(vdist(this.velocity, <=, 30))
                        setanim(this, this.anim_idle, true, false, false);
        }
 
@@ -905,6 +904,9 @@ void Monster_Move(entity this, float runspeed, float walkspeed, float stpspeed)
 
 void Monster_Remove(entity this)
 {
+       if(IS_CLIENT(this))
+               return; // don't remove it?
+
        .entity weaponentity = weaponentities[0];
        if(!this) { return; }
 
@@ -929,9 +931,9 @@ void Monster_Dead_Think()
        }
 }
 
-void Monster_Appear()
-{SELFPARAM();
-       this.enemy = activator;
+void Monster_Appear(entity this, entity actor, entity trigger)
+{
+       this.enemy = actor;
        this.spawnflags &= ~MONSTERFLAG_APPEAR; // otherwise, we get an endless loop
        Monster_Spawn(this, this.monsterid);
 }
@@ -1100,9 +1102,7 @@ void Monster_Damage(entity this, entity inflictor, entity attacker, float damage
                        this.candrop = false; // killed by mobkill command
 
                // TODO: fix this?
-               activator = attacker;
-               other = this.enemy;
-               WITH(entity, self, this, SUB_UseTargets());
+               SUB_UseTargets(this, attacker, this.enemy);
                this.target2 = this.oldtarget2; // reset to original target on death, incase we respawn
 
                Monster_Dead(this, attacker, (this.health <= -100 || deathtype == DEATH_KILL.m_id));
@@ -1171,7 +1171,7 @@ void Monster_Move_2D(entity this, float mspeed, bool allow_jumpoff)
 
        if(time > this.pain_finished)
        if(time > this.attack_finished_single[0])
-       if(vlen(this.velocity) > 10)
+       if(vdist(this.velocity, >, 10))
                setanim(this, this.anim_walk, true, false, false);
        else
                setanim(this, this.anim_idle, true, false, false);
@@ -1363,6 +1363,9 @@ bool Monster_Spawn(entity this, int mon_id)
        if(autocvar_g_nodepthtestplayers) { this.effects |= EF_NODEPTHTEST; }
        if(mon.spawnflags & MONSTER_TYPE_SWIM) { this.flags |= FL_SWIM; }
 
+       if(autocvar_g_playerclip_collisions)
+               this.dphitcontentsmask |= DPCONTENTS_PLAYERCLIP;
+
        if(mon.spawnflags & MONSTER_TYPE_FLY)
        {
                this.flags |= FL_FLY;