1 /*
2  * See Licensing and Copyright notice in naev.h
3  */
4 
5 
6 
7 #ifndef AI_H
8 #  define AI_H
9 
10 
11 /* yay Lua */
12 #include <lua.h>
13 
14 #include "physics.h"
15 #include "nlua.h"
16 
17 /* Forward declaration to avoid cyclical import. */
18 struct Pilot_;
19 typedef struct Pilot_ Pilot;
20 
21 
22 #define AI_MEM          "__mem" /**< Internal pilot memory. */
23 
24 
25 #define MIN_DIR_ERR     5.0*M_PI/180. /**< Minimum direction error. */
26 #define MAX_DIR_ERR     0.5*M_PI/180. /**< Maximum direction error. */
27 #define MIN_VEL_ERR     5.0 /**< Minimum velocity error. */
28 
29 
30 /* maximum number of AI timers */
31 #define MAX_AI_TIMERS   2 /**< Max amount of AI timers. */
32 
33 
34 /**
35  * @struct Task
36  *
37  * @brief Basic AI task.
38  */
39 typedef struct Task_ {
40    struct Task_* next; /**< Next task */
41    char *name; /**< Task name. */
42    int done; /**< Task is done and ready for deletion. */
43 
44    struct Task_* subtask; /**< Subtasks of the current task. */
45 
46    int dat; /**< Lua reference to the data (index in registry). */
47 } Task;
48 
49 
50 /**
51  * @struct AI_Profile
52  *
53  * @brief Basic AI profile.
54  */
55 typedef struct AI_Profile_ {
56    char* name; /**< Name of the profile. */
57    nlua_env env; /**< Assosciated Lua Environment. */
58 } AI_Profile;
59 
60 
61 /*
62  * misc
63  */
64 AI_Profile* ai_getProfile( char* name );
65 
66 
67 /*
68  * init/exit
69  */
70 int ai_load (void);
71 void ai_exit (void);
72 
73 
74 /*
75  * Init, destruction.
76  */
77 int ai_pinit( Pilot *p, const char *ai );
78 void ai_destroy( Pilot* p );
79 
80 /*
81  * Task related.
82  */
83 Task *ai_newtask( Pilot *p, const char *func, int subtask, int pos );
84 void ai_freetask( Task* t );
85 void ai_cleartasks( Pilot* p );
86 
87 /*
88  * Misc functions.
89  */
90 void ai_attacked( Pilot* attacked, const unsigned int attacker, double dmg );
91 void ai_refuel( Pilot* refueler, unsigned int target );
92 void ai_getDistress( Pilot *p, const Pilot *distressed, const Pilot *attacker );
93 void ai_think( Pilot* pilot, const double dt );
94 void ai_setPilot( Pilot *p );
95 
96 
97 #endif /* AI_H */
98