Skip to content

Commit

Permalink
added placeholder enemy ai file
Browse files Browse the repository at this point in the history
  • Loading branch information
timleader committed May 2, 2024
1 parent ba01aaf commit a8ad87f
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ dkms.conf
/tests/configuration.yml
/tests/bin/Debug/netcoreapp3.1
/gba-demo.sav
/.vs
5 changes: 3 additions & 2 deletions project/gba-demo.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@
<ClInclude Include="..\source\common\video\smk_hufftree_v5.h" />
<ClInclude Include="..\source\common\video\video.h" />
<ClInclude Include="..\source\games\7days\dialogue.h" />
<ClInclude Include="..\source\games\7days\enemy_ai.h" />
<ClInclude Include="..\source\games\7days\entities\entity.h" />
<ClInclude Include="..\source\games\7days\inventory.h" />
<ClInclude Include="..\source\games\7days\itemstore.h" />
Expand All @@ -277,13 +278,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down
3 changes: 3 additions & 0 deletions project/gba-demo.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,9 @@
<ClInclude Include="..\source\common\video\smk_hufftree.h">
<Filter>source\common\video</Filter>
</ClInclude>
<ClInclude Include="..\source\games\7days\enemy_ai.h">
<Filter>source\games\7days</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CopyFileToFolders Include="..\deps\SDL2-2.0.1\lib\x86\SDL2.dll">
Expand Down
8 changes: 4 additions & 4 deletions project/resources-extract.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down
8 changes: 4 additions & 4 deletions project/smk-patch.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down
3 changes: 3 additions & 0 deletions source/games/7days/dialogue.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ typedef struct dialogue_entry_s

struct
{
// mask to check if this option is available, checks against persistent data

uint16_t text;
int16_t next; // int16_t so we can support -1 for termination
// next can be next diag id or next sequence id, how do/
// value or bit to set in persistent data
}
options[1]; // can we support 6 options ??

Expand Down
62 changes: 62 additions & 0 deletions source/games/7days/enemy_ai.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

#ifndef ENEMY_AI_H
#define ENEMY_AI_H

#include "level.h"

// perhaps have this fit some kind of entity_ai interface
// throw all of this in an `ai` folder

typedef struct entity_ai_s // enemy, player, follow, dummy, etc...
{
// entity_id

// ai_state
// 40 byte limit

// ai_type => function pointer to update function // needs to be persistent

} entity_ai_t;


//-----------------------------------------------------------------------------
typedef struct enemy_ai_state_s
{
// state

// last known player position
// time since last seen player

// patrol waypoints ?

} enemy_ai_state_t;

typedef enemy_ai_state_t* enemy_ai_state_ptr;


//-----------------------------------------------------------------------------
void enemy_ai_update(entity_ptr entity);

/*
hidden ...
not yet in the level
patrol ...
follow predefined waypoints
check for line of sight to player - perhaps use navigation data to determine this.
pursue the player ... (hunting)
check for losing sight of player
if in range attack player
if out of sight for a certain amount of time, return to patrol
flee ...
should all reset between levels
generate sounds ...
*/

#endif
2 changes: 2 additions & 0 deletions source/games/7days/entities/player_entity.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "common/input/input.h"


// refactor to player_ai.h

/*
idle
Expand Down
6 changes: 4 additions & 2 deletions source/games/7days/world.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

//-----------------------------------------------------------------------------
#define WORLD_MODEL_ENTITY_COUNT 4
#define WORLD_IMAGE_ENTITY_COUNT 8
#define WORLD_IMAGE_ENTITY_COUNT 8 // ???
#define WORLD_NAVIGATION_AGENT_COUNT 4

#define WORLD_LEVEL_COUNT 8
Expand All @@ -36,6 +36,8 @@ typedef struct level_persistent_s

entity_t entities[WORLD_MODEL_ENTITY_COUNT]; // these are just render entities // maybe have a pointer to the active levels's entity

// ai state for entities ...

uint8_t view_state[WORLD_MAX_VIEWS_PER_LEVEL]; // door open / door closed
// bit mask to indicate the state of the view and what subview things should be active ...
// playing progress of subviews will be in the ephermal struct
Expand Down Expand Up @@ -70,7 +72,7 @@ typedef level_persistent_t* level_persistent_ptr;
//-----------------------------------------------------------------------------
typedef struct world_persistent_s
{
// dialogue persistence
// dialogue persistence -- just x bits, then the dialogue system can bitwise check against this


int16_t ambient_resource_id;
Expand Down
2 changes: 2 additions & 0 deletions source/games/7days/world_sequence.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ sequence_completion_mode_t sequence_event_handler_model_entity_spawn(sequence_pl

// how do we determine the idx ???

// ASSIGN AI BEHAVIOUR -- should this be it's own Event

entity_ptr entities = world_current_level(g_main_world)->entities;

entities[entity_id].id = entity_id;
Expand Down

0 comments on commit a8ad87f

Please sign in to comment.