00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00014
00015 #pragma warning (disable:4996)
00016 #pragma warning (disable:4005)
00017 #pragma warning(disable:4275)
00018
00019 #ifndef _AIBEHAVIORS_H
00020 #define _AIBEHAVIORS_H
00021
00022 #include "globals.h"
00023 #include "aiCharacter.h"
00024
00025 #include "seek.h"
00026 #include "flee.h"
00027 #include "pursue.h"
00028 #include "evade.h"
00029 #include "arrival.h"
00030 #include "flock.h"
00031 #include "wander.h"
00032 #include "pathFollow.h"
00033 #include "pathfind.h"
00034 #include "obstacleAvoidance.h"
00035
00036
00046
00048
00049 class AICharacter;
00050 class Seek;
00051 class Flee;
00052 class Pursue;
00053 class Evade;
00054 class Arrival;
00055 class Flock;
00056 class Wander;
00057 class PathFollow;
00058 class PathFind;
00059 class ObstacleAvoidance;
00060
00061 typedef list<Flee, allocator<Flee> > ListFlee;
00062 typedef list<Evade, allocator<Evade> > ListEvade;
00063
00064 class AIBehaviors {
00065
00066 public:
00067 enum _behavior_type {
00068 _none = 0x00000,
00069 _seek = 0x00002,
00070 _flee = 0x00004,
00071 _flee_activate = 0x00100,
00072 _arrival = 0x00008,
00073 _arrival_activate = 0x01000,
00074 _wander = 0x00010,
00075 _pursue = 0x00040,
00076 _evade = 0x00080,
00077 _evade_activate = 0x00800,
00078 _flock = 0x00200,
00079 _flock_activate = 0x00400,
00080 _obstacle_avoidance = 0x02000,
00081 _obstacle_avoidance_activate = 0x04000
00082 };
00083
00084 AICharacter *_ai_char;
00085 Flock *_flock_group;
00086
00087 int _behaviors_flags;
00088 LVecBase3f _steering_force;
00089
00090 Seek *_seek_obj;
00091 LVecBase3f _seek_force;
00092
00093 Flee *_flee_obj;
00094 LVecBase3f _flee_force;
00095
00097 ListFlee _flee_list;
00098 ListFlee::iterator _flee_itr;
00099
00100 Pursue *_pursue_obj;
00101 LVecBase3f _pursue_force;
00102
00103 Evade *_evade_obj;
00104 LVecBase3f _evade_force;
00105
00107 ListEvade _evade_list;
00108 ListEvade::iterator _evade_itr;
00109
00110 Arrival *_arrival_obj;
00111 LVecBase3f _arrival_force;
00112
00114 float _flock_weight;
00115 LVecBase3f _flock_force;
00116 bool _flock_done;
00117
00118 Wander * _wander_obj;
00119 LVecBase3f _wander_force;
00120
00121 ObstacleAvoidance *_obstacle_avoidance_obj;
00122 LVecBase3f _obstacle_avoidance_force;
00123
00124 PathFollow *_path_follow_obj;
00125
00126 PathFind *_path_find_obj;
00127
00128 bool _conflict, _previous_conflict;
00129
00130 AIBehaviors();
00131 ~AIBehaviors();
00132
00133 bool is_on(_behavior_type bt);
00134 bool is_on(string ai_type);
00135 bool is_off(_behavior_type bt);
00136 bool is_off(string ai_type);
00137 void turn_on(string ai_type);
00138 void turn_off(string ai_type);
00139
00140 bool is_conflict();
00141
00142 void accumulate_force(string force_type, LVecBase3f force);
00143 LVecBase3f calculate_prioritized();
00144
00145 void flock_activate();
00146 LVecBase3f do_flock();
00147
00148 int char_to_int(string ai_type);
00149
00150 PUBLISHED:
00151 void seek(NodePath target_object, float seek_wt = 1.0);
00152 void seek(LVecBase3f pos, float seek_wt = 1.0);
00153
00154 void flee(NodePath target_object, double panic_distance = 10.0, double relax_distance = 10.0, float flee_wt = 1.0);
00155 void flee(LVecBase3f pos, double panic_distance = 10.0, double relax_distance = 10.0, float flee_wt = 1.0);
00156
00157 void pursue(NodePath target_object, float pursue_wt = 1.0);
00158
00159 void evade(NodePath target_object, double panic_distance = 10.0, double relax_distance = 10.0, float evade_wt = 1.0);
00160
00161 void arrival(double distance = 10.0);
00162
00163 void flock(float flock_wt);
00164
00165 void wander(double wander_radius = 5.0, int flag =0, double aoe = 0.0, float wander_weight = 1.0);
00166
00167 void obstacle_avoidance(float feeler_length = 1.0);
00168
00169 void path_follow(float follow_wt);
00170 void add_to_path(LVecBase3f pos);
00171 void start_follow(string type = "normal");
00172
00173
00174 void init_path_find(const char* navmesh_filename);
00175 void path_find_to(LVecBase3f pos, string type = "normal");
00176 void path_find_to(NodePath target, string type = "normal");
00177 void add_static_obstacle(NodePath obstacle);
00178 void add_dynamic_obstacle(NodePath obstacle);
00179
00180
00181 void remove_ai(string ai_type);
00182 void pause_ai(string ai_type);
00183 void resume_ai(string ai_type);
00184
00185 string behavior_status(string ai_type);
00186 };
00187
00188 #endif
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199