From: Mario Date: Thu, 21 Jun 2018 12:47:18 +0000 (+1000) Subject: Some minor cleanups, fix some monsters not getting close enough to their target to... X-Git-Tag: xonotic-v0.8.5~7^2~1^2~43 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=47cabd5fc5c6b825b7b9d0a11fb7e76b3d4c3d35;p=xonotic%2Fxonotic-data.pk3dir.git Some minor cleanups, fix some monsters not getting close enough to their target to attack it --- diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index e7056f6c6c..517e8494c8 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -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); } } diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index b68aca16fe..3537cf61f5 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -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); } diff --git a/qcsrc/common/turrets/sv_turrets.qh b/qcsrc/common/turrets/sv_turrets.qh index deee313ab1..3e9d6fa0e5 100644 --- a/qcsrc/common/turrets/sv_turrets.qh +++ b/qcsrc/common/turrets/sv_turrets.qh @@ -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; diff --git a/qcsrc/common/turrets/turret/ewheel.qc b/qcsrc/common/turrets/turret/ewheel.qc index c0a0b177ee..82793ec7c9 100644 --- a/qcsrc/common/turrets/turret/ewheel.qc +++ b/qcsrc/common/turrets/turret/ewheel.qc @@ -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) diff --git a/qcsrc/common/turrets/turret/walker.qc b/qcsrc/common/turrets/turret/walker.qc index 6aa0865e69..efb2ab3020 100644 --- a/qcsrc/common/turrets/turret/walker.qc +++ b/qcsrc/common/turrets/turret/walker.qc @@ -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)