Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

_bot.c File Reference

#include <Windows.h>
#include <Assert.h>
#include <Math.h>
#include <Time.h>
#include "Genesis.h"
#include "Ram.h"
#include "GMain.h"
#include "_Bot.h"
#include "Track.h"

Go to the source code of this file.

Functions

void StackInit (Stack *s)
void StackReset (Stack *s)
void StackPush (Stack *s, int32 data)
int32 StackPop (Stack *s)
int32 StackTop (Stack *s)
geBoolean StackIsEmpty (Stack *s)
int32 krand ()
void ksrand (int32 seed)
int32 RandomRange (int32 range)
float DistWeightedY (const geVec3d *Pos1, const geVec3d *Pos2, const float Scale)
void Ang2Vec (float ang, geVec3d *vec)
void VectorRotateY (geVec3d *vec, float delta_ang, geVec3d *result)

Variables

int32 randomseed = 17


Function Documentation

void Ang2Vec float  ang,
geVec3d vec
 

Definition at line 112 of file _bot.c.

References geVec3d_Normalize(), SqueezeVector(), geVec3d::X, geVec3d::Y, and geVec3d::Z.

00113 {
00114 vec->X = (float)cos(ang);
00115 vec->Z = (float)sin(ang);
00116 vec->Y = 0.0f;
00117 SqueezeVector(vec, 0.0001f);
00118 
00119 geVec3d_Normalize(vec);
00120 }

float DistWeightedY const geVec3d Pos1,
const geVec3d Pos2,
const float  Scale
 

Definition at line 99 of file _bot.c.

References geVec3d_DistanceBetween(), Pos2, and geVec3d::Y.

Referenced by Track_FindTrack(), and Track_LinkTrack().

00100 {
00101         geVec3d LPos1, LPos2;
00102 
00103         LPos1 = *Pos1;
00104         LPos2 = *Pos2;
00105 
00106         LPos1.Y *= Scale;
00107         LPos2.Y *= Scale;
00108 
00109         return(geVec3d_DistanceBetween(&LPos1, &LPos2));
00110 }

int32 krand void   ) 
 

Definition at line 65 of file _bot.c.

References int32, and randomseed.

Referenced by RandomRange().

00066     {
00067     randomseed = ((randomseed * 21 + 1) & 65535);
00068     return (randomseed);
00069     }

void ksrand int32  seed  ) 
 

Definition at line 71 of file _bot.c.

References NULL, and randomseed.

00072     {
00073         
00074     randomseed = (unsigned)time( NULL );
00075     }

int32 RandomRange int32  range  ) 
 

Definition at line 77 of file _bot.c.

References int32, krand(), and U.

Referenced by Bot_FindNewMoveVec(), Bot_FindRandomItem(), Bot_FindRandomTrack(), Bot_ModeChange(), Bot_ModeThinkAttack(), Bot_ModeThinkLedge(), Bot_ModeThinkUnstick(), Bot_Shoot(), and ChooseAction().

00078     {
00079     int32 rand_num;
00080     int32 value;
00081     
00082     if (range <= 0)
00083         return(0);
00084     
00085     rand_num = krand();
00086     
00087     if (rand_num == 65535U)
00088         rand_num--;
00089     
00090     // shift values to give more precision
00091     value = (rand_num << 14) / ((65535UL << 14) / range);
00092     
00093     if (value >= range)
00094         value = range - 1;
00095         
00096     return(value);
00097     }

void StackInit Stack s  ) 
 

Definition at line 19 of file _bot.c.

References GE_RAM_ALLOCATE_ARRAY, int32, MAX_TRACKS, and s.

Referenced by Bot_Create().

00020         {
00021         s->TOS = -1;
00022         s->Data = GE_RAM_ALLOCATE_ARRAY(int32, MAX_TRACKS);
00023     assert(s->Data);
00024     s->Size = MAX_TRACKS;
00025         }

geBoolean StackIsEmpty Stack s  ) 
 

Definition at line 60 of file _bot.c.

References geBoolean, and s.

Referenced by Bot_FinishTrack(), Bot_InitFindMultiTrack(), Bot_InitFindMultiTrackAway(), and Bot_MoveToPoint().

00061         {
00062         return (s->TOS <= -1);
00063         }

int32 StackPop Stack s  ) 
 

Definition at line 39 of file _bot.c.

References int32, and s.

Referenced by Bot_FinishTrack().

00040         {
00041     int32 value;
00042 
00043         if (s->TOS <= -1)
00044                 return (s->TOS = -1);
00045 
00046         value = s->Data[s->TOS];
00047         s->TOS--;
00048 
00049         return (value);
00050         }

void StackPush Stack s,
int32  data
 

Definition at line 32 of file _bot.c.

References s.

Referenced by Bot_FindTrack(), Bot_FindTrackToGoal(), and Track_FindMultiTrack().

00033         {
00034         s->TOS++;
00035     assert(s->TOS < s->Size);
00036         s->Data[s->TOS] = data;
00037         }

void StackReset Stack s  ) 
 

Definition at line 27 of file _bot.c.

References s.

Referenced by Bot_ActorDying(), Bot_ClearTrack(), Bot_Dying(), and Track_FindMultiTrack().

00028         {
00029         s->TOS = -1;
00030         }

int32 StackTop Stack s  ) 
 

Definition at line 52 of file _bot.c.

References int32, and s.

Referenced by Bot_FindTrack(), Bot_FindTrackToGoal(), Bot_FinishTrack(), Bot_InitFindMultiTrack(), and Bot_InitFindMultiTrackAway().

00053         {
00054         if (s->TOS <= -1)
00055                 return (-1);
00056 
00057         return (s->Data[s->TOS]);
00058         }

void VectorRotateY geVec3d vec,
float  delta_ang,
geVec3d result
 

Definition at line 122 of file _bot.c.

References geXForm3d_Rotate(), geXForm3d_RotateY(), and geXForm3d_SetIdentity().

Referenced by Bot_FindNewMoveVec().

00123     {
00124     geXForm3d XForm;
00125 
00126     geXForm3d_SetIdentity(&XForm);
00127     geXForm3d_RotateY(&XForm, delta_ang);
00128     geXForm3d_Rotate(&XForm, vec, result);
00129     }


Variable Documentation

int32 randomseed = 17
 

Definition at line 17 of file _bot.c.

Referenced by krand(), and ksrand().


Generated on Tue Sep 30 12:36:56 2003 for GTestAndEngine by doxygen 1.3.2