Fix element numbers

This commit is contained in:
Miloslav Číž 2020-03-28 20:48:16 +01:00
parent 26a8f4adab
commit 41f61b049b
4 changed files with 43 additions and 19 deletions

View File

@ -27,7 +27,26 @@ elementTypes = [
"LOCK0",
"LOCK1",
"LOCK2",
"BLOCKER"
"BLOCKER",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"MONSTER_SPIDER",
"MONSTER_DESTROYER",
"MONSTER_WARRIOR",
"MONSTER_PLASMABOT",
"MONSTER_ENDER",
"MONSTER_TURRET",
"MONSTER_EXPLODER"
]
propertyTypes = [

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -86,7 +86,7 @@ typedef struct
unused because that will be used by the game engine, so the values must be
lower than 128.
*/
#define SFG_LEVEL_ELEMENT_NONE 255
#define SFG_LEVEL_ELEMENT_NONE 0
#define SFG_LEVEL_ELEMENT_BARREL 0x01
#define SFG_LEVEL_ELEMENT_HEALTH 0x02
#define SFG_LEVEL_ELEMENT_BULLETS 0x03
@ -110,24 +110,24 @@ typedef struct
#define SFG_LEVEL_ELEMENT_LOCK2 0x12
#define SFG_LEVEL_ELEMENT_BLOCKER 0x13 ///< Invisible wall.
/*
Monsters have lower 4 bits zero and are only distinguished by the 4 upper
bits, as this is convenient for the code.
*/
#define SFG_LEVEL_ELEMENT_MONSTER_SPIDER 0x00
#define SFG_LEVEL_ELEMENT_MONSTER_DESTROYER 0x10
#define SFG_LEVEL_ELEMENT_MONSTER_WARRIOR 0x20
#define SFG_LEVEL_ELEMENT_MONSTER_PLASMABOT 0x30
#define SFG_LEVEL_ELEMENT_MONSTER_ENDER 0x40
#define SFG_LEVEL_ELEMENT_MONSTER_TURRET 0x50
#define SFG_LEVEL_ELEMENT_MONSTER_EXPLODER 0x60
#define SFG_LEVEL_ELEMENT_MONSTER_SPIDER 0x20
#define SFG_LEVEL_ELEMENT_MONSTER_DESTROYER 0x21
#define SFG_LEVEL_ELEMENT_MONSTER_WARRIOR 0x22
#define SFG_LEVEL_ELEMENT_MONSTER_PLASMABOT 0x23
#define SFG_LEVEL_ELEMENT_MONSTER_ENDER 0x24
#define SFG_LEVEL_ELEMENT_MONSTER_TURRET 0x25
#define SFG_LEVEL_ELEMENT_MONSTER_EXPLODER 0x26
#define SFG_MONSTERS_TOTAL 7
#define SFG_MONSTER_TYPE_TO_INDEX(monsterType) \
((monsterType) >> 4)
((monsterType) - SFG_LEVEL_ELEMENT_MONSTER_SPIDER)
#define SFG_LEVEL_ELEMENT_TYPE_IS_MOSTER(t) (((t) & 0x0f) == 0)
#define SFG_MONSTER_INDEX_TO_TYPE(monsterIndex) \
((monsterIndex) + SFG_LEVEL_ELEMENT_MONSTER_SPIDER)
#define SFG_LEVEL_ELEMENT_TYPE_IS_MOSTER(t) \
((t) >= SFG_LEVEL_ELEMENT_MONSTER_SPIDER)
typedef struct
{

13
main.c
View File

@ -188,7 +188,8 @@ typedef struct
} SFG_MonsterRecord;
#define SFG_MR_STATE(mr) ((mr).stateType & SFG_MONSTER_MASK_STATE)
#define SFG_MR_TYPE(mr) ((mr).stateType & SFG_MONSTER_MASK_TYPE)
#define SFG_MR_TYPE(mr) \
(SFG_MONSTER_INDEX_TO_TYPE(((mr).stateType & SFG_MONSTER_MASK_TYPE) >> 4))
#define SFG_MONSTER_COORD_TO_RCL_UNITS(c) (c * 256)
#define SFG_MONSTER_COORD_TO_SQUARES(c) (c / 4)
@ -1294,7 +1295,9 @@ void SFG_setAndInitLevel(const SFG_Level *level)
monster =
&(SFG_currentLevel.monsterRecords[SFG_currentLevel.monsterRecordCount]);
monster->stateType = e->type | SFG_MONSTER_STATE_INACTIVE;
monster->stateType = (SFG_MONSTER_TYPE_TO_INDEX(e->type) << 4)
| SFG_MONSTER_STATE_INACTIVE;
monster->health =
SFG_GET_MONSTER_MAX_HEALTH(SFG_MONSTER_TYPE_TO_INDEX(e->type));
@ -2092,7 +2095,7 @@ void SFG_monsterPerformAI(SFG_MonsterRecord *monster)
newPos[1] = monster->coords[1];
}
monster->stateType = state | type;
monster->stateType = state | (monsterNumber << 4);
monster->coords[0] = newPos[0];
monster->coords[1] = newPos[1];;
}
@ -2449,7 +2452,9 @@ void SFG_updateLevel()
}
else if (monster->health == 0)
{
monster->stateType = SFG_MR_TYPE(*monster) | SFG_MONSTER_STATE_DYING;
monster->stateType = (monster->stateType & SFG_MONSTER_MASK_TYPE) |
SFG_MONSTER_STATE_DYING;
SFG_playSoundSafe(2,255);
}
else if (state != SFG_MONSTER_STATE_INACTIVE)