Explode exploder

This commit is contained in:
Miloslav Číž 2019-12-28 20:16:44 +01:00
parent 6cbe6f27c6
commit d641abe5db
2 changed files with 46 additions and 21 deletions

View File

@ -52,7 +52,7 @@
Says the (Chebyshev) distance in game squares at which level elements Says the (Chebyshev) distance in game squares at which level elements
(items, monsters etc.) become active. (items, monsters etc.) become active.
*/ */
#define SFG_LEVEL_ELEMENT_ACTIVE_DISTANCE 8 #define SFG_LEVEL_ELEMENT_ACTIVE_DISTANCE 10
/** /**
Rate at which AI will be updated, which also affects how fast enemies will Rate at which AI will be updated, which also affects how fast enemies will

25
main.c
View File

@ -1279,6 +1279,16 @@ void SFG_monsterPerformAI(SFG_MonsterRecord *monster)
uint8_t mX = SFG_MONSTER_COORD_TO_SQUARES(monster->coords[0]); uint8_t mX = SFG_MONSTER_COORD_TO_SQUARES(monster->coords[0]);
uint8_t mY = SFG_MONSTER_COORD_TO_SQUARES(monster->coords[1]); uint8_t mY = SFG_MONSTER_COORD_TO_SQUARES(monster->coords[1]);
if (!( // exploder will explode when close
(type == SFG_LEVEL_ELEMENT_MONSTER_EXPLODER) &&
(((mX > SFG_player.squarePosition[0]) ?
(mX - SFG_player.squarePosition[0]) :
(SFG_player.squarePosition[0] - mX)) <= 1) &&
(((mY > SFG_player.squarePosition[1]) ?
(mY - SFG_player.squarePosition[1]) :
(SFG_player.squarePosition[1] - mY)) <= 1)
))
{
if (mX > SFG_player.squarePosition[0]) if (mX > SFG_player.squarePosition[0])
{ {
if (mY > SFG_player.squarePosition[1]) if (mY > SFG_player.squarePosition[1])
@ -1306,6 +1316,19 @@ void SFG_monsterPerformAI(SFG_MonsterRecord *monster)
} }
} }
else else
{
// exploder explodes
uint8_t properties;
SFG_TileDefinition tile =
SFG_getMapTile(SFG_currentLevel.levelPointer,mX,mY,&properties);
SFG_createExplosion(mX * RCL_UNITS_PER_SQUARE ,mY * RCL_UNITS_PER_SQUARE,
SFG_TILE_FLOOR_HEIGHT(tile) * SFG_WALL_HEIGHT_STEP + SFG_WALL_HEIGHT_STEP);
}
}
else
{ {
// ranged monsters choose direction randomly // ranged monsters choose direction randomly
@ -1510,6 +1533,8 @@ void SFG_playerChangeHealth(int8_t healthAdd)
void SFG_createExplosion(RCL_Unit x, RCL_Unit y, RCL_Unit z) void SFG_createExplosion(RCL_Unit x, RCL_Unit y, RCL_Unit z)
{ {
printf("%d %d %d\n",x,y,z);
SFG_ProjectileRecord explostion; SFG_ProjectileRecord explostion;
explostion.type = SFG_PROJECTILE_EXPLOSION; explostion.type = SFG_PROJECTILE_EXPLOSION;