From 9fef13d4d2e0eab3376ea95b3cb8783d48d19dda Mon Sep 17 00:00:00 2001 From: Haru Date: Sat, 21 Nov 2015 15:44:24 +0100 Subject: Refactored/fixed race handling for bonuses that store it as a bitmask - The following bonuses now work correctly with RC_DemiPlayer, RC_NonDemiPlayer, RC_NonDemiHuman, RC_Nonplayer: * bIgnoreDefRace * bIgnoreMdefRace * bDefRatioAtkRace * bAddMonsterDropChainItem (bonus3) * bAddMonsterDropItem (bonus3) - A new function (map->race_id2mask) is provided, to easily and efficiently generate a bitmask from a race ID. - The RC_ALL race ID is mapped to RC_BOSS and RC_NONBOSS, for backwards compatibility. Signed-off-by: Haru --- src/map/map.h | 79 ++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 59 insertions(+), 20 deletions(-) (limited to 'src/map/map.h') diff --git a/src/map/map.h b/src/map/map.h index 974fbc4ba..8f0bbca39 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -251,26 +251,64 @@ enum bl_type { enum npc_subtype { WARP, SHOP, SCRIPT, CASHSHOP, TOMB }; -enum { - RC_FORMLESS=0, - RC_UNDEAD, - RC_BRUTE, - RC_PLANT, - RC_INSECT, - RC_FISH, - RC_DEMON, - RC_DEMIHUMAN, - RC_ANGEL, - RC_DRAGON, - RC_PLAYER, - RC_BOSS, - RC_NONBOSS, - RC_MAX, - RC_NONDEMIHUMAN, - RC_NONPLAYER, - RC_DEMIPLAYER, - RC_NONDEMIPLAYER, - RC_ALL = 0xFF +/** + * Race type IDs. + * + * Mostly used by scripts/bonuses. + */ +enum Race { + // Base Races + RC_FORMLESS = 0, ///< Formless + RC_UNDEAD, ///< Undead + RC_BRUTE, ///< Beast/Brute + RC_PLANT, ///< Plant + RC_INSECT, ///< Insect + RC_FISH, ///< Fish + RC_DEMON, ///< Demon + RC_DEMIHUMAN, ///< Demi-Human (not including Player) + RC_ANGEL, ///< Angel + RC_DRAGON, ///< Dragon + RC_PLAYER, ///< Player + // Boss + RC_BOSS, ///< Boss + RC_NONBOSS, ///< Non-boss + + RC_MAX, // Array size delimiter (keep before the combination races) + + // Combination Races + RC_NONDEMIHUMAN, ///< Every race except Demi-Human (including Player) + RC_NONPLAYER, ///< Every non-player race + RC_DEMIPLAYER, ///< Demi-Human (including Player) + RC_NONDEMIPLAYER, ///< Every race except Demi-Human (and except Player) + RC_ALL = 0xFF, ///< Every race (implemented as equivalent to RC_BOSS and RC_NONBOSS) +}; + +/** + * Race type bitmasks. + * + * Used by several bonuses internally, to simplify handling of race combinations. + */ +enum RaceMask { + RCMASK_NONE = 0, + RCMASK_FORMLESS = 1<