#pragma once #include "anm2.h" #include "classes.h" #include #include #include #include #include #include #include #include #include // The language argument that asks for the string table's current language. constexpr int LANGUAGE_CURRENT = 20; // The slots Init makes for the game's own ids in each list. constexpr int COLLECTIBLE_SLOTS = 733; constexpr int TRINKET_SLOTS = 190; constexpr int NULL_ITEM_SLOTS = 133; constexpr int CARD_SLOTS = 98; constexpr int PILL_EFFECT_SLOTS = 50; constexpr int PLAYER_FORM_SLOTS = 16; constexpr int EXTRA_WISP_SLOTS = 19; constexpr int TAG_CACHE_SLOTS = 32; constexpr int LOCUST_QUALITY_COUNT = 5; // What an ItemConfig_Item describes, by the XML element it came from. enum ItemType : int { ITEM_NULL = 0, ITEM_PASSIVE = 1, ITEM_TRINKET = 2, ITEM_ACTIVE = 3, ITEM_FAMILIAR = 4 }; // How an active item recharges, as items.xml names it in "chargetype". enum ChargeType : int { CHARGE_NORMAL = 0, CHARGE_TIMED = 1, CHARGE_SPECIAL = 2 }; // The stats an item makes the player recalculate, as items.xml names them in "cache". enum CacheFlag : uint32_t { CACHE_DAMAGE = 0x1, CACHE_FIREDELAY = 0x2, CACHE_SHOTSPEED = 0x4, CACHE_RANGE = 0x8, CACHE_SPEED = 0x10, CACHE_TEARFLAG = 0x20, CACHE_TEARCOLOR = 0x40, CACHE_FLYING = 0x80, CACHE_WEAPON = 0x100, CACHE_FAMILIARS = 0x200, CACHE_LUCK = 0x400, CACHE_SIZE = 0x800, CACHE_COLOR = 0x1000, CACHE_PICKUP_VISION = 0x2000, CACHE_ALL = 0xffff }; // An item's tags, as items.xml names them in "tags". enum ItemTag : uint64_t { TAG_DEAD = 1ull << 0, TAG_SYRINGE = 1ull << 1, TAG_MOM = 1ull << 2, TAG_TECH = 1ull << 3, TAG_BATTERY = 1ull << 4, TAG_GUPPY = 1ull << 5, TAG_FLY = 1ull << 6, TAG_BOB = 1ull << 7, TAG_MUSHROOM = 1ull << 8, TAG_BABY = 1ull << 9, TAG_ANGEL = 1ull << 10, TAG_DEVIL = 1ull << 11, TAG_POOP = 1ull << 12, TAG_BOOK = 1ull << 13, TAG_SPIDER = 1ull << 14, TAG_QUEST = 1ull << 15, TAG_MONSTER_MANUAL = 1ull << 16, TAG_NO_GREED = 1ull << 17, TAG_FOOD = 1ull << 18, TAG_TEARS_UP = 1ull << 19, TAG_OFFENSIVE = 1ull << 20, TAG_NO_KEEPER = 1ull << 21, TAG_NO_LOST_BR = 1ull << 22, TAG_STARS = 1ull << 23, TAG_SUMMONABLE = 1ull << 24, TAG_NO_CANTRIP = 1ull << 25, TAG_WISP = 1ull << 26, TAG_UNIQUE_FAMILIAR = 1ull << 27, TAG_NO_CHALLENGE = 1ull << 28, TAG_NO_DAILY = 1ull << 29, TAG_LAZ_SHARED = 1ull << 30, TAG_LAZ_SHARED_GLOBAL = 1ull << 31, TAG_NO_EDEN = 1ull << 32, TAG_DEVIL_SACRIFICE = 1ull << 33 }; // The checks ItemConfig_Item::IsAvailableEx runs, combined. enum AvailabilityCheck : uint32_t { AVAILABLE_RUN_RULES = 0x1, AVAILABLE_UNLOCKED = 0x2, AVAILABLE_CHARACTERS = 0x4, AVAILABLE_FILTERS = 0x8, AVAILABLE_ALL = 0xffffffff }; // Whether ItemConfig_Item::IsAvailable also asks for the item's achievement. enum UnlockCheck { UNLOCK_CHECKED, UNLOCK_IGNORED }; // How an active item spends its charge: by charges, as a whole bar (timed charges, and special charges of more than // 12), or while held (Spin to Win, Breath of Life). enum ActiveDischarge : int { DISCHARGE_CHARGES, DISCHARGE_BAR, DISCHARGE_HELD }; // What kind of card pocketitems.xml makes, as its "type" names it. enum CardType : int { CARD_TAROT, CARD_SUIT, CARD_RUNE, CARD_SPECIAL, CARD_OBJECT, CARD_TAROT_REVERSE }; // Whether a pill effect is the good (+) or bad (-) side of its class, as pocketitems.xml writes "class". enum PillClassModifier : uint8_t { PILL_CLASS_NEUTRAL, PILL_CLASS_POSITIVE, PILL_CLASS_NEGATIVE }; // Whether LoadBombConfigRules drops the rules loaded before. enum BombRulesLoad { BOMB_RULES_REPLACE, BOMB_RULES_APPEND }; using TearFlags = std::bitset<128>; using ColorPresets = std::map>; struct ItemConfig_Item; struct ModEntry; // A costume an item, form or null item puts on the player: its .anm2 and how it draws over the others. // Assignment (00728710) is the default. struct ItemConfig_Costume { std::string anm2Path; int id = -1; int priority = 0; int skinColor = -1; bool isFlying = false; bool isForceBodyColor = false; bool isForceHeadColor = false; bool isHasOverlay = false; bool isHasSkinAlt = false; bool isOverwriteColor = false; }; // One of a locust's effects: when it procs, the tear flags it hits with, and how it looks shooting. // A locust's first effect procs always, every further one a quarter of the time. // Construction (00722740), moves (00731c30) and destruction (00722c90) are the defaults. struct LocustEffect { TearFlags tearFlags; std::string shootBackGfx; std::string shootGfx; std::string shootOverlayGfx; float damageMultiplier = 1; float procChance = 0.25f; uint32_t locustFlags = 0; uint32_t mutexFlags = 0; }; constexpr float LOCUST_FIRST_PROC_CHANCE = 1; // How the Abyss spawns locusts for a collectible: their effects, the locust's own first, sprite overrides and movement. // gfx and color are anm2 overrides joined with '&' (spritesheet=0-x.png, 0-fly_red), resolved at spawn. // Moves (00731870), destruction (0072c8f0) and the list's (00731160, 00731b90, 007311e0, 00731d10) are the defaults. struct LocustConfig { std::vector effects; std::string color; std::string gfx; float scale = 1; float speed = 1; int collisionInterval = 7; int count = 1; LocustConfig() : effects(1) { effects[0].procChance = LOCUST_FIRST_PROC_CHANCE; } }; // The tears a wisp shoots: their look, flags and damage. struct WispTears { ColorMod color = COLOR_DEFAULT; TearFlags flags; float damageMultiplier = 1; float scale = 0.7f; int variant = 0; }; // The second kind of tear a wisp may shoot, each part taken from the first unless wisps.xml sets it. constexpr WispTears WISP_TEARS_UNSET = {{{1, 1, 1, -1}, {0, 0, 0, 0}, {0, 0, 0}}, {}, -1, -1, -1}; constexpr ColorMod WISP_COLOR_UNSET = {{1, 1, 1, -1}, {0, 0, 0, 0}, {0, 0, 0}}; // A Book of Virtues wisp a collectible spawns, as wisps.xml describes it: its stats, tears and looks. // Blood and poof colors keep an alpha of -1 when unset, for the spawning code to fall back on its own. // Construction (007227d0) is the default. struct WispEntry { ColorMod bloodColor = WISP_COLOR_UNSET; ColorMod coreColor = COLOR_DEFAULT; ColorMod flameColor = COLOR_DEFAULT; ColorMod poofColor = WISP_COLOR_UNSET; WispTears tears; WispTears tears2 = WISP_TEARS_UNSET; std::string coreGfx; std::string flameGfx; float damage = 3; float fireDelay = 30; float hp = 2; float procChance = 0.1f; float shotSpeed = 1; float stageDamage = 0.1f; short count = 1; short layer = 1; short priority = 0; bool isCanShoot = true; }; // A transformation, as playerforms.xml lists it: the tags that count towards it and what it gives. struct ItemConfig_PlayerForm { std::string name; uint64_t tags = 0; uint32_t cacheFlags = 0; int costume = -1; int id = 0; }; // One way bombcostumes.xml dresses a bomb variant: the tear flags it needs and lacks, and the sprites it swaps in. // Copies (007312c0) and the list's (00730e30, 00731b00, 0072fc90) are the defaults. struct BombCostumeRule { TearFlags excludeFlags; TearFlags includeFlags; std::string back; std::string body; std::string body2; std::string front; std::string front2; std::string overlay; std::string suffix; std::string suffix2; }; // What Bag of Crafting makes from a recipe's pickups, and the pool it rolls from. struct CraftingRecipe { int output = 0; int pool = 0; }; // A collectible, trinket or null item, as items.xml, costumes2.xml and items_metadata.xml describe it. // Rebirth's Lua Item binds this class. // Construction (00722a80) and destruction (00722c10) are the defaults. Item::Costume (0085dbc0) is costume. struct ItemConfig_Item { ItemConfig_Costume costume; std::vector locusts; std::unique_ptr wispConfig; std::string desc; std::string gfxFilename; std::string name; ModEntry* modEntry = nullptr; uint64_t tags = 0; uint32_t cacheFlags = 0; ChargeType chargeType = CHARGE_NORMAL; ItemType type = ITEM_NULL; int achievementId = 0; int addBlackHearts = 0; int addBombs = 0; int addCoins = 0; int addHearts = 0; int addKeys = 0; int addMaxHearts = 0; int addSoulHearts = 0; int craftingQuality = 0; int id = 0; int initCharge = -1; int maxCharges = 0; int maxCooldown = 0; int modItemId = -1; int quality = 0; short devilPrice = 1; short shopPrice = 15; bool isAddCostumeOnPickup = true; bool isClearEffectsOnRemove = true; bool isHidden = false; bool isPassiveCache = false; bool isPersistentEffect = false; bool isSpecial = false; std::string GetLocalizedName(int language = LANGUAGE_CURRENT); std::string description_get(); bool IsAvailable(UnlockCheck check); bool IsAvailableEx(uint32_t checks); bool IsCollectible(); bool IsNull(); bool IsTrinket(); bool HasTags(uint64_t mask); ActiveDischarge discharge_get(); bool is_mom_item(); }; // What cards and pill effects share, as pocketitems.xml describes them: their names, unlock and announcer. struct PocketItemConfig { std::string desc; std::string name; ModEntry* modEntry = nullptr; int achievementId = -1; int announcerDelay = 0; int announcerVoice = 0; int id = 0; int mimicCharge = 4; bool isGreedModeAllowed = true; std::string GetName(int language = LANGUAGE_CURRENT); }; // A card or rune. Rebirth's Lua Card binds this class. struct ItemConfig_Card : PocketItemConfig { std::string hudAnim; ANM2* moddedCardFront = nullptr; CardType cardType = CARD_SPECIAL; int pickupSubtype = 2; std::string description_get(); bool IsAvailable(); bool IsCard(); bool IsRune(); }; // A pill effect. Rebirth's Lua PillEffect binds this class. struct ItemConfig_Pill : PocketItemConfig { int announcerVoiceSuper = 0; uint8_t effectClass = 0; PillClassModifier effectSubClass = PILL_CLASS_NEUTRAL; bool IsAvailable(); }; // Every item, card, pill effect, transformation, wisp, locust, bomb costume and crafting recipe the game and its mods // define, loaded from their XML (converted to JSON) and looked up by id. Rebirth's Lua Config binds this class: its // list getters (0041e460, 00424530, 00685d30, 00685d40) are the members. // Destruction (00725190) is the default, as is the slot resizing Init and Unload inline (00730f90, 00731000, 00731070). struct ItemConfig { std::array>, TAG_CACHE_SLOTS> taggedItems; std::array locustQualityScales{}; std::vector> collectibles; std::vector> nullItems; std::vector> trinkets; std::vector> cards; std::vector> pillEffects; std::vector> playerForms; std::vector> extraWispConfigs; std::vector availabilityFilters; std::map> bombCostumes; std::map recipes; std::map> collectibleNameMap; ColorPresets locustColors; std::string locustGfxRoot; ItemConfig(); void Init(); void Unload(); bool Load(std::string_view path, ModEntry* mod); bool LoadCostumes(std::string_view path, ModEntry* mod); bool LoadMetadata(std::string_view path, ModEntry* mod); bool LoadPocketItems(std::string_view path, ModEntry* mod); bool LoadWispConfig(std::string_view path, ModEntry* mod); void LoadLocustConfig(std::string_view path, ModEntry* mod); bool LoadCraftingRecipes(std::string_view path, ModEntry* mod); bool LoadBombConfigRules(std::string_view path, BombRulesLoad mode); bool player_forms_load(std::string_view path); ItemConfig_Item* GetCollectible(int id); ItemConfig_Item* GetTrinket(uint32_t trinketType); ItemConfig_Item* GetNullItem(int id); ItemConfig_Card* GetCard(int id); ItemConfig_Pill* GetPillEffect(int id); std::vector& GetTaggedItems(uint64_t tags); static bool IsQuestItem(int id); static bool IsValidCollectible(int id); static bool ShouldAddCostumeOnPickup(ItemConfig_Item* item); static bool is_collectible_tagged(int id, uint64_t tags); static bool is_held_active(int id); static bool is_trinket_tagged(uint32_t trinketType, uint64_t tags); static WispEntry* wisp_config_get(int id); static LocustConfig* locust_config_get(int id, int index); }; uint32_t cache_flags_parse(std::string_view text); uint64_t tags_parse(std::string_view text); ColorMod color_preset_find(ColorPresets& presets, std::string_view text);