00001 /* Copyright (C) 1996-1997 Id Software, Inc. 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00016 00017 See file, 'COPYING', for details. 00018 */ 00019 00020 // This is a code harness for the tutor bot, which relies on some SP stuff. 00021 // It has been designed to be the _absolute minimum_ that the bot needs to 00022 // funciton, so there shouldn't be any duplication of code. 00023 00024 /* 00025 ============= 00026 range 00027 00028 returns the range catagorization of an entity reletive to self 00029 0 melee range, will become hostile even if back is turned 00030 1 visibility and infront, or visibility and show hostile 00031 2 infront and show hostile 00032 3 only triggered by damage 00033 ============= 00034 */ 00035 float range (entity targ) 00036 { 00037 vector spot1, spot2; 00038 float r; 00039 spot1 = self.origin + self.view_ofs; 00040 spot2 = targ.origin + targ.view_ofs; 00041 00042 r = vlen (spot1 - spot2); 00043 if (r < 120) 00044 return RANGE_MELEE; 00045 if (r < 500) 00046 return RANGE_NEAR; 00047 if (r < 1000) 00048 return RANGE_MID; 00049 return RANGE_FAR; 00050 } 00051 00052 /* 00053 ============= 00054 visible 00055 00056 returns 1 if the entity is visible to self, even if not infront () 00057 ============= 00058 */ 00059 float visible (entity targ) 00060 { 00061 vector spot1, spot2; 00062 00063 spot1 = self.origin + self.view_ofs; 00064 spot2 = targ.origin + targ.view_ofs; 00065 traceline (spot1, spot2, true, self); // see through other monsters 00066 00067 if (trace_inopen && trace_inwater) 00068 return false; // sight line crossed contents 00069 00070 if (trace_fraction == 1) 00071 return true; 00072 return false; 00073 } 00074 00075 /* 00076 ============= 00077 infront 00078 00079 returns 1 if the entity is in front (in sight) of self 00080 ============= 00081 */ 00082 float infront (entity targ) 00083 { 00084 vector vec; 00085 float dot; 00086 00087 makevectors (self.angles); 00088 vec = normalize (targ.origin - self.origin); 00089 dot = vec * v_forward; 00090 00091 if ( dot > 0.3) 00092 { 00093 return true; 00094 } 00095 return false; 00096 } 00097
1.5.4