]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/monsters/sv_monsters.qc
Merge branch 'master' into Mario/monsters
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / sv_monsters.qc
index 5307ccd2de7324b0cb9430d3b6481295f04b0dbe..20e7b26a1cc993513b07b7f91ad06bf8de763986 100644 (file)
@@ -125,21 +125,27 @@ entity Monster_FindTarget(entity this)
        vector my_center = CENTER_OR_VIEWOFS(this);
 
        // find the closest acceptable target to pass to
-       IL_EACH(g_monster_targets, it.monster_attack && vdist(it.origin - this.origin, <, this.target_range),
+       IL_EACH(g_monster_targets, it.monster_attack,
        {
-               if(Monster_ValidTarget(this, it))
-               {
-                       // if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc)
-                       vector targ_center = CENTER_OR_VIEWOFS(it);
+               float trange = this.target_range;
+               if(PHYS_INPUT_BUTTON_CROUCH(it))
+                       trange *= 0.75; // TODO cvar this
+               vector theirmid = (it.absmin + it.absmax) * 0.5;
+               if(vdist(theirmid - this.origin, >, trange))
+                       continue;
+               if(!Monster_ValidTarget(this, it))
+                       continue;
 
-                       if(closest_target)
-                       {
-                               vector closest_target_center = CENTER_OR_VIEWOFS(closest_target);
-                               if(vlen2(my_center - targ_center) < vlen2(my_center - closest_target_center))
-                                       { closest_target = it; }
-                       }
-                       else { closest_target = it; }
+               // if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc)
+               vector targ_center = CENTER_OR_VIEWOFS(it);
+
+               if(closest_target)
+               {
+                       vector closest_target_center = CENTER_OR_VIEWOFS(closest_target);
+                       if(vlen2(my_center - targ_center) < vlen2(my_center - closest_target_center))
+                               { closest_target = it; }
                }
+               else { closest_target = it; }
        });
 
        return closest_target;
@@ -166,6 +172,11 @@ void monster_setupcolors(entity this)
                else
                        this.colormap = 1024;
        }
+
+       if(this.colormap > 0)
+               this.glowmod = colormapPaletteColor(this.colormap & 0x0F, false);
+       else
+               this.glowmod = '1 1 1';
 }
 
 void monster_changeteam(entity this, int newteam)
@@ -943,7 +954,7 @@ void Monster_Dead(entity this, entity attacker, float gibbed)
 
        if(IS_PLAYER(attacker))
        if(autocvar_g_monsters_score_spawned || !((this.spawnflags & MONSTERFLAG_SPAWNED) || (this.spawnflags & MONSTERFLAG_RESPAWNED)))
-               PlayerScore_Add(attacker, SP_SCORE, +autocvar_g_monsters_score_kill);
+               GameRules_scoring_add(attacker, SCORE, +autocvar_g_monsters_score_kill);
 
        if(gibbed)
        {
@@ -1393,15 +1404,8 @@ bool Monster_Spawn(entity this, bool check_appear, int mon_id)
                set_movetype(this, MOVETYPE_FLY);
        }
 
-       if(!(this.spawnflags & MONSTERFLAG_RESPAWNED))
-       {
-               if(mon.spawnflags & MONSTER_SIZE_BROKEN)
-                       this.scale *= 1.3;
-
-               if(mon.spawnflags & MONSTER_SIZE_QUAKE)
-               if(autocvar_g_monsters_quake_resize)
-                       this.scale *= 1.3;
-       }
+       if((mon.spawnflags & MONSTER_SIZE_QUAKE) && autocvar_g_monsters_quake_resize && !(this.spawnflags & MONSTERFLAG_RESPAWNED))
+               this.scale *= 1.3;
 
        setsize(this, mon.m_mins * this.scale, mon.m_maxs * this.scale);