.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Programming
General Programming Help others and get yourself helped here!

Reply
 
Thread Tools
Re: Looking to trace out at 45 degrees off the players center...
Old
  (#11)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: Looking to trace out at 45 degrees off the players center... - 20-06-2004

HL is based on Quake1, and RTCW is based on Quake3 so that's why they are similar and Quake1, Quake2, Quake3, RTCW are all in C instead of C++.

"because our MAKE_VECTORS is actually a macro that calls AngleVectors()..."
it doesn't call AngleVectors() but g_engfuncs.pfnMakeVectors() although they are actually the same thing
  
Reply With Quote
Re: Looking to trace out at 45 degrees off the players center...
Old
  (#12)
sfx1999
Member
 
sfx1999's Avatar
 
Status: Offline
Posts: 534
Join Date: Jan 2004
Location: Pittsburgh, PA, USA
Default Re: Looking to trace out at 45 degrees off the players center... - 20-06-2004

Pierre haven't you looked at Quake code yet? Please note that HL is based off Quake I and not Quake II. Also, make sure it is the QuakeWorld server code (unless you want client stuff).

In Quake I's mathlib.h:

Code:
/*
 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.
 
 */
 // mathlib.h
 
 typedef float vec_t;
 typedef vec_t vec3_t[3];
 typedef vec_t vec5_t[5];
 
 typedef	int	fixed4_t;
 typedef	int	fixed8_t;
 typedef	int	fixed16_t;
 
 #ifndef M_PI
 #define M_PI		3.14159265358979323846	// matches value in gcc v2 math.h
 #endif
 
 struct mplane_s;
 
 extern vec3_t vec3_origin;
 extern	int nanmask;
 
 #define	IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
 
 #define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
 #define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}
 #define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}
 #define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];}
 
 void VectorMA (vec3_t veca, float scale, vec3_t vecb, vec3_t vecc);
 
 vec_t _DotProduct (vec3_t v1, vec3_t v2);
 void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out);
 void _VectorAdd (vec3_t veca, vec3_t vecb, vec3_t out);
 void _VectorCopy (vec3_t in, vec3_t out);
 
 int VectorCompare (vec3_t v1, vec3_t v2);
 vec_t Length (vec3_t v);
 void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross);
 float VectorNormalize (vec3_t v);		// returns vector length
 void VectorInverse (vec3_t v);
 void VectorScale (vec3_t in, vec_t scale, vec3_t out);
 int Q_log2(int val);
 
 void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]);
 void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);
 
 void FloorDivMod (double numer, double denom, int *quotient,
 		int *rem);
 fixed16_t Invert24To16(fixed16_t val);
 fixed16_t Mul16_30(fixed16_t multiplier, fixed16_t multiplicand);
 int GreatestCommonDivisor (int i1, int i2);
 
 void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
 int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane);
 float	anglemod(float a);
 
 void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees );
 
 
 #define BOX_ON_PLANE_SIDE(emins, emaxs, p)	\
 	(((p)->type < 3)?    		    		\
 	(	    		    		    		\
 		((p)->dist <= (emins)[(p)->type])?	\
 		    1		    		    		\
 		:    		    		    		\
 		(    		    		    		\
 			((p)->dist >= (emaxs)[(p)->type])?\
 		    	2	    		    		\
 		    :		    		    		\
 		    	3	    		    		\
 		)    		    		    		\
 	)	    		    		    		\
 	:	    		    		    		\
 		BoxOnPlaneSide( (emins), (emaxs), (p)))
  
Reply With Quote
Re: Looking to trace out at 45 degrees off the players center...
Old
  (#13)
sfx1999
Member
 
sfx1999's Avatar
 
Status: Offline
Posts: 534
Join Date: Jan 2004
Location: Pittsburgh, PA, USA
Default Re: Looking to trace out at 45 degrees off the players center... - 20-06-2004

Make sure that you can change that angle!!!

When your bots zoom in with a rifle, it WILL change their FOV. If you don't the bots will be able to see anything as if they were not zoomed in.

  
Reply With Quote
Re: Looking to trace out at 45 degrees off the players center...
Old
  (#14)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: Looking to trace out at 45 degrees off the players center... - 20-06-2004

well, here's some more implementions of HL engine functions. Some of them are "crazily" optimized
I also inlined all of them to make them faster
Code:
inline float UTIL_AngleMod(float a)
{
   // this function adds or substracts 360 enough times needed to the given angle in
   // order to set it into the range [0, 360) and returns the resulting angle. Letting
   // the engine have a hand on angles that are outside these bounds may cause the
   // game to freeze by screwing up the engine math code.

   return (360.0 / 65536) * ((int)(a * (65536.0 / 360.0)) & 65535);
}

inline float AngleNormalize(float angle)
{
   // this function adds or substracts 360 enough times needed to the given angle in
   // order to set it into the range [-180, 180) and returns the resulting angle. Letting
   // the engine have a hand on angles that are outside these bounds may cause the game
   // to freeze by screwing up the engine math code.

   return (360.0 / 65536) * ((int)((angle + 180) * (65536.0 / 360.0)) & 65535) - 180;
}

inline void ClampAngles(Vector &vecAngles)
{
   vecAngles.x = AngleNormalize(vecAngles.x);
   vecAngles.y = AngleNormalize(vecAngles.y);
   vecAngles.z = 0;
}

void
#ifndef __BORLANDC__
inline
#endif
SinCos( float rad, float *flSin, float *flCos )
{
#ifdef __linux__
   register double __cosr, __sinr;
   __asm __volatile__ ("fsincos" : "=t" (__cosr), "=u" (__sinr) : "0" (rad));
   *flSin = __sinr;
   *flCos = __cosr;
#else
#if !defined(__BORLANDC__) && !defined(_MSC_VER)
   *flSin = sinf(rad);
   *flCos = cosf(rad);
#else
   __asm
   {
      fld DWORD PTR[rad]
      fsincos
      mov edx, DWORD PTR[flCos]
      mov eax, DWORD PTR[flSin]
      fstp DWORD PTR[edx]
      fstp DWORD PTR[eax]
   }
#endif
#endif
}

inline float UTIL_AngleDiff( float destAngle, float srcAngle )
{
   return AngleNormalize(destAngle - srcAngle);
}

inline float UTIL_VecToYaw( const Vector &vec )
{
   // the purpose of this function is to convert a spatial location determined by the vector
   // passed in into an absolute Y angle (yaw) from the origin of the world.

   if (vec.x == 0 && vec.y == 0)
      return 0;
   else
      return atan2(vec.y, vec.x) * (180 / M_PI);
}

inline Vector UTIL_VecToAngles( const Vector &vec )
{
   // the purpose of this function is to convert a spatial location determined by the vector
   // passed in into absolute angles from the origin of the world.

   float yaw, pitch;

   if (vec.x == 0 && vec.y == 0)
   {
      yaw = 0;
      pitch = (vec.z > 0) ? 90 : 270;
   }
   else
   {
      yaw = atan2(vec.y, vec.x) * (180 / M_PI);
      pitch = atan2(vec.z, vec.Length2D()) * (180 / M_PI);
   }

   return Vector(pitch, yaw, 0);
}

inline void UTIL_MakeVectors( const Vector &vecAngles )
{
   float sp = 0, cp = 0, sy = 0, cy = 0, sr = 0, cr = 0;
   float angle = vecAngles.x * (M_PI / 180);
   SinCos(angle, &sp, &cp);
   angle = vecAngles.y * (M_PI / 180);
   SinCos(angle, &sy, &cy);
   angle = vecAngles.z * (M_PI / 180);
   SinCos(angle, &sr, &cr);

   gpGlobals->v_forward.x = cp * cy;
   gpGlobals->v_forward.y = cp * sy;
   gpGlobals->v_forward.z = -sp;
   gpGlobals->v_right.x = -sr * sp * cy + cr * sy;
   gpGlobals->v_right.y = -sr * sp * sy - cr * cy;
   gpGlobals->v_right.z = -sr * cp;
   gpGlobals->v_up.x = cr * sp * cy + sr * sy;
   gpGlobals->v_up.y = cr * sp * sy - sr * cy;
   gpGlobals->v_up.z = cr * cp;
}
  
Reply With Quote
Re: Looking to trace out at 45 degrees off the players center...
Old
  (#15)
sfx1999
Member
 
sfx1999's Avatar
 
Status: Offline
Posts: 534
Join Date: Jan 2004
Location: Pittsburgh, PA, USA
Default Re: Looking to trace out at 45 degrees off the players center... - 20-06-2004

Hey look Quake I's mathlib.h is extremely similar to Half-life's mathlib.h.
  
Reply With Quote
Re: Looking to trace out at 45 degrees off the players center...
Old
  (#16)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Looking to trace out at 45 degrees off the players center... - 20-06-2004

@Whistler: somehow these comments remind me of something, but I cant remember what ? I can swear I've seen them earlier......
the style looks like the comments I was making in the first RACC preview.....



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: Looking to trace out at 45 degrees off the players center...
Old
  (#17)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: Looking to trace out at 45 degrees off the players center... - 21-06-2004

Yes, that is your comments. Besides, I have changed "-180/+180" to "[-180, 180)".
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com