Add randomness to AI aim

This commit is contained in:
Miloslav Číž 2020-08-04 21:49:53 +02:00
parent 7450436bf4
commit 5ecdd195cd
3 changed files with 21 additions and 5 deletions

View File

@ -138,6 +138,11 @@
*/
#define SFG_DAMAGE_RANDOMNESS 64
/**
Height of monster collision BBox in RCL_Units.
*/
#define SFG_MONSTER_COLLISION_HEIGHT 1024
/**
Specifies key repeat delay, in ms.
*/
@ -518,7 +523,7 @@ SFG_PROGRAM_MEMORY uint8_t SFG_attackDamageTable[SFG_WEAPON_FIRE_TYPES_TOTAL] =
SFG_PROGRAM_MEMORY uint8_t SFG_projectileAttributeTable[SFG_PROJECTILES_TOTAL] =
{
/* explosion */ SFG_PROJECTILE_ATTRIBUTE(0,400),
/* fireball */ SFG_PROJECTILE_ATTRIBUTE(18,1000),
/* fireball */ SFG_PROJECTILE_ATTRIBUTE(11,1000),
/* plasma */ SFG_PROJECTILE_ATTRIBUTE(20,500),
/* dust */ SFG_PROJECTILE_ATTRIBUTE(0,450),
/* bullet */ SFG_PROJECTILE_ATTRIBUTE(28,1000)

9
main.c
View File

@ -1921,8 +1921,13 @@ void SFG_monsterPerformAI(SFG_MonsterRecord *monster)
pos.x = SFG_MONSTER_COORD_TO_RCL_UNITS(monster->coords[0]);
pos.y = SFG_MONSTER_COORD_TO_RCL_UNITS(monster->coords[1]);
dir.x = SFG_player.camera.position.x - pos.x;
dir.y = SFG_player.camera.position.y - pos.y;
dir.x = SFG_player.camera.position.x - pos.x
- 128 * SFG_MONSTER_AIM_RANDOMNESS +
SFG_random() * SFG_MONSTER_AIM_RANDOMNESS;
dir.y = SFG_player.camera.position.y - pos.y
- 128 * SFG_MONSTER_AIM_RANDOMNESS +
SFG_random() * SFG_MONSTER_AIM_RANDOMNESS;
dir = RCL_normalize(dir);

View File

@ -199,17 +199,23 @@
*/
#define SFG_MONSTER_SOUND_PROBABILITY 64
/**
Affects how precise monsters are in aiming, specify random range in
fourths of a game square. Should be power of 2 for performance.
*/
#define SFG_MONSTER_AIM_RANDOMNESS 4
//------ developer/debug settings ------
/**
Developer cheat for having infinite ammo in all weapons.
*/
#define SFG_INFINITE_AMMO 0
#define SFG_INFINITE_AMMO 1
/**
Developer cheat for immortality.
*/
#define SFG_IMMORTAL 0
#define SFG_IMMORTAL 1
/**
Turn on for previes mode for map editing (flying, noclip, fast movement etc.).