/* Copyright (C) 1996-1997 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA See file, 'COPYING', for details. */ // This is a code harness for the tutor bot, which relies on some SP stuff. // It has been designed to be the _absolute minimum_ that the bot needs to // funciton, so there shouldn't be any duplication of code. /* ============= range returns the range catagorization of an entity reletive to self 0 melee range, will become hostile even if back is turned 1 visibility and infront, or visibility and show hostile 2 infront and show hostile 3 only triggered by damage ============= */ float range (entity targ) { vector spot1, spot2; float r; spot1 = self.origin + self.view_ofs; spot2 = targ.origin + targ.view_ofs; r = vlen (spot1 - spot2); if (r < 120) return RANGE_MELEE; if (r < 500) return RANGE_NEAR; if (r < 1000) return RANGE_MID; return RANGE_FAR; } /* ============= visible returns 1 if the entity is visible to self, even if not infront () ============= */ float visible (entity targ) { vector spot1, spot2; spot1 = self.origin + self.view_ofs; spot2 = targ.origin + targ.view_ofs; traceline (spot1, spot2, true, self); // see through other monsters if (trace_inopen && trace_inwater) return false; // sight line crossed contents if (trace_fraction == 1) return true; return false; } /* ============= infront returns 1 if the entity is in front (in sight) of self ============= */ float infront (entity targ) { vector vec; float dot; makevectors (self.angles); vec = normalize (targ.origin - self.origin); dot = vec * v_forward; if ( dot > 0.3) { return true; } return false; }