]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Some minor cleanups, fix some monsters not getting close enough to their target to...
authorMario <mario@smbclan.net>
Thu, 21 Jun 2018 12:47:18 +0000 (22:47 +1000)
committerMario <mario@smbclan.net>
Thu, 21 Jun 2018 12:47:18 +0000 (22:47 +1000)
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/turrets/sv_turrets.qh
qcsrc/common/turrets/turret/ewheel.qc
qcsrc/common/turrets/turret/walker.qc

index e7056f6c6cf6d5986cca83c2073bd07402f26167..517e8494c85287f0e04ad974432fd0c3197d436a 100644 (file)
@@ -583,14 +583,14 @@ vector Monster_Move_Target(entity this, entity targ)
                WarpZone_TraceLine(this.origin, targ_origin, MOVE_NOMONSTERS, this);
 
                // cases where the enemy may have changed their state (don't need to check everything here)
-               if((!this.enemy)
-                       || (IS_DEAD(this.enemy) || GetResourceAmount(this.enemy, RESOURCE_HEALTH) < 1)
+               if(    (IS_DEAD(this.enemy) || GetResourceAmount(this.enemy, RESOURCE_HEALTH) < 1)
                        || (STAT(FROZEN, this.enemy))
                        || (this.enemy.flags & FL_NOTARGET)
                        || (this.enemy.alpha < 0.5 && this.enemy.alpha != 0)
                        || (this.enemy.takedamage == DAMAGE_NO)
                        || (vdist(this.origin - targ_origin, >, this.target_range))
-                       || ((trace_fraction < 1) && (trace_ent != this.enemy)))
+                       || ((trace_fraction < 1) && (trace_ent != this.enemy))
+                       )
                {
                        this.enemy = NULL;
                        //this.pass_distance = 0;
@@ -787,7 +787,7 @@ void Monster_Move(entity this, float runspeed, float walkspeed, float stpspeed)
        fixedmakevectors(this.angles);
        float vz = this.velocity_z;
 
-       if(!turret_closetotarget(this, this.moveto))
+       if(!turret_closetotarget(this, this.moveto, 16))
        {
                bool do_run = (this.enemy || this.monster_moveto);
                movelib_move_simple(this, v_forward, ((do_run) ? runspeed : walkspeed), 0.4);
@@ -1196,21 +1196,21 @@ void Monster_Frozen_Think(entity this)
 
 void Monster_Enemy_Check(entity this)
 {
-       if(!this.enemy)
+       if(this.enemy)
+               return;
+
+       this.enemy = Monster_FindTarget(this);
+       if(this.enemy)
        {
-               this.enemy = Monster_FindTarget(this);
-               if(this.enemy)
-               {
-                       WarpZone_RefSys_Copy(this.enemy, this);
-                       WarpZone_RefSys_AddInverse(this.enemy, this); // wz1^-1 ... wzn^-1 receiver
-                       // update move target immediately?
-                       this.moveto = WarpZone_RefSys_TransformOrigin(this.enemy, this, (0.5 * (this.enemy.absmin + this.enemy.absmax)));
-                       this.monster_moveto = '0 0 0';
-                       this.monster_face = '0 0 0';
-
-                       //this.pass_distance = vlen((('1 0 0' * this.enemy.origin_x) + ('0 1 0' * this.enemy.origin_y)) - (('1 0 0' *  this.origin_x) + ('0 1 0' *  this.origin_y)));
-                       Monster_Sound(this, monstersound_sight, 0, false, CH_VOICE);
-               }
+               WarpZone_RefSys_Copy(this.enemy, this);
+               WarpZone_RefSys_AddInverse(this.enemy, this); // wz1^-1 ... wzn^-1 receiver
+               // update move target immediately?
+               this.moveto = WarpZone_RefSys_TransformOrigin(this.enemy, this, (0.5 * (this.enemy.absmin + this.enemy.absmax)));
+               this.monster_moveto = '0 0 0';
+               this.monster_face = '0 0 0';
+
+               //this.pass_distance = vlen((('1 0 0' * this.enemy.origin_x) + ('0 1 0' * this.enemy.origin_y)) - (('1 0 0' *  this.origin_x) + ('0 1 0' *  this.origin_y)));
+               Monster_Sound(this, monstersound_sight, 0, false, CH_VOICE);
        }
 }
 
index b68aca16feddd93b6ea01b555b49aa6b17d2c53a..3537cf61f5c3dab7952baf8ba8db7949ceaa04bb 100644 (file)
@@ -1254,9 +1254,9 @@ void turret_initparams(entity tur)
        #undef TRY
 }
 
-bool turret_closetotarget(entity this, vector targ)
+bool turret_closetotarget(entity this, vector targ, float range)
 {
-       vector path_extra_size = '64 64 64';
+       vector path_extra_size = '1 1 1' * range;
        return boxesoverlap(targ - path_extra_size, targ + path_extra_size, this.absmin - path_extra_size, this.absmax + path_extra_size);
 }
 
index deee313ab109204ce7e1acbba2cb1aaaa6921aac..3e9d6fa0e5797dd86d5f648569e3b6d4c1f1d39c 100644 (file)
@@ -90,7 +90,7 @@ void turrets_setframe(entity this, float _frame, float client_only);
 bool turret_initialize(entity this, Turret tur);
 
 // returns true when box overlaps with a given location
-bool turret_closetotarget(entity this, vector targ);
+bool turret_closetotarget(entity this, vector targ, float range);
 
 /// Function to use for target evaluation. usualy turret_targetscore_generic
 .float(entity _turret, entity _target) turret_score_target;
index c0a0b177ee2d179afb99aeb774203521daf5eeeb..82793ec7c91c735c313e2720f68cca8d48b0c603 100644 (file)
@@ -17,7 +17,7 @@ const int ewheel_anim_bck_fast = 4;
 void ewheel_move_path(entity this)
 {
     // Are we close enough to a path node to switch to the next?
-    if(turret_closetotarget(this, this.pathcurrent.origin))
+    if(turret_closetotarget(this, this.pathcurrent.origin, 64))
     {
 #ifdef EWHEEL_FANCYPATH
         if (this.pathcurrent.path_next == NULL)
index 6aa0865e69d1e4fac73d93ab9177f72278071985..efb2ab3020af732dcebcc300e03a427a0a61b270 100644 (file)
@@ -281,7 +281,7 @@ void walker_move_path(entity this)
 {
 #ifdef WALKER_FANCYPATHING
     // Are we close enougth to a path node to switch to the next?
-    if(turret_closetotarget(this, this.pathcurrent.origin))
+    if(turret_closetotarget(this, this.pathcurrent.origin, 64))
     {
         if (this.pathcurrent.path_next == NULL)
         {
@@ -312,7 +312,7 @@ void walker_move_path(entity this)
     walker_move_to(this, this.moveto, 0);
 
 #else
-    if(turret_closetotarget(this, this.pathcurrent.origin))
+    if(turret_closetotarget(this, this.pathcurrent.origin, 64))
         this.pathcurrent = this.pathcurrent.enemy;
 
     if(!this.pathcurrent)