Dumb-ways-to-memorize
2D game
|
#include "ai_interpret.h"
#include "entity.h"
#include "parseentity.h"
#include "parsepowerup.h"
#include "mystrings.h"
#include <stdio.h>
#include <stdlib.h>
Go to the source code of this file.
Functions | |
void | NothingAI (entity_t *ent) |
void | MoveAI (entity_t *ent) |
void | WalkAI (entity_t *ent) |
void | JumpAI (entity_t *ent) |
void | AttackAI (entity_t *ent) |
ai_function_t * | ParseAI (object_t *obj, char *g_str, char **variables) |
ai_function_t * | ParsePresetAI (object_t *obj, char *g_str) |
void | SetAI_Var (ai_function_t *function, char *data_str, ai_variables_t var_type) |
void | SetAI_Action (ai_function_t *function, object_t *obj, jsmntok_t *tok, char *g_str, ai_actions_t action_type) |
void | SetAI_Check (ai_function_t *function, char **variables_str, char *data_str, ai_conditions_t condition) |
int | InitAISystem () |
void | ShutdownAISystem () |
ai_type_t | StrToAI_Type (const char *str) |
ai_actions_t | StrToAI_Action (const char *str) |
ai_conditions_t | StrToAI_Condition (const char *str) |
ai_variables_t | StrToVariableType (const char *str) |
Variables | |
ai_function_t * | gVariableAIs = NULL |
ai_function_t * | gPresetAIs = NULL |
char * | gAI_Variables [] = {"speed", "frames", "time", "damage", 0} |
char * | gAI_Actions [] = {"nothing", "move", "walk", "jump", "attack", 0} |
char * | gAI_Conditions [] = {"distance_player", "distance_object", "object_check", "link_ai", "link_action", 0} |
void(*)(entity_t *) | GetFunctionAI (ai_function_t *data) |
void AttackAI | ( | entity_t * | ent | ) |
AI for entity attacks, "spawns" a hit box / entity in front of Entity
[in,out] | ent | If non-null, the ent. |
Definition at line 200 of file ai_interpret.c.
References AI_FLAG_GRAVITY, AI_VAR_DAMAGE, AI_VAR_DIR_X, AI_VAR_DIR_Y, AI_VAR_FRAMES, AI_VAR_TIME, COLLISION_TYPE_RAGDOLL, FindCachedEntity(), FRAME_DELAY, and Spawn().
int InitAISystem | ( | ) |
Init AI system, similar to Entity init, for now....
Definition at line 646 of file ai_interpret.c.
References gPresetAIs, gVariableAIs, MAX_AI, and ShutdownAISystem().
Referenced by Setup().
void JumpAI | ( | entity_t * | ent | ) |
AI to change velocity of the entity, defaults to a jumping movement.
[in,out] | ent | If non-null, the ent. |
Definition at line 147 of file ai_interpret.c.
References AI_FLAG_GRAVITY, AI_VAR_DAMAGE, AI_VAR_DIR_X, AI_VAR_DIR_Y, AI_VAR_FRAMES, AI_VAR_SPEED, AI_VAR_TIME, COLLISION_TYPE_RAGDOLL, FindCachedEntity(), FRAME_DELAY, gCurrentTime, Vec2Add(), Vec2MultiplyScalar(), vec2_t::x, and vec2_t::y.
void MoveAI | ( | entity_t * | ent | ) |
AI to Move ent from point A to B w/o collisions.
[in,out] | ent | If non-null, the ent. |
Learn how to lerp.
Definition at line 61 of file ai_interpret.c.
References AI_FLAG_GRAVITY, AI_VAR_DAMAGE, AI_VAR_DIR_X, AI_VAR_DIR_Y, AI_VAR_FRAMES, AI_VAR_SPEED, AI_VAR_TIME, COLLISION_TYPE_CLIP, FindCachedEntity(), FRAME_DELAY, gCurrentTime, Vec2Add(), Vec2MultiplyScalar(), vec2_t::x, and vec2_t::y.
void NothingAI | ( | entity_t * | ent | ) |
AI that does nothing for its think, except make sure values are set.
[in,out] | ent | If non-null, the ent. |
Definition at line 25 of file ai_interpret.c.
References AI_FLAG_GRAVITY, AI_VAR_DAMAGE, AI_VAR_FRAMES, AI_VAR_TIME, COLLISION_TYPE_RAGDOLL, FindCachedEntity(), FRAME_DELAY, and gCurrentTime.
ai_function_t* ParseAI | ( | object_t * | obj, |
char * | g_str, | ||
char ** | variables | ||
) |
Parses AI behavior using the variables given and the AI obj/file specified.
[in,out] | obj | If non-null, the object. |
[in,out] | g_str | If non-null, the string. |
[in,out] | variables | If non-null, the variables. |
Definition at line 261 of file ai_interpret.c.
References AI_CONDITION_OBJECT_NAME, AI_FLAG_CHECK_OBJECT, AI_FLAG_GRAVITY, AI_FUNCTION_OBJECT, AI_TYPE_STR, AI_VAR_STR, CountMem(), CountObjectMembers(), FindKey(), FindObject(), FindValue(), gAI_Actions, gAI_Conditions, gAI_Variables, JsmnToString(), SetAI_Action(), SetAI_Check(), SetAI_Var(), StrToAI_Type(), and StrToInt().
Referenced by LoadLevel(), and SetAI_Check().
ai_function_t* ParsePresetAI | ( | object_t * | obj, |
char * | g_str | ||
) |
Parse a preset AI, with values determined by whats in the file.
[in,out] | obj | If non-null, the object. |
[in,out] | g_str | If non-null, the string. |
Definition at line 374 of file ai_interpret.c.
References AI_CONDITION_OBJECT_NAME, AI_FLAG_CHECK_OBJECT, AI_FLAG_GRAVITY, AI_FUNCTION_OBJECT, AI_TYPE_STR, AI_VAR_STR, CountMem(), CountObjectMembers(), FindKey(), FindObject(), FindValue(), gAI_Actions, gAI_Conditions, gAI_Variables, JsmnToString(), SetAI_Action(), SetAI_Check(), SetAI_Var(), and StrToAI_Type().
Referenced by LoadLevel().
void SetAI_Action | ( | ai_function_t * | function, |
object_t * | obj, | ||
jsmntok_t * | tok, | ||
char * | g_str, | ||
ai_actions_t | action_type | ||
) |
Sets AI action defined in ai_actions to the ai_function
[in,out] | function | If non-null, the function. |
[in,out] | obj | If non-null, the object. |
[in,out] | tok | If non-null, the tok. |
[in,out] | g_str | If non-null, the string. |
[in,out] | action_type | If non-null, the action type. |
Definition at line 516 of file ai_interpret.c.
References AI_ACTION_ATTACK, AI_ACTION_JUMP, AI_ACTION_MOVE, AI_ACTION_NOTHING, AI_ACTION_WALK, AI_BASE_JUMP, AI_VAR_DIR_X, AI_VAR_DIR_Y, JsmnToString(), ParseToVec2(), vec2_t::x, and vec2_t::y.
Referenced by ParseAI(), and ParsePresetAI().
void SetAI_Check | ( | ai_function_t * | function, |
char ** | variables_str, | ||
char * | data_str, | ||
ai_conditions_t | condition | ||
) |
Sets checks that need to occur for the ai_function to be called.
[in,out] | function | If non-null, the function. |
[in,out] | variables_str | If non-null, the variables string. |
[in,out] | data_str | If non-null, the data string. |
[in,out] | check_str | If non-null, the condition type. |
Definition at line 601 of file ai_interpret.c.
References AI_CONDITION_LINK_ACTION, AI_CONDITION_LINK_AI, AI_CONDITION_OBJECT_DISTANCE, AI_CONDITION_PLAYER_DISTANCE, AI_FLAG_CHECK_OBJECT, AI_FLAG_CHECK_PLAYER, AI_VAR_CHECK, ConvertFileToUseable(), ParseAI(), ParseToObject(), and StrToInt().
Referenced by ParseAI(), and ParsePresetAI().
void SetAI_Var | ( | ai_function_t * | function, |
char * | data_str, | ||
ai_variables_t | var_type | ||
) |
Sets AI variables in ai_function->mVariables.
[in,out] | function | If non-null, the function. |
[in,out] | data_str | If non-null, the data string. |
[in,out] | var_type | If non-null, the variable type. |
Definition at line 481 of file ai_interpret.c.
References AI_BASE_DAMAGE, AI_BASE_SPEED, AI_BASE_THINK_FRAMES, AI_VAR_DAMAGE, AI_VAR_FRAMES, AI_VAR_SPEED, AI_VAR_TIME, and StrToInt().
Referenced by ParseAI(), and ParsePresetAI().
void ShutdownAISystem | ( | ) |
Shutdown AI system, just frees the global variables simple.
Definition at line 668 of file ai_interpret.c.
References gPresetAIs, and gVariableAIs.
Referenced by InitAISystem().
ai_actions_t StrToAI_Action | ( | const char * | str | ) |
Definition at line 691 of file ai_interpret.c.
References AI_ACTION_MAX, and gAI_Actions.
ai_conditions_t StrToAI_Condition | ( | const char * | str | ) |
Definition at line 704 of file ai_interpret.c.
References AI_CONDITION_MAX, and gAI_Conditions.
ai_type_t StrToAI_Type | ( | const char * | str | ) |
Converts a str to an AI type.
str | The string. |
Definition at line 679 of file ai_interpret.c.
References AI_TYPE_NULL, AI_TYPE_PRESET, AI_TYPE_PRESET_STR, AI_TYPE_VARIABLE, and AI_TYPE_VARIABLE_STR.
Referenced by ParseAI(), and ParsePresetAI().
ai_variables_t StrToVariableType | ( | const char * | str | ) |
Definition at line 717 of file ai_interpret.c.
References AI_VAR_MAX, and gAI_Variables.
void WalkAI | ( | entity_t * | ent | ) |
AI to "walk" entity from point A to B w/ collisions.
[in,out] | ent | If non-null, the ent. |
Definition at line 106 of file ai_interpret.c.
References AI_FLAG_GRAVITY, AI_VAR_DAMAGE, AI_VAR_DIR_X, AI_VAR_DIR_Y, AI_VAR_FRAMES, AI_VAR_SPEED, AI_VAR_TIME, COLLISION_TYPE_RAGDOLL, FindCachedEntity(), FRAME_DELAY, gCurrentTime, Vec2Add(), Vec2MultiplyScalar(), vec2_t::x, and vec2_t::y.
char* gAI_Actions[] = {"nothing", "move", "walk", "jump", "attack", 0} |
The actions that are related to ai functions
Definition at line 13 of file ai_interpret.c.
Referenced by ParseAI(), ParsePresetAI(), and StrToAI_Action().
char* gAI_Conditions[] = {"distance_player", "distance_object", "object_check", "link_ai", "link_action", 0} |
The conditions for the ai function to be executed
Definition at line 14 of file ai_interpret.c.
Referenced by ParseAI(), ParsePresetAI(), and StrToAI_Condition().
char* gAI_Variables[] = {"speed", "frames", "time", "damage", 0} |
The variables to be parsed for ai data
Definition at line 12 of file ai_interpret.c.
Referenced by ParseAI(), ParsePresetAI(), and StrToVariableType().
void(*)(entity_t *) GetFunctionAI(ai_function_t *data) |
Returns a function pointer to the think function, given ai_function data.
[in,out] | parameter1 | If non-null, the first parameter. |
Definition at line 238 of file ai_interpret.c.
Referenced by ThinkEnemy().
ai_function_t* gPresetAIs = NULL |
The AI's of type preset
Definition at line 10 of file ai_interpret.c.
Referenced by InitAISystem(), and ShutdownAISystem().
ai_function_t* gVariableAIs = NULL |
The AI's of type variable
Definition at line 9 of file ai_interpret.c.
Referenced by InitAISystem(), and ShutdownAISystem().