X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fbot%2Fdefault%2Faim.qc;h=768aa6daee2bb2719c759eb5f9f7dc4354f5f264;hp=8f2abb3f824b5745448a5fb4c16ab21545e5451b;hb=70bba988cd32922d29e40235db6ad1d8149bdc67;hpb=8121bbc66f59f5c03939e3ce60575fcbc30ef764 diff --git a/qcsrc/server/bot/default/aim.qc b/qcsrc/server/bot/default/aim.qc index 8f2abb3f8..768aa6dae 100644 --- a/qcsrc/server/bot/default/aim.qc +++ b/qcsrc/server/bot/default/aim.qc @@ -11,7 +11,7 @@ #include "../../weapons/weaponsystem.qh" -#include "../../mutators/_mod.qh" +#include // traces multiple trajectories to find one that will impact the target // 'end' vector is the place it aims for, @@ -132,18 +132,19 @@ bool bot_shouldattack(entity this, entity targ) if(targ.team==0) return false; } - else if(bot_ignore_bots) - if(IS_BOT_CLIENT(targ)) - return false; + else if (autocvar_bot_ignore_bots && IS_BOT_CLIENT(targ)) + return false; if (!targ.takedamage) return false; if (IS_DEAD(targ)) return false; - if (PHYS_INPUT_BUTTON_CHAT(targ)) + if (PHYS_INPUT_BUTTON_CHAT(targ) && !autocvar_bot_typefrag) return false; if(targ.flags & FL_NOTARGET) return false; + if(targ.alpha <= 0.1 && targ.alpha != 0) + return false; // invisible via alpha if(MUTATOR_CALLHOOK(BotShouldAttack, this, targ)) return false; @@ -153,11 +154,6 @@ bool bot_shouldattack(entity this, entity targ) void bot_lagfunc(entity this, float t, float f1, float f2, entity e1, vector v1, vector v2, vector v3, vector v4) { - if(this.flags & FL_INWATER) - { - this.bot_aimtarg = NULL; - return; - } this.bot_aimtarg = e1; this.bot_aimlatency = CS(this).ping; // FIXME? Shouldn't this be in the lag item? //this.bot_aimorigin = v1; @@ -174,16 +170,21 @@ void bot_lagfunc(entity this, float t, float f1, float f2, entity e1, vector v1, this.bot_canfire = 1; } -float bot_aimdir(entity this, vector v, float maxfiredeviation) +void bot_aimdir(entity this, vector v, float maxfiredeviation) { float dist, delta_t, blend; vector desiredang, diffang; + this.bot_aimdir_executed = true; + //dprint("aim ", this.netname, ": old:", vtos(this.v_angle)); // make sure v_angle is sane first this.v_angle_y = this.v_angle.y - floor(this.v_angle.y / 360) * 360; this.v_angle_z = 0; + // invalid aim dir (can happen when bot overlaps target) + if(!v) return; + // get the desired angles to aim at //dprint(" at:", vtos(v)); v = normalize(v); @@ -241,6 +242,7 @@ float bot_aimdir(entity this, vector v, float maxfiredeviation) + this.bot_4th_order_aimfilter * autocvar_bot_ai_aimskill_order_mix_4th + this.bot_5th_order_aimfilter * autocvar_bot_ai_aimskill_order_mix_5th ); + desiredang.x = bound(-90, desiredang.x, 90); // calculate turn angles diffang = desiredang - this.bot_mouseaim; @@ -314,7 +316,7 @@ float bot_aimdir(entity this, vector v, float maxfiredeviation) //dprint(ftos(maxfiredeviation),"\n"); //dprint(" diff:", vtos(diffang), "\n"); - return this.bot_canfire && (time < this.bot_firetimer); + //return this.bot_canfire && (time < this.bot_firetimer); } vector bot_shotlead(vector targorigin, vector targvelocity, float shotspeed, float shotdelay) @@ -325,7 +327,7 @@ vector bot_shotlead(vector targorigin, vector targvelocity, float shotspeed, flo bool bot_aim(entity this, .entity weaponentity, float shotspeed, float shotspeedupward, float maxshottime, bool applygravity) { - float f, r, hf, distanceratio; + float r, hf, distanceratio; vector v; /* eprint(this); @@ -367,11 +369,11 @@ bool bot_aim(entity this, .entity weaponentity, float shotspeed, float shotspeed return false; } - f = bot_aimdir(this, findtrajectory_velocity - shotspeedupward * '0 0 1', r); + bot_aimdir(this, findtrajectory_velocity - shotspeedupward * '0 0 1', r); } else { - f = bot_aimdir(this, v - shotorg, r); + bot_aimdir(this, v - shotorg, r); //dprint("AIM: ");dprint(vtos(this.bot_aimtargorigin));dprint(" + ");dprint(vtos(this.bot_aimtargvelocity));dprint(" * ");dprint(ftos(this.bot_aimlatency + vlen(this.bot_aimtargorigin - shotorg) / shotspeed));dprint(" = ");dprint(vtos(v));dprint(" : aimdir = ");dprint(vtos(normalize(v - shotorg)));dprint(" : ");dprint(vtos(shotdir));dprint("\n"); //traceline(shotorg, shotorg + shotdir * 10000, false, this); //if (trace_ent.takedamage)