Continue AI

This commit is contained in:
Miloslav Číž 2019-10-18 17:26:13 +02:00
parent 3072597787
commit 53d4b86b0a
2 changed files with 12 additions and 1 deletions

View File

@ -58,6 +58,12 @@
Rate at which AI will be updated, which also affects how fast enemies will
appear.
*/
#define SFG_AI_FPS 5
#define SFG_AI_FPS 2
/**
Says a probability (0 - 255) of the AI changing its state during one update
step.
*/
#define SFG_AI_RANDOM_CHANGE_PROBABILITY 20
#endif // guard

5
main.c
View File

@ -1015,6 +1015,11 @@ void SFG_monsterPerformAI(SFG_MonsterRecord *monster)
coordAdd[0] = 0;
coordAdd[1] = 0;
if (SFG_random() < SFG_AI_RANDOM_CHANGE_PROBABILITY)
{
// sometimes randomly change state
state = SFG_MONSTER_STATE_IDLE;
}
if (state == SFG_MONSTER_STATE_IDLE)
{
switch (SFG_random() % 8)