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.
472 lines
13 KiB
472 lines
13 KiB
|
6 years ago
|
/**
|
||
|
|
* @file monstdat.cpp
|
||
|
|
*
|
||
|
|
* Implementation of all monster data.
|
||
|
|
*/
|
||
|
2 months ago
|
#include "tables/monstdat.h"
|
||
|
5 years ago
|
|
||
|
7 months ago
|
#include <algorithm>
|
||
|
|
#include <cstddef>
|
||
|
3 years ago
|
#include <cstdint>
|
||
|
7 months ago
|
#include <optional>
|
||
|
|
#include <string>
|
||
|
|
#include <string_view>
|
||
|
|
#include <vector>
|
||
|
3 years ago
|
|
||
|
2 years ago
|
#include <ankerl/unordered_dense.h>
|
||
|
7 months ago
|
#include <expected.hpp>
|
||
|
7 months ago
|
#include <fmt/core.h>
|
||
|
7 months ago
|
#include <magic_enum/magic_enum.hpp>
|
||
|
2 years ago
|
|
||
|
7 months ago
|
#include "appfat.h"
|
||
|
2 years ago
|
#include "cursor.h"
|
||
|
2 years ago
|
#include "data/file.hpp"
|
||
|
7 months ago
|
#include "data/iterators.hpp"
|
||
|
2 years ago
|
#include "data/record_reader.hpp"
|
||
|
3 years ago
|
#include "items.h"
|
||
|
7 months ago
|
#include "lua/lua_global.hpp"
|
||
|
5 years ago
|
#include "monster.h"
|
||
|
2 months ago
|
#include "tables/textdat.h"
|
||
|
5 years ago
|
#include "utils/language.h"
|
||
|
7 years ago
|
|
||
|
5 years ago
|
namespace devilution {
|
||
|
7 years ago
|
|
||
|
4 years ago
|
namespace {
|
||
|
|
|
||
|
4 years ago
|
// Returns a `treasure` value for the given item.
|
||
|
4 years ago
|
constexpr uint16_t Uniq(_unique_items item)
|
||
|
|
{
|
||
|
|
return static_cast<uint16_t>(T_UNIQ) + item;
|
||
|
|
}
|
||
|
|
|
||
|
2 years ago
|
std::vector<std::string> MonsterSpritePaths;
|
||
|
4 years ago
|
|
||
|
4 years ago
|
} // namespace
|
||
|
|
|
||
|
4 years ago
|
const char *MonsterData::spritePath() const
|
||
|
|
{
|
||
|
2 years ago
|
return MonsterSpritePaths[static_cast<size_t>(spriteId)].c_str();
|
||
|
4 years ago
|
}
|
||
|
|
|
||
|
6 years ago
|
/** Contains the data related to each monster ID. */
|
||
|
2 years ago
|
std::vector<MonsterData> MonstersData;
|
||
|
7 years ago
|
|
||
|
2 years ago
|
/** Contains the data related to each unique monster ID. */
|
||
|
|
std::vector<UniqueMonsterData> UniqueMonstersData;
|
||
|
|
|
||
|
6 years ago
|
/**
|
||
|
|
* Map between .DUN file value and monster type enum
|
||
|
|
*/
|
||
|
5 years ago
|
const _monster_id MonstConvTbl[] = {
|
||
|
6 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_SNEAK,
|
||
|
|
MT_STALKER,
|
||
|
|
MT_UNSEEN,
|
||
|
|
MT_ILLWEAV,
|
||
|
|
MT_NGOATMC,
|
||
|
|
MT_BGOATMC,
|
||
|
|
MT_RGOATMC,
|
||
|
|
MT_GGOATMC,
|
||
|
|
MT_FIEND,
|
||
|
|
MT_GLOOM,
|
||
|
|
MT_BLINK,
|
||
|
|
MT_FAMILIAR,
|
||
|
|
MT_NGOATBW,
|
||
|
|
MT_BGOATBW,
|
||
|
|
MT_RGOATBW,
|
||
|
|
MT_GGOATBW,
|
||
|
|
MT_NACID,
|
||
|
|
MT_RACID,
|
||
|
|
MT_BACID,
|
||
|
|
MT_XACID,
|
||
|
|
MT_SKING,
|
||
|
|
MT_FAT,
|
||
|
|
MT_MUDMAN,
|
||
|
|
MT_TOAD,
|
||
|
|
MT_FLAYED,
|
||
|
|
MT_WYRM,
|
||
|
|
MT_CAVSLUG,
|
||
|
|
MT_DEVOUR,
|
||
|
|
MT_DVLWYRM,
|
||
|
|
MT_NMAGMA,
|
||
|
|
MT_YMAGMA,
|
||
|
|
MT_BMAGMA,
|
||
|
|
MT_WMAGMA,
|
||
|
|
MT_HORNED,
|
||
|
|
MT_MUDRUN,
|
||
|
|
MT_FROSTC,
|
||
|
|
MT_OBLORD,
|
||
|
|
MT_BONEDMN,
|
||
|
|
MT_REDDTH,
|
||
|
|
MT_LTCHDMN,
|
||
|
|
MT_UDEDBLRG,
|
||
|
5 years ago
|
MT_INVALID,
|
||
|
|
MT_INVALID,
|
||
|
|
MT_INVALID,
|
||
|
|
MT_INVALID,
|
||
|
6 years ago
|
MT_INCIN,
|
||
|
|
MT_FLAMLRD,
|
||
|
|
MT_DOOMFIRE,
|
||
|
|
MT_HELLBURN,
|
||
|
5 years ago
|
MT_INVALID,
|
||
|
|
MT_INVALID,
|
||
|
|
MT_INVALID,
|
||
|
|
MT_INVALID,
|
||
|
6 years ago
|
MT_RSTORM,
|
||
|
|
MT_STORM,
|
||
|
|
MT_STORML,
|
||
|
|
MT_MAEL,
|
||
|
|
MT_WINGED,
|
||
|
|
MT_GARGOYLE,
|
||
|
|
MT_BLOODCLW,
|
||
|
|
MT_DEATHW,
|
||
|
|
MT_MEGA,
|
||
|
|
MT_GUARD,
|
||
|
|
MT_VTEXLRD,
|
||
|
|
MT_BALROG,
|
||
|
|
MT_NSNAKE,
|
||
|
|
MT_RSNAKE,
|
||
|
|
MT_GSNAKE,
|
||
|
|
MT_BSNAKE,
|
||
|
|
MT_NBLACK,
|
||
|
|
MT_RTBLACK,
|
||
|
|
MT_BTBLACK,
|
||
|
|
MT_RBLACK,
|
||
|
|
MT_UNRAV,
|
||
|
|
MT_HOLOWONE,
|
||
|
|
MT_PAINMSTR,
|
||
|
|
MT_REALWEAV,
|
||
|
|
MT_SUCCUBUS,
|
||
|
|
MT_SNOWWICH,
|
||
|
|
MT_HLSPWN,
|
||
|
|
MT_SOLBRNR,
|
||
|
|
MT_COUNSLR,
|
||
|
|
MT_MAGISTR,
|
||
|
|
MT_CABALIST,
|
||
|
|
MT_ADVOCATE,
|
||
|
5 years ago
|
MT_INVALID,
|
||
|
6 years ago
|
MT_DIABLO,
|
||
|
5 years ago
|
MT_INVALID,
|
||
|
6 years ago
|
MT_GOLEM,
|
||
|
5 years ago
|
MT_INVALID,
|
||
|
|
MT_INVALID,
|
||
|
|
MT_INVALID, // Monster from blood1.dun and blood2.dun
|
||
|
|
MT_INVALID,
|
||
|
|
MT_INVALID,
|
||
|
|
MT_INVALID,
|
||
|
|
MT_INVALID, // Snotspill from banner2.dun
|
||
|
|
MT_INVALID,
|
||
|
|
MT_INVALID,
|
||
|
6 years ago
|
MT_BIGFALL,
|
||
|
|
MT_DARKMAGE,
|
||
|
6 years ago
|
MT_HELLBOAR,
|
||
|
|
MT_STINGER,
|
||
|
|
MT_PSYCHORB,
|
||
|
|
MT_ARACHNON,
|
||
|
|
MT_FELLTWIN,
|
||
|
|
MT_HORKSPWN,
|
||
|
4 years ago
|
MT_VENMTAIL,
|
||
|
|
MT_NECRMORB,
|
||
|
|
MT_SPIDLORD,
|
||
|
6 years ago
|
MT_LASHWORM,
|
||
|
|
MT_TORCHANT,
|
||
|
|
MT_HORKDMN,
|
||
|
|
MT_DEFILER,
|
||
|
|
MT_GRAVEDIG,
|
||
|
|
MT_TOMBRAT,
|
||
|
|
MT_FIREBAT,
|
||
|
|
MT_SKLWING,
|
||
|
|
MT_LICH,
|
||
|
|
MT_CRYPTDMN,
|
||
|
4 years ago
|
MT_HELLBAT,
|
||
|
|
MT_BONEDEMN,
|
||
|
6 years ago
|
MT_LICH,
|
||
|
|
MT_BICLOPS,
|
||
|
|
MT_FLESTHNG,
|
||
|
|
MT_REAPER,
|
||
|
|
MT_NAKRUL,
|
||
|
6 years ago
|
MT_CLEAVER,
|
||
|
|
MT_INVILORD,
|
||
|
|
MT_LRDSAYTR,
|
||
|
7 years ago
|
};
|
||
|
|
|
||
|
7 months ago
|
namespace {
|
||
|
|
|
||
|
|
/** Contains the mapping between monster ID strings and indices, used for parsing additional monster data. */
|
||
|
|
ankerl::unordered_dense::map<std::string, int16_t> AdditionalMonsterIdStringsToIndices;
|
||
|
|
|
||
|
2 years ago
|
tl::expected<_monster_id, std::string> ParseMonsterId(std::string_view value)
|
||
|
|
{
|
||
|
7 months ago
|
const std::optional<_monster_id> enumValueOpt = magic_enum::enum_cast<_monster_id>(value);
|
||
|
|
if (enumValueOpt.has_value()) {
|
||
|
|
return enumValueOpt.value();
|
||
|
|
}
|
||
|
7 months ago
|
const auto findIt = AdditionalMonsterIdStringsToIndices.find(std::string(value));
|
||
|
|
if (findIt != AdditionalMonsterIdStringsToIndices.end()) {
|
||
|
|
return static_cast<_monster_id>(findIt->second);
|
||
|
|
}
|
||
|
2 years ago
|
return tl::make_unexpected("Unknown enum value");
|
||
|
|
}
|
||
|
|
|
||
|
2 years ago
|
tl::expected<MonsterAvailability, std::string> ParseMonsterAvailability(std::string_view value)
|
||
|
|
{
|
||
|
2 years ago
|
if (value == "Always") return MonsterAvailability::Always;
|
||
|
|
if (value == "Never") return MonsterAvailability::Never;
|
||
|
|
if (value == "Retail") return MonsterAvailability::Retail;
|
||
|
2 years ago
|
return tl::make_unexpected("Expected one of: Always, Never, or Retail");
|
||
|
|
}
|
||
|
|
|
||
|
|
tl::expected<MonsterAIID, std::string> ParseAiId(std::string_view value)
|
||
|
|
{
|
||
|
7 months ago
|
const std::optional<MonsterAIID> enumValueOpt = magic_enum::enum_cast<MonsterAIID>(value);
|
||
|
|
if (enumValueOpt.has_value()) {
|
||
|
|
return enumValueOpt.value();
|
||
|
|
}
|
||
|
2 years ago
|
return tl::make_unexpected("Unknown enum value");
|
||
|
|
}
|
||
|
|
|
||
|
|
tl::expected<monster_flag, std::string> ParseMonsterFlag(std::string_view value)
|
||
|
|
{
|
||
|
2 years ago
|
if (value == "HIDDEN") return MFLAG_HIDDEN;
|
||
|
|
if (value == "LOCK_ANIMATION") return MFLAG_LOCK_ANIMATION;
|
||
|
|
if (value == "ALLOW_SPECIAL") return MFLAG_ALLOW_SPECIAL;
|
||
|
|
if (value == "TARGETS_MONSTER") return MFLAG_TARGETS_MONSTER;
|
||
|
|
if (value == "GOLEM") return MFLAG_GOLEM;
|
||
|
|
if (value == "QUEST_COMPLETE") return MFLAG_QUEST_COMPLETE;
|
||
|
|
if (value == "KNOCKBACK") return MFLAG_KNOCKBACK;
|
||
|
|
if (value == "SEARCH") return MFLAG_SEARCH;
|
||
|
|
if (value == "CAN_OPEN_DOOR") return MFLAG_CAN_OPEN_DOOR;
|
||
|
|
if (value == "NO_ENEMY") return MFLAG_NO_ENEMY;
|
||
|
|
if (value == "BERSERK") return MFLAG_BERSERK;
|
||
|
|
if (value == "NOLIFESTEAL") return MFLAG_NOLIFESTEAL;
|
||
|
2 years ago
|
return tl::make_unexpected("Unknown enum value");
|
||
|
|
}
|
||
|
|
|
||
|
|
tl::expected<MonsterClass, std::string> ParseMonsterClass(std::string_view value)
|
||
|
|
{
|
||
|
7 months ago
|
const std::optional<MonsterClass> enumValueOpt = magic_enum::enum_cast<MonsterClass>(value);
|
||
|
|
if (enumValueOpt.has_value()) {
|
||
|
|
return enumValueOpt.value();
|
||
|
|
}
|
||
|
2 years ago
|
return tl::make_unexpected("Unknown enum value");
|
||
|
|
}
|
||
|
|
|
||
|
|
tl::expected<monster_resistance, std::string> ParseMonsterResistance(std::string_view value)
|
||
|
|
{
|
||
|
7 months ago
|
const std::optional<monster_resistance> enumValueOpt = magic_enum::enum_cast<monster_resistance>(value);
|
||
|
|
if (enumValueOpt.has_value()) {
|
||
|
|
return enumValueOpt.value();
|
||
|
|
}
|
||
|
2 years ago
|
return tl::make_unexpected("Unknown enum value");
|
||
|
|
}
|
||
|
|
|
||
|
2 years ago
|
tl::expected<SelectionRegion, std::string> ParseSelectionRegion(std::string_view value)
|
||
|
|
{
|
||
|
|
if (value.empty()) return SelectionRegion::None;
|
||
|
|
if (value == "Bottom") return SelectionRegion::Bottom;
|
||
|
|
if (value == "Middle") return SelectionRegion::Middle;
|
||
|
|
if (value == "Top") return SelectionRegion::Top;
|
||
|
|
return tl::make_unexpected("Unknown enum value");
|
||
|
|
}
|
||
|
|
|
||
|
7 months ago
|
tl::expected<uint16_t, std::string> ParseMonsterTreasure(std::string_view value)
|
||
|
|
{
|
||
|
|
// TODO: Replace this hack with proper parsing.
|
||
|
|
|
||
|
|
if (value.empty()) return 0;
|
||
|
|
if (value == "None") return T_NODROP;
|
||
|
|
if (value == "Uniq(SKCROWN)") return Uniq(UITEM_SKCROWN);
|
||
|
|
if (value == "Uniq(CLEAVER)") return Uniq(UITEM_CLEAVER);
|
||
|
|
return tl::make_unexpected("Invalid value. NOTE: Parser is incomplete");
|
||
|
|
}
|
||
|
|
|
||
|
2 years ago
|
tl::expected<UniqueMonsterPack, std::string> ParseUniqueMonsterPack(std::string_view value)
|
||
|
|
{
|
||
|
7 months ago
|
const std::optional<UniqueMonsterPack> enumValueOpt = magic_enum::enum_cast<UniqueMonsterPack>(value);
|
||
|
|
if (enumValueOpt.has_value()) {
|
||
|
|
return enumValueOpt.value();
|
||
|
|
}
|
||
|
2 years ago
|
return tl::make_unexpected("Unknown enum value");
|
||
|
|
}
|
||
|
|
|
||
|
7 months ago
|
} // namespace
|
||
|
|
|
||
|
7 months ago
|
void LoadMonstDatFromFile(DataFile &dataFile, const std::string_view filename, bool grow)
|
||
|
2 years ago
|
{
|
||
|
2 years ago
|
dataFile.skipHeaderOrDie(filename);
|
||
|
2 years ago
|
|
||
|
7 months ago
|
if (grow) {
|
||
|
|
MonstersData.reserve(MonstersData.size() + dataFile.numRecords());
|
||
|
|
}
|
||
|
7 months ago
|
|
||
|
2 years ago
|
for (DataFileRecord record : dataFile) {
|
||
|
7 months ago
|
if (MonstersData.size() >= static_cast<size_t>(NUM_MAX_MTYPES)) {
|
||
|
|
DisplayFatalErrorAndExit(_("Loading Monster Data Failed"), fmt::format(fmt::runtime(_("Could not add a monster, since the maximum monster type number of {} has already been reached.")), static_cast<size_t>(NUM_MAX_MTYPES)));
|
||
|
|
}
|
||
|
|
|
||
|
2 years ago
|
RecordReader reader { record, filename };
|
||
|
7 months ago
|
|
||
|
|
std::string monsterId;
|
||
|
|
reader.readString("_monster_id", monsterId);
|
||
|
|
const std::optional<_monster_id> monsterIdEnumValueOpt = magic_enum::enum_cast<_monster_id>(monsterId);
|
||
|
|
|
||
|
|
if (!monsterIdEnumValueOpt.has_value()) {
|
||
|
|
const size_t monsterIndex = MonstersData.size();
|
||
|
|
const auto [it, inserted] = AdditionalMonsterIdStringsToIndices.emplace(monsterId, static_cast<int16_t>(monsterIndex));
|
||
|
|
if (!inserted) {
|
||
|
|
DisplayFatalErrorAndExit(_("Loading Monster Data Failed"), fmt::format(fmt::runtime(_("A monster type already exists for ID \"{}\".")), monsterId));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// for hardcoded monsters, use their predetermined slot; for non-hardcoded ones, use the slots after that
|
||
|
|
MonsterData &monster = monsterIdEnumValueOpt.has_value() ? MonstersData[monsterIdEnumValueOpt.value()] : MonstersData.emplace_back();
|
||
|
|
|
||
|
2 years ago
|
reader.readString("name", monster.name);
|
||
|
2 years ago
|
{
|
||
|
2 years ago
|
std::string assetsSuffix;
|
||
|
|
reader.readString("assetsSuffix", assetsSuffix);
|
||
|
7 months ago
|
const auto findIt = std::find(MonsterSpritePaths.begin(), MonsterSpritePaths.end(), assetsSuffix);
|
||
|
|
if (findIt != MonsterSpritePaths.end()) {
|
||
|
|
monster.spriteId = static_cast<uint16_t>(findIt - MonsterSpritePaths.begin());
|
||
|
|
} else {
|
||
|
|
monster.spriteId = static_cast<uint16_t>(MonsterSpritePaths.size());
|
||
|
|
MonsterSpritePaths.push_back(std::string(assetsSuffix));
|
||
|
|
}
|
||
|
2 years ago
|
}
|
||
|
2 years ago
|
reader.readString("soundSuffix", monster.soundSuffix);
|
||
|
|
reader.readString("trnFile", monster.trnFile);
|
||
|
|
reader.read("availability", monster.availability, ParseMonsterAvailability);
|
||
|
|
reader.readInt("width", monster.width);
|
||
|
|
reader.readInt("image", monster.image);
|
||
|
|
reader.readBool("hasSpecial", monster.hasSpecial);
|
||
|
|
reader.readBool("hasSpecialSound", monster.hasSpecialSound);
|
||
|
|
reader.readIntArray("frames", monster.frames);
|
||
|
|
reader.readIntArray("rate", monster.rate);
|
||
|
|
reader.readInt("minDunLvl", monster.minDunLvl);
|
||
|
|
reader.readInt("maxDunLvl", monster.maxDunLvl);
|
||
|
|
reader.readInt("level", monster.level);
|
||
|
|
reader.readInt("hitPointsMinimum", monster.hitPointsMinimum);
|
||
|
|
reader.readInt("hitPointsMaximum", monster.hitPointsMaximum);
|
||
|
|
reader.read("ai", monster.ai, ParseAiId);
|
||
|
|
reader.readEnumList("abilityFlags", monster.abilityFlags, ParseMonsterFlag);
|
||
|
|
reader.readInt("intelligence", monster.intelligence);
|
||
|
|
reader.readInt("toHit", monster.toHit);
|
||
|
|
reader.readInt("animFrameNum", monster.animFrameNum);
|
||
|
|
reader.readInt("minDamage", monster.minDamage);
|
||
|
|
reader.readInt("maxDamage", monster.maxDamage);
|
||
|
|
reader.readInt("toHitSpecial", monster.toHitSpecial);
|
||
|
|
reader.readInt("animFrameNumSpecial", monster.animFrameNumSpecial);
|
||
|
|
reader.readInt("minDamageSpecial", monster.minDamageSpecial);
|
||
|
|
reader.readInt("maxDamageSpecial", monster.maxDamageSpecial);
|
||
|
|
reader.readInt("armorClass", monster.armorClass);
|
||
|
|
reader.read("monsterClass", monster.monsterClass, ParseMonsterClass);
|
||
|
|
reader.readEnumList("resistance", monster.resistance, ParseMonsterResistance);
|
||
|
|
reader.readEnumList("resistanceHell", monster.resistanceHell, ParseMonsterResistance);
|
||
|
2 years ago
|
reader.readEnumList("selectionRegion", monster.selectionRegion, ParseSelectionRegion);
|
||
|
7 months ago
|
reader.read("treasure", monster.treasure, ParseMonsterTreasure);
|
||
|
2 years ago
|
|
||
|
|
reader.readInt("exp", monster.exp);
|
||
|
2 years ago
|
}
|
||
|
2 years ago
|
}
|
||
|
|
|
||
|
7 months ago
|
namespace {
|
||
|
|
|
||
|
|
void LoadMonstDat()
|
||
|
|
{
|
||
|
|
const std::string_view filename = "txtdata\\monsters\\monstdat.tsv";
|
||
|
|
DataFile dataFile = DataFile::loadOrDie(filename);
|
||
|
|
MonstersData.clear();
|
||
|
|
AdditionalMonsterIdStringsToIndices.clear();
|
||
|
|
MonstersData.resize(NUM_DEFAULT_MTYPES); // ensure the hardcoded monster type slots are filled
|
||
|
7 months ago
|
LoadMonstDatFromFile(dataFile, filename, false);
|
||
|
7 months ago
|
|
||
|
|
LuaEvent("MonsterDataLoaded");
|
||
|
7 months ago
|
|
||
|
|
MonstersData.shrink_to_fit();
|
||
|
7 months ago
|
}
|
||
|
|
|
||
|
7 months ago
|
} // namespace
|
||
|
|
|
||
|
|
void LoadUniqueMonstDatFromFile(DataFile &dataFile, std::string_view filename)
|
||
|
2 years ago
|
{
|
||
|
2 years ago
|
dataFile.skipHeaderOrDie(filename);
|
||
|
2 years ago
|
|
||
|
7 months ago
|
UniqueMonstersData.reserve(UniqueMonstersData.size() + dataFile.numRecords());
|
||
|
|
|
||
|
2 years ago
|
for (DataFileRecord record : dataFile) {
|
||
|
2 years ago
|
RecordReader reader { record, filename };
|
||
|
|
UniqueMonsterData &monster = UniqueMonstersData.emplace_back();
|
||
|
|
reader.read("type", monster.mtype, ParseMonsterId);
|
||
|
|
reader.readString("name", monster.mName);
|
||
|
|
reader.readString("trn", monster.mTrnName);
|
||
|
|
reader.readInt("level", monster.mlevel);
|
||
|
|
reader.readInt("maxHp", monster.mmaxhp);
|
||
|
|
reader.read("ai", monster.mAi, ParseAiId);
|
||
|
|
reader.readInt("intelligence", monster.mint);
|
||
|
|
reader.readInt("minDamage", monster.mMinDamage);
|
||
|
|
reader.readInt("maxDamage", monster.mMaxDamage);
|
||
|
|
reader.readEnumList("resistance", monster.mMagicRes, ParseMonsterResistance);
|
||
|
|
reader.read("monsterPack", monster.monsterPack, ParseUniqueMonsterPack);
|
||
|
|
reader.readInt("customToHit", monster.customToHit);
|
||
|
|
reader.readInt("customArmorClass", monster.customArmorClass);
|
||
|
7 months ago
|
reader.read("talkMessage", monster.mtalkmsg, ParseSpeechId);
|
||
|
2 years ago
|
}
|
||
|
7 months ago
|
}
|
||
|
|
|
||
|
|
namespace {
|
||
|
|
|
||
|
|
void LoadUniqueMonstDat()
|
||
|
|
{
|
||
|
|
const std::string_view filename = "txtdata\\monsters\\unique_monstdat.tsv";
|
||
|
|
DataFile dataFile = DataFile::loadOrDie(filename);
|
||
|
|
|
||
|
|
UniqueMonstersData.clear();
|
||
|
|
LoadUniqueMonstDatFromFile(dataFile, filename);
|
||
|
7 months ago
|
|
||
|
|
LuaEvent("UniqueMonsterDataLoaded");
|
||
|
7 months ago
|
|
||
|
|
UniqueMonstersData.shrink_to_fit();
|
||
|
2 years ago
|
}
|
||
|
|
|
||
|
|
} // namespace
|
||
|
|
|
||
|
|
void LoadMonsterData()
|
||
|
|
{
|
||
|
|
LoadMonstDat();
|
||
|
|
LoadUniqueMonstDat();
|
||
|
2 years ago
|
}
|
||
|
|
|
||
|
|
size_t GetNumMonsterSprites()
|
||
|
|
{
|
||
|
|
return MonsterSpritePaths.size();
|
||
|
|
}
|
||
|
|
|
||
|
5 years ago
|
} // namespace devilution
|