00001 /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 00002 || NoX-Wizard UO Server Emulator (NXW) [http://noxwizard.sourceforge.net] || 00003 || || 00004 || This software is free software released under GPL2 license. || 00005 || You can find detailed license information in nox-wizard.cpp file. || 00006 || || 00007 || For any question post to NoX-Wizard forums. || 00008 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ 00009 00010 #ifndef __AI_H__ 00011 #define __AI_H__ 00012 00029 /*class cAction { 00030 private: 00031 cAI *m_ai; 00032 public: 00033 cAction( cAI* ai ); 00034 virtual void run(); 00035 };*/ 00036 00040 /*class cAttackAction : public cAction { 00041 private: 00042 SERIAL m_target; 00043 public: 00044 void run(); 00045 inline P_CHAR getTarget() { return pointers::findCharBySerial( m_target ); } 00046 };*/ 00047 00051 /*class cDefendAction : public cAction { 00052 private: 00053 SERIAL m_attacker; 00054 public: 00055 void run(); 00056 inline P_CHAR getAttacker() { return pointers::findCharBySerial( m_attacker ); } 00057 };*/ 00058 00063 /*class cAI { 00064 private: 00065 SERIAL m_pc; 00066 cAction *currAction; 00067 public: 00068 cAI( cChar &pc, SI32 type ); 00069 virtual void run(); 00070 cAction* getAction() 00071 void setAction(); 00072 inline LOGICAL hasAction() { return ( currAction != NULL ); } 00073 inline P_CHAR getChar() { return pointers::findCharBySerial( m_pc ); } 00074 };*/ 00075 00076 00078 00079 00081 00085 #include "nxwcommn.h" 00086 00087 #define MAX_PATH_INTERNAL_LOOPS 200 00088 #define MAX_PATH_TOTAL_LOOPS 10000 00089 #define Z_COST 1 00090 #define STRAIGHT_COST 10 00091 #define OBLIQUE_COST 14 00092 00093 00097 struct path_node { 00098 UI32 cost; 00099 Location pos; 00100 path_node *parentNode; 00101 }; 00102 00103 typedef slist<path_node*> NODE_LIST; 00104 typedef slist<Location> LOCATION_LIST; 00105 00110 class cPath { 00111 public: 00112 cPath( Location startPos, Location finalPos, P_CHAR pc = NULL ); 00113 void exec(); 00114 Location getNextPos(); 00115 inline Location getFinalPos() { return m_finalPos; } 00116 LOGICAL targetReached(); 00117 inline LOGICAL pathFound() { return m_pathFound; } 00118 private: 00119 LOGICAL m_pathFound; 00120 UI32 m_loops; 00121 SERIAL pc_serial; 00122 path_node* currNode; 00123 path_node* nextNode; 00124 path_node* create_node( Location pos, path_node* parentNode, UI32 cost ); 00125 queue<path_node> nodes_vector; 00126 UI08 addReachableNodes( path_node* node ); 00127 void dropToClosedList( path_node* node ); 00128 void addToOpenList( Location pos, path_node* parentNode, UI32 cost = STRAIGHT_COST ); 00129 void addToOpenList( path_node* node ); 00130 void addToClosedList( path_node* node ); 00131 Location m_startPos; 00132 Location m_finalPos; 00133 NODE_LIST open_list; 00134 NODE_LIST closed_list; 00135 LOCATION_LIST path_list; 00136 }; 00137 00139 00140 00141 #endif //__AI_H__