You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
366 lines
6.8 KiB
366 lines
6.8 KiB
|
6 years ago
|
/**
|
||
|
|
* @file monstdat.h
|
||
|
|
*
|
||
|
|
* Interface of all monster data.
|
||
|
|
*/
|
||
|
5 years ago
|
#pragma once
|
||
|
7 years ago
|
|
||
|
1 year ago
|
#include <cstddef>
|
||
|
5 years ago
|
#include <cstdint>
|
||
|
1 year ago
|
#include <string>
|
||
|
2 years ago
|
#include <vector>
|
||
|
5 years ago
|
|
||
|
7 months ago
|
#include <magic_enum/magic_enum.hpp>
|
||
|
|
|
||
|
2 years ago
|
#include "cursor.h"
|
||
|
2 months ago
|
#include "tables/textdat.h"
|
||
|
5 years ago
|
|
||
|
5 years ago
|
namespace devilution {
|
||
|
6 years ago
|
|
||
|
7 months ago
|
class DataFile;
|
||
|
|
|
||
|
3 years ago
|
enum class MonsterAIID : int8_t {
|
||
|
|
Zombie,
|
||
|
|
Fat,
|
||
|
|
SkeletonMelee,
|
||
|
|
SkeletonRanged,
|
||
|
|
Scavenger,
|
||
|
|
Rhino,
|
||
|
|
GoatMelee,
|
||
|
|
GoatRanged,
|
||
|
|
Fallen,
|
||
|
|
Magma,
|
||
|
|
SkeletonKing,
|
||
|
|
Bat,
|
||
|
|
Gargoyle,
|
||
|
|
Butcher,
|
||
|
|
Succubus,
|
||
|
|
Sneak,
|
||
|
|
Storm,
|
||
|
|
FireMan,
|
||
|
|
Gharbad,
|
||
|
|
Acid,
|
||
|
|
AcidUnique,
|
||
|
|
Golem,
|
||
|
|
Zhar,
|
||
|
|
Snotspill,
|
||
|
|
Snake,
|
||
|
|
Counselor,
|
||
|
|
Mega,
|
||
|
|
Diablo,
|
||
|
|
Lazarus,
|
||
|
|
LazarusSuccubus,
|
||
|
|
Lachdanan,
|
||
|
|
Warlord,
|
||
|
|
FireBat,
|
||
|
|
Torchant,
|
||
|
|
HorkDemon,
|
||
|
|
Lich,
|
||
|
|
ArchLich,
|
||
|
|
Psychorb,
|
||
|
|
Necromorb,
|
||
|
|
BoneDemon,
|
||
|
|
Invalid = -1,
|
||
|
5 years ago
|
};
|
||
|
5 years ago
|
|
||
|
5 years ago
|
enum class MonsterClass : uint8_t {
|
||
|
5 years ago
|
Undead,
|
||
|
|
Demon,
|
||
|
|
Animal,
|
||
|
5 years ago
|
};
|
||
|
5 years ago
|
|
||
|
5 years ago
|
enum monster_resistance : uint8_t {
|
||
|
5 years ago
|
// clang-format off
|
||
|
5 years ago
|
RESIST_MAGIC = 1 << 0,
|
||
|
|
RESIST_FIRE = 1 << 1,
|
||
|
|
RESIST_LIGHTNING = 1 << 2,
|
||
|
|
IMMUNE_MAGIC = 1 << 3,
|
||
|
|
IMMUNE_FIRE = 1 << 4,
|
||
|
|
IMMUNE_LIGHTNING = 1 << 5,
|
||
|
|
IMMUNE_ACID = 1 << 7,
|
||
|
5 years ago
|
// clang-format on
|
||
|
5 years ago
|
};
|
||
|
5 years ago
|
|
||
|
5 years ago
|
enum monster_treasure : uint16_t {
|
||
|
|
// clang-format off
|
||
|
|
T_MASK = 0xFFF,
|
||
|
|
T_NODROP = 0x4000, // monster doesn't drop any loot
|
||
|
|
T_UNIQ = 0x8000, // use combined with unique item's ID - for example butcher's cleaver = T_UNIQ+UITEM_CLEAVE
|
||
|
|
// clang-format on
|
||
|
|
};
|
||
|
|
|
||
|
4 years ago
|
enum class MonsterAvailability : uint8_t {
|
||
|
|
Never,
|
||
|
|
Always,
|
||
|
|
Retail,
|
||
|
|
};
|
||
|
|
|
||
|
5 years ago
|
struct MonsterData {
|
||
|
2 years ago
|
std::string name;
|
||
|
|
std::string soundSuffix;
|
||
|
|
std::string trnFile;
|
||
|
7 months ago
|
uint16_t spriteId = 0;
|
||
|
|
MonsterAvailability availability = MonsterAvailability::Never;
|
||
|
|
uint16_t width = 0;
|
||
|
|
uint16_t image = 0;
|
||
|
|
bool hasSpecial = false;
|
||
|
|
bool hasSpecialSound = false;
|
||
|
|
int8_t frames[6] {};
|
||
|
|
int8_t rate[6] {};
|
||
|
|
int8_t minDunLvl = 0;
|
||
|
|
int8_t maxDunLvl = 0;
|
||
|
|
int8_t level = 0;
|
||
|
|
uint16_t hitPointsMinimum = 0;
|
||
|
|
uint16_t hitPointsMaximum = 0;
|
||
|
|
MonsterAIID ai = MonsterAIID::Invalid;
|
||
|
4 years ago
|
/**
|
||
|
|
* @brief Denotes monster's abilities defined in @p monster_flag as bitflags
|
||
|
|
* For usage, see @p MonstersData in monstdat.cpp
|
||
|
|
*/
|
||
|
7 months ago
|
uint16_t abilityFlags = 0;
|
||
|
|
uint8_t intelligence = 0;
|
||
|
|
uint8_t toHit = 0;
|
||
|
|
int8_t animFrameNum = 0;
|
||
|
|
uint8_t minDamage = 0;
|
||
|
|
uint8_t maxDamage = 0;
|
||
|
|
uint8_t toHitSpecial = 0;
|
||
|
|
int8_t animFrameNumSpecial = 0;
|
||
|
|
uint8_t minDamageSpecial = 0;
|
||
|
|
uint8_t maxDamageSpecial = 0;
|
||
|
|
uint8_t armorClass = 0;
|
||
|
|
MonsterClass monsterClass {};
|
||
|
5 years ago
|
/** Using monster_resistance as bitflags */
|
||
|
7 months ago
|
uint8_t resistance = 0;
|
||
|
5 years ago
|
/** Using monster_resistance as bitflags */
|
||
|
7 months ago
|
uint8_t resistanceHell = 0;
|
||
|
|
SelectionRegion selectionRegion = SelectionRegion::None;
|
||
|
5 years ago
|
/** Using monster_treasure */
|
||
|
7 months ago
|
uint16_t treasure = 0;
|
||
|
|
uint16_t exp = 0;
|
||
|
4 years ago
|
|
||
|
|
[[nodiscard]] const char *spritePath() const;
|
||
|
|
|
||
|
|
[[nodiscard]] const char *soundPath() const
|
||
|
|
{
|
||
|
2 years ago
|
return !soundSuffix.empty() ? soundSuffix.c_str() : spritePath();
|
||
|
4 years ago
|
}
|
||
|
|
|
||
|
|
[[nodiscard]] bool hasAnim(size_t index) const
|
||
|
|
{
|
||
|
|
return frames[index] != 0;
|
||
|
|
}
|
||
|
5 years ago
|
};
|
||
|
5 years ago
|
|
||
|
5 years ago
|
enum _monster_id : int16_t {
|
||
|
5 years ago
|
MT_NZOMBIE,
|
||
|
|
MT_BZOMBIE,
|
||
|
|
MT_GZOMBIE,
|
||
|
|
MT_YZOMBIE,
|
||
|
|
MT_RFALLSP,
|
||
|
|
MT_DFALLSP,
|
||
|
|
MT_YFALLSP,
|
||
|
|
MT_BFALLSP,
|
||
|
|
MT_WSKELAX,
|
||
|
|
MT_TSKELAX,
|
||
|
|
MT_RSKELAX,
|
||
|
|
MT_XSKELAX,
|
||
|
|
MT_RFALLSD,
|
||
|
|
MT_DFALLSD,
|
||
|
|
MT_YFALLSD,
|
||
|
|
MT_BFALLSD,
|
||
|
|
MT_NSCAV,
|
||
|
|
MT_BSCAV,
|
||
|
|
MT_WSCAV,
|
||
|
|
MT_YSCAV,
|
||
|
|
MT_WSKELBW,
|
||
|
|
MT_TSKELBW,
|
||
|
|
MT_RSKELBW,
|
||
|
|
MT_XSKELBW,
|
||
|
|
MT_WSKELSD,
|
||
|
|
MT_TSKELSD,
|
||
|
|
MT_RSKELSD,
|
||
|
|
MT_XSKELSD,
|
||
|
|
MT_INVILORD,
|
||
|
|
MT_SNEAK,
|
||
|
|
MT_STALKER,
|
||
|
|
MT_UNSEEN,
|
||
|
|
MT_ILLWEAV,
|
||
|
|
MT_LRDSAYTR,
|
||
|
|
MT_NGOATMC,
|
||
|
|
MT_BGOATMC,
|
||
|
|
MT_RGOATMC,
|
||
|
|
MT_GGOATMC,
|
||
|
|
MT_FIEND,
|
||
|
|
MT_BLINK,
|
||
|
|
MT_GLOOM,
|
||
|
|
MT_FAMILIAR,
|
||
|
|
MT_NGOATBW,
|
||
|
|
MT_BGOATBW,
|
||
|
|
MT_RGOATBW,
|
||
|
|
MT_GGOATBW,
|
||
|
|
MT_NACID,
|
||
|
|
MT_RACID,
|
||
|
|
MT_BACID,
|
||
|
|
MT_XACID,
|
||
|
|
MT_SKING,
|
||
|
|
MT_CLEAVER,
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,
|
||
|
|
MT_CABALIST,
|
||
|
|
MT_ADVOCATE,
|
||
|
|
MT_GOLEM,
|
||
|
|
MT_DIABLO,
|
||
|
|
MT_DARKMAGE,
|
||
|
|
MT_HELLBOAR,
|
||
|
|
MT_STINGER,
|
||
|
|
MT_PSYCHORB,
|
||
|
|
MT_ARACHNON,
|
||
|
|
MT_FELLTWIN,
|
||
|
|
MT_HORKSPWN,
|
||
|
|
MT_VENMTAIL,
|
||
|
|
MT_NECRMORB,
|
||
|
|
MT_SPIDLORD,
|
||
|
|
MT_LASHWORM,
|
||
|
|
MT_TORCHANT,
|
||
|
|
MT_HORKDMN,
|
||
|
|
MT_DEFILER,
|
||
|
|
MT_GRAVEDIG,
|
||
|
|
MT_TOMBRAT,
|
||
|
|
MT_FIREBAT,
|
||
|
|
MT_SKLWING,
|
||
|
|
MT_LICH,
|
||
|
|
MT_CRYPTDMN,
|
||
|
|
MT_HELLBAT,
|
||
|
|
MT_BONEDEMN,
|
||
|
|
MT_ARCHLICH,
|
||
|
|
MT_BICLOPS,
|
||
|
|
MT_FLESTHNG,
|
||
|
|
MT_REAPER,
|
||
|
|
MT_NAKRUL,
|
||
|
7 months ago
|
NUM_DEFAULT_MTYPES,
|
||
|
|
NUM_MAX_MTYPES = 200, // same as MaxMonsters, for the sake of save game compability
|
||
|
5 years ago
|
MT_INVALID = -1,
|
||
|
5 years ago
|
};
|
||
|
5 years ago
|
|
||
|
5 years ago
|
/**
|
||
|
|
* @brief Defines if and how a group of monsters should be spawned with the unique monster
|
||
|
|
*/
|
||
|
4 years ago
|
enum class UniqueMonsterPack : uint8_t {
|
||
|
5 years ago
|
/**
|
||
|
|
* @brief Don't spawn a group of monsters with the unique monster
|
||
|
|
*/
|
||
|
|
None,
|
||
|
|
/**
|
||
|
|
* @brief Spawn a group of monsters that are independent from the unique monster
|
||
|
|
*/
|
||
|
|
Independent,
|
||
|
|
/**
|
||
|
|
* @brief Spawn a group of monsters that are leashed to the unique monster
|
||
|
|
*/
|
||
|
|
Leashed,
|
||
|
|
};
|
||
|
|
|
||
|
5 years ago
|
struct UniqueMonsterData {
|
||
|
5 years ago
|
_monster_id mtype;
|
||
|
2 years ago
|
std::string mName;
|
||
|
|
std::string mTrnName;
|
||
|
5 years ago
|
uint8_t mlevel;
|
||
|
|
uint16_t mmaxhp;
|
||
|
3 years ago
|
MonsterAIID mAi;
|
||
|
5 years ago
|
uint8_t mint;
|
||
|
|
uint8_t mMinDamage;
|
||
|
|
uint8_t mMaxDamage;
|
||
|
5 years ago
|
/** Using monster_resistance as bitflags */
|
||
|
5 years ago
|
uint16_t mMagicRes;
|
||
|
5 years ago
|
/**
|
||
|
|
* @brief Defines if and how a group of monsters should be spawned with the unique monster
|
||
|
|
*/
|
||
|
|
|
||
|
|
UniqueMonsterPack monsterPack;
|
||
|
4 years ago
|
uint8_t customToHit;
|
||
|
5 years ago
|
uint8_t customArmorClass;
|
||
|
5 years ago
|
_speech_id mtalkmsg;
|
||
|
5 years ago
|
};
|
||
|
5 years ago
|
|
||
|
2 years ago
|
extern std::vector<MonsterData> MonstersData;
|
||
|
5 years ago
|
extern const _monster_id MonstConvTbl[];
|
||
|
2 years ago
|
extern std::vector<UniqueMonsterData> UniqueMonstersData;
|
||
|
7 years ago
|
|
||
|
7 months ago
|
void LoadMonstDatFromFile(DataFile &dataFile, std::string_view filename, bool grow);
|
||
|
7 months ago
|
void LoadUniqueMonstDatFromFile(DataFile &dataFile, std::string_view filename);
|
||
|
2 years ago
|
void LoadMonsterData();
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief Returns the number of the monster sprite files.
|
||
|
|
*
|
||
|
|
* Different monsters can use the same sprite with different TRNs, these count as 1.
|
||
|
|
*/
|
||
|
|
size_t GetNumMonsterSprites();
|
||
|
|
|
||
|
5 years ago
|
} // namespace devilution
|
||
|
7 months ago
|
|
||
|
|
template <>
|
||
|
|
struct magic_enum::customize::enum_range<devilution::_monster_id> {
|
||
|
|
static constexpr int min = devilution::MT_INVALID;
|
||
|
|
static constexpr int max = devilution::NUM_DEFAULT_MTYPES;
|
||
|
|
};
|
||
|
|
|
||
|
|
template <>
|
||
|
|
struct magic_enum::customize::enum_range<devilution::monster_resistance> {
|
||
|
|
static constexpr int min = 0;
|
||
|
|
static constexpr int max = 128;
|
||
|
|
};
|