naev 0.10.4
ai.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
6#include "nlua.h"
7#include "physics.h"
8
9/* Forward declaration to avoid cyclical import. */
10struct Pilot_;
11typedef struct Pilot_ Pilot;
12
13#define MIN_DIR_ERR 5.0*M_PI/180.
14#define MAX_DIR_ERR 0.5*M_PI/180.
15#define MIN_VEL_ERR 5.0
17/* maximum number of AI timers */
18#define MAX_AI_TIMERS 2
25typedef struct Task_ {
26 struct Task_* next;
27 char *name;
28 int func;
29 int done;
31 struct Task_* subtask;
33 int dat;
34} Task;
35
41typedef struct AI_Profile_ {
42 char* name;
43 nlua_env env;
44 double control_rate;
45 int lua_mem;
51
52/*
53 * misc
54 */
55AI_Profile* ai_getProfile( const char *name );
56
57/*
58 * init/exit
59 */
60int ai_load (void);
61void ai_exit (void);
62
63/*
64 * Init, destruction.
65 */
66int ai_pinit( Pilot *p, const char *ai );
67void ai_destroy( Pilot* p );
68
69/*
70 * Task related.
71 */
72Task *ai_newtask( lua_State *L, Pilot *p, const char *func, int subtask, int pos );
73Task* ai_curTask( Pilot* pilot );
74void ai_freetask( Task* t );
75void ai_cleartasks( Pilot* p );
76
77/*
78 * Misc functions.
79 */
80void ai_attacked( Pilot* attacked, const unsigned int attacker, double dmg );
81void ai_discovered( Pilot* discovered );
82void ai_hail( Pilot* recipient );
83void ai_refuel( Pilot* refueler, unsigned int target );
84void ai_getDistress( Pilot *p, const Pilot *distressed, const Pilot *attacker );
85void ai_think( Pilot* pilot, const double dt );
86void ai_setPilot( Pilot *p );
87void ai_init( Pilot *p );
Task * ai_newtask(lua_State *L, Pilot *p, const char *func, int subtask, int pos)
Creates a new AI task.
Definition: ai.c:1051
void ai_getDistress(Pilot *p, const Pilot *distressed, const Pilot *attacker)
Sends a distress signal to a pilot.
Definition: ai.c:968
Task * ai_curTask(Pilot *pilot)
Gets the current running task.
Definition: ai.c:381
void ai_refuel(Pilot *refueler, unsigned int target)
Has a pilot attempt to refuel the other.
Definition: ai.c:937
void ai_cleartasks(Pilot *p)
Clears the pilot's tasks.
Definition: ai.c:485
void ai_freetask(Task *t)
Frees an AI task.
Definition: ai.c:1108
void ai_attacked(Pilot *attacked, const unsigned int attacker, double dmg)
Triggers the attacked() function in the pilot's AI.
Definition: ai.c:840
void ai_destroy(Pilot *p)
Destroys the ai part of the pilot.
Definition: ai.c:498
void ai_hail(Pilot *recipient)
Triggers the hail() function in the pilot's AI.
Definition: ai.c:906
void ai_discovered(Pilot *discovered)
Triggers the discovered() function in the pilot's AI.
Definition: ai.c:875
void ai_exit(void)
Cleans up global AI.
Definition: ai.c:695
void ai_setPilot(Pilot *p)
Sets the pilot for further AI calls.
Definition: ai.c:405
void ai_think(Pilot *pilot, const double dt)
Heart of the AI, brains of the pilot.
Definition: ai.c:715
void ai_init(Pilot *p)
Initializes the AI.
Definition: ai.c:823
int ai_pinit(Pilot *p, const char *ai)
Initializes the pilot in the ai.
Definition: ai.c:434
int ai_load(void)
Initializes the AI stuff which is basically Lua.
Definition: ai.c:525
AI_Profile * ai_getProfile(const char *name)
Gets the AI_Profile by name.
Definition: ai.c:683
Basic AI profile.
Definition: ai.h:41
int lua_mem
Definition: ai.h:45
int ref_refuel
Definition: ai.h:48
nlua_env env
Definition: ai.h:43
int ref_control
Definition: ai.h:46
char * name
Definition: ai.h:42
double control_rate
Definition: ai.h:44
int ref_create
Definition: ai.h:49
int ref_control_manual
Definition: ai.h:47
The representation of an in-game pilot.
Definition: pilot.h:210
Basic AI task.
Definition: ai.h:25
int func
Definition: ai.h:28
char * name
Definition: ai.h:27
struct Task_ * subtask
Definition: ai.h:31
struct Task_ * next
Definition: ai.h:26
int done
Definition: ai.h:29
int dat
Definition: ai.h:33