From 8c95737332bba76bb07e5cd076b112c209159f9e Mon Sep 17 00:00:00 2001 From: shweet Date: Tue, 24 Nov 2026 15:17:22 -0500 Subject: [PATCH] REPENTOGON phases 3 and 4: XML extensions for players, items, pools, pocket items, achievements, challenges, cutscenes, giantbook, backdrops, boss colours and entities through the format-neutral data API; REPENTOGON's ImGui Lua API and console extensions on the overlay; behaviour patches behind REPENTOGON's options and the parity switch; save-state management and mod reloading; 72 goldens identical from converted resources and the install --- analysis/repentogon_coverage.tsv | 568 ++++++++++----------- analysis/repentogon_overrides.tsv | 197 ++++++++ assets/repentogon/scripts/main_ex.lua | 8 +- generated-src/classes.h | 13 + src/engine/anm2.cpp | 15 +- src/entity/boss/delirium.cpp | 16 +- src/entity/boss/hornfel.cpp | 18 + src/entity/boss/intro.cpp | 4 + src/entity/boss/pool.cpp | 101 +++- src/entity/boss/pool.h | 4 + src/entity/config.cpp | 192 +++++++- src/entity/config.h | 28 +- src/entity/effect/boss.cpp | 18 +- src/entity/effect/items.cpp | 7 + src/entity/effect/vortex.cpp | 9 +- src/entity/entity.cpp | 13 +- src/entity/factory.cpp | 11 +- src/entity/familiar/babies.cpp | 9 + src/entity/familiar/familiar.cpp | 17 +- src/entity/familiar/follow.cpp | 4 + src/entity/familiar/gello.cpp | 17 +- src/entity/familiar/shoot.cpp | 4 + src/entity/familiar/wisp_kinds.cpp | 6 + src/entity/npc/deep_gaper.cpp | 10 +- src/entity/npc/fireplace.cpp | 20 +- src/entity/npc/npc.cpp | 3 +- src/entity/npc/npc.h | 2 + src/entity/pickup/chest.cpp | 4 + src/entity/pickup/item_config.cpp | 25 + src/entity/pickup/item_config.h | 6 +- src/entity/pickup/item_overlay.cpp | 17 +- src/entity/pickup/item_pool.cpp | 31 +- src/entity/pickup/pickup.cpp | 9 +- src/entity/player/actives.cpp | 22 +- src/entity/player/bombs.cpp | 6 +- src/entity/player/characters.cpp | 3 + src/entity/player/damage.cpp | 11 + src/entity/player/death.cpp | 7 + src/entity/player/effects.cpp | 3 + src/entity/player/evaluate.cpp | 34 +- src/entity/player/frame.cpp | 11 +- src/entity/player/health.cpp | 25 +- src/entity/player/hud.cpp | 10 +- src/entity/player/items.cpp | 11 + src/entity/player/manager.cpp | 3 + src/entity/player/mist.cpp | 12 +- src/entity/player/player.cpp | 8 + src/entity/player/player.h | 11 + src/entity/player/tears.cpp | 9 +- src/entity/player/trinkets.cpp | 3 + src/entity/player/weapons.cpp | 4 + src/entity/save_state.h | 4 + src/entity/status.cpp | 10 +- src/entity/weapon/knife.cpp | 8 + src/entity/weapon/knife_hits.cpp | 40 +- src/entity/weapon/laser.cpp | 12 + src/entity/weapon/laser_hits.cpp | 33 +- src/entity/weapon/projectile.cpp | 10 +- src/entity/weapon/tear.cpp | 3 + src/entity/weapon/tear_death.cpp | 13 + src/entity/weapon/tear_flags.cpp | 20 +- src/entity/weapon/weapon.cpp | 10 + src/game/end.cpp | 5 + src/game/game.cpp | 58 ++- src/game/main.cpp | 11 +- src/game/manager.cpp | 48 +- src/game/mod_manager.cpp | 61 ++- src/game/mod_manager.h | 6 + src/game/options_config.cpp | 9 +- src/game/persistent_game_data.cpp | 8 + src/game/restore.cpp | 10 +- src/game/save.cpp | 4 +- src/game/state.cpp | 63 ++- src/game/state_player.h | 3 + src/game/string_table.cpp | 9 +- src/level/ambush.cpp | 12 +- src/level/backdrop.cpp | 11 + src/level/camera.cpp | 16 +- src/level/generator.cpp | 17 +- src/level/grid/grid_entity.cpp | 11 +- src/level/grid/rock.cpp | 4 + src/level/grid/wall.cpp | 21 +- src/level/level.cpp | 14 +- src/level/minimap.cpp | 10 +- src/level/red_room.cpp | 19 +- src/level/room.cpp | 40 +- src/level/room_config.cpp | 11 + src/level/room_config.h | 2 +- src/level/room_grid.cpp | 13 +- src/level/room_special.cpp | 19 +- src/level/room_state.cpp | 16 +- src/level/room_update.cpp | 7 + src/lua/callbacks.cpp | 16 + src/repentogon/achievements.cpp | 303 ++++++++++++ src/repentogon/achievements.h | 26 + src/repentogon/api_console.cpp | 94 +++- src/repentogon/api_game.h | 32 ++ src/repentogon/api_imgui.cpp | 660 +++++++++++++++++++++++++ src/repentogon/api_misc.cpp | 101 ++++ src/repentogon/api_npc.cpp | 101 +++- src/repentogon/api_room.cpp | 18 +- src/repentogon/api_saves.cpp | 7 +- src/repentogon/api_weapons.cpp | 4 +- src/repentogon/console.cpp | 114 +++++ src/repentogon/console.h | 15 + src/repentogon/custom_cache.cpp | 190 ++++++++ src/repentogon/custom_cache.h | 41 ++ src/repentogon/custom_imgui.cpp | 149 ++++++ src/repentogon/custom_imgui.h | 194 ++++++++ src/repentogon/entities.cpp | 96 +++- src/repentogon/entities.h | 27 + src/repentogon/item_spoof.cpp | 608 +++++++++++++++++++++++ src/repentogon/item_spoof.h | 59 +++ src/repentogon/items.cpp | 142 +++++- src/repentogon/items.h | 20 +- src/repentogon/json_save.cpp | 66 +++ src/repentogon/json_save.h | 15 + src/repentogon/level.cpp | 59 +++ src/repentogon/level.h | 18 + src/repentogon/menus.cpp | 23 +- src/repentogon/menus.h | 3 + src/repentogon/mod_curses.cpp | 64 +++ src/repentogon/mod_curses.h | 12 + src/repentogon/npc.cpp | 12 + src/repentogon/npc.h | 6 +- src/repentogon/options.h | 8 +- src/repentogon/player.cpp | 86 ++++ src/repentogon/player.h | 18 + src/repentogon/player_api.cpp | 37 +- src/repentogon/player_config.cpp | 442 +++++++++++++++++ src/repentogon/player_config.h | 71 +++ src/repentogon/repentogon.cpp | 15 +- src/repentogon/save_state_id.h | 45 ++ src/repentogon/save_state_manager.cpp | 406 +++++++++++++++ src/repentogon/save_state_manager.h | 32 ++ src/repentogon/saves.cpp | 33 +- src/repentogon/saves.h | 1 + src/repentogon/stats.cpp | 178 ++++++- src/repentogon/stats.h | 25 + src/repentogon/ui_patches.cpp | 248 ++++++++++ src/repentogon/ui_patches.h | 33 ++ src/repentogon/vanilla_fixes.cpp | 132 +++++ src/repentogon/vanilla_fixes.h | 22 + src/repentogon/weapons.cpp | 36 ++ src/repentogon/weapons.h | 27 + src/repentogon/xml.cpp | 367 ++++++++++++++ src/repentogon/xml.h | 42 ++ src/ui/console.cpp | 7 + src/ui/console_commands.cpp | 15 +- src/ui/cutscene.cpp | 101 ++-- src/ui/cutscene.h | 7 +- src/ui/hud.cpp | 14 +- src/ui/menu/character.cpp | 19 +- src/ui/menu/daily_challenge.cpp | 14 +- src/ui/menu/manager.cpp | 15 +- src/ui/menu/save.cpp | 6 +- src/ui/menu/title.cpp | 6 + src/ui/nightmare_scene.cpp | 4 + src/ui/overlay/console.cpp | 42 +- src/ui/overlay/custom_imgui.cpp | 678 ++++++++++++++++++++++++++ src/ui/overlay/overlay.cpp | 34 +- src/ui/overlay/overlay.h | 4 + src/ui/pause_screen.cpp | 5 + src/ui/popups.cpp | 7 + src/ui/stat_hud.cpp | 32 +- 165 files changed, 8289 insertions(+), 620 deletions(-) create mode 100644 src/repentogon/achievements.cpp create mode 100644 src/repentogon/achievements.h create mode 100644 src/repentogon/api_imgui.cpp create mode 100644 src/repentogon/console.cpp create mode 100644 src/repentogon/console.h create mode 100644 src/repentogon/custom_cache.cpp create mode 100644 src/repentogon/custom_cache.h create mode 100644 src/repentogon/custom_imgui.cpp create mode 100644 src/repentogon/custom_imgui.h create mode 100644 src/repentogon/item_spoof.cpp create mode 100644 src/repentogon/item_spoof.h create mode 100644 src/repentogon/json_save.cpp create mode 100644 src/repentogon/json_save.h create mode 100644 src/repentogon/mod_curses.cpp create mode 100644 src/repentogon/mod_curses.h create mode 100644 src/repentogon/player_config.cpp create mode 100644 src/repentogon/player_config.h create mode 100644 src/repentogon/save_state_id.h create mode 100644 src/repentogon/save_state_manager.cpp create mode 100644 src/repentogon/save_state_manager.h create mode 100644 src/repentogon/ui_patches.cpp create mode 100644 src/repentogon/ui_patches.h create mode 100644 src/repentogon/vanilla_fixes.cpp create mode 100644 src/repentogon/vanilla_fixes.h create mode 100644 src/repentogon/xml.cpp create mode 100644 src/repentogon/xml.h create mode 100644 src/ui/overlay/custom_imgui.cpp diff --git a/analysis/repentogon_coverage.tsv b/analysis/repentogon_coverage.tsv index 608f564..5b6ca4c 100644 --- a/analysis/repentogon_coverage.tsv +++ b/analysis/repentogon_coverage.tsv @@ -637,8 +637,8 @@ function EntityPlayer AddCandyHeartBonus repentogon/LuaInterfaces/Entities/LuaEn function EntityPlayer AddCollectible repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3554 player done function EntityPlayer AddCollectibleEffect repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3776 EntityPlayer.md player done function EntityPlayer AddCustomCacheTag repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3796 EntityPlayer.md player todo -function EntityPlayer AddInnateCollectible repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3651 EntityPlayer.md player todo -function EntityPlayer AddInnateTrinket repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3657 EntityPlayer.md player todo +function EntityPlayer AddInnateCollectible repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3651 EntityPlayer.md player done +function EntityPlayer AddInnateTrinket repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3657 EntityPlayer.md player done function EntityPlayer AddLeprosy repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3715 EntityPlayer.md player done function EntityPlayer AddLocust repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3629 EntityPlayer.md player done function EntityPlayer AddNullCostume repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3794 player done @@ -647,8 +647,8 @@ function EntityPlayer AddSmeltedTrinket repentogon/LuaInterfaces/Entities/LuaEnt function EntityPlayer AddSoulLocketBonus repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3824 EntityPlayer.md player done function EntityPlayer AddTrinketEffect repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3784 EntityPlayer.md player done function EntityPlayer AddUrnSouls repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3717 EntityPlayer.md player done -function EntityPlayer BlockCollectible repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3778 EntityPlayer.md player todo -function EntityPlayer BlockTrinket repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3781 EntityPlayer.md player todo +function EntityPlayer BlockCollectible repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3778 EntityPlayer.md player done +function EntityPlayer BlockTrinket repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3781 EntityPlayer.md player done function EntityPlayer CalculateBagOfCraftingOutput repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3878 EntityPlayer.md player done function EntityPlayer CanAddCollectibleToInventory repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3718 EntityPlayer.md player done function EntityPlayer CanCrushRocks repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3719 EntityPlayer.md player done @@ -657,7 +657,7 @@ function EntityPlayer CanUsePill repentogon/LuaInterfaces/Entities/LuaEntityPlay function EntityPlayer CheckFamiliarEx repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3708 EntityPlayer.md player done function EntityPlayer ClearCollectibleAnim repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3706 EntityPlayer.md player done function EntityPlayer ClearDeadEyeCharge repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3677 EntityPlayer.md player done -function EntityPlayer ClearInnateItemGroup repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3663 EntityPlayer.md player todo +function EntityPlayer ClearInnateItemGroup repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3663 EntityPlayer.md player done function EntityPlayer ClearItemAnimCollectible repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3707 player done function EntityPlayer ClearQueueItem repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3772 EntityPlayer.md player done function EntityPlayer CreateAfterimage repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3834 EntityPlayer.md player done @@ -732,13 +732,13 @@ function EntityPlayer GetHeadDirectionLockTime repentogon/LuaInterfaces/Entities function EntityPlayer GetHealthType repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3561 EntityPlayer.md player done function EntityPlayer GetHeldEntity repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3684 EntityPlayer.md player done function EntityPlayer GetHeldSprite repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3682 EntityPlayer.md player done -function EntityPlayer GetHistory repentogon/LuaInterfaces/LuaHistory.cpp:89 EntityPlayer.md player todo +function EntityPlayer GetHistory repentogon/LuaInterfaces/LuaHistory.cpp:89 EntityPlayer.md player done function EntityPlayer GetImExcitedSpeedupCountdown repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3859 EntityPlayer.md player done function EntityPlayer GetImmaculateConceptionState repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3665 EntityPlayer.md player done -function EntityPlayer GetInnateCollectibleCount repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3653 EntityPlayer.md player todo -function EntityPlayer GetInnateCollectibleGroup repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3655 EntityPlayer.md player todo -function EntityPlayer GetInnateTrinketCount repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3659 EntityPlayer.md player todo -function EntityPlayer GetInnateTrinketGroup repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3661 EntityPlayer.md player todo +function EntityPlayer GetInnateCollectibleCount repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3653 EntityPlayer.md player done +function EntityPlayer GetInnateCollectibleGroup repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3655 EntityPlayer.md player done +function EntityPlayer GetInnateTrinketCount repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3659 EntityPlayer.md player done +function EntityPlayer GetInnateTrinketGroup repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3661 EntityPlayer.md player done function EntityPlayer GetInventoryCollectible repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3868 EntityPlayer.md player done function EntityPlayer GetInventoryHistoryIndex repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3867 EntityPlayer.md player done function EntityPlayer GetItemStateCooldown repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3857 EntityPlayer.md player done @@ -760,7 +760,7 @@ function EntityPlayer GetMegaBlastDuration repentogon/LuaInterfaces/Entities/Lua function EntityPlayer GetMetronomeCollectibleID repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3623 EntityPlayer.md player done function EntityPlayer GetMontezumaRevengeCharge repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3851 EntityPlayer.md player done function EntityPlayer GetMovingBoxContents repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3596 EntityPlayer.md player done -function EntityPlayer GetMultiShotParams repentogon/LuaInterfaces/LuaMultiShotParams.cpp:211 EntityPlayer.md player review +function EntityPlayer GetMultiShotParams repentogon/LuaInterfaces/LuaMultiShotParams.cpp:211 EntityPlayer.md player done function EntityPlayer GetMultiShotPositionVelocity repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3555 EntityPlayer.md player review function EntityPlayer GetNextUrethraBlockFrame repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3680 EntityPlayer.md player done function EntityPlayer GetPeeBurstCooldown repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3621 EntityPlayer.md player done @@ -768,7 +768,7 @@ function EntityPlayer GetPlanCKillCountdown repentogon/LuaInterfaces/Entities/Lu function EntityPlayer GetPlayerFormCounter repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3711 EntityPlayer.md player done function EntityPlayer GetPlayerHUD repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3825 EntityPlayer.md player done function EntityPlayer GetPlayerIndex repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3785 EntityPlayer.md player done -function EntityPlayer GetPocketItem repentogon/LuaInterfaces/LuaPocketItem.cpp:27 EntityPlayer.md player review +function EntityPlayer GetPocketItem repentogon/LuaInterfaces/LuaPocketItem.cpp:27 EntityPlayer.md player done function EntityPlayer GetPonyCharge repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3630 EntityPlayer.md player done function EntityPlayer GetPotatoPeelerUses repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3847 EntityPlayer.md player done function EntityPlayer GetPurityState repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3647 EntityPlayer.md player done @@ -787,7 +787,7 @@ function EntityPlayer GetSmeltedTrinkets repentogon/LuaInterfaces/Entities/LuaEn function EntityPlayer GetSoulLocketBonus repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3823 EntityPlayer.md player done function EntityPlayer GetSpecialGridCollision repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3737 EntityPlayer.md player done function EntityPlayer GetSpeedModifier repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3597 EntityPlayer.md player done -function EntityPlayer GetSpoofedCollectiblesList repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3786 EntityPlayer.md player todo +function EntityPlayer GetSpoofedCollectiblesList repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3786 EntityPlayer.md player done function EntityPlayer GetStatMultiplier repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3799 EntityPlayer.md player todo function EntityPlayer GetSuplexAimCountdown repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3828 EntityPlayer.md player done function EntityPlayer GetSuplexLandPosition repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3832 EntityPlayer.md player done @@ -818,7 +818,7 @@ function EntityPlayer IncrementPlayerFormCounter repentogon/LuaInterfaces/Entiti function EntityPlayer InitPostLevelInitStats repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3557 EntityPlayer.md player done function EntityPlayer InitTwin repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3556 EntityPlayer.md player done function EntityPlayer IsCollectibleAnimFinished repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3705 EntityPlayer.md player done -function EntityPlayer IsCollectibleBlocked repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3780 EntityPlayer.md player todo +function EntityPlayer IsCollectibleBlocked repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3780 EntityPlayer.md player done function EntityPlayer IsCollectibleCostumeVisible repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3702 EntityPlayer.md player done function EntityPlayer IsEntityValidTarget repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3740 EntityPlayer.md player done function EntityPlayer IsFootstepFrame repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3741 EntityPlayer.md player done @@ -830,7 +830,7 @@ function EntityPlayer IsLocalPlayer repentogon/LuaInterfaces/Entities/LuaEntityP function EntityPlayer IsNullItemCostumeVisible repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3703 EntityPlayer.md player done function EntityPlayer IsPacifist repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3745 player done function EntityPlayer IsPostLevelInitFinished repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3840 EntityPlayer.md player done -function EntityPlayer IsTrinketBlocked repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3783 EntityPlayer.md player todo +function EntityPlayer IsTrinketBlocked repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3783 EntityPlayer.md player done function EntityPlayer IsUrethraBlocked repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3678 EntityPlayer.md player done function EntityPlayer MorphToCoopGhost repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3746 EntityPlayer.md player done function EntityPlayer NeedsCharge repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3570 player done @@ -838,8 +838,8 @@ function EntityPlayer PlayCollectibleAnim repentogon/LuaInterfaces/Entities/LuaE function EntityPlayer PlayDelayedSFX repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3695 EntityPlayer.md player done function EntityPlayer PlayItemNullAnimation repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3854 EntityPlayer.md player todo function EntityPlayer RemoveCollectibleByHistoryIndex repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3582 EntityPlayer.md player done -function EntityPlayer RemoveInnateCollectible repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3652 EntityPlayer.md player todo -function EntityPlayer RemoveInnateTrinket repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3658 EntityPlayer.md player todo +function EntityPlayer RemoveInnateCollectible repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3652 EntityPlayer.md player done +function EntityPlayer RemoveInnateTrinket repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3658 EntityPlayer.md player done function EntityPlayer RemovePocketItem repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3747 EntityPlayer.md player done function EntityPlayer RemovePoopSpell repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3687 EntityPlayer.md player done function EntityPlayer RerollAllCollectibles repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3748 EntityPlayer.md player done @@ -885,10 +885,10 @@ function EntityPlayer SetHeadDirection repentogon/LuaInterfaces/Entities/LuaEnti function EntityPlayer SetHeadDirectionLockTime repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3774 EntityPlayer.md player done function EntityPlayer SetImExcitedSpeedupCountdown repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3860 EntityPlayer.md player done function EntityPlayer SetImmaculateConceptionState repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3666 EntityPlayer.md player done -function EntityPlayer SetInnateCollectibleCount repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3654 EntityPlayer.md player todo -function EntityPlayer SetInnateCollectibleGroup repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3656 EntityPlayer.md player todo -function EntityPlayer SetInnateTrinketCount repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3660 EntityPlayer.md player todo -function EntityPlayer SetInnateTrinketGroup repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3662 EntityPlayer.md player todo +function EntityPlayer SetInnateCollectibleCount repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3654 EntityPlayer.md player done +function EntityPlayer SetInnateCollectibleGroup repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3656 EntityPlayer.md player done +function EntityPlayer SetInnateTrinketCount repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3660 EntityPlayer.md player done +function EntityPlayer SetInnateTrinketGroup repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3662 EntityPlayer.md player done function EntityPlayer SetItemState repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3558 EntityPlayer.md player done function EntityPlayer SetItemStateCooldown repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3858 EntityPlayer.md player done function EntityPlayer SetKeepersSackBonus repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3765 EntityPlayer.md player done @@ -926,7 +926,7 @@ function EntityPlayer SetTearDisplacement repentogon/LuaInterfaces/Entities/LuaE function EntityPlayer SetTearPoisonDamage repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3649 EntityPlayer.md player done function EntityPlayer SetTearRangeModifier repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3603 EntityPlayer.md player done function EntityPlayer SetUrethraBlock repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3679 EntityPlayer.md player done -function EntityPlayer SetWeapon repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3628 EntityPlayer.md player todo +function EntityPlayer SetWeapon repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3628 EntityPlayer.md player done function EntityPlayer ShootBlueCandle repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3753 EntityPlayer.md player done function EntityPlayer ShootRedCandle repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3560 EntityPlayer.md player done function EntityPlayer ShuffleCostumes repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3646 EntityPlayer.md player done @@ -943,8 +943,8 @@ function EntityPlayer TryFakeDeath repentogon/LuaInterfaces/Entities/LuaEntityPl function EntityPlayer TryForgottenThrow repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3759 EntityPlayer.md player done function EntityPlayer TryPreventDeath repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3579 EntityPlayer.md player done function EntityPlayer TryRemoveSmeltedTrinket repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3760 EntityPlayer.md player done -function EntityPlayer UnblockCollectible repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3779 EntityPlayer.md player todo -function EntityPlayer UnblockTrinket repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3782 EntityPlayer.md player todo +function EntityPlayer UnblockCollectible repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3779 EntityPlayer.md player done +function EntityPlayer UnblockTrinket repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3782 EntityPlayer.md player done function EntityPlayer UpdateIsaacPregnancy repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3669 EntityPlayer.md player done function EntityPlayer UseActiveItem repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3841 EntityPlayer.md player done function EntityPlayer VoidHasCollectible repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3762 EntityPlayer.md player done @@ -988,10 +988,10 @@ function EntitySaveState SetSubType repentogon/LuaInterfaces/LuaEntitySaveState. function EntitySaveState SetType repentogon/LuaInterfaces/LuaEntitySaveState.cpp:372 EntitiesSaveState.md entities done function EntitySaveState SetU1 repentogon/LuaInterfaces/LuaEntitySaveState.cpp:410 EntitiesSaveState.md entities done function EntitySaveState SetVariant repentogon/LuaInterfaces/LuaEntitySaveState.cpp:374 EntitiesSaveState.md entities done -function EntitySaveStateManagement DeleteData repentogon/SaveStateManagement/EntitySaveStateManagement.cpp:3479 misc todo -function EntitySaveStateManagement GetEntitySaveStateId repentogon/SaveStateManagement/EntitySaveStateManagement.cpp:3476 persistent data and saves todo -function EntitySaveStateManagement LoadData repentogon/SaveStateManagement/EntitySaveStateManagement.cpp:3478 misc todo -function EntitySaveStateManagement SaveData repentogon/SaveStateManagement/EntitySaveStateManagement.cpp:3477 persistent data and saves todo +function EntitySaveStateManagement DeleteData repentogon/SaveStateManagement/EntitySaveStateManagement.cpp:3479 misc done +function EntitySaveStateManagement GetEntitySaveStateId repentogon/SaveStateManagement/EntitySaveStateManagement.cpp:3476 persistent data and saves done +function EntitySaveStateManagement LoadData repentogon/SaveStateManagement/EntitySaveStateManagement.cpp:3478 misc done +function EntitySaveStateManagement SaveData repentogon/SaveStateManagement/EntitySaveStateManagement.cpp:3477 persistent data and saves done function EntitySaveStateManager GetEntityData repentogon/resources/scripts/main_ex.lua:2344 EntitySaveStateManager.md entities done defined in Lua function EntitySaveStateManager GetEntitySaveStateData repentogon/resources/scripts/main_ex.lua:2345 EntitySaveStateManager.md entities done defined in Lua function EntitySaveStateManager TryGetEntityData repentogon/resources/scripts/main_ex.lua:2346 EntitySaveStateManager.md entities done defined in Lua @@ -1182,63 +1182,63 @@ function HistoryItem GetRoomType repentogon/LuaInterfaces/LuaHistoryItem.cpp:67 function HistoryItem GetStageType repentogon/LuaInterfaces/LuaHistoryItem.cpp:66 HistoryItem.md player done function HistoryItem GetTime repentogon/LuaInterfaces/LuaHistoryItem.cpp:63 HistoryItem.md player done function HistoryItem IsTrinket repentogon/LuaInterfaces/LuaHistoryItem.cpp:69 HistoryItem.md player done -function ImGui AddButton repentogon/ImGuiFeatures/LuaImGui.cpp:1081 ImGui.md console and debug todo -function ImGui AddCallback repentogon/ImGuiFeatures/LuaImGui.cpp:1069 ImGui.md console and debug todo -function ImGui AddCheckbox repentogon/ImGuiFeatures/LuaImGui.cpp:1090 ImGui.md console and debug todo -function ImGui AddCombobox repentogon/ImGuiFeatures/LuaImGui.cpp:1092 ImGui.md console and debug todo -function ImGui AddDragFloat repentogon/ImGuiFeatures/LuaImGui.cpp:1086 ImGui.md console and debug todo -function ImGui AddDragInteger repentogon/ImGuiFeatures/LuaImGui.cpp:1085 ImGui.md console and debug todo -function ImGui AddElement repentogon/ImGuiFeatures/LuaImGui.cpp:1071 ImGui.md console and debug todo -function ImGui AddInputColor repentogon/ImGuiFeatures/LuaImGui.cpp:1089 ImGui.md console and debug todo -function ImGui AddInputController repentogon/ImGuiFeatures/LuaImGui.cpp:1097 ImGui.md console and debug todo -function ImGui AddInputFloat repentogon/ImGuiFeatures/LuaImGui.cpp:1084 ImGui.md console and debug todo -function ImGui AddInputInteger repentogon/ImGuiFeatures/LuaImGui.cpp:1083 ImGui.md console and debug todo -function ImGui AddInputKeyboard repentogon/ImGuiFeatures/LuaImGui.cpp:1098 ImGui.md console and debug todo -function ImGui AddInputText repentogon/ImGuiFeatures/LuaImGui.cpp:1093 ImGui.md console and debug todo -function ImGui AddInputTextMultiline repentogon/ImGuiFeatures/LuaImGui.cpp:1094 ImGui.md console and debug todo -function ImGui AddPlotHistogram repentogon/ImGuiFeatures/LuaImGui.cpp:1100 ImGui.md console and debug todo -function ImGui AddPlotLines repentogon/ImGuiFeatures/LuaImGui.cpp:1099 ImGui.md console and debug todo -function ImGui AddProgressBar repentogon/ImGuiFeatures/LuaImGui.cpp:1101 ImGui.md console and debug todo -function ImGui AddRadioButtons repentogon/ImGuiFeatures/LuaImGui.cpp:1091 ImGui.md console and debug todo -function ImGui AddSliderFloat repentogon/ImGuiFeatures/LuaImGui.cpp:1088 ImGui.md console and debug todo -function ImGui AddSliderInteger repentogon/ImGuiFeatures/LuaImGui.cpp:1087 ImGui.md console and debug todo -function ImGui AddTab repentogon/ImGuiFeatures/LuaImGui.cpp:1096 ImGui.md console and debug todo -function ImGui AddTabBar repentogon/ImGuiFeatures/LuaImGui.cpp:1095 ImGui.md console and debug todo -function ImGui AddText repentogon/ImGuiFeatures/LuaImGui.cpp:1082 ImGui.md console and debug todo -function ImGui CreateMenu repentogon/ImGuiFeatures/LuaImGui.cpp:1073 ImGui.md console and debug todo -function ImGui CreateWindow repentogon/ImGuiFeatures/LuaImGui.cpp:1075 ImGui.md console and debug todo -function ImGui ElementExists repentogon/ImGuiFeatures/LuaImGui.cpp:1078 ImGui.md console and debug todo -function ImGui GetGameWindowRect repentogon/ImGuiFeatures/LuaImGui.cpp:1114 ImGui.md console and debug todo -function ImGui GetMousePosition repentogon/ImGuiFeatures/LuaImGui.cpp:1115 ImGui.md console and debug todo -function ImGui GetVisible repentogon/ImGuiFeatures/LuaImGui.cpp:1116 ImGui.md console and debug todo -function ImGui GetWindowChildFlags repentogon/ImGuiFeatures/LuaImGui.cpp:1119 ImGui.md console and debug todo -function ImGui GetWindowFlags repentogon/ImGuiFeatures/LuaImGui.cpp:1118 ImGui.md console and debug todo -function ImGui GetWindowPinned repentogon/ImGuiFeatures/LuaImGui.cpp:1117 ImGui.md console and debug todo -function ImGui Hide repentogon/ImGuiFeatures/LuaImGui.cpp:1123 ImGui.md console and debug todo +function ImGui AddButton repentogon/ImGuiFeatures/LuaImGui.cpp:1081 ImGui.md console and debug done +function ImGui AddCallback repentogon/ImGuiFeatures/LuaImGui.cpp:1069 ImGui.md console and debug done +function ImGui AddCheckbox repentogon/ImGuiFeatures/LuaImGui.cpp:1090 ImGui.md console and debug done +function ImGui AddCombobox repentogon/ImGuiFeatures/LuaImGui.cpp:1092 ImGui.md console and debug done +function ImGui AddDragFloat repentogon/ImGuiFeatures/LuaImGui.cpp:1086 ImGui.md console and debug done +function ImGui AddDragInteger repentogon/ImGuiFeatures/LuaImGui.cpp:1085 ImGui.md console and debug done +function ImGui AddElement repentogon/ImGuiFeatures/LuaImGui.cpp:1071 ImGui.md console and debug done +function ImGui AddInputColor repentogon/ImGuiFeatures/LuaImGui.cpp:1089 ImGui.md console and debug done +function ImGui AddInputController repentogon/ImGuiFeatures/LuaImGui.cpp:1097 ImGui.md console and debug done +function ImGui AddInputFloat repentogon/ImGuiFeatures/LuaImGui.cpp:1084 ImGui.md console and debug done +function ImGui AddInputInteger repentogon/ImGuiFeatures/LuaImGui.cpp:1083 ImGui.md console and debug done +function ImGui AddInputKeyboard repentogon/ImGuiFeatures/LuaImGui.cpp:1098 ImGui.md console and debug done +function ImGui AddInputText repentogon/ImGuiFeatures/LuaImGui.cpp:1093 ImGui.md console and debug done +function ImGui AddInputTextMultiline repentogon/ImGuiFeatures/LuaImGui.cpp:1094 ImGui.md console and debug done +function ImGui AddPlotHistogram repentogon/ImGuiFeatures/LuaImGui.cpp:1100 ImGui.md console and debug done +function ImGui AddPlotLines repentogon/ImGuiFeatures/LuaImGui.cpp:1099 ImGui.md console and debug done +function ImGui AddProgressBar repentogon/ImGuiFeatures/LuaImGui.cpp:1101 ImGui.md console and debug done +function ImGui AddRadioButtons repentogon/ImGuiFeatures/LuaImGui.cpp:1091 ImGui.md console and debug done +function ImGui AddSliderFloat repentogon/ImGuiFeatures/LuaImGui.cpp:1088 ImGui.md console and debug done +function ImGui AddSliderInteger repentogon/ImGuiFeatures/LuaImGui.cpp:1087 ImGui.md console and debug done +function ImGui AddTab repentogon/ImGuiFeatures/LuaImGui.cpp:1096 ImGui.md console and debug done +function ImGui AddTabBar repentogon/ImGuiFeatures/LuaImGui.cpp:1095 ImGui.md console and debug done +function ImGui AddText repentogon/ImGuiFeatures/LuaImGui.cpp:1082 ImGui.md console and debug done +function ImGui CreateMenu repentogon/ImGuiFeatures/LuaImGui.cpp:1073 ImGui.md console and debug done +function ImGui CreateWindow repentogon/ImGuiFeatures/LuaImGui.cpp:1075 ImGui.md console and debug done +function ImGui ElementExists repentogon/ImGuiFeatures/LuaImGui.cpp:1078 ImGui.md console and debug done +function ImGui GetGameWindowRect repentogon/ImGuiFeatures/LuaImGui.cpp:1114 ImGui.md console and debug done +function ImGui GetMousePosition repentogon/ImGuiFeatures/LuaImGui.cpp:1115 ImGui.md console and debug done +function ImGui GetVisible repentogon/ImGuiFeatures/LuaImGui.cpp:1116 ImGui.md console and debug done +function ImGui GetWindowChildFlags repentogon/ImGuiFeatures/LuaImGui.cpp:1119 ImGui.md console and debug done +function ImGui GetWindowFlags repentogon/ImGuiFeatures/LuaImGui.cpp:1118 ImGui.md console and debug done +function ImGui GetWindowPinned repentogon/ImGuiFeatures/LuaImGui.cpp:1117 ImGui.md console and debug done +function ImGui Hide repentogon/ImGuiFeatures/LuaImGui.cpp:1123 ImGui.md console and debug done function ImGui ImGuiToWorld repentogon/resources/scripts/main_ex.lua:2056 ImGui.md console and debug done defined in Lua -function ImGui IsVisible repentogon/ImGuiFeatures/LuaImGui.cpp:1124 ImGui.md console and debug todo -function ImGui LinkWindowToElement repentogon/ImGuiFeatures/LuaImGui.cpp:1077 ImGui.md console and debug todo -function ImGui PushNotification repentogon/ImGuiFeatures/LuaImGui.cpp:1120 ImGui.md console and debug todo -function ImGui RemoveCallback repentogon/ImGuiFeatures/LuaImGui.cpp:1070 ImGui.md console and debug todo -function ImGui RemoveColor repentogon/ImGuiFeatures/LuaImGui.cpp:1113 ImGui.md console and debug todo -function ImGui RemoveElement repentogon/ImGuiFeatures/LuaImGui.cpp:1072 ImGui.md console and debug todo -function ImGui RemoveMenu repentogon/ImGuiFeatures/LuaImGui.cpp:1074 ImGui.md console and debug todo -function ImGui RemoveWindow repentogon/ImGuiFeatures/LuaImGui.cpp:1076 ImGui.md console and debug todo -function ImGui Reset repentogon/ImGuiFeatures/LuaImGui.cpp:1121 ImGui.md console and debug todo -function ImGui SetColor repentogon/ImGuiFeatures/LuaImGui.cpp:1103 ImGui.md console and debug todo -function ImGui SetHelpmarker repentogon/ImGuiFeatures/LuaImGui.cpp:1102 ImGui.md console and debug todo -function ImGui SetSize repentogon/ImGuiFeatures/LuaImGui.cpp:1104 ImGui.md console and debug todo -function ImGui SetTextColor repentogon/ImGuiFeatures/LuaImGui.cpp:1105 ImGui.md console and debug todo -function ImGui SetTooltip repentogon/ImGuiFeatures/LuaImGui.cpp:1112 ImGui.md console and debug todo -function ImGui SetVisible repentogon/ImGuiFeatures/LuaImGui.cpp:1106 ImGui.md console and debug todo -function ImGui SetWindowChildFlags repentogon/ImGuiFeatures/LuaImGui.cpp:1109 ImGui.md console and debug todo -function ImGui SetWindowFlags repentogon/ImGuiFeatures/LuaImGui.cpp:1108 ImGui.md console and debug todo -function ImGui SetWindowPinned repentogon/ImGuiFeatures/LuaImGui.cpp:1107 ImGui.md console and debug todo -function ImGui SetWindowPosition repentogon/ImGuiFeatures/LuaImGui.cpp:1110 ImGui.md console and debug todo -function ImGui SetWindowSize repentogon/ImGuiFeatures/LuaImGui.cpp:1111 ImGui.md console and debug todo -function ImGui Show repentogon/ImGuiFeatures/LuaImGui.cpp:1122 ImGui.md console and debug todo -function ImGui UpdateData repentogon/ImGuiFeatures/LuaImGui.cpp:1080 ImGui.md console and debug todo -function ImGui UpdateText repentogon/ImGuiFeatures/LuaImGui.cpp:1079 ImGui.md console and debug todo +function ImGui IsVisible repentogon/ImGuiFeatures/LuaImGui.cpp:1124 ImGui.md console and debug done +function ImGui LinkWindowToElement repentogon/ImGuiFeatures/LuaImGui.cpp:1077 ImGui.md console and debug done +function ImGui PushNotification repentogon/ImGuiFeatures/LuaImGui.cpp:1120 ImGui.md console and debug done +function ImGui RemoveCallback repentogon/ImGuiFeatures/LuaImGui.cpp:1070 ImGui.md console and debug done +function ImGui RemoveColor repentogon/ImGuiFeatures/LuaImGui.cpp:1113 ImGui.md console and debug done +function ImGui RemoveElement repentogon/ImGuiFeatures/LuaImGui.cpp:1072 ImGui.md console and debug done +function ImGui RemoveMenu repentogon/ImGuiFeatures/LuaImGui.cpp:1074 ImGui.md console and debug done +function ImGui RemoveWindow repentogon/ImGuiFeatures/LuaImGui.cpp:1076 ImGui.md console and debug done +function ImGui Reset repentogon/ImGuiFeatures/LuaImGui.cpp:1121 ImGui.md console and debug done +function ImGui SetColor repentogon/ImGuiFeatures/LuaImGui.cpp:1103 ImGui.md console and debug done +function ImGui SetHelpmarker repentogon/ImGuiFeatures/LuaImGui.cpp:1102 ImGui.md console and debug done +function ImGui SetSize repentogon/ImGuiFeatures/LuaImGui.cpp:1104 ImGui.md console and debug done +function ImGui SetTextColor repentogon/ImGuiFeatures/LuaImGui.cpp:1105 ImGui.md console and debug done +function ImGui SetTooltip repentogon/ImGuiFeatures/LuaImGui.cpp:1112 ImGui.md console and debug done +function ImGui SetVisible repentogon/ImGuiFeatures/LuaImGui.cpp:1106 ImGui.md console and debug done +function ImGui SetWindowChildFlags repentogon/ImGuiFeatures/LuaImGui.cpp:1109 ImGui.md console and debug done +function ImGui SetWindowFlags repentogon/ImGuiFeatures/LuaImGui.cpp:1108 ImGui.md console and debug done +function ImGui SetWindowPinned repentogon/ImGuiFeatures/LuaImGui.cpp:1107 ImGui.md console and debug done +function ImGui SetWindowPosition repentogon/ImGuiFeatures/LuaImGui.cpp:1110 ImGui.md console and debug done +function ImGui SetWindowSize repentogon/ImGuiFeatures/LuaImGui.cpp:1111 ImGui.md console and debug done +function ImGui Show repentogon/ImGuiFeatures/LuaImGui.cpp:1122 ImGui.md console and debug done +function ImGui UpdateData repentogon/ImGuiFeatures/LuaImGui.cpp:1080 ImGui.md console and debug done +function ImGui UpdateText repentogon/ImGuiFeatures/LuaImGui.cpp:1079 ImGui.md console and debug done function ImGui WorldToImGui repentogon/resources/scripts/main_ex.lua:2050 ImGui.md console and debug done defined in Lua function Image GetHeight repentogon/LuaInterfaces/LuaRender.cpp:363 render and sprites done function Image GetName repentogon/LuaInterfaces/LuaRender.cpp:366 render and sprites done @@ -1271,11 +1271,11 @@ function Isaac FindByType repentogon/LuaInterfaces/LuaIsaac.cpp:1049 Isaac.md mi function Isaac FindInCapsule repentogon/LuaInterfaces/LuaIsaac.cpp:1070 Isaac.md misc done function Isaac FindInRadius repentogon/LuaInterfaces/LuaIsaac.cpp:1050 Isaac.md misc done function Isaac FindTargetPit repentogon/LuaInterfaces/LuaIsaac.cpp:1093 Isaac.md misc done -function Isaac GetAchievementIdByName repentogon/Patches/AchievementsStuff.cpp:319 Isaac.md persistent data and saves todo +function Isaac GetAchievementIdByName repentogon/Patches/AchievementsStuff.cpp:319 Isaac.md persistent data and saves done function Isaac GetAllowedDoorsMaskForRoomShape repentogon/resources/scripts/main_ex.lua:2160 Isaac.md level and room done defined in Lua function Isaac GetAxisAlignedUnitVectorFromDir repentogon/LuaInterfaces/LuaIsaac.cpp:1094 Isaac.md misc done function Isaac GetBabyIdByName repentogon/LuaInterfaces/LuaIsaac.cpp:1105 Isaac.md misc done -function Isaac GetBackdropIdByName repentogon/LuaInterfaces/LuaIsaac.cpp:1090 Isaac.md level and room todo +function Isaac GetBackdropIdByName repentogon/LuaInterfaces/LuaIsaac.cpp:1090 Isaac.md level and room done function Isaac GetBossColorIdByName repentogon/LuaInterfaces/LuaIsaac.cpp:1089 npc done function Isaac GetBossColorIdxByName repentogon/LuaInterfaces/LuaIsaac.cpp:1088 Isaac.md npc done function Isaac GetButtonsSprite repentogon/LuaInterfaces/LuaIsaac.cpp:1103 Isaac.md render and sprites done @@ -1292,7 +1292,7 @@ function Isaac GetCutsceneIdByName repentogon/LuaInterfaces/LuaIsaac.cpp:1063 Is function Isaac GetDwmWindowAttribute repentogon/LuaInterfaces/LuaIsaac.cpp:1074 Isaac.md misc done function Isaac GetEntityConfig repentogon/resources/scripts/main_ex.lua:2098 entities done defined in Lua function Isaac GetEntitySubTypeByName repentogon/LuaInterfaces/LuaIsaac.cpp:1062 Isaac.md entities done -function Isaac GetGiantBookIdByName repentogon/LuaInterfaces/LuaIsaac.cpp:1064 Isaac.md misc todo +function Isaac GetGiantBookIdByName repentogon/LuaInterfaces/LuaIsaac.cpp:1064 Isaac.md misc done function Isaac GetLoadedModules repentogon/LuaInterfaces/LuaIsaac.cpp:1061 Isaac.md misc done function Isaac GetLocalizedString repentogon/LuaInterfaces/LuaLocalizationStuff.cpp:78 Isaac.md misc done function Isaac GetModChallengeClearCount repentogon/LuaInterfaces/LuaIsaac.cpp:1085 Isaac.md game done @@ -1320,7 +1320,7 @@ function Isaac RemoveCallback repentogon/resources/scripts/main_ex.lua:1288 mis function Isaac RemoveModData repentogon/resources/scripts/main_ex.lua:2035 misc done defined in Lua function Isaac RenderCollectionItem repentogon/LuaInterfaces/LuaIsaac.cpp:1104 Isaac.md render and sprites done function Isaac RenderToWorld repentogon/LuaInterfaces/LuaIsaac.cpp:1055 Isaac.md render and sprites done -function Isaac ReworkBirthright repentogon/LuaInterfaces/LuaIsaac.cpp:1099 Isaac.md player todo +function Isaac ReworkBirthright repentogon/LuaInterfaces/LuaIsaac.cpp:1099 Isaac.md player done function Isaac ReworkCollectible repentogon/LuaInterfaces/LuaIsaac.cpp:1098 Isaac.md items and pools todo function Isaac ReworkTrinket repentogon/LuaInterfaces/LuaIsaac.cpp:1100 Isaac.md items and pools todo function Isaac RunAdditiveCallback repentogon/resources/scripts/main_ex.lua:1888 misc done defined in Lua @@ -1341,7 +1341,7 @@ function Isaac SetCurrentFloorBackdrop repentogon/Patches/StagesStuff.cpp:316 Is function Isaac SetCurrentFloorMusic repentogon/Patches/StagesStuff.cpp:315 Isaac.md level and room done function Isaac SetCurrentFloorName repentogon/Patches/StagesStuff.cpp:317 Isaac.md level and room done function Isaac SetDwmWindowAttribute repentogon/LuaInterfaces/LuaIsaac.cpp:1073 Isaac.md misc done -function Isaac SetIcon repentogon/LuaInterfaces/LuaIsaac.cpp:1077 Isaac.md misc todo +function Isaac SetIcon repentogon/LuaInterfaces/LuaIsaac.cpp:1077 Isaac.md misc done function Isaac SetWindowTitle repentogon/LuaInterfaces/LuaIsaac.cpp:1075 Isaac.md misc done function Isaac ShowErrorDialog repentogon/LuaInterfaces/LuaIsaac.cpp:1069 Isaac.md console and debug done function Isaac SpawnBoss repentogon/LuaInterfaces/LuaIsaac.cpp:1102 Isaac.md npc done @@ -1693,7 +1693,7 @@ function Renderer RenderToImage repentogon/LuaInterfaces/LuaRender.cpp:3248 ren function Renderer StartTransformation repentogon/LuaInterfaces/LuaRender.cpp:3249 render and sprites done function Room CanPickupGridEntity repentogon/LuaInterfaces/Room/LuaRoom.cpp:550 Room.md level and room done function Room CanSpawnObstacleAtPosition repentogon/LuaInterfaces/Room/LuaRoom.cpp:536 Room.md level and room done -function Room ClearBossHazards repentogon/LuaInterfaces/Room/LuaRoom.cpp:577 Room.md level and room todo +function Room ClearBossHazards repentogon/LuaInterfaces/Room/LuaRoom.cpp:577 Room.md level and room done function Room DoLightningStrike repentogon/LuaInterfaces/Room/LuaRoom.cpp:567 Room.md level and room done function Room GetBackdrop repentogon/LuaInterfaces/LuaBackdrop.cpp:99 Room.md level and room done function Room GetBackdropType repentogon/LuaInterfaces/Room/LuaRoom.cpp:571 Room.md level and room done @@ -1957,7 +1957,7 @@ function XMLData GetEntryFromEntity repentogon/Patches/XMLData.cpp:2490 XMLData. function XMLData GetModById repentogon/Patches/XMLData.cpp:2491 XMLData.md items and pools todo function XMLData GetNumEntries repentogon/Patches/XMLData.cpp:2487 XMLData.md items and pools todo function _G ASMPatch repentogon/LuaInterfaces/LuaASM.cpp:276 console and debug todo debug builds only -function _G Benchmark repentogon/LuaInit.cpp:366 persistent data and saves todo +function _G Benchmark repentogon/LuaInit.cpp:366 persistent data and saves done function _G DumpRegistry repentogon/LuaInit.cpp:362 console and debug done function _G ExtractFunctions repentogon/LuaInit.cpp:365 console and debug done function _G RandomFloat repentogon/LuaInit.cpp:367 console and debug done @@ -2066,7 +2066,7 @@ property Options Brightness repentogon/LuaInterfaces/LuaOptions.cpp:387 Options. property Options Contrast repentogon/LuaInterfaces/LuaOptions.cpp:388 Options.md misc done property Options Exposure repentogon/LuaInterfaces/LuaOptions.cpp:386 Options.md misc done property Options HushPanicStateFix repentogon/LuaInterfaces/LuaOptions.cpp:406 Options.md misc done -property Options KeyMasterDealChance Options.md misc todo docs only: no registration found +property Options KeyMasterDealChance Options.md misc done docs only: no registration found property Options OnlineChatEnabled repentogon/LuaInterfaces/LuaOptions.cpp:381 Options.md misc done property Options OnlineChatFilterEnabled repentogon/LuaInterfaces/LuaOptions.cpp:396 Options.md misc done property Options OnlineColorSet repentogon/LuaInterfaces/LuaOptions.cpp:384 Options.md misc done @@ -2113,19 +2113,19 @@ constructor WeightedOutcomePicker WeightedOutcomePicker repentogon/LuaInterfaces callback ModCallbacks MC_BOMB_GRID_COLLISION repentogon/resources/scripts/enums_ex.lua:170 enums/ModCallbacks.md tear and weapons done id 1178 callback ModCallbacks MC_CAN_SELECT_CHARACTER repentogon/resources/scripts/enums_ex.lua:291 enums/ModCallbacks.md misc done id 1328 callback ModCallbacks MC_COMPLETION_MARK_GET repentogon/resources/scripts/enums_ex.lua:49 enums/ModCallbacks.md persistent data and saves done id 1047 -callback ModCallbacks MC_CONSOLE_AUTOCOMPLETE repentogon/resources/scripts/enums_ex.lua:122 enums/ModCallbacks.md console and debug todo id 1120 -callback ModCallbacks MC_ENTITY_RESTORE repentogon/resources/scripts/enums_ex.lua:289 entities todo id 1315 +callback ModCallbacks MC_CONSOLE_AUTOCOMPLETE repentogon/resources/scripts/enums_ex.lua:122 enums/ModCallbacks.md console and debug done id 1120 +callback ModCallbacks MC_ENTITY_RESTORE repentogon/resources/scripts/enums_ex.lua:289 entities done id 1315 callback ModCallbacks MC_ENTITY_SAVE repentogon/resources/scripts/enums_ex.lua:288 persistent data and saves done id 1314 -callback ModCallbacks MC_ENTITY_TAKE_DMG enums/ModCallbacks.md entities review id 11, vanilla callback REPENTOGON changes -callback ModCallbacks MC_EVALUATE_CUSTOM_CACHE repentogon/resources/scripts/enums_ex.lua:199 enums/ModCallbacks.md items and pools todo id 1224 +callback ModCallbacks MC_ENTITY_TAKE_DMG enums/ModCallbacks.md entities done id 11, vanilla callback REPENTOGON changes +callback ModCallbacks MC_EVALUATE_CUSTOM_CACHE repentogon/resources/scripts/enums_ex.lua:199 enums/ModCallbacks.md items and pools done id 1224 callback ModCallbacks MC_EVALUATE_FAMILIAR_MULTIPLIER repentogon/resources/scripts/enums_ex.lua:200 enums/ModCallbacks.md familiar done id 1225 -callback ModCallbacks MC_EVALUATE_MULTI_SHOT_PARAMS repentogon/resources/scripts/enums_ex.lua:263 enums/ModCallbacks.md misc todo id 1289 +callback ModCallbacks MC_EVALUATE_MULTI_SHOT_PARAMS repentogon/resources/scripts/enums_ex.lua:263 enums/ModCallbacks.md misc done id 1289 callback ModCallbacks MC_EVALUATE_STAT repentogon/resources/scripts/enums_ex.lua:201 enums/ModCallbacks.md hud and menus done id 1226 callback ModCallbacks MC_EVALUATE_TEAR_HIT_PARAMS repentogon/resources/scripts/enums_ex.lua:404 enums/ModCallbacks.md tear and weapons done id 1490 callback ModCallbacks MC_FAMILIAR_GRID_COLLISION repentogon/resources/scripts/enums_ex.lua:168 enums/ModCallbacks.md familiar done id 1176 callback ModCallbacks MC_GET_BOSS_THEMATIC_ITEM repentogon/resources/scripts/enums_ex.lua:407 enums/ModCallbacks.md npc done id 1493 callback ModCallbacks MC_GET_FOLLOWER_PRIORITY repentogon/resources/scripts/enums_ex.lua:65 enums/ModCallbacks.md misc done id 1063 -callback ModCallbacks MC_GET_PILL_EFFECT enums/ModCallbacks.md items and pools review id 65, vanilla callback REPENTOGON changes +callback ModCallbacks MC_GET_PILL_EFFECT enums/ModCallbacks.md items and pools done id 65, vanilla callback REPENTOGON changes callback ModCallbacks MC_GET_SHOP_ITEM_PRICE repentogon/resources/scripts/enums_ex.lua:68 enums/ModCallbacks.md items and pools done id 1066 callback ModCallbacks MC_GET_STATUS_EFFECT_TARGET repentogon/resources/scripts/enums_ex.lua:399 enums/ModCallbacks.md hud and menus done id 1485 callback ModCallbacks MC_GRID_HURT_DAMAGE repentogon/resources/scripts/enums_ex.lua:13 enums/ModCallbacks.md level and room done id 1012 @@ -2149,11 +2149,11 @@ callback ModCallbacks MC_PLAYER_INIT_POST_LEVEL_INIT_STATS repentogon/resources/ callback ModCallbacks MC_PLAYER_INIT_PRE_LEVEL_INIT_STATS repentogon/resources/scripts/enums_ex.lua:129 enums/ModCallbacks.md player done id 1127 callback ModCallbacks MC_POST_ACHIEVEMENT_UNLOCK repentogon/resources/scripts/enums_ex.lua:390 enums/ModCallbacks.md persistent data and saves done id 1476 callback ModCallbacks MC_POST_ADD_COLLECTIBLE repentogon/resources/scripts/enums_ex.lua:5 enums/ModCallbacks.md items and pools done id 1005 -callback ModCallbacks MC_POST_ADD_INNATE_COLLECTIBLE repentogon/resources/scripts/enums_ex.lua:56 enums/ModCallbacks.md items and pools todo id 1054 -callback ModCallbacks MC_POST_ADD_INNATE_TRINKET repentogon/resources/scripts/enums_ex.lua:57 enums/ModCallbacks.md items and pools todo id 1055 +callback ModCallbacks MC_POST_ADD_INNATE_COLLECTIBLE repentogon/resources/scripts/enums_ex.lua:56 enums/ModCallbacks.md items and pools done id 1054 +callback ModCallbacks MC_POST_ADD_INNATE_TRINKET repentogon/resources/scripts/enums_ex.lua:57 enums/ModCallbacks.md items and pools done id 1055 callback ModCallbacks MC_POST_ADD_TO_BAG_OF_CRAFTING repentogon/resources/scripts/enums_ex.lua:17 enums/ModCallbacks.md items and pools done id 1016 callback ModCallbacks MC_POST_APPLY_TEARFLAG_EFFECTS repentogon/resources/scripts/enums_ex.lua:252 enums/ModCallbacks.md tear and weapons done id 1278 -callback ModCallbacks MC_POST_BACKDROP_CHANGE repentogon/resources/scripts/enums_ex.lua:144 enums/ModCallbacks.md level and room todo id 1142 +callback ModCallbacks MC_POST_BACKDROP_CHANGE repentogon/resources/scripts/enums_ex.lua:144 enums/ModCallbacks.md level and room done id 1142 callback ModCallbacks MC_POST_BACKDROP_PRE_RENDER_WALLS repentogon/resources/scripts/enums_ex.lua:111 enums/ModCallbacks.md render and sprites done id 1109 callback ModCallbacks MC_POST_BACKWARDS_ROOM_RESTORE repentogon/resources/scripts/enums_ex.lua:282 enums/ModCallbacks.md level and room done id 1308 callback ModCallbacks MC_POST_BACKWARDS_ROOM_SAVE repentogon/resources/scripts/enums_ex.lua:281 enums/ModCallbacks.md persistent data and saves done id 1307 @@ -2168,7 +2168,7 @@ callback ModCallbacks MC_POST_COMPLETION_MARKS_RENDER repentogon/resources/scrip callback ModCallbacks MC_POST_COMPLETION_MARK_GET repentogon/resources/scripts/enums_ex.lua:50 enums/ModCallbacks.md persistent data and saves done id 1048 callback ModCallbacks MC_POST_DEVIL_CALCULATE repentogon/resources/scripts/enums_ex.lua:135 enums/ModCallbacks.md items and pools done id 1133 callback ModCallbacks MC_POST_DISCHARGE_ACTIVE_ITEM repentogon/resources/scripts/enums_ex.lua:142 enums/ModCallbacks.md items and pools done id 1140 -callback ModCallbacks MC_POST_ENTITY_KILL enums/ModCallbacks.md entities review id 68, vanilla callback REPENTOGON changes +callback ModCallbacks MC_POST_ENTITY_KILL enums/ModCallbacks.md entities done id 68, vanilla callback REPENTOGON changes callback ModCallbacks MC_POST_ENTITY_SET_COLOR repentogon/resources/scripts/enums_ex.lua:401 enums/ModCallbacks.md render and sprites done id 1487 callback ModCallbacks MC_POST_ENTITY_TAKE_DMG repentogon/resources/scripts/enums_ex.lua:7 enums/ModCallbacks.md entities done id 1006 callback ModCallbacks MC_POST_ENTITY_THROW repentogon/resources/scripts/enums_ex.lua:43 enums/ModCallbacks.md entities done id 1041 @@ -2242,14 +2242,14 @@ callback ModCallbacks MC_POST_NIGHTMARE_SCENE_RENDER repentogon/resources/script callback ModCallbacks MC_POST_NIGHTMARE_SCENE_SHOW repentogon/resources/scripts/enums_ex.lua:105 enums/ModCallbacks.md hud and menus done id 1103 callback ModCallbacks MC_POST_NPC_COLLISION repentogon/resources/scripts/enums_ex.lua:221 enums/ModCallbacks.md npc done id 1247 callback ModCallbacks MC_POST_NPC_DARK_RED_CHAMPION_REGEN repentogon/resources/scripts/enums_ex.lua:198 enums/ModCallbacks.md npc done id 1223 -callback ModCallbacks MC_POST_NPC_GET_LOOT_LIST repentogon/resources/scripts/enums_ex.lua:302 npc todo id 1339 +callback ModCallbacks MC_POST_NPC_GET_LOOT_LIST repentogon/resources/scripts/enums_ex.lua:302 npc done id 1339 callback ModCallbacks MC_POST_NPC_MORPH repentogon/resources/scripts/enums_ex.lua:189 enums/ModCallbacks.md npc done id 1214 callback ModCallbacks MC_POST_OPEN_CHEST repentogon/resources/scripts/enums_ex.lua:406 enums/ModCallbacks.md misc done id 1492 callback ModCallbacks MC_POST_PAUSE_SCREEN_RENDER repentogon/resources/scripts/enums_ex.lua:194 enums/ModCallbacks.md hud and menus done id 1219 callback ModCallbacks MC_POST_PICKUP_COLLISION repentogon/resources/scripts/enums_ex.lua:213 enums/ModCallbacks.md pickup done id 1239 -callback ModCallbacks MC_POST_PICKUP_GET_LOOT_LIST repentogon/resources/scripts/enums_ex.lua:299 enums/ModCallbacks.md pickup todo id 1336 +callback ModCallbacks MC_POST_PICKUP_GET_LOOT_LIST repentogon/resources/scripts/enums_ex.lua:299 enums/ModCallbacks.md pickup done id 1336 callback ModCallbacks MC_POST_PICKUP_MORPH repentogon/resources/scripts/enums_ex.lua:190 enums/ModCallbacks.md pickup done id 1215 -callback ModCallbacks MC_POST_PICKUP_SELECTION enums/ModCallbacks.md pickup review id 37, vanilla callback REPENTOGON changes +callback ModCallbacks MC_POST_PICKUP_SELECTION enums/ModCallbacks.md pickup done id 37, vanilla callback REPENTOGON changes callback ModCallbacks MC_POST_PICKUP_SHOP_PURCHASE repentogon/resources/scripts/enums_ex.lua:64 enums/ModCallbacks.md pickup done id 1062 callback ModCallbacks MC_POST_PLANETARIUM_CALCULATE repentogon/resources/scripts/enums_ex.lua:117 enums/ModCallbacks.md items and pools done id 1115 callback ModCallbacks MC_POST_PLAYERHUD_RENDER_ACTIVE_ITEM repentogon/resources/scripts/enums_ex.lua:81 enums/ModCallbacks.md player done id 1079 @@ -2268,7 +2268,7 @@ callback ModCallbacks MC_POST_PLAYER_COLLISION repentogon/resources/scripts/enum callback ModCallbacks MC_POST_PLAYER_DROP_CARD repentogon/resources/scripts/enums_ex.lua:314 enums/ModCallbacks.md player done id 1360 callback ModCallbacks MC_POST_PLAYER_DROP_PILL repentogon/resources/scripts/enums_ex.lua:315 enums/ModCallbacks.md player done id 1361 callback ModCallbacks MC_POST_PLAYER_DROP_TRINKET repentogon/resources/scripts/enums_ex.lua:146 enums/ModCallbacks.md player done id 1144 -callback ModCallbacks MC_POST_PLAYER_GET_MULTI_SHOT_PARAMS repentogon/resources/scripts/enums_ex.lua:225 player todo id 1251 +callback ModCallbacks MC_POST_PLAYER_GET_MULTI_SHOT_PARAMS repentogon/resources/scripts/enums_ex.lua:225 player done id 1251 callback ModCallbacks MC_POST_PLAYER_NEW_LEVEL repentogon/resources/scripts/enums_ex.lua:80 enums/ModCallbacks.md player done id 1078 callback ModCallbacks MC_POST_PLAYER_NEW_ROOM_TEMP_EFFECTS repentogon/resources/scripts/enums_ex.lua:79 enums/ModCallbacks.md player done id 1077 callback ModCallbacks MC_POST_PLAYER_REMOVE_CARD repentogon/resources/scripts/enums_ex.lua:308 enums/ModCallbacks.md player done id 1354 @@ -2280,8 +2280,8 @@ callback ModCallbacks MC_POST_PLAYER_TRIGGER_ROOM_CLEAR repentogon/resources/scr callback ModCallbacks MC_POST_PLAYER_USE_BOMB repentogon/resources/scripts/enums_ex.lua:196 enums/ModCallbacks.md player done id 1221 callback ModCallbacks MC_POST_PROJECTILE_COLLISION repentogon/resources/scripts/enums_ex.lua:219 enums/ModCallbacks.md tear and weapons done id 1245 callback ModCallbacks MC_POST_PROJECTILE_DEATH repentogon/resources/scripts/enums_ex.lua:34 enums/ModCallbacks.md tear and weapons done id 1032 -callback ModCallbacks MC_POST_REMOVE_INNATE_COLLECTIBLE repentogon/resources/scripts/enums_ex.lua:58 enums/ModCallbacks.md items and pools todo id 1056 -callback ModCallbacks MC_POST_REMOVE_INNATE_TRINKET repentogon/resources/scripts/enums_ex.lua:59 enums/ModCallbacks.md items and pools todo id 1057 +callback ModCallbacks MC_POST_REMOVE_INNATE_COLLECTIBLE repentogon/resources/scripts/enums_ex.lua:58 enums/ModCallbacks.md items and pools done id 1056 +callback ModCallbacks MC_POST_REMOVE_INNATE_TRINKET repentogon/resources/scripts/enums_ex.lua:59 enums/ModCallbacks.md items and pools done id 1057 callback ModCallbacks MC_POST_RENDER_CHARACTER_SELECT_PAGE repentogon/resources/scripts/enums_ex.lua:293 enums/ModCallbacks.md render and sprites done id 1330 callback ModCallbacks MC_POST_RENDER_CHARACTER_SELECT_PORTRAIT repentogon/resources/scripts/enums_ex.lua:295 enums/ModCallbacks.md render and sprites done id 1332 callback ModCallbacks MC_POST_RENDER_PLAYER_BODY repentogon/resources/scripts/enums_ex.lua:48 player done id 1046 @@ -2311,14 +2311,14 @@ callback ModCallbacks MC_POST_SWAP_ROOMS repentogon/resources/scripts/enums_ex.l callback ModCallbacks MC_POST_TAKE_DMG repentogon/resources/scripts/enums_ex.lua:6 entities done id 1006 callback ModCallbacks MC_POST_TEAR_COLLISION repentogon/resources/scripts/enums_ex.lua:207 enums/ModCallbacks.md tear and weapons done id 1233 callback ModCallbacks MC_POST_TEAR_DEATH repentogon/resources/scripts/enums_ex.lua:35 enums/ModCallbacks.md tear and weapons done id 1033 -callback ModCallbacks MC_POST_TRIGGER_BED_SLEEP_EFFECT repentogon/resources/scripts/enums_ex.lua:260 enums/ModCallbacks.md misc todo id 1286 +callback ModCallbacks MC_POST_TRIGGER_BED_SLEEP_EFFECT repentogon/resources/scripts/enums_ex.lua:260 enums/ModCallbacks.md misc done id 1286 callback ModCallbacks MC_POST_TRIGGER_COLLECTIBLE_ADDED repentogon/resources/scripts/enums_ex.lua:55 enums/ModCallbacks.md items and pools done id 1053 callback ModCallbacks MC_POST_TRIGGER_COLLECTIBLE_REMOVED repentogon/resources/scripts/enums_ex.lua:97 enums/ModCallbacks.md items and pools done id 1095 callback ModCallbacks MC_POST_TRIGGER_TRINKET_ADDED repentogon/resources/scripts/enums_ex.lua:98 enums/ModCallbacks.md items and pools done id 1096 callback ModCallbacks MC_POST_TRIGGER_TRINKET_REMOVED repentogon/resources/scripts/enums_ex.lua:99 enums/ModCallbacks.md items and pools done id 1097 -callback ModCallbacks MC_POST_TRIGGER_WEAPON_FIRED repentogon/resources/scripts/enums_ex.lua:100 enums/ModCallbacks.md tear and weapons todo id 1098 +callback ModCallbacks MC_POST_TRIGGER_WEAPON_FIRED repentogon/resources/scripts/enums_ex.lua:100 enums/ModCallbacks.md tear and weapons done id 1098 callback ModCallbacks MC_POST_USE_ITEM repentogon/resources/scripts/enums_ex.lua:3 enums/ModCallbacks.md items and pools done id 1003 -callback ModCallbacks MC_POST_WEAPON_FIRE repentogon/resources/scripts/enums_ex.lua:107 enums/ModCallbacks.md tear and weapons todo id 1105 +callback ModCallbacks MC_POST_WEAPON_FIRE repentogon/resources/scripts/enums_ex.lua:107 enums/ModCallbacks.md tear and weapons done id 1105 callback ModCallbacks MC_PRE_ADD_COLLECTIBLE repentogon/resources/scripts/enums_ex.lua:4 enums/ModCallbacks.md items and pools done id 1004 callback ModCallbacks MC_PRE_ADD_TRINKET repentogon/resources/scripts/enums_ex.lua:15 enums/ModCallbacks.md items and pools done id 1014 callback ModCallbacks MC_PRE_APPLY_TEARFLAG_EFFECTS repentogon/resources/scripts/enums_ex.lua:251 enums/ModCallbacks.md tear and weapons done id 1277 @@ -2327,13 +2327,13 @@ callback ModCallbacks MC_PRE_BACKDROP_RENDER_FLOOR repentogon/resources/scripts/ callback ModCallbacks MC_PRE_BACKDROP_RENDER_WALLS repentogon/resources/scripts/enums_ex.lua:108 enums/ModCallbacks.md render and sprites done id 1106 callback ModCallbacks MC_PRE_BACKDROP_RENDER_WATER repentogon/resources/scripts/enums_ex.lua:110 enums/ModCallbacks.md render and sprites done id 1108 callback ModCallbacks MC_PRE_BED_SLEEP repentogon/resources/scripts/enums_ex.lua:262 enums/ModCallbacks.md misc done id 1288 -callback ModCallbacks MC_PRE_BOMB_COLLISION enums/ModCallbacks.md tear and weapons review id 60, vanilla callback REPENTOGON changes +callback ModCallbacks MC_PRE_BOMB_COLLISION enums/ModCallbacks.md tear and weapons done id 60, vanilla callback REPENTOGON changes callback ModCallbacks MC_PRE_BOMB_DAMAGE repentogon/resources/scripts/enums_ex.lua:265 enums/ModCallbacks.md tear and weapons done id 1291 callback ModCallbacks MC_PRE_BOMB_GRID_COLLISION repentogon/resources/scripts/enums_ex.lua:169 enums/ModCallbacks.md tear and weapons done id 1177 callback ModCallbacks MC_PRE_BOMB_RENDER repentogon/resources/scripts/enums_ex.lua:90 enums/ModCallbacks.md tear and weapons done id 1088 callback ModCallbacks MC_PRE_BOMB_TEARFLAG_EFFECTS repentogon/resources/scripts/enums_ex.lua:266 enums/ModCallbacks.md tear and weapons done id 1292 callback ModCallbacks MC_PRE_BOMB_UPDATE repentogon/resources/scripts/enums_ex.lua:155 enums/ModCallbacks.md tear and weapons done id 1163 -callback ModCallbacks MC_PRE_BOSS_SELECT repentogon/resources/scripts/enums_ex.lua:254 enums/ModCallbacks.md npc todo id 1280 +callback ModCallbacks MC_PRE_BOSS_SELECT repentogon/resources/scripts/enums_ex.lua:254 enums/ModCallbacks.md npc done id 1280 callback ModCallbacks MC_PRE_BRIMSTONE_SNEEZE repentogon/resources/scripts/enums_ex.lua:38 enums/ModCallbacks.md tear and weapons done id 1036 callback ModCallbacks MC_PRE_CHALLENGE_DONE repentogon/resources/scripts/enums_ex.lua:385 enums/ModCallbacks.md game done id 1471 callback ModCallbacks MC_PRE_CHANGE_ROOM repentogon/resources/scripts/enums_ex.lua:63 enums/ModCallbacks.md level and room done id 1061 @@ -2394,7 +2394,7 @@ callback ModCallbacks MC_PRE_GRID_HURT repentogon/resources/scripts/enums_ex.lua callback ModCallbacks MC_PRE_HISTORYHUD_RENDER repentogon/resources/scripts/enums_ex.lua:29 enums/ModCallbacks.md hud and menus done id 1027 callback ModCallbacks MC_PRE_ITEM_OVERLAY_SHOW repentogon/resources/scripts/enums_ex.lua:78 enums/ModCallbacks.md hud and menus done id 1076 callback ModCallbacks MC_PRE_ITEM_TEXT_DISPLAY repentogon/resources/scripts/enums_ex.lua:398 enums/ModCallbacks.md items and pools done id 1484 -callback ModCallbacks MC_PRE_KNIFE_COLLISION enums/ModCallbacks.md tear and weapons review id 53, vanilla callback REPENTOGON changes +callback ModCallbacks MC_PRE_KNIFE_COLLISION enums/ModCallbacks.md tear and weapons done id 53, vanilla callback REPENTOGON changes callback ModCallbacks MC_PRE_KNIFE_RENDER repentogon/resources/scripts/enums_ex.lua:88 enums/ModCallbacks.md tear and weapons done id 1086 callback ModCallbacks MC_PRE_KNIFE_UPDATE repentogon/resources/scripts/enums_ex.lua:157 enums/ModCallbacks.md tear and weapons done id 1165 callback ModCallbacks MC_PRE_LASER_COLLISION repentogon/resources/scripts/enums_ex.lua:222 enums/ModCallbacks.md tear and weapons done id 1248 @@ -2405,14 +2405,14 @@ callback ModCallbacks MC_PRE_LEVEL_SELECT repentogon/resources/scripts/enums_ex. callback ModCallbacks MC_PRE_MEGA_SATAN_ENDING repentogon/resources/scripts/enums_ex.lua:183 enums/ModCallbacks.md misc done id 1201 callback ModCallbacks MC_PRE_MINIMAP_RENDER repentogon/resources/scripts/enums_ex.lua:393 hud and menus done id 1479 callback ModCallbacks MC_PRE_MINIMAP_UPDATE repentogon/resources/scripts/enums_ex.lua:391 hud and menus done id 1477 -callback ModCallbacks MC_PRE_MOD_UNLOAD enums/ModCallbacks.md misc review id 73, vanilla callback REPENTOGON changes +callback ModCallbacks MC_PRE_MOD_UNLOAD enums/ModCallbacks.md misc done id 73, vanilla callback REPENTOGON changes callback ModCallbacks MC_PRE_MUSIC_LAYER_TOGGLE repentogon/resources/scripts/enums_ex.lua:37 enums/ModCallbacks.md audio done id 1035 callback ModCallbacks MC_PRE_MUSIC_PLAY repentogon/resources/scripts/enums_ex.lua:36 enums/ModCallbacks.md audio done id 1034 callback ModCallbacks MC_PRE_MUSIC_PLAY_JINGLE repentogon/resources/scripts/enums_ex.lua:96 enums/ModCallbacks.md audio done id 1094 callback ModCallbacks MC_PRE_M_MORPH_ACTIVE repentogon/resources/scripts/enums_ex.lua:178 enums/ModCallbacks.md misc done id 1190 callback ModCallbacks MC_PRE_NEW_ROOM repentogon/resources/scripts/enums_ex.lua:182 enums/ModCallbacks.md level and room done id 1200 -callback ModCallbacks MC_PRE_NPC_COLLISION enums/ModCallbacks.md npc review id 30, vanilla callback REPENTOGON changes -callback ModCallbacks MC_PRE_NPC_GET_LOOT_LIST repentogon/resources/scripts/enums_ex.lua:300 npc todo id 1337 +callback ModCallbacks MC_PRE_NPC_COLLISION enums/ModCallbacks.md npc done id 30, vanilla callback REPENTOGON changes +callback ModCallbacks MC_PRE_NPC_GET_LOOT_LIST repentogon/resources/scripts/enums_ex.lua:300 npc done id 1337 callback ModCallbacks MC_PRE_NPC_GRID_COLLISION repentogon/resources/scripts/enums_ex.lua:175 enums/ModCallbacks.md npc done id 1183 callback ModCallbacks MC_PRE_NPC_MORPH repentogon/resources/scripts/enums_ex.lua:187 enums/ModCallbacks.md npc done id 1212 callback ModCallbacks MC_PRE_NPC_RENDER repentogon/resources/scripts/enums_ex.lua:83 enums/ModCallbacks.md npc done id 1081 @@ -2421,9 +2421,9 @@ callback ModCallbacks MC_PRE_NPC_UPDATE_GHOST_PICKUPS repentogon/resources/scrip callback ModCallbacks MC_PRE_OPENGL_RENDER repentogon/resources/scripts/enums_ex.lua:138 render and sprites todo id 1136 callback ModCallbacks MC_PRE_OPEN_CHEST repentogon/resources/scripts/enums_ex.lua:405 enums/ModCallbacks.md misc done id 1491 callback ModCallbacks MC_PRE_PAUSE_SCREEN_RENDER repentogon/resources/scripts/enums_ex.lua:193 enums/ModCallbacks.md hud and menus done id 1218 -callback ModCallbacks MC_PRE_PICKUP_COLLISION enums/ModCallbacks.md pickup review id 38, vanilla callback REPENTOGON changes +callback ModCallbacks MC_PRE_PICKUP_COLLISION enums/ModCallbacks.md pickup done id 38, vanilla callback REPENTOGON changes callback ModCallbacks MC_PRE_PICKUP_COMPOSTED repentogon/resources/scripts/enums_ex.lua:241 enums/ModCallbacks.md pickup done id 1267 -callback ModCallbacks MC_PRE_PICKUP_GET_LOOT_LIST repentogon/resources/scripts/enums_ex.lua:297 enums/ModCallbacks.md pickup todo id 1334 +callback ModCallbacks MC_PRE_PICKUP_GET_LOOT_LIST repentogon/resources/scripts/enums_ex.lua:297 enums/ModCallbacks.md pickup done id 1334 callback ModCallbacks MC_PRE_PICKUP_GRID_COLLISION repentogon/resources/scripts/enums_ex.lua:171 enums/ModCallbacks.md pickup done id 1179 callback ModCallbacks MC_PRE_PICKUP_MORPH repentogon/resources/scripts/enums_ex.lua:188 enums/ModCallbacks.md pickup done id 1213 callback ModCallbacks MC_PRE_PICKUP_RENDER repentogon/resources/scripts/enums_ex.lua:85 enums/ModCallbacks.md pickup done id 1083 @@ -2449,7 +2449,7 @@ callback ModCallbacks MC_PRE_PLAYER_ADD_PILL repentogon/resources/scripts/enums_ callback ModCallbacks MC_PRE_PLAYER_APPLY_INNATE_COLLECTIBLE_NUM repentogon/resources/scripts/enums_ex.lua:94 player done id 1092 callback ModCallbacks MC_PRE_PLAYER_COLLECT_CARD repentogon/resources/scripts/enums_ex.lua:310 enums/ModCallbacks.md player done id 1356 callback ModCallbacks MC_PRE_PLAYER_COLLECT_PILL repentogon/resources/scripts/enums_ex.lua:312 enums/ModCallbacks.md player done id 1358 -callback ModCallbacks MC_PRE_PLAYER_COLLISION enums/ModCallbacks.md player review id 33, vanilla callback REPENTOGON changes +callback ModCallbacks MC_PRE_PLAYER_COLLISION enums/ModCallbacks.md player done id 33, vanilla callback REPENTOGON changes callback ModCallbacks MC_PRE_PLAYER_GIVE_BIRTH_CAMBION repentogon/resources/scripts/enums_ex.lua:388 enums/ModCallbacks.md player done id 1474 callback ModCallbacks MC_PRE_PLAYER_GIVE_BIRTH_IMMACULATE repentogon/resources/scripts/enums_ex.lua:389 enums/ModCallbacks.md player done id 1475 callback ModCallbacks MC_PRE_PLAYER_GRID_COLLISION repentogon/resources/scripts/enums_ex.lua:163 enums/ModCallbacks.md player done id 1171 @@ -2461,7 +2461,7 @@ callback ModCallbacks MC_PRE_PLAYER_TAKE_DMG repentogon/resources/scripts/enums_ callback ModCallbacks MC_PRE_PLAYER_TRIGGER_ROOM_CLEAR repentogon/resources/scripts/enums_ex.lua:71 enums/ModCallbacks.md player done id 1069 callback ModCallbacks MC_PRE_PLAYER_UPDATE repentogon/resources/scripts/enums_ex.lua:152 enums/ModCallbacks.md player done id 1160 callback ModCallbacks MC_PRE_PLAYER_USE_BOMB repentogon/resources/scripts/enums_ex.lua:195 enums/ModCallbacks.md player done id 1220 -callback ModCallbacks MC_PRE_PROJECTILE_COLLISION enums/ModCallbacks.md tear and weapons review id 46, vanilla callback REPENTOGON changes +callback ModCallbacks MC_PRE_PROJECTILE_COLLISION enums/ModCallbacks.md tear and weapons done id 46, vanilla callback REPENTOGON changes callback ModCallbacks MC_PRE_PROJECTILE_GRID_COLLISION repentogon/resources/scripts/enums_ex.lua:173 enums/ModCallbacks.md tear and weapons done id 1181 callback ModCallbacks MC_PRE_PROJECTILE_RENDER repentogon/resources/scripts/enums_ex.lua:87 enums/ModCallbacks.md tear and weapons done id 1085 callback ModCallbacks MC_PRE_PROJECTILE_UPDATE repentogon/resources/scripts/enums_ex.lua:158 enums/ModCallbacks.md tear and weapons done id 1166 @@ -2490,7 +2490,7 @@ callback ModCallbacks MC_PRE_SLOT_RENDER repentogon/resources/scripts/enums_ex.l callback ModCallbacks MC_PRE_SLOT_SET_PRIZE_COLLECTIBLE repentogon/resources/scripts/enums_ex.lua:127 enums/ModCallbacks.md pickup done id 1125 callback ModCallbacks MC_PRE_SLOT_UPDATE repentogon/resources/scripts/enums_ex.lua:161 enums/ModCallbacks.md pickup done id 1169 callback ModCallbacks MC_PRE_STATUS_EFFECT_APPLY repentogon/resources/scripts/enums_ex.lua:381 enums/ModCallbacks.md hud and menus done id 1465 -callback ModCallbacks MC_PRE_TEAR_COLLISION enums/ModCallbacks.md tear and weapons review id 42, vanilla callback REPENTOGON changes +callback ModCallbacks MC_PRE_TEAR_COLLISION enums/ModCallbacks.md tear and weapons done id 42, vanilla callback REPENTOGON changes callback ModCallbacks MC_PRE_TEAR_GRID_COLLISION repentogon/resources/scripts/enums_ex.lua:165 enums/ModCallbacks.md tear and weapons done id 1173 callback ModCallbacks MC_PRE_TEAR_RENDER repentogon/resources/scripts/enums_ex.lua:86 enums/ModCallbacks.md tear and weapons done id 1084 callback ModCallbacks MC_PRE_TEAR_UPDATE repentogon/resources/scripts/enums_ex.lua:153 enums/ModCallbacks.md tear and weapons done id 1161 @@ -2498,24 +2498,24 @@ callback ModCallbacks MC_PRE_TRIGGER_BED_SLEEP_EFFECT repentogon/resources/scrip callback ModCallbacks MC_PRE_TRIGGER_PLAYER_DEATH repentogon/resources/scripts/enums_ex.lua:52 enums/ModCallbacks.md player done id 1050 callback ModCallbacks MC_PRE_UPDATE repentogon/resources/scripts/enums_ex.lua:28 enums/ModCallbacks.md game done id 1026 callback ModCallbacks MC_PRE_USE_CARD repentogon/resources/scripts/enums_ex.lua:66 enums/ModCallbacks.md items and pools done id 1064 -callback ModCallbacks MC_PRE_USE_ITEM enums/ModCallbacks.md items and pools review id 23, vanilla callback REPENTOGON changes +callback ModCallbacks MC_PRE_USE_ITEM enums/ModCallbacks.md items and pools done id 23, vanilla callback REPENTOGON changes callback ModCallbacks MC_PRE_USE_PILL repentogon/resources/scripts/enums_ex.lua:67 enums/ModCallbacks.md items and pools done id 1065 callback ModCallbacks MC_PROJECTILE_GRID_COLLISION repentogon/resources/scripts/enums_ex.lua:174 enums/ModCallbacks.md tear and weapons done id 1182 callback ModCallbacks MC_SHOULD_SAVE_ENTITY repentogon/resources/scripts/enums_ex.lua:287 persistent data and saves done id 1313 callback ModCallbacks MC_TEAR_GRID_COLLISION repentogon/resources/scripts/enums_ex.lua:166 enums/ModCallbacks.md tear and weapons done id 1174 callback ModCallbacks MC_TRIGGER_PLAYER_DEATH_POST_CHECK_REVIVES repentogon/resources/scripts/enums_ex.lua:53 enums/ModCallbacks.md player done id 1051 callback ModCallbacks MC_TRY_ADD_TO_BAG_OF_CRAFTING repentogon/resources/scripts/enums_ex.lua:16 enums/ModCallbacks.md items and pools done id 1015 -callback ModCallbacks MC_USE_PILL enums/ModCallbacks.md items and pools review id 10, vanilla callback REPENTOGON changes -xml_attribute achievements.xml gfxback repentogon/Patches/AchievementsStuff.cpp:184 xml/achievements.md persistent data and saves todo File "achievements.xml": path of the png sprite to use as a background paper for the achievement -xml_attribute achievements.xml hidden repentogon/Patches/XMLData.cpp:1479 xml/achievements.md persistent data and saves todo File "achievements.xml": any value other than 'false', preferably 'true', will make it not show the achievement popup on -xml_attribute achievements.xml name repentogon/Patches/XMLData.cpp:269 xml/achievements.md persistent data and saves todo File "achievements.xml": used for the GetXByName functions (when this is not present, text is used instead) -xml_attribute babies.xml achievement repentogon/Patches/XMLData.cpp:957 xml/babies.md player todo Babies: Optionally allows you to lock your baby behind an achievement (modded achievements must be specified by name). -xml_attribute babies.xml hidden repentogon/Patches/XMLData.cpp:1479 xml/babies.md player todo Babies: Prevents the baby from appearing naturally. -xml_attribute babies.xml name repentogon/Patches/XMLData.cpp:269 xml/babies.md player todo Babies: The name of the baby. -xml_attribute babies.xml skin xml/babies.md player todo Babies: Path to the baby's spritesheet, starting from the `root` (see example below). -xml_attribute backdrops.xml name repentogon/Patches/XMLData.cpp:269 xml/backdrops.md level and room todo File "backdrops.xml": The name of the custom backdrop, for use with Isaac.GetBackdropIdByName -xml_attribute backdrops.xml reftype repentogon/Patches/XMLData.cpp:615 xml/backdrops.md level and room todo File "backdrops.xml": Defines the id of the backdrop to use as a base for the custom backdrop. This is useful to grab el -xml_attribute bosscolors.xml name repentogon/Patches/XMLData.cpp:269 xml/bosscolors.md npc todo File "bosscolors.xml": used for the GetXByName functions, should be assigned to the color node +callback ModCallbacks MC_USE_PILL enums/ModCallbacks.md items and pools done id 10, vanilla callback REPENTOGON changes +xml_attribute achievements.xml gfxback repentogon/Patches/AchievementsStuff.cpp:184 xml/achievements.md persistent data and saves done File "achievements.xml": path of the png sprite to use as a background paper for the achievement +xml_attribute achievements.xml hidden repentogon/Patches/XMLData.cpp:1479 xml/achievements.md persistent data and saves done File "achievements.xml": any value other than 'false', preferably 'true', will make it not show the achievement popup on +xml_attribute achievements.xml name repentogon/Patches/XMLData.cpp:269 xml/achievements.md persistent data and saves done File "achievements.xml": used for the GetXByName functions (when this is not present, text is used instead) +xml_attribute babies.xml achievement repentogon/Patches/XMLData.cpp:957 xml/babies.md player done Babies: Optionally allows you to lock your baby behind an achievement (modded achievements must be specified by name). +xml_attribute babies.xml hidden repentogon/Patches/XMLData.cpp:1479 xml/babies.md player done Babies: Prevents the baby from appearing naturally. +xml_attribute babies.xml name repentogon/Patches/XMLData.cpp:269 xml/babies.md player done Babies: The name of the baby. +xml_attribute babies.xml skin xml/babies.md player done Babies: Path to the baby's spritesheet, starting from the `root` (see example below). +xml_attribute backdrops.xml name repentogon/Patches/XMLData.cpp:269 xml/backdrops.md level and room done File "backdrops.xml": The name of the custom backdrop, for use with Isaac.GetBackdropIdByName +xml_attribute backdrops.xml reftype repentogon/Patches/XMLData.cpp:615 xml/backdrops.md level and room done File "backdrops.xml": Defines the id of the backdrop to use as a base for the custom backdrop. This is useful to grab el +xml_attribute bosscolors.xml name repentogon/Patches/XMLData.cpp:269 xml/bosscolors.md npc done File "bosscolors.xml": used for the GetXByName functions, should be assigned to the color node xml_attribute challenges.xml achievements repentogon/Patches/XMLData.cpp:3443 xml/challenges.md persistent data and saves todo File "challenges.xml": Same as vanilla, comma-separated list (without spaces) of achievements required to unlock the cha xml_attribute challenges.xml hidden repentogon/Patches/XMLData.cpp:1479 xml/challenges.md persistent data and saves todo File "challenges.xml": Anything but "false" would result in a hidden challenge that wont show up in the menu xml_attribute challenges.xml lockeddesc repentogon/Patches/XMLData.cpp:1153 xml/challenges.md persistent data and saves todo File "challenges.xml": Hint to display instead of the challenge name when its locked, the default phrase is "LOCKED :(" @@ -2525,109 +2525,109 @@ xml_attribute challenges.xml startingitems repentogon/Patches/XMLData.cpp:3439 x xml_attribute challenges.xml startingitems2 repentogon/Patches/XMLData.cpp:3440 xml/challenges.md persistent data and saves todo File "challenges.xml": This now supports modded items by using the names of the items instead of the ids. Same format as xml_attribute challenges.xml startingtrinkets repentogon/Patches/XMLData.cpp:3441 xml/challenges.md persistent data and saves todo File "challenges.xml": This now supports modded trinkets by using the names of the trinkets instead of the ids. Same for xml_attribute challenges.xml unlockachievement repentogon/Patches/XMLData.cpp:3444 xml/challenges.md persistent data and saves todo File "challenges.xml": Sets the achievement(preferably a modded one using the name of the achievement) to unlock when th -xml_attribute costumes2.xml id repentogon/Patches/XMLData.cpp:250 xml/costumes.md player todo File "costumes2.xml": Assign the same "id" to a type="none" costume and a corresponding "null" item in [items.xml](items +xml_attribute costumes2.xml id repentogon/Patches/XMLData.cpp:250 xml/costumes.md player done File "costumes2.xml": Assign the same "id" to a type="none" costume and a corresponding "null" item in [items.xml](items xml_attribute costumes2.xml name repentogon/Patches/XMLData.cpp:269 xml/costumes.md player todo File "costumes2.xml": used as a general way to identify xml nodes (when this is not present, the filename of the anm2pat -xml_attribute cutscenes.xml music repentogon/Patches/XMLData.cpp:2578 xml/cutscenes.md hud and menus todo File "cutscenes.xml": used for the anm2 cutscenes, its available in vanilla but in rgon it now allows to set it to a mod -xml_attribute cutscenes.xml name repentogon/Patches/XMLData.cpp:269 xml/cutscenes.md hud and menus todo File "cutscenes.xml": used for the GetXByName functions (when this is not present, the filename of the gfx attribute is -xml_attribute edenhair.xml gfx repentogon/Patches/XMLData.cpp:450 xml/edenhair.md player todo Eden Hair: Path to the hair spritesheet, starting from the `root` (see example below). -xml_attribute entities2.xml bagofcrafting repentogon/Patches/EntityConfigEx.cpp:97 xml/entities.md entities todo File "entities2.xml": Pickups only. Space-separated list of ingredients to add to Bag of Crafting when collected, up to -xml_attribute entities2.xml boomerang repentogon/Patches/EntityConfigEx.cpp:112 xml/entities.md entities todo File "entities2.xml": Pickups only. Whether to allow this pickup to be "grabbed" by Boomerang and Jawbone. -xml_attribute entities2.xml coinvalue repentogon/Patches/EntityConfigEx.cpp:105 xml/entities.md entities todo File "entities2.xml": How much this coin pickup is worth when using GetCoinValue (either by the game or a lua call). -xml_attribute entities2.xml customtags repentogon/Patches/EntityConfigEx.cpp:89 xml/entities.md entities todo File "entities2.xml": Space-separated list of strings. See "CustomTags" section below. -xml_attribute entities2.xml isactiveenemy repentogon/Patches/EntityConfigEx.cpp:113 xml/entities.md entities todo File "entities2.xml": Whether this EntityNPC is treated as an "Active Enemy". -xml_attribute entities2.xml meleecollide repentogon/Patches/EntityConfigEx.cpp:111 xml/entities.md entities todo File "entities2.xml": Pickups only. Whether or not to trigger a collision with the player when hit with a Bone Club / Sp -xml_attribute entities2.xml nosplit repentogon/Patches/EntityConfigEx.cpp:114 xml/entities.md entities todo File "entities2.xml": Allows preventing this NPC from being split by Meat Cleaver. -xml_attribute giantbook.xml name repentogon/Patches/XMLData.cpp:269 xml/giantbook.md hud and menus todo File "giantbook.xml": used for the GetXByName functions (when this is not present, the filename of the gfx attribute is -xml_attribute items.xml achievement repentogon/Patches/XMLData.cpp:957 xml/items.md items and pools todo Items & Trinkets: Ties the item/trinket to be unlocked by an achievement. For modded achievements use the corresponding -xml_attribute items.xml activegfxpath xml/items.md items and pools todo Items & Trinkets: Path to spritesheet to use when item is in an active slot (vs as a collectible). -xml_attribute items.xml cache xml/items.md items and pools todo "Null" Items: Can be used to specify stats that should be re-evaluated when the effect of the null item is added or remo -xml_attribute items.xml cooldown xml/items.md items and pools todo "Null" Items: If set, defines how long the effect of the null item lasts, in update frames (30 frames ~= 1 second). Afte -xml_attribute items.xml damage repentogon/LuaInterfaces/ProcedualItems/LuaProceduralEffect.cpp:65 xml/items.md items and pools todo Item stats: stat attribute -xml_attribute items.xml damagemult xml/items.md items and pools todo Item stats: stat attribute -xml_attribute items.xml flatdamage xml/items.md items and pools todo Item stats: stat attribute -xml_attribute items.xml flattears xml/items.md items and pools todo Item stats: stat attribute -xml_attribute items.xml id repentogon/Patches/XMLData.cpp:250 xml/items.md items and pools todo "Null" Items: Assign the same "id" to a null item and a corresponding costume with type="none" costume in [costumes2.xml -xml_attribute items.xml luck xml/items.md items and pools todo Item stats: stat attribute -xml_attribute items.xml persistent xml/items.md items and pools todo "Null" Items: By default null item effects only last for the current room. Set persistent to true to have the effect per -xml_attribute items.xml range xml/items.md items and pools todo Item stats: stat attribute -xml_attribute items.xml shotspeed xml/items.md items and pools todo Item stats: stat attribute -xml_attribute items.xml speed xml/items.md items and pools todo Item stats: stat attribute -xml_attribute items.xml tears xml/items.md items and pools todo Item stats: stat attribute -xml_attribute items.xml tearsmult xml/items.md items and pools todo Item stats: stat attribute -xml_attribute players.xml achievement repentogon/Patches/XMLData.cpp:957 xml/players.md player todo File "players.xml": This is now respected on modded characters. For mods, it's best to define this as the *name* of the -xml_attribute players.xml blackhearts repentogon/Patches/XMLPlayerExtras.cpp:36 xml/players.md player todo File "players.xml": The amount of black hearts the character should start with. These do not replace soul hearts and are -xml_attribute players.xml bloodytears repentogon/Patches/EntityConfigEx.cpp:156 xml/players.md player todo File "players.xml": Set to true to give the player bloody tears by default, akin to Esau or Tainted Judas. -xml_attribute players.xml bonehearts repentogon/Patches/XMLPlayerExtras.cpp:23 xml/players.md player todo File "players.xml": The amount of empty bone hearts the character should start with. 1 unit = 1 bone heart -xml_attribute players.xml brokenhearts repentogon/Patches/XMLPlayerExtras.cpp:27 xml/players.md player todo File "players.xml": The amount of broken hearts the character should start with. 1 unit = 1 broken heart -xml_attribute players.xml card repentogon/Patches/XMLData.cpp:1354 xml/players.md player todo File "players.xml": This now supports a modded card by using the name of the card instead of the id. +xml_attribute cutscenes.xml music repentogon/Patches/XMLData.cpp:2578 xml/cutscenes.md hud and menus done File "cutscenes.xml": used for the anm2 cutscenes, its available in vanilla but in rgon it now allows to set it to a mod +xml_attribute cutscenes.xml name repentogon/Patches/XMLData.cpp:269 xml/cutscenes.md hud and menus done File "cutscenes.xml": used for the GetXByName functions (when this is not present, the filename of the gfx attribute is +xml_attribute edenhair.xml gfx repentogon/Patches/XMLData.cpp:450 xml/edenhair.md player done Eden Hair: Path to the hair spritesheet, starting from the `root` (see example below). +xml_attribute entities2.xml bagofcrafting repentogon/Patches/EntityConfigEx.cpp:97 xml/entities.md entities done File "entities2.xml": Pickups only. Space-separated list of ingredients to add to Bag of Crafting when collected, up to +xml_attribute entities2.xml boomerang repentogon/Patches/EntityConfigEx.cpp:112 xml/entities.md entities done File "entities2.xml": Pickups only. Whether to allow this pickup to be "grabbed" by Boomerang and Jawbone. +xml_attribute entities2.xml coinvalue repentogon/Patches/EntityConfigEx.cpp:105 xml/entities.md entities done File "entities2.xml": How much this coin pickup is worth when using GetCoinValue (either by the game or a lua call). +xml_attribute entities2.xml customtags repentogon/Patches/EntityConfigEx.cpp:89 xml/entities.md entities done File "entities2.xml": Space-separated list of strings. See "CustomTags" section below. +xml_attribute entities2.xml isactiveenemy repentogon/Patches/EntityConfigEx.cpp:113 xml/entities.md entities done File "entities2.xml": Whether this EntityNPC is treated as an "Active Enemy". +xml_attribute entities2.xml meleecollide repentogon/Patches/EntityConfigEx.cpp:111 xml/entities.md entities done File "entities2.xml": Pickups only. Whether or not to trigger a collision with the player when hit with a Bone Club / Sp +xml_attribute entities2.xml nosplit repentogon/Patches/EntityConfigEx.cpp:114 xml/entities.md entities done File "entities2.xml": Allows preventing this NPC from being split by Meat Cleaver. +xml_attribute giantbook.xml name repentogon/Patches/XMLData.cpp:269 xml/giantbook.md hud and menus done File "giantbook.xml": used for the GetXByName functions (when this is not present, the filename of the gfx attribute is +xml_attribute items.xml achievement repentogon/Patches/XMLData.cpp:957 xml/items.md items and pools done Items & Trinkets: Ties the item/trinket to be unlocked by an achievement. For modded achievements use the corresponding +xml_attribute items.xml activegfxpath xml/items.md items and pools done Items & Trinkets: Path to spritesheet to use when item is in an active slot (vs as a collectible). +xml_attribute items.xml cache xml/items.md items and pools done "Null" Items: Can be used to specify stats that should be re-evaluated when the effect of the null item is added or remo +xml_attribute items.xml cooldown xml/items.md items and pools done "Null" Items: If set, defines how long the effect of the null item lasts, in update frames (30 frames ~= 1 second). Afte +xml_attribute items.xml damage repentogon/LuaInterfaces/ProcedualItems/LuaProceduralEffect.cpp:65 xml/items.md items and pools done Item stats: stat attribute +xml_attribute items.xml damagemult xml/items.md items and pools done Item stats: stat attribute +xml_attribute items.xml flatdamage xml/items.md items and pools done Item stats: stat attribute +xml_attribute items.xml flattears xml/items.md items and pools done Item stats: stat attribute +xml_attribute items.xml id repentogon/Patches/XMLData.cpp:250 xml/items.md items and pools done "Null" Items: Assign the same "id" to a null item and a corresponding costume with type="none" costume in [costumes2.xml +xml_attribute items.xml luck xml/items.md items and pools done Item stats: stat attribute +xml_attribute items.xml persistent xml/items.md items and pools done "Null" Items: By default null item effects only last for the current room. Set persistent to true to have the effect per +xml_attribute items.xml range xml/items.md items and pools done Item stats: stat attribute +xml_attribute items.xml shotspeed xml/items.md items and pools done Item stats: stat attribute +xml_attribute items.xml speed xml/items.md items and pools done Item stats: stat attribute +xml_attribute items.xml tears xml/items.md items and pools done Item stats: stat attribute +xml_attribute items.xml tearsmult xml/items.md items and pools done Item stats: stat attribute +xml_attribute players.xml achievement repentogon/Patches/XMLData.cpp:957 xml/players.md player done File "players.xml": This is now respected on modded characters. For mods, it's best to define this as the *name* of the +xml_attribute players.xml blackhearts repentogon/Patches/XMLPlayerExtras.cpp:36 xml/players.md player done File "players.xml": The amount of black hearts the character should start with. These do not replace soul hearts and are +xml_attribute players.xml bloodytears repentogon/Patches/EntityConfigEx.cpp:156 xml/players.md player done File "players.xml": Set to true to give the player bloody tears by default, akin to Esau or Tainted Judas. +xml_attribute players.xml bonehearts repentogon/Patches/XMLPlayerExtras.cpp:23 xml/players.md player done File "players.xml": The amount of empty bone hearts the character should start with. 1 unit = 1 bone heart +xml_attribute players.xml brokenhearts repentogon/Patches/XMLPlayerExtras.cpp:27 xml/players.md player done File "players.xml": The amount of broken hearts the character should start with. 1 unit = 1 broken heart +xml_attribute players.xml card repentogon/Patches/XMLData.cpp:1354 xml/players.md player done File "players.xml": This now supports a modded card by using the name of the card instead of the id. xml_attribute players.xml completionparent repentogon/Patches/CompletionTracker.cpp:723 xml/players.md player todo File "players.xml": Used for characters that have shared completion marks with a preexistent character, like Dark Judas -xml_attribute players.xml damagemodifier xml/players.md player todo File "players.xml": An inherent offset to the damage stat the character should start with. Base this offset off of Isaac -xml_attribute players.xml damagemultiplier xml/players.md player todo File "players.xml": Assigns a character damage multiplier, akin to those of Judas (1.35), Azazel (1.5), or Eve (0.75). N -xml_attribute players.xml deathsound repentogon/Patches/ASMPatches/ASMPlayer.cpp:121 xml/players.md player todo File "players.xml": Set this to define a death sound for the character whenever they would die or touch a White Fireplac -xml_attribute players.xml eternalheart repentogon/Patches/XMLPlayerExtras.cpp:25 xml/players.md player todo File "players.xml": If a character should start with an eternal heart. 1 = yes -xml_attribute players.xml flying repentogon/Patches/EntityConfigEx.cpp:165 xml/players.md player todo File "players.xml": Set to true to grant the player "flying" by default, like Azazel. Note that this does not provide a -xml_attribute players.xml gigabombs repentogon/Patches/XMLPlayerExtras.cpp:45 xml/players.md player todo File "players.xml": The amount of giga bombs the character should start with. These do not replace normal bombs. -xml_attribute players.xml goldenhearts repentogon/Patches/XMLPlayerExtras.cpp:26 xml/players.md player todo File "players.xml": The amount of golden hearts the character should start with. 1 unit = 1 golden heart -xml_attribute players.xml healthlimit repentogon/Patches/XMLPlayerExtras.cpp:59 xml/players.md player todo File "players.xml": A maximum amount of HP the character should be able to have. 1 unit = 1/2 heart -xml_attribute players.xml healthtype repentogon/LuaInterfaces/CustomCallbacks.cpp:1579 xml/players.md player todo File "players.xml": The health type the player should start with. The int corresponds to the [HealthType](../enums/Healt -xml_attribute players.xml heartcontainers repentogon/Patches/XMLPlayerExtras.cpp:21 xml/players.md player todo File "players.xml": The amount of empty heart containers the character should start with. 1 unit = 1/2 a heart -xml_attribute players.xml hideachievement repentogon/Patches/XMLData.cpp:957 xml/players.md player todo File "players.xml": Hides the character from the menu until this achievement is earned. Must be used on the non-tainted -xml_attribute players.xml hurtsound repentogon/Patches/ASMPatches/ASMPlayer.cpp:84 xml/players.md player todo File "players.xml": Set this to define a hurt sound for the character whenever they would take damage. -xml_attribute players.xml innateitems repentogon/Patches/ItemSpoofSystem.cpp:143 xml/players.md player todo File "players.xml": Same as `items`, but innate to the character -xml_attribute players.xml innatetrinkets repentogon/Patches/ItemSpoofSystem.cpp:144 xml/players.md player todo File "players.xml": Trinket effects innate to the character. Comma separated list of ids or names -xml_attribute players.xml items repentogon/Patches/XMLData.cpp:3431 xml/players.md player todo File "players.xml": This now supports modded items by using the names of the items instead of the ids. Same format as in -xml_attribute players.xml luckmodifier xml/players.md player todo File "players.xml": An inherent offset to the luck stat the character should start with. Base this offset off of Isaac's -xml_attribute players.xml modcostume repentogon/Patches/NullItemsAndCostumes.cpp:13 xml/players.md player todo File "players.xml": Set this to match the "id" attribute of a costume with type="none" defined in the same mod (in [cost +xml_attribute players.xml damagemodifier xml/players.md player done File "players.xml": An inherent offset to the damage stat the character should start with. Base this offset off of Isaac +xml_attribute players.xml damagemultiplier xml/players.md player done File "players.xml": Assigns a character damage multiplier, akin to those of Judas (1.35), Azazel (1.5), or Eve (0.75). N +xml_attribute players.xml deathsound repentogon/Patches/ASMPatches/ASMPlayer.cpp:121 xml/players.md player done File "players.xml": Set this to define a death sound for the character whenever they would die or touch a White Fireplac +xml_attribute players.xml eternalheart repentogon/Patches/XMLPlayerExtras.cpp:25 xml/players.md player done File "players.xml": If a character should start with an eternal heart. 1 = yes +xml_attribute players.xml flying repentogon/Patches/EntityConfigEx.cpp:165 xml/players.md player done File "players.xml": Set to true to grant the player "flying" by default, like Azazel. Note that this does not provide a +xml_attribute players.xml gigabombs repentogon/Patches/XMLPlayerExtras.cpp:45 xml/players.md player done File "players.xml": The amount of giga bombs the character should start with. These do not replace normal bombs. +xml_attribute players.xml goldenhearts repentogon/Patches/XMLPlayerExtras.cpp:26 xml/players.md player done File "players.xml": The amount of golden hearts the character should start with. 1 unit = 1 golden heart +xml_attribute players.xml healthlimit repentogon/Patches/XMLPlayerExtras.cpp:59 xml/players.md player done File "players.xml": A maximum amount of HP the character should be able to have. 1 unit = 1/2 heart +xml_attribute players.xml healthtype repentogon/LuaInterfaces/CustomCallbacks.cpp:1579 xml/players.md player done File "players.xml": The health type the player should start with. The int corresponds to the [HealthType](../enums/Healt +xml_attribute players.xml heartcontainers repentogon/Patches/XMLPlayerExtras.cpp:21 xml/players.md player done File "players.xml": The amount of empty heart containers the character should start with. 1 unit = 1/2 a heart +xml_attribute players.xml hideachievement repentogon/Patches/XMLData.cpp:957 xml/players.md player done File "players.xml": Hides the character from the menu until this achievement is earned. Must be used on the non-tainted +xml_attribute players.xml hurtsound repentogon/Patches/ASMPatches/ASMPlayer.cpp:84 xml/players.md player done File "players.xml": Set this to define a hurt sound for the character whenever they would take damage. +xml_attribute players.xml innateitems repentogon/Patches/ItemSpoofSystem.cpp:143 xml/players.md player done File "players.xml": Same as `items`, but innate to the character +xml_attribute players.xml innatetrinkets repentogon/Patches/ItemSpoofSystem.cpp:144 xml/players.md player done File "players.xml": Trinket effects innate to the character. Comma separated list of ids or names +xml_attribute players.xml items repentogon/Patches/XMLData.cpp:3431 xml/players.md player done File "players.xml": This now supports modded items by using the names of the items instead of the ids. Same format as in +xml_attribute players.xml luckmodifier xml/players.md player done File "players.xml": An inherent offset to the luck stat the character should start with. Base this offset off of Isaac's +xml_attribute players.xml modcostume repentogon/Patches/NullItemsAndCostumes.cpp:13 xml/players.md player done File "players.xml": Set this to match the "id" attribute of a costume with type="none" defined in the same mod (in [cost xml_attribute players.xml nomarks repentogon/Patches/CompletionTracker.cpp:764 xml/players.md player todo File "players.xml": If it has any value other than 'false', it will hide the completion marks for the given character -xml_attribute players.xml noshake repentogon/Patches/EntityConfigEx.cpp:145 xml/players.md player todo File "players.xml": Will prevent character's shaking during stage/boss screen transition (similarly to Keeper) if set to -xml_attribute players.xml rangemodifier xml/players.md player todo File "players.xml": An inherent offset to the range stat the character should start with. Base this offset off of Isaac' -xml_attribute players.xml redhearts repentogon/Patches/XMLPlayerExtras.cpp:22 xml/players.md player todo File "players.xml": The amount of red hearts the character should start with. 1 unit = 1/2 a heart -xml_attribute players.xml rottenhearts repentogon/Patches/XMLPlayerExtras.cpp:40 xml/players.md player todo File "players.xml": The amount of rotten hearts the character should start with. 1 unit = 1 rotten heart -xml_attribute players.xml shotspeedmodifier xml/players.md player todo File "players.xml": An inherent offset to the shot speed stat the character should start with. Base this offset off of I -xml_attribute players.xml soulhearts repentogon/Patches/XMLPlayerExtras.cpp:24 xml/players.md player todo File "players.xml": The amount of soul hearts the character should start with. 1 unit = 1/2 a heart -xml_attribute players.xml speedmodifier xml/players.md player todo File "players.xml": An inherent offset to the speed stat the character should start with. Base this offset off of Isaac' -xml_attribute players.xml tearsmodifier repentogon/Patches/EntityConfigEx.cpp:119 xml/players.md player todo File "players.xml": An inherent offset to the tears stat the character should start with. Base this offset off of Isaac' -xml_attribute players.xml tearsmultiplier xml/players.md player todo File "players.xml": Assigns a character tears multiplier, akin to those of Azazel (0.267) or Tainted Eve (0.66). -xml_attribute players.xml trinket repentogon/Patches/XMLData.cpp:1085 xml/players.md player todo File "players.xml": This now supports a modded trinket by using the name of the trinket instead of the id. -xml_attribute pocketitems.xml achievement repentogon/Patches/XMLData.cpp:957 xml/pocketitems.md items and pools todo Cards & Pill Effects: Ties the card/pill-effect to be unlocked by an achievement. For modded ones, use the provided achi -xml_attribute pocketitems.xml announcer repentogon/Patches/ItemConfigEx.cpp:445 xml/pocketitems.md items and pools todo Cards: Now allows modded sounds to be specified using their name. -xml_attribute pocketitems.xml announcer2 repentogon/Patches/ItemConfigEx.cpp:465 xml/pocketitems.md items and pools todo Cards & Pill Effects: Now allows modded sounds to be specified using their name (for ref, this is the Horse Pills line). -xml_attribute pocketitems.xml hidden repentogon/Patches/XMLData.cpp:1479 xml/pocketitems.md items and pools todo Cards: `Optional` `Default = false` Prevents the card from being randomly chosen by the game or when using the [ItemPool -xml_attribute pocketitems.xml weight repentogon/LuaInterfaces/LuaBossPool.cpp:45 xml/pocketitems.md items and pools todo Cards: `Optional` `Default = 1.0` Relative "likelihood" for this card to be chosen over others of the same [card type](h -xml_tag achievements.xml achievements.xml xml/achievements.md persistent data and saves todo file: content and resources support -xml_tag ambush.xml ambush.xml xml/ambush.md level and room todo file: content and resources support -xml_tag babies.xml babies xml/babies.md player todo tag in the docs' examples -xml_tag babies.xml babies.xml xml/babies.md player todo file: content and resources support -xml_tag babies.xml baby xml/babies.md player todo tag in the docs' examples -xml_tag backdrops.xml backdrop repentogon/Patches/XMLData.cpp:1991 xml/backdrops.md level and room todo tag in the docs' examples -xml_tag backdrops.xml backdrops xml/backdrops.md level and room todo tag in the docs' examples -xml_tag backdrops.xml backdrops.xml xml/backdrops.md level and room todo file: content and resources support -xml_tag bosscolors.xml bosscolors.xml xml/bosscolors.md npc todo file: content and resources support +xml_attribute players.xml noshake repentogon/Patches/EntityConfigEx.cpp:145 xml/players.md player done File "players.xml": Will prevent character's shaking during stage/boss screen transition (similarly to Keeper) if set to +xml_attribute players.xml rangemodifier xml/players.md player done File "players.xml": An inherent offset to the range stat the character should start with. Base this offset off of Isaac' +xml_attribute players.xml redhearts repentogon/Patches/XMLPlayerExtras.cpp:22 xml/players.md player done File "players.xml": The amount of red hearts the character should start with. 1 unit = 1/2 a heart +xml_attribute players.xml rottenhearts repentogon/Patches/XMLPlayerExtras.cpp:40 xml/players.md player done File "players.xml": The amount of rotten hearts the character should start with. 1 unit = 1 rotten heart +xml_attribute players.xml shotspeedmodifier xml/players.md player done File "players.xml": An inherent offset to the shot speed stat the character should start with. Base this offset off of I +xml_attribute players.xml soulhearts repentogon/Patches/XMLPlayerExtras.cpp:24 xml/players.md player done File "players.xml": The amount of soul hearts the character should start with. 1 unit = 1/2 a heart +xml_attribute players.xml speedmodifier xml/players.md player done File "players.xml": An inherent offset to the speed stat the character should start with. Base this offset off of Isaac' +xml_attribute players.xml tearsmodifier repentogon/Patches/EntityConfigEx.cpp:119 xml/players.md player done File "players.xml": An inherent offset to the tears stat the character should start with. Base this offset off of Isaac' +xml_attribute players.xml tearsmultiplier xml/players.md player done File "players.xml": Assigns a character tears multiplier, akin to those of Azazel (0.267) or Tainted Eve (0.66). +xml_attribute players.xml trinket repentogon/Patches/XMLData.cpp:1085 xml/players.md player done File "players.xml": This now supports a modded trinket by using the name of the trinket instead of the id. +xml_attribute pocketitems.xml achievement repentogon/Patches/XMLData.cpp:957 xml/pocketitems.md items and pools done Cards & Pill Effects: Ties the card/pill-effect to be unlocked by an achievement. For modded ones, use the provided achi +xml_attribute pocketitems.xml announcer repentogon/Patches/ItemConfigEx.cpp:445 xml/pocketitems.md items and pools done Cards: Now allows modded sounds to be specified using their name. +xml_attribute pocketitems.xml announcer2 repentogon/Patches/ItemConfigEx.cpp:465 xml/pocketitems.md items and pools done Cards & Pill Effects: Now allows modded sounds to be specified using their name (for ref, this is the Horse Pills line). +xml_attribute pocketitems.xml hidden repentogon/Patches/XMLData.cpp:1479 xml/pocketitems.md items and pools done Cards: `Optional` `Default = false` Prevents the card from being randomly chosen by the game or when using the [ItemPool +xml_attribute pocketitems.xml weight repentogon/LuaInterfaces/LuaBossPool.cpp:45 xml/pocketitems.md items and pools done Cards: `Optional` `Default = 1.0` Relative "likelihood" for this card to be chosen over others of the same [card type](h +xml_tag achievements.xml achievements.xml xml/achievements.md persistent data and saves done file: content and resources support +xml_tag ambush.xml ambush.xml xml/ambush.md level and room done file: content and resources support +xml_tag babies.xml babies xml/babies.md player done tag in the docs' examples +xml_tag babies.xml babies.xml xml/babies.md player done file: content and resources support +xml_tag babies.xml baby xml/babies.md player done tag in the docs' examples +xml_tag backdrops.xml backdrop repentogon/Patches/XMLData.cpp:1991 xml/backdrops.md level and room done tag in the docs' examples +xml_tag backdrops.xml backdrops xml/backdrops.md level and room done tag in the docs' examples +xml_tag backdrops.xml backdrops.xml xml/backdrops.md level and room done file: content and resources support +xml_tag bosscolors.xml bosscolors.xml xml/bosscolors.md npc done file: content and resources support xml_tag challenges.xml challenges.xml xml/challenges.md persistent data and saves todo file: content and resources support -xml_tag costumes2.xml costumes2.xml xml/costumes.md player todo file: content and resources support -xml_tag cutscenes.xml cutscenes.xml xml/cutscenes.md hud and menus todo file: content and resources support -xml_tag edenhair.xml edenhair repentogon/Patches/EntityConfigEx.cpp:201 xml/edenhair.md player todo tag in the docs' examples -xml_tag edenhair.xml edenhair.xml xml/edenhair.md player todo file: content and resources support -xml_tag edenhair.xml hair repentogon/Patches/EntityConfigEx.cpp:201 xml/edenhair.md player todo tag in the docs' examples -xml_tag entities2.xml entities2.xml xml/entities.md entities todo file: content and resources support -xml_tag giantbook.xml giantbook.xml xml/giantbook.md hud and menus todo file: content and resources support +xml_tag costumes2.xml costumes2.xml xml/costumes.md player done file: content and resources support +xml_tag cutscenes.xml cutscenes.xml xml/cutscenes.md hud and menus done file: content and resources support +xml_tag edenhair.xml edenhair repentogon/Patches/EntityConfigEx.cpp:201 xml/edenhair.md player done tag in the docs' examples +xml_tag edenhair.xml edenhair.xml xml/edenhair.md player done file: content and resources support +xml_tag edenhair.xml hair repentogon/Patches/EntityConfigEx.cpp:201 xml/edenhair.md player done tag in the docs' examples +xml_tag entities2.xml entities2.xml xml/entities.md entities done file: content and resources support +xml_tag giantbook.xml giantbook.xml xml/giantbook.md hud and menus done file: content and resources support xml_tag itempools.xml itempools.xml xml/itempools.md items and pools todo file: content and resources support -xml_tag items.xml items.xml xml/items.md items and pools todo file: content and resources support -xml_tag items.xml null repentogon/Patches/XMLData.cpp:998 xml/items.md items and pools todo tag in the docs' examples -xml_tag items.xml passive repentogon/Patches/XMLData.cpp:1369 xml/items.md items and pools todo tag in the docs' examples -xml_tag items.xml trinket repentogon/Patches/XMLData.cpp:1085 xml/items.md items and pools todo tag in the docs' examples -xml_tag players.xml players.xml xml/players.md player todo file: content and resources support -xml_tag pocketitems.xml pocketitems.xml xml/pocketitems.md items and pools todo file: content and resources support -xml_tag stringtable.sta category repentogon/Patches/XMLData.cpp:2864 xml/stringtable.md hud and menus todo tag in the docs' examples -xml_tag stringtable.sta challenge repentogon/Patches/ConsoleHooks.cpp:174 xml/stringtable.md hud and menus todo tag in the docs' examples -xml_tag stringtable.sta info repentogon/Patches/XMLData.cpp:2975 xml/stringtable.md hud and menus todo tag in the docs' examples -xml_tag stringtable.sta key repentogon/Patches/XMLData.cpp:2873 xml/stringtable.md hud and menus todo tag in the docs' examples -xml_tag stringtable.sta language xml/stringtable.md hud and menus todo tag in the docs' examples -xml_tag stringtable.sta languages xml/stringtable.md hud and menus todo tag in the docs' examples -xml_tag stringtable.sta passive repentogon/Patches/XMLData.cpp:1369 xml/stringtable.md hud and menus todo tag in the docs' examples -xml_tag stringtable.sta string repentogon/Patches/XMLData.cpp:2885 xml/stringtable.md hud and menus todo tag in the docs' examples -xml_tag stringtable.sta stringtable repentogon/Patches/XMLData.cpp:2971 xml/stringtable.md hud and menus todo tag in the docs' examples -xml_tag stringtable.sta stringtable.sta xml/stringtable.md hud and menus todo file: content and resources support +xml_tag items.xml items.xml xml/items.md items and pools done file: content and resources support +xml_tag items.xml null repentogon/Patches/XMLData.cpp:998 xml/items.md items and pools done tag in the docs' examples +xml_tag items.xml passive repentogon/Patches/XMLData.cpp:1369 xml/items.md items and pools done tag in the docs' examples +xml_tag items.xml trinket repentogon/Patches/XMLData.cpp:1085 xml/items.md items and pools done tag in the docs' examples +xml_tag players.xml players.xml xml/players.md player done file: content and resources support +xml_tag pocketitems.xml pocketitems.xml xml/pocketitems.md items and pools done file: content and resources support +xml_tag stringtable.sta category repentogon/Patches/XMLData.cpp:2864 xml/stringtable.md hud and menus done tag in the docs' examples +xml_tag stringtable.sta challenge repentogon/Patches/ConsoleHooks.cpp:174 xml/stringtable.md hud and menus done tag in the docs' examples +xml_tag stringtable.sta info repentogon/Patches/XMLData.cpp:2975 xml/stringtable.md hud and menus done tag in the docs' examples +xml_tag stringtable.sta key repentogon/Patches/XMLData.cpp:2873 xml/stringtable.md hud and menus done tag in the docs' examples +xml_tag stringtable.sta language xml/stringtable.md hud and menus done tag in the docs' examples +xml_tag stringtable.sta languages xml/stringtable.md hud and menus done tag in the docs' examples +xml_tag stringtable.sta passive repentogon/Patches/XMLData.cpp:1369 xml/stringtable.md hud and menus done tag in the docs' examples +xml_tag stringtable.sta string repentogon/Patches/XMLData.cpp:2885 xml/stringtable.md hud and menus done tag in the docs' examples +xml_tag stringtable.sta stringtable repentogon/Patches/XMLData.cpp:2971 xml/stringtable.md hud and menus done tag in the docs' examples +xml_tag stringtable.sta stringtable.sta xml/stringtable.md hud and menus done file: content and resources support enum enums_ex.lua Achievement repentogon/resources/scripts/enums_ex.lua:941 enums/Achievement.md persistent data and saves done new enum enum enums_ex.lua AddHealthType repentogon/resources/scripts/enums_ex.lua:573 enums/AddHealthType.md misc done new enum enum enums_ex.lua AltRockType repentogon/resources/scripts/enums_ex.lua:3254 enums/AltRockType.md misc done new enum @@ -2766,70 +2766,70 @@ option internal RenderDebugFindInRadius repentogon/REPENTOGONOptions.h:68 conso option internal SkipArchiveChecks repentogon/REPENTOGONOptions.h:67 misc done options.ini option internal UnifontRenderMode repentogon/REPENTOGONOptions.h:63 console and debug done options.ini behaviour_patch Patches ASMPatches.cpp repentogon/Patches/ASMPatches.cpp:1 console and debug todo Applies every byte patch at startup: log and console routing, mod and save folders moved to REPENTOGON's data folder -behaviour_patch Patches ASMPatches/ASMBagOfCrafting.cpp repentogon/Patches/ASMPatches/ASMBagOfCrafting.cpp:1 items and pools todo Bag of Crafting pickup adds: MC_TRY_ADD_TO_BAG_OF_CRAFTING and modded pickups +behaviour_patch Patches ASMPatches/ASMBagOfCrafting.cpp repentogon/Patches/ASMPatches/ASMBagOfCrafting.cpp:1 items and pools done Bag of Crafting pickup adds: MC_TRY_ADD_TO_BAG_OF_CRAFTING and modded pickups behaviour_patch Patches ASMPatches/ASMCallbacks.cpp repentogon/Patches/ASMPatches/ASMCallbacks.cpp:1 misc started Inline patches firing the callbacks a hook cannot reach (pause, HUD messages, room placement, NPC removal and many more) -behaviour_patch Patches ASMPatches/ASMCamera.cpp repentogon/Patches/ASMPatches/ASMCamera.cpp:1 level and room todo Keeps the room's single Camera alive for Lua and restores it on destruction -behaviour_patch Patches ASMPatches/ASMDelirium.cpp repentogon/Patches/ASMPatches/ASMDelirium.cpp:1 npc todo Delirium transformation callbacks (pre, transform, post) -behaviour_patch Patches ASMPatches/ASMEntityKnife.cpp repentogon/Patches/ASMPatches/ASMEntityKnife.cpp:1 tear and weapons todo Melee knife hitbox initialisation -behaviour_patch Patches ASMPatches/ASMEntityNPC.cpp repentogon/Patches/ASMPatches/ASMEntityNPC.cpp:1 npc todo NPC speed and active enemy checks driven by entity config -behaviour_patch Patches ASMPatches/ASMFixes.cpp repentogon/Patches/ASMPatches/ASMFixes.cpp:1 misc todo Vanilla bug fixes: modded crafting quality, smelted trinkets, pill identification and effects, game state load, render target overflow, familiar pathing -behaviour_patch Patches ASMPatches/ASMGridEntityCollision.cpp repentogon/Patches/ASMPatches/ASMGridEntityCollision.cpp:1 level and room started Grid collision callbacks, deduplicated per frame and grid index -behaviour_patch Patches ASMPatches/ASMGridEntitySpawn.cpp repentogon/Patches/ASMPatches/ASMGridEntitySpawn.cpp:1 level and room todo Routes inlined grid spawns through MC_PRE/POST_GRID_ENTITY_SPAWN -behaviour_patch Patches ASMPatches/ASMGridEntitySpawn_Definitions.cpp repentogon/Patches/ASMPatches/ASMGridEntitySpawn_Definitions.cpp:1 level and room todo Signature table of the inlined grid spawn sites -behaviour_patch Patches ASMPatches/ASMHud.cpp repentogon/Patches/ASMPatches/ASMHud.cpp:1 hud and menus todo HistoryHUD render and recompute callbacks, smelted item images +behaviour_patch Patches ASMPatches/ASMCamera.cpp repentogon/Patches/ASMPatches/ASMCamera.cpp:1 level and room done Keeps the room's single Camera alive for Lua and restores it on destruction +behaviour_patch Patches ASMPatches/ASMDelirium.cpp repentogon/Patches/ASMPatches/ASMDelirium.cpp:1 npc done Delirium transformation callbacks (pre, transform, post) +behaviour_patch Patches ASMPatches/ASMEntityKnife.cpp repentogon/Patches/ASMPatches/ASMEntityKnife.cpp:1 tear and weapons done Melee knife hitbox initialisation +behaviour_patch Patches ASMPatches/ASMEntityNPC.cpp repentogon/Patches/ASMPatches/ASMEntityNPC.cpp:1 npc done NPC speed and active enemy checks driven by entity config +behaviour_patch Patches ASMPatches/ASMFixes.cpp repentogon/Patches/ASMPatches/ASMFixes.cpp:1 misc started Vanilla bug fixes: modded crafting quality, smelted trinkets, pill identification and effects, game state load, render target overflow, familiar pathing +behaviour_patch Patches ASMPatches/ASMGridEntityCollision.cpp repentogon/Patches/ASMPatches/ASMGridEntityCollision.cpp:1 level and room done Grid collision callbacks, deduplicated per frame and grid index +behaviour_patch Patches ASMPatches/ASMGridEntitySpawn.cpp repentogon/Patches/ASMPatches/ASMGridEntitySpawn.cpp:1 level and room done Routes inlined grid spawns through MC_PRE/POST_GRID_ENTITY_SPAWN +behaviour_patch Patches ASMPatches/ASMGridEntitySpawn_Definitions.cpp repentogon/Patches/ASMPatches/ASMGridEntitySpawn_Definitions.cpp:1 level and room done Signature table of the inlined grid spawn sites +behaviour_patch Patches ASMPatches/ASMHud.cpp repentogon/Patches/ASMPatches/ASMHud.cpp:1 hud and menus done HistoryHUD render and recompute callbacks, smelted item images behaviour_patch Patches ASMPatches/ASMLevel.cpp repentogon/Patches/ASMPatches/ASMLevel.cpp:1 level and room started Custom stage ids, level generation and room placement callbacks, stage binaries -behaviour_patch Patches ASMPatches/ASMLocalization.cpp repentogon/Patches/ASMPatches/ASMLocalization.cpp:1 hud and menus todo Localised resource lookup in archives with an English fallback -behaviour_patch Patches ASMPatches/ASMMenu.cpp repentogon/Patches/ASMPatches/ASMMenu.cpp:1 hud and menus todo Mods menu font, language change from options, online and daily menu selection -behaviour_patch Patches ASMPatches/ASMPlayer.cpp repentogon/Patches/ASMPatches/ASMPlayer.cpp:1 player todo Familiar checks, Mars double tap window, active charge, custom hurt and death sounds, Lost Soul puddle +behaviour_patch Patches ASMPatches/ASMLocalization.cpp repentogon/Patches/ASMPatches/ASMLocalization.cpp:1 hud and menus started Localised resource lookup in archives with an English fallback +behaviour_patch Patches ASMPatches/ASMMenu.cpp repentogon/Patches/ASMPatches/ASMMenu.cpp:1 hud and menus started Mods menu font, language change from options, online and daily menu selection +behaviour_patch Patches ASMPatches/ASMPlayer.cpp repentogon/Patches/ASMPatches/ASMPlayer.cpp:1 player started Familiar checks, Mars double tap window, active charge, custom hurt and death sounds, Lost Soul puddle behaviour_patch Patches ASMPatches/ASMPlayerManager.cpp repentogon/Patches/ASMPatches/ASMPlayerManager.cpp:1 player todo Controller reassignment on restore and disconnect -behaviour_patch Patches ASMPatches/ASMRender.cpp repentogon/Patches/ASMPatches/ASMRender.cpp:1 hud and menus todo Planetarium chance on the stat HUD (option) -behaviour_patch Patches ASMPatches/ASMRoom.cpp repentogon/Patches/ASMPatches/ASMRoom.cpp:1 level and room todo Ambush wave count, boss wave difficulty, Mega Satan ending, water, room save state, clear delay, Blue Womb door -behaviour_patch Patches ASMPatches/ASMSplitTears.cpp repentogon/Patches/ASMPatches/ASMSplitTears.cpp:1 tear and weapons todo MC_POST_FIRE_SPLIT_TEAR for every tear split -behaviour_patch Patches ASMPatches/ASMStatusEffects.cpp repentogon/Patches/ASMPatches/ASMStatusEffects.cpp:1 entities todo Status effect targets and Weakness for custom status effects -behaviour_patch Patches ASMPatches/ASMTweaks.cpp repentogon/Patches/ASMPatches/ASMTweaks.cpp:1 misc todo Small tweaks: Godhead partition, Tear Detonator, Hush veins, archive checksums, console online, resource paths, exit prompt, music bound, language -behaviour_patch Patches AchievementsStuff.cpp repentogon/Patches/AchievementsStuff.cpp:1 persistent data and saves todo Modded achievements: XML, saving, popups, lockachievement, Isaac.GetAchievementIdByName +behaviour_patch Patches ASMPatches/ASMRender.cpp repentogon/Patches/ASMPatches/ASMRender.cpp:1 hud and menus done Planetarium chance on the stat HUD (option) +behaviour_patch Patches ASMPatches/ASMRoom.cpp repentogon/Patches/ASMPatches/ASMRoom.cpp:1 level and room done Ambush wave count, boss wave difficulty, Mega Satan ending, water, room save state, clear delay, Blue Womb door +behaviour_patch Patches ASMPatches/ASMSplitTears.cpp repentogon/Patches/ASMPatches/ASMSplitTears.cpp:1 tear and weapons done MC_POST_FIRE_SPLIT_TEAR for every tear split +behaviour_patch Patches ASMPatches/ASMStatusEffects.cpp repentogon/Patches/ASMPatches/ASMStatusEffects.cpp:1 entities done Status effect targets and Weakness for custom status effects +behaviour_patch Patches ASMPatches/ASMTweaks.cpp repentogon/Patches/ASMPatches/ASMTweaks.cpp:1 misc started Small tweaks: Godhead partition, Tear Detonator, Hush veins, archive checksums, console online, resource paths, exit prompt, music bound, language +behaviour_patch Patches AchievementsStuff.cpp repentogon/Patches/AchievementsStuff.cpp:1 persistent data and saves started Modded achievements: XML, saving, popups, lockachievement, Isaac.GetAchievementIdByName behaviour_patch Patches Anm2Extras.cpp repentogon/Patches/Anm2Extras.cpp:1 render and sprites todo Per ANM2 and per layer extras: shaders and render flags -behaviour_patch Patches CardsExtras.cpp repentogon/Patches/CardsExtras.cpp:1 items and pools todo Card XML extras: availability conditions, hidden cards, weights in GetCard +behaviour_patch Patches CardsExtras.cpp repentogon/Patches/CardsExtras.cpp:1 items and pools done Card XML extras: availability conditions, hidden cards, weights in GetCard behaviour_patch Patches ChallengesStuff.cpp repentogon/Patches/ChallengesStuff.cpp:1 persistent data and saves todo Modded challenge completion, saving and menus behaviour_patch Patches CompletionTracker.cpp repentogon/Patches/CompletionTracker.cpp:1 persistent data and saves todo Completion marks for modded characters: saving, the character menu and Isaac's completion functions -behaviour_patch Patches ConsoleHooks.cpp repentogon/Patches/ConsoleHooks.cpp:1 console and debug todo Console: REPENTOGON branding, command history kept on crash, new commands, autocomplete -behaviour_patch Patches CustomCache.cpp repentogon/Patches/CustomCache.cpp:1 items and pools todo Custom cache flags (customcache XML) evaluated on item, trinket and effect changes -behaviour_patch Patches CustomDevilPlanetariumChance.cpp repentogon/Patches/CustomDevilPlanetariumChance.cpp:1 items and pools todo Devil and planetarium chance split into callback steps -behaviour_patch Patches CustomModManager.cpp repentogon/Patches/CustomModManager.cpp:1 misc todo Per mod curses and mod entry extras -behaviour_patch Patches CutsceneSkip.cpp repentogon/Patches/CutsceneSkip.cpp:1 hud and menus todo Cutscenes skippable with input +behaviour_patch Patches ConsoleHooks.cpp repentogon/Patches/ConsoleHooks.cpp:1 console and debug started Console: REPENTOGON branding, command history kept on crash, new commands, autocomplete +behaviour_patch Patches CustomCache.cpp repentogon/Patches/CustomCache.cpp:1 items and pools done Custom cache flags (customcache XML) evaluated on item, trinket and effect changes +behaviour_patch Patches CustomDevilPlanetariumChance.cpp repentogon/Patches/CustomDevilPlanetariumChance.cpp:1 items and pools done Devil and planetarium chance split into callback steps +behaviour_patch Patches CustomModManager.cpp repentogon/Patches/CustomModManager.cpp:1 misc done Per mod curses and mod entry extras +behaviour_patch Patches CutsceneSkip.cpp repentogon/Patches/CutsceneSkip.cpp:1 hud and menus done Cutscenes skippable with input behaviour_patch Patches EntityConfigEx.cpp repentogon/Patches/EntityConfigEx.cpp:1 entities todo entities2.xml extras: tags, erased enemies, Jera and reroll flags, familiar buddies -behaviour_patch Patches EntityManager.cpp repentogon/Patches/EntityManager.cpp:1 entities todo Entity lifetime tracking: factory, list reset, removal +behaviour_patch Patches EntityManager.cpp repentogon/Patches/EntityManager.cpp:1 entities started Entity lifetime tracking: factory, list reset, removal behaviour_patch Patches EntityPlus.cpp repentogon/Patches/EntityPlus.cpp:1 entities todo Extra per entity data: water clip, flying override, init and remove -behaviour_patch Patches EvaluateStats.cpp repentogon/Patches/EvaluateStats.cpp:1 items and pools todo XML item stats (tears, damage, range ...) applied at the vanilla steps of EvaluateItems -behaviour_patch Patches ExtraDebugRender.cpp repentogon/Patches/ExtraDebugRender.cpp:1 console and debug todo Draws FindInRadius and capsule queries (debug option) -behaviour_patch Patches ExtraLives.cpp repentogon/Patches/ExtraLives.cpp:1 player started Custom extra lives and revives, MC_PRE_TRIGGER_PLAYER_DEATH -behaviour_patch Patches ExtraRenderSteps.cpp repentogon/Patches/ExtraRenderSteps.cpp:1 render and sprites todo Cursor initialised and rendered for the mouse control option -behaviour_patch Patches FamiliarTags.cpp repentogon/Patches/FamiliarTags.cpp:1 familiar todo Familiar XML tags: damageable, blocks projectiles, charmable +behaviour_patch Patches EvaluateStats.cpp repentogon/Patches/EvaluateStats.cpp:1 items and pools done XML item stats (tears, damage, range ...) applied at the vanilla steps of EvaluateItems +behaviour_patch Patches ExtraDebugRender.cpp repentogon/Patches/ExtraDebugRender.cpp:1 console and debug done Draws FindInRadius and capsule queries (debug option) +behaviour_patch Patches ExtraLives.cpp repentogon/Patches/ExtraLives.cpp:1 player done Custom extra lives and revives, MC_PRE_TRIGGER_PLAYER_DEATH +behaviour_patch Patches ExtraRenderSteps.cpp repentogon/Patches/ExtraRenderSteps.cpp:1 render and sprites done Cursor initialised and rendered for the mouse control option +behaviour_patch Patches FamiliarTags.cpp repentogon/Patches/FamiliarTags.cpp:1 familiar done Familiar XML tags: damageable, blocks projectiles, charmable behaviour_patch Patches GetCoinValue.cpp repentogon/Patches/GetCoinValue.cpp:1 pickup todo Custom coin values, MC_PICKUP_GET_COIN_VALUE -behaviour_patch Patches GridEntityPlus.cpp repentogon/Patches/GridEntityPlus.cpp:1 level and room todo Extra per grid entity data and water clip -behaviour_patch Patches ImagePatches.cpp repentogon/Patches/ImagePatches.cpp:1 render and sprites todo Transparent render batch reuse fixes -behaviour_patch Patches Init.cpp repentogon/Patches/Init.cpp:1 misc todo Starts REPENTOGON's systems in Manager::Init -behaviour_patch Patches InterpolV2.cpp repentogon/Patches/InterpolV2.cpp:1 render and sprites todo Interpolated rendering between updates (option) -behaviour_patch Patches ItemConfigEx.cpp repentogon/Patches/ItemConfigEx.cpp:1 items and pools todo items.xml extras and custom item sounds +behaviour_patch Patches GridEntityPlus.cpp repentogon/Patches/GridEntityPlus.cpp:1 level and room done Extra per grid entity data and water clip +behaviour_patch Patches ImagePatches.cpp repentogon/Patches/ImagePatches.cpp:1 render and sprites done Transparent render batch reuse fixes +behaviour_patch Patches Init.cpp repentogon/Patches/Init.cpp:1 misc done Starts REPENTOGON's systems in Manager::Init +behaviour_patch Patches InterpolV2.cpp repentogon/Patches/InterpolV2.cpp:1 render and sprites done Interpolated rendering between updates (option) +behaviour_patch Patches ItemConfigEx.cpp repentogon/Patches/ItemConfigEx.cpp:1 items and pools started items.xml extras and custom item sounds behaviour_patch Patches ItemPoolManager.cpp repentogon/Patches/ItemPoolManager.cpp:1 items and pools todo Custom item pools from XML, pool queries, Isaac.GetPoolIdByName -behaviour_patch Patches ItemSpoofSystem.cpp repentogon/Patches/ItemSpoofSystem.cpp:1 player todo Innate collectibles and trinkets counted by HasCollectible and friends -behaviour_patch Patches JsonSavedata.h repentogon/Patches/JsonSavedata.h:1 persistent data and saves todo JSON helpers for REPENTOGON's own save data -behaviour_patch Patches LagMetric.cpp repentogon/Patches/LagMetric.cpp:1 render and sprites todo Lag metric and laser sample caching -behaviour_patch Patches MainMenuBlock.cpp repentogon/Patches/MainMenuBlock.cpp:1 hud and menus todo Main menu input mask (MenuManager.SetInputMask) +behaviour_patch Patches ItemSpoofSystem.cpp repentogon/Patches/ItemSpoofSystem.cpp:1 player started Innate collectibles and trinkets counted by HasCollectible and friends +behaviour_patch Patches JsonSavedata.h repentogon/Patches/JsonSavedata.h:1 persistent data and saves done JSON helpers for REPENTOGON's own save data +behaviour_patch Patches LagMetric.cpp repentogon/Patches/LagMetric.cpp:1 render and sprites done Lag metric and laser sample caching +behaviour_patch Patches MainMenuBlock.cpp repentogon/Patches/MainMenuBlock.cpp:1 hud and menus done Main menu input mask (MenuManager.SetInputMask) behaviour_patch Patches MesaShaderFix.cpp repentogon/Patches/MesaShaderFix.cpp:1 render and sprites todo Shader loading fix for Mesa drivers -behaviour_patch Patches MinimapPatches.cpp repentogon/Patches/MinimapPatches.cpp:1 hud and menus todo Minimap shader before its image renders -behaviour_patch Patches MiscFixes.cpp repentogon/Patches/MiscFixes.cpp:1 misc todo Fixes: null frames, missing entity configs, familiar followers, innate collectibles, font drawing -behaviour_patch Patches ModReloading.cpp repentogon/Patches/ModReloading.cpp:1 misc todo Mod reloading and workshop updates +behaviour_patch Patches MinimapPatches.cpp repentogon/Patches/MinimapPatches.cpp:1 hud and menus done Minimap shader before its image renders +behaviour_patch Patches MiscFixes.cpp repentogon/Patches/MiscFixes.cpp:1 misc started Fixes: null frames, missing entity configs, familiar followers, innate collectibles, font drawing +behaviour_patch Patches ModReloading.cpp repentogon/Patches/ModReloading.cpp:1 misc done Mod reloading and workshop updates behaviour_patch Patches ModsMenuStuff.cpp repentogon/Patches/ModsMenuStuff.cpp:1 hud and menus todo Mods menu search bar and input -behaviour_patch Patches NullItemsAndCostumes.cpp repentogon/Patches/NullItemsAndCostumes.cpp:1 player todo Custom null items and their costumes +behaviour_patch Patches NullItemsAndCostumes.cpp repentogon/Patches/NullItemsAndCostumes.cpp:1 player done Custom null items and their costumes behaviour_patch Patches PlayerFeatures.cpp repentogon/Patches/PlayerFeatures.cpp:1 player started Modded character trinket handling, Greed donations, per save state -behaviour_patch Patches PlayerTags.cpp repentogon/Patches/PlayerTags.cpp:1 player todo players.xml tags: no shake, no Metronome, no expansion pack, nightmare portraits +behaviour_patch Patches PlayerTags.cpp repentogon/Patches/PlayerTags.cpp:1 player started players.xml tags: no shake, no Metronome, no expansion pack, nightmare portraits behaviour_patch Patches PocketItems.cpp repentogon/Patches/PocketItems.cpp:1 player started Pocket item adds and removals with callbacks -behaviour_patch Patches Quickstart.cpp repentogon/Patches/Quickstart.cpp:1 hud and menus todo Quickstart into the last save slot -behaviour_patch Patches RoomConfigExtras.h repentogon/Patches/RoomConfigExtras.h:1 level and room todo Stage id mapping for Greed and alternate stages -behaviour_patch Patches SaveImport.cpp repentogon/Patches/SaveImport.cpp:1 persistent data and saves todo Imports vanilla saves into REPENTOGON's save folder -behaviour_patch Patches StagesStuff.cpp repentogon/Patches/StagesStuff.cpp:1 level and room todo Custom floor music, backdrop and name, stage config ids, stage command -behaviour_patch Patches VanillaTweaks.cpp repentogon/Patches/VanillaTweaks.cpp:1 misc todo Option tweaks: better Void generation, Hush laser speed, quick room clear, Hornfel, archive checks +behaviour_patch Patches Quickstart.cpp repentogon/Patches/Quickstart.cpp:1 hud and menus done Quickstart into the last save slot +behaviour_patch Patches RoomConfigExtras.h repentogon/Patches/RoomConfigExtras.h:1 level and room done Stage id mapping for Greed and alternate stages +behaviour_patch Patches SaveImport.cpp repentogon/Patches/SaveImport.cpp:1 persistent data and saves done Imports vanilla saves into REPENTOGON's save folder +behaviour_patch Patches StagesStuff.cpp repentogon/Patches/StagesStuff.cpp:1 level and room done Custom floor music, backdrop and name, stage config ids, stage command +behaviour_patch Patches VanillaTweaks.cpp repentogon/Patches/VanillaTweaks.cpp:1 misc done Option tweaks: better Void generation, Hush laser speed, quick room clear, Hornfel, archive checks behaviour_patch Patches XMLData.cpp repentogon/Patches/XMLData.cpp:1 misc todo Loads every content XML into XMLData, merges content and resources, custom backdrops, cutscenes and stages -behaviour_patch Patches XMLPlayerExtras.cpp repentogon/Patches/XMLPlayerExtras.cpp:1 player todo players.xml extras: starting health and stats, health limit, custom character menu -behaviour_patch Patches Xml/XmlBossPools.cpp repentogon/Patches/Xml/XmlBossPools.cpp:1 npc todo bosspools.xml parsing for custom boss pools +behaviour_patch Patches XMLPlayerExtras.cpp repentogon/Patches/XMLPlayerExtras.cpp:1 player started players.xml extras: starting health and stats, health limit, custom character menu +behaviour_patch Patches Xml/XmlBossPools.cpp repentogon/Patches/Xml/XmlBossPools.cpp:1 npc done bosspools.xml parsing for custom boss pools diff --git a/analysis/repentogon_overrides.tsv b/analysis/repentogon_overrides.tsv index f218b52..44fc70a 100644 --- a/analysis/repentogon_overrides.tsv +++ b/analysis/repentogon_overrides.tsv @@ -93,3 +93,200 @@ function Vector __sub done property Options SFXVolume done the setter rounds to a tenth function EntityPickup CanReroll done answers a mod's SetCanRerollOverride function EntityNPC GetPathfinder done the NPC's own pathfinder, the vanilla Pathfinder property left handing out a copy +xml_attribute items.xml achievement done a name finds the achievement with it, a mod's included (r3a1 test: Test Ach locks Stat Thing until unlocked) +xml_attribute items.xml activegfxpath done read as REPENTOGON's code reads it, activegfx under the file's gfxroot, for an active's HUD sprite +xml_attribute items.xml cache done the game reads it for null items, which a mod's items.xml now adds (cache 1 in the r3a1 test) +xml_attribute items.xml cooldown done the game reads it for null items, which a mod's items.xml now adds (60 in the r3a1 test) +xml_attribute items.xml persistent done the game reads it for null items, which a mod's items.xml now adds +xml_attribute items.xml id done a mod's null item takes the next id, and its type="none" costume with the same id ties to it +xml_attribute items.xml damage done repentogon/stats.cpp, added at the damage-up stage (r3a1 test: 3.5 to 10.79 with flatdamage and damagemult) +xml_attribute items.xml damagemult done repentogon/stats.cpp, after the flat damage stage +xml_attribute items.xml flatdamage done repentogon/stats.cpp, at the flat damage stage +xml_attribute items.xml flattears done repentogon/stats.cpp, at the flat tears stage +xml_attribute items.xml luck done repentogon/stats.cpp, before MC_EVALUATE_CACHE's luck +xml_attribute items.xml range done repentogon/stats.cpp, beside the players.xml range modifier before Number One +xml_attribute items.xml shotspeed done repentogon/stats.cpp, before My Reflection +xml_attribute items.xml speed done repentogon/stats.cpp, before the D8 multiplier +xml_attribute items.xml tears done repentogon/stats.cpp, at the tears-up stage (r3a1 test: MaxFireDelay 10 to 7.71 as Sad Onion) +xml_attribute items.xml tearsmult done repentogon/stats.cpp, after the flat tears stage +xml_tag items.xml items.xml done the game's content and resources folder support, plus REPENTOGON's extras +xml_tag items.xml null done a mod's null items get their own ids (133 on in the r3a1 test) +xml_tag items.xml passive done +xml_tag items.xml trinket done +xml_attribute pocketitems.xml achievement done a name finds the achievement with it, cards and pill effects +xml_attribute pocketitems.xml announcer done a sound name resolves once its mod's sounds load +xml_attribute pocketitems.xml announcer2 done a sound name resolves once its mod's sounds load, a sound without a name by its first sample's file name +xml_attribute pocketitems.xml hidden done ItemConfig_Card::IsAvailable refuses it (0 of 200 draws in the r3a1 test) +xml_attribute pocketitems.xml weight done GetCardEx draws by weight once one is not 1 (188 of 200 draws for a weight of 1000) +xml_tag pocketitems.xml pocketitems.xml done the game's content and resources folder support, plus REPENTOGON's extras +xml_attribute achievements.xml gfxback done the popup's paper, the default one put back after it +xml_attribute achievements.xml hidden done no popup for it +xml_attribute achievements.xml name done else text, else steam_name, for Isaac.GetAchievementIdByName and achievement attributes +xml_tag achievements.xml achievements.xml done repentogon/achievements.cpp: mods' achievements from 642, saved in Repentogon/achievements.json, conditions, counts, completion marks; the secrets menu's mod pages and event conditions are not ported +behaviour_patch Patches CardsExtras.cpp done hidden cards, availability conditions and weights in GetCardEx; GetCard's runes-only chance of -1 only without vanilla parity +behaviour_patch Patches JsonSavedata.h done repentogon/json_save.cpp +behaviour_patch Patches SaveImport.cpp done nothing to port: the whole file is commented out at e2c5aec +behaviour_patch Patches EvaluateStats.cpp done item stats and the flying custom tags in repentogon/stats.cpp, players.xml modifiers in repentogon/player_config.cpp +callback ModCallbacks MC_POST_PICKUP_SELECTION done Entity_Pickup::Init runs the rework without vanilla parity: requested variant and subtype, RNG of shift 3 (the pinned code has no Continue field) +callback ModCallbacks MC_PRE_PICKUP_COLLISION done collision_callbacks_run takes the Collide and SkipCollisionEffects table without vanilla parity +callback ModCallbacks MC_GET_PILL_EFFECT done with the player, after ItemPool::GetPillEffect, without vanilla parity +callback ModCallbacks MC_PRE_USE_ITEM done a Discharge=false table cancels without discharging, without vanilla parity +callback ModCallbacks MC_USE_PILL done with the pill color, without vanilla parity +behaviour_patch Patches CutsceneSkip.cpp done SkipIntro skips the first cutscene shown and the menu fades in from black (repentogon/ui_patches.cpp), option and parity off +behaviour_patch Patches Quickstart.cpp done -quickstart continues the run of the save file opened last (LastSaveFile, remembered on every slot select), parity off +behaviour_patch Patches MainMenuBlock.cpp done MenuManager.SetInputMask holds back the masked actions after MC_MAIN_MENU_RENDER outside the fade into a run, in the game's and the menus' action tests +behaviour_patch Patches ASMPatches/ASMRender.cpp done StatHUDPlanetarium: the unused stat shows the planetarium chance once planetariums are unlocked, recomputed as a floor starts or a run is restored (VanillaTweaks.cpp's hooks), option and parity off +behaviour_patch Patches InterpolV2.cpp done interpolated keyframes drawn half an update ahead between updates (needs the game's interpolation on), option and parity off +behaviour_patch Patches LagMetric.cpp done only the TEAR_LASERSHOT laser homing removal applies, parity off: the lag metric itself hangs on FastLasers, which REPENTOGON no longer reads +behaviour_patch Patches ExtraRenderSteps.cpp done the cursor always loads, and a mod's error shows at the top (click opens the overlay), cursor forced on, parity off +behaviour_patch Patches ASMPatches/ASMHud.cpp done callbacks and hidden items were ported in phases 1 and 2; the smelted Modeling Clay and Error image patches backport 1.9.7.13, which this 1.9.7.17 exe does itself +behaviour_patch Patches ImagePatches.cpp done not applicable: the rebuild's renderer keeps no per-image last transparent batch nor reusable batches with their own vertex buffers +behaviour_patch Patches MinimapPatches.cpp done not applicable: it repairs the shader side effect of REPENTOGON's own RenderFrame reimplementation; RenderFrame here resets the shader as this exe's does +xml_attribute backdrops.xml name done repentogon/xml.cpp: the game's and mods' backdrops by name (else the gfx file without extension and number prefix), Isaac.GetBackdropIdByName (r3a2 test) +xml_attribute backdrops.xml reftype done a mod's backdrop draws as its base (reftype, else 1 or 3 for reversed water), lending it its sheets until the base is asked for again (r3a2 test) +xml_tag backdrops.xml backdrops.xml done mods' content backdrops.xml adds backdrops from 63; Room:SetBackdropType/GetBackdropType take them, MC_POST_BACKDROP_CHANGE fires for them; the custom range starts after the game's 62, not REPENTOGON's 60 +xml_tag backdrops.xml backdrops done the mod file's root, whose gfxroot and gridgfxroot its backdrops inherit, then the game's +xml_tag backdrops.xml backdrop done each one a custom backdrop +xml_attribute bosscolors.xml name done EntityConfig::boss_colors_load reads it, mods' too, for Isaac.GetBossColorIdxByName (r3a2 test) +xml_tag bosscolors.xml bosscolors.xml done mods' content bosscolors.xml as REPENTOGON's full merge: a with the same attributes adds the colors it lacks, any other replaces its boss's colors +xml_attribute cutscenes.xml music done ui/cutscene.cpp: a music.xml name in place of the id, found as the part loads +xml_attribute cutscenes.xml name done Isaac.GetCutsceneIdByName finds mods' cutscenes (r3a2 test) +xml_tag cutscenes.xml cutscenes.xml done mods' content cutscenes.xml adds cutscenes from 27 under the game's root; the cutscene command and Isaac.PlayCutscene play them, counted as the intro as REPENTOGON's hijack does (r3a2 test) +xml_attribute giantbook.xml name done the game's and mods' giant books by name, else the gfx file name, Isaac.GetGiantBookIdByName (r3a2 test) +xml_tag giantbook.xml giantbook.xml done mods' content giantbook.xml adds giant books from 48 that ItemOverlay.Show plays (first book as base, Appear without anim, four channel tints); the game's 47 keeps the vanilla path +xml_tag ambush.xml ambush.xml done game/game.cpp LoadBossRushXml: mods' content spawn slots added after the game's +xml_attribute entities2.xml bagofcrafting done entity/config.cpp entity_ex_read; repentogon/items.cpp bag_ingredients_hook takes them, and the bag's swing grabs such a pickup +xml_attribute entities2.xml boomerang done repentogon/entities.cpp pickup_grab_check at the boomerang's grab +xml_attribute entities2.xml coinvalue done repentogon/entities.cpp coin_value_get in Entity_Pickup::GetCoinValue (r3a2 test); the unknown-coin worth of 1 only without vanilla parity +xml_attribute entities2.xml customtags done lowercased tags, plus noerase, norerollpickup, nojera and the familiar tags (ignore BFFS, take damage, block projectiles, nocharm) at their game sites (r3a2 test) +xml_attribute entities2.xml isactiveenemy done Entity::IsActiveEnemy override (r3a2 test) +xml_attribute entities2.xml meleecollide done repentogon/entities.cpp pickup_grab_check at the swing's grab +xml_attribute entities2.xml nosplit done repentogon/entities.cpp npc_split_blocked_check in Entity_NPC::split, after MC_PRE_NPC_SPLIT +xml_tag entities2.xml entities2.xml done the game's content and resources support plus EntityConfigEx's attributes and tags +xml_tag stringtable.sta stringtable.sta done repentogon/xml.cpp: each enabled mod's content(-repentogon, -dlc3) stringtable.sta and stringtable_pc.sta merged in load order, with ; the English fallback for untranslated official keys is not ported (a vanilla change, and the tables load before the options) +xml_tag stringtable.sta stringtable done the mod file's root +xml_tag stringtable.sta info done rgon_sta_version 0 required +xml_tag stringtable.sta languages done read from the game's table, a mod's ignored as in REPENTOGON +xml_tag stringtable.sta language done read from the game's table, a mod's ignored as in REPENTOGON +xml_tag stringtable.sta category done added when new (r3a2 test) +xml_tag stringtable.sta key done added when new with every translation empty (r3a2 test) +xml_tag stringtable.sta string done a filled one replaces the translation at its place (r3a2 test) +xml_tag stringtable.sta passive done an items.xml #key name: the raw name is in the collectible name map too (ItemConfigEx.cpp), Isaac.GetItemIdByName finds it (r3a2 test) +xml_tag stringtable.sta challenge done a challenges.xml #key name, Isaac.GetChallengeIdByName finds it (r3a2 test) +callback ModCallbacks MC_ENTITY_TAKE_DMG done table results and ExtraSource (lasers, swings, Gello, Brimstone balls via ExtraDamageSource) without vanilla parity +callback ModCallbacks MC_POST_ENTITY_KILL done the kill source without vanilla parity (repentogon/entities.cpp entity_kill_post) +callback ModCallbacks MC_PRE_BOMB_COLLISION done collision_callbacks_run table results without vanilla parity +callback ModCallbacks MC_PRE_KNIFE_COLLISION done collision_callbacks_run table results without vanilla parity +callback ModCallbacks MC_PRE_NPC_COLLISION done collision_callbacks_run table results without vanilla parity +callback ModCallbacks MC_PRE_PROJECTILE_COLLISION done collision_callbacks_run table results without vanilla parity +callback ModCallbacks MC_PRE_TEAR_COLLISION done collision_callbacks_run table results without vanilla parity +callback ModCallbacks MC_PRE_MOD_UNLOAD done repentogon/repentogon.cpp mods_shutdown_notify with ShuttingDown true, early in shutdown +property Options KeyMasterDealChance done nothing to port: documented, but REPENTOGON registers no such property at e2c5aec +behaviour_patch Patches ExtraDebugRender.cpp done entity_query_radius and entity_query_capsule draw their shape for a frame with RenderDebugFindInRadius, debug 6 and vanilla parity off (src/repentogon/console.cpp) +behaviour_patch Patches ASMPatches/ASMEntityKnife.cpp done a swing's hitbox knife takes the knife it swings from as hitboxSource (knife_hits.cpp swing_effect_spawn) +behaviour_patch Patches ASMPatches/ASMCamera.cpp done Camera:SetClampEnabled(false) lets ClampedToRoom and the active camera's soft clamp go past the room, until the next room's camera (isCameraClamped in repentogon/level.h) +behaviour_patch Patches ASMPatches/ASMEntityNPC.cpp done HushLaserSpeedFix (option and parity off) slows Hush's hunting laser pull in a slowed room outside dailies; FireProjectilesEx capture and isactiveenemy were ported before; the frozen enemy death patch is disabled at e2c5aec +behaviour_patch Patches ASMPatches/ASMSplitTears.cpp done MC_POST_FIRE_SPLIT_TEAR at every split the game makes: Cricket's Body, Parasite, Compound Fracture, Haemolacria, Lachryphagy, Mucormycosis, sticky copies (Ludovico, lasers, knives), Pop! lasers, knife splits, sword beams, Angelic Prism and Multidimensional Baby +behaviour_patch Patches ASMPatches/ASMDelirium.cpp done DeliriumCallbacks PRE_TRANSFORMATION (false keeps the form), TRANSFORMATION (false or a {type, variant} table) and POST_TRANSFORMATION; Delirium:Transform's fourth argument runs TRANSFORMATION for a forced form +behaviour_patch Patches ASMPatches/ASMBagOfCrafting.cpp done MC_TRY_ADD_TO_BAG_OF_CRAFTING, entities2.xml bagofcrafting and the melee, boomerang and bag pickup overrides were ported before (repentogon/items.cpp, repentogon/entities.cpp); verified +behaviour_patch Patches CustomDevilPlanetariumChance.cpp done the deal and planetarium chances in callback steps were ported before (repentogon/items.cpp devil_chance_hook, planetarium_chance_hook); verified +behaviour_patch Patches ASMPatches/ASMGridEntityCollision.cpp done the grid collision callbacks of every grid collision class and the player's, cached per update (repentogon/collision.cpp, entity/collision.cpp); verified +behaviour_patch Patches ASMPatches/ASMGridEntitySpawn.cpp done the inlined grid spawns call Room::SpawnGridEntity (secret shop stairs, Sanguine Bond spikes, Card Against Humanity poops and crawlspace ladders and gravity rewritten, the rest already did) +behaviour_patch Patches ASMPatches/ASMGridEntitySpawn_Definitions.cpp done its 23 sites, each checked against the rebuild (see ASMGridEntitySpawn.cpp) +behaviour_patch Patches GridEntityPlus.cpp done the water clip override lives on the grid entity and an Init clears it +behaviour_patch Patches RoomConfigExtras.h done nothing to port: included nowhere at e2c5aec, the same mapping as RoomConfig::GetStageID +behaviour_patch Patches ASMPatches/ASMRoom.cpp done ambush wave counts (before), a missing boss wave of difficulty 15 drawn as 10, MC_PRE_MEGA_SATAN_ENDING (before), QuickRoomClear (option and parity off: clear delay 3, save state 2, Deep Gaper 3); the Blue Womb door already reads the time counter in this exe; WaterDisabled is only set by the Void generation of ASMLevel.cpp, not ported +behaviour_patch Patches Xml/XmlBossPools.cpp done mods' content bosspools.xml add game boss ids to the game's pools by name, the last pool of a name in a file counting (BossPool::content_merge) +behaviour_patch Patches CustomCache.cpp done repentogon/custom_cache.cpp: item customcache evaluation on add and removal (now for collectibles and wisps, next EvaluateItems for trinkets and effects, all known on a full evaluation), maxcoins/maxkeys/maxbombs (limits, HUD digits, Curse of the Mist), tearscap, statmultiplier, healthtype; BFFS!, Hive Mind and Deep Pockets get their caches; a number replaces the game's only once a mod returns one, the excess is cut for a mod's number or without parity; familiarmultiplier is asked each time instead of cached +behaviour_patch Patches StagesStuff.cpp done SetCurrentFloor* and their restore were ported before; the stage suffixes are set on load without parity (repentogon/level.cpp stage_binary_load_post); its stage console override is vestigial at e2c5aec (its SetStage hook is commented out) and not ported +behaviour_patch Patches ModReloading.cpp done without vanilla parity ModManager::Reset restarts the game (exec of itself) in place of reloading the mods inside it, the options saved first, as the launcher restart does (repentogon/vanilla_fixes.cpp); DidModReset is only the launcher's +behaviour_patch Patches Init.cpp done a failed binding of main_ex.lua's _LuaBindings raises REPENTOGON's error display (repentogon/save_state_manager.cpp); the OpenGL loader and the launcher log's GMT timestamp do not apply +behaviour_patch Patches CustomModManager.cpp done a mod's gfx/mapitemicons.anm2 gives its curses their minimap icons by order, after the game's (repentogon/mod_curses.cpp) +behaviour_patch Patches VanillaTweaks.cpp done parity off: the Void's own room set (empty unless a mod replaces rooms/26.The Void_ex.stb), console refused in a non-practice daily, Hornfel without his cart, wispCollectibleType reset on Init; EcoMode sleeps while minimized (no priority change); REPENTOGON options saved with the game's; StatHUD by ASMRender +behaviour_patch Patches ASMPatches/ASMStatusEffects.cpp done the rebuild's status adders call GetStatusEffectTarget itself; AddWeakness takes its duration without vanilla parity +behaviour_patch Patches NullItemsAndCostumes.cpp done mods' null items and null costumes by relative id and modcostume (item_config.cpp, repentogon/player_config.cpp); AddCostume rejects a null item and its doubled costumes are checked +behaviour_patch Patches FamiliarTags.cpp done familiarblockprojectiles, familiarcantakedamage, familiarignorebffs and the deprecated familiarallowlasercollision attribute (repentogon/entities.cpp), nocharm +behaviour_patch Patches ExtraLives.cpp done the death callbacks (repentogon/player.cpp) and the revive, reviveeffect, hiddenrevive and chancerevive custom tags in GetExtraLives, the HUD's "?" and the three save deletion checks +function EntitySaveStateManagement GetEntitySaveStateId done _CBindings.ESSM, which entity_save_state_manager.lua reads (repentogon/save_state_manager.cpp) +function EntitySaveStateManagement SaveData done _CBindings.ESSM, which entity_save_state_manager.lua reads (repentogon/save_state_manager.cpp) +function EntitySaveStateManagement LoadData done _CBindings.ESSM, which entity_save_state_manager.lua reads (repentogon/save_state_manager.cpp) +function EntitySaveStateManagement DeleteData done _CBindings.ESSM, which entity_save_state_manager.lua reads (repentogon/save_state_manager.cpp) +xml_attribute players.xml items done names of items resolved for a mod's characters (player_config.cpp) +xml_attribute players.xml trinket done a mod's trinket by name +xml_attribute players.xml card done a mod's card by name +xml_attribute players.xml innateitems done ids or names, counted by the ItemSpoofSystem port (item_spoof.cpp) +xml_attribute players.xml innatetrinkets done ids or names, counted by the ItemSpoofSystem port +xml_attribute players.xml heartcontainers done set after Init (player_hearts_init) +xml_attribute players.xml redhearts done set after Init +xml_attribute players.xml soulhearts done set after Init +xml_attribute players.xml blackhearts done added after Init +xml_attribute players.xml goldenhearts done set after Init +xml_attribute players.xml bonehearts done set after Init +xml_attribute players.xml eternalheart done set after Init +xml_attribute players.xml brokenhearts done set after Init +xml_attribute players.xml rottenhearts done added after Init +xml_attribute players.xml gigabombs done added with bombs after Init +xml_attribute players.xml healthtype done the default GetHealthType hands MC_PLAYER_GET_HEALTH_TYPE +xml_attribute players.xml healthlimit done replaces GetHeartLimit's limit +xml_attribute players.xml speedmodifier done before the D8 multiplier +xml_attribute players.xml tearsmodifier done with the character's own tears offset, firedelaymodifier as its legacy form +xml_attribute players.xml tearsmultiplier done after the flat tears stage +xml_attribute players.xml damagemodifier done after the pre flat damage stage +xml_attribute players.xml damagemultiplier done before the pre flat damage stage, not with Azazel's Stump +xml_attribute players.xml rangemodifier done in tiles of 40, before Number One +xml_attribute players.xml shotspeedmodifier done before My Reflection +xml_attribute players.xml luckmodifier done before MC_EVALUATE_CACHE +xml_attribute players.xml flying done before MC_EVALUATE_CACHE's flying evaluation +xml_attribute players.xml bloodytears done replaces the four characters GetTearHitParams bleeds for +xml_attribute players.xml noshake done replaces the still portrait characters of the nightmare and boss screens +xml_attribute players.xml hurtsound done by id or a sound's name, the hurt grunt +xml_attribute players.xml deathsound done by id or a sound's name, the death animation's and Astral Projection's (not Soul of Lazarus's or the Lost soul's) +xml_attribute players.xml modcostume done the null costume a mod's costumes2.xml gave that id +xml_attribute players.xml achievement done a modded character locked on the menu (wheel portrait frame, page layers, random pick, tainted page) +xml_attribute players.xml hideachievement done a modded character (and its tainted twin) kept off the wheel until unlocked +xml_tag players.xml players.xml done every 's attributes kept by lowercase name (PlayerConfigEx) +xml_attribute babies.xml achievement done by number or a mod achievement's name +xml_attribute babies.xml hidden done achievement 9999, as vanilla hides babies +xml_attribute babies.xml name done a mod's babies appended with the next ids +xml_attribute babies.xml skin done under the game's babies.xml root, as XMLData merges them +xml_tag babies.xml babies done a mod's content babies.xml +xml_tag babies.xml baby done a mod's content babies.xml +xml_tag babies.xml babies.xml done content support; GetRandomBaby's pick (mods' babies included) without vanilla parity +xml_attribute costumes2.xml id done a none costume's id ties it to the mod's null item or its character's modcostume +xml_tag costumes2.xml costumes2.xml done content support was vanilla's, the ids REPENTOGON's +function EntityPlayer AddInnateCollectible done +function EntityPlayer AddInnateTrinket done +function EntityPlayer RemoveInnateCollectible done +function EntityPlayer RemoveInnateTrinket done +function EntityPlayer GetInnateCollectibleCount done +function EntityPlayer GetInnateTrinketCount done +function EntityPlayer SetInnateCollectibleCount done +function EntityPlayer SetInnateTrinketCount done +function EntityPlayer GetInnateCollectibleGroup done +function EntityPlayer GetInnateTrinketGroup done +function EntityPlayer SetInnateCollectibleGroup done +function EntityPlayer SetInnateTrinketGroup done +function EntityPlayer ClearInnateItemGroup done +function EntityPlayer BlockCollectible done +function EntityPlayer UnblockCollectible done +function EntityPlayer IsCollectibleBlocked done +function EntityPlayer BlockTrinket done +function EntityPlayer UnblockTrinket done +function EntityPlayer IsTrinketBlocked done +function EntityPlayer GetSpoofedCollectiblesList done +function EntityPlayer GetHistory done api_game.cpp's player_getters_register +function EntityPlayer GetPocketItem done api_game.cpp's player_getters_register +function EntityPlayer GetMultiShotParams done api_weapons.cpp, evaluated by MC_EVALUATE_MULTI_SHOT_PARAMS +function EntityPlayer SetWeapon done +function Isaac ReworkBirthright done Birthright counts for the character only in Lua's checks +callback ModCallbacks MC_POST_PLAYER_GET_MULTI_SHOT_PARAMS done run with MC_EVALUATE_MULTI_SHOT_PARAMS through main_ex.lua's legacy wrapper +callback ModCallbacks MC_PRE_PLAYER_COLLISION done vanilla dispatch with parity, collision_callbacks_run around HandleCollision without +behaviour_patch Patches ItemSpoofSystem.cpp started innates, blocks, reworked Birthrights, players.xml innates and the Lua context; groups are not saved in the run's state yet +behaviour_patch Patches XMLPlayerExtras.cpp started starting health and bombs, health limit, locked and hidden modded characters; not its SelectRandomChar rewrite +behaviour_patch Patches NullItemsAndCostumes.cpp done null items (items.xml) and their costumes, modcostume, AddCostume's null guard +behaviour_patch Patches PlayerTags.cpp started noshake; not nometronome, noexpansionpack or the stage portraits +behaviour_patch Patches ASMPatches/ASMPlayer.cpp started hurt and death sounds (three of five sites), bloody tears, the Mars double tap window without parity +xml_attribute edenhair.xml gfx done a mod's hairstyles appended to Eden's, under the file's root +xml_tag edenhair.xml edenhair done a mod's content edenhair.xml +xml_tag edenhair.xml hair done a mod's content edenhair.xml +xml_tag edenhair.xml edenhair.xml done content only, as REPENTOGON reads it diff --git a/assets/repentogon/scripts/main_ex.lua b/assets/repentogon/scripts/main_ex.lua index 3836638..56dda6b 100644 --- a/assets/repentogon/scripts/main_ex.lua +++ b/assets/repentogon/scripts/main_ex.lua @@ -771,7 +771,6 @@ local function logWarning(callbackID, modName, warn) end local function imGuiError(errortext) - if not ImGui then return end -- rebuild: until ImGui is ported local windowId = "ErrorDisplayWindow" if not ImGui.ElementExists("ErrorDisplayMenu") then ImGui.CreateMenu("ErrorDisplayMenu", "REPENTOGON Error Display") @@ -2086,7 +2085,6 @@ MenuManager.StatsMenu = StatsMenu -- ImGui alias functions --local ImGui = Isaac.GetImGui() -if ImGui then -- rebuild: until ImGui is ported ImGui.WorldToImGui = function (world_pos) local scr_xy = Isaac.WorldToScreen(world_pos) -- scale the screen xy to the window rectangle @@ -2097,7 +2095,6 @@ ImGui.ImGuiToWorld = function (imgui_pos) local _, imgui_wh = ImGui.GetGameWindowRect() return Isaac.RenderToWorld(Vector(imgui_pos.X * Isaac.GetScreenWidth() / imgui_wh.X, imgui_pos.Y * Isaac.GetScreenHeight() / imgui_wh.Y)) end -end if not _LUADEBUG then debug = nil @@ -2142,7 +2139,7 @@ rawset(Isaac, "GetEntityConfig", function() return EntityConfig end) RoomConfigHolder = RoomConfig -- Backwards compatability -- Reset Imgui Data after reload of all mods -if ImGui then ImGui.Reset() end -- rebuild: until ImGui is ported +ImGui.Reset() --resource load error, used in changelog but it's not strictly a changelog thing so i'm putting it here @@ -2290,7 +2287,6 @@ end pcall(require, "repentogon_api/room_descriptor") -if _CBindings.ESSM then -- rebuild: until the save state bindings are ported local SSM = _GetModule("repentogon_extras.save_state_manager") local ESSM = _GetModule("repentogon_extras.entity_save_state_manager") @@ -2394,7 +2390,5 @@ EntitySaveStateManager = { TryGetEntitySaveStateData = ESSM.TryGetEntitySaveStateData, } -end - _GetModule = nil s_modules = nil \ No newline at end of file diff --git a/generated-src/classes.h b/generated-src/classes.h index 3add0ee..04b09fc 100644 --- a/generated-src/classes.h +++ b/generated-src/classes.h @@ -203,6 +203,12 @@ struct CostumeItem; struct CostumeSpriteDesc; struct CostumeWalk; struct CraftingRecipe; +struct CustomCacheState; +struct CustomColor; +struct CustomElement; +struct CustomImGui; +struct CustomNotification; +struct CustomRevives; struct CustomShaders; struct Cutscene; struct CutsceneEntry; @@ -278,6 +284,7 @@ struct Entity_Tear; struct Entity_Text; struct ErasedEnemy; struct Explosion; +struct ExtraDamageSource; struct FXLayer; struct FXLayers; struct FXParams; @@ -383,6 +390,7 @@ struct InfoDisplayConfig; struct InfoDisplayEntry; struct InfoDisplayItem; struct InfoDisplayText; +struct InnateGroup; struct InputBindings; struct InputConfig; struct InputDelta; @@ -402,6 +410,7 @@ struct ItemInfoHUD; struct ItemOverlay; struct ItemPool; struct ItemPool_Item; +struct ItemSpoof; struct ItemUse; struct ItemsHit; struct JacobsCurseDelay; @@ -548,6 +557,7 @@ struct PickupMorph; struct PickupMorphed; struct PillEffect; struct Platform; +struct PlayerConfigEx; struct PlayerCostumeMap; struct PlayerHUD; struct PlayerHUDActiveItem; @@ -555,6 +565,7 @@ struct PlayerHUDHeart; struct PlayerHUDIcon; struct PlayerHUDPocketItem; struct PlayerHUDTrinket; +struct PlayerItemSpoofs; struct PlayerManager; struct PlayerProceduralItems; struct PlayerTrail; @@ -634,6 +645,7 @@ struct RoomTransition; struct RoomTransitionRequest; struct SFXManager; struct SaveDataManager; +struct SaveStateId; struct SavedRoom; struct ScoreRecord; struct ScoreSheet; @@ -691,6 +703,7 @@ struct TechLaserShot; struct TechXShot; struct TemporaryEffect; struct TemporaryEffects; +struct TemporaryInnate; struct TexelQuery; struct TextMeasure; struct TexturePtr; diff --git a/src/engine/anm2.cpp b/src/engine/anm2.cpp index 2fca017..22926ef 100644 --- a/src/engine/anm2.cpp +++ b/src/engine/anm2.cpp @@ -19,6 +19,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/render.h" +#include "repentogon/ui_patches.h" #endif // 00a15640 A value's place between inMin and inMax carried between outMin and outMax, logging an empty range. @@ -1031,13 +1032,20 @@ void AnimationState::Rewind() std::fill(nullLayerFrames.begin(), nullLayerFrames.end(), 0); } -// 0040a030 Draws every layer track on its current keyframe, bottom first. +// 0040a030 Draws every layer track on its current keyframe, bottom first, which REPENTOGON's InterpolV2 may draw +// part way to the next. void AnimationState::Render(const SpriteDraw& draw, const ANM2& animation) const { if (!animData) return; +#ifdef ISAAC_REPENTOGON + rendered_state_set(this); +#endif for (size_t i = 0; i < animData->animLayers.size(); i++) animData->animLayers[i].RenderFrame(draw, layerFrames[i], animation); +#ifdef ISAAC_REPENTOGON + rendered_state_set(nullptr); +#endif } // 0040a080 Draws one layer on its current keyframe, if the animation keys it. @@ -1444,7 +1452,12 @@ void AnimationLayer::RenderFrame(const SpriteDraw& draw, int frameIndex, const A { if (!isVisible || frameIndex < 0 || frameIndex >= (int)frames.size()) return; +#ifdef ISAAC_REPENTOGON + AnimationFrame lerped; + const AnimationFrame& frame = frame_interpolate(*this, frameIndex, animation, lerped); +#else const AnimationFrame& frame = frames[frameIndex]; +#endif if (!frame.isVisible || layerId < 0 || layerId >= (int)animation.layerStates.size()) return; const LayerState& layer = animation.layerStates[layerId]; diff --git a/src/entity/boss/delirium.cpp b/src/entity/boss/delirium.cpp index 6c611c3..51d3d79 100644 --- a/src/entity/boss/delirium.cpp +++ b/src/entity/boss/delirium.cpp @@ -995,12 +995,11 @@ static void delirium_morph(Entity_NPC& npc, FormSeconds seconds) npc.child->Remove(); BossId form = form_pick(npc); +#ifdef ISAAC_REPENTOGON + delirium_form_hook(npc, form.type, form.variant); +#endif npc.deliriumBossType = form.type; npc.deliriumBossVariant = form.variant; -#ifdef ISAAC_REPENTOGON - delirium_form_force(npc, npc.deliriumBossType, npc.deliriumBossVariant); - form = {(int)npc.deliriumBossType, (int)npc.deliriumBossVariant}; -#endif if (form.type == 0) log_printf(LOG_ASSERT, "No form for Delirium"); rage_roll(npc); if (form.type == ENTITY_MAMA_GURDY) npc.deliriumBossVariant = 0; @@ -1168,6 +1167,15 @@ void boss_delirium_update(Entity_NPC& npc) npc.shieldStrength = (1 - npc.health / npc.maxHitPoints) * SHIELD_STRENGTH; if (npc.deliriumBossType == ENTITY_DELIRIUM) npc.shieldStrength = 0; +#ifdef ISAAC_REPENTOGON + if (npc.deliriumState == DELIRIUM_MORPH && !delirium_morph_pre(npc)) npc.deliriumState = DELIRIUM_FORM; + if (npc.deliriumState == DELIRIUM_MORPH) + { + delirium_morph(npc, seconds); + return delirium_morph_post(npc); + } +#else if (npc.deliriumState == DELIRIUM_MORPH) return delirium_morph(npc, seconds); +#endif if (npc.deliriumState == DELIRIUM_FORM) form_update(npc); } diff --git a/src/entity/boss/hornfel.cpp b/src/entity/boss/hornfel.cpp index eaa5571..dd658ad 100644 --- a/src/entity/boss/hornfel.cpp +++ b/src/entity/boss/hornfel.cpp @@ -12,6 +12,9 @@ #include #include #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/options.h" +#endif // Hornfel's forms, by variant: Hornfel himself and the decoys he sends out in carts. constexpr int HORNFEL_DECOY = 1; @@ -1171,6 +1174,17 @@ static void hornfel_death_update(Entity_NPC& npc, Entity_NPC* cart) void Entity_NPC::Hornfel_UpdateAI() { auto* cart = static_cast(minecart.get()); +#ifdef ISAAC_REPENTOGON + if (!cart && (state == HORNFEL_HIDDEN || state == HORNFEL_CHARGE_EXIT) && !repentogonOptions.isVanillaParity) + { + // Patches/VanillaTweaks.cpp: a cart lost while he is out of the room would crash, so he falls back in. + log_printf(LOG_INFO, "Warning! Hornfel is about to blow this game! (I hate this red thing, I spit on you)\n"); + state = HORNFEL_FALL; + entityGridCollisionClass = GRIDCOLL_GROUND; + entityCollisionClass = ENTCOLL_ALL; + isVisible = true; + } +#endif switch (state) { case NPC_STATE_INIT: @@ -1241,6 +1255,10 @@ void Entity_NPC::Hornfel_UpdateAI() // cart where he left, and a cart off the grid takes him on to his next door or into hiding. void Entity_NPC::Hornfel_UpdateFrame() { +#ifdef ISAAC_REPENTOGON + bool isOffCart = state == HORNFEL_RUN || state == HORNFEL_FALL; + if (isOffCart && !repentogonOptions.isVanillaParity) return; // Patches/VanillaTweaks.cpp +#endif auto* cart = static_cast(minecart.get()); if (state == HORNFEL_CHARGE && entityRef) { diff --git a/src/entity/boss/intro.cpp b/src/entity/boss/intro.cpp index 95b4049..defe582 100644 --- a/src/entity/boss/intro.cpp +++ b/src/entity/boss/intro.cpp @@ -89,7 +89,11 @@ static void player_portrait_set(RoomTransition& transition, const EntityConfig_P const PlayerLayers& layers) { ANM2& versus = transition.versusScreenANM2; +#ifdef ISAAC_REPENTOGON + bool isAlt = is_player_no_shake(config.id); +#else bool isAlt = std::ranges::find(ALT_PORTRAIT_PLAYERS, config.id) != ALT_PORTRAIT_PLAYERS.end(); +#endif int layer = isAlt ? layers.portraitAlt : layers.portrait; versus.GetLayer(layers.spot)->isVisible = true; diff --git a/src/entity/boss/pool.cpp b/src/entity/boss/pool.cpp index 3c4fadb..575b414 100644 --- a/src/entity/boss/pool.cpp +++ b/src/entity/boss/pool.cpp @@ -8,6 +8,11 @@ #include #include #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/callbacks.h" +#include "repentogon/xml.h" +#include +#endif constexpr const char* BOSS_POOLS_XML = "bosspools.xml"; @@ -228,14 +233,101 @@ void BossPool::load_xml(std::string_view path, BossPoolSource source) pool.totalWeight += weight; } } +#ifdef ISAAC_REPENTOGON + content_merge(); +#endif } -// 00422830 The boss of a stage's boss room: a challenge's, the special daily's or a chapter end's fixed boss, one of +#ifdef ISAAC_REPENTOGON +// (Patches/Xml/XmlBossPools.cpp) Adds the bosses of the mods' content bosspools.xml to the game's pools of the same +// name: game boss ids only, the last pool of a name in a file counting, a boss without a weight taking the one before +// it in the pool. Their room and the pools' Double Trouble stay the game's. +void BossPool::content_merge() +{ + content_files_load(BOSS_POOLS_XML, [&](Data& data, ModEntry&) { + if (node_tag(data.root) != "bosspools") return; + std::map lastPools; + for (DataNode poolNode : node_children(data.root)) + if (auto name = node_attr_find(poolNode, "name")) lastPools.insert_or_assign(std::string(*name), poolNode); + + for (auto& [name, poolNode] : lastPools) + { + auto stage = std::ranges::find(BOSS_POOL_STAGES, std::string_view(name), &BossPoolStage::name); + if (stage == BOSS_POOL_STAGES.end()) continue; + BossPool_Pool& pool = pools[stage->stageId]; + float weight = pool.entries.empty() ? 0 : pool.entries.back().initialWeight; + for (DataNode bossNode : node_children(poolNode)) + { + auto id = node_attr_find(bossNode, "id"); + int bossId = id ? std::atoi(std::string(*id).c_str()) : 0; + if (bossId < 1 || bossId >= BOSS_ID_COUNT) continue; + if (auto text = node_attr_find(bossNode, "weight")) weight = (float)std::atof(std::string(*text).c_str()); + + BossPool_Entry entry; + entry.id = bossId; + entry.initialWeight = weight; + entry.weight = weight; + entry.achievementID = bossId < (int)g_manager->entityConfig.bosses.size() + ? g_manager->entityConfig.bosses[bossId].achievement + : -1; + pool.entries.push_back(entry); + pool.totalWeight += weight; + } + } + }); +} +#endif + +#ifdef ISAAC_REPENTOGON +// The bosses GetBossId may stage outside PickBoss, whose staging a mod's pick undoes, and the boss PickBoss last +// staged (CustomCallbacks.cpp's s_specialBosses and s_lastPickedBoss). +constexpr std::array SPECIAL_BOSSES = {BOSS_FAMINE, BOSS_PESTILENCE, BOSS_WAR, + BOSS_DEATH, BOSS_HEADLESS_HORSEMAN, BOSS_CONQUEST}; +constexpr size_t SPECIAL_DEATH_INDEX = 3; +static BossPool_Entry* lastPickedBoss = nullptr; +#endif + +// 00422830 The boss of a stage's boss room (boss_id_pick). With REPENTOGON, a mod's MC_PRE_BOSS_SELECT may pick +// another boss id, which is staged in place of the game's pick. A negative id (Double Trouble) leaves the game's. +// The original's RNG argument is never read, so it is left out. +int BossPool::GetBossId(int levelStage, int stageType) +{ +#ifndef ISAAC_REPENTOGON + return boss_id_pick(levelStage, stageType); +#else + std::array staged; + for (size_t i = 0; i < SPECIAL_BOSSES.size(); i++) staged[i] = levelBlacklist[SPECIAL_BOSSES[i]]; + lastPickedBoss = nullptr; + int bossId = boss_id_pick(levelStage, stageType); + + BossPool_Pool& pool = pools[RoomConfig::GetStageID(levelStage, stageType, ROOM_MODE_CURRENT)]; + LuaEngine& engine = lua_engine_get(); + if (!callback_run(engine, {"PreBossSelect", MC_PRE_BOSS_SELECT, bossId}, bossId, &pool, levelStage, stageType)) + return bossId; + int isInteger = 0; + auto chosen = (int)lua_tointegerx(engine.state, -1, &isInteger); + lua_pop(engine.state, 1); + if (!isInteger || chosen < 0 || chosen >= (int)levelBlacklist.size()) return bossId; + + if (lastPickedBoss) levelBlacklist.reset(lastPickedBoss->id); + else + for (size_t i = 0; i < SPECIAL_BOSSES.size(); i++) + { + if (SPECIAL_BOSSES[i] != bossId) continue; + levelBlacklist[bossId] = staged[i]; + if (bossId == BOSS_CONQUEST) levelBlacklist[BOSS_DEATH] = staged[SPECIAL_DEATH_INDEX]; + break; + } + levelBlacklist.set(chosen); + return chosen; +#endif +} + +// The game's boss for a stage's boss room: a challenge's, the special daily's or a chapter end's fixed boss, one of // the Horsemen (on one in ten first floors of chapters 1 to 4 once unlocked), the pool's Double Trouble room (as minus // its first room variant), The Fallen after a devil room, else a pick from the stage's pool, which ten failed picks // leave on Monstro. Each roll comes from the pool's own generator. -// The original's RNG argument is never read, so it is left out. -int BossPool::GetBossId(int levelStage, int stageType) +int BossPool::boss_id_pick(int levelStage, int stageType) { Game& game = *g_game; PersistentGameData& data = g_manager->persistentGameData; @@ -358,6 +450,9 @@ BossPool_Entry* BossPool::PickBoss(BossPool_Pool& pool, float roll) return nullptr; } boss_mark(levelBlacklist, picked->id); +#ifdef ISAAC_REPENTOGON + lastPickedBoss = picked; +#endif return picked; } diff --git a/src/entity/boss/pool.h b/src/entity/boss/pool.h index c09f2ef..151e9b6 100644 --- a/src/entity/boss/pool.h +++ b/src/entity/boss/pool.h @@ -77,7 +77,11 @@ public: void init(uint32_t seed); void load_xml(std::string_view path, BossPoolSource source); +#ifdef ISAAC_REPENTOGON + void content_merge(); +#endif int GetBossId(int levelStage, int stageType); + int boss_id_pick(int levelStage, int stageType); BossPool_Entry* PickBoss(BossPool_Pool& pool, float roll); bool WasBossRemoved(int bossId); void blacklist_clear(); diff --git a/src/entity/config.cpp b/src/entity/config.cpp index 48161ba..4a70ceb 100644 --- a/src/entity/config.cpp +++ b/src/entity/config.cpp @@ -9,6 +9,11 @@ #include #include #include +#ifdef ISAAC_REPENTOGON +#include "entity/pickup/pickup.h" +#include "repentogon/xml.h" +#include "repentogon/vanilla_fixes.h" +#endif constexpr std::string_view ENTITIES_VERSION = "5"; constexpr int BOSS_COLORS_VERSION_MAX = 1; @@ -244,9 +249,72 @@ static void entity_attr_read(EntityConfig_Entity& entity, std::string_view name, if (!tag.empty()) entity.customTags.insert(tag); } else if (name == "familiarignorebffs" && value == "true") entity.customTags.insert(CUSTOM_TAG_IGNORE_BFFS); + else if (name == "familiarallowlasercollision" && (value == "true" || value == "false")) + entity.isLaserHit = value == "true"; #endif } +#ifdef ISAAC_REPENTOGON +// The bag of crafting pickups entities2.xml's bagofcrafting names, by number (0 for none, which ends the list). +constexpr std::array BAG_PICKUP_NAMES = { + "none", "redheart", "soulheart", "blackheart", "eternalheart", "goldheart", "boneheart", + "rottenheart", "penny", "nickel", "dime", "luckypenny", "key", "goldkey", + "chargedkey", "bomb", "goldbomb", "gigabomb", "minibattery", "battery", "megabattery", + "card", "pill", "rune", "diceshard", "crackedkey", "goldpenny", "goldpill", + "goldbattery", "poop"}; +// The other names a bag pickup goes by. +constexpr std::pair BAG_PICKUP_ALIASES[] = {{"-1", 0}, {"false", 0}, {"heart", 1}}; +constexpr size_t BAG_PICKUP_LIMIT = 8; +// A coin's worth by vanilla subtype. +constexpr std::array COIN_WORTHS = {1, 1, 5, 10, 2, 1, 5, 1}; + +// A bag pickup by name, -1 for none. +static int bag_pickup_find(std::string_view name) +{ + auto found = std::ranges::find(BAG_PICKUP_NAMES, name); + if (found != BAG_PICKUP_NAMES.end()) return (int)(found - BAG_PICKUP_NAMES.begin()); + for (auto [alias, pickup] : BAG_PICKUP_ALIASES) + if (alias == name) return pickup; + return -1; +} + +// (EntityConfigEx.cpp's EntityEx::Parse) An entity's REPENTOGON attributes: a pickup's bag pickups (up to 8, up to +// the first unknown one or none) and a coin's worth (the vanilla ones', else coinvalue, else 1), and the overrides +// a "true" or "false" meleecollide, boomerang, isactiveenemy or nosplit sets. +static void entity_ex_read(EntityConfig_Entity& entity, DataNode node) +{ + XmlAttributes attributes = xml_attributes_read(node); + auto override_read = [&](const char* name, std::optional& flag) { + std::string& value = attributes[name]; + if (value == "true" || value == "false") flag = value == "true"; + }; + + if (entity.id == ENTITY_PICKUP) + { + std::string bag = attributes["bagofcrafting"]; + std::ranges::transform(bag, bag.begin(), [](unsigned char c) { return (char)std::tolower(c); }); + std::vector& pickups = entity.bagOfCraftingPickups; + for (std::string& name : bag.empty() ? std::vector() : text_split(bag, ' ')) + { + int pickup = bag_pickup_find(name); + if (pickups.size() >= BAG_PICKUP_LIMIT || pickup < 0) break; + if (pickup > 0 || pickups.empty()) pickups.push_back(pickup); + if (pickup == 0) break; + } + + std::string& coinValue = attributes["coinvalue"]; + if (entity.variant != PICKUP_COIN) entity.coinValue = 0; + else if (entity.subtype >= 0 && entity.subtype < (int)COIN_WORTHS.size()) + entity.coinValue = COIN_WORTHS[entity.subtype]; + else entity.coinValue = !coinValue.empty() && std::isdigit((unsigned char)coinValue[0]) ? text_int(coinValue) : 1; + } + override_read("meleecollide", entity.isMeleeCollide); + override_read("boomerang", entity.isBoomerangGrab); + override_read("isactiveenemy", entity.isActiveEnemy); + override_read("nosplit", entity.isNoSplit); +} +#endif + // One attribute of an entity's . static void bestiary_attr_read(EntityConfig_Entity& entity, std::string_view name, std::string_view value, EntityLoad& load) @@ -386,6 +454,10 @@ EntityConfig_Entity* EntityConfig::GetEntity(int id, int variant, int subtype) while (true) { auto found = entities.find(entity_key(id, variant, subtype)); +#ifdef ISAAC_REPENTOGON + if (found != entities.end() && !is_entity_config_matched(found->second, id, variant, subtype)) + found = entities.end(); +#endif if (found != entities.end()) return &found->second; if (subtype != 0) subtype = 0; @@ -464,6 +536,9 @@ bool EntityConfig::LoadEntities(std::string_view path, ModEntry* mod) EntityConfig_Entity& filed = entities[entity_key(entity.id, entity.variant, entity.subtype)]; filed = std::move(entity); +#ifdef ISAAC_REPENTOGON + entity_ex_read(filed, node); +#endif if (filed.isBoss || !filed.isReroll) return; bool isGround = filed.gridCollisionClassString == "ground" || @@ -502,6 +577,9 @@ bool EntityConfig::LoadPlayers(std::string_view path, ModEntry* mod) player_attr_read(player, name, value, load); }); player.modEntry = mod; +#ifdef ISAAC_REPENTOGON + player_config_ex_load(player, node, mod); +#endif if (mod) { @@ -559,17 +637,94 @@ void EntityConfig::LoadBabies(std::string_view path) }); } +// The roots and version a bosscolors.xml gives its colors' sprites. +struct BossColorFile +{ + std::string anm2Root; + std::string portraitRoot; + int version = 0; +}; + +// A : its preset tint, suffix, sprites under the roots (from version 1), scale and health. +static EntityConfig_BossColor boss_color_read(DataNode colorNode, BossColorFile& file) +{ + EntityConfig_BossColor bossColor; + attrs_walk(colorNode, [&](std::string_view name, std::string_view value) { + if (name == "idx") boss_color_preset_apply(bossColor.color, text_int(value)); + else if (name == "suffix") bossColor.suffix = value; + else if (name == "anm2path" && file.version > 0) bossColor.anm2Path = file.anm2Root + std::string(value); + else if (name == "portrait" && file.version > 0) bossColor.portraitPath = file.portraitRoot + std::string(value); + else if (name == "scale") bossColor.scale = text_float(value); + else if (name == "hp") bossColor.hpMultiplier = text_float(value); +#ifdef ISAAC_REPENTOGON + else if (name == "name") bossColor.name = value; +#endif + }); + return bossColor; +} + +#ifdef ISAAC_REPENTOGON +// A as REPENTOGON's merge compares it: its attributes and its colors'. +struct BossColorNode +{ + XmlAttributes attributes; + std::vector colors; +}; + +// (XMLData.cpp's bosscolors full merge) Adds each mod's content bosscolors.xml after the game's: a with the +// same attributes as one before adds the colors it lacks to that boss, any other replaces its boss's colors. Sprite +// paths stay under the game's roots. +static void boss_colors_content_load(EntityConfig& config, DataNode root, BossColorFile& file) +{ + std::vector bosses; + for (DataNode bossNode : node_children(root)) + { + BossColorNode& boss = bosses.emplace_back(xml_attributes_read(bossNode)); + for (DataNode colorNode : node_children(bossNode)) boss.colors.push_back(xml_attributes_read(colorNode)); + } + + content_files_load("bosscolors.xml", [&](Data& data, ModEntry&) { + std::optional modRoot = data_root_get(data, "bosscolors"); + if (!modRoot) return; + for (DataNode bossNode : node_children(*modRoot)) + { + XmlAttributes attributes = xml_attributes_read(bossNode); + int type = text_int(attributes["id"]); + int variant = text_int(attributes["variant"]); + EntityConfig_Entity* entity = config.GetEntity(type, variant, 0); + if (!entity || entity->variant != variant) + { + log_printf(LOG_INFO, "Cannot patch boss colors for Entity %d.%d\n", type, variant); + continue; + } + + auto merged = std::ranges::find(bosses, attributes, &BossColorNode::attributes); + if (merged == bosses.end()) + { + merged = bosses.insert(bosses.end(), BossColorNode{attributes, {}}); + entity->bossColors.clear(); + } + for (DataNode colorNode : node_children(bossNode)) + { + XmlAttributes color = xml_attributes_read(colorNode); + if (std::ranges::find(merged->colors, color) != merged->colors.end()) continue; + merged->colors.push_back(color); + entity->bossColors.push_back(boss_color_read(colorNode, file)); + } + } + }); +} +#endif + // 00698e80 Replaces the champion looks of each boss bosscolors.xml names. False without the file. // The original reads a boss without id or variant from memory it never wrote. This carries them over from the // boss before, from 0. bool EntityConfig::boss_colors_load(std::string_view path) { Data data; - std::string anm2Root; - std::string portraitRoot; + BossColorFile file; int type = 0; int variant = 0; - int version = 0; data_load(data, path); if (!data.isLoaded) return false; @@ -578,15 +733,15 @@ bool EntityConfig::boss_colors_load(std::string_view path) if (!root) return false; std::string_view versionText = node_attr(*root, "version"); - version = text_int(versionText); - if (version < 0 || version > BOSS_COLORS_VERSION_MAX) + file.version = text_int(versionText); + if (file.version < 0 || file.version > BOSS_COLORS_VERSION_MAX) log_printf(LOG_ASSERT, "Invalid version %.*s for %.*s\n", (int)versionText.size(), versionText.data(), (int)path.size(), path.data()); - if (version > 0) + if (file.version > 0) { - anm2Root = node_attr(*root, "anm2root"); - portraitRoot = node_attr(*root, "portraitroot"); + file.anm2Root = node_attr(*root, "anm2root"); + file.portraitRoot = node_attr(*root, "portraitroot"); } children_walk(*root, "boss", CHILDREN_FROM_TAGGED, [&](DataNode bossNode) { @@ -603,23 +758,12 @@ bool EntityConfig::boss_colors_load(std::string_view path) } entity->bossColors.clear(); - children_walk(bossNode, "color", CHILDREN_FROM_TAGGED, [&](DataNode colorNode) { - EntityConfig_BossColor bossColor; - attrs_walk(colorNode, [&](std::string_view name, std::string_view value) { - if (name == "idx") boss_color_preset_apply(bossColor.color, text_int(value)); - else if (name == "suffix") bossColor.suffix = value; - else if (name == "anm2path" && version > 0) bossColor.anm2Path = anm2Root + std::string(value); - else if (name == "portrait" && version > 0) bossColor.portraitPath = portraitRoot + std::string(value); - else if (name == "scale") bossColor.scale = text_float(value); - else if (name == "hp") bossColor.hpMultiplier = text_float(value); -#ifdef ISAAC_REPENTOGON - else if (name == "name") bossColor.name = value; -#endif - }); - entity->bossColors.push_back(bossColor); - }); + children_walk(bossNode, "color", CHILDREN_FROM_TAGGED, + [&](DataNode colorNode) { entity->bossColors.push_back(boss_color_read(colorNode, file)); }); }); - +#ifdef ISAAC_REPENTOGON + boss_colors_content_load(*this, *root, file); +#endif return true; } diff --git a/src/entity/config.h b/src/entity/config.h index e2a2449..5d965b9 100644 --- a/src/entity/config.h +++ b/src/entity/config.h @@ -5,10 +5,14 @@ #include #include #include +#include #include #include #include #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/player_config.h" +#endif // The key EntityConfig files an entity under: type, variant and subtype packed into one number. constexpr int ENTITY_KEY_TYPE_SHIFT = 20; @@ -21,8 +25,16 @@ constexpr int NAME_LANGUAGE_CURRENT = 20; constexpr int PLAYER_TYPE_COUNT = 41; constexpr int BOSS_PORTRAIT_COUNT = 104; -// The custom tag the legacy familiarignorebffs="true" stands for (REPENTOGON's CustomTags::FAMILIAR_IGNORE_BFFS). +// REPENTOGON's CustomTags that change what an entity does: BFFS! skipping a familiar (also the legacy +// familiarignorebffs="true"), a familiar taking hits and blocking shots, the Siren not charming it, the Eraser not +// erasing it, and rerolls or Jera passing a pickup by. constexpr const char* CUSTOM_TAG_IGNORE_BFFS = "familiarignorebffs"; +constexpr const char* CUSTOM_TAG_CAN_TAKE_DAMAGE = "familiarcantakedamage"; +constexpr const char* CUSTOM_TAG_BLOCK_PROJECTILES = "familiarblockprojectiles"; +constexpr const char* CUSTOM_TAG_NO_CHARM = "nocharm"; +constexpr const char* CUSTOM_TAG_NO_ERASE = "noerase"; +constexpr const char* CUSTOM_TAG_NO_REROLL = "norerollpickup"; +constexpr const char* CUSTOM_TAG_NO_JERA = "nojera"; // The tags entities2.xml gives an entity, as REPENTOGON's EntityTag. Each is bit n for the nth name tags reads. enum EntityTag : uint32_t @@ -191,8 +203,17 @@ struct EntityConfig_Entity bool isReroll = false; bool isShutDoors = true; #ifdef ISAAC_REPENTOGON - // REPENTOGON's EntityConfigEx: the lowercase customtags a mod's entities2.xml gives the entity. + // REPENTOGON's EntityConfigEx: the lowercase customtags a mod's entities2.xml gives the entity, the bag pickups a + // pickup brings, a coin's worth, and what decides a melee swing's or the boomerang's grab, an active enemy, a + // familiar's laser hits and a split where the game would (unset). std::set customTags; + std::vector bagOfCraftingPickups; + std::optional isActiveEnemy; + std::optional isBoomerangGrab; + std::optional isLaserHit; + std::optional isMeleeCollide; + std::optional isNoSplit; + int coinValue = 0; #endif std::string GetName(int language); @@ -235,6 +256,9 @@ struct EntityConfig_Player bool isCanShoot = true; bool isHidden = false; bool isRenderCustomBackground = false; +#ifdef ISAAC_REPENTOGON + PlayerConfigEx ex; +#endif std::string GetDisplayName(); }; diff --git a/src/entity/effect/boss.cpp b/src/entity/effect/boss.cpp index 0c27c3f..1fdc605 100644 --- a/src/entity/effect/boss.cpp +++ b/src/entity/effect/boss.cpp @@ -1,4 +1,5 @@ #include "entity/effect/effect.h" +#include "entity/config.h" #include "entity/familiar/familiar.h" #include "entity/weapon/laser.h" #include "entity/player/player.h" @@ -12,6 +13,8 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/entities.h" +#include "repentogon/options.h" #endif // A beam of light from above (Crack the Sky, Isaac's and the Holy Eye's beams): a spotlight that strikes on its Hit @@ -202,6 +205,8 @@ constexpr float HUSH_LASER_LEAD = 5; constexpr float HUSH_LASER_SIDE = 40; constexpr float HUSH_LASER_PLAYER_PULL = 1.1f; constexpr float HUSH_LASER_FRICTION = 0.8f; +// REPENTOGON's HushLaserSpeedFix: the player's speed the pull reads in a slowed room (its empirical 0.513, with room). +constexpr float HUSH_LASER_SLOW_SPEED = 0.513f * 0.75f; constexpr int HUSH_LASER_HIT_SPACING = 2; constexpr float HUSH_LASER_DAMAGE = 2; constexpr int HUSH_LASER_TRAIL_SPACING = 5; @@ -242,7 +247,8 @@ static void hush_laser_hit(Entity_Effect& laser) for (size_t i = 0; i < g_game->playerManager.playerList.size(); i++) hit(*g_game->GetPlayer((int)i)); } -// 005ea523 (Update's case 96) The laser hunting Hush's target. +// 005ea523 (Update's case 96) The laser hunting Hush's target. Patches/ASMPatches/ASMEntityNPC.cpp's HushLaserSpeedFix +// slows its pull on the player in a slowed room, as the player is. static void hush_laser_update(Entity_Effect& laser) { if (laser.parent && laser.parent->isDead) laser.Kill(EntityRef()); @@ -279,7 +285,14 @@ static void hush_laser_update(Entity_Effect& laser) if (target.is_player()) { auto& player = static_cast(target); - Vector pull = vector_scale(vector_scale(toward, HUSH_LASER_PLAYER_PULL), player.moveSpeed); + float speed = player.moveSpeed; +#ifdef ISAAC_REPENTOGON + Room& room = *g_game->room; + bool isSlow = room.slowdownDuration > 0 || room.GetBrokenWatchState() == BROKEN_WATCH_SLOW; + if (is_tweak_on(repentogonOptions.isHushLaserSpeedFix) && g_game->dailyChallenge.id == 0 && isSlow) + speed *= HUSH_LASER_SLOW_SPEED; +#endif + Vector pull = vector_scale(vector_scale(toward, HUSH_LASER_PLAYER_PULL), speed); laser.velocity = vector_add(laser.velocity, vector_scale(pull, player.speedMultiplier)); } @@ -332,6 +345,7 @@ bool is_familiar_charmable(Entity_Familiar& familiar) #ifdef ISAAC_REPENTOGON CallbackRun run = {"PreFamiliarCanCharm", MC_PRE_FAMILIAR_CAN_CHARM, familiar.variant}; if (!boolean_run(run, true, &familiar)) return false; + if (is_custom_tagged(ENTITY_FAMILIAR, familiar.variant, familiar.subtype, CUSTOM_TAG_NO_CHARM)) return false; #endif int variant = familiar.variant; if (variant > FAMILIAR_VARIANT_LAST_PLAIN) return true; diff --git a/src/entity/effect/items.cpp b/src/entity/effect/items.cpp index 428bb31..47d17da 100644 --- a/src/entity/effect/items.cpp +++ b/src/entity/effect/items.cpp @@ -24,6 +24,9 @@ #include "entity/weapon/weapon.h" #include #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/entities.h" +#endif // The effects of items, cards and pickups, and the small effects of no other group: the fires, Mom's stomping foot, // the shop's spikes, the souls and skulls, and the many that only play their animation. @@ -1166,7 +1169,11 @@ static void boomerang_grab(Entity_Effect& boomerang) for (Entity* entity : entity_query_radius(boomerang.pos, boomerang.size, QUERY_PICKUPS)) { auto* pickup = dynamic_cast(entity); + #ifdef ISAAC_REPENTOGON + if (!pickup || !pickup_grab_check(*pickup, PICKUP_GRABBER_BOOMERANG, false)) continue; +#else if (!pickup || !pickup->CanBePickedUp(false)) continue; +#endif if (pickup->variant == PICKUP_COIN && pickup->subtype == COIN_STICKYNICKEL) { if (pickup->sprite.IsPlaying("Touched")) continue; diff --git a/src/entity/effect/vortex.cpp b/src/entity/effect/vortex.cpp index 42e40b3..679b7e5 100644 --- a/src/entity/effect/vortex.cpp +++ b/src/entity/effect/vortex.cpp @@ -14,6 +14,9 @@ #include #include #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/entities.h" +#endif // The effects that pull the room in or grind through it: the Black Hole, the tears' rifts and brimstone balls. @@ -508,7 +511,11 @@ static void brimstone_ball_hits_update(Entity_Effect& ball, Entity_Player* playe brimstone_ball_splatter(ball, *entity); damage = damage * BALL_MARK_DAMAGE_SCALE + BALL_MARK_DAMAGE_BONUS; } - entity->TakeDamage(damage, damageFlags, EntityRef(ball.parent), HIT_COUNTDOWN); + EntityRef thrower(ball.parent); +#ifdef ISAAC_REPENTOGON + ExtraDamageSource extra{thrower, &ball}; +#endif + entity->TakeDamage(damage, damageFlags, thrower, HIT_COUNTDOWN); } } diff --git a/src/entity/entity.cpp b/src/entity/entity.cpp index b5d21b9..d6126cf 100644 --- a/src/entity/entity.cpp +++ b/src/entity/entity.cpp @@ -23,6 +23,7 @@ #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" #include "repentogon/entities.h" +#include "repentogon/save_state_manager.h" #endif // classes.h declares the original's Lua imports, and its luaL_newstate differs from Lua's only in its return type. @@ -182,6 +183,9 @@ EntityRef::EntityRef(Entity* source) // The original left the pointers to a destroyed entity dangling: they are nulled here. Entity::~Entity() { +#ifdef ISAAC_REPENTOGON + entity_deleted_notify(*this); +#endif if (isExists) Entity::Remove(); data_release(); for (EntityPtr* referrer : referrers) referrer->forget(); @@ -552,6 +556,9 @@ bool Entity::IsVulnerableEnemy(Entity* source) // 006b5b90 Whether it is an enemy that counts as active, alive unless the dead are included. bool Entity::IsActiveEnemy(DeadMode mode) { +#ifdef ISAAC_REPENTOGON + if (std::optional isActive = active_enemy_override(*this)) return *isActive && (!isDead || mode == DEAD_INCLUDED); +#endif if (!(g_game->deathmatchManager.is_active() && type == ENTITY_PLAYER)) { if (type < ENTITY_FIRST_ENEMY || type > ENTITY_LAST_ENEMY) return false; @@ -1286,9 +1293,13 @@ void Entity::Remove() } // 006acb60 Unlinks it from every entity it points to and nulls every pointer to it, removing its magnet effect. -// An entity in a list also drops its colors, damage, collision points and sprite. +// An entity in a list also drops its colors, damage, collision points and sprite. Mods lose their data on all but a +// player, which keeps it until destroyed. void Entity::ClearReferences() { +#ifdef ISAAC_REPENTOGON + if (type != ENTITY_PLAYER) entity_deleted_notify(*this); +#endif parent = nullptr; child = nullptr; target = nullptr; diff --git a/src/entity/factory.cpp b/src/entity/factory.cpp index fca772c..9ddf7bb 100644 --- a/src/entity/factory.cpp +++ b/src/entity/factory.cpp @@ -26,6 +26,8 @@ #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" #include "repentogon/level.h" +#include "repentogon/entities.h" +#include "repentogon/save_state_manager.h" #endif // The seed of a pedestal's Flip item comes from its own with this shift. @@ -226,7 +228,11 @@ Entity* EntityFactory::Create(int type, PoolMode mode) case ENTITY_EFFECT: pool = ENTITY_POOL_EFFECT; break; case ENTITY_TEXT: pool = ENTITY_POOL_TEXT; break; } - return pools[pool].Create(mode); + Entity* entity = pools[pool].Create(mode); +#ifdef ISAAC_REPENTOGON + if (entity) entity_created_notify(*entity); +#endif + return entity; } // The slot at the cursor, made when first reached. @@ -371,6 +377,9 @@ Entity* game_spawn(const EntitySpawn& request, PoolMode mode) // friendly enemies never are. bool entity_is_erased(Entity& entity) { +#ifdef ISAAC_REPENTOGON + if (is_custom_tagged(entity.type, entity.variant, entity.subtype, CUSTOM_TAG_NO_ERASE)) return false; +#endif Game& game = *g_game; bool isEnemy = entity.type == ENTITY_PLAYER ? game.deathmatchManager.state >= DEATHMATCH_INTRO : entity.type >= ENTITY_FIRST_ENEMY && entity.type < ENTITY_EFFECT; diff --git a/src/entity/familiar/babies.cpp b/src/entity/familiar/babies.cpp index 5eb6f06..e6a99bb 100644 --- a/src/entity/familiar/babies.cpp +++ b/src/entity/familiar/babies.cpp @@ -24,6 +24,9 @@ #include "level/room_grid.h" #include #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/weapons.h" +#endif // Lil Spewer's five kinds (its state): normal, white, red, black and yellow, each with its sheet, creep, charge tint and // wave (puddles, step, scale, damage, delay between puddles and how long each lasts, BFFS!'s extra puddles and time, @@ -1275,6 +1278,9 @@ static void buddy_in_a_box_look(Entity_Familiar& buddy) RNG rng{buddy.initSeed ^ g_game->dungeonPlacementSeed, 1, 21, 20}; const EntityConfig_Baby* look = nullptr; +#ifdef ISAAC_REPENTOGON + if (!repentogonOptions.isVanillaParity) look = &baby_random_get(buddy.initSeed ^ g_game->dungeonPlacementSeed); +#endif for (int draw = 0; draw < BUDDY_LOOK_DRAWS && !look; draw++) { const EntityConfig_Baby& baby = babies[rng.Next() % babies.size()]; @@ -1765,6 +1771,9 @@ static void prism_tear_split(Entity_Familiar& prism, Entity_Tear& tear) else copy->velocity = vector_rotated(copy->velocity, PRISM_FAN_FIRST - turn * PRISM_FAN_STEP); copy->SetColor(PRISM_COLORS[i], -1, COLOR_PRIORITY_DEFAULT, false, true); copy->Update(); +#ifdef ISAAC_REPENTOGON + split_tear_post(*copy, tear, SPLIT_ANGELIC_PRISM); +#endif } } diff --git a/src/entity/familiar/familiar.cpp b/src/entity/familiar/familiar.cpp index ca553b9..cf7a907 100644 --- a/src/entity/familiar/familiar.cpp +++ b/src/entity/familiar/familiar.cpp @@ -23,6 +23,9 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/entities.h" +#include "repentogon/save_state_manager.h" +#include "repentogon/options.h" #endif // The familiars that join the following line, and the ones that trail the player's path instead (Init 0060de70). @@ -281,6 +284,9 @@ bool Entity_Familiar::CanShutDoors() // 0060d8c0 Whether enemies can hurt it: only the familiars that take hits. bool Entity_Familiar::CanBeDamagedByEnemy() { +#ifdef ISAAC_REPENTOGON + if (is_custom_tagged(ENTITY_FAMILIAR, variant, subtype, CUSTOM_TAG_CAN_TAKE_DAMAGE)) return true; +#endif return variant == ISAACS_HEART || variant == PUNCHING_BAG || variant == LOST_SOUL || variant == MILK; } @@ -301,6 +307,9 @@ void Entity_Familiar::AddKeys(int amount) // familiar that stays where it spawned. void Entity_Familiar::Init(int initType, int initVariant, int initSubtype, uint32_t seed) { +#ifdef ISAAC_REPENTOGON + if (!repentogonOptions.isVanillaParity) wispCollectibleType = 0; // Patches/VanillaTweaks.cpp +#endif extraData.reset(); isSubtype55555 = initSubtype == SUBTYPE_PERMANENT; isHourglassRewound = false; @@ -1268,6 +1277,9 @@ int Entity_Familiar::hit_list_interval() // rest by variant. A locust blocks when its item shields, which stops the game. bool Entity_Familiar::CanBlockProjectiles() { +#ifdef ISAAC_REPENTOGON + if (is_custom_tagged(ENTITY_FAMILIAR, variant, subtype, CUSTOM_TAG_BLOCK_PROJECTILES)) return true; +#endif switch (variant) { case SMART_FLY: return subtype == 0; @@ -1326,9 +1338,12 @@ void Entity_Familiar::store_backup(FamiliarData* backup) // 00630560 Takes back what store_backup kept: drop seed, counters, formation spot and health, then what the variant // keeps. Tinytoma stays shed, the Lost Soul stays gone, a wisp rejoins its orbit, Blood Puppy's body comes back with its -// health and the Star of Bethlehem regains its speed. +// health and the Star of Bethlehem regains its speed. MC_ENTITY_RESTORE follows. void Entity_Familiar::RestoreState(const FamiliarData& saved) { +#ifdef ISAAC_REPENTOGON + ScopeExit post{[&] { entity_restore_notify(*this, saved.saveStateId.id); }}; +#endif dropRNG = DROP_RNG_SAVED; dropRNG._seed = saved.dropSeed; flags &= ~FLAG_APPEAR; diff --git a/src/entity/familiar/follow.cpp b/src/entity/familiar/follow.cpp index e0847ac..c7f1a38 100644 --- a/src/entity/familiar/follow.cpp +++ b/src/entity/familiar/follow.cpp @@ -17,6 +17,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/vanilla_fixes.h" #endif // How far behind its leader a follower keeps, closer for Milk and on Child's Leash, and how hard it catches up. @@ -268,6 +269,9 @@ static void ride_gello(Entity_Familiar& rider) static bool is_line_joined(Entity_Familiar& familiar, bool Entity_Familiar::* line) { Entity* parent = familiar.parent; +#ifdef ISAAC_REPENTOGON + if (is_familiar_line_led(familiar, line)) return true; +#endif if (!(familiar.*line) || !parent) return false; auto* leader = parent->type == ENTITY_FAMILIAR ? dynamic_cast(parent) : nullptr; diff --git a/src/entity/familiar/gello.cpp b/src/entity/familiar/gello.cpp index 11dc2b6..ee409f8 100644 --- a/src/entity/familiar/gello.cpp +++ b/src/entity/familiar/gello.cpp @@ -17,6 +17,9 @@ #include "level/room.h" #include "level/room_grid.h" #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/entities.h" +#endif // Gello's looks by the player's items: the overlay on the head layer, the eye layer and the body. constexpr int GELLO_BODY_LAYER = 1; @@ -417,7 +420,11 @@ static void cord_enemy_hit(Entity_Familiar& gello, UmbilicalBabyData& data, Enti owner.numBlueFlies <= CORD_FLY_LIMIT) damageFlags = DAMAGE_SPAWN_FLY; if (gello.HasEntityFlags(FLAG_BLEED_OUT)) damageFlags |= DAMAGE_SPAWN_TEMP_HEART; - if (enemy.TakeDamage(strike.damage, damageFlags, EntityRef(&owner), HIT_COUNTDOWN) && + EntityRef striker(&owner); +#ifdef ISAAC_REPENTOGON + ExtraDamageSource extra{striker, &gello}; +#endif + if (enemy.TakeDamage(strike.damage, damageFlags, striker, HIT_COUNTDOWN) && enemy.IsVulnerableEnemy(nullptr)) { int sound = SOUND_MEATY_DEATHS; @@ -529,7 +536,13 @@ static void gello_fling_hits(Entity_Familiar& gello, UmbilicalBabyData& data) if (entity->type != ENTITY_POOP && entity->type != ENTITY_MOVABLE_TNT) hit_list_insert(gello.hitList, *entity); if (entity->type == ENTITY_FIREPLACE && entity->variant != CORD_FIREPLACE_HIT_VARIANT) - entity->TakeDamage(CORD_FIREPLACE_DAMAGE, 0, EntityRef(gello.parent.get()), HIT_COUNTDOWN); + { + EntityRef striker(gello.parent.get()); +#ifdef ISAAC_REPENTOGON + ExtraDamageSource extra{striker, &gello}; +#endif + entity->TakeDamage(CORD_FIREPLACE_DAMAGE, 0, striker, HIT_COUNTDOWN); + } else if (entity->type == ENTITY_FROZEN_ENEMY) Entity::ForceCollide(&owner, entity, true); else if (entity->type != ENTITY_SHOPKEEPER) cord_enemy_hit(gello, data, *entity, strike); } diff --git a/src/entity/familiar/shoot.cpp b/src/entity/familiar/shoot.cpp index 6467833..b6d263d 100644 --- a/src/entity/familiar/shoot.cpp +++ b/src/entity/familiar/shoot.cpp @@ -13,6 +13,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/entities.h" #endif // The items and trinkets the familiars' shots read. @@ -157,6 +158,9 @@ float Entity_Familiar::GetMultiplier() { uint64_t tags = config->tags; bool isBffs = player->HasCollectible(COLLECTIBLE_BFFS) && variant != BLUE_FLY && variant != BLUE_SPIDER; +#ifdef ISAAC_REPENTOGON + isBffs = isBffs && !is_custom_tagged(type, variant, subtype, CUSTOM_TAG_IGNORE_BFFS); +#endif bool isHiveMind = (player->HasCollectible(COLLECTIBLE_HIVE_MIND) || player->temporaryEffects.HasCollectibleEffect(COLLECTIBLE_HIVE_MIND)) && ((tags & TAG_FAMILIAR_FLY) || (tags & TAG_FAMILIAR_SPIDER) || variant == ABYSS_LOCUST); diff --git a/src/entity/familiar/wisp_kinds.cpp b/src/entity/familiar/wisp_kinds.cpp index e7640d8..c6390f1 100644 --- a/src/entity/familiar/wisp_kinds.cpp +++ b/src/entity/familiar/wisp_kinds.cpp @@ -30,6 +30,9 @@ #include #include #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/entities.h" +#endif // The wisps of the actives with their own behaviour, item by item: what they set up, do each frame, fire, take and // leave behind. Book of Virtues' extra wisps (wisps.xml's "s" ids) count from WISP_EXTRA. @@ -1380,6 +1383,9 @@ void wisp_kind_tear(Entity_Familiar& wisp, WispTear& tear) void erased_enemy_add(Entity& enemy) { if (enemy.type == ENTITY_DOGMA) return; +#ifdef ISAAC_REPENTOGON + if (is_custom_tagged(enemy.type, enemy.variant, enemy.subtype, CUSTOM_TAG_NO_ERASE)) return; +#endif ErasedEnemy erased{.type = enemy.type, .subtype = enemy.subtype, .variant = enemy.variant}; erased_enemy_id_fix(erased.type, erased.variant, erased.subtype); diff --git a/src/entity/npc/deep_gaper.cpp b/src/entity/npc/deep_gaper.cpp index 530a7d4..32d7dbb 100644 --- a/src/entity/npc/deep_gaper.cpp +++ b/src/entity/npc/deep_gaper.cpp @@ -3,6 +3,9 @@ #include "level/room_grid.h" #include "game/sfx_manager.h" #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/level.h" +#endif // One Deep Gaper in 3 without a subtype rolls one of 6 heads, the sixth carrying a leech it throws as it dies. constexpr int DEEP_GAPER_HEAD_ODDS = 3; @@ -15,6 +18,7 @@ constexpr float DEEP_GAPER_LEECH_HEIGHT = -30; // enemy gone, its plates pressed, or itself friendly). Then, every 4 frames, one time in 8 (or after 90 frames), with // no player within 60, it rises out. constexpr int DEEP_GAPER_PLATE_DELAY = 9; +constexpr int DEEP_GAPER_PLATE_DELAY_QUICK = 3; constexpr int DEEP_GAPER_RISE_CHECK_FRAMES = 4; constexpr uint32_t DEEP_GAPER_RISE_MASK = 7; constexpr int DEEP_GAPER_RISE_AFTER = 90; @@ -79,8 +83,12 @@ static void deep_gaper_wait(Entity_NPC& npc) if (!npc.isCanShutDoors) { Room& room = *g_game->room; + int plateDelay = DEEP_GAPER_PLATE_DELAY; +#ifdef ISAAC_REPENTOGON + if (is_quick_room_clear()) plateDelay = DEEP_GAPER_PLATE_DELAY_QUICK; +#endif bool isFightOn = npc.HasEntityFlags(FLAG_FRIENDLY) || - (npc.GetAliveEnemyCount() < 1 && room.roomClearDelay < DEEP_GAPER_PLATE_DELAY) || + (npc.GetAliveEnemyCount() < 1 && room.roomClearDelay < plateDelay) || g_game->GetCurrentRoomDesc()->flags & ROOM_DESCRIPTOR_FLAG_PRESSURE_PLATES_TRIGGERED; if (!isFightOn) return; npc.isCanShutDoors = true; diff --git a/src/entity/npc/fireplace.cpp b/src/entity/npc/fireplace.cpp index 0de0824..4ae0b72 100644 --- a/src/entity/npc/fireplace.cpp +++ b/src/entity/npc/fireplace.cpp @@ -10,6 +10,9 @@ #include "entity/npc/caves.h" #include "level/room.h" #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/npc.h" +#endif // A fire's dying animation for each of its looks. constexpr const char* DISAPPEAR[FIRE_LOOKS] = {"Dissapear", "Dissapear2", "Dissapear3"}; @@ -204,9 +207,22 @@ static Entity_Player* fire_putter_get(Entity_NPC& npc) return source ? static_cast(source->GetPlayerAncestor()) : nullptr; } -// 006d1580 What a fire put out drops, from its drop RNG, which only an advancing draw moves on: nothing from white, -// moveable or Coal fires or without rewards. +// 006d1580 What a fire put out drops (fireplace_loot_roll). With REPENTOGON, mods' MC_PRE and MC_POST_NPC_GET_LOOT_LIST +// may change it. LootList Entity_NPC::fireplace_get_loot(bool isShouldAdvance) +{ +#ifdef ISAAC_REPENTOGON + return npc_loot_hook(*this, isShouldAdvance, [](Entity_NPC& npc, bool isAdvance) { + return npc.fireplace_loot_roll(isAdvance); + }); +#else + return fireplace_loot_roll(isShouldAdvance); +#endif +} + +// What a fire put out drops, from its drop RNG, which only an advancing draw moves on: nothing from white, moveable +// or Coal fires or without rewards. +LootList Entity_NPC::fireplace_loot_roll(bool isShouldAdvance) { LootList loot; PlayerManager& players = g_game->playerManager; diff --git a/src/entity/npc/npc.cpp b/src/entity/npc/npc.cpp index bdfa84d..31fa269 100644 --- a/src/entity/npc/npc.cpp +++ b/src/entity/npc/npc.cpp @@ -38,6 +38,7 @@ #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" #include "repentogon/npc.h" +#include "repentogon/entities.h" #endif // The frames of a controlled NPC's charge bar, empty to full. @@ -3651,7 +3652,7 @@ bool Entity_NPC::split(float damage, const EntityRef& source, bool isPlaySound) if (isPlaySound) npc_sound_play(SOUND_MEATY_DEATHS, 1, 2, 1); bool isBlacklisted = split_is_unsplittable(*this); #ifdef ISAAC_REPENTOGON - isBlacklisted = boolean_run({"PreNPCSplit", MC_PRE_NPC_SPLIT, (int)type}, isBlacklisted, this, isBlacklisted); + isBlacklisted = npc_split_blocked_check(*this, isBlacklisted); #endif bool isHurtOnly = scale < SPLIT_LEAST_SCALE || isBlacklisted; bool isChain = (type == ENTITY_VISAGE && variant == VISAGE_CHAIN) || (type == ENTITY_SCOURGE && variant == SCOURGE_CHAIN); diff --git a/src/entity/npc/npc.h b/src/entity/npc/npc.h index dd87bb6..ea25d4c 100644 --- a/src/entity/npc/npc.h +++ b/src/entity/npc/npc.h @@ -411,6 +411,7 @@ struct Entity_NPC : Entity void CreateBling(); void CreateGoldParticles(uint32_t count); LootList fireplace_get_loot(bool isShouldAdvance); + LootList fireplace_loot_roll(bool isShouldAdvance); void on_player_damaged(); static int FindTargetPit(const Vector& pos1, const Vector& pos2, uint32_t pitIndex); static Entity_NPC* ThrowStrider(const Vector& pos, Entity* spawner, const Vector& targetPos); @@ -501,4 +502,5 @@ inline bool room_check_line(const Vector& start, const Vector& end, int mode, in return room_check_line({.start = start, .end = end, .mode = mode, .gridPathThreshold = gridPathThreshold}); } std::vector shopkeeper_loot_get(Entity_NPC& npc, bool isAdvance); +std::vector shopkeeper_loot_roll(Entity_NPC& npc, bool isAdvance); bool entity_is_prey(Entity& prey); diff --git a/src/entity/pickup/chest.cpp b/src/entity/pickup/chest.cpp index 8e85132..052c16a 100644 --- a/src/entity/pickup/chest.cpp +++ b/src/entity/pickup/chest.cpp @@ -18,6 +18,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/items.h" #endif // The shift index of the RNG every outcome draw seeds (5, 9, 7), and the one a loot's spot angle comes from. @@ -631,6 +632,9 @@ LootList Entity_Pickup::GetChestLoot(PoolDraw draw, Entity_Player* player) loot_item_add(chest, POOL_TREASURE); if (variant == PICKUP_MEGACHEST) loot_item_add(chest, POOL_TREASURE); } +#ifdef ISAAC_REPENTOGON + loot_list_callbacks_run(*this, chest.loot, draw == POOL_DRAW_TAKE, *chest.rng, player); +#endif return chest.loot; } diff --git a/src/entity/pickup/item_config.cpp b/src/entity/pickup/item_config.cpp index 50050b4..f255a06 100644 --- a/src/entity/pickup/item_config.cpp +++ b/src/entity/pickup/item_config.cpp @@ -552,7 +552,11 @@ bool ItemConfig_Card::IsAvailable() if (id == CARD_SUICIDE_KING && g_game->playerManager.FirstPlayerByType(PLAYER_JACOB)) return false; if (versus_rules_get() && versus_rules_get()->is_card_banned(id)) return false; } +#ifdef ISAAC_REPENTOGON + return is_achievement_unlocked(achievementId) && card_is_available_ex(*this); +#else return is_achievement_unlocked(achievementId); +#endif } // 00730b20 Whether the pill effect may appear: in Greed mode, in a deathmatch, and by its achievement. @@ -728,11 +732,19 @@ bool ItemConfig::Load(std::string_view path, ModEntry* mod) item->modEntry = mod; item->id = nextId; } +#ifdef ISAAC_REPENTOGON + if (mod && item->IsNull()) item->id = mod->nullItemIdMap[item->id] = (int)list.size(); +#endif std::unique_ptr* slot = slot_get(list, item->id); if (!slot) continue; ItemConfig_Item& placed = *(*slot = std::move(item)); if (placed.IsCollectible()) collectibleNameMap[placed.GetLocalizedName()] = placed.id; +#ifdef ISAAC_REPENTOGON + item_xml_extras_load(node, placed, gfxRoot); + // (ItemConfigEx.cpp) The raw name too, a string table key for a translated item, for pools and lookups. + if (placed.IsCollectible() && !placed.name.empty() && placed.id > 0) collectibleNameMap[placed.name] = placed.id; +#endif } return true; } @@ -775,12 +787,21 @@ bool ItemConfig::LoadCostumes(std::string_view path, ModEntry* mod) if (type == "none") { +#ifdef ISAAC_REPENTOGON + int relativeId = costume.id; + if (mod && costume.id != 0 && mod->nullItemIdMap.contains(costume.id)) + costume.id = mod->nullItemIdMap[costume.id]; + else +#endif if (mod) { costume.id = (int)nullItems.size(); nullItems.push_back(std::make_unique()); nullItems.back()->id = costume.id; } +#ifdef ISAAC_REPENTOGON + if (mod && relativeId != 0) mod->nullCostumeIdMap[relativeId] = costume.id; +#endif item = item_find(nullItems, costume.id, nullptr); } else if (type == "trinket") @@ -947,6 +968,7 @@ bool ItemConfig::LoadPocketItems(std::string_view path, ModEntry* mod) card->initialWeight = std::max(card->initialWeight, 0.0f); card->weight = card->initialWeight; card->isHidden = node_attr_find(node, "hidden") == "true"; + pocket_item_xml_extras_load(node, *card, nullptr); #endif if (card->id < 0) { @@ -970,6 +992,9 @@ bool ItemConfig::LoadPocketItems(std::string_view path, ModEntry* mod) pocket_item_parse(*pill, node, mod); attr_read(node, "announcer2", pill->announcerVoiceSuper); if (auto effectClass = node_attr_find(node, "class")) pill_class_parse(*pill, *effectClass); +#ifdef ISAAC_REPENTOGON + pocket_item_xml_extras_load(node, *pill, &pill->announcerVoiceSuper); +#endif if (pill->id < 0) { log_print(LOG_INFO, "[warn] %s: Pill Effect ID %d out of range!\n", pathText.c_str(), pill->id); diff --git a/src/entity/pickup/item_config.h b/src/entity/pickup/item_config.h index 4ef57da..e0e9963 100644 --- a/src/entity/pickup/item_config.h +++ b/src/entity/pickup/item_config.h @@ -453,7 +453,11 @@ struct ItemConfig_Item bool isPersistentEffect = false; bool isSpecial = false; #ifdef ISAAC_REPENTOGON - // REPENTOGON's ItemConfigEx: the lowercase customcache and customtags words its XML gives the item. + // REPENTOGON's ItemConfigEx: the lowercase customcache and customtags words its XML gives the item, the stats + // (by ItemStat) it gives while held and while its effect lasts, and an active's sprite in the HUD. + std::map effectStats; + std::map stats; + std::string activeGfx; std::set customCaches; std::set customTags; #endif diff --git a/src/entity/pickup/item_overlay.cpp b/src/entity/pickup/item_overlay.cpp index 649d486..669345a 100644 --- a/src/entity/pickup/item_overlay.cpp +++ b/src/entity/pickup/item_overlay.cpp @@ -10,6 +10,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/xml.h" #endif constexpr int SLEEP_SOUL_HEARTS = 6; @@ -69,12 +70,17 @@ static void overlay_sound_play(int sound, int frameDelay, float pitch) } // Sleeping's healing: each player but Tainted Soul fills its red hearts, or takes three soul hearts without heart -// containers, with a power up sound unless finishing. The game counts the sleep. A mod may skip a player. +// containers, with a power up sound unless finishing. The game counts the sleep. A mod may skip a player, and +// MC_POST_TRIGGER_BED_SLEEP_EFFECT runs as each player's turn ends. static void sleep_heal(OverlayUpdate mode) { for (Entity_Player* player : g_game->playerManager.playerList) { #ifdef ISAAC_REPENTOGON + ScopeExit post{[&] { + CallbackRun run = {"PostTriggerBedSleepEffect", MC_POST_TRIGGER_BED_SLEEP_EFFECT, std::nullopt}; + callback_notify(lua_engine_get(), run, player); + }}; if (boolean_run({"PreTriggerBedSleepEffect", MC_PRE_TRIGGER_BED_SLEEP_EFFECT, std::nullopt}, false, player)) continue; #endif @@ -152,10 +158,15 @@ void ItemOverlay::Show(int overlayId, int showDelay, Entity_Player* shown) callback_notify(engine, run, overlayId, showDelay, shown); }}; #endif - if ((unsigned)overlayId >= GIANTBOOK_ENTRY_COUNT) + const GiantbookEntry* found = (unsigned)overlayId < GIANTBOOK_ENTRY_COUNT ? &g_game->giantbookEntries[overlayId] + : nullptr; +#ifdef ISAAC_REPENTOGON + if (!found) found = giantbook_custom_find(overlayId); +#endif + if (!found) return; - const GiantbookEntry& entry = g_game->giantbookEntries[overlayId]; + const GiantbookEntry& entry = *found; if (entry.anm2Path.empty()) sprite.Reset(); else diff --git a/src/entity/pickup/item_pool.cpp b/src/entity/pickup/item_pool.cpp index c572e8f..7ec7d11 100644 --- a/src/entity/pickup/item_pool.cpp +++ b/src/entity/pickup/item_pool.cpp @@ -18,6 +18,7 @@ #include "repentogon/callbacks.h" #include "repentogon/items.h" #include "repentogon/level.h" +#include "repentogon/vanilla_fixes.h" #endif // An outcome of a weighted draw and its weight, as WeightedOutcomePicker holds them. @@ -67,6 +68,8 @@ constexpr uint32_t HOLY_CARD_RNG_SHIFT = 47; constexpr size_t RUNE_POOL_MIN = 6; constexpr uint32_t RUNE_SHARD_ODDS = 5; constexpr int CARD_RUNE_SHARD = 55; +// The rune chance that always draws a rune, an empty rune pool padded too: REPENTOGON's GetCard for runes only. +constexpr int CARD_RUNES_ONLY = -1; constexpr int HOLY_CARD = 51; constexpr uint32_t HOLY_CARD_ODDS = 10; constexpr int REVERSED_TAROT_OFFSET = 55; @@ -952,12 +955,18 @@ static int pill_slot_get(uint32_t pillColor) // 00718ea0 void ItemPool::IdentifyPill(uint32_t pillColor) { +#ifdef ISAAC_REPENTOGON + if (is_pill_color_ignored(pillColor)) return; +#endif identifiedPillEffects[pill_slot_get(pillColor)] = true; } // 0083c490 bool ItemPool::IsPillIdentified(uint32_t pillColor) { +#ifdef ISAAC_REPENTOGON + if (is_pill_color_ignored(pillColor)) return false; +#endif return identifiedPillEffects[pill_slot_get(pillColor)]; } @@ -1026,6 +1035,9 @@ int ItemPool::GetCard(uint32_t drawSeed, bool isPlaying, bool isRunes, bool isOn { int suitChance = isPlaying ? CARD_SUIT_CHANCE : 0; int runeChance = isOnlyRunes ? 1 : isRunes ? CARD_RUNE_CHANCE : 0; +#ifdef ISAAC_REPENTOGON + if (isOnlyRunes && !repentogonOptions.isVanillaParity) runeChance = CARD_RUNES_ONLY; +#endif int card = GetCardEx((int)drawSeed, isOnlyRunes ? 0 : CARD_SPECIAL_CHANCE, runeChance, suitChance, true); RNG rng = rng_make(drawSeed, POOL_SHIFT); return lua_engine_get().GetCard( @@ -1039,11 +1051,20 @@ static bool is_card_available(int id) return card && card->IsAvailable(); } +// One of a pool's cards, by REPENTOGON's card weights once one is not 1. +static int card_pick(RNG& rng, const std::vector& pool) +{ +#ifdef ISAAC_REPENTOGON + if (std::optional card = card_weighted_pick(rng, pool)) return *card; +#endif + return pool[rng.RandomInt((uint32_t)pool.size())]; +} + // One of a pool's cards when the generator rolls one in odds, or 0. static int card_pool_draw(RNG& rng, int odds, const std::vector& pool) { if (rng.Next() % (uint32_t)odds != 0 || pool.empty()) return 0; - return pool[rng.RandomInt((uint32_t)pool.size())]; + return card_pick(rng, pool); } // 00734180 A card from a seed, one in each chance from its pool: a special card (with objects when allowed), a rune @@ -1080,22 +1101,22 @@ int ItemPool::GetCardEx(int drawSeed, int specialChance, int runeChance, int sui default: break; } } - if (!runes.empty() || runeChance == -1) runes.resize(std::max(runes.size(), RUNE_POOL_MIN), 0); + if (!runes.empty() || runeChance == CARD_RUNES_ONLY) runes.resize(std::max(runes.size(), RUNE_POOL_MIN), 0); RNG rng = rng_make((uint32_t)drawSeed, CARD_DRAW_SHIFT); - int runeOdds = runeChance == -1 ? 1 : runeChance; + int runeOdds = runeChance == CARD_RUNES_ONLY ? 1 : runeChance; int card = specialChance ? card_pool_draw(rng, specialChance, special) : 0; bool isRuneShard = false; if (!card && runeOdds && rng.Next() % (uint32_t)runeOdds == 0 && !runes.empty()) { - card = runes[rng.RandomInt((uint32_t)runes.size())]; + card = card_pick(rng, runes); isRuneShard = !card && (runeOdds == 1 || rng.RandomInt(RUNE_SHARD_ODDS) == 0); } if (isRuneShard) card = CARD_RUNE_SHARD; else { if (!card && suitChance) card = card_pool_draw(rng, suitChance, suits); - if (!card && !tarots.empty()) card = tarots[rng.RandomInt((uint32_t)tarots.size())]; + if (!card && !tarots.empty()) card = card_pick(rng, tarots); bool isReversible = card > 0 && card <= CARD_WORLD; if (isReversible && rng.Next() % REVERSED_TAROT_ODDS == 0 && is_card_available(card + REVERSED_TAROT_OFFSET)) card += REVERSED_TAROT_OFFSET; diff --git a/src/entity/pickup/pickup.cpp b/src/entity/pickup/pickup.cpp index d2eef31..a900a74 100644 --- a/src/entity/pickup/pickup.cpp +++ b/src/entity/pickup/pickup.cpp @@ -34,6 +34,7 @@ #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" #include "repentogon/items.h" +#include "repentogon/entities.h" #endif // The chest variants (chest, locked, red, bomb, eternal, spiked, mimic, mom's, old, wooden, mega, haunted). @@ -2703,7 +2704,7 @@ int Entity_Pickup::GetCoinValue() { #ifdef ISAAC_REPENTOGON CallbackRun run = {"PickupGetCoinValue", MC_PICKUP_GET_COIN_VALUE, subtype}; - if (variant == PICKUP_COIN) return callback_integer_run(lua_engine_get(), run, coin_worth(), this); + if (variant == PICKUP_COIN) return callback_integer_run(lua_engine_get(), run, coin_value_get(*this, coin_worth()), this); #endif return coin_worth(); } @@ -2739,6 +2740,9 @@ bool Entity_Pickup::CanReroll() // needs them, the glitched item a seed hides). bool Entity_Pickup::CanRerollVariant(int pickupVariant, int pickupSubType) { +#ifdef ISAAC_REPENTOGON + if (is_custom_tagged(ENTITY_PICKUP, pickupVariant, pickupSubType, CUSTOM_TAG_NO_REROLL)) return false; +#endif if (is_listed({PICKUP_BED, PICKUP_TROPHY, PICKUP_BIGCHEST, PICKUP_THROWABLEBOMB, PICKUP_MOMSCHEST}, pickupVariant)) return false; if (pickupVariant != PICKUP_COLLECTIBLE) return true; @@ -2909,6 +2913,9 @@ void Entity_Pickup::AppearFast() // Jera itself or empty chest. bool Entity_Pickup::CanJeraDuplicate() { +#ifdef ISAAC_REPENTOGON + if (is_custom_tagged(type, variant, subtype, CUSTOM_TAG_NO_JERA)) return false; +#endif if (isDead || variant == PICKUP_COLLECTIBLE || variant == PICKUP_TRINKET) return false; if (variant == PICKUP_TAROTCARD && subtype == RUNE_JERA) return false; return CanReroll() && (!IsChest(variant) || subtype != 0); diff --git a/src/entity/player/actives.cpp b/src/entity/player/actives.cpp index 023043a..52414a7 100644 --- a/src/entity/player/actives.cpp +++ b/src/entity/player/actives.cpp @@ -44,6 +44,7 @@ #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" #include "repentogon/items.h" +#include "repentogon/menus.h" #include "repentogon/player.h" #endif @@ -236,18 +237,24 @@ static std::optional action_hook_run(Entity* entity, int hook, ButtonActio return lua_engine_get().InputAction(entity, hook, action); } -// 00956110 Whether an action is held on a controller, or on any device for -1. A mod may answer first. Netplay's -// remote devices are offline. +// 00956110 Whether an action is held on a controller, or on any device for -1. A mod may answer first, and +// REPENTOGON's main menu input mask may hold it back. Netplay's remote devices are offline. bool input_is_action_pressed(ButtonAction action, int controllerIndex, Entity* entity) { +#ifdef ISAAC_REPENTOGON + if (is_action_masked(action)) return false; +#endif std::optional isModPressed = action_hook_run(entity, INPUT_HOOK_PRESSED, action); return isModPressed ? *isModPressed : is_action_met(action, controllerIndex, ACTION_PRESSED); } -// 009561e0 Whether an action was pressed this frame on a controller, or on any device for -1. A mod may answer first. -// Netplay's remote devices are offline. +// 009561e0 Whether an action was pressed this frame on a controller, or on any device for -1. A mod may answer first, +// and REPENTOGON's main menu input mask may hold it back. Netplay's remote devices are offline. bool input_is_action_triggered(ButtonAction action, int controllerIndex, Entity* entity) { +#ifdef ISAAC_REPENTOGON + if (is_action_masked(action)) return false; +#endif std::optional isModTriggered = action_hook_run(entity, INPUT_HOOK_TRIGGERED, action); return isModTriggered ? *isModTriggered : is_action_met(action, controllerIndex, ACTION_TRIGGERED); } @@ -910,6 +917,9 @@ static void expansion_pack_use(Entity_Player& player) { if (!is_trinket_active(player, item.get()) || std::ranges::find(EXCLUDED, item->id) != std::end(EXCLUDED)) continue; +#ifdef ISAAC_REPENTOGON + if (item->customTags.contains(CUSTOM_TAG_NO_EXPANSION_PACK)) continue; // Patches/PlayerTags.cpp +#endif if (versus.is_active() && versus.type->is_collectible_banned(item->id)) continue; if (item->maxCharges == 1 || item->maxCharges == 2) small.AddOutcomeWeight(item->id, 1); else if (item->maxCharges == 3) large.AddOutcomeWeight(item->id, 1); @@ -1548,6 +1558,10 @@ static int metronome_item_roll(Entity_Player& player) { int id = (int)rng.RandomInt((uint32_t)config.collectibles.size() - 1) + 1; if (std::ranges::find(METRONOME_EXCLUDED, id) != std::end(METRONOME_EXCLUDED)) continue; +#ifdef ISAAC_REPENTOGON + ItemConfig_Item* rolled = config.GetCollectible(id); + if (rolled && rolled->customTags.contains(CUSTOM_TAG_NO_METRONOME)) continue; // Patches/PlayerTags.cpp +#endif if (g_game->challenge == CHALLENGE_CANTRIPPED && ItemConfig::is_collectible_tagged(id, TAG_NO_CANTRIP)) continue; if (id == COLLECTIBLE_DEATH_CERTIFICATE && chances.RandomFloat() >= METRONOME_DEATH_CERTIFICATE_CHANCE) continue; if (id == COLLECTIBLE_GENESIS && chances.RandomFloat() >= METRONOME_GENESIS_CHANCE) continue; diff --git a/src/entity/player/bombs.cpp b/src/entity/player/bombs.cpp index f36adfe..6e9d9b2 100644 --- a/src/entity/player/bombs.cpp +++ b/src/entity/player/bombs.cpp @@ -259,7 +259,11 @@ static void bomb_count_take(Entity_Player& player, bool isFree) hud_refresh_players(); if (isFree) return; - player.numBombs = std::clamp(player.numBombs - 1, 0, BOMBS_MAX); + int bombMax = BOMBS_MAX; +#ifdef ISAAC_REPENTOGON + bombMax = consumable_limit_get(LIMIT_BOMBS, bombMax); +#endif + player.numBombs = std::clamp(player.numBombs - 1, 0, bombMax); player.ConsumableCountChanged(CONSUMABLE_BOMBS); hud_refresh_players(); } diff --git a/src/entity/player/characters.cpp b/src/entity/player/characters.cpp index e6ef227..b5f0073 100644 --- a/src/entity/player/characters.cpp +++ b/src/entity/player/characters.cpp @@ -970,6 +970,9 @@ static void animation_restore(ANM2& sprite, const std::string& animation, bool i // Lazarus its other form unless isKeepState. Becoming Jacob splits the hearts and items with a new Esau. void Entity_Player::ChangePlayerType(int newType, bool isKeepState) { +#ifdef ISAAC_REPENTOGON + ScopeExit spoofsCheck = {[this] { item_spoofs_player_check(*this, false); }}; +#endif EntityConfig& configs = g_manager->entityConfig; if (newType < 0) return; diff --git a/src/entity/player/damage.cpp b/src/entity/player/damage.cpp index c2c0334..2d71736 100644 --- a/src/entity/player/damage.cpp +++ b/src/entity/player/damage.cpp @@ -1064,7 +1064,11 @@ bool Entity_Player::TakeDamage(float damage, uint64_t damageFlags, const EntityR if (HasCollectible(COLLECTIBLE_MARBLES) && (trinkets[0] != 0 || isTrinketQueued)) marbles_swallow(*this); float pitch = get_voice_pitch(); +#ifdef ISAAC_REPENTOGON + int grunt = player_sound_get(*this, PLAYER_SOUND_HURT); +#else int grunt = SOUND_ISAAC_HURT_GRUNT; +#endif if (temporaryEffects.HasCollectibleEffect(COLLECTIBLE_THE_NAIL)) grunt = random_below(2) ? SOUND_MONSTER_GRUNT_0 : SOUND_MONSTER_GRUNT_1; voice_play(grunt, volume, SOUND_FRAME_DELAY, pitch); if (source.type == ENTITY_MOM || source.type == ENTITY_MOMS_HEART) @@ -1205,6 +1209,9 @@ int Entity_Player::GetExtraLives() for (int item : EXTRA_LIFE_ITEMS) lives += collectibleCounts[item]; if (playerType == PLAYER_THELOST_B) lives += collectibleCounts[TAINTED_LOST_BIRTHRIGHT]; +#ifdef ISAAC_REPENTOGON + lives += custom_revives_get(*this, REVIVE_COUNT_SHOWN).lives; +#endif return lives + (playerType == PLAYER_LAZARUS); } @@ -1605,7 +1612,11 @@ bool Entity_Player::try_end_astral_projection() if (std::string_view(GetDeathAnimName()) != "Death") return true; PlayExtraAnimation("Death"); if (sprite.animState.animData) sprite.animState.SetFrameFloat(DEATH_SKIP_FRAME); +#ifdef ISAAC_REPENTOGON + int sound = player_sound_get(*this, PLAYER_SOUND_DEATH); +#else int sound = SOUND_ISAACDIES; +#endif seed_fart_sound_override(&sound); g_manager->sfxManager.Play(sound, {.pitch = get_voice_pitch()}); return true; diff --git a/src/entity/player/death.cpp b/src/entity/player/death.cpp index 53a3807..88842c7 100644 --- a/src/entity/player/death.cpp +++ b/src/entity/player/death.cpp @@ -729,6 +729,9 @@ static void revived_players_settle(std::vector& players, int old bool Entity_Player::TriggerDeath(bool isCheckOnly) { #ifdef ISAAC_REPENTOGON + ScopeExit spoofsCheck = {[this, isCheckOnly] { + if (!isCheckOnly) item_spoofs_player_check(*this, false); + }}; if (!isCheckOnly) if (std::optional isRevived = player_death_pre_trigger(*this)) return *isRevived; #endif @@ -944,7 +947,11 @@ void Entity_Player::death_update() } else if (sprite.IsPlaying(animation) && sprite.IsEventTriggered("DeathSound")) { +#ifdef ISAAC_REPENTOGON + if (!IsHologram()) effect_sound_play(player_sound_get(*this, PLAYER_SOUND_DEATH), {.pitch = get_voice_pitch()}); +#else if (!IsHologram()) effect_sound_play(SOUND_ISAACDIES, {.pitch = get_voice_pitch()}); +#endif if (playerType == PLAYER_BLUEBABY_B) blue_baby_last_poops(*this); } diff --git a/src/entity/player/effects.cpp b/src/entity/player/effects.cpp index 03aa3bb..c377872 100644 --- a/src/entity/player/effects.cpp +++ b/src/entity/player/effects.cpp @@ -2019,6 +2019,9 @@ static void dirty_mind_update(Entity_Player& player) // original's order. void items_frame_update(Entity_Player& player) { +#ifdef ISAAC_REPENTOGON + item_spoofs_update(player); +#endif TemporaryEffects& effects = player.temporaryEffects; if (g_game->stageTransition.state != 0) return; if (player.isPlayingExtraAnimation && player.sprite.IsPlaying("Trapdoor")) return; diff --git a/src/entity/player/evaluate.cpp b/src/entity/player/evaluate.cpp index d44fe0f..7b7c2dc 100644 --- a/src/entity/player/evaluate.cpp +++ b/src/entity/player/evaluate.cpp @@ -164,6 +164,9 @@ static StatBonuses stat_bonuses_get(Entity_Player& player) bonus.isMistOrGhost = player.hasCurseMistEffect || player.isCoopGhost; bonus.crownScale = (float)player.GetTrinketMultiplier(TRINKET_CRACKED_CROWN) * 0.2f + 1; if (player.playerType == PLAYER_BETHANY_B) bonus.crownScale *= TAINTED_BETHANY_STAT_SCALE; +#ifdef ISAAC_REPENTOGON + bonus.crownScale = stat_multiplier_get(player, bonus.crownScale); +#endif if (player.temporaryEffects.HasCollectibleEffect(COLLECTIBLE_EXPERIMENTAL_TREATMENT)) { @@ -255,6 +258,9 @@ static void fire_delay_evaluate(Entity_Player& p, const StatBonuses& bonus) tears = n(465) * 0.35f + tears; bulbs_apply(p, tears, 0.5f, 0.2f); tears = tears + character_tears_get(p); +#ifdef ISAAC_REPENTOGON + player_stat_modify(p, PLAYER_STAT_TEARS_MODIFIER, tears); +#endif float bonusTears = is_eden(p) ? bonus.tears * 0.5f + p.edenFireDelay : bonus.tears * 0.5f; if (bonusTears < 0) bonusTears *= NEGATIVE_TEARS_SCALE; tears = bonusTears + tears; @@ -267,8 +273,12 @@ static void fire_delay_evaluate(Entity_Player& p, const StatBonuses& bonus) #endif float curve = std::sqrt(std::max(tears * TEARS_CURVE_SCALE + 1, 0.0f)); + float delayMin = TEARS_DELAY_MIN; +#ifdef ISAAC_REPENTOGON + delayMin = tears_cap_get(p, delayMin); +#endif float delay = std::max(TEARS_DELAY_BASE - curve * TEARS_DELAY_STEP - std::min(tears, 0.0f) * TEARS_DELAY_STEP, - TEARS_DELAY_MIN); + delayMin); float rate = FIRE_RATE_FRAMES / (delay + 1); if (has(600)) rate *= 1.2f; if (crownScale != 1 && rate > CRACKED_CROWN_FIRE_RATE) rate = rate + (rate - CRACKED_CROWN_FIRE_RATE) * (crownScale - 1); @@ -305,6 +315,7 @@ static void fire_delay_evaluate(Entity_Player& p, const StatBonuses& bonus) if (TemporaryEffect* camo = effects.GetNullEffect(NULLITEM_CAMO_BOOST)) rate = rate + (float)camo->count * 0.25f; #ifdef ISAAC_REPENTOGON rate = stat_evaluate(p, rate, STAT_STAGE_FLAT_TEARS); + player_stat_modify(p, PLAYER_STAT_TEARS_MULTIPLIER, rate); #endif if (!has(245)) @@ -507,7 +518,9 @@ static void damage_evaluate(Entity_Player& p, const StatBonuses& bonus) damage = damage * character_damage_scale_get(p); if (p.variant == PLAYER_VARIANT_COOP_BABY && p.babySkin == BABY_BONE) damage = damage * 1.5f; #ifdef ISAAC_REPENTOGON + if (!effects.HasTrinketEffect(TRINKET_AZAZELS_STUMP)) player_stat_modify(p, PLAYER_STAT_DAMAGE_MULTIPLIER, damage); damage = stat_evaluate(p, damage, STAT_STAGE_PRE_FLAT_DAMAGE); + player_stat_modify(p, PLAYER_STAT_DAMAGE_MODIFIER, damage); #endif damage = damage + character_damage_get(p); if (effects.HasNullEffect(NULLITEM_ESAU_JR)) damage = damage + 2; @@ -659,6 +672,12 @@ static void shot_speed_evaluate(Entity_Player& p, const StatBonuses& bonus) if (effects.HasNullEffect(NULLITEM_ERA_WALK)) speed = speed - 1; speed = trinket_num(p, TRINKET_WHIP_WORM) * 0.5f + speed; speed = (float)n(554) * 0.2f + speed; +#ifdef ISAAC_REPENTOGON + player_stat_modify(p, PLAYER_STAT_SHOT_SPEED_MODIFIER, speed); +#endif +#ifdef ISAAC_REPENTOGON + item_stat_add(p, ITEM_STAT_SHOTSPEED_UP, speed); +#endif if (has(5) || effects.HasCollectibleEffect(5)) speed = speed * 1.6f; if (has(149)) speed = speed * 0.8f; if (p.variant == PLAYER_VARIANT_COOP_BABY && p.babySkin == BABY_BEGOTTEN) speed = speed * 0.5f; @@ -767,6 +786,10 @@ static void range_evaluate(Entity_Player& p, const StatBonuses& bonus) p.tearFallingSpeed = tape * 0.5f * p.tearFallingSpeed; p.tearRange = tape * 120 + p.tearRange; } +#ifdef ISAAC_REPENTOGON + player_stat_modify(p, PLAYER_STAT_RANGE_MODIFIER, p.tearRange); + item_stat_add(p, ITEM_STAT_RANGE_UP, p.tearRange); +#endif if (is_having(p, 6)) { p.tearHeight = p.tearHeight + 18; @@ -852,6 +875,12 @@ static void speed_evaluate(Entity_Player& p, const StatBonuses& bonus) if (effects.HasNullEffect(NULLITEM_SPIN_TO_WIN)) p.moveSpeed = p.moveSpeed + 0.5f; if (effects.HasCollectibleEffect(COLLECTIBLE_DARK_ARTS)) p.moveSpeed = p.moveSpeed + 1; else if (effects.HasCollectibleEffect(COLLECTIBLE_CAMO_UNDIES)) p.moveSpeed = p.moveSpeed + 0.5f; +#ifdef ISAAC_REPENTOGON + player_stat_modify(p, PLAYER_STAT_SPEED_MODIFIER, p.moveSpeed); +#endif +#ifdef ISAAC_REPENTOGON + item_stat_add(p, ITEM_STAT_SPEED_UP, p.moveSpeed); +#endif p.moveSpeed = p.d8SpeedModifier * p.moveSpeed; if (crownScale != 1 && p.moveSpeed > 1) p.moveSpeed = (p.moveSpeed - 1) * (crownScale - 1) + p.moveSpeed; if (g_game->dailyChallenge.specialDailyId == SPECIAL_DAILY_SEPTEMBER_5) p.moveSpeed = p.moveSpeed - 1; @@ -1421,6 +1450,9 @@ static void speed_share(Entity_Player& p) // fire delay, damage and speed. void Entity_Player::EvaluateItems() { +#ifdef ISAAC_REPENTOGON + custom_caches_evaluate(*this); +#endif StatBonuses bonus = stat_bonuses_get(*this); if (cacheFlags & CACHE_WEAPON) weapons_evaluate(*this); if (cacheFlags & CACHE_SHOTSPEED) cacheFlags |= CACHE_RANGE; diff --git a/src/entity/player/frame.cpp b/src/entity/player/frame.cpp index 3ab90a5..8bc6575 100644 --- a/src/entity/player/frame.cpp +++ b/src/entity/player/frame.cpp @@ -1,4 +1,7 @@ #include "entity/player/player.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/options.h" +#endif #include "entity/config.h" #include "entity/player/trinkets.h" #include "entity/player/characters.h" @@ -408,13 +411,19 @@ static void jupiter_update(Entity_Player& p, Vector input) p.temporaryEffects.isEvaluateCachePending = true; } -// Mars: tapping a direction twice within 11 frames, its cooldown over, starts its dash that way. +// Mars: tapping a direction twice within 11 frames (without vanilla parity, REPENTOGON's MarsDoubleTapWindow plus one), +// its cooldown over, starts its dash that way. static void mars_taps_read(Entity_Player& p) { for (int direction = 0; direction < 4; direction++) { if (!input_is_action_triggered((ButtonAction)(ACTION_LEFT + direction), p.controllerIndex, &p)) continue; +#ifdef ISAAC_REPENTOGON + int window = repentogonOptions.isVanillaParity ? MARS_DOUBLE_TAP_FRAMES - 1 : repentogonOptions.marsDoubleTapWindow; + bool isDoubleTap = p.marsLastTapDirection == direction && p.marsTapFrames <= window; +#else bool isDoubleTap = p.marsLastTapDirection == direction && p.marsTapFrames < MARS_DOUBLE_TAP_FRAMES; +#endif if (isDoubleTap && p.HasCollectible(COLLECTIBLE_MARS) && p.marsCooldown < 1) { if (ItemConfig_Item* mars = g_manager->itemConfig.GetCollectible(COLLECTIBLE_MARS)) diff --git a/src/entity/player/health.cpp b/src/entity/player/health.cpp index 15aa60e..3639db8 100644 --- a/src/entity/player/health.cpp +++ b/src/entity/player/health.cpp @@ -96,7 +96,8 @@ static HealthType character_health_type(int playerType) HealthType Entity_Player::GetHealthType() { #ifdef ISAAC_REPENTOGON - return (HealthType)player_health_type_evaluate(*this, character_health_type(playerType)); + return (HealthType)player_health_type_evaluate(*this, + player_health_type_get(playerType, character_health_type(playerType))); #else return character_health_type(playerType); #endif @@ -108,7 +109,9 @@ HealthType Entity_Player::GetHealthType() int Entity_Player::GetHeartLimit(bool isKeeperBypass) { #ifdef ISAAC_REPENTOGON - if (std::optional limit = heart_limit_hook(*this, isKeeperBypass)) return *limit; + std::optional hooked = heart_limit_hook(*this, isKeeperBypass); + if (std::optional xmlLimit = player_health_limit_get(playerType)) return *xmlLimit; + if (hooked) return *hooked; #endif if (g_game->deathmatchManager.is_active()) return HEART_LIMIT_DEATHMATCH; if (variant == PLAYER_VARIANT_PLAYER) @@ -737,7 +740,11 @@ void Entity_Player::AddCoins(int amount) } bool isDeepPockets = g_game->playerManager.FirstCollectibleOwner(COLLECTIBLE_DEEP_POCKETS, LAZARUS_SHARE_CHECK); - numCoins = std::max(0, std::min(numCoins + coins, isDeepPockets ? DEEP_POCKETS_COIN_MAX : CONSUMABLE_MAX)); + int coinMax = isDeepPockets ? DEEP_POCKETS_COIN_MAX : CONSUMABLE_MAX; +#ifdef ISAAC_REPENTOGON + coinMax = consumable_limit_get(LIMIT_COINS, coinMax); +#endif + numCoins = std::max(0, std::min(numCoins + coins, coinMax)); ConsumableCountChanged(CONSUMABLE_COINS); hud_refresh_players(); } @@ -750,7 +757,11 @@ void Entity_Player::AddBombs(int amount) AddBlueFlies(std::min(amount, BLUEBABY_B_POOP_CAP), pos, nullptr); return; } - numBombs = std::max(0, std::min(numBombs + amount, CONSUMABLE_MAX)); + int bombMax = CONSUMABLE_MAX; +#ifdef ISAAC_REPENTOGON + bombMax = consumable_limit_get(LIMIT_BOMBS, bombMax); +#endif + numBombs = std::max(0, std::min(numBombs + amount, bombMax)); ConsumableCountChanged(CONSUMABLE_BOMBS); hud_refresh_players(); } @@ -758,7 +769,11 @@ void Entity_Player::AddBombs(int amount) // 007595b0 Adds keys, up to 99. void Entity_Player::AddKeys(int amount) { - numKeys = std::max(0, std::min(numKeys + amount, CONSUMABLE_MAX)); + int keyMax = CONSUMABLE_MAX; +#ifdef ISAAC_REPENTOGON + keyMax = consumable_limit_get(LIMIT_KEYS, keyMax); +#endif + numKeys = std::max(0, std::min(numKeys + amount, keyMax)); ConsumableCountChanged(CONSUMABLE_KEYS); hud_refresh_players(); } diff --git a/src/entity/player/hud.cpp b/src/entity/player/hud.cpp index 97b1d6f..ce78e96 100644 --- a/src/entity/player/hud.cpp +++ b/src/entity/player/hud.cpp @@ -441,6 +441,9 @@ void PlayerHUD::actives_update(bool& isChanged) if (item == COLLECTIBLE_URN_OF_SOULS) path = is_judas_birthright(shown) ? URN_OF_SOULS_BELIAL_PNG : URN_OF_SOULS_PNG; if (item == COLLECTIBLE_BAG_OF_CRAFTING && slot != ACTIVE_SLOT_POCKET) path = BAG_OF_CRAFTING_PNG; +#ifdef ISAAC_REPENTOGON + if (!config->activeGfx.empty()) path = config->activeGfx; +#endif active.itemImage = Manager::LoadImage(path); } isChanged = true; @@ -899,8 +902,11 @@ void PlayerHUD::RenderHearts(Vector& outExtent, ANM2& sprite, PlayerHudLayout la float rowsY = (float)maxRow * spacingY * heartScale + at.y; float right = at.x + (float)maxColumn * stepX * heartScale + shake.x; char text[32]; - std::snprintf(text, sizeof(text), EXTRA_LIVES_FORMAT, lives, - shown.HasCollectible(COLLECTIBLE_GUPPYS_COLLAR) ? "?" : ""); + bool isChance = shown.HasCollectible(COLLECTIBLE_GUPPYS_COLLAR); +#ifdef ISAAC_REPENTOGON + isChance = isChance || custom_revives_get(shown, REVIVE_COUNT_SHOWN).isChance; +#endif + std::snprintf(text, sizeof(text), EXTRA_LIVES_FORMAT, lives, isChance ? "?" : ""); Font& font = g_manager->font6_PFTempestaSevenCondensed; float y = (-LIVES_RISE - (float)maxRow * LIVES_ROW_RISE) + rowsY + shake.y; diff --git a/src/entity/player/items.cpp b/src/entity/player/items.cpp index 8d26fd3..fa00b25 100644 --- a/src/entity/player/items.cpp +++ b/src/entity/player/items.cpp @@ -103,6 +103,10 @@ static bool is_quest_item(ItemConfig_Item* item) // one less. bool Entity_Player::HasCollectible(int collectibleType, ItemCheck check) { +#ifdef ISAAC_REPENTOGON + if (std::optional spoofed = collectible_spoof_has(*this, collectibleType, check == ITEM_CHECK_OWNED)) + return *spoofed; +#endif ItemConfig_Item* item = g_manager->itemConfig.GetCollectible(collectibleType); if (!item) return false; @@ -219,6 +223,7 @@ int Entity_Player::GetCollectibleNum(int collectibleId, ItemCheck check) { #ifdef ISAAC_REPENTOGON if (std::optional count = collectible_num_hook(*this, collectibleId, check == ITEM_CHECK_OWNED)) return *count; + if (std::optional count = collectible_spoof_count(*this, collectibleId, check == ITEM_CHECK_OWNED)) return *count; #endif if (collectibleId < 0 || collectibleId >= (int)collectibleCounts.size()) return 0; if (variant == PLAYER_VARIANT_COOP_BABY) @@ -365,6 +370,9 @@ void Entity_Player::apply_innate_collectibles() // one more copy, or one less. bool Entity_Player::HasTrinket(uint32_t trinketType, ItemCheck check) { +#ifdef ISAAC_REPENTOGON + if (std::optional spoofed = trinket_spoof_has(*this, trinketType, check == ITEM_CHECK_OWNED)) return *spoofed; +#endif bool isPreviewed = previewTrinket != 0 && previewTrinket == trinketType; if (isPreviewed && isPreviewAdded) return true; if (check == ITEM_CHECK_MODIFIED) return GetTrinketMultiplier(trinketType) > (isPreviewed ? 1 : 0); @@ -381,6 +389,9 @@ bool Entity_Player::HasTrinket(uint32_t trinketType, ItemCheck check) // Curse of the Mist and co-op ghosts keep only Lil Larva's. int Entity_Player::GetTrinketMultiplier(uint32_t trinketType) { +#ifdef ISAAC_REPENTOGON + if (std::optional spoofed = trinket_spoof_multiplier(*this, trinketType)) return *spoofed; +#endif Entity_Player& owner = *item_owner_get(this); Game& game = *g_game; uint32_t id = trinketType & TRINKET_ID_MASK; diff --git a/src/entity/player/manager.cpp b/src/entity/player/manager.cpp index 7b0ddd4..8c42cd5 100644 --- a/src/entity/player/manager.cpp +++ b/src/entity/player/manager.cpp @@ -276,6 +276,9 @@ Entity_Player* PlayerManager::SpawnCoPlayerBaby(int babyId) Entity_Player* player = player_create(playerList.size()); playerList.push_back(player); +#ifdef ISAAC_REPENTOGON + if (babyId < 0 && !repentogonOptions.isVanillaParity) babyId = baby_random_get(Random()).id; +#endif if (babyId < 0) { babyId = BABY_COUNT; diff --git a/src/entity/player/mist.cpp b/src/entity/player/mist.cpp index abebeb7..b979849 100644 --- a/src/entity/player/mist.cpp +++ b/src/entity/player/mist.cpp @@ -101,11 +101,19 @@ void Entity_Player::RemoveCurseMistEffect() int coinCap = players.FirstCollectibleOwner(COLLECTIBLE_DEEP_POCKETS, LAZARUS_SHARE_CHECK) ? MIST_DEEP_POCKETS_COIN_CAP : MIST_CONSUMABLE_CAP; + int keyCap = MIST_CONSUMABLE_CAP; + int bombCap = MIST_CONSUMABLE_CAP; +#ifdef ISAAC_REPENTOGON + coinCap = consumable_limit_get(LIMIT_COINS, coinCap); + keyCap = consumable_limit_get(LIMIT_KEYS, keyCap); + bombCap = consumable_limit_get(LIMIT_BOMBS, bombCap); +#endif + int poopCap = players.FirstBirthrightOwner(PLAYER_BLUEBABY_B) ? MIST_BIRTHRIGHT_POOP_MANA_CAP : MIST_POOP_MANA_CAP; backup.coins = std::min(numCoins + backup.coins, coinCap); - backup.keys = std::min(numKeys + backup.keys, MIST_CONSUMABLE_CAP); - backup.bombs = std::min(backup.bombs + numBombs, MIST_CONSUMABLE_CAP); + backup.keys = std::min(numKeys + backup.keys, keyCap); + backup.bombs = std::min(backup.bombs + numBombs, bombCap); backup.isGoldenKey = backup.isGoldenKey || hasGoldenKey; backup.isGoldenBomb = backup.isGoldenBomb || hasGoldenBomb; backup.gigaBombs = std::min(backup.gigaBombs + numGigaBombs, backup.bombs); diff --git a/src/entity/player/player.cpp b/src/entity/player/player.cpp index 67bae24..608dda7 100644 --- a/src/entity/player/player.cpp +++ b/src/entity/player/player.cpp @@ -24,6 +24,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/player.h" +#include "repentogon/save_state_manager.h" #endif constexpr float PLAYER_START_TEAR_HEIGHT = -23.75f; @@ -137,6 +138,9 @@ Entity_Player::Entity_Player() pocketItems.fill({0, POCKET_CARD}); curseMistPocketItems.fill({0, POCKET_CARD}); ghostPocketItems.fill({0, POCKET_CARD}); +#ifdef ISAAC_REPENTOGON + entity_created_notify(*this); +#endif } // 00754ed0, 00754d60 Unlinks the twin and frees a sub player the room does not hold, then forgets being a transition's. @@ -283,6 +287,9 @@ void Entity_Player::Init(int entityType, int entityVariant, int subType, uint32_ AddActiveCharge(BETHANY_START_CHARGE, 0, false, false, false); } static_cast(g_luaEngine)->PostPlayerInit(this); +#ifdef ISAAC_REPENTOGON + player_hearts_init(*this, subType); +#endif } // Resets the counters and stats Init starts every player with. @@ -805,6 +812,7 @@ void Entity_Player::starting_trinket_add(int id) void Entity_Player::InitPostLevelInitStats() { #ifdef ISAAC_REPENTOGON + item_spoofs_player_check(*this, false); ScopeExit statsPost = {[this] { player_level_stats_post_init(*this); }}; #endif Game& game = *g_game; diff --git a/src/entity/player/player.h b/src/entity/player/player.h index 04eda31..8c93266 100644 --- a/src/entity/player/player.h +++ b/src/entity/player/player.h @@ -7,6 +7,7 @@ #include "online/emotes.h" #include "entity/player/temporary_effects.h" #include "entity/weapon/weapon.h" +#include "repentogon/save_state_id.h" #include #include #include @@ -16,6 +17,10 @@ #include #include #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/custom_cache.h" +#include "repentogon/item_spoof.h" +#endif struct DeliriousBoss; @@ -1376,6 +1381,9 @@ struct FamiliarData uint32_t initSeed = 0; bool isNotCountedAsFollower = false; bool isSubtype55555 = false; +#ifdef ISAAC_REPENTOGON + SaveStateId saveStateId; +#endif }; // Coins, keys, bombs and charges, as Curse of the Mist keeps them aside. @@ -1840,6 +1848,9 @@ public: bool isEvaluatingHealthType = false; // REPENTOGON's camoOverride (EntityPlayerPlus): a mod's SetForceCamoEffect fades the player as Camo Undies does. bool isCamoForced = false; + // REPENTOGON's itemSpoofs (EntityPlayerPlus): its innate and blocked collectibles and trinkets. + PlayerItemSpoofs itemSpoofs; + CustomCacheState customCache; #endif // Set while EvaluateItems spawns the players Found Soul and Strawman give, who start without pickups. static inline bool isSpawningHelperPlayers = false; diff --git a/src/entity/player/tears.cpp b/src/entity/player/tears.cpp index 1b136fe..b1326a4 100644 --- a/src/entity/player/tears.cpp +++ b/src/entity/player/tears.cpp @@ -411,8 +411,13 @@ static bool is_bloody(Entity_Player& player, const TearHitState& state) bool isBloodyBaby = familiar && familiar->variant == Entity_Familiar::BLOOD_BABY && (familiar->subtype == BLOOD_BABY_RED || familiar->subtype == BLOOD_BABY_ROTTEN || familiar->subtype == BLOOD_BABY_BROKEN); - return (effects.HasCollectibleEffect(COLLECTIBLE_SCOOPER) && state.isRightEye) || type == PLAYER_ESAU || - type == PLAYER_JUDAS_B || type == PLAYER_LAZARUS2_B || type == PLAYER_BETHANY_B || isBloodyBaby || +#ifdef ISAAC_REPENTOGON + bool isCharacterBloody = is_player_bloody_tears(player); +#else + bool isCharacterBloody = + type == PLAYER_ESAU || type == PLAYER_JUDAS_B || type == PLAYER_LAZARUS2_B || type == PLAYER_BETHANY_B; +#endif + return (effects.HasCollectibleEffect(COLLECTIBLE_SCOOPER) && state.isRightEye) || isCharacterBloody || isBloodyBaby || std::ranges::any_of(std::array{NULLITEM_BLOOD_OATH, NULLITEM_INTRUDER, NULLITEM_JUDAS_BIRTHRIGHT, NULLITEM_JUDAS_BIRTHRIGHT_TIMED, NULLITEM_JUDAS_BIRTHRIGHT_STAGE, NULLITEM_JUDAS_BIRTHRIGHT_PERMANENT, NULLITEM_ESAU_JR}, diff --git a/src/entity/player/trinkets.cpp b/src/entity/player/trinkets.cpp index 7d725f1..0809959 100644 --- a/src/entity/player/trinkets.cpp +++ b/src/entity/player/trinkets.cpp @@ -111,6 +111,9 @@ void Entity_Player::remove_wooden_cross_mantles() // 00771620 Whether the player holds the trinket golden, in a slot or smelted, or previews it golden. bool Entity_Player::HasGoldenTrinket(uint32_t trinketId) { +#ifdef ISAAC_REPENTOGON + if (std::optional spoofed = golden_trinket_spoof_has(*this, trinketId)) return *spoofed; +#endif for (int i = 0; i < GetMaxTrinkets(); i++) if ((trinkets[i] & TRINKET_ID_MASK) == trinketId && (trinkets[i] & TRINKET_GOLDEN_FLAG)) return true; if (trinketId < smeltedTrinkets.size() && smeltedTrinkets[trinketId].goldenCount > 0) return true; diff --git a/src/entity/player/weapons.cpp b/src/entity/player/weapons.cpp index 7e2547b..d3c97d0 100644 --- a/src/entity/player/weapons.cpp +++ b/src/entity/player/weapons.cpp @@ -17,6 +17,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/player.h" #endif // Stye's right eye tears float longer. @@ -359,6 +360,9 @@ Weapon_MultiShotParams Entity_Player::GetMultiShotParams(WeaponType weaponType) params.numRandomDirTears = (short)(Random() % LUNG_RANDOM_RANGE + LUNG_RANDOM_ROCKETS); else if (isLung && (weaponType == WEAPON_BRIMSTONE || weaponType == WEAPON_TECH_X)) params.numRandomDirTears = (short)(Random() % LUNG_RANDOM_RANGE + LUNG_RANDOM_LASERS); +#ifdef ISAAC_REPENTOGON + multi_shot_params_evaluate(*this, params, weaponType); +#endif return params; } diff --git a/src/entity/save_state.h b/src/entity/save_state.h index 9fec175..82ae3de 100644 --- a/src/entity/save_state.h +++ b/src/entity/save_state.h @@ -1,6 +1,7 @@ #pragma once #include "classes.h" +#include "repentogon/save_state_id.h" #include #include #include @@ -42,4 +43,7 @@ struct EntitySaveState uint8_t byteStorage = 1; bool boolStorage1 = false; bool boolStorage2 = false; +#ifdef ISAAC_REPENTOGON + SaveStateId saveStateId; +#endif }; diff --git a/src/entity/status.cpp b/src/entity/status.cpp index 4119dfc..1001437 100644 --- a/src/entity/status.cpp +++ b/src/entity/status.cpp @@ -13,6 +13,7 @@ #include #include #ifdef ISAAC_REPENTOGON +#include "repentogon/options.h" #include "repentogon/status.h" #endif @@ -544,7 +545,8 @@ void Entity::AddBaited(const EntityRef& source, int duration) } // 006b77d0 Weakens the entity unless a friend did it, tinted purple, whatever its status guards. -// The original ignores the duration it is given and always weakens for three frames or more. +// The original ignores the duration it is given and always weakens for three frames or more. REPENTOGON takes it, +// without vanilla parity. void Entity::AddWeakness(const EntityRef& source, int requestedDuration) { #ifdef ISAAC_REPENTOGON @@ -553,7 +555,11 @@ void Entity::AddWeakness(const EntityRef& source, int requestedDuration) if (statusScope.isCancelled) return; #endif if (IsDamageSourceFriendly(source)) return; - int duration = apply_second_hand_duration(WEAKNESS_DURATION, source); + int duration = WEAKNESS_DURATION; +#ifdef ISAAC_REPENTOGON + if (!repentogonOptions.isVanillaParity) duration = requestedDuration; // Patches/ASMPatches/ASMStatusEffects.cpp +#endif + duration = apply_second_hand_duration(duration, source); Entity& head = *GetStatusEffectTarget(); if (duration == 0) return; diff --git a/src/entity/weapon/knife.cpp b/src/entity/weapon/knife.cpp index 64ee103..5ee9e3f 100644 --- a/src/entity/weapon/knife.cpp +++ b/src/entity/weapon/knife.cpp @@ -23,6 +23,8 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/weapons.h" +#include "repentogon/vanilla_fixes.h" #endif constexpr float KNIFE_DAMAGE_DEFAULT = 22; @@ -402,6 +404,9 @@ void Entity_Knife::Init(int knifeType, int knifeVariant, int knifeSubType, uint3 sprite.GetLayer(1)->isVisible = isHeldItem; if (knife_kind(variant) == KNIFE_KIND_SWORD) sprite.GetLayer(2)->isVisible = isHeldItem; } +#ifdef ISAAC_REPENTOGON + knife_homing_path_init(*this); +#endif lua_engine_get().PostKnifeInit(this); } @@ -851,6 +856,9 @@ void Entity_Knife::sword_beam_fire(Entity_Player* player) tear.fScale = tear.baseScale; tear.ResetSpriteScale(); tear.Update(); +#ifdef ISAAC_REPENTOGON + split_tear_post(tear, *this, SPLIT_SWORD_BEAM); +#endif } // 00961b00 One frame of a knife: held around or thrown out from its owner (or steered as Ludovico's), following a homing diff --git a/src/entity/weapon/knife_hits.cpp b/src/entity/weapon/knife_hits.cpp index fb380f9..88a819b 100644 --- a/src/entity/weapon/knife_hits.cpp +++ b/src/entity/weapon/knife_hits.cpp @@ -18,6 +18,10 @@ #include "entity/weapon/weapon.h" #include #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/entities.h" +#include "repentogon/weapons.h" +#endif // The player swinging a Notched Axe this frame, whose rocks and poop roll the axe's rewards (DAT_00c7ac6c). Entity_Player* g_notchedAxePlayer = nullptr; @@ -480,7 +484,11 @@ static bool swing_enemy_hit(Entity_Knife& knife, Entity& enemy, SwingHit& hit) if (enemy.type == ENTITY_FIREPLACE && enemy.variant != FIREPLACE_HARD_VARIANT) { - enemy.TakeDamage(FIREPLACE_SWING_DAMAGE, 0, EntityRef(knife.parent), SWING_COUNTDOWN); + EntityRef swinger(knife.parent); +#ifdef ISAAC_REPENTOGON + ExtraDamageSource extra{swinger, &knife}; +#endif + enemy.TakeDamage(FIREPLACE_SWING_DAMAGE, 0, swinger, SWING_COUNTDOWN); hit.isHit = true; return true; } @@ -513,7 +521,11 @@ static bool swing_enemy_hit(Entity_Knife& knife, Entity& enemy, SwingHit& hit) } uint64_t damageFlags = swing_damage_flags(knife, enemy, hit.player); - if (enemy.TakeDamage(hit.damage, damageFlags, EntityRef(knife.parent), SWING_COUNTDOWN)) + EntityRef swinger(knife.parent); +#ifdef ISAAC_REPENTOGON + ExtraDamageSource extra{swinger, &knife}; +#endif + if (enemy.TakeDamage(hit.damage, damageFlags, swinger, SWING_COUNTDOWN)) { if (enemy.IsVulnerableEnemy(nullptr)) { @@ -613,7 +625,12 @@ static void swing_other_hit(Entity_Knife& knife, Entity& entity, SwingHit& hit) swing_hit_add(hits, pickup); swing_push(pickup, knife.pos, hit.knockback); - if (player && (pickup.CanBePickedUp(isBag) || Entity_Pickup::IsChest(pickup.variant))) + #ifdef ISAAC_REPENTOGON + bool isGrabbed = pickup_grab_check(pickup, isBag ? PICKUP_GRABBER_BAG : PICKUP_GRABBER_SWING, isBag); +#else + bool isGrabbed = pickup.CanBePickedUp(isBag); +#endif + if (player && (isGrabbed || Entity_Pickup::IsChest(pickup.variant))) if (!isBag || !player->bag_of_crafting_collect(&pickup)) Entity::ForceCollide(player, &pickup, true); if (Entity_Pickup::IsChest(pickup.variant)) pickup.TakeDamage(hit.damage, knife.variant == KNIFE_NOTCHED_AXE ? DAMAGE_CRUSH : 0, EntityRef(knife.parent), @@ -661,7 +678,7 @@ static bool swing_effect_spawn(Entity_Knife& knife, Entity_Player* player, const Entity_Knife& swing = *static_cast(spawned); swing.parent = owner; #ifdef ISAAC_REPENTOGON - swing.hitboxSource = &knife; + swing.hitboxSource = &knife; // Patches/ASMPatches/ASMEntityKnife.cpp #endif swing.targetPosition.y = 0; if (knife.swingTick == 0) @@ -922,6 +939,9 @@ void Entity_Knife::apply_hit_effects(const KnifeHit& hit) tear.fallingSpeed = (random_unit() * HAEMO_FALL_SPREAD + BURST_FALL_MIN) * (tearHeight * 0.5f); tear.SetColor(sprite.color, -1, COLOR_PRIORITY_DEFAULT, false, true); tear.Update(); +#ifdef ISAAC_REPENTOGON + split_tear_post(tear, *this, SPLIT_BURST); +#endif Entity* trail = g_game->Spawn({.position = tear.pos, .velocity = vector_scale(tear.velocity, BURST_TRAIL_SPEED), @@ -951,6 +971,9 @@ void Entity_Knife::apply_hit_effects(const KnifeHit& hit) shard.fallingSpeed = random_unit() * SHARD_FALL_SPREAD - fall; shard.SetTearFlags(flags_without(tearFlags, QUAD_SHARD_DROPPED)); shard_finish(*this, shard, scaleY, player); +#ifdef ISAAC_REPENTOGON + split_tear_post(shard, *this, SPLIT_QUAD); +#endif } } } @@ -1034,6 +1057,9 @@ void Entity_Knife::apply_hit_effects(const KnifeHit& hit) shard.SetColor(sprite.color, -1, COLOR_PRIORITY_DEFAULT, false, true); shard.parent = player; shard.Update(); +#ifdef ISAAC_REPENTOGON + split_tear_post(shard, *this, SPLIT_PARASITE); +#endif } if (tearFlags[TEAR_BONE_FLAG]) @@ -1053,6 +1079,9 @@ void Entity_Knife::apply_hit_effects(const KnifeHit& hit) shard.fallingSpeed = fallSpeed; shard.SetTearFlags(flags_without(tearFlags, BONE_SHARD_DROPPED)); shard_finish(*this, shard, scaleY, player); +#ifdef ISAAC_REPENTOGON + split_tear_post(shard, *this, SPLIT_BONE); +#endif } if (tearFlags[TEAR_JACOBS]) @@ -1095,5 +1124,8 @@ void Entity_Knife::apply_hit_effects(const KnifeHit& hit) tear.baseScale = std::max(scale, SHARD_SCALE_MIN); tear.fScale = tear.baseScale; tear.ResetSpriteScale(); +#ifdef ISAAC_REPENTOGON + split_tear_post(tear, *this, SPLIT_STICKY); +#endif Entity::ForceCollide(&tear, &target, true); } diff --git a/src/entity/weapon/laser.cpp b/src/entity/weapon/laser.cpp index 389b68c..8c0c892 100644 --- a/src/entity/weapon/laser.cpp +++ b/src/entity/weapon/laser.cpp @@ -21,7 +21,9 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/ui_patches.h" #include "repentogon/weapons.h" +#include "repentogon/entities.h" #endif constexpr float THIN_SCALE_THRESHOLDS[] = {1.15f, 2.2f, 4.2f}; @@ -329,6 +331,9 @@ bool Entity_Laser::CanDamageEntity(Entity* entity) (entity->variant == Entity_Familiar::ISAACS_HEART || entity->variant == Entity_Familiar::PUNCHING_BAG || entity->variant == Entity_Familiar::LOST_SOUL || entity->variant == Entity_Familiar::MILK || (entity->variant == Entity_Familiar::WISP && entity->subtype == WISP_DAMAGED_SUBTYPE)); +#ifdef ISAAC_REPENTOGON + if (entity->type == ENTITY_FAMILIAR) isDamagedFamiliar = familiar_laser_hit_get(*entity, isDamagedFamiliar); +#endif bool isHittable = entity != owner && !entity->isDead && entity->entityCollisionClass != ENTCOLL_NONE && entity->maxHitPoints > 0; bool isOtherKind = (parentType == ENTITY_PLAYER && isVersus) || parentType != entity->type || isCharmedParent; @@ -403,8 +408,12 @@ void Entity_Laser::set_aim_angle(float angle) } // 0096f4e0 Forgets the path, and sets it up again for a ring (which ignores the grid) or a line, or a homing one. +// REPENTOGON first takes the homing from a laser a tear fired. void Entity_Laser::ClearLaserSamples() { +#ifdef ISAAC_REPENTOGON + laser_samples_clear_pre(*this); +#endif homingLaser.bezier.clear(); homingLaser.samples.clear(); homingLaser.smoothedSamples.clear(); @@ -1899,6 +1908,9 @@ void Entity_Laser::pop_tear_fire() auto at = std::lower_bound(tear->hitList.begin(), tear->hitList.end(), hit); if (at == tear->hitList.end() || *at != hit) tear->hitList.insert(at, hit); } +#ifdef ISAAC_REPENTOGON + split_tear_post(*tear, *this, SPLIT_POP); +#endif } // Cricket's Body: two beams leave across the beam a little before where it hit, easing along with the hit (or from diff --git a/src/entity/weapon/laser_hits.cpp b/src/entity/weapon/laser_hits.cpp index a6ee38d..a52ac7b 100644 --- a/src/entity/weapon/laser_hits.cpp +++ b/src/entity/weapon/laser_hits.cpp @@ -23,6 +23,8 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/entities.h" +#include "repentogon/weapons.h" #endif constexpr float LASER_KNOCKBACK = 1.8f; @@ -126,6 +128,24 @@ static void laser_push(Entity_Laser& laser, Entity& entity, Vector direction, fl vector_add(entity.velocity, vector_scale(direction, strength * entity.speedMultiplier / entity.friction)); } +// What a laser deals a hit: its damage and flags. +struct LaserDamage +{ + float damage; + uint64_t damageFlags; +}; + +// Hurts an entity with a laser's hit, from the laser's spawner (or the laser) as the source. With REPENTOGON the +// laser itself is the hit's ExtraSource. +static void laser_damage_deal(Entity_Laser& laser, Entity& target, LaserDamage hit) +{ + EntityRef source(laser.spawnerEntity ? laser.spawnerEntity.get() : &laser); +#ifdef ISAAC_REPENTOGON + ExtraDamageSource extra{source, &laser}; +#endif + target.TakeDamage(hit.damage, hit.damageFlags, source, HIT_COUNTDOWN); +} + // 0097e3c0 Hits an entity: it joins the hit list, then takes the laser's damage and tear effects from its spawner. A // player outside a versus match (and the familiars that take a player's hits) takes one heart's hit. Bombs are // spared. A Brimstone-marked entity takes a thick beam's hit harder, and Black Hp drops are rolled from its seed. @@ -141,13 +161,12 @@ void Entity_Laser::DoDamage(Entity* entity, float damage) if (slot == hits.end() || *slot != hitIndex) hits.insert(slot, hitIndex); if (entity->type == ENTITY_BOMB) return; - Entity* source = spawnerEntity ? spawnerEntity.get() : this; bool isVersus = g_game->deathmatchManager.is_active(); if (entity->type == ENTITY_PLAYER) { if (!isVersus) { - entity->TakeDamage(PLAYER_HIT_DAMAGE, DAMAGE_LASER, EntityRef(source), HIT_COUNTDOWN); + laser_damage_deal(*this, *entity, {PLAYER_HIT_DAMAGE, DAMAGE_LASER}); return; } if (IsDescendantOf(entity)) return; @@ -157,7 +176,7 @@ void Entity_Laser::DoDamage(Entity* entity, float damage) (g_game->challenge == CHALLENGE_GUARDIAN && entity->variant == Entity_Familiar::PUNCHING_BAG))) { Entity_Player* player = static_cast(entity)->player; - player->TakeDamage(PLAYER_HIT_DAMAGE, DAMAGE_LASER | DAMAGE_ISAAC_HURT, EntityRef(source), HIT_COUNTDOWN); + laser_damage_deal(*this, *player, {PLAYER_HIT_DAMAGE, DAMAGE_LASER | DAMAGE_ISAAC_HURT}); return; } @@ -178,7 +197,7 @@ void Entity_Laser::DoDamage(Entity* entity, float damage) if (roll.RandomFloat() < blackHpDropChance) damageFlags |= DAMAGE_SPAWN_BLACK_HEART; } if (isVersus && tearFlags[TEAR_LASERSHOT]) damageFlags |= DAMAGE_THROUGH_COOLDOWN; - entity->TakeDamage(damage, damageFlags, EntityRef(source), HIT_COUNTDOWN); + laser_damage_deal(*this, *entity, {damage, damageFlags}); } // 00971590 Hurts the grid entity in a cell the beam crosses. One time in four a standing one is broken by an Acid or @@ -483,6 +502,9 @@ static void sticking_tear_fire(Entity_Laser& laser, Entity& entity, const Vector tear->baseScale = tearScale; tear->fScale = tearScale; tear->ResetSpriteScale(); +#ifdef ISAAC_REPENTOGON + split_tear_post(*tear, laser, SPLIT_STICKY); +#endif Entity::ForceCollide(tear, &entity, true); } @@ -724,6 +746,9 @@ void Entity_Laser::impact_split(const Vector& position, const Vector& direction, tear->ResetSpriteScale(); tear->SetColor(color, -1, COLOR_PRIORITY_DEFAULT, false, true); tear->Update(); +#ifdef ISAAC_REPENTOGON + split_tear_post(*tear, *this, SPLIT_QUAD); +#endif float turned = velocity.x * stepSine; velocity.x = velocity.x * stepCosine - velocity.y * stepSine; diff --git a/src/entity/weapon/projectile.cpp b/src/entity/weapon/projectile.cpp index be56546..0847283 100644 --- a/src/entity/weapon/projectile.cpp +++ b/src/entity/weapon/projectile.cpp @@ -26,6 +26,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/entities.h" #endif // The shot a fresh projectile is: its height, slight random fall, homing, curving and change defaults. @@ -2641,8 +2642,13 @@ bool Entity_Projectile::enemy_hit(Entity* collider) bool Entity_Projectile::familiar_hit(Entity* collider) { bool isLava = variant == PROJECTILE_LAVA; - if (collider->type != ENTITY_FAMILIAR || !is_listed(HURT_FAMILIARS, collider->variant)) return isLava; - if (collider->variant == SPARED_FAMILIAR && collider->subtype == SPARED_FAMILIAR_SUBTYPE) return isLava; + bool isHurt = collider->type == ENTITY_FAMILIAR && is_listed(HURT_FAMILIARS, collider->variant) && + !(collider->variant == SPARED_FAMILIAR && collider->subtype == SPARED_FAMILIAR_SUBTYPE); +#ifdef ISAAC_REPENTOGON + isHurt = isHurt || (collider->type == ENTITY_FAMILIAR && is_custom_tagged(*collider, CUSTOM_TAG_CAN_TAKE_DAMAGE) && + is_custom_tagged(*collider, CUSTOM_TAG_BLOCK_PROJECTILES)); +#endif + if (!isHurt) return isLava; if (projectileFlags & PROJECTILE_CANT_HIT_PLAYER) return true; isDead = true; diff --git a/src/entity/weapon/tear.cpp b/src/entity/weapon/tear.cpp index ab8933b..8e41b74 100644 --- a/src/entity/weapon/tear.cpp +++ b/src/entity/weapon/tear.cpp @@ -2270,6 +2270,9 @@ Entity_Tear* Entity_Tear::MakeMultidimensionalCopy(Entity* spawner) copy.continueVelocity = continueVelocity; copy.parent = parent; copy.spawnerEntity = spawner; +#ifdef ISAAC_REPENTOGON + split_tear_post(copy, *this, SPLIT_MULTIDIMENSIONAL); +#endif return © } diff --git a/src/entity/weapon/tear_death.cpp b/src/entity/weapon/tear_death.cpp index cb19d41..8f76eea 100644 --- a/src/entity/weapon/tear_death.cpp +++ b/src/entity/weapon/tear_death.cpp @@ -17,6 +17,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/weapons.h" #endif // The splash a dying tear leaves: the poof sizes by its scale, the volumes and pitches of the sounds, the particles @@ -510,6 +511,9 @@ void Entity_Tear::quadsplit_fire(bool isRising) piece.SetColor(sprite.color, -1, TEAR_COLOR_PRIORITY, false, true); piece.parent = parent; piece.Update(); +#ifdef ISAAC_REPENTOGON + split_tear_post(piece, *this, SPLIT_QUAD); +#endif } } @@ -627,6 +631,9 @@ void Entity_Tear::split_fire(bool isRising) piece.fScale = piece.baseScale; piece.ResetSpriteScale(); child_setup(piece, flags, alpha); +#ifdef ISAAC_REPENTOGON + split_tear_post(piece, *this, SPLIT_PARASITE); +#endif } } @@ -659,6 +666,9 @@ void Entity_Tear::bone_shards_fire(bool isRising) shard.fallingSpeed = fallingSpeed; shard.SetCollisionDamage(collisionDamage * BONE_DAMAGE); child_setup(shard, flags, alpha); +#ifdef ISAAC_REPENTOGON + split_tear_post(shard, *this, SPLIT_BONE); +#endif } } @@ -797,5 +807,8 @@ void Entity_Tear::fire_split_projectiles(bool isHalved) piece.isPrismTouched = isPrismTouched; piece.isMultidimensionalTouched = isMultidimensionalTouched; piece.Update(); +#ifdef ISAAC_REPENTOGON + split_tear_post(piece, *this, SPLIT_BURST); +#endif } } diff --git a/src/entity/weapon/tear_flags.cpp b/src/entity/weapon/tear_flags.cpp index 6b6c8fe..bb8ae44 100644 --- a/src/entity/weapon/tear_flags.cpp +++ b/src/entity/weapon/tear_flags.cpp @@ -22,6 +22,9 @@ #include "game/sfx_manager.h" #include #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/weapons.h" +#endif // Remote Detonator's tears blow up at once when its player sets it off. constexpr float DETONATE_DAMAGE = 3; @@ -963,9 +966,14 @@ bool Entity_Tear::absorb_burst(float shotSpeed) piece.isMultidimensionalTouched = isMultidimensionalTouched; piece.isPrismTouched = isPrismTouched; piece.targetPosition = pos; - if (!tearFlags[TEAR_HYDROBOUNCE]) continue; - piece.fallingSpeed = ABSORB_HYDRO_FALL - piece.fallingSpeed; - piece.fallingAccel = ABSORB_HYDRO_ACCEL; + if (tearFlags[TEAR_HYDROBOUNCE]) + { + piece.fallingSpeed = ABSORB_HYDRO_FALL - piece.fallingSpeed; + piece.fallingAccel = ABSORB_HYDRO_ACCEL; + } +#ifdef ISAAC_REPENTOGON + split_tear_post(piece, *this, SPLIT_ABSORB); +#endif } Remove(); return true; @@ -1403,6 +1411,9 @@ void Entity_Tear::spores_burst() hit_list_insert(spore.hitList, *stickTarget); spore.AddEntityFlags(FLAG_REDUCE_GIBS); spore.Update(); +#ifdef ISAAC_REPENTOGON + split_tear_post(spore, *this, SPLIT_SPORE); +#endif } } @@ -1467,6 +1478,9 @@ void Entity_Tear::ludovico_stick_copy(Entity& enemy) int displacement = (int)(Random() & 1) * 2 - 1; copy.SetScale(player->GetTearHitParams(WEAPON_TEARS, 1, displacement, nullptr).tearScale); } +#ifdef ISAAC_REPENTOGON + split_tear_post(copy, *this, SPLIT_STICKY); +#endif g_forceCollideDepth++; copy.HandleCollision(&enemy, true); enemy.HandleCollision(©, false); diff --git a/src/entity/weapon/weapon.cpp b/src/entity/weapon/weapon.cpp index 27d63d2..763e10b 100644 --- a/src/entity/weapon/weapon.cpp +++ b/src/entity/weapon/weapon.cpp @@ -29,6 +29,10 @@ #include "entity/weapon/urn_of_souls.h" #include #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/callbacks.h" +#include "repentogon/weapons.h" +#endif constexpr float EYE_DROPS_FAST_RATE = 0.5833333f; constexpr float EYE_DROPS_SLOW_RATE = 0.41666666f; @@ -250,6 +254,9 @@ void Weapon::technology2_extra_lasers(Entity_Player& player, const Vector& aim) // Horns may add lasers. Letting go removes it, unless a room transition is on. The umbilical whip has none. void Weapon::Fire(const Vector& shootDirection, bool isShooting, bool isInterpolated) { +#ifdef ISAAC_REPENTOGON + ScopeExit post{[&] { weapon_fire_post(*this, shootDirection, isShooting, isInterpolated); }}; +#endif Entity_Player* player = owner_player(); Entity_Laser* laser = static_cast(technology2Laser.get()); bool isTechnology2 = player && player->HasCollectible(COLLECTIBLE_TECHNOLOGY_2) && weaponType != WEAPON_UMBILICAL_WHIP; @@ -727,6 +734,9 @@ static void lead_pencil_fire(Weapon& weapon, Entity_Player& player) // add their own, counting the shots fired. Without a shot direction it aims the weapon's or the player's way. void Weapon::TriggerTearEffects(const Vector& shootDirection, int count) { +#ifdef ISAAC_REPENTOGON + ScopeExit post{[&] { weapon_fired_post(*this, shootDirection, count); }}; +#endif if (count < 1) return; Entity_Player* player = owner_player(); diff --git a/src/game/end.cpp b/src/game/end.cpp index eeed24c..980ea78 100644 --- a/src/game/end.cpp +++ b/src/game/end.cpp @@ -16,6 +16,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/player.h" #include "repentogon/saves.h" #endif @@ -144,7 +145,11 @@ void rerun_save() GameState& gamestate = manager.gamestate; Entity_Player& player = *game.GetPlayer(0); +#ifdef ISAAC_REPENTOGON + if (player.isDead && extra_lives_all_get(player) < 1) return; +#else if (player.isDead && player.GetExtraLives() < 1) return; +#endif if (!manager.persistentGameData.Unlocked(ACHIEVEMENT_RERUN)) return; game.store_game_state(gamestate); if (gamestate.isRerun) return; diff --git a/src/game/game.cpp b/src/game/game.cpp index 9e52075..786dc93 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -25,6 +25,8 @@ extern "C" } #ifdef ISAAC_REPENTOGON #include "repentogon/level.h" +#include "repentogon/ui_patches.h" +#include "repentogon/xml.h" #endif constexpr const char* STAGES_XML = "stages.xml"; @@ -271,6 +273,9 @@ bool Game::load_giantbook_xml(std::string_view path) entry.id = id; if ((unsigned)id < GIANTBOOK_ENTRY_COUNT) giantbookEntries[id] = std::move(entry); } +#ifdef ISAAC_REPENTOGON + giantbooks_content_load(*root); +#endif return true; } @@ -303,8 +308,29 @@ bool Game::load_bossoverlays_xml(std::string_view path) return true; } +// A Boss Rush spawn slot of ambush.xml: from its first on, each element's boss count times. +static void boss_rush_slot_read(Ambush& ambush, DataNode slotNode) +{ + BossRushWave& slot = ambush.bossRushWaves.emplace_back(); + bool isEnemyStarted = false; + for (DataNode enemyNode : node_children(slotNode)) + { + isEnemyStarted = isEnemyStarted || node_tag(enemyNode) == "enemy"; + if (!isEnemyStarted) continue; + + BossRushEntry spawn; + int count = 1; + spawn.type = std::atoi(node_attr(enemyNode, "type").data()); + spawn.variant = std::atoi(node_attr(enemyNode, "variant").data()); + if (auto text = node_attr_find(enemyNode, "chunks")) spawn.chunks = std::atoi(text->data()); + if (auto text = node_attr_find(enemyNode, "count")) count = std::atoi(text->data()); + slot.insert(slot.end(), std::max(count, 0), spawn); + } +} + // 00834680 Reads ambush.xml's into the Boss Rush: its wave counts, then from its first on, a slot -// for each element, holding from its first on each element's boss count times. A missing file changes nothing. +// for each element. A missing file changes nothing. With REPENTOGON, each mod's content ambush.xml adds its +// slots after them. // The original crashes on a file without . Here that leaves the Boss Rush empty. void Game::LoadBossRushXml(std::string_view path) { @@ -324,24 +350,14 @@ void Game::LoadBossRushXml(std::string_view path) for (DataNode slotNode : node_children(*root)) { isSlotStarted = isSlotStarted || node_tag(slotNode) == "spawn"; - if (!isSlotStarted) continue; - - BossRushWave& slot = ambush.bossRushWaves.emplace_back(); - bool isEnemyStarted = false; - for (DataNode enemyNode : node_children(slotNode)) - { - isEnemyStarted = isEnemyStarted || node_tag(enemyNode) == "enemy"; - if (!isEnemyStarted) continue; - - BossRushEntry spawn; - int count = 1; - spawn.type = std::atoi(node_attr(enemyNode, "type").data()); - spawn.variant = std::atoi(node_attr(enemyNode, "variant").data()); - if (auto text = node_attr_find(enemyNode, "chunks")) spawn.chunks = std::atoi(text->data()); - if (auto text = node_attr_find(enemyNode, "count")) count = std::atoi(text->data()); - slot.insert(slot.end(), std::max(count, 0), spawn); - } + if (isSlotStarted) boss_rush_slot_read(ambush, slotNode); } +#ifdef ISAAC_REPENTOGON + content_files_load("ambush.xml", [&](Data& mod, ModEntry&) { + if (std::optional modRoot = data_root_get(mod, "bossrush")) + for (DataNode slotNode : node_children(*modRoot)) boss_rush_slot_read(ambush, slotNode); + }); +#endif } // 006f43b0 Clears the run back to a fresh one: counters, fades, debug flags, the daily, score sheet and screen effects. @@ -1048,6 +1064,9 @@ static void effects_resolve(Game& game, bool isRoomSnapshot, bool isOldTv) void Game::Render() { KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager; +#ifdef ISAAC_REPENTOGON + game_render_mark(true); +#endif OptionsConfig& options = g_manager->optionsConfig; bool isOldTv = seedEffects.HasSeedEffect(SEED_OLD_TV); bool isTransitionShown = roomTransition.mode == TRANSITION_OUT || roomTransition.mode == TRANSITION_IN; @@ -1094,6 +1113,9 @@ void Game::Render() overlays_render(*this); effects_resolve(*this, isRoomSnapshot, isOldTv); console.Render(); +#ifdef ISAAC_REPENTOGON + game_render_mark(false); +#endif } // 006fd350 Whether the run's frame stands still: an open console or pause menu while offline, a freeze, the death or diff --git a/src/game/main.cpp b/src/game/main.cpp index a0ae9e7..73e920d 100644 --- a/src/game/main.cpp +++ b/src/game/main.cpp @@ -6,6 +6,9 @@ #include "lua/engine.h" #include "game/manager.h" #include "engine/platform.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/ui_patches.h" +#endif #include #include #include @@ -15,6 +18,7 @@ constexpr const char* LOCALHOST_FLAG = "--localhost_match"; constexpr const char* RESOURCES_FLAG = "--resources"; constexpr const char* MUTE_FLAG = "--mute"; +constexpr const char* QUICKSTART_FLAG = "-quickstart"; constexpr const char* LOG_FILE = "log.txt"; constexpr const char* LOCALHOST_LOG = "localhost/log_"; constexpr const char* CLAMP_COLOR_EXTENSION = "GL_ARB_color_buffer_float"; @@ -79,14 +83,17 @@ int IsaacMain(int argc, uint8_t** argv) } // The Linux entry point: "--resources " says where the game files are (the import tool's folder, or an install's -// resources folder with its packed archives, mounted here), "--mute" plays nothing, the harness takes its flags, then -// the game's own main runs. +// resources folder with its packed archives, mounted here), "--mute" plays nothing, REPENTOGON's "-quickstart" +// continues the last save file's run, the harness takes its flags, then the game's own main runs. int main(int argc, char** argv) { harness.arguments_load(argc, argv); for (int i = 1; i < argc; i++) { if (std::strcmp(argv[i], MUTE_FLAG) == 0) KAGE::Sound::manager.isMuted = true; +#ifdef ISAAC_REPENTOGON + else if (std::strcmp(argv[i], QUICKSTART_FLAG) == 0) isQuickstartAsked = true; +#endif else if (std::strcmp(argv[i], RESOURCES_FLAG) == 0 && i + 1 < argc) dataDirectory = std::string(argv[i + 1]) + "/"; } diff --git a/src/game/manager.cpp b/src/game/manager.cpp index 63789d4..9d012f8 100644 --- a/src/game/manager.cpp +++ b/src/game/manager.cpp @@ -13,10 +13,15 @@ #include "engine/kage_input.h" #include "engine/texture_cache.h" #ifdef ISAAC_REPENTOGON +#include "repentogon/achievements.h" #include "repentogon/callbacks.h" #include "repentogon/collision.h" +#include "repentogon/player.h" +#include "repentogon/ui_patches.h" #include "repentogon/options.h" #include "repentogon/repentogon.h" +#include "repentogon/save_state_manager.h" +#include "repentogon/vanilla_fixes.h" #include "repentogon/saves.h" #endif #include @@ -334,7 +339,11 @@ void Manager::Init() manager.framecount = 0; manager.activeControllerIndex = 0; +#ifdef ISAAC_REPENTOGON + if (options.isMouseControlEnabled || !repentogonOptions.isVanillaParity) +#else if (options.isMouseControlEnabled) +#endif { manager.cursorSprite.Load(CURSOR_ANM2, GRAPHICS_LOAD); manager.cursorSprite.Play(CURSOR_ANIMATION); @@ -395,14 +404,19 @@ void Manager::ShowCutscene(uint32_t cutsceneId, CutsceneCleanup cleanup, int nex Manager& manager = *g_manager; PersistentGameData& data = manager.persistentGameData; - if (cutsceneId >= CUTSCENE_COUNT) + uint32_t counted = cutsceneId; +#ifdef ISAAC_REPENTOGON + // A mod's cutscene counts as the intro, the one REPENTOGON's console hook queues in its place. + if (cutsceneId >= CUTSCENE_COUNT && cutsceneId < manager.cutsceneManager.entries.size()) counted = CUTSCENE_INTRO; +#endif + if (counted >= CUTSCENE_COUNT) { log_printf(LOG_ERROR, "Invalid cutscene ID \"%d\" \n", (int)cutsceneId); return; } - data.cutsceneCounters[cutsceneId]++; + data.cutsceneCounters[counted]++; data.isChangesMade = true; - if (cutsceneId != CUTSCENE_INTRO) + if (counted != CUTSCENE_INTRO) { data.cutsceneCounters[CUTSCENE_CREDITS]++; data.isChangesMade = true; @@ -440,6 +454,9 @@ void Manager::unload_state() if (g_game) g_game->deathmatchManager.Reset(); } TextureCache::Purge(); +#ifdef ISAAC_REPENTOGON + game_state_cleanup_notify(); +#endif } // 009a9fc0 Keeps the windowed position in the options as the window moves, then refits the view to the window. @@ -1009,8 +1026,8 @@ void Manager::update_screen_scale(Size size, ScreenFit fit) view_changed(); } -// 009595e0 Whether achievements cannot unlock now: with mods loaded or the console on, unless The Womb is unlocked, -// and never in a daily or debug run. +// 009595e0 Whether achievements cannot unlock now: with mods loaded or the console on, unless The Womb is unlocked +// (REPENTOGON drops that exemption without vanilla parity), and never in a daily or debug run. // Netplay is offline: online, the original asks the netplay layer instead. bool Manager::AchievementUnlocksDisallowed() { @@ -1018,8 +1035,12 @@ bool Manager::AchievementUnlocksDisallowed() bool isModded = manager.modManager.is_any_mod_loaded() || manager.optionsConfig.isDebugConsoleEnabled; bool isExemptRun = manager.state == MANAGER_STATE_GAME && g_game && (g_game->dailyChallenge.id != 0 || g_game->isDebug); + bool isWombUnlocked = manager.persistentGameData.achievements[ACHIEVEMENT_THE_WOMB]; +#ifdef ISAAC_REPENTOGON + isWombUnlocked = isWombUnlocked && repentogonOptions.isVanillaParity; // Patches/ASMPatches/ASMTweaks.cpp +#endif - return isModded && !manager.persistentGameData.achievements[ACHIEVEMENT_THE_WOMB] && !isExemptRun; + return isModded && !isWombUnlocked && !isExemptRun; } // 009548d0 The hotkeys while they are enabled: mute toggles the music, the window's fullscreen state is kept in the @@ -1180,6 +1201,7 @@ void Manager::SetSaveSlot(uint32_t slot) } currentSaveSlot = slot; #ifdef ISAAC_REPENTOGON + achievements_slot_load(slot); save_slot_post(slot); #endif } @@ -1353,7 +1375,11 @@ void Manager::save_game_state() } if (game.dailyChallenge.id != 0 || manager.netplayManager.is_online()) return; Entity_Player& player = *game.GetPlayer(0); +#ifdef ISAAC_REPENTOGON + if (player.isDead && extra_lives_all_get(player) < 1) return; +#else if (player.isDead && player.GetExtraLives() < 1) return; +#endif manager.isSavingGameState = true; game.store_game_state(manager.gamestate); @@ -1499,6 +1525,9 @@ void Manager::Update(InputPoll poll) { Manager& manager = *g_manager; AchievementOverlay& overlay = manager.achievementOverlay; +#ifdef ISAAC_REPENTOGON + quickstart_try(manager); +#endif if ((int)manager.framecount % UPDATE_FRAME_PERIOD == 1 && !manager.optionsConfig.render.isInterpolationEnabled) { @@ -1610,6 +1639,7 @@ static void cursor_render(Manager& manager) void Manager::Render() { #ifdef ISAAC_REPENTOGON + if (is_render_skipped()) return; callback_notify(lua_engine_get(), {"MC_PRE_RENDER", MC_PRE_RENDER, std::nullopt}); #endif KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager; @@ -1641,7 +1671,13 @@ void Manager::Render() achievementOverlay.Render(); popupQueue.render_layer(POPUP_LAYER_TOP); popupButtons.Render(); +#ifdef ISAAC_REPENTOGON + cursor_render_pre(*this); +#endif cursor_render(*this); +#ifdef ISAAC_REPENTOGON + cursor_render_post(*this); +#endif if (isColorCorrected) { diff --git a/src/game/mod_manager.cpp b/src/game/mod_manager.cpp index 46b7be1..ab17674 100644 --- a/src/game/mod_manager.cpp +++ b/src/game/mod_manager.cpp @@ -15,8 +15,13 @@ #include #include #ifdef ISAAC_REPENTOGON +#include "repentogon/achievements.h" #include "repentogon/callbacks.h" +#include "repentogon/items.h" +#include "repentogon/mod_curses.h" +#include "repentogon/vanilla_fixes.h" #include "repentogon/render.h" +#include "repentogon/repentogon.h" #endif // classes.h declares the original's Lua imports, and its luaL_newstate differs from Lua's only in its return type. @@ -31,6 +36,7 @@ extern "C" constexpr const char* CONTENT_FOLDER = "/content/"; constexpr const char* DISABLE_MARKER = "/disable.it"; constexpr const char* DLC_FOLDER_SUFFIX = "-dlc3/"; +constexpr const char* REPENTOGON_FOLDER_SUFFIX = "-repentogon/"; constexpr const char* MAIN_SCRIPT = "/main.lua"; constexpr const char* METADATA_FILE = "/metadata.xml"; // Where mods live, under resources/: the game paths ModEntry keeps are relative to it, as data_load takes them. @@ -143,9 +149,19 @@ static bool is_resource_found(std::string_view path) } // A mod folder's twin, whose files win over the folder's own. -static std::string dlc_folder_get(std::string_view folder) +static std::string dlc_folder_get(std::string_view folder, std::string_view suffix = DLC_FOLDER_SUFFIX) { - return std::string(folder.substr(0, folder.size() - 1)) + DLC_FOLDER_SUFFIX; + return std::string(folder.substr(0, folder.size() - 1)) + std::string(suffix); +} + +// The mod folder's -repentogon twin, whose files come first while mods see REPENTOGON +// (Patches/ASMPatches/ASMLocalization.cpp), or none. +static std::string repentogon_folder_get(std::string_view folder) +{ +#ifdef ISAAC_REPENTOGON + if (IS_REPENTOGON_EXPOSED) return dlc_folder_get(folder, REPENTOGON_FOLDER_SUFFIX); +#endif + return {}; } // The child elements with this tag, in document order. @@ -467,10 +483,13 @@ void ModShader::render_target_push() KAGE::Graphics::PRESENT_FLUSH); } -// 008f99c0 A file of the mod's content folder, taken from the folder's -dlc3 twin when that holds it. +// 008f99c0 A file of the mod's content folder, taken from the folder's -dlc3 twin when that holds it, and before that +// from its REPENTOGON twin. std::string ModEntry::GetContentPath(std::string_view fileName) { + std::string repentogonPath = repentogon_folder_get(contentDirectory); std::string dlcPath = dlc_folder_get(contentDirectory).append(fileName); + if (!repentogonPath.empty() && is_resource_found(repentogonPath.append(fileName))) return repentogonPath; return is_resource_found(dlcPath) ? dlcPath : contentDirectory + std::string(fileName); } @@ -478,6 +497,10 @@ std::string ModEntry::GetContentPath(std::string_view fileName) // The workshop id stays out of the file, as in the original. void ModEntry::WriteMetadata() { + std::string path = resource_path(MODS_FOLDER + directory + METADATA_FILE); +#ifdef ISAAC_REPENTOGON + if (is_metadata_write_refused(path)) return; +#endif pugi::xml_document document; pugi::xml_node metadata = document.append_child(METADATA_TAG); @@ -485,8 +508,6 @@ void ModEntry::WriteMetadata() if (field.field != &ModEntry::metadataWorkshopID) metadata.append_child(field.tag).text() = (this->*field.field).c_str(); for (std::string& tag : tags) metadata.append_child(TAG_TAG).append_attribute(ID_ATTRIBUTE) = tag.c_str(); - - std::string path = resource_path(MODS_FOLDER + directory + METADATA_FILE); document.save_file(path.c_str(), "\t", pugi::format_indent | pugi::format_no_declaration); } @@ -552,11 +573,17 @@ void ModManager::ListMods() // they add, then loads the sprite drawn for modded items that bring none. void ModManager::LoadModContent() { +#ifdef ISAAC_REPENTOGON + achievements_mods_load(); +#endif for (auto& mod : mods) { if (!mod->isLoaded) continue; mod->load_menu_sprites(); for (ModContentFile file : CONTENT_FILES) content_load(*mod, file.name, file.load); +#ifdef ISAAC_REPENTOGON + pocket_item_announcers_resolve(); +#endif std::string scriptPath = platform.modsDirectory + mod->directory + MAIN_SCRIPT; std::error_code error; @@ -569,6 +596,8 @@ void ModManager::LoadModContent() g_manager->entityConfig.tainted_players_link(); modDefaultsSprite.Load(MOD_DEFAULTS_SPRITE, GRAPHICS_LOAD); #ifdef ISAAC_REPENTOGON + achievements_reload(); + player_content_post_load(); unfiltered_notify("PostModsLoaded", MC_POST_MODS_LOADED); #endif } @@ -593,8 +622,12 @@ void ModManager::LoadModBossPools() void ModManager::LoadModCurses() { if (!g_game) return; +#ifdef ISAAC_REPENTOGON + loaded_mods_load(*this, CURSES_FILE, mod_curses_load); +#else loaded_mods_load(*this, CURSES_FILE, [](std::string& path, ModEntry&) { g_game->roomConfig.LoadCurses(path, CURSES_APPEND); }); +#endif } // 008f8040 Adds each loaded mod's .stb for a stage's room set (the set's file, its extension made "stb", in the mod's @@ -633,6 +666,9 @@ void ModManager::LoadShaders() // room stages so they load again with the mods' rooms. void ModManager::Reset() { +#ifdef ISAAC_REPENTOGON + if (is_game_restarted()) return; +#endif LuaEngine& lua = lua_engine_get(); log_printf(LOG_INFO, "Lua is resetting!\n"); @@ -668,7 +704,8 @@ void ModManager::TriggerResize() } // 008f5ad0 The file a loaded mod's resources hold in place of a game path, or the path itself: the first mod in name -// order that has it wins, its -dlc3 twin folder first. Answers are cached by normalized path, misses included. +// order that has it wins, its -dlc3 twin folder first (and its REPENTOGON twin before that). Answers are cached by +// normalized path, misses included. // The original's 32768-slot cache evicts when full. This one keeps every answer, which only costs memory. std::string ModManager::TryRedirectPath(std::string_view filePath) { @@ -680,8 +717,10 @@ std::string ModManager::TryRedirectPath(std::string_view filePath) ModEntry& mod = *mods[i]; if (!mod.isLoaded) continue; - for (std::string path : {dlc_folder_get(mod.resourcesDirectory), mod.resourcesDirectory}) - if (!redirect.modEntry && is_resource_found(path.append(filePath))) redirect = {&mod, path}; + std::string_view folder = mod.resourcesDirectory; + for (std::string path : {repentogon_folder_get(folder), dlc_folder_get(folder), std::string(folder)}) + if (!redirect.modEntry && !path.empty() && is_resource_found(path.append(filePath))) + redirect = {&mod, path}; } return redirect.modEntry ? redirect.filePath : std::string(filePath); } @@ -743,6 +782,8 @@ void ModManager::RenderCustomCharacterMenu(int characterId, Vector& renderPos, A EntityConfig_Player* player = g_manager->entityConfig.GetPlayer(characterId); ANM2* sprite = character_sprite_play(characterId, PLAYER_SPRITE_MENU_BACKGROUND); #ifdef ISAAC_REPENTOGON + bool isLockable = !player_attribute_get(characterId, "achievement").empty() || !repentogonOptions.isVanillaParity; + if (sprite && isLockable) character_page_lock(*sprite, is_player_unlocked(characterId)); CharacterPage page = {sprite, defaultSprite, renderPos, characterId, sprite && player->isRenderCustomBackground}; if (!character_page_pre(page)) return; #endif @@ -767,6 +808,10 @@ void ModManager::RenderCustomCharacterPortraits(int characterId, ModSpriteDraw& if (!sprite) return; sprite_style(*sprite, draw, 0); +#ifdef ISAAC_REPENTOGON + if (!player_attribute_get(characterId, "achievement").empty()) + sprite->SetLayerFrame(0, is_player_unlocked(characterId) ? 0 : 1); +#endif sprite->Render({draw.position}); } diff --git a/src/game/mod_manager.h b/src/game/mod_manager.h index f151e5a..850b8f7 100644 --- a/src/game/mod_manager.h +++ b/src/game/mod_manager.h @@ -67,6 +67,12 @@ struct ModEntry std::list shaders; std::map collectibleIdMap; std::map trinketIdMap; +#ifdef ISAAC_REPENTOGON + // REPENTOGON's: the null items its items.xml adds, by the ids it gives them. + std::map nullItemIdMap; + // The null items its costumes2.xml's "none" costumes went to, by the ids it gives them. + std::map nullCostumeIdMap; +#endif std::vector tags; std::string contentDirectory; std::string dataDirectory; diff --git a/src/game/options_config.cpp b/src/game/options_config.cpp index 1293613..d6e7f84 100644 --- a/src/game/options_config.cpp +++ b/src/game/options_config.cpp @@ -10,6 +10,9 @@ #include #include #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/options.h" +#endif constexpr const char* CONFIG_INI = "config.ini"; constexpr const char* OPTIONS_INI = "options.ini"; @@ -234,9 +237,13 @@ void OptionsConfig::Load(std::string_view path) hudOffset = 1; } -// 00924d10 Writes every option to options.ini, with the language and whether music plays. +// 00924d10 Writes every option to options.ini, with the language and whether music plays. REPENTOGON's own options +// are saved first (VanillaTweaks.cpp). void OptionsConfig::Save() { +#ifdef ISAAC_REPENTOGON + repentogonOptions.save(); +#endif std::string text = "[Options]\r\n"; line_write(text, "Language", g_manager->stringTable.language); diff --git a/src/game/persistent_game_data.cpp b/src/game/persistent_game_data.cpp index 8359464..654988c 100644 --- a/src/game/persistent_game_data.cpp +++ b/src/game/persistent_game_data.cpp @@ -13,6 +13,7 @@ #include #include #ifdef ISAAC_REPENTOGON +#include "repentogon/achievements.h" #include "repentogon/callbacks.h" #include "repentogon/level.h" #include "repentogon/saves.h" @@ -1065,6 +1066,9 @@ void PersistentGameData::UnlockSteamAchievement(int achievementID) // already unlocked. An id past the table is refused, where the game wrote past it. bool PersistentGameData::TryUnlock(int achievementID) { +#ifdef ISAAC_REPENTOGON + if (achievement_is_custom(achievementID)) return custom_achievement_unlock(*this, achievementID); +#endif if (isReadOnly || achievementID <= 0 || achievementID >= ACHIEVEMENT_COUNT || achievements[achievementID]) return false; @@ -1088,6 +1092,10 @@ bool PersistentGameData::TryUnlock(int achievementID) // everything does during a daily challenge or a debug run. bool PersistentGameData::Unlocked(int achievementID) { +#ifdef ISAAC_REPENTOGON + if (achievementID >= ACHIEVEMENT_COUNT && achievement_is_custom(achievementID)) + return custom_achievement_is_unlocked(achievementID); +#endif if (achievementID == ACHIEVEMENT_NEVER || achievementID >= ACHIEVEMENT_COUNT) return false; if (achievementID <= 0 || achievements[achievementID]) return true; return g_manager->state == MANAGER_STATE_GAME && g_game && (g_game->dailyChallenge.id != 0 || g_game->isDebug); diff --git a/src/game/restore.cpp b/src/game/restore.cpp index dec631f..ff7a213 100644 --- a/src/game/restore.cpp +++ b/src/game/restore.cpp @@ -19,6 +19,7 @@ #include "repentogon/callbacks.h" #include "repentogon/items.h" #include "repentogon/saves.h" +#include "repentogon/ui_patches.h" #endif constexpr uint32_t ROOM_REF_STAGE_MASK = 0xffff; @@ -194,6 +195,7 @@ void Game::restore_game_state(GameState& state, GameRestore restore) for (Entity_Player* player : playerManager.playerList) player->update_mini_mush_costume(); #ifdef ISAAC_REPENTOGON game_state_callbacks_run(state, MC_POST_GAME_STATE_RESTORE, MC_POST_GLOWING_HOURGLASS_LOAD); + planetarium_chance_recompute(); #endif } @@ -692,14 +694,20 @@ static void coop_babies_restore(Entity_Player& player, const std::vectoritemConfig; std::vector& configs = g_manager->entityConfig.players; if (replacedPlayer) return; +#ifdef ISAAC_REPENTOGON + ScopeExit post{[&] { entity_restore_notify(*this, saved.saveStateId.id); }}; +#endif SetControllerIndex(saved.controllerIndex, true); if (playerType >= (int)configs.size()) playerType = PLAYER_ISAAC; if (game.isRestoringGlowingHourglassState) diff --git a/src/game/save.cpp b/src/game/save.cpp index a4411e3..9e6b0b5 100644 --- a/src/game/save.cpp +++ b/src/game/save.cpp @@ -506,7 +506,7 @@ void Entity_Player::StoreGameState(GameStatePlayer* saveState, bool isSaveTempor familiar.store_backup(&state.familiars.emplace_back()); #ifdef ISAAC_REPENTOGON - unfiltered_notify("EntitySave", MC_ENTITY_SAVE, entity); + entity_store_notify(*entity, state.familiars.back().saveStateId); #endif } } @@ -526,6 +526,6 @@ void Entity_Player::StoreGameState(GameStatePlayer* saveState, bool isSaveTempor state.temporaryEffects = temporaryEffects.effects; state.strengthMaxHearts = strengthMaxHearts; #ifdef ISAAC_REPENTOGON - unfiltered_notify("EntitySave", MC_ENTITY_SAVE, (Entity*)this); + entity_store_notify(*this, state.saveStateId); #endif } diff --git a/src/game/state.cpp b/src/game/state.cpp index cef7da2..b5c2c4f 100644 --- a/src/game/state.cpp +++ b/src/game/state.cpp @@ -4,6 +4,10 @@ #include "engine/log.h" #include "game/manager.h" #include "engine/platform.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/options.h" +#include "repentogon/save_state_manager.h" +#endif #include #include #include @@ -79,6 +83,9 @@ void GameState::Clear() cleared.rerunPath = std::move(rerunPath); cleared.savePath = std::move(savePath); *this = std::move(cleared); +#ifdef ISAAC_REPENTOGON + game_state_clear_notify(*this); +#endif } // 009c8350 Removes the saved run's file, warning when there is none named, and empties the run. @@ -86,6 +93,9 @@ void GameState::Delete() { if (savePath.empty()) log_printf(LOG_INFO, "[warn] GameState::Delete: no filename specified.\n"); std::remove(savePath.c_str()); +#ifdef ISAAC_REPENTOGON + game_state_delete_notify(*this, GAME_STATE_FILE_RUN); +#endif Clear(); } @@ -95,6 +105,9 @@ void GameState::DeleteRerun() { if (savePath.empty()) log_printf(LOG_INFO, "[warn] GameState::DeleteRerun: no filename specified.\n"); std::remove(rerunPath.c_str()); +#ifdef ISAAC_REPENTOGON + game_state_delete_notify(*this, GAME_STATE_FILE_RERUN); +#endif } // A saved run as it is written: its bytes, and the checksum (CRC-32 from Checksum's seed) over all of them after the @@ -178,6 +191,9 @@ struct StateWriter // entity follow, and those. void StateWriter::entity_write(const EntitySaveState& entity) { +#ifdef ISAAC_REPENTOGON + save_state_written(entity.saveStateId); +#endif for (uint32_t value : {(uint32_t)entity.type, (uint32_t)entity.variant, (uint32_t)entity.subtype, entity.intStorage1, entity.intStorage2, entity.intStorage3}) write(value); @@ -277,6 +293,9 @@ void StateWriter::familiars_write(const std::vector& familiars) write((uint32_t)familiars.size()); for (const FamiliarData& familiar : familiars) { +#ifdef ISAAC_REPENTOGON + save_state_written(familiar.saveStateId); +#endif for (int value : {(int)familiar.initSeed, familiar.variant, familiar.subtype, familiar.coins, familiar.hearts, familiar.keys, familiar.state, familiar.roomClearCount}) write(value); @@ -319,6 +338,9 @@ static uint8_t counter_byte(int value) // The Echo Chamber's type is written as a word whose padding the original leaves unset. It is zero here. void StateWriter::player_write(const GameStatePlayer& player) { +#ifdef ISAAC_REPENTOGON + save_state_written(player.saveStateId); +#endif for (int value : {player.playerType, player.redHearts, player.maxHearts, player.soulHearts, player.blackHearts, player.eternalHearts, player.jarHearts, player.jarFlies, player.numCoins, player.numKeys, player.numBombs}) @@ -588,6 +610,9 @@ static std::vector room_map_pack(const std::array std::vector GameState::write() { StateWriter writer; +#ifdef ISAAC_REPENTOGON + game_state_collect_begin(); +#endif rooms.resize(ROOM_DESCRIPTOR_COUNT); writer.bytes.assign(SAVE_HEADER, SAVE_HEADER + sizeof(SAVE_HEADER)); @@ -706,6 +731,9 @@ std::vector GameState::write() writer.list_write(versusCollectibles); checksum = writer.seal(); +#ifdef ISAAC_REPENTOGON + game_state_write_end(*this, GAME_STATE_FILE_RUN); +#endif return writer.bytes; } @@ -714,6 +742,9 @@ std::vector GameState::write() std::vector GameState::write_rerun() { StateWriter writer; +#ifdef ISAAC_REPENTOGON + game_state_collect_begin(); +#endif writer.bytes.assign(SAVE_HEADER, SAVE_HEADER + sizeof(SAVE_HEADER)); writer.write((uint8_t)isConsoleUsedThisRun); @@ -723,6 +754,9 @@ std::vector GameState::write_rerun() for (const GameStatePlayer& player : players) writer.player_write(player); writer.seed_write(seeds.gameStartSeed); checksum = writer.seal(); +#ifdef ISAAC_REPENTOGON + game_state_write_end(*this, GAME_STATE_FILE_RERUN); +#endif return writer.bytes; } @@ -854,6 +888,9 @@ struct StateReader // 009cb020 Reads a saved entity, its extra bytes and the entity it carries. void StateReader::entity_read(EntitySaveState& entity) { +#ifdef ISAAC_REPENTOGON + save_state_read(entity.saveStateId); +#endif fields_read(entity.type, entity.variant, entity.subtype, entity.intStorage1, entity.intStorage2, entity.intStorage3, entity.byteStorage, entity.intStorage4, entity.intStorage5); entity.boolStorage1 = bool_read(); @@ -950,6 +987,9 @@ bool StateReader::familiars_read(std::vector& familiars) if (is_end()) return fail(LOG_INFO, "[warn] Invalid familiar count %d. Save file %s might be corrupt.\n", (int)familiars.size(), path); +#ifdef ISAAC_REPENTOGON + save_state_read(familiar.saveStateId); +#endif fields_read(familiar.initSeed, familiar.variant, familiar.subtype, familiar.coins, familiar.hearts, familiar.keys, familiar.state, familiar.roomClearCount, familiar.formationTargetOffset, familiar.health, familiar.dropSeed); @@ -1006,6 +1046,9 @@ bool StateReader::history_read(std::vector& history) // mode. The first Echo Chamber list is only checked, as the original does. bool StateReader::player_read(GameStatePlayer& player) { +#ifdef ISAAC_REPENTOGON + save_state_read(player.saveStateId); +#endif ItemConfig& items = g_manager->itemConfig; player.playerType = read(); @@ -1345,6 +1388,9 @@ bool GameState::read(std::span file) } StateReader reader = {file, sizeof(SAVE_HEADER), version, savePath.c_str()}; +#ifdef ISAAC_REPENTOGON + game_state_collect_begin(); +#endif challenge = reader.read(); isRerun = reader.bool_read(); seeds.isCustomRun = reader.bool_read(); @@ -1413,7 +1459,10 @@ bool GameState::read(std::span file) bool isRead = reader.player_read(i < ESAU_JR_STATE_COUNT ? esauJrStates[i] : dropped); if (i < ESAU_JR_STATE_COUNT && !isRead) return false; } - reader.item_pool_read(itemPool); + [[maybe_unused]] bool isPoolRead = reader.item_pool_read(itemPool); +#ifdef ISAAC_REPENTOGON + if (!isPoolRead && !repentogonOptions.isVanillaParity) return false; // Patches/ASMPatches/ASMFixes.cpp +#endif std::array seedString{}; reader.each_read(std::span(seedString).first(SEED_STRING_LENGTH)); @@ -1461,7 +1510,11 @@ bool GameState::read(std::span file) bool isEndEarly = reader.is_end(); bool isSealMatching = (reader.read() ^ CHECKSUM_KEY) == checksum; - if (!isEndEarly && isSealMatching && reader.position == file.size()) return true; + bool isRead = !isEndEarly && isSealMatching && reader.position == file.size(); +#ifdef ISAAC_REPENTOGON + game_state_read_end(*this, GAME_STATE_FILE_RUN, isRead); +#endif + if (isRead) return true; log_printf(LOG_INFO, "[warn] Bad Gamestate Offset! Gamestate corrupted or has new data!\n"); return false; } @@ -1487,6 +1540,9 @@ bool GameState::read_rerun(std::span file) } StateReader reader = {file, sizeof(SAVE_HEADER), version, rerunPath.c_str()}; +#ifdef ISAAC_REPENTOGON + game_state_collect_begin(); +#endif std::array seedString{}; isConsoleUsedThisRun = reader.bool_read(); @@ -1497,5 +1553,8 @@ bool GameState::read_rerun(std::span file) for (GameStatePlayer& player : players) reader.player_read(player); reader.each_read(std::span(seedString).first(SEED_STRING_LENGTH)); seeds.set_start_seed(Seeds::String2Seed(seedString.data())); +#ifdef ISAAC_REPENTOGON + game_state_read_end(*this, GAME_STATE_FILE_RERUN, true); +#endif return true; } diff --git a/src/game/state_player.h b/src/game/state_player.h index 922f216..08fb68e 100644 --- a/src/game/state_player.h +++ b/src/game/state_player.h @@ -208,4 +208,7 @@ struct GameStatePlayer bool isCoopGhost = false; bool isHolyMantle = false; bool isLevelStartPending = false; +#ifdef ISAAC_REPENTOGON + SaveStateId saveStateId; +#endif }; diff --git a/src/game/string_table.cpp b/src/game/string_table.cpp index badb7cc..21437c5 100644 --- a/src/game/string_table.cpp +++ b/src/game/string_table.cpp @@ -1,6 +1,9 @@ #include "game/string_table.h" #include "engine/data.h" #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/xml.h" +#endif constexpr std::string_view INVALID_LANGUAGE = "StringTable::InvalidLanguage"; constexpr std::string_view INVALID_CATEGORY = "StringTable::InvalidCategory"; @@ -69,7 +72,8 @@ static int column_find(std::map& languages, int language) return found == languages.end() || found->second < 0 || found->second >= (int)languages.size() ? -1 : found->second; } -// 00a26810 Loads a .sta file and makes its lowest language id current. Anything else empties the table. +// 00a26810 Loads a .sta file and makes its lowest language id current. Anything else empties the table. With +// REPENTOGON, the mods' content copies of the file merge into it. // The extension is what follows the last dot, or all but the first character when there is none, as in the game. bool StringTable::Load(std::string_view fileName) { @@ -80,6 +84,9 @@ bool StringTable::Load(std::string_view fileName) clear(); if (isTable) isLoaded = load_file(fileName); +#ifdef ISAAC_REPENTOGON + if (isLoaded) string_table_mods_merge(*this, fileName); +#endif if (isLoaded && !languages.empty()) language = languages.begin()->first; return isLoaded; } diff --git a/src/level/ambush.cpp b/src/level/ambush.cpp index 66c5243..901c9df 100644 --- a/src/level/ambush.cpp +++ b/src/level/ambush.cpp @@ -34,6 +34,10 @@ constexpr int WAVE_SUBTYPE_NORMAL = 10; constexpr int WAVE_SUBTYPE_BOSS = 11; constexpr int AMBUSH_WAVE_TRIES = 10; constexpr int AMBUSH_HOME_DIMENSION = 2; +// (Patches/ASMPatches/ASMRoom.cpp) The boss wave difficulty no room has, which a mod's extra boss waves reach, drawn +// as the last one there is. +constexpr int BOSS_WAVE_DIFFICULTY_MISSING = 15; +constexpr int BOSS_WAVE_DIFFICULTY_FALLBACK = 10; // A challenge's three waves (two for bosses), 30 frames between them, and Door Stop's multiplier that keeps the // entrance open. @@ -137,8 +141,14 @@ static std::vector> wave_entries_pick(Ambush& ambush) .stageId = stageId, .subtype = isBossWave ? WAVE_SUBTYPE_BOSS : WAVE_SUBTYPE_NORMAL, .type = ROOM_CHALLENGE}; - RoomConfig_Room* wave = game.roomConfig.GetRandomRoom(ambush.waveRng.Next(), WEIGHT_REDUCE, query); + uint32_t seed = ambush.waveRng.Next(); + RoomConfig_Room* wave = game.roomConfig.GetRandomRoom(seed, WEIGHT_REDUCE, query); #ifdef ISAAC_REPENTOGON + if (!wave && isBossWave && difficulty == BOSS_WAVE_DIFFICULTY_MISSING) + { + query.minDifficulty = query.maxDifficulty = BOSS_WAVE_DIFFICULTY_FALLBACK; + wave = game.roomConfig.GetRandomRoom(seed, WEIGHT_REDUCE, query); + } wave = wave_room_select(wave, MC_PRE_SELECT_AMBUSH_WAVE, ambush.waveRng._seed); #endif if (!wave) diff --git a/src/level/backdrop.cpp b/src/level/backdrop.cpp index 1aada39..b8b2f48 100644 --- a/src/level/backdrop.cpp +++ b/src/level/backdrop.cpp @@ -24,6 +24,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/xml.h" #endif constexpr std::string_view DEFAULT_PROPS = "gfx/grid/props_01_basement.anm2"; @@ -351,6 +352,9 @@ bool Backdrop::LoadConfig(std::string_view path) BackdropConfig config = config_load(node, base, gfxRoot, gridRoot); if (config.backdropId >= 1 && config.backdropId < BACKDROP_COUNT) configs[config.backdropId] = config; } +#ifdef ISAAC_REPENTOGON + backdrops_content_load(data.root); +#endif return true; } @@ -361,6 +365,13 @@ void Backdrop::Init(uint32_t id, bool isLoadGraphics) #ifdef ISAAC_REPENTOGON CallbackRun run = {"PreBackdropChange", MC_PRE_BACKDROP_CHANGE, std::nullopt}; id = (uint32_t)callback_integer_run(lua_engine_get(), run, (int)id, id); + uint32_t requested = id; + BackdropDraw draw = backdrop_custom_apply(*this, id); + if (draw == BACKDROP_DRAW_NONE) return; + ScopeExit post{[&] { + if (draw == BACKDROP_DRAW_CUSTOM) + callback_notify(lua_engine_get(), {"PostBackdropChange", MC_POST_BACKDROP_CHANGE, requested}, requested); + }}; #endif Room& room = *g_game->room; diff --git a/src/level/camera.cpp b/src/level/camera.cpp index bf99a77..5287ebf 100644 --- a/src/level/camera.cpp +++ b/src/level/camera.cpp @@ -8,6 +8,9 @@ #include "game/manager.h" #include "level/room.h" #include "engine/seeds.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/level.h" +#endif #include #include @@ -123,8 +126,12 @@ Vector VectorRing::average(float peakFraction) } // 009428d0 Starts centered on the room, or on the door the players come in by, or on where they enter. +// (Patches/ASMPatches/ASMCamera.cpp) A room's camera keeps within it again, as the last camera's destruction set it. Camera::Camera(Room& owner) { +#ifdef ISAAC_REPENTOGON + isCameraClamped = true; +#endif room = &owner; screenAnchor = vector_make(0.5f, 0.5f); position = ClampedToRoom(vector_make(0, 0)); @@ -199,6 +206,9 @@ Vector Camera::ClampedToRoom(Vector worldPosition) Vector target = to_camera(worldPosition); if (room->descriptor->flags & ROOM_DESCRIPTOR_FLAG_NO_WALLS) return target; +#ifdef ISAAC_REPENTOGON + if (!isCameraClamped) return target; +#endif Vector clamped = vector_make(std::max(std::min(target.x, bounds.high.x), bounds.low.x), std::max(std::min(target.y, bounds.high.y), bounds.low.y)); @@ -365,7 +375,11 @@ void Camera::update_focus_position(bool isSkipFocusBuffer) VectorRing focusCopy = focusPositions; for (int i = 0; i < focusCopy.count; i++) if (focusCopy.at(i).x == -1 && focusCopy.at(i).y == -1) focusCopy.at(i) = target; - position = soft_clamp_position(to_camera(focusCopy.average(FOCUS_PEAK))); + position = to_camera(focusCopy.average(FOCUS_PEAK)); +#ifdef ISAAC_REPENTOGON + if (isCameraClamped) +#endif + position = soft_clamp_position(position); shake_update(); for (int slot = 0; slot < DOOR_SLOT_COUNT; slot++) diff --git a/src/level/generator.cpp b/src/level/generator.cpp index 0fb3a08..ae19c13 100644 --- a/src/level/generator.cpp +++ b/src/level/generator.cpp @@ -71,6 +71,10 @@ constexpr std::array, DIRECTION_COUNT> L_SHAPES = {{ // game's table (its stack cookie), so that spot never matches a door here. constexpr std::array RESIZE_SPOT_FAR_SLOTS = {false, false, true, false, true, false, true, false, true, false, true, false, false, false}; +// (Patches/ASMPatches/ASMLevel.cpp, vanilla parity off) The same, the larger shapes' spots fixed and the last spot +// reading the one before it. +constexpr std::array RESIZE_SPOT_FAR_SLOTS_FIXED = {false, false, false, true, false, true, false, + true, false, true, false, true, false, false}; int XY::ToGridIdx() const { @@ -472,11 +476,20 @@ bool LevelGenerator::try_resize_room(LevelGenerator_Room& room, RoomShape shape, int self = roomMap[linkCell]; int parentSide = direction_opposite(room.connectDirection); std::array spots = shape_spots_get(room.linkPos, room.connectDirection); + const std::array* farSlots = &RESIZE_SPOT_FAR_SLOTS; + int spotCount = RESIZE_SPOT_COUNT - 1; +#ifdef ISAAC_REPENTOGON + if (!repentogonOptions.isVanillaParity) + { + farSlots = &RESIZE_SPOT_FAR_SLOTS_FIXED; + spotCount = RESIZE_SPOT_COUNT; + } +#endif - for (int i = 0; i < RESIZE_SPOT_COUNT - 1; i++) + for (int i = 0; i < spotCount; i++) { ShapeSpot spot = i == 0 ? ShapeSpot{room.linkPos, ROOMSHAPE_1x1} : spots[i - 1]; - int parentSlot = parentSide + (RESIZE_SPOT_FAR_SLOTS[i] ? DIRECTION_COUNT : 0); + int parentSlot = parentSide + ((*farSlots)[i] ? DIRECTION_COUNT : 0); bool isFits = true; int neighborCount = 0; diff --git a/src/level/grid/grid_entity.cpp b/src/level/grid/grid_entity.cpp index 11dcbeb..08f36f4 100644 --- a/src/level/grid/grid_entity.cpp +++ b/src/level/grid/grid_entity.cpp @@ -39,6 +39,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/options.h" #endif // TNT still standing before its output trigger blows it up. @@ -169,6 +170,7 @@ void GridEntity::Init(uint32_t seed) isInitialized = true; spawnFrame = g_game->frameCount; #ifdef ISAAC_REPENTOGON + waterClipFlagsOverride.reset(); callback_notify(lua_engine_get(), {"PostGridEntitySpawn", MC_POST_GRID_ENTITY_SPAWN, (int)type}, this); #endif } @@ -236,7 +238,8 @@ WaterClipInfo GridEntity::GetWaterClipInfo() return {WATER_CLIP_SOLID, 0}; } -// How the water clips the grid entity: its type's clip, with REPENTOGON the flags a mod set in their place. +// How the water clips the grid entity: its type's clip, with REPENTOGON the flags a mod set in their place +// (Patches/GridEntityPlus.cpp), which an Init clears. WaterClipInfo GridEntity::water_clip_get() { WaterClipInfo clip = GetWaterClipInfo(); @@ -293,6 +296,9 @@ bool GridEntity::IsEasyCrushableOrWalkable() bool isRock = type == GRID_ROCK || type == GRID_ROCK_ALT || type == GRID_ROCKT || type == GRID_ROCK_SS || type == GRID_ROCK_ALT2; +#ifdef ISAAC_REPENTOGON + isRock |= type == GRID_ROCK_GOLD && !repentogonOptions.isVanillaParity; // Patches/MiscFixes.cpp +#endif return isRock || (type == GRID_POOP && variant != POOP_RED); } @@ -303,6 +309,9 @@ bool GridEntity::IsDangerousCrushableOrWalkable() return true; bool isHazard = type == GRID_TNT || type == GRID_ROCK_BOMB || type == GRID_SPIKES || type == GRID_SPIKES_ONOFF; +#ifdef ISAAC_REPENTOGON + isHazard |= type == GRID_ROCK_SPIKED && !repentogonOptions.isVanillaParity; // Patches/MiscFixes.cpp +#endif return isHazard || (type == GRID_POOP && variant == POOP_RED); } diff --git a/src/level/grid/rock.cpp b/src/level/grid/rock.cpp index b9ec3a1..5cdf12e 100644 --- a/src/level/grid/rock.cpp +++ b/src/level/grid/rock.cpp @@ -24,6 +24,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/vanilla_fixes.h" #endif // A big rock's last frame. @@ -840,6 +841,9 @@ void GridEntity_Rock::PlayBreakSound(GridEntityType type, int backdropType) bool GridEntity_Rock::TrySpawnLadder() { if (type == GRID_ROCKB) return false; +#ifdef ISAAC_REPENTOGON + if (is_crawlspace_refused(*g_game->room)) return false; +#endif Game& game = *g_game; RNG* studFinder = nullptr; diff --git a/src/level/grid/wall.cpp b/src/level/grid/wall.cpp index 5bee03d..83afa62 100644 --- a/src/level/grid/wall.cpp +++ b/src/level/grid/wall.cpp @@ -28,16 +28,6 @@ constexpr int BRICK_LOW_VARIANTS = 2; constexpr int WALL_DECORATION_1 = 1; constexpr int WALL_DECORATION_2 = 2; -// Puts a new grid entity on its cell in place of the one there, then initializes it. -static void grid_place(Room& room, GridEntity* entity, int variant, uint32_t seed) -{ - delete room.gridEntities[entity->gridIndex]; - room.gridEntities[entity->gridIndex] = entity; - entity->variant = variant; - entity->varData = 0; - entity->Init(seed); -} - // Whether a cell above or below a crawlspace brick leaves it open: nothing, a decoration or gravity. static bool is_open_cell(GridEntity* entity) { @@ -66,19 +56,12 @@ static bool make_wall(Room& room, int x, int y) (y == CRAWLSPACE_GRAVITY_ROW_TOP || y == CRAWLSPACE_GRAVITY_ROW_BOTTOM); if (isLadderCrawlspace && y == 0 && x == CRAWLSPACE_LADDER_COLUMN) { - uint32_t seed = Random(); - if (room.gridPaths[gridIndex] > GRID_PATH_FREED) - return false; - - GridEntity* ladder = CreateGridEntity(GRID_DECORATION, gridIndex); - grid_place(room, ladder, DECORATION_LADDER_LOW, seed); + room.SpawnGridEntity(gridIndex, GRID_DECORATION, DECORATION_LADDER_LOW, Random(), 0); return false; } if (isGravityCell) { - uint32_t seed = Random(); - if (room.gridPaths[gridIndex] <= GRID_PATH_FREED) - grid_place(room, CreateGridEntity(GRID_GRAVITY, gridIndex), 0, seed); + room.SpawnGridEntity(gridIndex, GRID_GRAVITY, 0, Random(), 0); if (room.gridEntities[gridIndex]) room.gridEntities[gridIndex]->PostInit(); return false; diff --git a/src/level/level.cpp b/src/level/level.cpp index 5a9132e..12914ab 100644 --- a/src/level/level.cpp +++ b/src/level/level.cpp @@ -37,6 +37,7 @@ #include "repentogon/items.h" #include "repentogon/level.h" #include "repentogon/saves.h" +#include "repentogon/ui_patches.h" #endif // Where GetEnterPosition puts the players: a crawlspace's ladder down and its ladder back up, the Black Market's @@ -630,7 +631,11 @@ void Level::Init(bool isResetLilPortalRoom) if (game.challenge == CHALLENGE_RED_REDEMPTION || stage % 2 == 0 || stage >= STAGE_WOMB_II || is_greed()) curses &= ~CURSE_OF_LABYRINTH; } - if (stage == STAGE_BLUE_WOMB || game.victoryLap > 2) curses &= ~CURSE_OF_DARKNESS; + uint32_t liftedCurses = CURSE_OF_DARKNESS; +#ifdef ISAAC_REPENTOGON + if (!repentogonOptions.isVanillaParity) liftedCurses |= CURSE_OF_THE_LOST; // Patches/ASMPatches/ASMLevel.cpp +#endif + if (stage == STAGE_BLUE_WOMB || game.victoryLap > 2) curses &= ~liftedCurses; game.hud.InvalidateCraftingItem(nullptr); game.roomConfig.ClearGeneratedRooms(); @@ -705,6 +710,9 @@ void Level::Init(bool isResetLilPortalRoom) TextureCache::Purge(); lua_engine_get().PostNewLevel(); isLevelGenerating = false; +#ifdef ISAAC_REPENTOGON + planetarium_chance_recompute(); +#endif } // 00738650 Resets every room descriptor (the Lil Portal room's only when asked), numbering them and giving the rooms @@ -4294,7 +4302,11 @@ void Level::InitializeDevilAngelRoom(bool isForceAngel, bool isForceDevil) desc.InitSeeds(devilAngelRoomRNG); for (int tries = DEAL_ROOM_TRIES; tries > 0; tries--) { +#ifdef ISAAC_REPENTOGON + desc.data = deal_room_get(devilAngelRoomRNG.Next(), WEIGHT_KEEP, query); +#else desc.data = random_room_get(devilAngelRoomRNG.Next(), query, WEIGHT_KEEP); +#endif if (!CanSpawnDevilRoom()) break; int startSlot = (int)(Random() & (DOOR_SLOT_COUNT - 1)); diff --git a/src/level/minimap.cpp b/src/level/minimap.cpp index 5b42ca5..2cb512e 100644 --- a/src/level/minimap.cpp +++ b/src/level/minimap.cpp @@ -16,6 +16,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/mod_curses.h" #endif constexpr const char* SMALL_MAP_ANM2 = "gfx/ui/minimap1.anm2"; @@ -976,15 +977,20 @@ void Minimap::render_icons(Vector position, float alpha) icon_add(players.FirstCollectibleOwner(COLLECTIBLE_RESTOCK, LAZARUS_SHARE_CHECK), ICON_RESTOCK); uint32_t curses = curses_get(); for (int curse = 0; curse < CURSE_ICON_COUNT; curse++) icon_add(curses & 1u << curse, ~curse); +#ifdef ISAAC_REPENTOGON + for (int curseId : mod_curse_icons_get(curses)) icon_add(true, -curseId); +#endif if (count == 0) return; float spacing = count < ICON_STACK_START ? ICON_SPACING : (float)(count - 3) + ICON_SPACING; - for (int i = 0; i < count; i++) + for (int i = 0; i < count; i++, position.x += spacing) { +#ifdef ISAAC_REPENTOGON + if (frames[i] < 0 && is_mod_curse_icon_rendered(-frames[i], position, alpha)) continue; +#endif if (frames[i] < 0) itemIconsSprite.SetFrame(ANIMATION_CURSES, ~frames[i]); else itemIconsSprite.SetFrame(ANIMATION_ICONS, frames[i]); itemIconsSprite.Render({position}); - position.x += spacing; } } diff --git a/src/level/red_room.cpp b/src/level/red_room.cpp index 509dcf2..ae507b9 100644 --- a/src/level/red_room.cpp +++ b/src/level/red_room.cpp @@ -10,6 +10,9 @@ #include "level/room_config.h" #include "game/sfx_manager.h" #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/level.h" +#endif // The map's width and height in cells. constexpr int MAP_SIZE = 13; @@ -198,6 +201,16 @@ int Level::roll_red_room_type(RNG& rng) return type; } +// A red room's room, drawn as a deal through REPENTOGON's deal draw. +static RoomConfig_Room* red_room_draw(uint32_t seed, RoomQuery& query) +{ +#ifdef ISAAC_REPENTOGON + return deal_room_get(seed, WEIGHT_KEEP, query); +#else + return g_game->roomConfig.GetRandomRoom(seed, WEIGHT_KEEP, query); +#endif +} + // 0074d010 Opens a red room through a door slot (the Red Key, Cracked Key, Soul of Cain): picks a room for the empty // cell beyond from the cell's seed, places it with doors to every room around that takes one, or opens the way to the // next floor off the map's edge, and puts the new doors in if the slot's room is the current one. @@ -257,11 +270,11 @@ bool Level::MakeRedRoomDoor(int roomIdx, int doorSlot) query.minDifficulty = query.maxDifficulty = (int)stage > RED_ROOM_LATE_STAGE ? RED_ROOM_LATE_MINIBOSS : 1; - data = config.GetRandomRoom(rng.Next(), WEIGHT_KEEP, query); + data = red_room_draw(rng.Next(), query); if (!data && type != ROOM_DEFAULT) { query.stageId = 0; - data = config.GetRandomRoom(rng.Next(), WEIGHT_KEEP, query); + data = red_room_draw(rng.Next(), query); if (!data) { query = {.requiredDoors = RED_ROOM_DOORS, @@ -270,7 +283,7 @@ bool Level::MakeRedRoomDoor(int roomIdx, int doorSlot) .minDifficulty = 1, .stageId = stageId, .subtype = query.subtype}; - data = config.GetRandomRoom(rng.Next(), WEIGHT_KEEP, query); + data = red_room_draw(rng.Next(), query); } } } diff --git a/src/level/room.cpp b/src/level/room.cpp index 962afb2..280a128 100644 --- a/src/level/room.cpp +++ b/src/level/room.cpp @@ -39,6 +39,7 @@ extern "C" #include "repentogon/callbacks.h" #include "repentogon/items.h" #include "repentogon/level.h" +#include "repentogon/vanilla_fixes.h" #endif // REPENTOGON's LRoomTileDesc table at 00c35b80, by shape. @@ -953,11 +954,14 @@ void Room::init_dungeon_rock() // 007ebca0 Puts a new grid entity of a type and variant on a cell from a seed, replacing what stood there, when // the cell is free: no collision for trapdoors, stairs, pressure plates and teleporters, an unclaimed path for the // others. False when it is not or the type has no grid entity. +// The original inlines it in about twenty places, which call it here, as Patches/ASMPatches/ASMGridEntitySpawn.cpp +// routes them (their list in Patches/ASMPatches/ASMGridEntitySpawn_Definitions.cpp) through MC_PRE_GRID_ENTITY_SPAWN. bool Room::SpawnGridEntity(int gridIndex, GridEntityType type, int variant, uint32_t seed, int varData) { #ifdef ISAAC_REPENTOGON std::optional isSpawned = grid_spawn_pre(*this, gridIndex, type, variant, seed, varData); if (isSpawned) return *isSpawned; + if (type == GRID_STAIRS && is_crawlspace_refused(*this)) return false; #endif if (gridIndex < 0 || gridIndex >= ROOM_GRID_CELLS) KAGE_LogMessage(LOG_ASSERT, (uint8_t*)"SpawnGridEntity: Grid index invalid\n"); @@ -3369,17 +3373,7 @@ bool Room::TrySpawnSecretShop(bool isForce) int sound = SOUND_SHOVEL_DIG2; seed_fart_sound_override(&sound); g_manager->sfxManager.Play(sound); - uint32_t seed = Random(); - if (gridIndex < 0 || gridIndex >= ROOM_GRID_CELLS) - KAGE_LogMessage(LOG_ASSERT, (uint8_t*)"SpawnGridEntity: Grid index invalid\n"); - if ((uint32_t)gridIndex >= ROOM_GRID_CELLS || (int)GetGridCollision(gridIndex) >= 1) return true; - - GridEntity* stairs = CreateGridEntity(GRID_STAIRS, gridIndex); - delete gridEntities[gridIndex]; - gridEntities[gridIndex] = stairs; - stairs->variant = STAIRS_SECRET_SHOP; - stairs->varData = 0; - stairs->Init(seed); + SpawnGridEntity(gridIndex, GRID_STAIRS, STAIRS_SECRET_SHOP, Random(), 0); return true; } @@ -3472,17 +3466,7 @@ bool Room::spawn_sanguine_bond_spikes(bool isRoomInit) static_cast(grid)->unsummon(false); } RNG rng = {descriptor->decorationSeed, 11, 7, 12}; - uint32_t seed = rng.Next(); - if (spikeIndex < 0) log_printf(LOG_ASSERT, "SpawnGridEntity: Grid index invalid\n"); - if (spikeIndex >= 0 && gridPaths[spikeIndex] <= GRID_PATH_FREED) - { - GridEntity* spikes = CreateGridEntity(GRID_SPIKES, spikeIndex); - delete gridEntities[spikeIndex]; - gridEntities[spikeIndex] = spikes; - spikes->variant = SPIKES_LAYOUT_VARIANTS; - spikes->varData = 0; - spikes->Init(seed); - } + SpawnGridEntity(spikeIndex, GRID_SPIKES, SPIKES_LAYOUT_VARIANTS, rng.Next(), 0); // The original poofs on a room too small for the cell at the grid's position of -1. Here it does not. if (!isRoomInit && spikeIndex >= 0) entity_spawn(ENTITY_EFFECT, EFFECT_POOF01, GetGridPosition(spikeIndex), 0, Random())->Update(); @@ -3605,16 +3589,6 @@ void Room::card_against_humanity_fill() size_t pick = rng.RandomInt((uint32_t)freeCells.size()); int gridIndex = freeCells[pick]; freeCells.erase(freeCells.begin() + (long)pick); - uint32_t seed = rng.Next(); - if (gridIndex < 0) log_printf(LOG_ASSERT, "SpawnGridEntity: Grid index invalid\n"); - Room& room = *game.room; - if (gridIndex < 0 || room.gridPaths[gridIndex] > GRID_PATH_FREED) continue; - - GridEntity* poop = CreateGridEntity(GRID_POOP, gridIndex); - delete room.gridEntities[gridIndex]; - room.gridEntities[gridIndex] = poop; - poop->variant = variant; - poop->varData = 0; - poop->Init(seed); + game.room->SpawnGridEntity(gridIndex, GRID_POOP, variant, rng.Next(), 0); } } diff --git a/src/level/room_config.cpp b/src/level/room_config.cpp index a8b7fa5..1096298 100644 --- a/src/level/room_config.cpp +++ b/src/level/room_config.cpp @@ -10,6 +10,10 @@ #include #include #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/level.h" +#include "repentogon/vanilla_fixes.h" +#endif // One way the Curse of the Giant splits a big shape into two rooms: each part's shape, whether it sits a room width or // height into the big one, and the doors it starts with, which are the walls the two parts share. @@ -459,6 +463,10 @@ void RoomConfig::LoadStageBinary(int stageId, RoomMode mode) log_printf(LOG_INFO, "[RoomConfig] load stage %d: %s (mode %d)\n", stage.id, stage.GetDisplayName(LANGUAGE_CURRENT).c_str(), mode); std::optional reader = file_read(g_manager->modManager.TryRedirectPath(binary_path_get(set.filePath))); +#ifdef ISAAC_REPENTOGON + if (std::optional bytes = void_rooms_load(stageId, set.filePath)) + reader = StbReader{std::move(*bytes)}; +#endif if (!reader) return; set.Clear(); @@ -482,6 +490,9 @@ void RoomConfig::LoadStageBinary(int stageId, RoomMode mode) g_manager->modManager.LoadModRooms(stageId, mode); set.isLoaded = true; +#ifdef ISAAC_REPENTOGON + stage_binary_load_post(*this, stageId, mode); +#endif } // 0082a9c0 Loads a stage's room set, or when it is loaded already, gives every room its weight back. diff --git a/src/level/room_config.h b/src/level/room_config.h index bdf267b..bf478b6 100644 --- a/src/level/room_config.h +++ b/src/level/room_config.h @@ -52,7 +52,7 @@ enum RoomFlag : uint32_t }; // Whether picking a room lowers its weight for the rest of the floor. -enum WeightReduction +enum WeightReduction : int { WEIGHT_KEEP, WEIGHT_REDUCE diff --git a/src/level/room_grid.cpp b/src/level/room_grid.cpp index 9a4da73..5072b57 100644 --- a/src/level/room_grid.cpp +++ b/src/level/room_grid.cpp @@ -14,6 +14,9 @@ #include "entity/npc/ai.h" #include "level/room.h" #include "level/room_descriptor.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/console.h" +#endif #include #include #include @@ -68,9 +71,12 @@ static int spot_path_limit(int triesLeft) } // 0041a790 The entities whose size reaches within a radius of a position and that queries may see: those of the -// partitions asked for, then the players, then the effects. +// partitions asked for, then the players, then the effects. REPENTOGON may draw the query. EntityList_EL entity_query_radius(const Vector& position, float radius, uint32_t partitions) { +#ifdef ISAAC_REPENTOGON + query_debug_render(position, radius); +#endif EntityList& list = g_game->room->entityList; EntityList_EL found; Vector extent = vector_make(radius, radius); @@ -91,9 +97,12 @@ EntityList_EL entity_query_radius(const Vector& position, float radius, uint32_t } // 0041ab50 (EntityList::query_player_capsule_hits) The entities a capsule touches that queries may see: those of the -// partitions asked for within its bounding box, then the players, then the effects. +// partitions asked for within its bounding box, then the players, then the effects. REPENTOGON may draw the query. EntityList_EL entity_query_capsule(const Capsule& capsule, uint32_t partitions) { +#ifdef ISAAC_REPENTOGON + query_debug_render(capsule); +#endif EntityList& list = g_game->room->entityList; EntityList_EL found; Vector low{}; diff --git a/src/level/room_special.cpp b/src/level/room_special.cpp index 948d24b..38ff783 100644 --- a/src/level/room_special.cpp +++ b/src/level/room_special.cpp @@ -19,6 +19,7 @@ #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" #include "repentogon/items.h" +#include "repentogon/npc.h" #endif constexpr int TRINKET_KEEPERS_BARGAIN = 171; @@ -699,10 +700,22 @@ static int shopkeeper_trinket_roll(RNG& rng) return 0; } -// 006c1ac0 What a shopkeeper drops when it dies (Entity_NPC::shopkeeper_get_loot), from its drop RNG, which only an -// advancing draw moves on: rarely Steam Sale, Head of the Keeper or Coupon, else two spiders, two coins or nothing. -// A secret room's shopkeeper rarely hides Greed, else a rare trinket or a nickel. One without a reward drops nothing. +// 006c1ac0 What a shopkeeper drops when it dies (Entity_NPC::shopkeeper_get_loot, shopkeeper_loot_roll). With +// REPENTOGON, mods' MC_PRE and MC_POST_NPC_GET_LOOT_LIST may change it. std::vector shopkeeper_loot_get(Entity_NPC& npc, bool isAdvance) +{ +#ifdef ISAAC_REPENTOGON + auto roll = [](Entity_NPC& shopkeeper, bool isDrawn) { return LootList{shopkeeper_loot_roll(shopkeeper, isDrawn)}; }; + return npc_loot_hook(npc, isAdvance, roll).entries; +#else + return shopkeeper_loot_roll(npc, isAdvance); +#endif +} + +// What a shopkeeper drops when it dies, from its drop RNG, which only an advancing draw moves on: rarely Steam Sale, +// Head of the Keeper or Coupon, else two spiders, two coins or nothing. A secret room's shopkeeper rarely hides +// Greed, else a rare trinket or a nickel. One without a reward drops nothing. +std::vector shopkeeper_loot_roll(Entity_NPC& npc, bool isAdvance) { std::vector loot; if (npc.HasEntityFlags(FLAG_NO_REWARD)) return loot; diff --git a/src/level/room_state.cpp b/src/level/room_state.cpp index 02b432f..bdc879f 100644 --- a/src/level/room_state.cpp +++ b/src/level/room_state.cpp @@ -18,11 +18,13 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/level.h" #include "repentogon/saves.h" #endif // The last frames of a clear's delay that leaving the room still counts the clear in. constexpr int ROOM_CLEAR_DELAY_PENDING = 8; +constexpr int ROOM_CLEAR_DELAY_PENDING_QUICK = 2; // The effects, slots and enemies whose saves keep more than the common fields. constexpr int HEAVEN_LIGHT_MOONLIGHT = 1; @@ -154,7 +156,8 @@ static bool effect_state_save(Entity_Effect& effect, EntitySaveState& state) bool entity_state_save(Room& room, Entity& entity, EntitySaveState& state, MinecartCheck check) { #ifdef ISAAC_REPENTOGON - if (!is_hook_inner() && lua_engine_get().is_callback_enabled(MC_ENTITY_SAVE)) + LuaEngine& lua = lua_engine_get(); + if (!is_hook_inner() && (lua.is_callback_enabled(MC_ENTITY_SAVE) || !lua.mods.empty())) return entity_save_hook(room, entity, state, check); #endif if (entity.isDead || entity.HasEntityFlags(FLAG_PERSISTENT)) return false; @@ -325,9 +328,12 @@ static void enemy_state_restore(Entity& entity, const EntitySaveState& state) } // 007ef420 Gives a respawned entity what its save kept (Entity_Pickup::RestoreState in the dump): its drop seed, grid -// cell and score, then what its class keeps. +// cell and score, then what its class keeps. MC_ENTITY_RESTORE follows. void entity_state_restore(Room& room, Entity& entity, const EntitySaveState& state) { +#ifdef ISAAC_REPENTOGON + ScopeExit post{[&] { entity_restore_notify(entity, state.saveStateId.id); }}; +#endif if (entity.pos.x == 0 && entity.pos.y == 0) entity.pos = room_free_pickup_position_find( {.position = room.GetRandomPosition(0), .step = UNPLACED_STEP, .isAvoidActiveEntities = true}); @@ -380,7 +386,11 @@ void Room::on_leave() room_restock_partial(*this); } if (game.currentRoomIdx == ROOM_DEBUG_IDX || descriptor->visitedCount == 0) return; - if (roomClearDelay >= 1 && roomClearDelay <= ROOM_CLEAR_DELAY_PENDING && !IsClear()) + int pendingDelay = ROOM_CLEAR_DELAY_PENDING; +#ifdef ISAAC_REPENTOGON + if (is_quick_room_clear()) pendingDelay = ROOM_CLEAR_DELAY_PENDING_QUICK; +#endif + if (roomClearDelay >= 1 && roomClearDelay <= pendingDelay && !IsClear()) { bool isGreedWave = game.IsGreedMode() && roomType == ROOM_DEFAULT; diff --git a/src/level/room_update.cpp b/src/level/room_update.cpp index e4d1441..c87ad02 100644 --- a/src/level/room_update.cpp +++ b/src/level/room_update.cpp @@ -28,6 +28,9 @@ #include #include #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/level.h" +#endif // The grid paths an entity leaves: a permanent mark, the value it fades back to, and how fast it fades. constexpr int GRID_PATH_DECAY_FRAMES = 3; @@ -37,6 +40,7 @@ constexpr int GRID_TIMER_MAX = 99; // The frames a room waits once its enemies are gone before it counts as cleared (a crawlspace's exit room longer). constexpr int ROOM_CLEAR_DELAY = 10; +constexpr int ROOM_CLEAR_DELAY_QUICK = 3; constexpr int ROOM_CLEAR_DELAY_DUNGEON_EXIT = 20; constexpr int OUTPUT_GROUP_ROOM_CLEAR = 9; // The fireplaces the pressure plates put out: red to normal, purple to blue. @@ -544,6 +548,9 @@ static void clear_update(Room& room) { room.roomClearDelay = isDungeon && dungeonKind == DUNGEON_ROTGUT_HEART ? ROOM_CLEAR_DELAY_DUNGEON_EXIT : ROOM_CLEAR_DELAY; +#ifdef ISAAC_REPENTOGON + if (room.roomClearDelay == ROOM_CLEAR_DELAY && is_quick_room_clear()) room.roomClearDelay = ROOM_CLEAR_DELAY_QUICK; +#endif return; } if (room.roomClearDelay >= 1) diff --git a/src/lua/callbacks.cpp b/src/lua/callbacks.cpp index 573f038..51593b8 100644 --- a/src/lua/callbacks.cpp +++ b/src/lua/callbacks.cpp @@ -8,6 +8,9 @@ #include "entity/npc/npc.h" #include "entity/pickup/pickup.h" #include "entity/player/player.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/player_config.h" +#endif #include "entity/weapon/projectile.h" #include "entity/weapon/tear.h" #include "game/game.h" @@ -16,6 +19,8 @@ #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" #include "repentogon/menus.h" +#include "repentogon/ui_patches.h" +#include "repentogon/vanilla_fixes.h" #endif constexpr int PILL_EFFECT_UNCHANGED = -1; @@ -250,6 +255,10 @@ bool LuaEngine::PreNPCUpdate(Entity_NPC* npc) // order, with each element that is not nil. void LuaEngine::Callback_PreEntitySpawn(EntitySpawn& spawn) { +#ifdef ISAAC_REPENTOGON + spawn.seed = spawn_seed_fix(spawn.seed); + ScopeExit fixed{[&] { spawn.seed = spawn_seed_fix(spawn.seed); }}; +#endif if (!callback_run(*this, {"PreEntitySpawn", MC_PRE_ENTITY_SPAWN}, spawn.type, spawn.variant, spawn.subType, spawn.position, spawn.velocity, spawn.spawner, spawn.seed)) return; @@ -300,6 +309,9 @@ bool LuaEngine::UseItem(LuaItemUse& use) // 00863e90 Runs MC_EVALUATE_CACHE for a player's stat, filtered by the cache flag. void LuaEngine::EvaluateItems(Entity_Player* player, int cacheFlag) { +#ifdef ISAAC_REPENTOGON + player_cache_pre_evaluate(*player, cacheFlag); +#endif callback_notify(*this, {"PostEvaluateItems", MC_EVALUATE_CACHE, cacheFlag}, player, cacheFlag); } @@ -539,6 +551,10 @@ void LuaEngine::PostProjectileRender(Entity_Projectile* projectile, const Vector // 00863680 Runs MC_POST_RENDER after the game renders. void LuaEngine::PostRender() { +#ifdef ISAAC_REPENTOGON + game_render_mark(false); + ScopeExit renderResume{[] { game_render_mark(true); }}; +#endif callback_notify(*this, {"PostRender", MC_POST_RENDER}); } diff --git a/src/repentogon/achievements.cpp b/src/repentogon/achievements.cpp new file mode 100644 index 0000000..418c872 --- /dev/null +++ b/src/repentogon/achievements.cpp @@ -0,0 +1,303 @@ +// Mods' achievements (Patches/AchievementsStuff.cpp): loaded from their content folders, saved apart from the game's, +// unlocked and shown like the game's own. +#include "repentogon/achievements.h" +#include "game/game.h" +#include "game/manager.h" +#include "game/mod_manager.h" +#include "repentogon/callbacks.h" +#include "repentogon/json_save.h" +#include "repentogon/xml.h" +#include "ui/popups.h" +#include + +// Mods' achievements come after the game's own, their conditions below 0. +constexpr int CUSTOM_ACHIEVEMENT_FIRST = ACHIEVEMENT_COUNT; +constexpr const char* ACHIEVEMENTS_FILE = "achievements.xml"; +constexpr const char* ACHIEVEMENTS_SAVE_MEMBER = "Achievements"; +constexpr const char* DEFAULT_PAPER = "gfx/ui/achievement/paper.png"; +constexpr int PAPER_SHEET = 2; +constexpr int CHARACTER_ANY = -1; +// REPENTOGON's progress of a mod's achievement: notified once unlocked, unlocked from 1, and locked by the console. +constexpr int PROGRESS_NOTIFIED = 2; +constexpr int PROGRESS_UNLOCKED = 1; +constexpr int PROGRESS_LOCKED = -9999; + +// The completion marks a condition names (CompletionTracker's reversemarksenum). An unknown one is 0. +constexpr std::pair MARK_NAMES[] = { + {"MOMS_HEART", 0}, {"ISAAC", 1}, {"SATAN", 2}, {"BOSS_RUSH", 3}, {"BLUE_BABY", 4}, + {"LAMB", 5}, {"MEGA_SATAN", 6}, {"ULTRA_GREED", 7}, {"HUSH", 9}, {"ULTRA_GREEDIER", 11}, + {"DELIRIUM", 12}, {"MOTHER", 13}, {"BEAST", 14}, {"MomsHeart", 0}, {"Isaac", 1}, + {"Satan", 2}, {"BossRush", 3}, {"BlueBaby", 4}, {"???", 4}, {"????", 4}, + {"Lamb", 5}, {"MegaSatan", 6}, {"UltraGreed", 7}, {"Greed", 7}, {"GREED", 7}, + {"Hush", 9}, {"UltraGreedier", 11}, {"GREEDIER", 11}, {"Greedier", 11}, {"Delirium", 12}, + {"Mother", 13}, {"Beast", 14}}; + +// A mod's achievement as its achievements.xml gives it (attributes by lowercase name, the root's inherited, and its +// s), or one of those conditions, which counts as a hidden achievement of its own. Its progress is saved by +// its name and mod. +struct CustomAchievement +{ + XmlAttributes attributes; + std::vector conditions; + std::string name; + std::string sourceId; + int id = 0; + bool isHidden = false; + + std::string key() const { return name + sourceId; } +}; + +static std::vector customAchievements; +static std::vector achievementConditions; +static JsonCounts achievementProgress; +// The achievements a completion mark (by mark and character, or any) or another achievement raises. +static std::map, std::vector> markListeners; +static std::map> achievementListeners; +static std::string achievementsPath; +static bool isPaperReplaced = false; + +static CustomAchievement* custom_achievement_get(int id) +{ + if (id >= CUSTOM_ACHIEVEMENT_FIRST && id - CUSTOM_ACHIEVEMENT_FIRST < (int)customAchievements.size()) + return &customAchievements[id - CUSTOM_ACHIEVEMENT_FIRST]; + if (id < 0 && -id - 1 < (int)achievementConditions.size()) return &achievementConditions[-id - 1]; + return nullptr; +} + +bool achievement_is_custom(int id) +{ + return custom_achievement_get(id) != nullptr; +} + +// (XMLData.cpp's achievements) Reads each loaded mod's achievements.xml, numbered after the game's own: each named by +// its name, else its text, else its steam_name. +void achievements_mods_load() +{ + customAchievements.clear(); + content_files_load(ACHIEVEMENTS_FILE, [](Data& data, ModEntry& mod) { + std::optional root = data_root_get(data, "achievements"); + if (!root) return; + + for (DataNode node : node_children(*root)) + { + if (node_tag(node) != "achievement") continue; + CustomAchievement& achievement = customAchievements.emplace_back(); + XmlAttributes& attributes = achievement.attributes = xml_attributes_read(node, {*root}); + + for (DataNode condition : node_children(node)) + if (node_tag(condition) == "condition") + achievement.conditions.push_back(xml_attributes_read(condition)); + achievement.id = CUSTOM_ACHIEVEMENT_FIRST + (int)customAchievements.size() - 1; + achievement.sourceId = mod.metadataWorkshopID.empty() ? mod.directory : mod.metadataWorkshopID; + achievement.name = attributes.contains("name") ? attributes["name"] : attributes["text"]; + if (achievement.name.empty()) achievement.name = attributes["steam_name"]; + achievement.isHidden = attributes.contains("hidden") && attributes["hidden"] != "false"; + } + }); +} + +// (GetAchievementIdByName) The achievement with this name, the last one given it, a condition or a mod's before the +// game's own, or -1. +int achievement_id_find(std::string_view name) +{ + for (auto list : {&achievementConditions, &customAchievements}) + for (auto achievement = list->rbegin(); achievement != list->rend(); achievement++) + if (achievement->name == name) return achievement->id; + + std::array& entries = g_manager->achievementOverlay.entries; + for (int id = ACHIEVEMENT_COUNT - 1; id > 0; id--) + if (entries[id].name == name) return id; + return -1; +} + +// (SingleValXMLParamParse) An achievement attribute naming an achievement in place of its number sets its id, when +// one has that name. +void achievement_attr_read(DataNode node, int& id) +{ + std::string text(node_attr(node, "achievement")); + char* end = nullptr; + std::strtol(text.c_str(), &end, 0); + if (text.empty() || end != text.c_str()) return; + + int found = achievement_id_find(text); + if (found != -1) id = found; +} + +static void achievements_save() +{ + if (achievementsPath.empty()) return; + json_save_write(achievementsPath, ACHIEVEMENTS_SAVE_MEMBER, &achievementProgress, nullptr); +} + +// (IncreaseAchievementCounter) Raises a mod's achievement towards its unlock, unlocking it on reaching it. +static void achievement_progress_raise(int id) +{ + CustomAchievement* achievement = custom_achievement_get(id); + int& progress = achievementProgress[achievement ? achievement->key() : ""]; + + if (progress == PROGRESS_UNLOCKED) return; + if (++progress == PROGRESS_UNLOCKED) g_manager->persistentGameData.TryUnlock(id); +} + +static void listeners_add(std::vector& listeners, int id) +{ + if (std::ranges::find(listeners, id) == listeners.end()) listeners.push_back(id); +} + +// (AddTrackers4Achiev) What raises an achievement: a count of raises it needs, and a completion mark (by a character +// when it names one, unknown ones being Isaac) or every one of a list of achievements, its last after the others. +static void achievement_trackers_add(CustomAchievement& achievement) +{ + XmlAttributes& attributes = achievement.attributes; + int& progress = achievementProgress[achievement.key()]; + int character = CHARACTER_ANY; + + if (attributes.contains("count")) progress = -(std::atoi(attributes["count"].c_str()) - 1); + if (attributes.contains("conditioncharacter")) + { + character = 0; + for (EntityConfig_Player& player : g_manager->entityConfig.players) + if (player.name == attributes["conditioncharacter"]) character = player.id; + } + + std::string& type = attributes["conditiontype"]; + std::string& value = attributes["conditionvalue"]; + if (type == "completionmark") + { + auto mark = std::ranges::find(MARK_NAMES, value, &std::pair::first); + listeners_add(markListeners[{mark == std::end(MARK_NAMES) ? 0 : mark->second, character}], achievement.id); + } + if (type != "achievement") return; + for (size_t start = 0, end = 0; end != value.npos; start = end + 1) + { + end = value.find(',', start); + std::string item = value.substr(start, end == value.npos ? end : end - start); + int id = std::atoi(item.c_str()); + listeners_add(achievementListeners[id ? id : achievement_id_find(item)], achievement.id); + if (end != value.npos) progress--; + } +} + +// (InitAchievs, LoadAchievementsFromJson) Starts every mod's achievement over: each condition made a hidden +// achievement the condition's owner waits on, then the trackers. The save's progress replaces any it is above. +static void achievements_progress_load() +{ + achievementProgress.clear(); + achievementConditions.clear(); + markListeners.clear(); + achievementListeners.clear(); + + for (CustomAchievement& achievement : customAchievements) + { + std::string conditionNames; + achievementProgress[achievement.key()] = 0; + for (XmlAttributes& attributes : achievement.conditions) + { + CustomAchievement& condition = achievementConditions.emplace_back(); + condition.attributes = attributes; + condition.id = -(int)achievementConditions.size(); + condition.name = std::format("{}-Cond-{}-{}-{}", achievement.key(), attributes["conditiontype"], + attributes["conditionvalue"], attributes["conditioncharacter"]); + condition.sourceId = achievement.sourceId; + condition.isHidden = true; + achievement.attributes["conditiontype"] = "achievement"; + conditionNames += (conditionNames.empty() ? "" : ",") + condition.name; + achievement_trackers_add(condition); + } + achievement.attributes["conditionvalue"] = conditionNames; + achievement_trackers_add(achievement); + } + + JsonCounts saved; + json_save_load(achievementsPath, ACHIEVEMENTS_SAVE_MEMBER, &saved, nullptr); + for (auto& [key, value] : saved) achievementProgress[key] = std::max(achievementProgress[key], value); +} + +// (Manager::SetSaveSlot) Reads the progress of the mods' achievements saved for a save file, the first for none. +void achievements_slot_load(unsigned int slot) +{ + achievementsPath = json_save_path(std::format("achievements{}.json", std::max(slot, 1u))); + achievements_progress_load(); +} + +// Reads the progress again once the mods' content loaded, when a save file was picked. +void achievements_reload() +{ + if (!achievementsPath.empty()) achievements_progress_load(); +} + +// (PersistentGameData::TryUnlock) Unlocks a mod's achievement unless it is or the save is read only: saved at once, +// raising the achievements waiting on it, and shown like the game's own unless hidden or asked not to be. +bool custom_achievement_unlock(PersistentGameData& data, int id) +{ + CustomAchievement& achievement = *custom_achievement_get(id); + int& progress = achievementProgress[achievement.key()]; + if (data.isReadOnly || progress > PROGRESS_UNLOCKED) return false; + + progress = PROGRESS_NOTIFIED; + for (int listener : achievementListeners[id]) achievement_progress_raise(listener); + achievements_save(); + + bool isSkipped = std::exchange(achievementPopupSkipped, -1) == id; + bool isShown = !g_manager->netplayManager.is_online() || !Manager::AchievementUnlocksDisallowed(); + if (!isSkipped && !achievement.isHidden && isShown && data.isSteamAchievementsEnabled) + Manager::queue_achievement_popup(id); + callback_notify(lua_engine_get(), {"PostAchievementUnlock", MC_POST_ACHIEVEMENT_UNLOCK, id}, id); + return true; +} + +// (PersistentGameData::Unlocked) Whether a mod's achievement is unlocked. +bool custom_achievement_is_unlocked(int id) +{ + return achievementProgress[custom_achievement_get(id)->key()] > 0; +} + +// (LockAchievement) Locks an achievement again, a mod's until unlocked anew. Whether it was unlocked. +bool achievement_lock(int id) +{ + if (achievementsPath.empty() || id <= 0) return false; + + PersistentGameData& data = g_manager->persistentGameData; + if (id < ACHIEVEMENT_COUNT) return std::exchange(data.achievements[id], false); + if (!achievement_is_custom(id)) return false; + + int& progress = achievementProgress[custom_achievement_get(id)->key()]; + bool isUnlocked = progress > 0; + progress = PROGRESS_LOCKED; + achievements_save(); + achievements_progress_load(); + return isUnlocked; +} + +// (RunTrackersForMark) Raises the achievements waiting on a completion mark for this character, then those for any. +void achievement_marks_run(int completion, int playerType) +{ + for (int id : markListeners[{completion, playerType}]) achievement_progress_raise(id); + if (playerType >= 0) + for (int id : markListeners[{completion, CHARACTER_ANY}]) achievement_progress_raise(id); +} + +bool achievement_marks_is_tracked() +{ + return !markListeners.empty(); +} + +// (ReplaceAchievementSprite) The entry the achievement popup shows for an id: a mod's with its paper (the default one +// without gfxback), or the game's own, putting the default paper back after a mod's. +AchievementEntry* achievement_entry_get(AchievementOverlay& overlay, int id) +{ + static AchievementEntry custom; + CustomAchievement* achievement = id >= CUSTOM_ACHIEVEMENT_FIRST ? custom_achievement_get(id) : nullptr; + if (!achievement && !isPaperReplaced) return &overlay.entries[id]; + + std::string paper = DEFAULT_PAPER; + if (achievement && achievement->attributes.contains("gfxback")) + paper = achievement->attributes["gfxroot"] + achievement->attributes["gfxback"]; + overlay.sprite.ReplaceSpritesheet(PAPER_SHEET, paper); + overlay.sprite.LoadGraphics(); + isPaperReplaced = achievement != nullptr; + if (!achievement) return &overlay.entries[id]; + + custom = {achievement->attributes["gfxroot"] + achievement->attributes["gfx"], achievement->name, id}; + return &custom; +} diff --git a/src/repentogon/achievements.h b/src/repentogon/achievements.h new file mode 100644 index 0000000..be469d4 --- /dev/null +++ b/src/repentogon/achievements.h @@ -0,0 +1,26 @@ +#pragma once + +#include "engine/data.h" +#include +#include + +class AchievementOverlay; +class PersistentGameData; +struct AchievementEntry; + +// The achievement PersistentGameData:Unlock or TryUnlock asked to unlock without its popup (REPENTOGON's +// nextSkipAchiev), or -1. +inline int achievementPopupSkipped = -1; + +void achievements_mods_load(); +void achievements_slot_load(unsigned int slot); +void achievements_reload(); +bool achievement_is_custom(int id); +bool custom_achievement_unlock(PersistentGameData& data, int id); +bool custom_achievement_is_unlocked(int id); +bool achievement_lock(int id); +int achievement_id_find(std::string_view name); +void achievement_attr_read(DataNode node, int& id); +void achievement_marks_run(int completion, int playerType); +bool achievement_marks_is_tracked(); +AchievementEntry* achievement_entry_get(AchievementOverlay& overlay, int id); diff --git a/src/repentogon/api_console.cpp b/src/repentogon/api_console.cpp index 99f503d..4eba350 100644 --- a/src/repentogon/api_console.cpp +++ b/src/repentogon/api_console.cpp @@ -2,11 +2,13 @@ #include "engine/platform.h" #include "game/game.h" #include "repentogon/api.h" +#include "repentogon/callbacks.h" #include "repentogon/repentogon.h" #include "ui/console.h" #ifdef ISAAC_OVERLAY #include "ui/overlay/overlay.h" #endif +#include #include #include #include @@ -77,6 +79,69 @@ void console_macro_names_add(std::vector& names) for (ModConsoleMacro& macro : modMacros) names.push_back(macro.name); } +// The command a mod registered by a name, null for none. +static ModConsoleCommand* mod_command_find(std::string_view name) +{ + auto command = std::ranges::find(modCommands, name, &ModConsoleCommand::name); + return command == modCommands.end() ? nullptr : &*command; +} + +// The AutocompleteType a mod registered a command with, AUTOCOMPLETE_UNREGISTERED for a command no mod registered. +int console_autocomplete_type_get(std::string_view name) +{ + ModConsoleCommand* command = mod_command_find(name); + return command ? command->autocompleteType : AUTOCOMPLETE_UNREGISTERED; +} + +// The description a mod registered a command with, empty for none. +std::string console_description_get(std::string_view name) +{ + ModConsoleCommand* command = mod_command_find(name); + return command ? command->description : std::string(); +} + +// The help text a mod registered a command with, empty for none. +std::string console_help_text_get(std::string_view name) +{ + ModConsoleCommand* command = mod_command_find(name); + return command ? command->helpText : std::string(); +} + +// MC_CONSOLE_AUTOCOMPLETE for a command of the CUSTOM type, filtered by its name, with its arguments: the entries of +// the table it returns, each a string or {text, description}, as "text:description" entries. +std::vector console_autocomplete_run(const std::string& command, const std::string& arguments) +{ + LuaEngine& engine = lua_engine_get(); + lua_State* state = engine.state; + std::vector entries; + if (!callback_run(engine, {"MC_CONSOLE_AUTOCOMPLETE", MC_CONSOLE_AUTOCOMPLETE, std::nullopt, std::nullopt, + command.c_str()}, + command, arguments)) + return entries; + + for (lua_Integer index = 1; lua_istable(state, -1) && index <= (lua_Integer)lua_rawlen(state, -1); index++) + { + lua_geti(state, -1, index); + if (lua_istable(state, -1)) + { + lua_geti(state, -1, 1); + std::string entry = lua_isstring(state, -1) ? lua_tostring(state, -1) : ""; + lua_pop(state, 1); + if (lua_rawlen(state, -1) == 2) + { + lua_geti(state, -1, 2); + if (lua_isstring(state, -1)) entry += std::string(":") + lua_tostring(state, -1); + lua_pop(state, 1); + } + entries.push_back(entry); + } + else if (lua_isstring(state, -1)) entries.push_back(lua_tostring(state, -1)); + lua_pop(state, 1); + } + lua_pop(state, 1); + return entries; +} + // The commands of the first macro a mod registered by a name, null for none. const std::vector* console_macro_find(std::string_view name) { @@ -215,6 +280,30 @@ static int registry_dump(lua_State* state) return 1; } +// (LuaInit.cpp) Benchmark(code): runs the code once, then again with the garbage collector stopped, giving the second +// run's nanoseconds. A first run's error names the code, as REPENTOGON reads the error from the wrong slot. +static int code_benchmark(lua_State* state) +{ + if (int count = lua_gettop(state); count != 1) return luaL_error(state, "Expected one parameter, got %d", count); + const char* code = lua_tostring(state, 1); + if (!code) return luaL_error(state, "Invalid parameter"); + if (luaL_dostring(state, code)) + { + std::string error = lua_tostring(state, 1); + lua_pop(state, 1); + return luaL_error(state, "Invalid error: %s", error.c_str()); + } + + bool isRunning = lua_gc(state, LUA_GCISRUNNING, 0); + if (isRunning) lua_gc(state, LUA_GCSTOP, 0); + auto begin = std::chrono::steady_clock::now(); + luaL_dostring(state, code); + auto end = std::chrono::steady_clock::now(); + lua_pushinteger(state, std::chrono::duration_cast(end - begin).count()); + if (isRunning) lua_gc(state, LUA_GCRESTART, 0); + return 1; +} + // ExtractFunctions: each class's C functions from 0, as {type = name, functions = {name = address}}, read off the // metatables in the registry. static int functions_extract(lua_State* state) @@ -418,10 +507,12 @@ void isaac_console_register(lua_State* state) }); } -// (LuaConsole.cpp, LuaDebug.cpp, LuaInit.cpp) Registers REPENTOGON's Console and Debug, and its global functions. +// (LuaConsole.cpp, LuaDebug.cpp, LuaInit.cpp, LuaImGui.cpp) Registers REPENTOGON's Console, ImGui and Debug, and its +// global functions. void console_classes_register(lua_State* state) { console_register(state); + imgui_register(state); lua_namespace_begin(state, "Debug"); lua_functions_add(state, {{"GetSignature", signature_get}, @@ -431,6 +522,7 @@ void console_classes_register(lua_State* state) lua_pushglobaltable(state); lua_functions_add(state, {{"DumpRegistry", registry_dump}, + {"Benchmark", code_benchmark}, {"ExtractFunctions", functions_extract}, {"RandomFloat", random_float_get}}); lua_method(state, "ToRadians", [](float angle) { return angle * std::numbers::pi / DEGREES_HALF_TURN; }); diff --git a/src/repentogon/api_game.h b/src/repentogon/api_game.h index c2242a9..6a0c2a2 100644 --- a/src/repentogon/api_game.h +++ b/src/repentogon/api_game.h @@ -13,7 +13,39 @@ void isaac_console_register(lua_State* state); void game_classes_register(lua_State* state); void console_classes_register(lua_State* state); void internals_mod_data_register(lua_State* state); +void imgui_register(lua_State* state); + +// REPENTOGON's AutocompleteType, from the console's own words (ConsoleMega.h), and a command no mod registered. +enum AutocompleteType : int +{ + AUTOCOMPLETE_UNREGISTERED = -1, + AUTOCOMPLETE_NONE, + AUTOCOMPLETE_ENTITY, + AUTOCOMPLETE_GOTO, + AUTOCOMPLETE_STAGE, + AUTOCOMPLETE_GRID, + AUTOCOMPLETE_DEBUG_FLAG, + AUTOCOMPLETE_ITEM, + AUTOCOMPLETE_CHALLENGE, + AUTOCOMPLETE_COMBO, + AUTOCOMPLETE_CUTSCENE, + AUTOCOMPLETE_MACRO, + AUTOCOMPLETE_SFX, + AUTOCOMPLETE_CURSE, + AUTOCOMPLETE_METRO, + AUTOCOMPLETE_DELIRIOUS, + AUTOCOMPLETE_PLAYER, + AUTOCOMPLETE_ACHIEVEMENT, + AUTOCOMPLETE_MODFOLDER, + AUTOCOMPLETE_CUSTOM, + AUTOCOMPLETE_EFFECT, + AUTOCOMPLETE_COUNT +}; void console_command_names_add(std::vector& names); void console_macro_names_add(std::vector& names); const std::vector* console_macro_find(std::string_view name); +int console_autocomplete_type_get(std::string_view name); +std::string console_description_get(std::string_view name); +std::string console_help_text_get(std::string_view name); +std::vector console_autocomplete_run(const std::string& command, const std::string& arguments); diff --git a/src/repentogon/api_imgui.cpp b/src/repentogon/api_imgui.cpp new file mode 100644 index 0000000..05f2215 --- /dev/null +++ b/src/repentogon/api_imgui.cpp @@ -0,0 +1,660 @@ +// REPENTOGON's ImGui Lua API (ImGuiFeatures/LuaImGui.cpp) over the element tree the overlay draws. +#include "engine/harness.h" +#include "engine/platform.h" +#include "game/game.h" +#include "repentogon/api.h" +#include "repentogon/custom_imgui.h" +#ifdef ISAAC_OVERLAY +#include "ui/overlay/overlay.h" +#endif +#include +#include +#include +#include +#include + +// The window flags SetWindowFlags keeps: the public ones, none of ImGui's internal or deprecated flags. +constexpr int WINDOW_FLAGS_PUBLIC = (1 << 23) - 1; +constexpr float PLOT_HEIGHT = 40; +constexpr int RGB_CHANNELS = 3; +// The integer ranges' defaults: REPENTOGON's float range cast to int, which MSVC makes INT_MIN for FLT_MAX. +constexpr lua_Integer INT_RANGE_MIN = 0; +constexpr lua_Integer INT_RANGE_MAX = INT_MIN; + +// The registry reference of the function at a slot, 0 for nil. An error for anything else. +static int callback_ref_get(lua_State* state, int slot) +{ + if (!lua_isfunction(state, slot) && !lua_isnoneornil(state, slot)) + return luaL_error(state, "Argument %d is not a function and not nil", slot - 1); + if (!lua_isfunction(state, slot)) return 0; + lua_pushvalue(state, slot); + return luaL_ref(state, LUA_REGISTRYINDEX); +} + +// An element by the id at a slot, an error naming what was looked for when there is none. +static CustomElement& element_check(lua_State* state, int slot, const char* what = "No element with id '%s' found.") +{ + const char* id = luaL_checkstring(state, slot); + CustomElement* element = customImGui.element_find(id); + if (!element) luaL_error(state, what, id); + return *element; +} + +// A window element by the id at argument 1, an error when there is none. +static CustomElement& window_check(lua_State* state, int slot = 1) +{ + CustomElement& element = element_check(state, slot, "Window Element with id '%s' not found"); + if (element.type != CUSTOM_WINDOW) luaL_error(state, "Window Element with id '%s' not found", element.id.c_str()); + return element; +} + +// Adds an element under a parent (EvalIDAndParent and AddElement): the parent must exist, an element with the id +// already there goes first. +static CustomElement* element_place(lua_State* state, const char* parentId, const char* id, const char* text, int type) +{ + if (!customImGui.element_find(parentId)) luaL_error(state, "Parent Element with id '%s'doesnt exist.", parentId); + if (customImGui.element_find(id)) customImGui.element_remove(id); + return customImGui.element_add(*customImGui.element_find(parentId), id, text, type); +} + +// Adds an element under the parent at argument 1 with the id at 2. The function at callbackSlot, when there is one, +// runs on event. +static CustomElement* element_create(lua_State* state, int type, const char* text, int callbackSlot = 0, + CustomCallback event = CUSTOM_EDITED) +{ + const char* parentId = luaL_checkstring(state, 1); + const char* id = luaL_checkstring(state, 2); + int callback = callbackSlot ? callback_ref_get(state, callbackSlot) : 0; + CustomElement* element = element_place(state, parentId, id, text, type); + if (callback) element->callbacks[event] = callback; + return element; +} + +// An element whose label is the optional string at argument 3 and whose function is at 4. +static CustomElement* element_labelled_create(lua_State* state, int type, CustomCallback event = CUSTOM_EDITED) +{ + return element_create(state, type, luaL_optstring(state, 3, ""), 4, event); +} + +// Reads the array at a slot into values, up to its first nil, as strings or numbers. +template +static void values_read(lua_State* state, int slot, std::vector& values) +{ + values.clear(); + for (lua_Integer index = 1; index <= (lua_Integer)lua_rawlen(state, slot); index++) + { + lua_geti(state, slot, index); + if (lua_isnil(state, -1)) break; + if constexpr (std::is_same_v) values.push_back((float)luaL_checknumber(state, -1)); + else values.push_back(luaL_checkstring(state, -1)); + lua_pop(state, 1); + } +} + +// Checks that the argument at a slot is a table, naming it one higher, as REPENTOGON counts. +static void table_check(lua_State* state, int slot) +{ + if (!lua_istable(state, slot)) luaL_error(state, "Argument %d needs to be a table!", slot + 1); +} + +// Whether the overlay shows (REPENTOGON's menuShown). +static bool is_overlay_shown() +{ +#ifdef ISAAC_OVERLAY + return overlay.is_visible(); +#else + return false; +#endif +} + +// Shows or hides the overlay (ImGui.Show and ImGui.Hide). +static void overlay_show(bool isShown) +{ +#ifdef ISAAC_OVERLAY + if (overlay.is_ready() && overlay.is_visible() != isShown) overlay.visible_set(isShown); +#endif +} + +// An input's value from argument 3, for UpdateData's Value. Whether the element holds one. +static bool element_value_update(lua_State* state, CustomElement& element) +{ + switch (element.type) + { + case CUSTOM_INPUT_TEXT: + case CUSTOM_INPUT_TEXT_WITH_HINT: + case CUSTOM_INPUT_TEXT_MULTILINE: + element.inputText = luaL_checkstring(state, 3); + return true; + case CUSTOM_CHECKBOX: + element.isChecked = lua_get(state, 3).value; + return true; + case CUSTOM_RADIO_BUTTON: + case CUSTOM_COMBOBOX: + element.index = (int)luaL_checkinteger(state, 3); + return true; + case CUSTOM_INPUT_INT: + case CUSTOM_DRAG_INT: + case CUSTOM_SLIDER_INT: + case CUSTOM_INPUT_CONTROLLER: + case CUSTOM_INPUT_KEYBOARD: + element.currentIntVal = (int)luaL_checkinteger(state, 3); + return true; + case CUSTOM_INPUT_FLOAT: + case CUSTOM_DRAG_FLOAT: + case CUSTOM_SLIDER_FLOAT: + case CUSTOM_PROGRESS_BAR: + element.currentFloatVal = (float)luaL_checknumber(state, 3); + return true; + default: + return false; + } +} + +// UpdateData (UpdateElementData): changes the data argument 2 names to argument 3. Whether the element has it. +static bool element_data_update(lua_State* state, CustomElement& element) +{ + CustomElementType type = element.type; + bool isRanged = type == CUSTOM_DRAG_INT || type == CUSTOM_SLIDER_INT || type == CUSTOM_DRAG_FLOAT || + type == CUSTOM_SLIDER_FLOAT; + bool isPlot = type == CUSTOM_PLOT_LINES || type == CUSTOM_PLOT_HISTOGRAM; + std::vector channels; + CustomData data = (CustomData)luaL_checkinteger(state, 2); + + switch (data) + { + case CUSTOM_DATA_LABEL: + element.name = luaL_checkstring(state, 3); + return true; + case CUSTOM_DATA_VALUE: + return element_value_update(state, element); + case CUSTOM_DATA_LIST_VALUES: + table_check(state, 3); + element.plotValues.clear(); + if (isPlot) values_read(state, 3, element.plotValues); + else values_read(state, 3, element.values); + return true; + case CUSTOM_DATA_MIN: + case CUSTOM_DATA_MAX: + if (!isRanged) return false; + (data == CUSTOM_DATA_MIN ? element.minVal : element.maxVal) = (float)luaL_checknumber(state, 3); + return true; + case CUSTOM_DATA_HINT_TEXT: + if (type != CUSTOM_INPUT_TEXT && type != CUSTOM_INPUT_TEXT_WITH_HINT && !isPlot && + type != CUSTOM_PROGRESS_BAR) + return false; + element.hintText = luaL_checkstring(state, 3); + return true; + case CUSTOM_DATA_COLOR_VALUES: + if (type != CUSTOM_COLOR_EDIT) return false; + table_check(state, 3); + values_read(state, 3, channels); + element.isColorAlpha = channels.size() > RGB_CHANNELS; + for (size_t channel = 0; channel < std::size(element.rgba) && channel < channels.size(); channel++) + element.rgba[channel] = channels[channel]; + return true; + default: + return false; + } +} + +// Sets or removes a style color of the element at argument 1. +static void element_color_set(CustomElement& element, int type, std::optional color) +{ + std::erase_if(element.colors, [&](CustomColor& pushed) { return pushed.type == type; }); + if (color) element.colors.push_back(*color); +} + +// A style color from the numbers at slot onward, alpha 1 when left out. +static CustomColor color_check(lua_State* state, int type, int slot) +{ + return {{(float)luaL_checknumber(state, slot), (float)luaL_checknumber(state, slot + 1), + (float)luaL_checknumber(state, slot + 2), (float)luaL_optnumber(state, slot + 3, 1)}, + type}; +} + +// The Add* functions for numeric inputs: a value, then their own steps, speed, range and format. +static void numeric_adders_add(lua_State* state) +{ + static const luaL_Reg NUMERIC_ADDERS[] = { + {"AddInputInteger", + [](lua_State* s) { + CustomElement* element = element_labelled_create(s, CUSTOM_INPUT_INT); + element->currentIntVal = (int)luaL_optinteger(s, 5, 0); + element->step = (float)luaL_optinteger(s, 6, 1); + element->stepFast = (float)luaL_optinteger(s, 7, (lua_Integer)INPUT_STEP_FAST); + return 0; + }}, + {"AddInputFloat", + [](lua_State* s) { + CustomElement* element = element_labelled_create(s, CUSTOM_INPUT_FLOAT); + element->currentFloatVal = (float)luaL_optnumber(s, 5, 0); + element->step = (float)luaL_optnumber(s, 6, 1); + element->stepFast = (float)luaL_optnumber(s, 7, INPUT_STEP_FAST); + return 0; + }}, + {"AddDragInteger", + [](lua_State* s) { + CustomElement* element = element_labelled_create(s, CUSTOM_DRAG_INT); + element->currentIntVal = (int)luaL_optinteger(s, 5, 0); + element->speed = (float)luaL_optnumber(s, 6, 1); + element->minVal = (float)luaL_optinteger(s, 7, INT_RANGE_MIN); + element->maxVal = (float)luaL_optinteger(s, 8, INT_RANGE_MAX); + element->formatting = luaL_optstring(s, 9, INT_FORMAT); + return 0; + }}, + {"AddDragFloat", + [](lua_State* s) { + CustomElement* element = element_labelled_create(s, CUSTOM_DRAG_FLOAT); + element->currentFloatVal = (float)luaL_optnumber(s, 5, 0); + element->speed = (float)luaL_optnumber(s, 6, 1); + element->minVal = (float)luaL_optnumber(s, 7, FLT_MIN); + element->maxVal = (float)luaL_optnumber(s, 8, FLT_MAX); + element->formatting = luaL_optstring(s, 9, FLOAT_FORMAT); + return 0; + }}, + {"AddSliderInteger", + [](lua_State* s) { + CustomElement* element = element_labelled_create(s, CUSTOM_SLIDER_INT); + element->currentIntVal = (int)luaL_optinteger(s, 5, 0); + element->minVal = (float)luaL_optinteger(s, 6, INT_RANGE_MIN); + element->maxVal = (float)luaL_optinteger(s, 7, INT_RANGE_MAX); + element->formatting = luaL_optstring(s, 8, INT_FORMAT); + return 0; + }}, + {"AddSliderFloat", [](lua_State* s) { + CustomElement* element = element_labelled_create(s, CUSTOM_SLIDER_FLOAT); + element->currentFloatVal = (float)luaL_optnumber(s, 5, 0); + element->minVal = (float)luaL_optnumber(s, 6, FLT_MIN); + element->maxVal = (float)luaL_optnumber(s, 7, FLT_MAX); + element->formatting = luaL_optstring(s, 8, FLOAT_FORMAT); + return 0; + }}}; + lua_functions_add(state, NUMERIC_ADDERS); +} + +// The Add* functions for every other element. +static void element_adders_add(lua_State* state) +{ + static const luaL_Reg ELEMENT_ADDERS[] = { + {"AddElement", + [](lua_State* s) { + int type = (int)luaL_checkinteger(s, 3); + element_create(s, type, luaL_optstring(s, 4, "")); + return 0; + }}, + {"AddButton", + [](lua_State* s) { + bool isSmall = lua_get>(s, 5).value; + element_labelled_create(s, isSmall ? CUSTOM_SMALL_BUTTON : CUSTOM_BUTTON, CUSTOM_CLICKED); + return 0; + }}, + {"AddText", + [](lua_State* s) { + const char* parentId = luaL_checkstring(s, 1); + const char* text = luaL_optstring(s, 2, ""); + bool isWrapped = lua_get>(s, 3).value; + const char* id = luaL_optstring(s, 4, ""); + element_place(s, parentId, id, text, isWrapped ? CUSTOM_TEXT_WRAPPED : CUSTOM_TEXT); + return 0; + }}, + {"AddInputColor", + [](lua_State* s) { + CustomElement* element = element_labelled_create(s, CUSTOM_COLOR_EDIT); + element->isColorAlpha = !lua_isnoneornil(s, 8); + for (int channel = 0; channel < RGB_CHANNELS; channel++) + element->rgba[channel] = (float)luaL_optnumber(s, 5 + channel, 0); + element->rgba[RGB_CHANNELS] = (float)luaL_optnumber(s, 8, 1); + return 0; + }}, + {"AddCheckbox", + [](lua_State* s) { + element_labelled_create(s, CUSTOM_CHECKBOX)->isChecked = lua_get>(s, 5).value; + return 0; + }}, + {"AddRadioButtons", + [](lua_State* s) { + table_check(s, 4); + CustomElement* element = element_create(s, CUSTOM_RADIO_BUTTON, "", 3); + element->index = (int)luaL_optinteger(s, 5, 0); + element->isSameLine = lua_get>(s, 6).value; + values_read(s, 4, element->values); + return 0; + }}, + {"AddTabBar", + [](lua_State* s) { + element_create(s, CUSTOM_TAB_BAR, ""); + return 0; + }}, + {"AddTab", + [](lua_State* s) { + const char* text = luaL_checkstring(s, 3); + CustomElement* parent = customImGui.element_find(luaL_checkstring(s, 1)); + if (parent && parent->type != CUSTOM_TAB_BAR) + return luaL_error(s, "The given parent element is not of type 'TabBar'!"); + element_create(s, CUSTOM_TAB, text); + return 0; + }}, + {"AddCombobox", + [](lua_State* s) { + table_check(s, 5); + CustomElement* element = element_labelled_create(s, CUSTOM_COMBOBOX); + element->index = (int)luaL_optinteger(s, 6, 0); + element->isSlider = lua_get>(s, 7).value; + values_read(s, 5, element->values); + return 0; + }}, + {"AddInputText", + [](lua_State* s) { + CustomElement* element = element_labelled_create(s, CUSTOM_INPUT_TEXT); + element->inputText = luaL_optstring(s, 5, ""); + element->hintText = luaL_optstring(s, 6, ""); + return 0; + }}, + {"AddInputTextMultiline", + [](lua_State* s) { + CustomElement* element = element_labelled_create(s, CUSTOM_INPUT_TEXT_MULTILINE); + element->inputText = luaL_optstring(s, 5, ""); + element->lineCount = (float)luaL_optnumber(s, 6, INPUT_LINES); + return 0; + }}, + {"AddInputController", + [](lua_State* s) { + element_labelled_create(s, CUSTOM_INPUT_CONTROLLER)->currentIntVal = (int)luaL_optinteger(s, 5, 0); + return 0; + }}, + {"AddInputKeyboard", + [](lua_State* s) { + element_labelled_create(s, CUSTOM_INPUT_KEYBOARD)->currentIntVal = (int)luaL_optinteger(s, 5, 0); + return 0; + }}, + {"AddPlotLines", + [](lua_State* s) { + table_check(s, 4); + CustomElement* element = element_create(s, CUSTOM_PLOT_LINES, luaL_optstring(s, 3, "")); + element->hintText = luaL_optstring(s, 5, ""); + element->minVal = (float)luaL_optnumber(s, 6, FLT_MIN); + element->maxVal = (float)luaL_optnumber(s, 7, FLT_MAX); + element->sizeY = (float)luaL_optnumber(s, 8, PLOT_HEIGHT); + values_read(s, 4, element->plotValues); + return 0; + }}, + {"AddPlotHistogram", + [](lua_State* s) { + table_check(s, 4); + CustomElement* element = element_create(s, CUSTOM_PLOT_HISTOGRAM, luaL_optstring(s, 3, "")); + element->hintText = luaL_optstring(s, 5, ""); + element->minVal = (float)luaL_optnumber(s, 6, FLT_MIN); + element->maxVal = (float)luaL_optnumber(s, 7, FLT_MAX); + element->sizeY = (float)luaL_optnumber(s, 8, PLOT_HEIGHT); + values_read(s, 4, element->plotValues); + return 0; + }}, + {"AddProgressBar", [](lua_State* s) { + CustomElement* element = element_create(s, CUSTOM_PROGRESS_BAR, luaL_optstring(s, 3, "")); + element->currentFloatVal = (float)luaL_optnumber(s, 4, 0); + element->hintText = luaL_optstring(s, 5, PROGRESS_DEFAULT); + return 0; + }}}; + lua_functions_add(state, ELEMENT_ADDERS); +} + +// Creating, linking, finding and removing elements, menus and windows, and their callbacks. +static void tree_functions_add(lua_State* state) +{ + static const luaL_Reg TREE_FUNCTIONS[] = { + {"RemoveElement", + [](lua_State* s) { + customImGui.element_remove(luaL_checkstring(s, 1)); + return 0; + }}, + {"CreateMenu", + [](lua_State* s) { + const char* id = luaL_checkstring(s, 1); + const char* text = luaL_checkstring(s, 2); + if (customImGui.element_find(id)) customImGui.element_remove(id); + CustomElement& menu = customImGui.menus.emplace_back(); + menu.id = id; + menu.name = text; + menu.type = CUSTOM_MENU; + return 0; + }}, + {"CreateWindow", + [](lua_State* s) { + const char* id = luaL_checkstring(s, 1); + const char* title = luaL_checkstring(s, 2); + const char* parentId = luaL_optstring(s, 3, nullptr); + if (customImGui.element_find(id)) customImGui.element_remove(id); + CustomElement* parent = parentId ? customImGui.element_find(parentId) : nullptr; + if (parentId && !parent) return luaL_error(s, "Error while adding new Window '%s'", id); + if (parent) customImGui.element_add(*parent, id, title, CUSTOM_WINDOW); + else + { + CustomElement& window = customImGui.windows.emplace_back(); + window.id = id; + window.name = title; + } + return 0; + }}, + {"LinkWindowToElement", + [](lua_State* s) { + const char* windowId = luaL_checkstring(s, 1); + const char* elementId = luaL_checkstring(s, 2); + CustomElement* window = customImGui.element_find(windowId); + CustomElement* element = customImGui.element_find(elementId); + if (!window) return luaL_error(s, "No window with id '%s' exists", windowId); + if (!element) return luaL_error(s, "Element with id '%s' not found", elementId); + if (window->type == CUSTOM_POPUP) element->triggerPopup = window; + else window->triggerElement = element; + if (element->type != CUSTOM_MENU_ITEM) element->callbacks[CUSTOM_CLICKED] = 0; + return 0; + }}, + {"ElementExists", + [](lua_State* s) { + lua_pushboolean(s, customImGui.element_find(luaL_checkstring(s, 1)) != nullptr); + return 1; + }}, + {"AddCallback", + [](lua_State* s) { + const char* id = luaL_checkstring(s, 1); + CustomCallback type = (CustomCallback)luaL_checkinteger(s, 2); + if (!lua_isfunction(s, 3)) return luaL_error(s, "Argument %d is not a function", 3); + CustomElement* element = customImGui.element_find(id); + if (!element) return luaL_error(s, "No element '%s' found.", id); + element->callbacks[type] = callback_ref_get(s, 3); + return 0; + }}, + {"RemoveCallback", + [](lua_State* s) { + const char* id = luaL_checkstring(s, 1); + CustomCallback type = (CustomCallback)luaL_checkinteger(s, 2); + CustomElement* element = customImGui.element_find(id); + if (!element) return luaL_error(s, "No element '%s' found.", id); + element->callbacks.erase(type); + return 0; + }}, + {"Reset", [](lua_State*) { + customImGui.reset(); + return 0; + }}}; + lua_functions_add(state, TREE_FUNCTIONS); +} + +// Changing elements' texts, data, colors, sizes, visibility and windows' flags, and reading them back. +static void element_setters_add(lua_State* state) +{ + static const luaL_Reg ELEMENT_SETTERS[] = { + {"UpdateText", + [](lua_State* s) { + CustomElement& element = element_check(s, 1); + element.name = luaL_checkstring(s, 2); + return 0; + }}, + {"UpdateData", + [](lua_State* s) { + CustomElement& element = element_check(s, 1); + luaL_checkinteger(s, 2); + if (!element_data_update(s, element)) + return luaL_error(s, "The given element does not use the provided data type."); + return 0; + }}, + {"SetTooltip", + [](lua_State* s) { + CustomElement& element = element_check(s, 1); + element.tooltipText = luaL_checkstring(s, 2); + return 0; + }}, + {"SetHelpmarker", + [](lua_State* s) { + CustomElement& element = element_check(s, 1); + element.helpmarkerText = luaL_checkstring(s, 2); + return 0; + }}, + {"SetColor", + [](lua_State* s) { + CustomElement& element = element_check(s, 1, "Element with id '%s' not found"); + int type = (int)luaL_checkinteger(s, 2); + element_color_set(element, type, color_check(s, type, 3)); + return 0; + }}, + {"RemoveColor", + [](lua_State* s) { + CustomElement& element = element_check(s, 1, "Element with id '%s' not found"); + element_color_set(element, (int)luaL_checkinteger(s, 2), std::nullopt); + return 0; + }}, + {"SetTextColor", + [](lua_State* s) { + CustomElement& element = element_check(s, 1, "Element with id '%s' not found"); + element_color_set(element, CUSTOM_COLOR_TEXT, color_check(s, CUSTOM_COLOR_TEXT, 2)); + return 0; + }}, + {"SetSize", + [](lua_State* s) { + CustomElement& element = element_check(s, 1, "Element with id '%s' not found"); + element.sizeX = (float)luaL_checknumber(s, 2); + element.sizeY = (float)luaL_checknumber(s, 3); + element.isSizeRequested = true; + return 0; + }}, + {"SetVisible", + [](lua_State* s) { + CustomElement& element = element_check(s, 1, "Element with id '%s' not found"); + element.visible_set(lua_get(s, 2).value); + return 0; + }}, + {"GetVisible", + [](lua_State* s) { + CustomElement& element = element_check(s, 1, "Element with id '%s' not found"); + lua_pushboolean(s, (is_overlay_shown() || element.isWindowPinned) && element.isEvaluatedVisible); + return 1; + }}, + {"SetWindowPinned", + [](lua_State* s) { + window_check(s).isWindowPinned = lua_get(s, 2).value; + return 0; + }}, + {"GetWindowPinned", + [](lua_State* s) { + // REPENTOGON reads the id from argument 2. + lua_pushboolean(s, window_check(s, 2).isWindowPinned); + return 1; + }}, + {"SetWindowFlags", + [](lua_State* s) { + window_check(s).windowFlags = (int)luaL_checkinteger(s, 2) & WINDOW_FLAGS_PUBLIC; + return 0; + }}, + {"GetWindowFlags", + [](lua_State* s) { + lua_pushinteger(s, window_check(s).windowFlags); + return 1; + }}, + {"SetWindowChildFlags", + [](lua_State* s) { + window_check(s).childFlags = (int)luaL_checkinteger(s, 2); + return 0; + }}, + {"GetWindowChildFlags", + [](lua_State* s) { + lua_pushinteger(s, window_check(s).childFlags); + return 1; + }}, + {"SetWindowPosition", [](lua_State* s) { + CustomElement& window = window_check(s); + window.positionX = (float)luaL_checknumber(s, 2); + window.positionY = (float)luaL_checknumber(s, 3); + window.isPositionRequested = true; + return 0; + }}}; + lua_functions_add(state, ELEMENT_SETTERS); +} + +// The overlay, the game's window and the mouse, and notifications. +static void overlay_functions_add(lua_State* state) +{ + static const luaL_Reg OVERLAY_FUNCTIONS[] = { + {"GetGameWindowRect", + [](lua_State* s) { + int x = 0; + int y = 0; + int width = 0; + int height = 0; + SDL_GetWindowPosition(platform.window, &x, &y); + SDL_GetWindowSize(platform.window, &width, &height); + lua_push(s, vector_make((float)x, (float)y)); + lua_push(s, vector_make((float)width, (float)height)); + return 2; + }}, + {"GetMousePosition", + [](lua_State* s) { + Vector position = {}; + harness.mouse_get(&position.x, &position.y); + lua_push(s, position); + return 1; + }}, + {"PushNotification", + [](lua_State* s) { + const char* text = luaL_checkstring(s, 1); + int severity = (int)luaL_optinteger(s, 2, NOTIFICATION_INFO); + if (severity < 0 || severity >= NOTIFICATION_SEVERITY_COUNT) + return luaL_error(s, "Severity needs to be a value between 0 and 3"); + uint64_t lifetime = (uint64_t)luaL_optinteger(s, 3, NOTIFICATION_LIFETIME); + customImGui.notifications.push_front({text, SDL_GetTicks() + lifetime, (NotificationSeverity)severity}); + return 0; + }}, + {"Show", + [](lua_State*) { + overlay_show(true); + return 0; + }}, + {"Hide", + [](lua_State*) { + overlay_show(false); + return 0; + }}, + {"IsVisible", [](lua_State* s) { + lua_pushboolean(s, is_overlay_shown()); + return 1; + }}}; + lua_functions_add(state, OVERLAY_FUNCTIONS); +} + +// (LuaImGui.cpp) Registers the ImGui global, a plain table, with RemoveMenu and RemoveWindow as RemoveElement and +// SetWindowSize as SetSize. +void imgui_register(lua_State* state) +{ + lua_namespace_begin(state, "ImGui"); + numeric_adders_add(state); + element_adders_add(state); + tree_functions_add(state); + element_setters_add(state); + overlay_functions_add(state); + for (auto [alias, name] : {std::pair{"RemoveMenu", "RemoveElement"}, {"RemoveWindow", "RemoveElement"}, + {"SetWindowSize", "SetSize"}}) + { + lua_pushstring(state, name); + lua_rawget(state, -2); + lua_table_set(state, -2, alias); + } + lua_namespace_plain_end(state); +} diff --git a/src/repentogon/api_misc.cpp b/src/repentogon/api_misc.cpp index 00ee594..b3db04b 100644 --- a/src/repentogon/api_misc.cpp +++ b/src/repentogon/api_misc.cpp @@ -1,4 +1,5 @@ #include "engine/capsule.h" +#include "engine/filesys.h" #include "engine/platform.h" #include "engine/seeds.h" #include "entity/config.h" @@ -15,11 +16,14 @@ #include "repentogon/api_items.h" #include "repentogon/options.h" #include "repentogon/repentogon.h" +#include "repentogon/xml.h" +#include "stb_image.h" #include #include #include #include #include +#include #include #include #include @@ -448,6 +452,99 @@ static int window_title_set(lua_State* state) return 0; } +// An .ico file's directory: where each image starts and its size, after the 6 byte header, 16 bytes an entry. +constexpr size_t ICO_HEADER_SIZE = 6; +constexpr size_t ICO_ENTRY_SIZE = 16; +constexpr size_t ICO_ENTRY_SIZE_OFFSET = 8; +constexpr size_t ICO_ENTRY_DATA_OFFSET = 12; +constexpr size_t ICO_COUNT_OFFSET = 4; +constexpr int ICO_SIZE_BYTE_ZERO = 256; +// A bitmap image of an .ico: its BITMAPINFOHEADER (width, doubled height, bit depth) and 32-bit BGRA rows bottom up. +constexpr int DIB_WIDTH_OFFSET = 4; +constexpr int DIB_HEIGHT_OFFSET = 8; +constexpr int DIB_BITS_OFFSET = 14; +constexpr int DIB_BITS_BGRA = 32; +constexpr int ICON_SMALL_SIZE = 16; +constexpr unsigned char PNG_SIGNATURE[] = {0x89, 'P', 'N', 'G'}; + +template +static T bytes_read(const std::string& bytes, size_t offset) +{ + T value{}; + if (offset + sizeof(T) <= bytes.size()) std::memcpy(&value, bytes.data() + offset, sizeof(T)); + return value; +} + +// The image of an .ico closest to size (the largest without one) as an RGBA surface, null when none reads. +static SDL_Surface* icon_surface_load(const std::string& bytes, int size) +{ + auto count = bytes_read(bytes, ICO_COUNT_OFFSET); + size_t best = 0; + int bestSize = -1; + for (size_t i = 0; i < count; i++) + { + size_t entry = ICO_HEADER_SIZE + i * ICO_ENTRY_SIZE; + int width = bytes_read(bytes, entry) ? bytes_read(bytes, entry) : ICO_SIZE_BYTE_ZERO; + bool isBetter = bestSize < 0 || (size ? std::abs(width - size) < std::abs(bestSize - size) : width > bestSize); + if (isBetter) std::tie(best, bestSize) = std::pair{entry, width}; + } + if (bestSize < 0) return nullptr; + + auto length = bytes_read(bytes, best + ICO_ENTRY_SIZE_OFFSET); + auto offset = bytes_read(bytes, best + ICO_ENTRY_DATA_OFFSET); + if ((size_t)offset + length > bytes.size()) return nullptr; + std::string image = bytes.substr(offset, length); + + int width = 0; + int height = 0; + if (image.starts_with(std::string_view((const char*)PNG_SIGNATURE, sizeof(PNG_SIGNATURE)))) + { + int channels = 0; + stbi_uc* pixels = stbi_load_from_memory((stbi_uc*)image.data(), (int)image.size(), &width, &height, &channels, + STBI_rgb_alpha); + if (!pixels) return nullptr; + SDL_Surface* surface = SDL_CreateSurface(width, height, SDL_PIXELFORMAT_RGBA32); + if (surface) std::memcpy(surface->pixels, pixels, (size_t)width * height * 4); + stbi_image_free(pixels); + return surface; + } + + auto headerSize = bytes_read(image, 0); + width = bytes_read(image, DIB_WIDTH_OFFSET); + height = bytes_read(image, DIB_HEIGHT_OFFSET) / 2; + if (bytes_read(image, DIB_BITS_OFFSET) != DIB_BITS_BGRA || width <= 0 || height <= 0) return nullptr; + if (headerSize + (size_t)width * height * 4 > image.size()) return nullptr; + + SDL_Surface* surface = SDL_CreateSurface(width, height, SDL_PIXELFORMAT_BGRA32); + if (!surface) return nullptr; + for (int row = 0; row < height; row++) + std::memcpy((char*)surface->pixels + (size_t)row * surface->pitch, + image.data() + headerSize + (size_t)(height - 1 - row) * width * 4, (size_t)width * 4); + return surface; +} + +// Isaac.SetIcon: the game window's icon from a mod's .ico, 16 pixels unless the cap is bypassed. The game's own icons +// (0 and 1) live in the original's executable, which the rebuild does not have, so those change nothing. +static int icon_set(lua_State* state) +{ + static std::string currentIconPath; + bool isUncapped = lua_toboolean(state, 2); + if (lua_isinteger(state, 1)) return 0; + + std::string path = luaL_optstring(state, 1, ""); + if (path.empty()) return 0; + path = g_manager->modManager.TryRedirectPath(path); + if (path == currentIconPath) return 0; + + std::string bytes; + SDL_Surface* icon = resource_load(path, bytes) ? icon_surface_load(bytes, isUncapped ? 0 : ICON_SMALL_SIZE) : nullptr; + if (!icon) return luaL_error(state, "Icon has failed to load!"); + SDL_SetWindowIcon(platform.window, icon); + SDL_DestroySurface(icon); + currentIconPath = path; + return 0; +} + // Isaac.GetLocalizedString: a string of the string table in a language, by id or REPENTOGON's language code. static int localized_string_get(lua_State* state) { @@ -499,6 +596,7 @@ void isaac_misc_register(lua_State* state) {"GetLoadedModules", loaded_modules_get}, {"SetDwmWindowAttribute", dwm_attribute_set}, {"SetWindowTitle", window_title_set}, + {"SetIcon", icon_set}, {"GetLocalizedString", localized_string_get}, {"LoadModDataFromFolder", folder_mod_data_load}}); lua_method(state, "GetDwmWindowAttribute", [](LuaDefault) { return 0; }); @@ -514,7 +612,10 @@ void isaac_misc_register(lua_State* state) if (baby.name == name) return baby.id; return -1; }); + lua_method(state, "GetBackdropIdByName", [](std::string name) { return backdrop_id_find(name); }); + lua_method(state, "GetGiantBookIdByName", [](std::string name) { return giantbook_id_find(name); }); lua_method(state, "IsShuttingDown", []() { return isShuttingDown; }); + item_spoof_isaac_register(state); lua_method(state, "GetNanoTime", []() { auto now = std::chrono::high_resolution_clock::now().time_since_epoch(); return (lua_Integer)std::chrono::duration_cast(now).count(); diff --git a/src/repentogon/api_npc.cpp b/src/repentogon/api_npc.cpp index 115ccdf..c2be15e 100644 --- a/src/repentogon/api_npc.cpp +++ b/src/repentogon/api_npc.cpp @@ -13,6 +13,8 @@ #include "game/game.h" #include "game/manager.h" #include "repentogon/api.h" +#include "repentogon/entities.h" +#include "repentogon/callbacks.h" #include "repentogon/npc.h" #include "repentogon/options.h" #include "repentogon/weapons.h" @@ -29,6 +31,9 @@ constexpr int SPAWN_BOSS_TYPE_END = 990; constexpr int SPAWN_BOSS_SEED_ARG = 7; constexpr int SPAWN_BOSS_SPAWNER_ARG = 6; constexpr int DELIRIUM_TYPE_FIRST = 10; +constexpr const char* DELIRIUM_PRE_TRANSFORMATION = "DeliriumPreTransformation"; +constexpr const char* DELIRIUM_TRANSFORMATION = "DeliriumTransformation"; +constexpr const char* DELIRIUM_POST_TRANSFORMATION = "DeliriumPostTransformation"; constexpr int DELIRIUM_RAGE_FULL = 0xff; constexpr int DELIRIUM_TELEPORT_MAX = 0x3ff; constexpr int DELIRIUM_RAGE_SHIFT = 7; @@ -54,16 +59,87 @@ constexpr int LASER_HURT_WISP = 427; constexpr const char* TAG_CAN_TAKE_DAMAGE = "familiarcantakedamage"; constexpr const char* TAG_BLOCK_PROJECTILES = "familiarblockprojectiles"; -// The forms Delirium:Transform sets for his next change. -static std::map> forcedForms; +// The form Delirium:Transform sets for his next change, and whether DeliriumCallbacks.TRANSFORMATION sees it. +struct ForcedForm +{ + int type; + int variant; + bool isCallbackRun; +}; -// (ASMDelirium.cpp) Delirium's next form, when Transform forced one. -void delirium_form_force(Entity_NPC& npc, unsigned int& type, unsigned int& variant) +static std::map forcedForms; + +// Runs one of the DeliriumCallbacks (string ids, which run without an enable state) with Delirium and args. Whether +// it ran, leaving its result on the stack. +template +static bool delirium_callback_run(const char* id, Entity_NPC& npc, Args... args) +{ + LuaEngine& engine = lua_engine_get(); + if (engine.mods.empty()) return false; + + lua_State* state = engine.state; + lua_rawgeti(state, LUA_REGISTRYINDEX, engine.runCallbackRef); + lua_pushstring(state, id); + lua_pushnil(state); + lua_object_push(state, &npc, LUA_CLASS_ENTITY_DELIRIUM); + (lua_push(state, args), ...); + if (lua_pcall(state, sizeof...(Args) + 3, 1, 0) == LUA_OK) return true; + + lua_error_log(state, id); + return false; +} + +// (Patches/ASMPatches/ASMDelirium.cpp) DeliriumCallbacks.PRE_TRANSFORMATION as Delirium is about to change. Whether +// he does: false keeps him in his form, attacking. +bool delirium_morph_pre(Entity_NPC& npc) +{ + if (!delirium_callback_run(DELIRIUM_PRE_TRANSFORMATION, npc)) return true; + + bool isMorphing = !is_result_false(lua_engine_get().state); + lua_pop(lua_engine_get().state, 1); + return isMorphing; +} + +// DeliriumCallbacks.TRANSFORMATION for the form Delirium picked, or the one Transform forced, which skips it unless +// asked. False keeps his current form, a table of a type (and a variant, 0 without one) replaces it. +void delirium_form_hook(Entity_NPC& npc, int& type, int& variant) { auto forced = forcedForms.find(&npc); - if (forced == forcedForms.end()) return; - std::tie(type, variant) = forced->second; - forcedForms.erase(forced); + bool isForced = forced != forcedForms.end(); + if (isForced) + { + ForcedForm form = forced->second; + forcedForms.erase(forced); + type = form.type; + variant = form.variant; + if (!form.isCallbackRun) return; + } + if (!delirium_callback_run(DELIRIUM_TRANSFORMATION, npc, type, variant, isForced)) return; + + lua_State* state = lua_engine_get().state; + if (lua_isboolean(state, -1) && !lua_toboolean(state, -1)) + { + type = (int)npc.deliriumBossType; + variant = (int)npc.deliriumBossVariant; + } + else if (lua_istable(state, -1)) + { + if (lua_rawgeti(state, -1, 1) == LUA_TNUMBER) + { + type = (int)lua_tointeger(state, -1); + variant = 0; + if (lua_rawgeti(state, -2, 2) == LUA_TNUMBER) variant = (int)lua_tointeger(state, -1); + lua_pop(state, 1); + } + lua_pop(state, 1); + } + lua_pop(state, 1); +} + +// DeliriumCallbacks.POST_TRANSFORMATION once Delirium changed. +void delirium_morph_post(Entity_NPC& npc) +{ + if (delirium_callback_run(DELIRIUM_POST_TRANSFORMATION, npc)) lua_pop(lua_engine_get().state, 1); } // Whether a familiar's custom tags hold a tag. @@ -88,12 +164,13 @@ static bool familiar_projectile_hurt_check(Entity_Familiar& familiar) (variant == FV::WISP && familiar.subtype != VENGEFUL_SPIRIT_WISP); } -// (FamiliarTags.cpp) Whether enemy lasers hurt a familiar: with the damage tag, else the game's own few. +// (FamiliarTags.cpp) Whether enemy lasers hurt a familiar: with the damage tag or as its attribute says, else the +// game's own few. static bool familiar_laser_hurt_check(Entity_Familiar& familiar) { - if (is_tagged(familiar, TAG_CAN_TAKE_DAMAGE)) return true; int variant = familiar.variant; - return is_listed(HURTABLE_FAMILIARS, variant) || (variant == FV::WISP && familiar.subtype == LASER_HURT_WISP); + bool isWisp = variant == FV::WISP && familiar.subtype == LASER_HURT_WISP; + return familiar_laser_hit_get(familiar, is_listed(HURTABLE_FAMILIARS, variant) || isWisp); } // EntityFamiliar:TryAimAtMarkedTarget. With three arguments its target position or nil, else whether it aimed and a @@ -415,13 +492,13 @@ static void delirium_attack_set(Entity_NPC& npc, uint32_t attack) npc.deliriumAttackFrame = attack >> 3 * BYTE_BITS & BYTE_MASK; } -// Delirium:Transform, into a type from the first enemy on at his next change. +// Delirium:Transform, into a type from the first enemy on at his next change, through TRANSFORMATION when asked. static int delirium_transform(lua_State* state) { Entity_NPC& npc = lua_get(state, 1); int type = (int)luaL_checkinteger(state, 2); if (type < DELIRIUM_TYPE_FIRST) return luaL_error(state, "Invalid EntityType %d for Delirium\n", type); - forcedForms[&npc] = {(uint32_t)type, (uint32_t)luaL_optinteger(state, 3, 0)}; + forcedForms[&npc] = {type, (int)luaL_optinteger(state, 3, 0), lua_toboolean(state, 4) != 0}; npc.deliriumTransformationTimer = 1; return 0; } diff --git a/src/repentogon/api_room.cpp b/src/repentogon/api_room.cpp index 617e0c4..ddb6cfa 100644 --- a/src/repentogon/api_room.cpp +++ b/src/repentogon/api_room.cpp @@ -11,6 +11,8 @@ #include "repentogon/api_level.h" #include "repentogon/level.h" #include "repentogon/lua_render.h" +#include "repentogon/npc.h" +#include "repentogon/xml.h" #include // The last pressure plate output group TriggerOutput takes. @@ -45,8 +47,6 @@ constexpr float COLOR_MODIFIER_RATE = 0.015f; // Room:TrySpawnSpecialQuestDoor forces the door. static int forcedItemPool = POOL_NONE; static bool isSpecialQuestDoorForced = false; -// Whether the camera keeps within the room (REPENTOGON's roomCameraData.Clamped). -static bool isCameraClamped = true; // Raises luaL_typeerror's argument error. static int type_error(lua_State* state, int index, const char* expected) @@ -136,6 +136,17 @@ static int backdrop_type_set(lua_State* state) return 0; } +// Room:ClearBossHazards: the room's shots, and the enemies keeping its doors shut unless asked to ignore them (the +// default), killed as from a source. +static int room_boss_hazards_clear(lua_State* state) +{ + lua_get(state, 1); + bool isIgnoreNpcs = lua_isnoneornil(state, 2) || lua_toboolean(state, 2); + auto* source = lua_type(state, 3) == LUA_TUSERDATA ? (Entity*)lua_object_test(state, 3, LUA_CLASS_ENTITY) : nullptr; + boss_hazards_clear(isIgnoreNpcs ? BOSS_HAZARDS_SHOTS : BOSS_HAZARDS_ALL, source); + return 0; +} + // Room:GetRail: a cell's rail piece, nil for none or a cell its layout does not allow. static int rail_get(lua_State* state) { @@ -446,7 +457,8 @@ void repentogon_room_register(lua_State* state) lua_method(state, "IsPersistentRoomEntity", [](Room&, int type, LuaDefault variant) { return room_entity_is_persistent(type, variant.value); }); - lua_method(state, "GetBackdropType", [](Room& room) { return room.backdrop.backdropId; }); + lua_method(state, "GetBackdropType", [](Room& room) { return backdrop_type_get(room.backdrop); }); + lua_functions_add(state, {{"ClearBossHazards", room_boss_hazards_clear}}); lua_method(state, "SaveState", [](Room& room) { room.on_leave(); }); lua_method(state, "GetBossVictoryJingle", [](Room& room) { return room.GetBossVictoryJingle(); }); diff --git a/src/repentogon/api_saves.cpp b/src/repentogon/api_saves.cpp index e595db9..5813deb 100644 --- a/src/repentogon/api_saves.cpp +++ b/src/repentogon/api_saves.cpp @@ -1,6 +1,7 @@ #include "game/game.h" #include "game/manager.h" #include "game/persistent_game_data.h" +#include "repentogon/achievements.h" #include "repentogon/api.h" #include "repentogon/api_level.h" #include "repentogon/callbacks.h" @@ -341,15 +342,18 @@ static int mod_challenge_completion_get(lua_State* state) return 1; } -// PersistentGameData:Unlock and TryUnlock: an achievement unlocked, Unlock even while the save is read only. +// PersistentGameData:Unlock and TryUnlock: an achievement unlocked, Unlock even while the save is read only, a mod's +// without its popup when the third argument is true. template static int achievement_unlock(lua_State* state) { PersistentGameData& data = lua_get(state, 1); int achievement = (int)luaL_checkinteger(state, 2); + if (lua_isboolean(state, 3) && lua_toboolean(state, 3)) achievementPopupSkipped = achievement; bool isReadOnly = std::exchange(data.isReadOnly, data.isReadOnly && !IsForced); bool isUnlocked = data.TryUnlock(achievement); data.isReadOnly = isReadOnly; + if (!isUnlocked) achievementPopupSkipped = -1; lua_pushboolean(state, isUnlocked); return 1; } @@ -447,5 +451,6 @@ void repentogon_isaac_saves_register(lua_State* state) {"SetChallengeCompletion", challenge_completion_set}, {"GetModChallengeCompletionData", mod_challenge_completion_get}}); lua_method(state, "MarkChallengeAsNotDone", [](int challenge) { challenge_completion_reset(challenge); }); + lua_method(state, "GetAchievementIdByName", [](std::string name) { return achievement_id_find(name); }); persistent_game_data_register(state); } diff --git a/src/repentogon/api_weapons.cpp b/src/repentogon/api_weapons.cpp index 7e624f3..a0160c8 100644 --- a/src/repentogon/api_weapons.cpp +++ b/src/repentogon/api_weapons.cpp @@ -139,8 +139,8 @@ static void hit_list_register(lua_State* state, std::vector T::*) } // MC_POST_FIRE_SPLIT_TEAR for a tear split from a tear, laser or knife, filtered by the split type (its name for a -// custom one). -static void split_tear_notify(Entity_Tear& tear, Entity& source, const SplitTear& split) +// custom one). Patches/ASMPatches/ASMSplitTears.cpp runs it at every split the game makes, once the tear is set up. +void split_tear_notify(Entity_Tear& tear, Entity& source, const SplitTear& split) { if (source.type != ENTITY_TEAR && source.type != ENTITY_LASER && source.type != ENTITY_KNIFE) return; diff --git a/src/repentogon/console.cpp b/src/repentogon/console.cpp new file mode 100644 index 0000000..cf76e56 --- /dev/null +++ b/src/repentogon/console.cpp @@ -0,0 +1,114 @@ +// REPENTOGON's console hooks (Patches/ConsoleHooks.cpp) and its debug drawing of entity queries +// (Patches/ExtraDebugRender.cpp), each only with vanilla parity off. +#include "repentogon/console.h" +#include "game/game.h" +#include "game/manager.h" +#include "repentogon/achievements.h" +#include "repentogon/api_game.h" +#include "repentogon/options.h" +#include "ui/console.h" +#include +#include +#include + +constexpr std::string_view REPENTOGON_GREETING = "REPENTOGON Console\n"; + +// giveeffect and removeeffect (ge and re): c for a collectible's effect, t for a trinket's, a bare id for a null +// item's. +static void effect_command_run(const std::vector& words, bool isGiven) +{ + Entity_Player* player = g_game->playerManager.GetPlayer(0); + if (words.size() < 2 || words[1].empty() || !player) return; + + char prefix = words[1].front(); + int id = std::atoi(words[1].c_str() + (std::isalpha((unsigned char)prefix) ? 1 : 0)); + TemporaryEffects& effects = player->temporaryEffects; + if (id <= 0) return; + if (prefix == 'c' && isGiven) effects.AddCollectibleEffect(id, true, 1); + else if (prefix == 'c') effects.RemoveCollectibleEffect(id, 1); + else if (prefix == 't' && isGiven) effects.AddTrinketEffect(id, true, 1); + else if (prefix == 't') effects.RemoveTrinketEffect(id, 1); + else if (isGiven) effects.AddNullEffect(id, true, 1); + else effects.RemoveNullEffect(id, 1); +} + +// help lists the commands, by name with what mods registered for theirs. help name prints a mod command's help text. +static void help_command_run(Console& console, const std::vector& words) +{ + std::vector names = command_names_get(); + std::string text; + + std::ranges::sort(names); + for (std::string_view name : names) + { + std::string description = console_description_get(name); + std::string line = " - " + std::string(name) + (description.empty() ? "" : " - " + description); + if (words.size() == 1) text += line + "\n"; + else if (name == words[1]) + { + text += std::string(name) + " - " + console_help_text_get(name) + "\n"; + break; + } + } + console.Print(text, CONSOLE_WHITE, CONSOLE_FADE_FRAMES); +} + +// (AchievementsStuff.cpp) achievement id unlocks one even while the save is read only, lockachievement id locks one. +static void achievement_command_run(Console& console, const std::vector& words, bool isLocked) +{ + PersistentGameData& data = g_manager->persistentGameData; + int id = words.size() > 1 ? std::atoi(words[1].c_str()) : 0; + if (id <= 0) return console.PrintError("No achievement Id Provided. \n"); + + bool isReadOnly = std::exchange(data.isReadOnly, false); + bool isChanged = isLocked ? achievement_lock(id) : data.TryUnlock(id); + data.isReadOnly = isReadOnly; + if (isChanged) console.Print(isLocked ? "Locked achievement. \n" : "Unlocked achievement. \n"); + else console.PrintError(isLocked ? "Achievement already locked." : "Achievement already unlocked. \n"); +} + +// The commands REPENTOGON adds or changes, run in place of the game's. Whether one ran. +bool is_console_hook_run(Console& console, const std::vector& words, Entity_Player*) +{ + if (repentogonOptions.isVanillaParity) return false; + + std::string_view name = words[0]; + if (name == "help") help_command_run(console, words); + else if (name == "achievement" || name == "lockachievement") + achievement_command_run(console, words, name == "lockachievement"); + else if (name == "giveeffect" || name == "ge" || name == "removeeffect" || name == "re") + effect_command_run(words, name == "giveeffect" || name == "ge"); + else return false; + return true; +} + +// The console's first line, which names REPENTOGON in place of Repentance+. +std::string_view console_greeting_get(std::string_view greeting) +{ + return repentogonOptions.isVanillaParity ? greeting : REPENTOGON_GREETING; +} + +// Whether entity queries draw their shape for a frame: REPENTOGON's RenderDebugFindInRadius with the hitspheres view. +static bool is_query_drawn() +{ + return !repentogonOptions.isVanillaParity && repentogonOptions.isRenderDebugFindInRadius && + (g_game->debugFlags & DEBUG_HITSPHERES); +} + +// Draws the circle an entity query searches for a frame. +void query_debug_render(const Vector& position, float radius) +{ + if (!is_query_drawn()) return; + Shape& shape = g_game->debugRenderer.Get(-1, true); + shape.timeout = 1; + shape.Circle(position, radius); +} + +// Draws the capsule an entity query searches for a frame. +void query_debug_render(const Capsule& capsule) +{ + if (!is_query_drawn()) return; + Shape& shape = g_game->debugRenderer.Get(-1, true); + shape.timeout = 1; + shape.Capsula(capsule); +} diff --git a/src/repentogon/console.h b/src/repentogon/console.h new file mode 100644 index 0000000..89a8e3a --- /dev/null +++ b/src/repentogon/console.h @@ -0,0 +1,15 @@ +#pragma once + +#include +#include +#include + +class Console; +struct Capsule; +struct Entity_Player; +struct Vector; + +bool is_console_hook_run(Console& console, const std::vector& words, Entity_Player* player); +std::string_view console_greeting_get(std::string_view greeting); +void query_debug_render(const Vector& position, float radius); +void query_debug_render(const Capsule& capsule); diff --git a/src/repentogon/custom_cache.cpp b/src/repentogon/custom_cache.cpp new file mode 100644 index 0000000..493fe32 --- /dev/null +++ b/src/repentogon/custom_cache.cpp @@ -0,0 +1,190 @@ +// REPENTOGON's custom caches (Patches/CustomCache.cpp): an item's customcache words evaluate through +// MC_EVALUATE_CUSTOM_CACHE as it is added or removed, or with its player's EvaluateItems. Six are the game's own +// numbers: the most coins, keys and bombs, the tears cap, the stat multiplier (Cracked Crown, Tainted Bethany) and the +// health type, and familiarmultiplier for MC_EVALUATE_FAMILIAR_MULTIPLIER, which the rebuild asks each time. +// A number only replaces the game's once a mod returned one. Without vanilla parity a lower most coins, keys or bombs +// also takes the excess away outside dailies. +#include "repentogon/custom_cache.h" +#include "entity/pickup/item_config.h" +#include "entity/player/player.h" +#include "game/game.h" +#include "repentogon/callbacks.h" +#include +#include +#include +#include + +constexpr const char* CACHE_FAMILIAR_MULTIPLIER = "familiarmultiplier"; +constexpr const char* CACHE_HEALTH_TYPE = "healthtype"; +constexpr const char* CACHE_TEARS_CAP = "tearscap"; +constexpr const char* CACHE_STAT_MULTIPLIER = "statmultiplier"; +constexpr std::array LIMIT_CACHES = {"maxcoins", "maxkeys", "maxbombs"}; +constexpr std::array LIMIT_CONSUMABLES = {CONSUMABLE_COINS, CONSUMABLE_KEYS, CONSUMABLE_BOMBS}; +constexpr int LIMIT_VANILLA = 99; +constexpr int LIMIT_DEEP_POCKETS = 999; +constexpr int LIMIT_DIGITS_MAX = 10; +constexpr double TEARS_CAP_VANILLA = 5; +constexpr double TEARS_CAP_FRAMES = 30; +constexpr float FIRE_DELAY_FLOOR = -0.75f; +constexpr int HUD_REFRESH_FRAMES = 2; +constexpr int TRINKET_CRACKED_CROWN = 92; +constexpr float CRACKED_CROWN_SCALE = 0.2f; +constexpr float TAINTED_BETHANY_SCALE = 0.75f; +constexpr uint32_t STAT_MULTIPLIER_CACHE = CACHE_DAMAGE | CACHE_FIREDELAY | CACHE_SHOTSPEED | CACHE_RANGE | CACHE_SPEED; + +static std::set knownCaches = {CACHE_FAMILIAR_MULTIPLIER, LIMIT_CACHES[LIMIT_COINS], + LIMIT_CACHES[LIMIT_KEYS], LIMIT_CACHES[LIMIT_BOMBS], CACHE_TEARS_CAP, + CACHE_STAT_MULTIPLIER}; +// The most of each consumable a mod's evaluation set, none while the game's own applies. +static std::array, LIMIT_COUNT> consumableLimits; + +void custom_caches_known_add(const std::set& caches) +{ + knownCaches.insert(caches.begin(), caches.end()); +} + +// What a custom cache starts from: the game's number for it. +static double cache_default_get(Entity_Player& player, const std::string& cache) +{ + if (cache == LIMIT_CACHES[LIMIT_COINS]) + return g_game->playerManager.FirstCollectibleOwner(COLLECTIBLE_DEEP_POCKETS, LAZARUS_SHARE_CHECK) + ? LIMIT_DEEP_POCKETS + : LIMIT_VANILLA; + if (cache == LIMIT_CACHES[LIMIT_KEYS] || cache == LIMIT_CACHES[LIMIT_BOMBS]) return LIMIT_VANILLA; + if (cache == CACHE_TEARS_CAP) return TEARS_CAP_VANILLA; + if (cache == CACHE_STAT_MULTIPLIER) + { + float scale = (float)player.GetTrinketMultiplier(TRINKET_CRACKED_CROWN) * CRACKED_CROWN_SCALE + 1; + return player.playerType == PLAYER_BETHANY_B ? scale * TAINTED_BETHANY_SCALE : scale; + } + if (cache != CACHE_HEALTH_TYPE) return 0; + + bool isEvaluating = std::exchange(player.isEvaluatingHealthType, true); + int previous = std::exchange(player.previousHealthType, -1); + double healthType = player.GetHealthType(); + player.isEvaluatingHealthType = isEvaluating; + player.previousHealthType = previous; + return healthType; +} + +// Sets the most of a consumable from the first player's evaluation, a mod's number or else the game's, and outside +// dailies takes away what is over it: always for a mod's, without vanilla parity for the game's. +static void consumable_limit_set(Entity_Player& player, ConsumableLimit kind, double limit, std::optional modded) +{ + int most = (int)std::clamp(modded.value_or(limit), 0.0, (double)INT_MAX); + if (modded) consumableLimits[kind] = most; + std::array counts = {&player.numCoins, &player.numKeys, &player.numBombs}; + bool isTrimmed = modded || !repentogonOptions.isVanillaParity; + if (isTrimmed && g_game->dailyChallenge.id == 0 && *counts[kind] > most) + { + *counts[kind] = most; + player.ConsumableCountChanged(LIMIT_CONSUMABLES[kind]); + } + if (!isTrimmed || g_game->hud.hudRefreshType == HUD_REFRESH_FULL) return; + g_game->hud.hudRefreshType = HUD_REFRESH_PLAYER; + g_game->hud.hudRefreshCountdown = HUD_REFRESH_FRAMES; +} + +// (RunEvaluateCustomCacheCallback) Evaluates one custom cache for a player, the most coins, keys and bombs for the +// first player only, and acts on a changed tears cap or stat multiplier. +static void cache_evaluate(Entity_Player& player, const std::string& cache) +{ + auto limit = std::ranges::find(LIMIT_CACHES, cache); + Entity_Player* evaluated = &player; + if (limit != LIMIT_CACHES.end()) + { + evaluated = g_game->GetPlayer(0); + if (!evaluated) return; + for (Entity_Player* other : g_game->playerManager.playerList) other->customCache.pending.erase(cache); + } + if (cache == CACHE_FAMILIAR_MULTIPLIER) return; + + CustomCacheState& state = evaluated->customCache; + double initial = cache_default_get(*evaluated, cache); + auto previous = state.results.find(cache); + double previousValue = previous == state.results.end() ? initial : previous->second; + std::optional value; + LuaEngine& engine = lua_engine_get(); + CallbackRun run = {"EvaluateCustomCache", MC_EVALUATE_CUSTOM_CACHE, std::nullopt}; + run.stringParam = cache.c_str(); + if (callback_run(engine, run, evaluated, cache.c_str(), initial)) + { + if (lua_isnumber(engine.state, -1)) value = lua_tonumber(engine.state, -1); + lua_pop(engine.state, 1); + } + if (value) state.results[cache] = *value; + + if (limit != LIMIT_CACHES.end()) + return consumable_limit_set(*evaluated, (ConsumableLimit)(limit - LIMIT_CACHES.begin()), initial, value); + if (cache == CACHE_HEALTH_TYPE) + { + evaluated->GetHealthType(); + return; + } + bool isStat = cache == CACHE_TEARS_CAP || cache == CACHE_STAT_MULTIPLIER; + if (!isStat || value.value_or(initial) == previousValue) return; + evaluated->cacheFlags |= cache == CACHE_TEARS_CAP ? CACHE_FIREDELAY : STAT_MULTIPLIER_CACHE; + state.isEvaluateItemsRequired = true; +} + +// (TriggerCustomCache) An item's custom caches evaluate now (then EvaluateItems when one asked for it), or with the +// player's next EvaluateItems. +void custom_cache_trigger(Entity_Player& player, ItemConfig_Item* item, CustomCacheTiming timing) +{ + if (!item || item->customCaches.empty()) return; + + CustomCacheState& state = player.customCache; + if (timing == CUSTOM_CACHE_NEXT_EVALUATE) + { + state.pending.insert(item->customCaches.begin(), item->customCaches.end()); + player.temporaryEffects.isEvaluateCachePending = true; + return; + } + for (const std::string& cache : item->customCaches) + { + state.pending.erase(cache); + cache_evaluate(player, cache); + } + if (std::exchange(state.isEvaluateItemsRequired, false)) player.EvaluateItems(); +} + +// (The EvaluateItems hook) Evaluates the player's pending custom caches before its items, every known one for a full +// evaluation. +void custom_caches_evaluate(Entity_Player& player) +{ + CustomCacheState& state = player.customCache; + if ((player.cacheFlags & CACHE_ALL) == CACHE_ALL) state.pending.insert(knownCaches.begin(), knownCaches.end()); + std::set> caches = std::exchange(state.pending, {}); + for (const std::string& cache : caches) cache_evaluate(player, cache); + state.isEvaluateItemsRequired = false; +} + +// The most of a consumable: a mod's, else the game's. +int consumable_limit_get(ConsumableLimit kind, int vanilla) +{ + return consumableLimits[kind].value_or(vanilla); +} + +// The format the HUD shows a consumable's count in: with as many digits as its most has once a mod set it. +std::string consumable_format_get(ConsumableLimit kind, const char* vanilla) +{ + if (!consumableLimits[kind]) return vanilla; + int most = *consumableLimits[kind]; + int digits = most < 1 ? 1 : std::min((int)std::floor(std::log10(most)) + 1, LIMIT_DIGITS_MAX); + return "%0" + std::to_string(digits) + "d"; +} + +// (TearsCapHook) The least fire delay: from a mod's tears cap, else the game's. +float tears_cap_get(Entity_Player& player, float vanilla) +{ + auto cap = player.customCache.results.find(CACHE_TEARS_CAP); + if (cap == player.customCache.results.end() || cap->second <= 0) return vanilla; + return (float)std::max(TEARS_CAP_FRAMES / cap->second - 1, (double)FIRE_DELAY_FLOOR); +} + +// (StatMultiplierHook) The stat multiplier: a mod's, else the game's. +float stat_multiplier_get(Entity_Player& player, float vanilla) +{ + auto multiplier = player.customCache.results.find(CACHE_STAT_MULTIPLIER); + return multiplier != player.customCache.results.end() && multiplier->second > 0 ? (float)multiplier->second : vanilla; +} diff --git a/src/repentogon/custom_cache.h b/src/repentogon/custom_cache.h new file mode 100644 index 0000000..eaa5057 --- /dev/null +++ b/src/repentogon/custom_cache.h @@ -0,0 +1,41 @@ +#pragma once + +#include +#include +#include + +struct Entity_Player; +struct ItemConfig_Item; + +// A player's custom caches (EntityPlayerPlus's customCacheTags and customCacheResults): those its next EvaluateItems +// evaluates, and what a mod's MC_EVALUATE_CUSTOM_CACHE made of each. +struct CustomCacheState +{ + std::map> results; + std::set> pending; + bool isEvaluateItemsRequired = false; +}; + +// When an item's custom caches evaluate: at once, or with the player's next EvaluateItems. +enum CustomCacheTiming +{ + CUSTOM_CACHE_NOW, + CUSTOM_CACHE_NEXT_EVALUATE +}; + +// The consumables whose most a maxcoins, maxkeys or maxbombs custom cache sets. +enum ConsumableLimit +{ + LIMIT_COINS, + LIMIT_KEYS, + LIMIT_BOMBS, + LIMIT_COUNT +}; + +void custom_caches_known_add(const std::set& caches); +void custom_cache_trigger(Entity_Player& player, ItemConfig_Item* item, CustomCacheTiming timing); +void custom_caches_evaluate(Entity_Player& player); +int consumable_limit_get(ConsumableLimit kind, int vanilla); +std::string consumable_format_get(ConsumableLimit kind, const char* vanilla); +float tears_cap_get(Entity_Player& player, float vanilla); +float stat_multiplier_get(Entity_Player& player, float vanilla); diff --git a/src/repentogon/custom_imgui.cpp b/src/repentogon/custom_imgui.cpp new file mode 100644 index 0000000..0f58729 --- /dev/null +++ b/src/repentogon/custom_imgui.cpp @@ -0,0 +1,149 @@ +// REPENTOGON's CustomImGui (ImGuiFeatures/CustomImGui.h): the element tree behind its ImGui Lua API. +#include "repentogon/custom_imgui.h" +#include "game/game.h" +#include + +CustomImGui customImGui; + +// A window's visibility from its trigger or SetVisible. A window that stayed put while its shown state changed was +// closed with its (X), which then sticks. +void CustomElement::visible_evaluate() +{ + bool isShown = (triggerElement && triggerElement->isActive) || isUserVisible; + if (isLastEvaluatedVisible == isShown && isShown != isEvaluatedVisible) + { + visible_set(isEvaluatedVisible); + isShown = isEvaluatedVisible; + } + isEvaluatedVisible = isLastEvaluatedVisible = isShown; +} + +// Shows or hides an element through its trigger when it has one. +void CustomElement::visible_set(bool isShown) +{ + if (triggerElement) triggerElement->isActive = isShown; + else isUserVisible = isShown; +} + +// The first element with an id in a list, depth first. Elements without an id and removed ones are never found. +static CustomElement* list_find(std::list& list, std::string_view id) +{ + for (CustomElement& element : list) + { + if (element.isRemoved) continue; + if (element.id == id && !id.empty()) return &element; + if (CustomElement* child = list_find(element.children, id)) return child; + } + return nullptr; +} + +// An element by id, in the menus first. +CustomElement* CustomImGui::element_find(std::string_view id) +{ + CustomElement* element = list_find(menus, id); + return element ? element : list_find(windows, id); +} + +// Adds an element under a parent. +CustomElement* CustomImGui::element_add(CustomElement& parent, std::string_view id, std::string_view name, int type) +{ + CustomElement& element = parent.children.emplace_back(); + element.id = id; + element.name = name; + element.type = (CustomElementType)type; + element.parent = &parent; + return &element; +} + +// Whether an element lies in the tree under root, root included. +static bool is_within(CustomElement* element, CustomElement& root) +{ + if (element == &root) return true; + return std::ranges::any_of(root.children, [&](CustomElement& child) { return is_within(element, child); }); +} + +// Unlinks every trigger pointing into a tree about to go. +static void links_clear(std::list& list, CustomElement& erased) +{ + for (CustomElement& element : list) + { + if (element.triggerElement && is_within(element.triggerElement, erased)) element.triggerElement = nullptr; + if (element.triggerPopup && is_within(element.triggerPopup, erased)) element.triggerPopup = nullptr; + links_clear(element.children, erased); + } +} + +// Drops an element, only marking it while the elements draw. +void CustomImGui::element_erase(std::list& list, std::list::iterator element) +{ + if (isDrawing) + { + element->isRemoved = true; + return; + } + links_clear(menus, *element); + links_clear(windows, *element); + list.erase(element); +} + +// RemoveElement: a top menu goes with every other of its id, a top window alone, anything else from its parent. +// Whether one was found, else an error in the console. +bool CustomImGui::element_remove(std::string_view id) +{ + CustomElement* element = element_find(id); + auto erase_first = [&](std::list& list) { + auto found = std::ranges::find_if(list, [&](CustomElement& e) { return !e.isRemoved && e.id == id; }); + if (found == list.end()) return false; + element_erase(list, found); + return true; + }; + + bool isMenu = element && element->type == CUSTOM_MENU; + bool isTopWindow = element && element->type == CUSTOM_WINDOW && !element->parent; + if (isMenu) + while (erase_first(menus)); + else if (isTopWindow) erase_first(windows); + else if (element && element->parent && erase_first(element->parent->children)) return true; + if (isMenu || isTopWindow) return true; + + std::string error = element ? "Couldnt find the element to remove! (" : "Couldn't find the element to remove! ("; + g_game->console.PrintError(error + std::string(id) + ") \n"); + return false; +} + +// Drops the elements removed while they drew. +void CustomImGui::elements_sweep() +{ + auto sweep = [&](auto& self, std::list& list) -> void { + for (auto element = list.begin(); element != list.end();) + { + auto next = std::next(element); + if (element->isRemoved) element_erase(list, element); + else self(self, element->children); + element = next; + } + }; + sweep(sweep, menus); + sweep(sweep, windows); +} + +// Evaluates the windows' visibility, as each frame does. +void CustomImGui::windows_evaluate() +{ + for (CustomElement& window : windows) window.visible_evaluate(); +} + +// ImGui.Reset: drops every menu and window. +void CustomImGui::reset() +{ + for (auto* list : {&menus, &windows}) + for (auto element = list->begin(); element != list->end();) element_erase(*list, element++); +} + +// Whether anything draws while the overlay is hidden: a pinned window that is open, or a notification. +bool CustomImGui::is_shown_hidden() +{ + return !notifications.empty() || std::ranges::any_of(windows, [](CustomElement& window) { + return !window.isRemoved && window.isWindowPinned && window.isEvaluatedVisible; + }); +} diff --git a/src/repentogon/custom_imgui.h b/src/repentogon/custom_imgui.h new file mode 100644 index 0000000..d54eb0d --- /dev/null +++ b/src/repentogon/custom_imgui.h @@ -0,0 +1,194 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +// What an element draws as (ImGuiElement, CustomImGui.h's IMGUI_ELEMENT). +enum CustomElementType : int +{ + CUSTOM_WINDOW, + CUSTOM_MENU, + CUSTOM_MENU_ITEM, + CUSTOM_POPUP, + CUSTOM_COLLAPSING_HEADER, + CUSTOM_TREE_NODE, + CUSTOM_SEPARATOR, + CUSTOM_SEPARATOR_TEXT, + CUSTOM_TEXT, + CUSTOM_TEXT_WRAPPED, + CUSTOM_BULLET_TEXT, + CUSTOM_SAME_LINE, + CUSTOM_BUTTON, + CUSTOM_SMALL_BUTTON, + CUSTOM_INPUT_INT, + CUSTOM_INPUT_FLOAT, + CUSTOM_DRAG_INT, + CUSTOM_DRAG_FLOAT, + CUSTOM_SLIDER_INT, + CUSTOM_SLIDER_FLOAT, + CUSTOM_COLOR_EDIT, + CUSTOM_TAB_BAR, + CUSTOM_TAB, + CUSTOM_CHECKBOX, + CUSTOM_RADIO_BUTTON, + CUSTOM_COMBOBOX, + CUSTOM_INPUT_TEXT, + CUSTOM_INPUT_TEXT_WITH_HINT, + CUSTOM_INPUT_TEXT_MULTILINE, + CUSTOM_INPUT_CONTROLLER, + CUSTOM_INPUT_KEYBOARD, + CUSTOM_PLOT_LINES, + CUSTOM_PLOT_HISTOGRAM, + CUSTOM_PROGRESS_BAR +}; + +// When an element's Lua function runs (ImGuiCallback). +enum CustomCallback : int +{ + CUSTOM_CLICKED, + CUSTOM_HOVERED, + CUSTOM_ACTIVE, + CUSTOM_FOCUSED, + CUSTOM_VISIBLE, + CUSTOM_EDITED, + CUSTOM_ACTIVATED, + CUSTOM_DEACTIVATED, + CUSTOM_DEACTIVATED_AFTER_EDIT, + CUSTOM_TOGGLED_OPEN, + CUSTOM_RENDER, + CUSTOM_CALLBACK_COUNT +}; + +// Which of an element's data ImGui.UpdateData changes (ImGuiData). +enum CustomData : int +{ + CUSTOM_DATA_LABEL, + CUSTOM_DATA_VALUE, + CUSTOM_DATA_LIST_VALUES, + CUSTOM_DATA_MIN, + CUSTOM_DATA_MAX, + CUSTOM_DATA_HINT_TEXT, + CUSTOM_DATA_COLOR_VALUES +}; + +// How bad a notification is (ImGuiNotificationType), which picks its icon and color. +enum NotificationSeverity : int +{ + NOTIFICATION_INFO, + NOTIFICATION_SUCCESS, + NOTIFICATION_WARNING, + NOTIFICATION_ERROR, + NOTIFICATION_SEVERITY_COUNT +}; + +constexpr int CHILD_FLAGS_BORDERS = 1; +// ImGuiColor.Text, which SetTextColor sets. +constexpr int CUSTOM_COLOR_TEXT = 0; +constexpr int NOTIFICATION_LIFETIME = 5000; +constexpr float INPUT_LINES = 6; +constexpr float INPUT_STEP_FAST = 100; +constexpr const char* FLOAT_FORMAT = "%.3f"; +constexpr const char* INT_FORMAT = "%d%"; +// The overlay text a progress bar shows when no hint was given: its percentage. +constexpr const char* PROGRESS_DEFAULT = "__DEFAULT__"; + +// A style color an element pushes while it draws: REPENTOGON's ImGuiColor, red, green, blue and alpha. +struct CustomColor +{ + float rgba[4]; + int type; +}; + +// One element of a mod's windows and menus (CustomImGui.h's Element, its Data, ElementData and ColorData in one). +// A window opens with the element it is linked to (triggerElement) or with SetVisible. +// isRemoved hides one removed while the elements draw, until they are done. +struct CustomElement +{ + std::list children; + std::vector colors; + std::vector plotValues; + std::vector values; + std::map callbacks; + std::string formatting = FLOAT_FORMAT; + std::string helpmarkerText; + std::string hintText; + std::string id; + std::string inputText; + std::string name; + std::string tooltipText; + CustomElement* parent = nullptr; + CustomElement* triggerElement = nullptr; + CustomElement* triggerPopup = nullptr; + CustomElementType type = CUSTOM_WINDOW; + float rgba[4] = {0, 0, 0, 1}; + float currentFloatVal = 0; + float lineCount = INPUT_LINES; + float maxVal = FLT_MAX; + float minVal = FLT_MIN; + float positionX = 0; + float positionY = 0; + float sizeX = 0; + float sizeY = 0; + float speed = 1; + float step = 1; + float stepFast = INPUT_STEP_FAST; + int childFlags = CHILD_FLAGS_BORDERS; + int clickCounter = 0; + int currentIntVal = 0; + int index = 0; + int windowFlags = 0; + bool isActive = false; + bool isChecked = false; + bool isColorAlpha = false; + bool isEvaluatedVisible = false; + bool isLastEvaluatedVisible = false; + bool isPositionRequested = false; + bool isRemoved = false; + bool isSameLine = true; + bool isSizeRequested = false; + bool isSlider = false; + bool isUserVisible = false; + bool isWindowPinned = false; + + void visible_evaluate(); + void visible_set(bool isShown); +}; + +// A message ImGui.PushNotification shows at the top of the screen until its time runs out. +struct CustomNotification +{ + std::string text; + uint64_t deletionTime = 0; + NotificationSeverity severity = NOTIFICATION_INFO; +}; + +// REPENTOGON's CustomImGui: the menus and windows mods build through the ImGui global, and their notifications. +// The overlay draws them (ui/overlay/custom_imgui.cpp). Without a mod using it, there is nothing to draw. +// While the elements draw (isDrawing), a removed element is only marked, and dropped once the drawing is done. +class CustomImGui +{ +public: + std::list menus; + std::list windows; + std::deque notifications; + bool isDrawing = false; + + CustomElement* element_find(std::string_view id); + CustomElement* element_add(CustomElement& parent, std::string_view id, std::string_view name, int type); + bool element_remove(std::string_view id); + void elements_sweep(); + void windows_evaluate(); + void reset(); + bool is_shown_hidden(); + +private: + void element_erase(std::list& list, std::list::iterator element); +}; + +extern CustomImGui customImGui; diff --git a/src/repentogon/entities.cpp b/src/repentogon/entities.cpp index ac8d561..1092b2e 100644 --- a/src/repentogon/entities.cpp +++ b/src/repentogon/entities.cpp @@ -1,7 +1,12 @@ #include "repentogon/entities.h" +#include "entity/config.h" +#include "entity/npc/npc.h" +#include "entity/pickup/pickup.h" #include "entity/player/player.h" +#include "game/manager.h" #include "repentogon/callbacks.h" #include +#include constexpr int FIRE_DAMAGE_COOLDOWN = 10; constexpr int WHITE_FIREPLACE_VARIANT = 4; @@ -54,8 +59,28 @@ static bool damage_table_read(lua_State* state, Entity& entity, DamageHit& hit) return true; } +// The extra sources of the hits being dealt, by their source. +static std::map extraSources; + +ExtraDamageSource::ExtraDamageSource(const EntityRef& source, Entity* extra) : source(&source) +{ + extraSources.insert_or_assign(&source, EntityRef(extra)); +} + +ExtraDamageSource::~ExtraDamageSource() +{ + extraSources.erase(source); +} + +// A hit's ExtraSource: what dealt it for its source, when that is another entity, else null. +static EntityRef* extra_source_get(const EntityRef& source) +{ + auto found = extraSources.find(&source); + return found != extraSources.end() && found->second.entity != source.entity ? &found->second : nullptr; +} + // REPENTOGON's MC_ENTITY_TAKE_DMG, filtered by the entity's type: a player's hit passes its hearts as the damage, and -// an ExtraSource follows the countdown (nil until the damage dealers pass theirs). A boolean decides the hit, a table +// the ExtraSource follows the countdown (nil for most hits). A boolean decides the hit, a table // changes it. Whether the hit lands. static bool damage_callback_run(Entity& entity, DamageHit& hit) { @@ -64,7 +89,7 @@ static bool damage_callback_run(Entity& entity, DamageHit& hit) CallbackRun run = {"PreEntityTakeDamage", MC_ENTITY_TAKE_DMG, entity.type}; auto damage_run = [&](auto damage) { return callback_run(engine, run, &entity, damage, hit.damageFlags, &hit.source, hit.countdown, - (EntityRef*)nullptr); + extra_source_get(hit.source)); }; if (!(hit.hearts ? damage_run(*hit.hearts) : damage_run(hit.damage))) return true; @@ -101,7 +126,7 @@ bool entity_damage_pre(Entity& entity, DamageHit hit) void entity_damage_post(Entity& entity, DamageHit hit) { callback_notify(lua_engine_get(), {"MC_POST_ENTITY_TAKE_DMG", MC_POST_ENTITY_TAKE_DMG, entity.type}, &entity, - hit.damage, hit.damageFlags, &hit.source, hit.countdown, (EntityRef*)nullptr); + hit.damage, hit.damageFlags, &hit.source, hit.countdown, extra_source_get(hit.source)); } // Runs Entity_Player::TakeDamage and after it MC_POST_ENTITY_TAKE_DMG when it hurt, but for the white fireplace's hit, @@ -121,7 +146,7 @@ std::optional player_damage_hook(Entity_Player& player, DamageHit hit) callback_notify(lua_engine_get(), {"MC_POST_ENTITY_TAKE_DMG", MC_POST_ENTITY_TAKE_DMG, player.type}, (Entity*)&player, (int)std::round(settled.damage), settled.damageFlags, &hit.source, settled.countdown, - (EntityRef*)nullptr); + extra_source_get(hit.source)); return isHurt; } @@ -184,3 +209,66 @@ bool entity_color_hook(Entity& entity, const ColorParams& params) if (color_run({"MC_POST_ENTITY_SET_COLOR", MC_POST_ENTITY_SET_COLOR, entity.type})) lua_pop(state, 1); return true; } + +// (EntityConfigEx's HasCustomTag) Whether the config of a kind holds a custom tag. +bool is_custom_tagged(int type, int variant, int subtype, const char* tag) +{ + EntityConfig_Entity* config = g_manager->entityConfig.GetEntity(type, variant, subtype); + return config && config->customTags.contains(tag); +} + +bool is_custom_tagged(Entity& entity, const char* tag) +{ + return entity.config && entity.config->customTags.contains(tag); +} + +// (Patches/FamiliarTags.cpp) Whether a laser hurts a familiar: always with the familiarcantakedamage tag, else as its +// deprecated familiarallowlasercollision attribute says, else as the game decides. +bool familiar_laser_hit_get(Entity& familiar, bool isHit) +{ + if (!familiar.config) return isHit; + if (familiar.config->customTags.contains(CUSTOM_TAG_CAN_TAKE_DAMAGE)) return true; + return familiar.config->isLaserHit.value_or(isHit); +} + +// (GetCoinValue.cpp) What a coin is worth before mods' callbacks: the game's coins as the game says, a mod's coin +// what its entities2.xml says (1 without coinvalue). Without vanilla parity a coin of no known kind is worth 1 too, +// where the game reads past its table. +int coin_value_get(Entity_Pickup& coin, int worth) +{ + if (coin.subtype >= COIN_PENNY && coin.subtype <= COIN_GOLDEN) return worth; + + EntityConfig_Entity* config = g_manager->entityConfig.GetEntity(ENTITY_PICKUP, PICKUP_COIN, coin.subtype); + bool isModCoin = config && config->variant == PICKUP_COIN && config->subtype == coin.subtype; + if (!isModCoin && repentogonOptions.isVanillaParity) return worth; + return config ? config->coinValue : 1; +} + +// (ASMBagOfCrafting.cpp's CanPickupBePickedUp) Whether a swing or the boomerang takes a pickup: as its entities2.xml +// meleecollide or boomerang says when it says, the bag's swing always taking one with bag pickups, else as the game. +bool pickup_grab_check(Entity_Pickup& pickup, PickupGrabber grab, bool isIgnorePrice) +{ + EntityConfig_Entity* config = pickup.config; + if (!config) return pickup.CanBePickedUp(isIgnorePrice); + + std::optional isGrabbed = grab == PICKUP_GRABBER_BOOMERANG ? config->isBoomerangGrab : config->isMeleeCollide; + std::vector& bag = config->bagOfCraftingPickups; + if (grab == PICKUP_GRABBER_BAG && !bag.empty() && bag.front() > 0) isGrabbed = true; + if (isGrabbed) return *isGrabbed && (isIgnorePrice || pickup.price == 0); + return pickup.CanBePickedUp(isIgnorePrice); +} + +// (ASMEntityNPC.cpp's Entity::IsActiveEnemy hook) An enemy's entities2.xml isactiveenemy, when it gives one. +std::optional active_enemy_override(Entity& entity) +{ + bool isEnemy = entity.type >= ENTITY_FIRST_ENEMY && entity.type < ENTITY_EFFECT; + return isEnemy && entity.config ? entity.config->isActiveEnemy : std::nullopt; +} + +// (ASMCallbacks.cpp's TrySplit patch) Whether Meat Cleaver only hurts an enemy: a mod's MC_PRE_NPC_SPLIT says, else +// its entities2.xml nosplit, else the game. +bool npc_split_blocked_check(Entity_NPC& npc, bool isBlocked) +{ + bool fallback = npc.config && npc.config->isNoSplit ? *npc.config->isNoSplit : isBlocked; + return boolean_run({"PreNPCSplit", MC_PRE_NPC_SPLIT, (int)npc.type}, fallback, &npc, isBlocked); +} diff --git a/src/repentogon/entities.h b/src/repentogon/entities.h index 2725bbc..41a03ff 100644 --- a/src/repentogon/entities.h +++ b/src/repentogon/entities.h @@ -5,6 +5,8 @@ #include struct Entity; +struct Entity_NPC; +struct Entity_Pickup; struct Entity_Player; struct ColorParams; struct EntityRef; @@ -23,6 +25,31 @@ struct DamageHit uint64_t& damageFlags; }; +// What grabs a pickup: a melee swing, the bag of crafting's swing or the boomerang. +enum PickupGrabber +{ + PICKUP_GRABBER_SWING, + PICKUP_GRABBER_BAG, + PICKUP_GRABBER_BOOMERANG +}; + +// A hit's source standing in for the laser, swing, cord or ball that dealt it (ASMCallbacks.cpp's +// TakeDamageWithExtraSource): while it lives, MC_ENTITY_TAKE_DMG passes that entity as the ExtraSource of hits from it. +struct ExtraDamageSource +{ + const EntityRef* source; + + ExtraDamageSource(const EntityRef& source, Entity* extra); + ~ExtraDamageSource(); +}; + +bool is_custom_tagged(int type, int variant, int subtype, const char* tag); +bool is_custom_tagged(Entity& entity, const char* tag); +bool familiar_laser_hit_get(Entity& familiar, bool isHit); +int coin_value_get(Entity_Pickup& coin, int worth); +bool pickup_grab_check(Entity_Pickup& pickup, PickupGrabber grab, bool isIgnorePrice); +std::optional active_enemy_override(Entity& entity); +bool npc_split_blocked_check(Entity_NPC& npc, bool isBlocked); bool entity_damage_pre(Entity& entity, DamageHit hit); void entity_damage_post(Entity& entity, DamageHit hit); std::optional player_damage_hook(Entity_Player& player, DamageHit hit); diff --git a/src/repentogon/item_spoof.cpp b/src/repentogon/item_spoof.cpp new file mode 100644 index 0000000..70040e2 --- /dev/null +++ b/src/repentogon/item_spoof.cpp @@ -0,0 +1,608 @@ +#include "repentogon/item_spoof.h" +#include "entity/player/player.h" +#include "game/manager.h" +#include "repentogon/api.h" +#include "repentogon/callbacks.h" +#include "repentogon/items.h" +#include +#include + +// What the next spoofed call was asked from (ItemSpoofCallContext): from Lua, which sees reworked items, and whether +// it skips the spoofs. +struct SpoofContext +{ + bool isIgnoreSpoof = false; + bool isLuaRequest = false; +}; + +static SpoofContext spoofContext; +static bool isSpoofInner = false; +static std::set reworkedBirthrights; + +static ItemSpoof& spoof_get(Entity_Player& player, SpoofKind kind) +{ + return kind == SPOOF_TRINKET ? player.itemSpoofs.trinkets : player.itemSpoofs.collectibles; +} + +// SanitizeID: a trinket keeps only its id and golden flag, and only its id in the blocklist. +static int spoof_id_get(SpoofKind kind, int id, bool isBlocklist) +{ + if (kind == SPOOF_COLLECTIBLE) return id; + return isBlocklist ? id & (int)TRINKET_ID_MASK : id & (int)(TRINKET_ID_MASK | TRINKET_GOLDEN_FLAG); +} + +static int group_count_get(const InnateGroup& group, int id) +{ + auto found = group.persistent.find(id); + int count = found == group.persistent.end() ? 0 : found->second; + for (const TemporaryInnate& item : group.temporary) + if (item.id == id) count += item.count; + return count; +} + +static int innate_count_get(ItemSpoof& spoof, int id) +{ + int count = 0; + for (auto& [key, group] : spoof.innates) count += group_count_get(group, id); + return count; +} + +// The innate copies a character's players.xml gives it. +static int character_innate_get(int playerType, SpoofKind kind, int id) +{ + EntityConfig_Player* config = g_manager->entityConfig.GetPlayer(playerType); + if (!config) return 0; + + std::map& innates = kind == SPOOF_TRINKET ? config->ex.innateTrinkets : config->ex.innateCollectibles; + auto found = innates.find(id); + return found == innates.end() ? 0 : found->second; +} + +static ItemConfig_Item* spoof_item_get(SpoofKind kind, int id) +{ + ItemConfig& items = g_manager->itemConfig; + return kind == SPOOF_TRINKET ? items.GetTrinket(id & (int)TRINKET_ID_MASK) : items.GetCollectible(id); +} + +static bool is_spoof_player_having(Entity_Player& player, SpoofKind kind, int id) +{ + return kind == SPOOF_TRINKET ? player.HasTrinket((uint32_t)id) : player.HasCollectible(id); +} + +static SpoofContext context_take() +{ + return std::exchange(spoofContext, {}); +} + +// ItemSpoof::TriggerAdded: an innate item's costume, then its trinket triggers or its caches and MC_POST_TRIGGER_ +// COLLECTIBLE_ADDED as an innate one, after the fixes REPENTOGON makes for Mars and Book of Virtues. +static void spoof_added_trigger(Entity_Player& player, SpoofKind kind, int id, int amount, bool isAddCostume) +{ + ItemConfig_Item* item = spoof_item_get(kind, id); + if (!item) return; + + if (isAddCostume && item->isAddCostumeOnPickup) player.AddCostume(item, false); + if (kind == SPOOF_TRINKET) + { + for (int i = 0; i < amount; i++) player.TriggerTrinketAdded((uint32_t)id, false); + return; + } + + player.AddCacheFlags(item->cacheFlags); + if (id == COLLECTIBLE_MARS) + { + player.marsCooldown = 0; + player.marsDashDirection = -1; + player.isMarsDashReady = true; + } + else if (id == COLLECTIBLE_BOOK_OF_VIRTUES) player.UpdateBookOfVirtues(true); + collectible_added_post(player, id, false, true); +} + +// ItemSpoof::TriggerRemoved: off goes the costume the player has no other copy for, and the trinket triggers or the +// caches and TriggerCollectibleRemoved as for a wisp. +static void spoof_removed_trigger(Entity_Player& player, SpoofKind kind, int id, int amount) +{ + ItemConfig_Item* item = spoof_item_get(kind, id); + if (!item) return; + + if (item->isAddCostumeOnPickup && !is_spoof_player_having(player, kind, id)) player.RemoveCostume(item); + if (kind == SPOOF_TRINKET) + { + for (int i = 0; i < amount; i++) player.TriggerTrinketRemoved((uint32_t)id); + return; + } + player.AddCacheFlags(item->cacheFlags); + collectibleRemoval = REMOVAL_KIND_WISP; + player.TriggerCollectibleRemoved(id); +} + +// Runs a callback filtered by an id and a group key through _RunCallbackWithTwoParams, its result ignored. +template +static void key_callback_notify(const char* name, int callback, int id, std::string_view key, Args... args) +{ + LuaEngine& engine = lua_engine_get(); + if (!engine.is_callback_enabled(callback)) return; + + lua_State* state = engine.state; + lua_rawgeti(state, LUA_REGISTRYINDEX, engine.runCallbackTwoParamsRef); + lua_pushinteger(state, callback); + lua_pushinteger(state, id); + lua_pushlstring(state, key.data(), key.size()); + (lua_push(state, args), ...); + if (lua_pcall(state, sizeof...(Args) + 3, 1, 0) != LUA_OK) return lua_error_log(state, name); + lua_pop(state, 1); +} + +// MC_POST_ADD_INNATE_COLLECTIBLE or TRINKET, filtered by the id and the group. +static void spoof_added_post(Entity_Player& player, SpoofKind kind, std::string_view key, int id, int amount, + int duration) +{ + int callback = kind == SPOOF_TRINKET ? MC_POST_ADD_INNATE_TRINKET : MC_POST_ADD_INNATE_COLLECTIBLE; + key_callback_notify("PostAddInnateItem", callback, id, key, &player, id, key, amount, duration); +} + +// MC_POST_REMOVE_INNATE_COLLECTIBLE or TRINKET, filtered by the id and the group. +static void spoof_removed_post(Entity_Player& player, SpoofKind kind, std::string_view key, int id, int amount, + bool isExpired) +{ + int callback = kind == SPOOF_TRINKET ? MC_POST_REMOVE_INNATE_TRINKET : MC_POST_REMOVE_INNATE_COLLECTIBLE; + key_callback_notify("PostRemoveInnateItem", callback, id, key, &player, id, key, amount, isExpired); +} + +// InnateItems::Remove: copies for a while first, oldest first, then copies for good. How many went. +static int group_remove(InnateGroup& group, int id, int amount) +{ + int removed = 0; + for (TemporaryInnate& item : group.temporary) + { + if (item.id != id || removed >= amount) continue; + int taken = std::min(item.count, amount - removed); + item.count -= taken; + removed += taken; + } + std::erase_if(group.temporary, [](const TemporaryInnate& item) { return item.count <= 0; }); + + auto found = group.persistent.find(id); + if (found == group.persistent.end() || removed >= amount) return removed; + int taken = std::min(found->second, amount - removed); + if ((found->second -= taken) <= 0) group.persistent.erase(found); + return removed + taken; +} + +static bool is_group_empty(const InnateGroup& group) +{ + return group.persistent.empty() && group.temporary.empty(); +} + +// ItemSpoof::AddInnate: copies of a valid item into a group, for good or for duration frames. +static void innate_add(Entity_Player& player, SpoofKind kind, int id, int amount, std::string_view key, int duration, + bool isAddCostume) +{ + id = spoof_id_get(kind, id, false); + if (amount <= 0 || !spoof_item_get(kind, id)) return; + + InnateGroup& group = spoof_get(player, kind).innates[std::string(key)]; + if (duration > 0) group.temporary.push_back({amount, id, duration}); + else group.persistent[id] += amount; + spoof_added_trigger(player, kind, id, amount, isAddCostume); + player.EvaluateItems(); + spoof_added_post(player, kind, key, id, amount, duration); +} + +// ItemSpoof::RemoveInnate: up to amount copies out of a group. The legacy removal only reevaluates the caches. How +// many went. +static int innate_remove(Entity_Player& player, SpoofKind kind, int id, int amount, std::string_view key, + bool isLegacy) +{ + id = spoof_id_get(kind, id, false); + if (amount <= 0 || !spoof_item_get(kind, id)) return 0; + + ItemSpoof& spoof = spoof_get(player, kind); + InnateGroup& group = spoof.innates[std::string(key)]; + int removed = group_remove(group, id, amount); + if (is_group_empty(group)) spoof.innates.erase(std::string(key)); + if (removed <= 0) return 0; + + if (isLegacy) + { + if (ItemConfig_Item* item = spoof_item_get(kind, id)) player.AddCacheFlags(item->cacheFlags); + } + else spoof_removed_trigger(player, kind, id, removed); + player.EvaluateItems(); + spoof_removed_post(player, kind, key, id, removed, false); + return removed; +} + +static int group_count_find(ItemSpoof& spoof, std::string_view key, int id) +{ + auto group = spoof.innates.find(key); + return group == spoof.innates.end() ? 0 : group_count_get(group->second, id); +} + +// ItemSpoof::SetInnateCount: adds or removes copies in a group until it holds newCount. The change. +static int innate_count_set(Entity_Player& player, SpoofKind kind, int id, int newCount, std::string_view key, + bool isAddCostume) +{ + id = spoof_id_get(kind, id, false); + int change = std::max(newCount, 0) - group_count_find(spoof_get(player, kind), key, id); + if (change > 0) innate_add(player, kind, id, change, key, -1, isAddCostume); + else if (change < 0) return -innate_remove(player, kind, id, -change, key, false); + return change; +} + +// A group's copies by id, both kinds summed. +static std::map group_counts_get(ItemSpoof& spoof, std::string_view key) +{ + std::map counts; + auto group = spoof.innates.find(key); + if (group == spoof.innates.end()) return counts; + + counts = group->second.persistent; + for (TemporaryInnate& item : group->second.temporary) counts[item.id] += item.count; + return counts; +} + +// Triggers the removals of copies that left, evaluates once, then runs their callbacks by group. +static void removals_finish(Entity_Player& player, SpoofKind kind, std::map>& removed, + bool isExpired) +{ + std::map combined; + for (auto& [key, items] : removed) + for (auto [id, amount] : items) combined[id] += amount; + if (combined.empty()) return; + + for (auto [id, amount] : combined) spoof_removed_trigger(player, kind, id, amount); + player.EvaluateItems(); + for (auto& [key, items] : removed) + for (auto [id, amount] : items) spoof_removed_post(player, kind, key, id, amount, isExpired); +} + +// ItemSpoof::ClearItemGroup: every copy of a group gone. +static void group_clear(Entity_Player& player, SpoofKind kind, std::string_view key) +{ + ItemSpoof& spoof = spoof_get(player, kind); + std::map> removed = {{std::string(key), group_counts_get(spoof, key)}}; + spoof.innates.erase(std::string(key)); + removals_finish(player, kind, removed, false); +} + +// ItemSpoof::UpdateTemporaryTimers: each copy for a while loses a frame, the ones out of time leave. +static void timers_update(Entity_Player& player, SpoofKind kind) +{ + ItemSpoof& spoof = spoof_get(player, kind); + std::map> removed; + + for (auto& [key, group] : spoof.innates) + { + for (TemporaryInnate& item : group.temporary) + if (--item.timer <= 0) removed[key][item.id] += item.count; + std::erase_if(group.temporary, [](const TemporaryInnate& item) { return item.timer <= 0; }); + } + std::erase_if(spoof.innates, [](auto& entry) { return is_group_empty(entry.second); }); + removals_finish(player, kind, removed, true); +} + +// ItemSpoof::Block and Unblock: the caches of an item the player has are evaluated again. +static void block_set(Entity_Player& player, SpoofKind kind, int id, bool isBlocked) +{ + ItemSpoof& spoof = spoof_get(player, kind); + id = spoof_id_get(kind, id, true); + if (spoof.blocks.contains(id) == isBlocked) return; + + bool isHad = isBlocked && is_spoof_player_having(player, kind, id); + if (isBlocked) spoof.blocks.insert(id); + else spoof.blocks.erase(id); + if (!isHad && !(!isBlocked && is_spoof_player_having(player, kind, id))) return; + + if (ItemConfig_Item* item = spoof_item_get(kind, id)) player.AddCacheFlags(item->cacheFlags); + player.EvaluateItems(); +} + +static bool is_reworked(int id, int playerType) +{ + return id == COLLECTIBLE_BIRTHRIGHT && reworkedBirthrights.contains(playerType); +} + +// (ItemSpoofSystem.cpp) HasCollectible's spoofs: a reworked Birthright is missing outside Lua, then a blocked +// collectible is missing and an innate one is had. Nothing when the game's own answer stands. +std::optional collectible_spoof_has(Entity_Player& player, int id, bool isOwnedOnly) +{ + SpoofContext context = context_take(); + if (!context.isLuaRequest && is_reworked(id, player.playerType)) return false; + if (isOwnedOnly || context.isIgnoreSpoof) return std::nullopt; + + ItemSpoof& spoof = player.itemSpoofs.collectibles; + if (spoof.blocks.contains(id)) return false; + if (innate_count_get(spoof, id) > 0 || character_innate_get(player.playerType, SPOOF_COLLECTIBLE, id) > 0) + return true; + return std::nullopt; +} + +// GetCollectibleNum's spoofs: none of a reworked or blocked collectible, the innate copies added to the game's count. +std::optional collectible_spoof_count(Entity_Player& player, int id, bool isOwnedOnly) +{ + if (std::exchange(isSpoofInner, false)) return std::nullopt; + SpoofContext context = context_take(); + if (!context.isLuaRequest && is_reworked(id, player.playerType)) return 0; + if (isOwnedOnly || context.isIgnoreSpoof) return std::nullopt; + + ItemSpoof& spoof = player.itemSpoofs.collectibles; + if (spoof.blocks.contains(id)) return 0; + int innate = innate_count_get(spoof, id) + character_innate_get(player.playerType, SPOOF_COLLECTIBLE, id); + if (innate == 0) return std::nullopt; + + isSpoofInner = true; + return innate + hook_inner_call([&] { return player.GetCollectibleNum(id, ITEM_CHECK_MODIFIED); }); +} + +// HasTrinket's spoofs: a blocked trinket is missing, an innate one (or one the character has innately) is had. +std::optional trinket_spoof_has(Entity_Player& player, uint32_t id, bool isOwnedOnly) +{ + SpoofContext context = context_take(); + if (isOwnedOnly || context.isIgnoreSpoof) return std::nullopt; + + ItemSpoof& spoof = player.itemSpoofs.trinkets; + if (spoof.blocks.contains(spoof_id_get(SPOOF_TRINKET, (int)id, true))) return false; + if (innate_count_get(spoof, (int)(id & TRINKET_ID_MASK)) > 0) return true; + if (character_innate_get(player.playerType, SPOOF_TRINKET, (int)id) > 0) return true; + return std::nullopt; +} + +// GetTrinketMultiplier's spoofs: none for a blocked trinket, else its innate copies (golden ones twice) and the +// character's, plus Mom's Box's one when the game counted none. +std::optional trinket_spoof_multiplier(Entity_Player& player, uint32_t id) +{ + if (std::exchange(isSpoofInner, false)) return std::nullopt; + SpoofContext context = context_take(); + if (context.isIgnoreSpoof) return std::nullopt; + + ItemSpoof& spoof = player.itemSpoofs.trinkets; + if (spoof.blocks.contains(spoof_id_get(SPOOF_TRINKET, (int)id, true))) return 0; + int innate = innate_count_get(spoof, (int)(id & TRINKET_ID_MASK)) + + innate_count_get(spoof, (int)(id | TRINKET_GOLDEN_FLAG)) * 2 + + character_innate_get(player.playerType, SPOOF_TRINKET, (int)id); + if (innate == 0) return std::nullopt; + + isSpoofInner = true; + int multiplier = player.GetTrinketMultiplier(id); + if (multiplier == 0 && player.HasCollectible(COLLECTIBLE_MOMS_BOX, ITEM_CHECK_OWNED)) innate++; + return innate + multiplier; +} + +// HasGoldenTrinket's spoofs: a blocked trinket is not golden, an innate golden copy is. +std::optional golden_trinket_spoof_has(Entity_Player& player, uint32_t id) +{ + SpoofContext context = context_take(); + if (context.isIgnoreSpoof) return std::nullopt; + + ItemSpoof& spoof = player.itemSpoofs.trinkets; + if (spoof.blocks.contains(spoof_id_get(SPOOF_TRINKET, (int)id, true))) return false; + if (innate_count_get(spoof, (int)(id | TRINKET_GOLDEN_FLAG)) > 0) return true; + return std::nullopt; +} + +// StartLuaRequest: the next spoofed call comes from Lua. +void item_spoof_lua_request(bool isIgnoreSpoof) +{ + spoofContext = {isIgnoreSpoof, true}; +} + +// UpdateEffects' hook: a change of character, then the copies for a while count down. +void item_spoofs_update(Entity_Player& player) +{ + item_spoofs_player_check(player, false); + timers_update(player, SPOOF_COLLECTIBLE); + timers_update(player, SPOOF_TRINKET); +} + +// PlayerItemSpoofs::CheckPlayerType: on a change of character, its old innate items leave and its new ones come, +// quietly when a state is restored. REPENTOGON evaluates the items on every change: this only when innates changed. +void item_spoofs_player_check(Entity_Player& player, bool isRestoring) +{ + PlayerItemSpoofs& spoofs = player.itemSpoofs; + int previous = std::exchange(spoofs.lastPlayerType, player.playerType); + if (previous == player.playerType || isRestoring) return; + + bool isChanged = false; + for (SpoofKind kind : {SPOOF_COLLECTIBLE, SPOOF_TRINKET}) + { + auto innates = [&](int playerType) -> std::map { + EntityConfig_Player* config = g_manager->entityConfig.GetPlayer(playerType); + if (!config) return {}; + return kind == SPOOF_TRINKET ? config->ex.innateTrinkets : config->ex.innateCollectibles; + }; + for (auto [id, count] : innates(previous)) spoof_removed_trigger(player, kind, id, count); + for (auto [id, count] : innates(player.playerType)) spoof_added_trigger(player, kind, id, count, false); + isChanged = isChanged || !innates(previous).empty() || !innates(player.playerType).empty(); + } + if (isChanged) player.EvaluateItems(); +} + +// Pushes a group's copies as a table of counts by id. +static int group_counts_push(lua_State* state, ItemSpoof& spoof, std::string_view key) +{ + lua_newtable(state); + for (auto [id, count] : group_counts_get(spoof, key)) + { + lua_pushinteger(state, count); + lua_rawseti(state, -2, id); + } + return 1; +} + +// SetInnateItemGroup: a group set to the counts of a table, the ids it leaves out to none. +static void group_set(lua_State* state, SpoofKind kind) +{ + Entity_Player& player = lua_get(state, 1); + std::string key = luaL_checkstring(state, 2); + if (!lua_istable(state, 3)) luaL_argerror(state, 3, "Expected a table"); + bool isAddCostume = lua_gettop(state) < 4 || lua_toboolean(state, 4); + + std::map counts; + for (auto [id, count] : group_counts_get(spoof_get(player, kind), key)) counts[id] = 0; + lua_pushnil(state); + while (lua_next(state, 3) != 0) + { + if (lua_isinteger(state, -2) && lua_isinteger(state, -1)) + counts[spoof_id_get(kind, (int)lua_tointeger(state, -2), false)] = (int)lua_tointeger(state, -1); + lua_pop(state, 1); + } + for (auto [id, count] : counts) innate_count_set(player, kind, id, count, key, isAddCostume); +} + +// An item id argument, an error for one that is not a valid item of the kind. +static int item_arg_check(lua_State* state, SpoofKind kind) +{ + int id = (int)luaL_checkinteger(state, 2); + if (!spoof_item_get(kind, id)) + luaL_error(state, kind == SPOOF_TRINKET ? "Invalid TrinketType %d" : "Invalid CollectibleType %d", id); + return id; +} + +template static int innate_remove_lua(lua_State* state) +{ + Entity_Player& player = lua_get(state, 1); + int id = item_arg_check(state, Kind); + int amount = (int)luaL_optinteger(state, 3, 1); + lua_pushinteger(state, innate_remove(player, Kind, id, amount, luaL_optstring(state, 4, ""), false)); + return 1; +} + +template static int innate_count_get_lua(lua_State* state) +{ + Entity_Player& player = lua_get(state, 1); + int id = spoof_id_get(Kind, item_arg_check(state, Kind), false); + lua_pushinteger(state, group_count_find(spoof_get(player, Kind), luaL_optstring(state, 3, ""), id)); + return 1; +} + +template static int innate_count_set_lua(lua_State* state) +{ + Entity_Player& player = lua_get(state, 1); + int id = item_arg_check(state, Kind); + int count = (int)luaL_optinteger(state, 3, 1); + bool isAddCostume = lua_gettop(state) < 5 || lua_toboolean(state, 5); + lua_pushinteger(state, innate_count_set(player, Kind, id, count, luaL_optstring(state, 4, ""), isAddCostume)); + return 1; +} + +template static int innate_group_get_lua(lua_State* state) +{ + return group_counts_push(state, spoof_get(lua_get(state, 1), Kind), luaL_optstring(state, 2, "")); +} + +template static int innate_group_set_lua(lua_State* state) +{ + group_set(state, Kind); + return 0; +} + +template static int block_set_lua(lua_State* state) +{ + block_set(lua_get(state, 1), Kind, item_arg_check(state, Kind), IsBlocked); + return 0; +} + +template static int block_is_lua(lua_State* state) +{ + Entity_Player& player = lua_get(state, 1); + int id = spoof_id_get(Kind, (int)luaL_checkinteger(state, 2), true); + lua_pushboolean(state, spoof_get(player, Kind).blocks.contains(id)); + return 1; +} + +// AddInnateCollectible: copies into a group. A negative amount (the legacy removal) removes from the unnamed group, +// an error when the newer arguments are given. +static int innate_collectible_add_lua(lua_State* state) +{ + Entity_Player& player = lua_get(state, 1); + int id = item_arg_check(state, SPOOF_COLLECTIBLE); + int amount = (int)luaL_optinteger(state, 3, 1); + std::string key = lua_isnoneornil(state, 4) || lua_isboolean(state, 4) ? "" : luaL_checkstring(state, 4); + int duration = (int)luaL_optinteger(state, 5, -1); + bool isAddCostume = lua_gettop(state) < 6 || lua_toboolean(state, 6); + + if (amount >= 0) innate_add(player, SPOOF_COLLECTIBLE, id, amount, key, duration, isAddCostume); + else if (lua_isstring(state, 4) || lua_isnumber(state, 5)) + luaL_argerror(state, 3, "Removing innate collectibles with AddInnateCollectible via a negative `Amount` is " + "deprecated. Please use RemoveInnateCollectible instead."); + else innate_remove(player, SPOOF_COLLECTIBLE, id, -amount, "", true); + return 0; +} + +static int innate_trinket_add_lua(lua_State* state) +{ + Entity_Player& player = lua_get(state, 1); + int id = item_arg_check(state, SPOOF_TRINKET); + int amount = (int)luaL_optinteger(state, 3, 1); + bool isAddCostume = lua_gettop(state) < 6 || lua_toboolean(state, 6); + innate_add(player, SPOOF_TRINKET, id, amount, luaL_optstring(state, 4, ""), (int)luaL_optinteger(state, 5, -1), + isAddCostume); + return 0; +} + +static int innate_group_clear_lua(lua_State* state) +{ + Entity_Player& player = lua_get(state, 1); + std::string key = luaL_checkstring(state, 2); + group_clear(player, SPOOF_COLLECTIBLE, key); + group_clear(player, SPOOF_TRINKET, key); + return 0; +} + +// GetSpoofedCollectiblesList: every blocked or innate collectible, with its innate count and whether it is blocked. +static int spoofed_list_get_lua(lua_State* state) +{ + ItemSpoof& spoof = lua_get(state, 1).itemSpoofs.collectibles; + std::set ids = spoof.blocks; + for (auto& [key, group] : spoof.innates) + for (auto [id, count] : group_counts_get(spoof, key)) ids.insert(id); + + lua_newtable(state); + for (int id : ids) + { + lua_newtable(state); + lua_pushinteger(state, id); + lua_setfield(state, -2, "CollectibleID"); + lua_pushinteger(state, innate_count_get(spoof, id)); + lua_setfield(state, -2, "AppendedCount"); + lua_pushboolean(state, spoof.blocks.contains(id)); + lua_setfield(state, -2, "IsBlocked"); + lua_rawseti(state, -2, id); + } + return 1; +} + +// (LuaEntityPlayer.cpp) EntityPlayer's innate and blocked item functions, run in its class. +void item_spoof_api_register(lua_State* state) +{ + lua_functions_add(state, {{"AddInnateCollectible", innate_collectible_add_lua}, + {"RemoveInnateCollectible", innate_remove_lua}, + {"GetInnateCollectibleCount", innate_count_get_lua}, + {"SetInnateCollectibleCount", innate_count_set_lua}, + {"GetInnateCollectibleGroup", innate_group_get_lua}, + {"SetInnateCollectibleGroup", innate_group_set_lua}, + {"AddInnateTrinket", innate_trinket_add_lua}, + {"RemoveInnateTrinket", innate_remove_lua}, + {"GetInnateTrinketCount", innate_count_get_lua}, + {"SetInnateTrinketCount", innate_count_set_lua}, + {"GetInnateTrinketGroup", innate_group_get_lua}, + {"SetInnateTrinketGroup", innate_group_set_lua}, + {"ClearInnateItemGroup", innate_group_clear_lua}, + {"BlockCollectible", block_set_lua}, + {"UnblockCollectible", block_set_lua}, + {"IsCollectibleBlocked", block_is_lua}, + {"BlockTrinket", block_set_lua}, + {"UnblockTrinket", block_set_lua}, + {"IsTrinketBlocked", block_is_lua}, + {"GetSpoofedCollectiblesList", spoofed_list_get_lua}}); +} + +// (LuaIsaac.cpp) Isaac.ReworkBirthright: a character's Birthright stops counting outside Lua, for a mod to redo. +void item_spoof_isaac_register(lua_State* state) +{ + lua_method(state, "ReworkBirthright", [](int playerType) { + if (playerType >= 0 && playerType < PLAYER_TYPE_COUNT) reworkedBirthrights.insert(playerType); + }); +} diff --git a/src/repentogon/item_spoof.h b/src/repentogon/item_spoof.h new file mode 100644 index 0000000..46c565a --- /dev/null +++ b/src/repentogon/item_spoof.h @@ -0,0 +1,59 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +struct Entity_Player; +struct lua_State; + +// Whether an item kind is collectibles or trinkets (a golden trinket counting apart from its plain one). +enum SpoofKind +{ + SPOOF_COLLECTIBLE, + SPOOF_TRINKET +}; + +// Copies of an item for a while: its id, how many and the frames left. +struct TemporaryInnate +{ + int count; + int id; + int timer; +}; + +// A group of innate copies (REPENTOGON's InnateItems): the ones for good and the ones for a while. +struct InnateGroup +{ + std::map persistent; + std::vector temporary; +}; + +// The collectibles or trinkets a player has without holding them, by group, and the ones it is kept from (ItemSpoof). +struct ItemSpoof +{ + std::map> innates; + std::set blocks; +}; + +// A player's spoofed items (PlayerItemSpoofs): both kinds, and the character it was when its innates last changed. +struct PlayerItemSpoofs +{ + ItemSpoof collectibles; + ItemSpoof trinkets; + int lastPlayerType = -1; +}; + +std::optional collectible_spoof_has(Entity_Player& player, int id, bool isOwnedOnly); +std::optional collectible_spoof_count(Entity_Player& player, int id, bool isOwnedOnly); +std::optional trinket_spoof_has(Entity_Player& player, uint32_t id, bool isOwnedOnly); +std::optional trinket_spoof_multiplier(Entity_Player& player, uint32_t id); +std::optional golden_trinket_spoof_has(Entity_Player& player, uint32_t id); +void item_spoof_lua_request(bool isIgnoreSpoof); +void item_spoofs_update(Entity_Player& player); +void item_spoofs_player_check(Entity_Player& player, bool isRestoring); +void item_spoof_api_register(lua_State* state); +void item_spoof_isaac_register(lua_State* state); diff --git a/src/repentogon/items.cpp b/src/repentogon/items.cpp index bcdcc49..f716227 100644 --- a/src/repentogon/items.cpp +++ b/src/repentogon/items.cpp @@ -1,4 +1,7 @@ #include "repentogon/items.h" +#include "entity/config.h" +#include "entity/npc/npc.h" +#include "entity/pickup/loot_list.h" #include "entity/pickup/pickup.h" #include "entity/player/active_items.h" #include "entity/player/player.h" @@ -6,10 +9,17 @@ #include "game/manager.h" #include "level/level.h" #include "level/room.h" +#include "repentogon/achievements.h" #include "repentogon/callbacks.h" +#include "repentogon/custom_cache.h" +#include "repentogon/stats.h" +#include "repentogon/xml.h" #include #include #include +#include +#include +#include constexpr int MORPH_KIND_SIZE = 3; constexpr int MORPH_FULL_SIZE = 6; @@ -142,12 +152,14 @@ bool collectible_add_pre(Entity_Player& player, CollectibleAdd add) return isAdded; } -// Runs MC_POST_TRIGGER_COLLECTIBLE_ADDED, then MC_POST_ADD_COLLECTIBLE, once a player got a collectible. +// Runs MC_POST_TRIGGER_COLLECTIBLE_ADDED, then MC_POST_ADD_COLLECTIBLE, once a player got a collectible, then its +// custom caches. void collectible_add_post(Entity_Player& player, CollectibleAdd add) { collectible_added_post(player, add.type, add.isFirstTime, false); callback_notify(lua_engine_get(), {"PostAddCollectible", MC_POST_ADD_COLLECTIBLE, add.type}, add.type, add.charge, add.isFirstTime, add.activeSlot, add.varData, &player); + custom_cache_trigger(player, g_manager->itemConfig.GetCollectible(add.type), CUSTOM_CACHE_NOW); } // Runs MC_POST_TRIGGER_COLLECTIBLE_ADDED for a collectible a player got, or an item wisp lends it. @@ -155,6 +167,7 @@ void collectible_added_post(Entity_Player& player, int type, bool isFirstTime, b { CallbackRun run = {"PostTriggerCollectibleAdded", MC_POST_TRIGGER_COLLECTIBLE_ADDED, type}; callback_notify(lua_engine_get(), run, &player, type, isFirstTime, isWisp); + if (isWisp) custom_cache_trigger(player, g_manager->itemConfig.GetCollectible(type), CUSTOM_CACHE_NOW); } // Runs MC_POST_TRIGGER_COLLECTIBLE_REMOVED once a collectible's loss ran. @@ -162,6 +175,7 @@ void collectible_removed_post(Entity_Player& player, int type, CollectibleRemova { CallbackRun run = {"PostTriggerCollectibleRemoved", MC_POST_TRIGGER_COLLECTIBLE_REMOVED, type}; callback_notify(lua_engine_get(), run, &player, type, removal == REMOVAL_KIND_FORM, removal == REMOVAL_KIND_WISP); + custom_cache_trigger(player, g_manager->itemConfig.GetCollectible(type), CUSTOM_CACHE_NOW); } // Runs MC_PRE_ADD_TRINKET before a player gets a trinket that exists. An integer replaces it, a table its type and @@ -193,6 +207,7 @@ void trinket_added_post(Entity_Player& player, uint32_t type, bool isFirstTime) { CallbackRun run = {"PostTriggerTrinketAdded", MC_POST_TRIGGER_TRINKET_ADDED, (int)type}; callback_notify(lua_engine_get(), run, &player, type, isFirstTime, false); + custom_cache_trigger(player, g_manager->itemConfig.GetTrinket(type & TRINKET_ID_MASK), CUSTOM_CACHE_NEXT_EVALUATE); } // Runs MC_POST_TRIGGER_TRINKET_REMOVED once a trinket's loss ran. @@ -200,6 +215,7 @@ void trinket_removed_post(Entity_Player& player, uint32_t type) { CallbackRun run = {"PostTriggerTrinketRemoved", MC_POST_TRIGGER_TRINKET_REMOVED, (int)type}; callback_notify(lua_engine_get(), run, &player, type, false); + custom_cache_trigger(player, g_manager->itemConfig.GetTrinket(type & TRINKET_ID_MASK), CUSTOM_CACHE_NEXT_EVALUATE); } // MC_PRE_USE_ITEM before an active item is used: the game's own with vanilla parity, else REPENTOGON's, which a true @@ -434,7 +450,8 @@ float planetarium_chance_hook(Level& level, float chance) return std::min(chance, 1.0f); } -// Runs MC_TRY_ADD_TO_BAG_OF_CRAFTING once the bag chose a pickup's ingredients (none for one it cannot take). A table +// Runs MC_TRY_ADD_TO_BAG_OF_CRAFTING once the bag chose a pickup's ingredients (none for one it cannot take, its +// entities2.xml bagofcrafting in their place when it gives one). A table // of up to eight replaces them up to its first one out of range, false refuses the pickup. What goes in the bag, // nothing when it does not take the pickup. std::optional bag_ingredients_hook(Entity_Player& player, Entity_Pickup& pickup, @@ -447,6 +464,13 @@ std::optional bag_ingredients_hook(Entity_Player& player, Entity if (ingredient == 0) break; chosen[count++] = ingredient; } + if (pickup.config && !pickup.config->bagOfCraftingPickups.empty()) + { + chosen = {}; + count = 0; + for (int ingredient : pickup.config->bagOfCraftingPickups) chosen[count++] = (uint8_t)ingredient; + count -= chosen[0] == 0; + } LuaEngine& engine = lua_engine_get(); lua_State* state = engine.state; @@ -508,3 +532,117 @@ void custom_tags_parse(std::string_view text, std::set& tags) start = end + 1; } } + +// The announcer fields of mods' cards and pill effects whose XML names a sound, until the mod's sounds load. +static std::vector> namedAnnouncers; + +// (Patches/ItemConfigEx.cpp, XMLData.cpp) What REPENTOGON reads of an items.xml element beyond the game: an achievement by +// name, the stats, and an active's sprite in the HUD (activegfx under the file's gfxroot). BFFS! and Hive Mind +// evaluate familiarmultiplier, Deep Pockets maxcoins, and the custom caches become known ones. +void item_xml_extras_load(DataNode node, ItemConfig_Item& item, std::string_view gfxRoot) +{ + bool isFamiliarBoost = item.id == COLLECTIBLE_BFFS || item.id == COLLECTIBLE_HIVE_MIND; + if (item.IsCollectible() && isFamiliarBoost) item.customCaches.insert("familiarmultiplier"); + if (item.IsCollectible() && item.id == COLLECTIBLE_DEEP_POCKETS) item.customCaches.insert("maxcoins"); + custom_caches_known_add(item.customCaches); + achievement_attr_read(node, item.achievementId); + item_stats_parse(node, item); + if (auto activeGfx = node_attr_find(node, "activegfx"); activeGfx && item.type == ITEM_ACTIVE && !gfxRoot.empty()) + item.activeGfx = std::string(gfxRoot) + "collectibles/" + std::string(*activeGfx); +} + +// (ItemConfigEx.cpp PostLoadSounds, XMLData.cpp) A card's or pill effect's achievement by name, and its announcers by +// sound name once its mod's sounds load. +void pocket_item_xml_extras_load(DataNode node, PocketItemConfig& item, int* announcerSuper) +{ + achievement_attr_read(node, item.achievementId); + if (auto announcer = node_attr_find(node, "announcer"); announcer && item.announcerVoice <= 0) + namedAnnouncers.emplace_back(&item.announcerVoice, *announcer); + if (auto announcer = node_attr_find(node, "announcer2"); announcer && announcerSuper && *announcerSuper <= 0) + namedAnnouncers.emplace_back(announcerSuper, *announcer); +} + +// Gives each announcer a mod named the sound by that name, by its name or else its first sample's file name. +void pocket_item_announcers_resolve() +{ + std::vector& sounds = g_manager->sfxManager.sounds; + auto isNamed = [](SoundEffect& sound, std::string& name) { + return sound.name.empty() && !sound.samples.empty() ? file_name_get(sound.samples[0].path) == name + : sound.name == name; + }; + + for (auto& [announcer, name] : namedAnnouncers) + for (SoundEffect& sound : sounds) + if (!name.empty() && isNamed(sound, name)) *announcer = sound.id; + namedAnnouncers.clear(); +} + +// (CardsExtras.cpp is_card_available_ex) Whether a card the game allows is not hidden and its mod's availability +// condition, if any, returns true. An error in the condition is printed and counts as available. +bool card_is_available_ex(ItemConfig_Card& card) +{ + if (card.isHidden) return false; + if (!card.availabilityRef) return true; + + lua_State* state = lua_engine_get().state; + lua_rawgeti(state, LUA_REGISTRYINDEX, *card.availabilityRef); + if (lua_pcall(state, 0, 1, 0) != LUA_OK) + { + std::string error = std::format("Error whilst checking availability of card \"{}\": {}", card.GetName(), + lua_tostring(state, -1)); + if (g_game) g_game->console.PrintError(error); + log_printf(LOG_INFO, "%s\n", error.c_str()); + lua_pop(state, 1); + return true; + } + bool isAvailable = lua_isboolean(state, -1) && lua_toboolean(state, -1); + lua_pop(state, 1); + return isAvailable; +} + +// (CardsExtras.cpp CardPool::PickCard) A card of a pool by the cards' weights, once one is not 1, an empty slot +// weighing 1. Nothing when every weight is 1, for the game's own pick. No card when they weigh nothing. +std::optional card_weighted_pick(RNG& rng, const std::vector& pool) +{ + std::vector weights; + for (int id : pool) weights.push_back(id ? g_manager->itemConfig.GetCard(id)->weight : 1); + if (std::ranges::all_of(weights, [](float weight) { return weight == 1; })) return std::nullopt; + + float total = std::accumulate(weights.begin(), weights.end(), 0.0f); + if (total == 0) return 0; + float target = rng.RandomFloat() * total; + float sum = 0; + for (size_t i = 0; i < pool.size(); i++) + if ((sum += weights[i]) > target) return pool[i]; + return 0; +} + +// (CustomCallbacks.cpp RunLootListCallbacks) Runs MC_PRE_PICKUP_GET_LOOT_LIST around a pickup's loot, filtered by its +// variant, or MC_PRE_NPC_GET_LOOT_LIST around an NPC's, by its type: a LootList it returns replaces the loot. Then the +// MC_POST one gets the loot to change, with whether the draw is for good, the RNG it drew from and the player if any. +template +static void loot_callbacks_run(T& entity, int pre, int post, LootList& loot, bool isAdvancing, RNG& rng, + Entity_Player* player) +{ + int param = entity.type == ENTITY_PICKUP ? entity.variant : entity.type; + LuaEngine& engine = lua_engine_get(); + lua_State* state = engine.state; + + if (callback_run(engine, {"PreGetLootList", pre, param}, &entity, isAdvancing, &rng, player)) + { + if (void* replaced = lua_object_test(state, -1, LUA_CLASS_LOOT_LIST)) loot = *(LootList*)replaced; + lua_pop(state, 1); + } + callback_notify(engine, {"PostGetLootList", post, param}, &entity, &loot, isAdvancing, &rng, player); +} + +void loot_list_callbacks_run(Entity_Pickup& pickup, LootList& loot, bool isAdvancing, RNG& rng, Entity_Player* player) +{ + int pre = MC_PRE_PICKUP_GET_LOOT_LIST; + loot_callbacks_run(pickup, pre, MC_POST_PICKUP_GET_LOOT_LIST, loot, isAdvancing, rng, player); +} + +void loot_list_callbacks_run(Entity_NPC& npc, LootList& loot, bool isAdvancing, RNG& rng, Entity_Player* player) +{ + loot_callbacks_run(npc, MC_PRE_NPC_GET_LOOT_LIST, MC_POST_NPC_GET_LOOT_LIST, loot, isAdvancing, rng, player); +} diff --git a/src/repentogon/items.h b/src/repentogon/items.h index 8135d3f..c7896a6 100644 --- a/src/repentogon/items.h +++ b/src/repentogon/items.h @@ -1,13 +1,21 @@ #pragma once +#include "engine/data.h" #include #include #include #include #include #include +#include +struct RNG; +struct Entity_NPC; struct Entity_Pickup; +struct LootList; +struct ItemConfig_Card; +struct ItemConfig_Item; +struct PocketItemConfig; struct Entity_Player; struct PickupChoice; struct ActiveUse; @@ -15,9 +23,12 @@ struct UseResult; class Level; class Room; -// The custom tags that make an item's holder fly (REPENTOGON's CustomTags::FLYING and FLYING_EFFECT). +// The custom tags that make an item's holder fly (REPENTOGON's CustomTags::FLYING and FLYING_EFFECT), and keep it from +// Expansion Pack's and Metronome's picks. constexpr const char* CUSTOM_TAG_FLYING = "flying"; constexpr const char* CUSTOM_TAG_FLYING_EFFECT = "flyingeffect"; +constexpr const char* CUSTOM_TAG_NO_EXPANSION_PACK = "noexpansionpack"; +constexpr const char* CUSTOM_TAG_NO_METRONOME = "nometronome"; // How a collectible left for MC_POST_TRIGGER_COLLECTIBLE_REMOVED: taken counting towards its form or not (Entity_Player:: // RemoveCollectible's choice), or its item wisp gone. @@ -109,3 +120,10 @@ bool shop_restock_pre(RestockKind kind); void shop_restock_post(RestockKind kind); void pickup_selection_post(Entity_Pickup& pickup, PickupChoice& choice, const PickupChoice& requested); void custom_tags_parse(std::string_view text, std::set& tags); +void item_xml_extras_load(DataNode node, ItemConfig_Item& item, std::string_view gfxRoot); +void pocket_item_xml_extras_load(DataNode node, PocketItemConfig& item, int* announcerSuper); +void pocket_item_announcers_resolve(); +bool card_is_available_ex(ItemConfig_Card& card); +std::optional card_weighted_pick(RNG& rng, const std::vector& pool); +void loot_list_callbacks_run(Entity_Pickup& pickup, LootList& loot, bool isAdvancing, RNG& rng, Entity_Player* player); +void loot_list_callbacks_run(Entity_NPC& npc, LootList& loot, bool isAdvancing, RNG& rng, Entity_Player* player); diff --git a/src/repentogon/json_save.cpp b/src/repentogon/json_save.cpp new file mode 100644 index 0000000..68ab194 --- /dev/null +++ b/src/repentogon/json_save.cpp @@ -0,0 +1,66 @@ +#include "repentogon/json_save.h" +#include "repentogon/options.h" +#include "simdjson.h" +#include +#include + +// (REPENTOGON::GetRepentogonDataPath) A file of REPENTOGON's data folder, the one beside its options.ini. +std::string json_save_path(std::string_view fileName) +{ + return (std::filesystem::path(repentogonOptions.path).parent_path() / fileName).string(); +} + +// (JsonToArray, JsonToArrayOfArray) Reads one member of a save file into counts or lists, whichever is given. False +// when the file is missing, not JSON or lacks the member. +bool json_save_load(std::string_view path, std::string_view member, JsonCounts* counts, JsonLists* lists) +{ + simdjson::dom::parser parser; + simdjson::dom::object object; + if (parser.load(std::string(path)).get_object().get(object) != simdjson::SUCCESS) return false; + if (object[member].get_object().get(object) != simdjson::SUCCESS) return false; + + for (auto [key, value] : object) + { + int64_t number = 0; + simdjson::dom::array array; + if (counts && value.get_int64().get(number) == simdjson::SUCCESS) (*counts)[std::string(key)] = (int)number; + if (!lists || value.get_array().get(array) != simdjson::SUCCESS) continue; + + std::vector& list = (*lists)[std::string(key)]; + for (simdjson::dom::element entry : array) + if (entry.get_int64().get(number) == simdjson::SUCCESS) list.push_back((int)number); + } + return true; +} + +// A JSON string literal of text. +static std::string json_quote(std::string_view text) +{ + std::string quoted = "\""; + for (char letter : text) + { + if (letter == '"' || letter == '\\') quoted += '\\'; + quoted += letter; + } + return quoted + '"'; +} + +// (ArrayToJson, ArrayOfArrayToJson) Writes a save file holding one member, made of counts or lists. +void json_save_write(std::string_view path, std::string_view member, const JsonCounts* counts, const JsonLists* lists) +{ + std::string text = "{" + json_quote(member) + ":{"; + std::string separator; + + for (auto& [key, value] : counts ? *counts : JsonCounts{}) + text += std::exchange(separator, ",") + json_quote(key) + ":" + std::to_string(value); + for (auto& [key, values] : lists ? *lists : JsonLists{}) + { + text += std::exchange(separator, ",") + json_quote(key) + ":["; + for (size_t i = 0; i < values.size(); i++) text += (i ? "," : "") + std::to_string(values[i]); + text += "]"; + } + + std::error_code error; + std::filesystem::create_directories(std::filesystem::path(path).parent_path(), error); + std::ofstream(std::string(path)) << text << "}}\n"; +} diff --git a/src/repentogon/json_save.h b/src/repentogon/json_save.h new file mode 100644 index 0000000..22445fa --- /dev/null +++ b/src/repentogon/json_save.h @@ -0,0 +1,15 @@ +#pragma once + +#include +#include +#include +#include + +// REPENTOGON's JsonSavedata: its own save files in its data folder, JSON objects whose members map names to an integer +// (ArrayToJson) or to a list of integers (ArrayOfArrayToJson). +using JsonCounts = std::map; +using JsonLists = std::map>; + +std::string json_save_path(std::string_view fileName); +bool json_save_load(std::string_view path, std::string_view member, JsonCounts* counts, JsonLists* lists); +void json_save_write(std::string_view path, std::string_view member, const JsonCounts* counts, const JsonLists* lists); diff --git a/src/repentogon/level.cpp b/src/repentogon/level.cpp index a3710fc..57f599f 100644 --- a/src/repentogon/level.cpp +++ b/src/repentogon/level.cpp @@ -4,15 +4,29 @@ #include "game/game.h" #include "level/generator.h" #include "level/grid/grid_entity.h" +#include "level/level.h" #include "level/room.h" #include "level/room_config.h" #include "repentogon/api_level.h" #include "repentogon/callbacks.h" +#include +#include constexpr int LEVEL_STAGE_LAST = 14; constexpr int GREED_STAGE_LAST = 7; constexpr int STAGE_TYPE_REMOVED = 3; constexpr int STAGE_TYPE_LAST = 5; +constexpr uint32_t DEAL_VARIANT_TRAPDOOR = 100; +constexpr int DEAL_SUBTYPE_TRAPDOOR = 666; +constexpr int DEAL_DIFFICULTY_MAX = 20; +constexpr float DEAL_WEIGHT_SCALE = 0.1f; +constexpr float DEAL_WEIGHT_MIN = 1e-7f; +// The suffix of each stage id from 1 (the floor versions of sprites), none for the stages that take none. +constexpr std::array STAGE_SUFFIXES = { + "_basement", "_cellar", "_burningbasement", "_caves", "_catacombs", "_downpour", "_depths", "_necropolis", + "_dankdepths", "_womb", "_utero", "_scarredwomb", "_bluewomb", "_sheol", "_cathedral", "_darkroom", "_chest", "", + "", "", "", "", "", "", "", "", "_downpour", "_dross", "_mines", "_ashpit", "_mausoleum", "_gehenna", "_corpse", + "", "_home"}; bool isUpdateHeld = false; @@ -279,3 +293,48 @@ void grid_hurt_post(GridEntity& grid, int damage, const EntityRef& source) { callback_notify(lua_engine_get(), {"PostGridHurt", MC_POST_GRID_HURT, (int)grid.type}, &grid, damage, &source); } + +// Once a stage's rooms load, with vanilla parity off: each stage takes its floor's suffix (Patches/StagesStuff.cpp), +// and the special rooms' trapdoor deals (the devil and angel rooms of variant 100 the Womb II deal draws) take a +// subtype of their own, so no other draw meets them (Patches/ASMPatches/ASMLevel.cpp). +void stage_binary_load_post(RoomConfig& config, int stageId, RoomMode mode) +{ + if (repentogonOptions.isVanillaParity) return; + if (stageId > 0 && stageId <= (int)STAGE_SUFFIXES.size()) config.stages[stageId].suffix = STAGE_SUFFIXES[stageId - 1]; + if (stageId != STAGE_ID_SPECIAL_ROOMS) return; + + for (int type : {ROOM_DEVIL, ROOM_ANGEL}) + { + RoomQuery query = {.maxVariant = DEAL_VARIANT_TRAPDOOR, + .minVariant = DEAL_VARIANT_TRAPDOOR, + .mode = mode, + .maxDifficulty = DEAL_DIFFICULTY_MAX, + .subtype = 0, + .type = type}; + for (RoomConfig_Room* room : config.GetRooms(query)) room->subtype = DEAL_SUBTYPE_TRAPDOOR; + } +} + +// (Patches/ASMPatches/ASMLevel.cpp, vanilla parity off) A devil or angel room for InitializeDevilAngelRoom and +// MakeRedRoomDoor. The trapdoor deal draw asks for their subtype. Any other draws a deal of any variant, so mods' +// above 100 come up too, and draws as the game does when that is a trapdoor deal. Its redraws reuse the seed and +// draw the same room, which the rebuild skips. +RoomConfig_Room* deal_room_get(uint32_t seed, WeightReduction reduction, RoomQuery& query) +{ + RoomConfig& config = g_game->roomConfig; + if (repentogonOptions.isVanillaParity || (query.type != ROOM_DEVIL && query.type != ROOM_ANGEL)) + return config.GetRandomRoom(seed, reduction, query); + + RoomQuery dealQuery = query; + if (query.minVariant == DEAL_VARIANT_TRAPDOOR && query.maxVariant == DEAL_VARIANT_TRAPDOOR) + { + dealQuery.subtype = DEAL_SUBTYPE_TRAPDOOR; + return config.GetRandomRoom(seed, reduction, dealQuery); + } + dealQuery.minVariant = 0; + dealQuery.maxVariant = UINT32_MAX; + RoomConfig_Room* room = config.GetRandomRoom(seed, WEIGHT_KEEP, dealQuery); + if (room && room->variant == (int)DEAL_VARIANT_TRAPDOOR) return config.GetRandomRoom(seed, reduction, query); + if (room && reduction == WEIGHT_REDUCE) room->weight = std::max(DEAL_WEIGHT_MIN, room->weight * DEAL_WEIGHT_SCALE); + return room; +} diff --git a/src/repentogon/level.h b/src/repentogon/level.h index c3ae395..e0686e5 100644 --- a/src/repentogon/level.h +++ b/src/repentogon/level.h @@ -1,5 +1,6 @@ #pragma once +#include "repentogon/options.h" #include #include #include @@ -12,12 +13,27 @@ struct GridEntityDesc; struct LevelGenerator_Room; struct RoomConfig_Room; struct RoomDescriptor; +class RoomConfig; enum GridEntityType : int; +enum RoomMode : int; +enum WeightReduction : int; +struct RoomQuery; // Whether MC_PRE_UPDATE holds the run: while it runs, and until the next update once a mod skipped one. The game // reads it as paused. extern bool isUpdateHeld; +// QuickRoomClear (Patches/ASMPatches/ASMRoom.cpp): a room clears 3 frames after its last enemy instead of 10, and +// what waits on the clear waits that much less. +inline bool is_quick_room_clear() +{ + return is_tweak_on(repentogonOptions.isQuickRoomClear); +} + +// Whether the room's camera keeps within it (ASMCamera.cpp's roomCameraData.Clamped), which Camera:SetClampEnabled +// turns off until the next room's camera. +inline bool isCameraClamped = true; + bool game_update_is_skipped(); bool challenge_done_pre(int challenge); void change_room_pre(int& roomIdx, int& dimension); @@ -37,6 +53,8 @@ int special_quest_force_get(); bool special_quest_check(int expectedStage, int quest); bool special_quest_stage_type_check(bool isAltPath); int room_item_pool_forced_get(); +void stage_binary_load_post(RoomConfig& config, int stageId, RoomMode mode); +RoomConfig_Room* deal_room_get(uint32_t seed, WeightReduction reduction, RoomQuery& query); void room_item_pool_reset(); // Runs MC_PRE_GRID_HURT, which may change the damage or cancel the hurt, then hurt, then MC_POST_GRID_HURT once it diff --git a/src/repentogon/menus.cpp b/src/repentogon/menus.cpp index bff8c5c..52d38bd 100644 --- a/src/repentogon/menus.cpp +++ b/src/repentogon/menus.cpp @@ -3,6 +3,7 @@ #include "game/game.h" #include "game/manager.h" #include "repentogon/api.h" +#include "repentogon/callbacks.h" #include "repentogon/lua_render.h" #include "ui/menu/manager.h" #include @@ -18,13 +19,16 @@ constexpr float COLOR_MOD_DEFAULT_RATE = 0.015f; constexpr int CHARACTER_FLAT_ENTRY_COUNT = CHARACTER_ENTRY_COUNT * CHARACTER_MENU_COUNT; constexpr uint32_t CUTSCENE_GAME_LAST = CUTSCENE_ENTRY_COUNT - 1; constexpr uint32_t INPUT_MASK_ALL = ~0u; +constexpr int INPUT_MASK_BITS = 32; constexpr int SAVE_SLOT_FIRST = 1; // The bosses a bestiary page shows, which REPENTOGON's page count divides by. constexpr int BESTIARY_BOSSES_PER_PAGE = 4; -// REPENTOGON's MainMenuInputBlock: the input mask SetInputMask keeps, which never takes effect since nothing enables -// it, and the menu GetActiveMenu reports after SetActiveMenu was given one out of range. +// REPENTOGON's MainMenuInputBlock (Patches/MainMenuBlock.cpp): the input mask SetInputMask keeps, which holds back +// the actions it leaves out once MC_MAIN_MENU_RENDER ran outside the fade into a run, until the run starts. Also the +// menu GetActiveMenu reports after SetActiveMenu was given one out of range. static uint32_t inputMask = INPUT_MASK_ALL; +static bool isInputMaskOn = false; static int activeMenuLie = 0; // The sheets SaveMenu.SetSlotSpritesheet gave each save file's drawing. static std::array slotSpritesheets; @@ -532,6 +536,21 @@ void menus_register(lua_State* state) void menu_input_mask_clear() { inputMask = INPUT_MASK_ALL; + isInputMaskOn = false; +} + +// Runs MC_MAIN_MENU_RENDER, unmasked, then turns the input mask on but for the fade into a run. +void main_menu_render_notify(MenuManager& menu) +{ + isInputMaskOn = false; + unfiltered_notify("MainMenuRender", MC_MAIN_MENU_RENDER); + isInputMaskOn = !menu.isFadeOutActive; +} + +// Whether the main menu's input mask holds an action back. An action past the mask's bits wraps, as x86's shift does. +bool is_action_masked(int action) +{ + return isInputMaskOn && !(inputMask & (1u << (action % INPUT_MASK_BITS))); } // Isaac.WorldToMenuPosition: a position of a menu's place on the menu sheet as the screen shows it now. diff --git a/src/repentogon/menus.h b/src/repentogon/menus.h index d77093a..1b29fc8 100644 --- a/src/repentogon/menus.h +++ b/src/repentogon/menus.h @@ -1,9 +1,12 @@ #pragma once struct ANM2; +class MenuManager; struct lua_State; void menus_register(lua_State* state); void isaac_menus_register(lua_State* state); void save_slot_sprite_replace(ANM2& sprite); void menu_input_mask_clear(); +void main_menu_render_notify(MenuManager& menu); +bool is_action_masked(int action); diff --git a/src/repentogon/mod_curses.cpp b/src/repentogon/mod_curses.cpp new file mode 100644 index 0000000..a6bfa36 --- /dev/null +++ b/src/repentogon/mod_curses.cpp @@ -0,0 +1,64 @@ +#include "repentogon/mod_curses.h" +#include "engine/anm2.h" +#include "engine/filesys.h" +#include "game/game.h" +#include "game/mod_manager.h" +#include +#include + +// (Patches/CustomModManager.cpp) The minimap icons of mods' own curses: a mod with curses and a +// gfx/mapitemicons.anm2 shows each of its curses as the frame of that sprite's curses animation it has by order, after +// the game's curses on the minimap. + +constexpr const char* MOD_ICONS_FILE = "gfx/mapitemicons.anm2"; +constexpr const char* CURSES_ANIMATION = "curses"; +constexpr int GAME_CURSE_ICONS = 9; + +// A mod curse's icon: its mod's sprite and its frame. +struct ModCurseIcon +{ + ANM2* sprite = nullptr; + int frame = 0; +}; + +static std::map modIconSprites; +static std::map curseIcons; + +// Adds a mod's curses.xml to the room config, its curses taking its icons, by order. +void mod_curses_load(std::string& path, ModEntry& mod) +{ + std::vector& curses = g_game->roomConfig.curses; + int first = (int)curses.size(); + g_game->roomConfig.LoadCurses(path, CURSES_APPEND); + + std::string iconsPath = mod.GetContentPath(MOD_ICONS_FILE); + if (!resource_exists(iconsPath)) return; + ANM2& sprite = modIconSprites[mod.directory]; + if (!sprite.isLoaded) sprite.Load(iconsPath, GRAPHICS_LOAD); + for (int id = first; id < (int)curses.size(); id++) curseIcons[id] = {&sprite, id - first}; +} + +// The ids of the mod curses on that have an icon, past the game's own icons. +std::vector mod_curse_icons_get(uint32_t curses) +{ + std::vector ids; + for (auto& [id, icon] : curseIcons) + if (id > GAME_CURSE_ICONS && id <= (int)sizeof(curses) * CHAR_BIT && (curses & 1u << (id - 1)) && + icon.sprite->isLoaded) + ids.push_back(id); + return ids; +} + +// Draws a mod curse's icon. Whether it has one. +bool is_mod_curse_icon_rendered(int curseId, Vector position, float alpha) +{ + auto found = curseIcons.find(curseId); + if (curseId < GAME_CURSE_ICONS || found == curseIcons.end() || !found->second.sprite->isLoaded) return false; + + ANM2& sprite = *found->second.sprite; + sprite.Play(CURSES_ANIMATION); + sprite.SetFrame(CURSES_ANIMATION, found->second.frame); + sprite.color._tint[3] = alpha; + sprite.Render({position}); + return true; +} diff --git a/src/repentogon/mod_curses.h b/src/repentogon/mod_curses.h new file mode 100644 index 0000000..98c5111 --- /dev/null +++ b/src/repentogon/mod_curses.h @@ -0,0 +1,12 @@ +#pragma once + +#include +#include +#include + +struct ModEntry; +struct Vector; + +void mod_curses_load(std::string& path, ModEntry& mod); +std::vector mod_curse_icons_get(uint32_t curses); +bool is_mod_curse_icon_rendered(int curseId, Vector position, float alpha); diff --git a/src/repentogon/npc.cpp b/src/repentogon/npc.cpp index adf646d..d3fd52d 100644 --- a/src/repentogon/npc.cpp +++ b/src/repentogon/npc.cpp @@ -6,6 +6,7 @@ #include "game/manager.h" #include "level/room.h" #include "repentogon/callbacks.h" +#include "repentogon/items.h" constexpr float FIREPLACE_GHOSTS_HEALTH_MIN = 1; @@ -127,3 +128,14 @@ void boss_hazards_clear(BossHazards hazards, Entity* source) if (entity.type == ENTITY_PROJECTILE) entity.isDead = true; } } + +// (CustomCallbacks.cpp's fireplace_get_loot and shopkeeper_get_loot hooks) An NPC's loot as roll draws it, then +// MC_PRE and MC_POST_NPC_GET_LOOT_LIST on its drop RNG, which a draw not for good gets back after. +LootList npc_loot_hook(Entity_NPC& npc, bool isAdvance, LootList (*roll)(Entity_NPC& npc, bool isAdvance)) +{ + RNG saved = npc.dropRNG; + LootList loot = roll(npc, isAdvance); + loot_list_callbacks_run(npc, loot, isAdvance, npc.dropRNG, nullptr); + if (!isAdvance) npc.dropRNG = saved; + return loot; +} diff --git a/src/repentogon/npc.h b/src/repentogon/npc.h index f7a4ffb..925ad6f 100644 --- a/src/repentogon/npc.h +++ b/src/repentogon/npc.h @@ -1,5 +1,6 @@ #pragma once +#include "entity/pickup/loot_list.h" #include #include @@ -32,8 +33,11 @@ enum BossHazards // Where FireProjectilesEx and FireBossProjectilesEx collect the shots a fire spawns, null outside them. inline std::vector* projectileCapture = nullptr; -void delirium_form_force(Entity_NPC& npc, unsigned int& type, unsigned int& variant); +bool delirium_morph_pre(Entity_NPC& npc); +void delirium_form_hook(Entity_NPC& npc, int& type, int& variant); +void delirium_morph_post(Entity_NPC& npc); void boss_hazards_clear(BossHazards hazards, Entity* source); +LootList npc_loot_hook(Entity_NPC& npc, bool isAdvance, LootList (*roll)(Entity_NPC& npc, bool isAdvance)); void npc_api_register(lua_State* state); void familiar_api_register(lua_State* state); void npc_classes_register(lua_State* state); diff --git a/src/repentogon/options.h b/src/repentogon/options.h index 07405e9..99730b4 100644 --- a/src/repentogon/options.h +++ b/src/repentogon/options.h @@ -8,7 +8,7 @@ constexpr int MARS_DOUBLE_TAP_WINDOW_MAX = 20; // REPENTOGON's own options (REPENTOGONOptions), kept by section in Repentogon/options.ini in the save folder, with its // defaults, plus the rebuild's vanilla parity switch, which keeps the game's behaviour exactly the original's. -// Keys it does not know are kept as read. Only the parity switch changes anything yet: the callback dispatch. +// Keys it does not know are kept as read. struct RepentogonOptions { std::map> ini; @@ -82,3 +82,9 @@ template void repentogon_options_visit(RepentogonOptions& optio } extern RepentogonOptions repentogonOptions; + +// Whether one of REPENTOGON's changes to the vanilla game applies: its option on, and the parity switch off. +inline bool is_tweak_on(bool isOption) +{ + return isOption && !repentogonOptions.isVanillaParity; +} diff --git a/src/repentogon/player.cpp b/src/repentogon/player.cpp index 88abe51..f76f787 100644 --- a/src/repentogon/player.cpp +++ b/src/repentogon/player.cpp @@ -3,10 +3,13 @@ #include "entity/player/hud.h" #include "entity/player/player.h" #include "entity/weapon/bomb.h" +#include "engine/platform.h" #include "game/game.h" +#include "game/manager.h" #include "repentogon/callbacks.h" #include #include +#include #include // REPENTOGON's player callbacks (LuaInterfaces/CustomCallbacks.cpp, Patches/ASMPatches/ASMCallbacks.cpp, @@ -176,6 +179,8 @@ int player_health_type_evaluate(Entity_Player& player, int healthType) player.isEvaluatingHealthType = true; int previous = player.previousHealthType != HEALTH_TYPE_UNSET ? player.previousHealthType : healthType; + if (auto cached = player.customCache.results.find("healthtype"); cached != player.customCache.results.end()) + healthType = cached->second >= 0 && cached->second < HEALTH_TYPE_COUNT ? (int)cached->second : healthType; int evaluated = healthType; CallbackRun run = {"PlayerGetHealthType", MC_PLAYER_GET_HEALTH_TYPE, player.playerType}; if (std::optional chosen = integer_get(run, &player, previous, healthType); @@ -315,6 +320,7 @@ void player_effect_post_remove(Entity_Player& player, ItemConfig_Item* item, int { CallbackRun run = {"PostPlayerTriggerEffectRemoved", MC_POST_PLAYER_TRIGGER_EFFECT_REMOVED, item_param(item)}; notify(run, &player, item, count); + custom_cache_trigger(player, item, CUSTOM_CACHE_NEXT_EVALUATE); } // 00930220's MC_POST_PLAYER_ADD_EFFECT, after copies of an item's effect were added to a player. @@ -323,6 +329,7 @@ void player_effect_post_add(Entity_Player& player, const TemporaryEffect& effect if (!effect.item) return; CallbackRun run = {"PostPlayerAddEffect", MC_POST_PLAYER_ADD_EFFECT, item_param(effect.item)}; notify(run, &player, effect.item, isAddCostume, count); + custom_cache_trigger(player, effect.item, CUSTOM_CACHE_NEXT_EVALUATE); } // 0075d1d0's MC_PRE_PLAYER_ADD_COSTUME. Whether a mod returned true, which keeps the costume off. An Item it returned @@ -360,6 +367,55 @@ void costume_post_remove(Entity_Player& player, ItemConfig_Item* item) notify({"PostPlayerRemoveCostume", MC_POST_PLAYER_REMOVE_COSTUME, item_param(item)}, item, &player); } +constexpr const char* TAG_REVIVE = "revive"; +constexpr const char* TAG_REVIVE_EFFECT = "reviveeffect"; +constexpr const char* TAG_REVIVE_HIDDEN = "hiddenrevive"; +constexpr const char* TAG_REVIVE_CHANCE = "chancerevive"; + +// (ItemConfigEx.cpp's GetCustomReviveCount and HasCustomChanceRevive, ExtraLives.cpp) The lives mods' items tagged +// revive give while held (a trinket smelted too), and those tagged reviveeffect while their effect lasts. Tagged +// hiddenrevive, they count only with the hidden ones. A chancerevive item held makes the count only a chance. +CustomRevives custom_revives_get(Entity_Player& player, ReviveCount count) +{ + ItemConfig& config = g_manager->itemConfig; + TemporaryEffects& effects = player.temporaryEffects; + CustomRevives revives; + auto add = [&](ItemConfig_Item* item, const char* tag, auto lives) { + if (!item || !item->customTags.contains(tag)) return; + if (count == REVIVE_COUNT_SHOWN && item->customTags.contains(TAG_REVIVE_HIDDEN)) return; + int added = lives(item->id); + revives.lives += added; + revives.isChance |= added > 0 && item->customTags.contains(TAG_REVIVE_CHANCE); + }; + + ItemCheck check = count == REVIVE_COUNT_SHOWN ? ITEM_CHECK_OWNED : ITEM_CHECK_MODIFIED; + for (auto& item : config.collectibles) + { + add(item.get(), TAG_REVIVE, [&](int id) { return player.GetCollectibleNum(id, check); }); + add(item.get(), TAG_REVIVE_EFFECT, [&](int id) { return effects.GetCollectibleEffectNum(id); }); + } + for (auto& item : config.trinkets) + { + add(item.get(), TAG_REVIVE, [&](int id) { + auto isHeld = [&](uint32_t held) { return (held & TRINKET_ID_MASK) == (uint32_t)id; }; + int held = (int)std::ranges::count_if(player.trinkets, isHeld); + if ((size_t)id >= player.smeltedTrinkets.size()) return held; + return held + player.smeltedTrinkets[id].count + player.smeltedTrinkets[id].goldenCount; + }); + add(item.get(), TAG_REVIVE_EFFECT, [&](int id) { return effects.GetTrinketEffectNum(id); }); + } + for (auto& item : config.nullItems) + add(item.get(), TAG_REVIVE_EFFECT, [&](int id) { return effects.GetNullEffectNum(id); }); + return revives; +} + +// (ExtraLives.cpp's PlayerHasAnyReviveItem) The lives that keep a dead player's run saved: the HUD's and every mod +// revive, hidden ones too. +int extra_lives_all_get(Entity_Player& player) +{ + return player.GetExtraLives() + custom_revives_get(player, REVIVE_COUNT_ALL).lives; +} + // 007a2220's MC_PRE_PLAYER_REVIVE. Whether a mod returned false, which keeps the player dead. bool player_revive_is_cancelled(Entity_Player& player) { @@ -718,3 +774,33 @@ bool hud_trinket_pre_render(PlayerHUD& hud, int slot, Vector& position, float& s lua_pop(state, 1); return isDrawn; } + +// MC_EVALUATE_MULTI_SHOT_PARAMS, after the legacy MC_POST_PLAYER_GET_MULTI_SHOT_PARAMS (main_ex.lua's +// _RunGetMultiShotParamsCallbackWithLegacyCompat), filtered by the character: a MultiShotParams a mod returned +// replaces the params. A call inside it for the same player and weapon skips it. +void multi_shot_params_evaluate(Entity_Player& player, Weapon_MultiShotParams& params, int weaponType) +{ + static std::map> evaluating; + LuaEngine& engine = lua_engine_get(); + bool isEnabled = engine.is_callback_enabled(MC_EVALUATE_MULTI_SHOT_PARAMS) || + engine.is_callback_enabled(MC_POST_PLAYER_GET_MULTI_SHOT_PARAMS); + std::set& weapons = evaluating[player.playerIndex]; + if (!isEnabled || !weapons.insert(weaponType).second) return; + + lua_State* state = engine.state; + lua_getglobal(state, "_RunGetMultiShotParamsCallbackWithLegacyCompat"); + lua_push(state, player.playerType); + lua_push(state, &player); + lua_push(state, params); + lua_push(state, weaponType); + if (lua_pcall(state, 4, 1, 0) != LUA_OK) lua_error_log(state, "EvaluateMultiShotParams"); + else + { + auto* result = (Weapon_MultiShotParams*)lua_object_test(state, -1, LUA_CLASS_MULTI_SHOT_PARAMS); + if (result) params = *result; + else if (lua_isuserdata(state, -1)) + log_printf(LOG_ERROR, "Invalid userdata returned in MC_EVALUATE_MULTI_SHOT_PARAMS!"); + lua_pop(state, 1); + } + weapons.erase(weaponType); +} diff --git a/src/repentogon/player.h b/src/repentogon/player.h index 2fe24c2..b96b3f4 100644 --- a/src/repentogon/player.h +++ b/src/repentogon/player.h @@ -15,6 +15,7 @@ struct EntityRef; struct ItemConfig_Item; struct PlayerHUD; struct TemporaryEffect; +struct Weapon_MultiShotParams; // The hearts MC_PRE and MC_POST_PLAYER_ADD_HEARTS tell apart (Lua's AddHealthType), as their filter bits. enum AddHealthType : int @@ -107,6 +108,20 @@ struct ActiveItemRender extern ActiveItemRender activeItemRender; +// Which revives of mods' items count: those the HUD shows, or the hidden ones too. +enum ReviveCount +{ + REVIVE_COUNT_SHOWN, + REVIVE_COUNT_ALL +}; + +// The extra lives mods' items give through their revive custom tags, and whether one only may revive (the HUD's "?"). +struct CustomRevives +{ + int lives = 0; + bool isChance = false; +}; + bool player_damage_is_cancelled(Entity_Player& player, float damage, uint64_t damageFlags, const EntityRef& source, int countdown); int hearts_pre_add(Entity_Player& player, const HeartsAdd& add); @@ -134,6 +149,8 @@ void costume_post_add(Entity_Player& player, ItemConfig_Item* item, bool isItemS bool costume_pre_remove(Entity_Player& player, ItemConfig_Item* item); void costume_post_remove(Entity_Player& player, ItemConfig_Item* item); bool player_revive_is_cancelled(Entity_Player& player); +CustomRevives custom_revives_get(Entity_Player& player, ReviveCount count); +int extra_lives_all_get(Entity_Player& player); void player_revive_post(Entity_Player& player); bool costumes_shuffle_is_cancelled(Entity_Player& player, uint32_t seed); void costumes_shuffle_post(Entity_Player& player, uint32_t seed); @@ -154,5 +171,6 @@ void hud_hearts_post_render(PlayerHUD& hud, const HudHeartsDraw& draw); bool hud_active_item_pre_render(PlayerHUD& hud, const HudActiveDraw& draw); void hud_active_item_post_render(PlayerHUD& hud, const HudActiveDraw& draw); bool hud_trinket_pre_render(PlayerHUD& hud, int slot, Vector& position, float& scale, Vector& cropOffset); +void multi_shot_params_evaluate(Entity_Player& player, Weapon_MultiShotParams& params, int weaponType); void player_api_register(lua_State* state); void player_classes_api_register(lua_State* state); diff --git a/src/repentogon/player_api.cpp b/src/repentogon/player_api.cpp index c9296ac..400123b 100644 --- a/src/repentogon/player_api.cpp +++ b/src/repentogon/player_api.cpp @@ -17,6 +17,7 @@ #include "repentogon/items.h" #include "repentogon/options.h" #include "repentogon/player.h" +#include "repentogon/weapons.h" #include #include @@ -723,6 +724,21 @@ static int head_direction_set(lua_State* state) return 0; } +// SetWeapon: a Weapon into a slot from 0 to 4, the one there left to whoever held it, as REPENTOGON overwrites it. +static int weapon_set(lua_State* state) +{ + Entity_Player& player = lua_get(state, 1); + WeaponData& data = lua_get(state, 2); + int slot = (int)luaL_checkinteger(state, 3); + if (slot < 0 || slot > WEAPON_SLOT_LAST) return luaL_argerror(state, 2, "Index must be between 0 and 4"); + + (void)player.weapons[slot].release(); + player.weapons[slot].reset(data.weapon); + data.player = &player; + data.slot = slot; + return 0; +} + // Registers REPENTOGON's functions on EntityPlayer, in the class begun last, over the vanilla ones it changes. static void player_state_api_register(lua_State* state) { @@ -934,16 +950,19 @@ static void player_actions_api_register(lua_State* state) {"GetVoidedCollectiblesList", voided_collectibles_get}, {"GetActiveWeaponNumFired", weapon_fired_count_get}, {"GetCostumeSpriteDescs", costume_descs_get}, + {"SetWeapon", weapon_set}, }; lua_functions_add(state, functions); lua_method(state, "HasCollectible", - [](P& player, int id, LuaOptionalBool isIgnoreModifiers, LuaOptionalBool) { + [](P& player, int id, LuaOptionalBool isIgnoreModifiers, LuaOptionalBool isIgnoreSpoof) { + item_spoof_lua_request(isIgnoreSpoof.value); return player.HasCollectible(id, isIgnoreModifiers.value ? ITEM_CHECK_OWNED : ITEM_CHECK_MODIFIED); }); lua_method(state, "GetCollectibleNum", [](P& player, int id, LuaOptionalBool isOnlyTrueItems, LuaOptionalBool isIgnoreSpoof) { ItemCheck check = isOnlyTrueItems.value ? ITEM_CHECK_OWNED : ITEM_CHECK_MODIFIED; + item_spoof_lua_request(isIgnoreSpoof.value); if (!isIgnoreSpoof.value) return player.GetCollectibleNum(id, check); return hook_inner_call([&] { return player.GetCollectibleNum(id, check); }); }); @@ -952,14 +971,21 @@ static void player_actions_api_register(lua_State* state) LuaDefault varData, LuaDefault pool) { player.AddCollectible(id, charge.value, isFirstTime.value, slot.value, varData.value, pool.value); }); - lua_method(state, "HasTrinket", [](P& player, uint32_t id, LuaOptionalBool isIgnoreModifiers, LuaOptionalBool) { + lua_method(state, "HasTrinket", [](P& player, uint32_t id, LuaOptionalBool isIgnoreModifiers, + LuaOptionalBool isIgnoreSpoof) { + item_spoof_lua_request(isIgnoreSpoof.value); if (!isIgnoreModifiers.value) return player.GetTrinketMultiplier(id) > 0; return player.HasTrinket(id, ITEM_CHECK_OWNED); }); lua_method(state, "GetTrinketMultiplier", - [](P& player, uint32_t id, LuaOptionalBool) { return player.GetTrinketMultiplier(id); }); - lua_method(state, "HasGoldenTrinket", - [](P& player, uint32_t id, LuaOptionalBool) { return player.HasGoldenTrinket(id); }); + [](P& player, uint32_t id, LuaOptionalBool isIgnoreSpoof) { + item_spoof_lua_request(isIgnoreSpoof.value); + return player.GetTrinketMultiplier(id); + }); + lua_method(state, "HasGoldenTrinket", [](P& player, uint32_t id, LuaOptionalBool isIgnoreSpoof) { + item_spoof_lua_request(isIgnoreSpoof.value); + return player.HasGoldenTrinket(id); + }); lua_method(state, "AddCacheFlags", [](P& player, int flags, LuaOptionalBool isEvaluate) { player.AddCacheFlags((uint32_t)flags); if (isEvaluate.value) player.EvaluateItems(); @@ -1160,6 +1186,7 @@ void player_api_register(lua_State* state) player_state_api_register(state); player_actions_api_register(state); player_effects_api_register(state); + item_spoof_api_register(state); } // Registers REPENTOGON's CostumeSpriteDesc, EntityConfigPlayer and EntityConfigBaby. diff --git a/src/repentogon/player_config.cpp b/src/repentogon/player_config.cpp new file mode 100644 index 0000000..692222b --- /dev/null +++ b/src/repentogon/player_config.cpp @@ -0,0 +1,442 @@ +#include "repentogon/player_config.h" +#include "entity/config.h" +#include "entity/player/player.h" +#include "game/manager.h" +#include "game/mod_manager.h" +#include "repentogon/achievements.h" +#include "repentogon/items.h" +#include "repentogon/options.h" +#include "repentogon/stats.h" +#include +#include +#include + +constexpr float RANGE_MODIFIER_SCALE = 40; +constexpr float LEGACY_TEARS_NEGATIVE_SCALE = 0.686655f; +constexpr int HEALTH_TYPE_LAST = 4; +constexpr int BABY_HIDDEN_ACHIEVEMENT = 9999; +constexpr int BABY_RANDOM_FALLBACK = 71; +constexpr int BABY_RANDOM_SHIFT = 35; +constexpr const char* BABIES_XML = "babies.xml"; +constexpr const char* EDEN_HAIR_XML = "edenhair.xml"; + +// The characters whose tears bleed without anything else, REPENTOGON's bloodytears default. +constexpr std::array BLOODY_TEARS_PLAYERS = {PLAYER_ESAU, PLAYER_JUDAS_B, PLAYER_LAZARUS2_B, PLAYER_BETHANY_B}; + +// The attribute of each PlayerStat. +constexpr std::array PLAYER_STAT_ATTRIBUTES = { + "tearsmodifier", "tearsmultiplier", "damagemodifier", "damagemultiplier", + "shotspeedmodifier", "speedmodifier", "rangemodifier", "luckmodifier"}; + +// The layers of a modded character's menu page its achievement hides while locked, and the one it shows then. +constexpr std::array PAGE_UNLOCKED_LAYERS = { + "Item Name", "Item Name 2", "Item Name 3", "Item Icon", "Item Icon 2", "Item Icon 3", + "Power Stat", "Speed Stat", "Life Stat", "Power Icon", "Speed Icon", "Life Icon"}; +constexpr std::string_view PAGE_LOCKED_LAYER = "Unlocked By"; + +// The lists a players.xml name may stand for an id of. +enum IdList +{ + ID_LIST_COLLECTIBLES, + ID_LIST_TRINKETS, + ID_LIST_CARDS, + ID_LIST_SOUNDS +}; + +// An id as XMLData's isvalidid takes it: a whole number strtol reads to the end, nonzero unless written "0". +static bool is_id_text(std::string_view text) +{ + std::string copy(text); + char* end = nullptr; + long id = std::strtol(copy.c_str(), &end, 0); + return !copy.empty() && *end == '\0' && (id != 0 || copy == "0"); +} + +static int text_int(std::string_view text) +{ + return std::atoi(std::string(text).c_str()); +} + +// The id a name stands for in a list (the last entry of the name, as XMLData's byname keeps it), or -1. +static int id_by_name_find(IdList list, std::string_view name) +{ + ItemConfig& items = g_manager->itemConfig; + auto last = [&](auto& entries, auto entryName) { + for (auto entry = entries.rbegin(); entry != entries.rend(); ++entry) + if (*entry && entryName(**entry) == name) return (int)(*entry)->id; + return -1; + }; + + switch (list) + { + case ID_LIST_COLLECTIBLES: + { + auto found = items.collectibleNameMap.find(name); + return found == items.collectibleNameMap.end() ? -1 : found->second; + } + case ID_LIST_TRINKETS: + return last(items.trinkets, [](auto& item) -> std::string& { return item.name; }); + case ID_LIST_CARDS: + return last(items.cards, [](auto& card) -> std::string& { return card.name; }); + case ID_LIST_SOUNDS: + for (SoundEffect& sound : g_manager->sfxManager.sounds | std::views::reverse) + if (sound.name == name) return sound.id; + return -1; + } + return -1; +} + +// XMLData's ComaSeparatedNamesToIds: the ids of a comma separated list, numbers as written and names looked up, the +// names that find nothing dropped. +static std::vector ids_parse(std::string_view text, IdList list) +{ + std::vector ids; + + for (size_t start = 0; start <= text.size();) + { + size_t end = std::min(text.find(',', start), text.size()); + std::string_view piece = text.substr(start, end - start); + int id = is_id_text(piece) ? text_int(piece) : id_by_name_find(list, piece); + if (is_id_text(piece) || id >= 0) ids.push_back(id); + start = end + 1; + } + + return ids; +} + +// The id a single valued attribute names (SingleValXMLParamParse), when it is a name that finds one. +static std::optional id_named_get(DataNode node, std::string_view attribute, IdList list) +{ + std::optional text = node_attr_find(node, attribute); + if (!text || is_id_text(*text)) return std::nullopt; + + int id = id_by_name_find(list, *text); + return id >= 0 ? std::optional(id) : std::nullopt; +} + +// A boolean REPENTOGON reads strictly: "true" or "false", anything else leaving the default. +static void bool_override_read(XmlAttributes& attributes, std::string_view name, bool& value) +{ + auto found = attributes.find(name); + if (found != attributes.end() && (found->second == "true" || found->second == "false")) + value = found->second == "true"; +} + +// A stat modifier's float, logged and skipped when it is not one. +static std::optional stat_parse(std::string_view name, const std::string& text) +{ + char* end = nullptr; + float value = std::strtof(text.c_str(), &end); + if (end != text.c_str()) return value; + + log_printf(LOG_INFO, "[EntityConfigEx::PlayerEx] Invalid xml value `%s` for attribute `%.*s`\n", text.c_str(), + (int)name.size(), name.data()); + return std::nullopt; +} + +std::string_view PlayerConfigEx::attribute_get(std::string_view name) +{ + auto found = attributes.find(name); + return found == attributes.end() ? std::string_view() : std::string_view(found->second); +} + +// (XMLData.cpp, EntityConfigEx.cpp, NullItemsAndCostumes.cpp, XMLPlayerExtras.cpp) What REPENTOGON reads of a +// after the original: its attributes, a mod's items, pocket active, trinket and card by name, a mod's costume +// by its costumes2.xml id, the stat modifiers and the forced looks. A character hidden until an achievement is not +// hidden. +void player_config_ex_load(EntityConfig_Player& player, DataNode node, ModEntry* mod) +{ + PlayerConfigEx& ex = player.ex; + XmlAttributes& attributes = ex.attributes; + + attributes = xml_attributes_read(node); + if (!attributes.contains("achievement") && attributes.contains("hideachievement")) + attributes["achievement"] = attributes["hideachievement"]; + if (player.isHidden && attributes.contains("hideachievement")) player.isHidden = false; + + if (mod) + { + if (std::optional items = node_attr_find(node, "items")) + if (std::vector ids = ids_parse(*items, ID_LIST_COLLECTIBLES); !ids.empty()) player.collectibles = ids; + if (std::optional id = id_named_get(node, "pocketActive", ID_LIST_COLLECTIBLES)) player.pocketActiveID = *id; + if (std::optional id = id_named_get(node, "trinket", ID_LIST_TRINKETS)) player.trinket = *id; + if (std::optional id = id_named_get(node, "card", ID_LIST_CARDS)) player.card = *id; + + std::string_view costume = ex.attribute_get("modcostume"); + auto found = mod->nullCostumeIdMap.find(text_int(costume)); + if (player.costumeID == -1 && !costume.empty() && found != mod->nullCostumeIdMap.end()) + player.costumeID = found->second; + } + + if (attributes.contains("firedelaymodifier")) + if (std::optional legacy = stat_parse("firedelaymodifier", attributes["firedelaymodifier"])) + ex.statModifiers[PLAYER_STAT_TEARS_MODIFIER] = *legacy < 0 ? *legacy * LEGACY_TEARS_NEGATIVE_SCALE : *legacy; + for (int stat = 0; stat < PLAYER_STAT_COUNT; stat++) + if (auto found = attributes.find(PLAYER_STAT_ATTRIBUTES[stat]); found != attributes.end()) + if (std::optional value = stat_parse(found->first, found->second)) ex.statModifiers[stat] = value; + + ex.isNoShake = std::ranges::find(ALT_PORTRAIT_PLAYERS, player.id) != ALT_PORTRAIT_PLAYERS.end(); + ex.isBloodyTears = std::ranges::find(BLOODY_TEARS_PLAYERS, player.id) != BLOODY_TEARS_PLAYERS.end(); + bool_override_read(attributes, "noshake", ex.isNoShake); + bool_override_read(attributes, "bloodytears", ex.isBloodyTears); + ex.isFlying = ex.attribute_get("flying") == "true"; +} + +// Counts each id of an innate list (ParseCommaSeparatedIdList keeps the positive ones). +static void innate_ids_count(std::string_view text, IdList list, std::map& counts) +{ + counts.clear(); + for (int id : ids_parse(text, list)) + if (id > 0) counts[id]++; +} + +// A co-op baby from a mod's babies.xml, as XMLData merges it into the game's: the next id, the game's root before its +// skin, its achievement by number or name, never unlocked when hidden. +static void mod_baby_add(DataNode node, std::string_view root) +{ + std::vector& babies = g_manager->entityConfig.babies; + XmlAttributes attributes = xml_attributes_read(node); + EntityConfig_Baby baby; + + for (EntityConfig_Baby& other : babies) baby.id = std::max(baby.id, other.id); + baby.id++; + baby.name = attributes["name"]; + baby.gfx = std::string(root) + attributes["skin"]; + baby.achievementID = attributes.contains("achievement") ? achievement_id_parse(attributes["achievement"]) : -1; + if (attributes["hidden"] == "true") baby.achievementID = BABY_HIDDEN_ACHIEVEMENT; + if (baby.achievementID <= 0) baby.achievementID = -1; + babies.push_back(baby); +} + +// After the mods' content loaded: each character's innate items and trinkets by id or name (ItemSpoofSystem.cpp), +// the mods' co-op babies and Eden's hairstyles (EntityConfigEx.cpp). +void player_content_post_load() +{ + EntityConfig& config = g_manager->entityConfig; + + for (EntityConfig_Player& player : config.players) + { + innate_ids_count(player.ex.attribute_get("innateitems"), ID_LIST_COLLECTIBLES, player.ex.innateCollectibles); + innate_ids_count(player.ex.attribute_get("innatetrinkets"), ID_LIST_TRINKETS, player.ex.innateTrinkets); + } + + Data vanilla; + data_load(vanilla, g_manager->modManager.TryRedirectPath(BABIES_XML)); + std::optional vanillaRoot = data_root_get(vanilla, "babies"); + std::string root(vanillaRoot ? node_attr(*vanillaRoot, "root") : ""); + content_files_load(BABIES_XML, [&](Data& data, ModEntry&) { + if (std::optional babies = data_root_get(data, "babies")) + for (DataNode baby : node_children(*babies)) mod_baby_add(baby, root); + }); + + content_files_load(EDEN_HAIR_XML, [&](Data& data, ModEntry&) { + std::optional hairs = data_root_get(data, "edenhair"); + if (!hairs) return; + for (DataNode hair : node_children(*hairs)) + { + XmlAttributes attributes = xml_attributes_read(hair, {*hairs}); + std::string path = attributes["root"] + attributes["gfx"]; + if (!path.empty()) config.edenHair.push_back(path); + } + }); +} + +// EntityConfigEx::GetPlayerEx: a character's additions, none for Isaac or a type past the characters. +PlayerConfigEx* player_config_ex_get(int playerType) +{ + std::vector& players = g_manager->entityConfig.players; + return playerType > 0 && playerType < (int)players.size() ? &players[playerType].ex : nullptr; +} + +// An attribute of a character's , empty without it (XMLStuff.PlayerData). +std::string_view player_attribute_get(int playerType, std::string_view name) +{ + EntityConfig_Player* player = g_manager->entityConfig.GetPlayer(playerType); + return player ? player->ex.attribute_get(name) : std::string_view(); +} + +// An achievement an attribute names: its number, or the achievement of the name (-1 for none). +int achievement_id_parse(std::string_view text) +{ + std::string copy(text); + char* end = nullptr; + long id = std::strtol(copy.c_str(), &end, 0); + return id == 0 && end == copy.c_str() ? achievement_id_find(text) : (int)id; +} + +// IsAchievementUnlockedByXmlString: whether the achievement an attribute names is unlocked, false for none. +bool is_achievement_text_unlocked(std::string_view text) +{ + return !text.empty() && g_manager->persistentGameData.Unlocked(achievement_id_parse(text)); +} + +// IsCharacterUnlockedRgon: whether a character's achievement, if it names one, is unlocked. +bool is_player_unlocked(int playerType) +{ + std::string_view achievement = player_attribute_get(playerType, "achievement"); + return achievement.empty() || is_achievement_text_unlocked(achievement); +} + +// IsCharacterHiddenByAchievementRgon: whether a modded character waits on its hideachievement, a tainted one on its +// regular twin's. +bool is_player_hidden_by_achievement(int playerType) +{ + std::vector& players = g_manager->entityConfig.players; + if (playerType < PLAYER_TYPE_COUNT || playerType >= (int)players.size()) return false; + + EntityConfig_Player& player = players[playerType]; + if (!player.bSkinParentName.empty()) + { + for (EntityConfig_Player& other : players | std::views::drop(PLAYER_TYPE_COUNT)) + if (other.id != player.id && other.name == player.bSkinParentName && other.bSkinParentName.empty()) + return is_player_hidden_by_achievement(other.id); + return false; + } + + std::string_view achievement = player.ex.attribute_get("hideachievement"); + return !achievement.empty() && !is_achievement_text_unlocked(achievement); +} + +// EvaluateStats' ApplyPlayerStatModifier: a character's multiplier (a positive one) or modifier on a stat, range in +// tiles. +void player_stat_modify(Entity_Player& player, PlayerStat stat, float& value) +{ + PlayerConfigEx* ex = player_config_ex_get(player.playerType); + if (!ex || !ex->statModifiers[stat]) return; + + float modifier = *ex->statModifiers[stat]; + if (stat == PLAYER_STAT_TEARS_MULTIPLIER || stat == PLAYER_STAT_DAMAGE_MULTIPLIER) + { + if (modifier > 0) value *= modifier; + return; + } + value += stat == PLAYER_STAT_RANGE_MODIFIER ? modifier * RANGE_MODIFIER_SCALE : modifier; +} + +// (XMLPlayerExtras.cpp) After Init, the hearts and giga bombs a character's players.xml entry starts it with, then +// the hearts settled. It reads the entry of the subtype, as REPENTOGON does for co-op babies too. REPENTOGON settles +// the hearts of every player: this only of one the entry gave any. +void player_hearts_init(Entity_Player& player, int subType) +{ + EntityConfig_Player* config = g_manager->entityConfig.GetPlayer(subType); + if (!config) return; + + PlayerConfigEx& ex = config->ex; + std::pair hearts[] = { + {"heartcontainers", &player.maxHearts}, {"redhearts", &player.redHearts}, + {"bonehearts", &player.boneHearts}, {"soulhearts", &player.soulHearts}, + {"eternalheart", &player.eternalHearts}, {"goldenhearts", &player.goldenHearts}, + {"brokenhearts", &player.brokenHearts}}; + bool isSet = false; + + for (auto [name, field] : hearts) + if (std::string_view value = ex.attribute_get(name); !value.empty()) + { + *field = text_int(value); + isSet = true; + } + if (std::string_view black = ex.attribute_get("blackhearts"); !black.empty()) + { + player.AddBlackHearts(text_int(black)); + isSet = true; + } + if (std::string_view rotten = ex.attribute_get("rottenhearts"); !rotten.empty()) + { + player.AddRottenHearts(text_int(rotten) * 2, false); + isSet = true; + } + if (std::string_view giga = ex.attribute_get("gigabombs"); !giga.empty()) + { + player.AddBombs(text_int(giga)); + player.AddGigaBombs(text_int(giga)); + isSet = true; + } + if (!isSet) return; + + player.UpdateHeartDependentEffects(); + player.ClampGoldenHearts(false); + player.update_bone_hearts(); +} + +// (XMLPlayerExtras.cpp) A character's healthlimit, which replaces every other limit. +std::optional player_health_limit_get(int playerType) +{ + std::string_view limit = player_attribute_get(playerType, "healthlimit"); + return limit.empty() ? std::nullopt : std::optional(text_int(limit)); +} + +// (CustomCallbacks.cpp) The health type a character's healthtype names (0 to 4), or its own. +int player_health_type_get(int playerType, int healthType) +{ + std::string_view text = player_attribute_get(playerType, "healthtype"); + int xmlType = text.empty() ? -1 : text_int(text); + return xmlType >= 0 && xmlType <= HEALTH_TYPE_LAST ? xmlType : healthType; +} + +// (PlayerTags.cpp) Whether a character's portrait stays still on the stage and boss screens. +bool is_player_no_shake(int playerType) +{ + PlayerConfigEx* ex = player_config_ex_get(playerType); + return ex && ex->isNoShake; +} + +// (ASMPlayer.cpp) Whether a character's tears bleed of its own. +bool is_player_bloody_tears(Entity_Player& player) +{ + PlayerConfigEx* ex = player_config_ex_get(player.playerType); + return ex && ex->isBloodyTears; +} + +// (ASMPlayer.cpp) The sound a character's hurtsound or deathsound names by id or name, else the game's. +int player_sound_get(Entity_Player& player, PlayerSound sound) +{ + int fallback = sound == PLAYER_SOUND_HURT ? SOUND_ISAAC_HURT_GRUNT : SOUND_ISAACDIES; + std::string_view text = player_attribute_get(player.playerType, sound == PLAYER_SOUND_HURT ? "hurtsound" : "deathsound"); + if (text.empty()) return fallback; + + int id = is_id_text(text) ? text_int(text) : id_by_name_find(ID_LIST_SOUNDS, text); + bool isFound = std::ranges::any_of(g_manager->sfxManager.sounds, [&](SoundEffect& effect) { return effect.id == id; }); + return isFound && id > 0 ? id : fallback; +} + +// (EvaluateStats.cpp) Before MC_EVALUATE_CACHE: a character's luck modifier and the items' luck, and its forced flight +// or the flight of an item's flying custom tag. +void player_cache_pre_evaluate(Entity_Player& player, int cacheFlag) +{ + if (cacheFlag & CACHE_LUCK) + { + player_stat_modify(player, PLAYER_STAT_LUCK_MODIFIER, player.luck); + item_stat_add(player, ITEM_STAT_LUCK_UP, player.luck); + } + else if (cacheFlag & CACHE_FLYING) + { + PlayerConfigEx* ex = player_config_ex_get(player.playerType); + if ((ex && ex->isFlying) || item_custom_tag_is_held(player, CUSTOM_TAG_FLYING, CUSTOM_TAG_FLYING_EFFECT)) + player.canFly = true; + } +} + +// EntityConfigEx's GetRandomBaby: an unlocked co-op baby of all of them, mods' included, drawn from the seed. +EntityConfig_Baby& baby_random_get(uint32_t seed) +{ + std::vector& babies = g_manager->entityConfig.babies; + std::vector candidates; + RNG rng{}; + + for (EntityConfig_Baby& baby : babies) + if (baby.achievementID <= 0 || g_manager->persistentGameData.Unlocked(baby.achievementID)) + candidates.push_back(&baby); + if (candidates.empty()) return babies.at(babies.size() > BABY_RANDOM_FALLBACK ? BABY_RANDOM_FALLBACK : 0); + + rng.SetSeed(seed > 0 ? seed : 1, BABY_RANDOM_SHIFT); + return *candidates[rng.RandomInt((uint32_t)candidates.size())]; +} + +// (XMLPlayerExtras.cpp) A modded character's menu page as its achievement leaves it: the items and stats shown when +// unlocked, "Unlocked By" when not. +void character_page_lock(ANM2& page, bool isUnlocked) +{ + for (std::string_view name : PAGE_UNLOCKED_LAYERS) + if (LayerState* layer = page.GetLayer(name)) layer->isVisible = isUnlocked; + if (LayerState* layer = page.GetLayer(PAGE_LOCKED_LAYER)) layer->isVisible = !isUnlocked; +} diff --git a/src/repentogon/player_config.h b/src/repentogon/player_config.h new file mode 100644 index 0000000..4b3ba17 --- /dev/null +++ b/src/repentogon/player_config.h @@ -0,0 +1,71 @@ +#pragma once + +#include "repentogon/options.h" +#include "repentogon/xml.h" +#include +#include +#include +#include +#include + +struct ANM2; +struct EntityConfig_Baby; +struct EntityConfig_Player; +struct Entity_Player; +struct ModEntry; + +// The player stats players.xml adjusts (REPENTOGON's EvaluateStats::PlayerStat). +enum PlayerStat +{ + PLAYER_STAT_TEARS_MODIFIER, + PLAYER_STAT_TEARS_MULTIPLIER, + PLAYER_STAT_DAMAGE_MODIFIER, + PLAYER_STAT_DAMAGE_MULTIPLIER, + PLAYER_STAT_SHOT_SPEED_MODIFIER, + PLAYER_STAT_SPEED_MODIFIER, + PLAYER_STAT_RANGE_MODIFIER, + PLAYER_STAT_LUCK_MODIFIER, + PLAYER_STAT_COUNT +}; + +// The voice lines a character's players.xml entry may replace. +enum PlayerSound +{ + PLAYER_SOUND_HURT, + PLAYER_SOUND_DEATH +}; + +// What REPENTOGON keeps of a character's beyond the original (XMLStuff.PlayerData and EntityConfigEx:: +// PlayerEx): every attribute by lowercase name, the stat modifiers, the innate collectibles and trinkets by id and +// count, and the looks it forces. +struct PlayerConfigEx +{ + XmlAttributes attributes; + std::map innateCollectibles; + std::map innateTrinkets; + std::array, PLAYER_STAT_COUNT> statModifiers; + bool isBloodyTears = false; + bool isFlying = false; + bool isNoShake = false; + + std::string_view attribute_get(std::string_view name); +}; + +void player_config_ex_load(EntityConfig_Player& player, DataNode node, ModEntry* mod); +void player_content_post_load(); +PlayerConfigEx* player_config_ex_get(int playerType); +std::string_view player_attribute_get(int playerType, std::string_view name); +int achievement_id_parse(std::string_view text); +bool is_achievement_text_unlocked(std::string_view text); +bool is_player_unlocked(int playerType); +bool is_player_hidden_by_achievement(int playerType); +void player_stat_modify(Entity_Player& player, PlayerStat stat, float& value); +void player_hearts_init(Entity_Player& player, int subType); +std::optional player_health_limit_get(int playerType); +int player_health_type_get(int playerType, int healthType); +bool is_player_no_shake(int playerType); +bool is_player_bloody_tears(Entity_Player& player); +int player_sound_get(Entity_Player& player, PlayerSound sound); +void player_cache_pre_evaluate(Entity_Player& player, int cacheFlag); +EntityConfig_Baby& baby_random_get(uint32_t seed); +void character_page_lock(ANM2& page, bool isUnlocked); diff --git a/src/repentogon/repentogon.cpp b/src/repentogon/repentogon.cpp index a2caa6a..f1c2302 100644 --- a/src/repentogon/repentogon.cpp +++ b/src/repentogon/repentogon.cpp @@ -8,6 +8,8 @@ #include "repentogon/api_game.h" #include "repentogon/lua_render.h" #include "repentogon/options.h" +#include "repentogon/save_state_manager.h" +#include "repentogon/ui_patches.h" constexpr const char* SCRIPTS_FOLDER = "repentogon/scripts/"; constexpr const char* ENUMS_SCRIPT = "enums_ex.lua"; @@ -15,10 +17,12 @@ constexpr const char* MAIN_SCRIPT = "main_ex.lua"; constexpr const char* GLOBAL = "REPENTOGON"; constexpr const char* RUN_CALLBACK_TWO_PARAMS = "_RunCallbackWithTwoParams"; -// Logs that a mod's callback failed, where REPENTOGON raises its error display. +// Logs that a mod's callback failed and raises REPENTOGON's error display. static int mod_error_raise(lua_State* state) { - log_printf(LOG_INFO, "%s is causing errors!\n", luaL_checkstring(state, 1)); + std::string message = std::string(luaL_checkstring(state, 1)) + " is causing errors!"; + log_printf(LOG_INFO, "%s\n", message.c_str()); + error_display_raise(message); return 0; } @@ -61,8 +65,9 @@ std::string repentogon_script_path(std::string_view path) // Runs REPENTOGON's enums_ex.lua and main_ex.lua after the game's own scripts, as its LuaEngine::Init hook does. // debug opens again for them (main.lua closed it), os too unless vanilla parity is on, and _CBindings holds the -// internals main_ex.lua takes, cleared after. main_ex.lua replaces _RunCallback and _UnloadMod, which Init then takes, -// and adds _RunCallbackWithTwoParams. The REPENTOGON global is cleared while it is not exposed. +// internals main_ex.lua takes, cleared after, as is the _LuaBindings it gives back. main_ex.lua replaces _RunCallback +// and _UnloadMod, which Init then takes, and adds _RunCallbackWithTwoParams. The REPENTOGON global is cleared while it +// is not exposed. void repentogon_scripts_run(LuaEngine& engine) { lua_State* state = engine.state; @@ -78,6 +83,7 @@ void repentogon_scripts_run(LuaEngine& engine) {"GetModId", mod_id_get}, {"IsVanillaParity", vanilla_parity_get}}); internals_mod_data_register(state); + save_state_internals_register(state); lua_pushboolean(state, IS_REPENTOGON_EXPOSED); lua_table_set(state, -2, "IsExposed"); lua_namespace_plain_end(state); @@ -85,6 +91,7 @@ void repentogon_scripts_run(LuaEngine& engine) color_constructor_set(state); engine.RunScript(repentogon_script_path(ENUMS_SCRIPT)); engine.RunScript(repentogon_script_path(MAIN_SCRIPT)); + save_state_bindings_load(state); lua_pushnil(state); lua_setglobal(state, "_CBindings"); diff --git a/src/repentogon/save_state_id.h b/src/repentogon/save_state_id.h new file mode 100644 index 0000000..100f518 --- /dev/null +++ b/src/repentogon/save_state_id.h @@ -0,0 +1,45 @@ +#pragma once + +#include + +void save_state_id_clear(uint32_t id); +uint32_t save_state_id_copy(uint32_t id); +uint32_t save_state_id_make(); + +// The id REPENTOGON's SaveStateManager knows a saved entity, player or familiar by, for the data mods keep on it +// (EntitySaveStateManagement hijacks one of the state's fields for it). None until the state is saved with mods on. +// A copy gets an id of its own with the data copied, and the data goes with the state. +struct SaveStateId +{ + uint32_t id = 0; + + SaveStateId() = default; + SaveStateId(const SaveStateId& other) : id(other.id ? save_state_id_copy(other.id) : 0) {} + SaveStateId(SaveStateId&& other) noexcept : id(other.id) { other.id = 0; } + ~SaveStateId() + { + if (id) save_state_id_clear(id); + } + + SaveStateId& operator=(const SaveStateId& other) + { + if (this != &other) *this = SaveStateId(other); + return *this; + } + + SaveStateId& operator=(SaveStateId&& other) noexcept + { + if (this == &other) return *this; + if (id) save_state_id_clear(id); + id = other.id; + other.id = 0; + return *this; + } + + // Takes a new id, the data of the old one dropped. + void renew() + { + if (id) save_state_id_clear(id); + id = save_state_id_make(); + } +}; diff --git a/src/repentogon/save_state_manager.cpp b/src/repentogon/save_state_manager.cpp new file mode 100644 index 0000000..904f832 --- /dev/null +++ b/src/repentogon/save_state_manager.cpp @@ -0,0 +1,406 @@ +#include "repentogon/save_state_manager.h" +#include "entity/save_state.h" +#include "game/game.h" +#include "game/manager.h" +#include "repentogon/api.h" +#include "repentogon/callbacks.h" +#include "repentogon/entities.h" +#include "repentogon/repentogon.h" +#include "repentogon/ui_patches.h" +#include +#include +#include +#include + +// (SaveStateManagement/) REPENTOGON's SaveStateManager: the data mods keep on entities, on their saved states and on +// the game's states (the save file's and the Glowing Hourglass's), which its scripts hold and the game tells about +// every save, restore, copy and clear. The rebuild gives each saved state an id of its own (SaveStateId) where +// REPENTOGON hijacks two of its fields, so the game's files stay vanilla. A state's place in the order a file writes +// them is its serialization id, which the same order on read finds again. +// Without mods nothing reaches Lua, and MC_ENTITY_SAVE and MC_ENTITY_RESTORE run on their own. + +constexpr const char* ESSM_FOLDER = "EntitySaveStateManagement"; +constexpr const char* ESSM_EXTENSION = ".dat"; +constexpr const char* LUA_BINDINGS = "_LuaBindings"; +constexpr const char* INIT_ERROR = "REPENTOGON failed to initialize!"; + +// The functions main_ex.lua hands over through _LuaBindings. +enum SaveStateBinding +{ + BINDING_NEW_ENTITY, + BINDING_DELETE_ENTITY, + BINDING_STORE_ENTITY, + BINDING_RESTORE_ENTITY, + BINDING_CLEAR_STATES, + BINDING_COPY_STATES, + BINDING_SERIALIZE, + BINDING_PRE_DESERIALIZE, + BINDING_DESERIALIZE, + BINDING_STORE_GAME_STATE, + BINDING_RESTORE_GAME_STATE, + BINDING_CLEAR_GAME_STATE, + BINDING_SERIALIZE_GAME_STATE, + BINDING_DESERIALIZE_GAME_STATE, + BINDING_DELETE_GAME_STATE, + BINDING_CLEANUP_STATE, + BINDING_COUNT +}; + +struct BindingName +{ + const char* table; + const char* name; +}; + +constexpr std::array BINDING_NAMES = {{{"EntityManager", "NewEntity"}, + {"EntityManager", "DeleteEntity"}, + {"ESSM", "StoreEntity"}, + {"ESSM", "RestoreEntity"}, + {"ESSM", "ClearStates"}, + {"ESSM", "CopyStates"}, + {"ESSM", "Serialize"}, + {"ESSM", "PreDeserialize"}, + {"ESSM", "Deserialize"}, + {"SSM", "StoreGameState"}, + {"SSM", "RestoreGameState"}, + {"SSM", "ClearGameState"}, + {"SSM", "SerializeGameState"}, + {"SSM", "DeserializeGameState"}, + {"SSM", "DeleteGameState"}, + {"SSM", "CleanupState"}}}; + +// A game state file's name and checksum, as the SSM reads them (GameStateSaveInfo). +struct GameStateInfo +{ + std::string fileName; + uint32_t checksum = 0; +}; + +// The mods holding saved entity data for a file, which PreDeserialize registers. +struct ModTables +{ + std::vector mods; +}; + +// The bound functions and the Lua state they live in, the last id given, and the ids of the states a file writes or +// reads while it does. +struct SaveStateBindings +{ + std::optional> collected; + std::array refs{}; + lua_State* state = nullptr; + uint32_t lastId = 0; +}; + +static SaveStateBindings bindings; + +// Whether mods' data is kept: the functions bound in the running Lua state, and a mod loaded. +static bool is_save_state_managed() +{ + if (!bindings.state || !g_luaEngine) return false; + LuaEngine& engine = lua_engine_get(); + return engine.state == bindings.state && !engine.mods.empty(); +} + +static void binding_argument_push(lua_State* state, const std::vector& ids) +{ + lua_createtable(state, (int)ids.size(), 0); + for (size_t i = 0; i < ids.size(); i++) + { + if (!ids[i]) continue; + lua_pushinteger(state, ids[i]); + lua_rawseti(state, -2, (lua_Integer)i + 1); + } +} + +static void binding_argument_push(lua_State* state, const GameStateInfo& info) +{ + lua_createtable(state, 0, 2); + lua_push(state, info.checksum); + lua_setfield(state, -2, "checksum"); + lua_push(state, info.fileName); + lua_setfield(state, -2, "fileName"); +} + +static void binding_argument_push(lua_State* state, const ModTables& tables) +{ + lua_createtable(state, (int)tables.mods.size(), 0); + for (size_t i = 0; i < tables.mods.size(); i++) + { + lua_rawgeti(state, LUA_REGISTRYINDEX, tables.mods[i]->tableRef); + lua_rawseti(state, -2, (lua_Integer)i + 1); + } +} + +static void binding_argument_push(lua_State* state, const std::vector& names) +{ + lua_array_push(state, names); +} + +template +static void binding_argument_push(lua_State* state, const T& value) +{ + lua_push(state, value); +} + +// Calls a bound function, logging its error. +template +static void binding_call(SaveStateBinding binding, const Args&... args) +{ + lua_State* state = bindings.state; + lua_rawgeti(state, LUA_REGISTRYINDEX, bindings.refs[binding]); + (binding_argument_push(state, args), ...); + if (lua_pcall(state, sizeof...(Args), 0, 0) != LUA_OK) lua_error_log(state, BINDING_NAMES[binding].name); +} + +// (LuaInit.cpp's bind_lua_internals, Patches/Init.cpp) Takes the functions main_ex.lua left in _LuaBindings, then +// clears it. One missing raises REPENTOGON's error display. +void save_state_bindings_load(lua_State* state) +{ + lua_getglobal(state, LUA_BINDINGS); + bool isBound = lua_istable(state, -1); + for (int binding = 0; isBound && binding < BINDING_COUNT; binding++) + { + lua_getfield(state, -1, BINDING_NAMES[binding].table); + if (lua_istable(state, -1)) lua_getfield(state, -1, BINDING_NAMES[binding].name); + else lua_pushnil(state); + isBound = lua_isfunction(state, -1); + if (!isBound) log_printf(LOG_INFO, "[ERROR] _LuaBindings.%s is not a function\n", BINDING_NAMES[binding].name); + bindings.refs[binding] = luaL_ref(state, LUA_REGISTRYINDEX); + lua_pop(state, 1); + } + lua_pop(state, 1); + bindings.state = isBound ? state : nullptr; + if (!isBound) error_display_raise(INIT_ERROR); + + lua_pushnil(state); + lua_setglobal(state, LUA_BINDINGS); +} + +// The file a mod's saved entity data for a game state file is in. +static std::filesystem::path essm_data_path(LuaMod& mod, std::string_view fileName) +{ + return std::filesystem::path(mod.directory) / ESSM_FOLDER / (std::string(fileName) + ESSM_EXTENSION); +} + +static std::filesystem::path essm_argument_path(lua_State* state) +{ + if (!lua_istable(state, 1)) luaL_argerror(state, 1, "Expected a table."); + LuaMod* mod = repentogon_mod_find(state, 1); + if (!mod) luaL_argerror(state, 1, "Invalid ModReference."); + return essm_data_path(*mod, luaL_checkstring(state, 2)); +} + +// GetEntitySaveStateId(saved entity): its id, which a state the game made without saving an entity takes now. +static int essm_id_get(lua_State* state) +{ + EntitySaveStateHandle& handle = lua_get(state, 1); + SaveStateId& id = (*handle.states)[handle.index].saveStateId; + if (!id.id) id.renew(); + lua_pushinteger(state, id.id); + return 1; +} + +// SaveData(mod, file name, data): writes a mod's saved entity data, its folder made first. +static int essm_data_save(lua_State* state) +{ + std::filesystem::path path = essm_argument_path(state); + size_t size = 0; + const char* data = luaL_checklstring(state, 3, &size); + std::error_code error; + std::filesystem::create_directories(path.parent_path(), error); + std::ofstream file(path, std::ios::binary); + if (!file) log_printf(LOG_INFO, "[ERROR] [ESSM] - unable to open Mod file for writing at \"%s\"\n", path.c_str()); + file.write(data, (std::streamsize)size); + return 0; +} + +// LoadData(mod, file name): a mod's saved entity data, nil when there is none. +static int essm_data_load(lua_State* state) +{ + std::ifstream file(essm_argument_path(state), std::ios::binary); + std::stringstream data; + data << file.rdbuf(); + if (file.is_open()) lua_push(state, data.str()); + else lua_pushnil(state); + return 1; +} + +// DeleteData(mod, file name): deletes a mod's saved entity data. +static int essm_data_delete(lua_State* state) +{ + std::error_code error; + std::filesystem::remove(essm_argument_path(state), error); + return 0; +} + +// (EntitySaveStateManagement.cpp's RegisterLuaInternals) Adds _CBindings.ESSM, which entity_save_state_manager.lua +// reads its ids and files through. +void save_state_internals_register(lua_State* state) +{ + lua_newtable(state); + lua_functions_add(state, {{"GetEntitySaveStateId", essm_id_get}, + {"SaveData", essm_data_save}, + {"LoadData", essm_data_load}, + {"DeleteData", essm_data_delete}}); + lua_table_set(state, -2, "ESSM"); +} + +uint32_t save_state_id_make() +{ + return ++bindings.lastId; +} + +void save_state_id_clear(uint32_t id) +{ + if (is_save_state_managed()) binding_call(BINDING_CLEAR_STATES, std::vector{id}); +} + +uint32_t save_state_id_copy(uint32_t id) +{ + if (!is_save_state_managed()) return 0; + uint32_t copy = save_state_id_make(); + binding_call(BINDING_COPY_STATES, std::vector{id}, std::vector{copy}); + return copy; +} + +// The id Lua knows an entity by: its GetPtrHash. +static lua_Integer entity_id_get(Entity& entity) +{ + return (lua_Integer)((uintptr_t)&entity ^ lua_engine_get().pointerMask); +} + +// (Patches/EntityManager.cpp) Tells the scripts an entity was made, or handed out again by its pool. +void entity_created_notify(Entity& entity) +{ + if (is_save_state_managed()) binding_call(BINDING_NEW_ENTITY, entity_id_get(entity)); +} + +// (EntityManager.cpp) Tells the scripts an entity left the room or was destroyed, its data dropped. +void entity_deleted_notify(Entity& entity) +{ + if (is_save_state_managed()) binding_call(BINDING_DELETE_ENTITY, entity_id_get(entity)); +} + +// Runs MC_ENTITY_SAVE for an entity the game saved, then keeps mods' data on it in its state under a new id. +void entity_store_notify(Entity& entity, SaveStateId& id) +{ + if (!is_save_state_managed()) return unfiltered_notify("EntitySave", MC_ENTITY_SAVE, &entity); + id.renew(); + binding_call(BINDING_STORE_ENTITY, &entity, entity_id_get(entity), id.id); +} + +// Gives an entity the game restored the data its state kept, then runs MC_ENTITY_RESTORE. +void entity_restore_notify(Entity& entity, uint32_t id) +{ + if (!is_save_state_managed()) return unfiltered_notify("EntityRestore", MC_ENTITY_RESTORE, &entity); + binding_call(BINDING_RESTORE_ENTITY, &entity, entity_id_get(entity), id); +} + +// A game state's slot: 0 for the save file's, 1 and 2 for the Glowing Hourglass's, -1 for another. +int game_state_slot_get(GameState& state) +{ + if (!g_manager || !g_game) return -1; + if (&state == &g_manager->gamestate) return 0; + + auto& slots = g_game->glowingHourglassStates; + auto slot = std::ranges::find_if(slots, [&](GlowingHourglassState& kept) { return &kept.gameState == &state; }); + return slot == slots.end() ? -1 : (int)(slot - slots.begin()) + 1; +} + +// Keeps mods' game data in a slot after the game saved its state there. +void game_state_store_notify(int slot) +{ + if (is_save_state_managed()) binding_call(BINDING_STORE_GAME_STATE, slot); +} + +// Gives mods back the game data of a slot before the game restores its state. +void game_state_restore_notify(int slot) +{ + if (is_save_state_managed()) binding_call(BINDING_RESTORE_GAME_STATE, slot); +} + +// Drops mods' game data of a cleared game state's slot. +void game_state_clear_notify(GameState& state) +{ + int slot = game_state_slot_get(state); + if (slot >= 0 && is_save_state_managed()) binding_call(BINDING_CLEAR_GAME_STATE, slot); +} + +// Resets mods' game data once the game was left. +void game_state_cleanup_notify() +{ + if (is_save_state_managed()) binding_call(BINDING_CLEANUP_STATE); +} + +// The name mods' files for a game state file take (local_gamestate1, local_rerunstate1), empty for one with no slot. +static std::string game_state_file_name(GameState& state, GameStateFile file) +{ + std::string_view path = file == GAME_STATE_FILE_RUN ? state.savePath : state.rerunPath; + std::string stem = std::filesystem::path(path).stem().string(); + if (stem.empty() || stem.back() < '1' || stem.back() > '3') return ""; + return (file == GAME_STATE_FILE_RUN ? "local_gamestate" : "local_rerunstate") + stem.substr(stem.size() - 1); +} + +// Deletes mods' game data files of a game state file. +void game_state_delete_notify(GameState& state, GameStateFile file) +{ + std::string name = game_state_file_name(state, file); + if (!name.empty() && is_save_state_managed()) binding_call(BINDING_DELETE_GAME_STATE, name); +} + +// Starts collecting the states a game state file writes or reads. +void game_state_collect_begin() +{ + bindings.collected.reset(); + if (is_save_state_managed()) bindings.collected.emplace(); +} + +void save_state_written(const SaveStateId& id) +{ + if (bindings.collected) bindings.collected->push_back(id.id); +} + +// Gives a state read from a file a new id. +void save_state_read(SaveStateId& id) +{ + if (!bindings.collected) return; + id.renew(); + bindings.collected->push_back(id.id); +} + +// Saves mods' data on the states a game state file wrote, then their game data. +void game_state_write_end(GameState& state, GameStateFile file) +{ + std::optional> ids = std::exchange(bindings.collected, std::nullopt); + std::string name = game_state_file_name(state, file); + if (!ids || name.empty()) return; + + binding_call(BINDING_SERIALIZE, *ids, name, state.checksum); + binding_call(BINDING_SERIALIZE_GAME_STATE, GameStateInfo{name, state.checksum}); +} + +// Loads mods' data on the states a game state file read, the mods holding some registered first, then their game +// data. +void game_state_read_end(GameState& state, GameStateFile file, bool isRead) +{ + std::optional> ids = std::exchange(bindings.collected, std::nullopt); + std::string name = game_state_file_name(state, file); + if (!ids || !isRead || name.empty()) return; + + ModTables tables; + std::vector modIds; + for (LuaMod& mod : lua_engine_get().mods) + { + std::error_code error; + if (!std::filesystem::exists(essm_data_path(mod, name), error)) continue; + tables.mods.push_back(&mod); + modIds.push_back(mod.scriptPath); + } + binding_call(BINDING_PRE_DESERIALIZE, tables, modIds); + + std::vector serializedIds(ids->size()); + std::iota(serializedIds.begin(), serializedIds.end(), 1); + binding_call(BINDING_DESERIALIZE, serializedIds, *ids, name, state.checksum); + binding_call(BINDING_DESERIALIZE_GAME_STATE, GameStateInfo{name, state.checksum}); +} diff --git a/src/repentogon/save_state_manager.h b/src/repentogon/save_state_manager.h new file mode 100644 index 0000000..75b9799 --- /dev/null +++ b/src/repentogon/save_state_manager.h @@ -0,0 +1,32 @@ +#pragma once + +#include "repentogon/save_state_id.h" + +struct Entity; +struct GameState; +struct lua_State; + +// Which of a save slot's files a game state is written to or read from. +enum GameStateFile +{ + GAME_STATE_FILE_RUN, + GAME_STATE_FILE_RERUN +}; + +void save_state_bindings_load(lua_State* state); +void save_state_internals_register(lua_State* state); +int game_state_slot_get(GameState& state); +void game_state_store_notify(int slot); +void game_state_restore_notify(int slot); +void game_state_clear_notify(GameState& state); +void game_state_delete_notify(GameState& state, GameStateFile file); +void game_state_cleanup_notify(); +void game_state_collect_begin(); +void game_state_write_end(GameState& state, GameStateFile file); +void game_state_read_end(GameState& state, GameStateFile file, bool isRead); +void save_state_written(const SaveStateId& id); +void save_state_read(SaveStateId& id); +void entity_created_notify(Entity& entity); +void entity_deleted_notify(Entity& entity); +void entity_store_notify(Entity& entity, SaveStateId& id); +void entity_restore_notify(Entity& entity, uint32_t id); diff --git a/src/repentogon/saves.cpp b/src/repentogon/saves.cpp index 5fd7a94..a0231b7 100644 --- a/src/repentogon/saves.cpp +++ b/src/repentogon/saves.cpp @@ -1,39 +1,41 @@ #include "repentogon/saves.h" #include "game/game.h" #include "game/manager.h" +#include "repentogon/achievements.h" #include "repentogon/callbacks.h" #include // (GameStateManagement.cpp) Runs a callback around a save or restore of a game state the game keeps, the save file's -// or a Glowing Hourglass slot's, then for a slot its hourglass callback with the slot. +// or a Glowing Hourglass slot's, then for a slot its hourglass callback with the slot. Mods' game data is restored +// before and kept after. void game_state_callbacks_run(GameState& state, int callback, int hourglassCallback) { - std::array& slots = g_game->glowingHourglassStates; - auto slot = std::ranges::find_if(slots, [&](GlowingHourglassState& kept) { return &kept.gameState == &state; }); - bool isHourglass = slot != slots.end(); - if (!isHourglass && &state != &g_manager->gamestate) return; + int slot = game_state_slot_get(state); + if (slot < 0) return; + if (callback == MC_PRE_GAME_STATE_RESTORE) game_state_restore_notify(slot); unfiltered_notify("GameState", callback); - if (isHourglass) unfiltered_notify("GlowingHourglass", hourglassCallback, (int)(slot - slots.begin())); + if (slot > 0) unfiltered_notify("GlowingHourglass", hourglassCallback, slot - 1); + if (callback == MC_POST_GAME_STATE_SAVE) game_state_store_notify(slot); } -// A rider saved for its minecart, which MC_ENTITY_SAVE reports once the minecart saved too. -static Entity* savedRider = nullptr; +// A rider saved for its minecart, and its state, which MC_ENTITY_SAVE reports once the minecart saved too. +static std::pair savedRider = {nullptr, nullptr}; -// (EntitySaveStateManagement.cpp) Runs MC_ENTITY_SAVE for an entity the room saved, a minecart's rider first. Whether -// it saved. +// (EntitySaveStateManagement.cpp) Runs MC_ENTITY_SAVE for an entity the room saved, a minecart's rider first, and +// keeps mods' data on them. Whether it saved. bool entity_save_hook(Room& room, Entity& entity, EntitySaveState& state, MinecartCheck check) { - Entity* rider = std::exchange(savedRider, nullptr); + auto [rider, riderState] = std::exchange(savedRider, {nullptr, nullptr}); if (!hook_inner_call([&] { return entity_state_save(room, entity, state, check); })) return false; if (check == MINECART_IGNORED) { - savedRider = &entity; + savedRider = {&entity, &state}; return true; } - if (rider) unfiltered_notify("EntitySave", MC_ENTITY_SAVE, rider); - unfiltered_notify("EntitySave", MC_ENTITY_SAVE, &entity); + if (rider) entity_store_notify(*rider, riderState->saveStateId); + entity_store_notify(entity, state.saveStateId); return true; } @@ -86,7 +88,7 @@ bool completion_mark_hook(PersistentGameData& data, int counter, int num) static std::array owners = mark_owners_make(); LuaEngine& engine = lua_engine_get(); bool isEnabled = engine.is_callback_enabled(MC_COMPLETION_MARK_GET) || - engine.is_callback_enabled(MC_POST_COMPLETION_MARK_GET); + engine.is_callback_enabled(MC_POST_COMPLETION_MARK_GET) || achievement_marks_is_tracked(); if (!isEnabled || num <= 0 || counter < 0 || counter >= EVENT_COUNTER_COUNT || owners[counter].playerType < 0) return false; @@ -109,6 +111,7 @@ bool completion_mark_hook(PersistentGameData& data, int counter, int num) return true; } increase(); + achievement_marks_run(owner.completion, owner.playerType); CallbackRun post = {"PostCompletionMarkGet", MC_POST_COMPLETION_MARK_GET, owner.playerType}; callback_notify(engine, post, owner.completion, owner.playerType); if (isHardFirst) lastMarkCounter = counter; diff --git a/src/repentogon/saves.h b/src/repentogon/saves.h index c6c88ba..2a35a3a 100644 --- a/src/repentogon/saves.h +++ b/src/repentogon/saves.h @@ -1,6 +1,7 @@ #pragma once #include "level/room_state.h" +#include "repentogon/save_state_manager.h" #include class PersistentGameData; diff --git a/src/repentogon/stats.cpp b/src/repentogon/stats.cpp index ca15234..8554377 100644 --- a/src/repentogon/stats.cpp +++ b/src/repentogon/stats.cpp @@ -1,15 +1,181 @@ #include "repentogon/stats.h" #include "entity/player/player.h" +#include "game/manager.h" #include "repentogon/callbacks.h" +#include +#include -// (EvaluateStats.cpp) Runs MC_EVALUATE_STAT, filtered by the stage, with a stat's value there. A number replaces it, -// at the flat tears stage only a positive one. +// An items.xml stat attribute: its name, the cache it makes the item evaluate and the value that changes nothing. +struct ItemStatAttr +{ + const char* name; + uint32_t cacheFlag; + float neutral; +}; + +constexpr ItemStatAttr ITEM_STAT_ATTRS[ITEM_STAT_COUNT] = { + {"tears", CACHE_FIREDELAY, 0}, {"flattears", CACHE_FIREDELAY, 0}, {"tearsmult", CACHE_FIREDELAY, 1}, + {"damage", CACHE_DAMAGE, 0}, {"flatdamage", CACHE_DAMAGE, 0}, {"earlydamagemult", CACHE_DAMAGE, 1}, + {"damagemult", CACHE_DAMAGE, 1}, {"shotspeed", CACHE_SHOTSPEED, 0}, {"speed", CACHE_SPEED, 0}, + {"range", CACHE_RANGE, 0}, {"luck", CACHE_LUCK, 0}}; + +// The attribute prefix that gives a stat to an item's temporary effect. +constexpr std::string_view EFFECT_PREFIX = "effect"; + +// The item stat each evaluation stage adds before MC_EVALUATE_STAT, and the one it multiplies by after, if any. +constexpr ItemStat STAGE_ADDED_STATS[] = {ITEM_STAT_TEARS_UP, ITEM_STAT_FLAT_TEARS, ITEM_STAT_DAMAGE_UP, + ITEM_STAT_FLAT_DAMAGE, ITEM_STAT_COUNT}; +constexpr ItemStat STAGE_MULTIPLIED_STATS[] = {ITEM_STAT_COUNT, ITEM_STAT_TEARS_MULT, ITEM_STAT_COUNT, + ITEM_STAT_DAMAGE_MULT, ITEM_STAT_COUNT}; + +// The lists items with stats are in. +enum StatItemList +{ + STAT_LIST_COLLECTIBLES, + STAT_LIST_TRINKETS, + STAT_LIST_NULL_ITEMS, + STAT_LIST_COUNT +}; + +// The ids of the items with each stat, by list (REPENTOGON's stat lookups). An id an item reload freed counts nothing. +static std::array, ITEM_STAT_COUNT>, STAT_LIST_COUNT> statItems; + +// (EvaluateStats.cpp) Adds the stage's item stat, runs MC_EVALUATE_STAT filtered by the stage, then multiplies by the +// stage's item multiplier. A number the callback returns replaces the value, at the flat tears stage only a positive +// one. float stat_evaluate(Entity_Player& player, float value, EvaluateStatStage stage) { LuaEngine& engine = lua_engine_get(); - if (!callback_run(engine, {"EvaluateStat", MC_EVALUATE_STAT, stage}, &player, (int)stage, value)) return value; - float result = lua_isnumber(engine.state, -1) ? (float)lua_tonumber(engine.state, -1) : value; - lua_pop(engine.state, 1); - return stage != STAT_STAGE_FLAT_TEARS || result > 0 ? result : value; + item_stat_add(player, STAGE_ADDED_STATS[stage], value); + if (callback_run(engine, {"EvaluateStat", MC_EVALUATE_STAT, stage}, &player, (int)stage, value)) + { + float result = lua_isnumber(engine.state, -1) ? (float)lua_tonumber(engine.state, -1) : value; + lua_pop(engine.state, 1); + if (stage != STAT_STAGE_FLAT_TEARS || result > 0) value = result; + } + item_stat_add(player, STAGE_MULTIPLIED_STATS[stage], value); + return value; +} + +static StatItemList stat_list_get(ItemConfig_Item& item) +{ + return item.IsNull() ? STAT_LIST_NULL_ITEMS : item.IsTrinket() ? STAT_LIST_TRINKETS : STAT_LIST_COLLECTIBLES; +} + +// An attribute read as a float, logging one that is not a number. +static std::optional stat_attr_read(DataNode node, std::string_view name) +{ + std::optional text = node_attr_find(node, name); + if (!text) return std::nullopt; + + char* end = nullptr; + float value = std::strtof(text->data(), &end); + if (end != text->data()) return value; + log_printf(LOG_INFO, "[ItemConfigEx] Invalid xml value `%s` for attribute `%.*s`\n", text->data(), (int)name.size(), + name.data()); + return std::nullopt; +} + +// (ItemConfigEx.cpp ItemEx::Parse, RefreshStats) Reads an item's stat attributes, a null item's going to its effect, +// and "effect" ones to its temporary effect. A stat changing anything makes the item evaluate its cache, an active +// item's while held. +void item_stats_parse(DataNode node, ItemConfig_Item& item) +{ + StatItemList list = stat_list_get(item); + + for (int stat = 0; stat < ITEM_STAT_COUNT; stat++) + { + ItemStatAttr attr = ITEM_STAT_ATTRS[stat]; + std::string effectName = std::string(EFFECT_PREFIX) + attr.name; + + if (std::optional value = stat_attr_read(node, attr.name)) + (item.IsNull() ? item.effectStats : item.stats)[stat] = *value; + if (std::optional value = stat_attr_read(node, effectName)) item.effectStats[stat] = *value; + + bool isStat = item.stats.contains(stat) && item.stats[stat] != attr.neutral; + bool isEffectStat = item.effectStats.contains(stat) && item.effectStats[stat] != attr.neutral; + if (!isStat && !isEffectStat) + { + item.stats.erase(stat); + item.effectStats.erase(stat); + statItems[list][stat].erase(item.id); + continue; + } + statItems[list][stat].insert(item.id); + item.cacheFlags |= attr.cacheFlag; + if (item.type == ITEM_ACTIVE && isStat) item.isPassiveCache = true; + } +} + +static ItemConfig_Item* stat_item_get(StatItemList list, int id) +{ + ItemConfig& config = g_manager->itemConfig; + if (list == STAT_LIST_COLLECTIBLES) return config.GetCollectible(id); + return list == STAT_LIST_TRINKETS ? config.GetTrinket(id) : config.GetNullItem(id); +} + +// How many of an item the player holds, and how many of its effects it has. +static std::pair stat_item_count(Entity_Player& player, StatItemList list, int id) +{ + TemporaryEffects& effects = player.temporaryEffects; + if (list == STAT_LIST_COLLECTIBLES) return {player.GetCollectibleNum(id), effects.GetCollectibleEffectNum(id)}; + if (list == STAT_LIST_TRINKETS) return {player.GetTrinketMultiplier(id), effects.GetTrinketEffectNum(id)}; + return {0, effects.GetNullEffectNum(id)}; +} + +// A multiplier raised to how many give it, none for none. +static float stat_mult_power(float mult, int count) +{ + return mult > 0 && count > 0 ? (float)std::pow(mult, count) : 1; +} + +// (ItemConfigEx.cpp CalculateStatChange, CalculateStatMult) Adds what the player's items and effects give of a stat +// to value, or multiplies it by a multiplier stat. As in REPENTOGON, a collectible's or trinket's effect multiplies by +// the held item's multiplier. +void item_stat_add(Entity_Player& player, ItemStat stat, float& value) +{ + if (stat == ITEM_STAT_COUNT) return; + float neutral = ITEM_STAT_ATTRS[stat].neutral; + + for (int list = 0; list < STAT_LIST_COUNT; list++) + for (int id : statItems[list][stat]) + { + ItemConfig_Item* item = stat_item_get((StatItemList)list, id); + if (!item) continue; + + auto [held, effects] = stat_item_count(player, (StatItemList)list, id); + float itemValue = item->stats.contains(stat) ? item->stats[stat] : neutral; + float effectValue = item->effectStats.contains(stat) ? item->effectStats[stat] : neutral; + if (neutral == 0) + { + value += (float)held * itemValue + (float)effects * effectValue; + continue; + } + if (itemValue != 1) value *= stat_mult_power(itemValue, held); + float effectMult = list == STAT_LIST_NULL_ITEMS ? effectValue : itemValue; + if (effectValue != 1) value *= stat_mult_power(effectMult, effects); + } +} + +// (ItemConfigEx.cpp HasItemWithCustomTag, HasEffectWithCustomTag) Whether the player holds a collectible or trinket +// with the custom tag, or has the effect of an item with the effect tag. +bool item_custom_tag_is_held(Entity_Player& player, std::string_view tag, std::string_view effectTag) +{ + ItemConfig& config = g_manager->itemConfig; + TemporaryEffects& effects = player.temporaryEffects; + std::string heldTag(tag); + std::string heldEffectTag(effectTag); + + for (auto& item : config.collectibles) + if (item && ((item->customTags.contains(heldTag) && player.HasCollectible(item->id)) || + (item->customTags.contains(heldEffectTag) && effects.HasCollectibleEffect(item->id)))) + return true; + for (auto& item : config.trinkets) + if (item && ((item->customTags.contains(heldTag) && player.HasTrinket(item->id)) || + (item->customTags.contains(heldEffectTag) && effects.HasTrinketEffect(item->id)))) + return true; + for (auto& item : config.nullItems) + if (item && item->customTags.contains(heldEffectTag) && effects.HasNullEffect(item->id)) return true; + return false; } diff --git a/src/repentogon/stats.h b/src/repentogon/stats.h index 4a3948c..0c24018 100644 --- a/src/repentogon/stats.h +++ b/src/repentogon/stats.h @@ -1,6 +1,10 @@ #pragma once +#include "engine/data.h" +#include + struct Entity_Player; +struct ItemConfig_Item; // REPENTOGON's EvaluateStatStage: the points of a player's tears and damage evaluation where MC_EVALUATE_STAT runs. enum EvaluateStatStage @@ -12,4 +16,25 @@ enum EvaluateStatStage STAT_STAGE_PRE_FLAT_DAMAGE }; +// REPENTOGON's ItemStat: the stats an items.xml attribute gives an item, added or multiplied at their steps of the +// evaluation. The early damage multiplier is read but, as in REPENTOGON, applied nowhere. +enum ItemStat : int +{ + ITEM_STAT_TEARS_UP, + ITEM_STAT_FLAT_TEARS, + ITEM_STAT_TEARS_MULT, + ITEM_STAT_DAMAGE_UP, + ITEM_STAT_FLAT_DAMAGE, + ITEM_STAT_DAMAGE_EARLY_MULT, + ITEM_STAT_DAMAGE_MULT, + ITEM_STAT_SHOTSPEED_UP, + ITEM_STAT_SPEED_UP, + ITEM_STAT_RANGE_UP, + ITEM_STAT_LUCK_UP, + ITEM_STAT_COUNT +}; + float stat_evaluate(Entity_Player& player, float value, EvaluateStatStage stage); +void item_stats_parse(DataNode node, ItemConfig_Item& item); +void item_stat_add(Entity_Player& player, ItemStat stat, float& value); +bool item_custom_tag_is_held(Entity_Player& player, std::string_view tag, std::string_view effectTag); diff --git a/src/repentogon/ui_patches.cpp b/src/repentogon/ui_patches.cpp new file mode 100644 index 0000000..42f2427 --- /dev/null +++ b/src/repentogon/ui_patches.cpp @@ -0,0 +1,248 @@ +#include "repentogon/ui_patches.h" +#include "engine/anm2.h" +#include "engine/harness.h" +#include "engine/kage_graphics.h" +#include "engine/platform.h" +#include "entity/weapon/laser.h" +#include "entity/weapon/tear.h" +#include "game/game.h" +#include "game/manager.h" +#include "game/persistent_game_data.h" +#include "repentogon/options.h" +#include "ui/menu/manager.h" +#ifdef ISAAC_OVERLAY +#include "ui/overlay/overlay.h" +#endif +#include +#include +#include + +// InterpolV2 (Patches/InterpolV2.cpp) draws half an update ahead on the frames between updates, and turns the short +// way round. +constexpr float HALF_UPDATE = 0.5f; +constexpr float FULL_TURN = 360; + +// The error display of Patches/ExtraRenderSteps.cpp: it pulses red for 483 frames (8 pulses, slowing down) while +// fading to 0.3, and a click on its 18 point high box opens the overlay. The cursor turns red over it. +constexpr const char* ERROR_CLICK_TEXT = "Click this message for more info."; +constexpr uint32_t ERROR_PULSE_FRAMES = 483; +constexpr float ERROR_PULSE_SPEED = 200; +constexpr float ERROR_PULSE_SLOWING = 1500; +constexpr float ERROR_ALPHA_LOSS = 0.7f; +constexpr float ERROR_ALPHA_MIN = 0.3f; +constexpr float ERROR_BOX_HEIGHT = 18; +constexpr float ERROR_CLICK_TEXT_Y = 7; +constexpr float ERROR_HOVER_TINT = 0.5f; + +// Patches/CutsceneSkip.cpp: whether the first cutscene SkipIntro let through was skipped, and whether the menu still +// has to take the black it fades in from. +static bool isFirstCutsceneSkipped = false; +static bool isIntroFadePending = false; +// Patches/Quickstart.cpp: whether "-quickstart" was given, and whether the first update looked at it. +bool isQuickstartAsked = false; +static bool isQuickstartChecked = false; + +// Whether SkipIntro skips a cutscene: the first one shown while it is on, the intro. +bool is_cutscene_skipped() +{ + if (isFirstCutsceneSkipped || !is_tweak_on(repentogonOptions.isSkipIntro)) return false; + + isFirstCutsceneSkipped = true; + isIntroFadePending = true; + return true; +} + +// Turns the menu's fade in black once the intro was skipped. +void intro_skip_fade(MenuManager& menu) +{ + if (!isIntroFadePending) return; + + menu.fadeInColor._red = 0; + menu.fadeInColor._green = 0; + menu.fadeInColor._blue = 0; + isIntroFadePending = false; +} + +// Remembers the save file opened last, which Quickstart continues. +void save_slot_remember(uint32_t slot) +{ + repentogonOptions.lastSaveFile = (int)slot; + repentogonOptions.save(); +} + +// On the first update with "-quickstart", continues the run saved in the file opened last, skipping the intro, when +// there is one. +void quickstart_try(Manager& manager) +{ + if (isQuickstartChecked) return; + + isQuickstartChecked = true; + if (!isQuickstartAsked || repentogonOptions.lastSaveFile == 0 || repentogonOptions.isVanillaParity) return; + + manager.SetSaveSlot((uint32_t)repentogonOptions.lastSaveFile); + manager.isNetworkPlay = false; + manager.isDebugStart = false; + manager.isRerunAvailable = manager.gamestate.seeds.gameStartSeed != 0; + if (!manager.isRerunAvailable) return; + + manager.isStartingFromRerun = false; + manager.dailyChallenge.id = 0; + manager.isStarting = true; + manager.isCutscenePending = false; +} + +// Whether the stat HUD shows the planetarium chance (Patches/ASMPatches/ASMRender.cpp): StatHUDPlanetarium, once +// planetariums are unlocked. +bool is_planetarium_chance_shown() +{ + return is_tweak_on(repentogonOptions.isStatHudPlanetarium) && + g_manager->persistentGameData.Unlocked(ACHIEVEMENT_PLANETARIUMS); +} + +// The planetarium chance in percent StatHUDPlanetarium puts in the stat HUD's unused stat, which is 0 otherwise. +float planetarium_chance_get() +{ + return is_tweak_on(repentogonOptions.isStatHudPlanetarium) ? g_game->GetPlanetariumChance() * PERCENT : 0; +} + +// Recomputes the first player's planetarium chance on the stat HUD, as a floor starts or a run is restored, so it +// is not worked out every frame. +void planetarium_chance_recompute() +{ + if (!is_tweak_on(repentogonOptions.isStatHudPlanetarium)) return; + + StatHUD& stats = g_game->hud.statHUD; + stats.RecomputeStats(stats.player_slot_get(g_game->GetPlayer(0)), STAT_FLAG_UNUSED); +} + +// The laser sample caching of Patches/LagMetric.cpp: a laser that a tear with TEAR_LASERSHOT fired loses its homing +// as its samples are cleared. REPENTOGON does this without an option. +void laser_samples_clear_pre(Entity_Laser& laser) +{ + Entity* parent = laser.parent.get(); + if (repentogonOptions.isVanillaParity || !parent || parent->type != ENTITY_TEAR) return; + if (static_cast(parent)->tearFlags.test(TEAR_LASERSHOT)) laser.tearFlags.reset(TEAR_HOMING); +} + +// InterpolV2: whether the game itself renders (outside Lua's post render), and the animation drawing its layers. +static bool isGameRendering = false; +static const AnimationState* renderedState = nullptr; + +// Notes whether the game itself renders now. +void game_render_mark(bool isRendering) +{ + isGameRendering = isRendering; +} + +// Notes the animation drawing its layers now, or none. +void rendered_state_set(const AnimationState* state) +{ + renderedState = state; +} + +// The turn from one angle to another, the short way round, as InterpolV2 takes it. +static float angle_distance(float from, float to) +{ + float distance = std::fmod(to - from, FULL_TURN); + return std::fmod(2 * distance, FULL_TURN) - distance; +} + +// The keyframe a layer draws. With InterpolV2, an interpolated keyframe of a playing animation the game itself draws +// (not paused, the console closed) moves part way to the next one: its color, scale, position and rotation, by the +// ticks since it began, half a tick more on the frames between updates. +const AnimationFrame& frame_interpolate(const AnimationLayer& layer, int frameIndex, const ANM2& animation, + AnimationFrame& lerped) +{ + const AnimationFrame& frame = layer.frames[frameIndex]; + bool isLerped = is_tweak_on(repentogonOptions.isInterpolV2) && isGameRendering && renderedState && + renderedState->isPlaying && g_game->pauseScreen.state == PAUSE_HIDDEN && + g_game->console.state == CONSOLE_CLOSED && frame.isInterpolated; + if (!isLerped || frameIndex + 1 >= (int)layer.frames.size()) return frame; + + const AnimationFrame& next = layer.frames[frameIndex + 1]; + float ahead = g_manager->framecount % 2 ? 0 : HALF_UPDATE * animation.playbackSpeed; + float t = std::min((ahead + renderedState->animFrame - (float)frame.startFrame) / (float)frame.duration, 1.0f); + auto mix = [t](float from, float to) { return from * (1 - t) + to * t; }; + + lerped = frame; + for (int i = 0; i < 3; i++) lerped.color._offset[i] = mix(frame.color._offset[i], next.color._offset[i]); + for (int i = 0; i < 4; i++) lerped.color._tint[i] = mix(frame.color._tint[i], next.color._tint[i]); + lerped.scale = vector_make(mix(frame.scale.x, next.scale.x), mix(frame.scale.y, next.scale.y)); + lerped.pos = vector_make(mix(frame.pos.x, next.pos.x), mix(frame.pos.y, next.pos.y)); + lerped.rotation = frame.rotation + angle_distance(frame.rotation, next.rotation) * t; + return lerped; +} + +// The error display's message and the frame it was raised on, while it shows, and the cursor's color before it. +static std::string errorMessage; +static uint32_t errorFrame = 0; +static bool isErrorShown = false; +static ColorMod cursorColor; + +// Shows an error at the top of the screen, unless one already shows (a mod's error never outranks another). +void error_display_raise(const std::string& message) +{ + if (isErrorShown || repentogonOptions.isVanillaParity) return; + + errorMessage = message; + errorFrame = g_manager->framecount; + isErrorShown = true; +} + +// Draws the error display before the cursor, and the cursor itself when mouse control would leave it out. +void cursor_render_pre(Manager& manager) +{ + cursorColor = manager.cursorSprite.color; + if (!isErrorShown) return; +#ifdef ISAAC_OVERLAY + if (overlay.is_visible()) return void(isErrorShown = false); +#endif + + Size window = platform.window_size_get(); + Vector mouse{}; + bool isPressed = harness.mouse_get(&mouse.x, &mouse.y) & SDL_BUTTON_LMASK; + mouse.x *= KAGE::Graphics::manager.orthographicWidth / (float)window.width; + mouse.y *= KAGE::Graphics::manager.orthographicHeight / (float)window.height; + + Font& messageFont = manager.font6_PFTempestaSevenCondensed; + Font& clickFont = manager.font8_LuaMiniOutlined; + int messageWidth = messageFont.GetStringWidth(errorMessage); + int clickWidth = clickFont.GetStringWidth(ERROR_CLICK_TEXT); + float centerX = g_screenWidth / 2; + float halfBox = (float)std::max(messageWidth, clickWidth) / 2; + if (mouse.x > centerX - halfBox && mouse.y > 0 && mouse.x < centerX + halfBox && mouse.y < ERROR_BOX_HEIGHT) + { +#ifdef ISAAC_OVERLAY + if (isPressed && overlay.is_ready()) overlay.visible_set(true); +#endif + if (isPressed) return void(isErrorShown = false); + manager.cursorSprite.color._tint[0] = 1; + manager.cursorSprite.color._tint[1] = ERROR_HOVER_TINT; + manager.cursorSprite.color._tint[2] = ERROR_HOVER_TINT; + } + + uint32_t frame = manager.framecount - errorFrame; + float redLoss = 0; + if (frame < ERROR_PULSE_FRAMES) + redLoss = std::sin((float)frame * (ERROR_PULSE_SPEED / ((float)frame + ERROR_PULSE_SLOWING))) / 2 + 0.5f; + float alpha = std::max(1 - ERROR_ALPHA_LOSS / ERROR_PULSE_FRAMES * (float)frame, ERROR_ALPHA_MIN); + KColor color = kcolor_rgba(1, redLoss, redLoss, alpha); + FontSettings settings; + messageFont.DrawString(errorMessage, vector_make(centerX - (float)messageWidth / 2, 0), vector_make(1, 1), color, + settings); + clickFont.DrawString(ERROR_CLICK_TEXT, vector_make(centerX - (float)clickWidth / 2, ERROR_CLICK_TEXT_Y), + vector_make(1, 1), color, settings); + if (manager.optionsConfig.isMouseControlEnabled) return; + + manager.cursorSprite.color._tint[3] = std::min(manager.cursorSprite.color._tint[3], alpha); + SpriteDraw draw; + draw.position = mouse; + manager.cursorSprite.Render(draw); + manager.cursorSprite.color = cursorColor; +} + +// Gives the cursor back the color it had before the error display. +void cursor_render_post(Manager& manager) +{ + manager.cursorSprite.color = cursorColor; +} diff --git a/src/repentogon/ui_patches.h b/src/repentogon/ui_patches.h new file mode 100644 index 0000000..3e8bad6 --- /dev/null +++ b/src/repentogon/ui_patches.h @@ -0,0 +1,33 @@ +#pragma once + +#include +#include + +struct ANM2; +struct AnimationFrame; +struct AnimationLayer; +struct AnimationState; +struct Entity_Laser; +class Manager; +class MenuManager; + +// REPENTOGON's changes to the menus, the HUD, rendering and debugging (its Patches/), each behind its option (where it +// has one) and the parity switch. +bool is_cutscene_skipped(); +void intro_skip_fade(MenuManager& menu); +void save_slot_remember(uint32_t slot); +void quickstart_try(Manager& manager); + +bool is_planetarium_chance_shown(); +float planetarium_chance_get(); +void planetarium_chance_recompute(); +void laser_samples_clear_pre(Entity_Laser& laser); +void game_render_mark(bool isRendering); +void rendered_state_set(const AnimationState* state); +void error_display_raise(const std::string& message); +void cursor_render_pre(Manager& manager); +void cursor_render_post(Manager& manager); +const AnimationFrame& frame_interpolate(const AnimationLayer& layer, int frameIndex, const ANM2& animation, + AnimationFrame& lerped); + +extern bool isQuickstartAsked; diff --git a/src/repentogon/vanilla_fixes.cpp b/src/repentogon/vanilla_fixes.cpp new file mode 100644 index 0000000..70e24b8 --- /dev/null +++ b/src/repentogon/vanilla_fixes.cpp @@ -0,0 +1,132 @@ +#include "repentogon/vanilla_fixes.h" +#include "engine/filesys.h" +#include "engine/platform.h" +#include "entity/config.h" +#include "entity/familiar/familiar.h" +#include "entity/weapon/knife.h" +#include "game/game.h" +#include "game/manager.h" +#include "level/room.h" +#include "repentogon/options.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// REPENTOGON's fixes and tweaks to the vanilla game (Patches/VanillaTweaks.cpp, Patches/MiscFixes.cpp, +// Patches/ModReloading.cpp), each only without vanilla parity, and some only with their option on too. + +constexpr const char* VOID_ROOMS_VANILLA = "rooms/01.Basement.xml"; +constexpr const char* VOID_ROOMS_OWN = "rooms/26.The Void_ex.stb"; +constexpr char VOID_ROOMS_EMPTY[] = {'S', 'T', 'B', '1', 0, 0, 0, 0}; +constexpr const char* SELF_COMMAND_LINE = "/proc/self/cmdline"; +constexpr const char* SELF_EXECUTABLE = "/proc/self/exe"; +constexpr uint32_t ECO_SLEEP_MS = 5; +constexpr uint32_t ECO_SLEEP_IDLE_MS = 333; + +// (VanillaTweaks.cpp) Whether a console command is refused in a daily run that is not practice. +bool is_daily_command_refused() +{ + if (repentogonOptions.isVanillaParity || !g_game) return false; + return g_game->dailyChallenge.id != 0 && !g_game->dailyChallenge.isPractice; +} + +// (MiscFixes.cpp) Whether a crawlspace is refused in a room under Curse of the Mist, the mineshaft, whose keys it may +// softlock. Rep+ refuses them itself after 1.9.7.12. +bool is_crawlspace_refused(Room& room) +{ + return !repentogonOptions.isVanillaParity && room.HasCurseMist(); +} + +// (MiscFixes.cpp) Whether a config the entity key found is the one asked for, not another one sharing its key, as a +// subtype or variant too large for the key gives. +bool is_entity_config_matched(EntityConfig_Entity& config, int id, int variant, int subtype) +{ + if (repentogonOptions.isVanillaParity) return true; + return config.id == id && config.variant == variant && config.subtype == subtype; +} + +// (MiscFixes.cpp) Whether a familiar leads its line already: in it, with nobody ahead and a familiar of the line +// behind. The original adds it again, which may parent it to itself and stop the line. +bool is_familiar_line_led(Entity_Familiar& familiar, bool Entity_Familiar::* line) +{ + if (repentogonOptions.isVanillaParity || familiar.parent || !(familiar.*line)) return false; + Entity* child = familiar.child.get(); + auto* follower = child && child->type == ENTITY_FAMILIAR ? dynamic_cast(child) : nullptr; + return follower && follower->*line; +} + +// (MiscFixes.cpp) Whether a pill color past the gold pill is ignored, which the original reads as gold. +bool is_pill_color_ignored(uint32_t pillColor) +{ + return !repentogonOptions.isVanillaParity && (int)(pillColor & PILL_COLOR_MASK) > PILL_COLOR_GOLD; +} + +// (VanillaTweaks.cpp) EcoMode: while the window is minimized the game sleeps in place of drawing, longer out of a +// running run. The original also lowers the process's priority. +bool is_render_skipped() +{ + if (!is_tweak_on(repentogonOptions.isEcoMode) || !platform.window) return false; + if (!(SDL_GetWindowFlags(platform.window) & SDL_WINDOW_MINIMIZED)) return false; + + bool isIdle = g_manager->state != MANAGER_STATE_GAME || !g_game || g_game->pauseScreen.state != PAUSE_HIDDEN; + SDL_Delay(isIdle ? ECO_SLEEP_IDLE_MS : ECO_SLEEP_MS); + return true; +} + +// (VanillaTweaks.cpp) The stage binary the Void loads, which names the Basement's rooms: its own room set, empty unless +// a mod replaces it, the mods' Void rooms added after. Nothing for another stage. +std::optional void_rooms_load(int stageId, const std::string& path) +{ + bool isVoidBasement = stageId == STAGE_ID_VOID && path == VOID_ROOMS_VANILLA; + if (repentogonOptions.isVanillaParity || !isVoidBasement) return std::nullopt; + + std::string bytes; + if (resource_load(g_manager->modManager.TryRedirectPath(VOID_ROOMS_OWN), bytes)) return bytes; + return std::string(VOID_ROOMS_EMPTY, sizeof(VOID_ROOMS_EMPTY)); +} + +// (ModReloading.cpp) Restarts the game in place of reloading the mods inside it, the options saved first, as +// REPENTOGON's launcher restarts it. False when the game could not start again, which then reloads them in place. +bool is_game_restarted() +{ + if (repentogonOptions.isVanillaParity) return false; + g_manager->optionsConfig.Save(); + + std::ifstream file(SELF_COMMAND_LINE, std::ios::binary); + std::vector args; + for (std::string arg; std::getline(file, arg, '\0');) args.push_back(arg); + std::vector argv; + for (std::string& arg : args) argv.push_back(arg.data()); + argv.push_back(nullptr); + if (!args.empty()) execv(SELF_EXECUTABLE, argv.data()); + return false; +} + +// (MiscFixes.cpp) Whether a mod's metadata.xml is not written into a folder that does not exist: a workshop mod's, +// named without its id at that point, which the original makes as an empty duplicate of the mod. +bool is_metadata_write_refused(const std::string& path) +{ + std::error_code error; + bool isFolderFound = std::filesystem::exists(std::filesystem::path(path).parent_path(), error); + return !repentogonOptions.isVanillaParity && !isFolderFound; +} + +// (MiscFixes.cpp) Keeps a spawn's seed from 0, which crashes, before and after MC_PRE_ENTITY_SPAWN. +uint32_t spawn_seed_fix(uint32_t seed) +{ + return repentogonOptions.isVanillaParity ? seed : std::max(seed, 1u); +} + +// (MiscFixes.cpp) A subtype 1 knife a mod spawns updates through a homing path it lacks: it starts as a straight one +// from its parent, itself without one. +void knife_homing_path_init(Entity_Knife& knife) +{ + if (repentogonOptions.isVanillaParity || knife.subtype != 1) return; + Entity* parent = knife.parent.get(); + knife.InitHomingPath(knife.velocity, parent ? parent : &knife, knife.pathOffset); +} diff --git a/src/repentogon/vanilla_fixes.h b/src/repentogon/vanilla_fixes.h new file mode 100644 index 0000000..1495a8d --- /dev/null +++ b/src/repentogon/vanilla_fixes.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include +#include + +struct Entity_Familiar; +struct Entity_Knife; +struct EntityConfig_Entity; +struct Room; + +bool is_daily_command_refused(); +bool is_crawlspace_refused(Room& room); +bool is_entity_config_matched(EntityConfig_Entity& config, int id, int variant, int subtype); +bool is_game_restarted(); +bool is_metadata_write_refused(const std::string& path); +bool is_familiar_line_led(Entity_Familiar& familiar, bool Entity_Familiar::* line); +bool is_pill_color_ignored(uint32_t pillColor); +bool is_render_skipped(); +std::optional void_rooms_load(int stageId, const std::string& path); +uint32_t spawn_seed_fix(uint32_t seed); +void knife_homing_path_init(Entity_Knife& knife); diff --git a/src/repentogon/weapons.cpp b/src/repentogon/weapons.cpp index 92b487a..df73808 100644 --- a/src/repentogon/weapons.cpp +++ b/src/repentogon/weapons.cpp @@ -1,8 +1,10 @@ #include "repentogon/weapons.h" +#include "entity/familiar/familiar.h" #include "entity/npc/npc.h" #include "entity/player/player.h" #include "entity/weapon/bomb.h" #include "entity/weapon/tear.h" +#include "entity/weapon/weapon.h" #include "repentogon/callbacks.h" #include #include @@ -167,3 +169,37 @@ void tear_hit_params_evaluate(Entity_Player& player, TearParams& params, TearHit } std::erase(tearHitEvaluations, evaluation); } + +// The player slots REPENTOGON's weapon callbacks look a player's weapon up in. +constexpr int CALLBACK_WEAPON_SLOTS = 4; + +// A weapon as REPENTOGON's weapon callbacks hand it to Lua: with its familiar, or its player and slot. +static WeaponData weapon_data_get(Weapon& weapon) +{ + WeaponData data{.weapon = &weapon}; + if (!weapon.owner) return data; + if (weapon.owner->type == ENTITY_FAMILIAR) data.familiar = static_cast(weapon.owner); + else if (Entity_Player* player = weapon.owner->ToPlayer()) + { + data.player = player; + for (int slot = 0; slot < CALLBACK_WEAPON_SLOTS && data.slot < 0; slot++) + if (player->weapons[slot].get() == &weapon) data.slot = slot; + } + return data; +} + +// (CustomCallbacks.cpp's Weapon::Fire hook) Runs MC_POST_WEAPON_FIRE once a weapon's shared firing ran, filtered by +// its type. +void weapon_fire_post(Weapon& weapon, const Vector& direction, bool isShooting, bool isInterpolated) +{ + CallbackRun run = {"PostWeaponFire", MC_POST_WEAPON_FIRE, weapon.weaponType}; + callback_notify(lua_engine_get(), run, weapon_data_get(weapon), direction, isShooting, isInterpolated); +} + +// (CustomCallbacks.cpp's Weapon::TriggerTearFired hook) Runs MC_POST_TRIGGER_WEAPON_FIRED once a weapon triggered +// what its shots do, filtered by its type. +void weapon_fired_post(Weapon& weapon, const Vector& direction, int count) +{ + CallbackRun run = {"PostTriggerWeaponFired", MC_POST_TRIGGER_WEAPON_FIRED, weapon.weaponType}; + callback_notify(lua_engine_get(), run, direction, count, weapon.owner, weapon_data_get(weapon)); +} diff --git a/src/repentogon/weapons.h b/src/repentogon/weapons.h index 6172331..a50f30d 100644 --- a/src/repentogon/weapons.h +++ b/src/repentogon/weapons.h @@ -66,8 +66,35 @@ struct SplitTear int type = 0; }; +// The splits the game makes that MC_POST_FIRE_SPLIT_TEAR names (SplitTearType). +enum SplitTearType +{ + SPLIT_GENERIC, + SPLIT_QUAD, + SPLIT_PARASITE, + SPLIT_BONE, + SPLIT_ABSORB, + SPLIT_SPORE, + SPLIT_STICKY, + SPLIT_BURST, + SPLIT_POP, + SPLIT_MULTIDIMENSIONAL, + SPLIT_ANGELIC_PRISM, + SPLIT_SWORD_BEAM +}; + +void split_tear_notify(Entity_Tear& tear, Entity& source, const SplitTear& split); + +// MC_POST_FIRE_SPLIT_TEAR for a split the game made. +inline void split_tear_post(Entity_Tear& tear, Entity& source, SplitTearType type) +{ + split_tear_notify(tear, source, {.type = type}); +} + Entity_Tear* split_tear_fire(Entity& source, const SplitShot& shot, const SplitTear& split); bool init_sound_play(const std::optional& initSound); +void weapon_fire_post(Weapon& weapon, const Vector& direction, bool isShooting, bool isInterpolated); +void weapon_fired_post(Weapon& weapon, const Vector& direction, int count); int familiar_weapon_get(lua_State* state); void bomb_api_register(lua_State* state); void knife_api_register(lua_State* state); diff --git a/src/repentogon/xml.cpp b/src/repentogon/xml.cpp new file mode 100644 index 0000000..220f892 --- /dev/null +++ b/src/repentogon/xml.cpp @@ -0,0 +1,367 @@ +#include "repentogon/xml.h" +#include "engine/filesys.h" +#include "engine/platform.h" +#include "game/game.h" +#include "game/manager.h" +#include "game/mod_manager.h" +#include "game/string_table.h" +#include "level/backdrop.h" +#include +#include +#include + +constexpr std::string_view CONTENT_FOLDER_REPENTOGON = "-repentogon/"; +constexpr std::string_view MODS_FOLDER = "mods/"; +constexpr std::string_view METADATA_PATH = "/metadata.xml"; +constexpr std::string_view DISABLE_MARKER = "/disable.it"; +constexpr std::string_view CONTENT_FOLDERS[] = {"/content-repentogon/", "/content-dlc3/", "/content/"}; +constexpr std::string_view PNG_EXTENSION = ".png"; +constexpr std::string_view ANM2_EXTENSION = ".anm2"; +constexpr std::string_view STA_VERSION = "0"; +constexpr std::string_view APPEAR_ANIMATION = "Appear"; +// The bases whose sheet is an .anm2, which a mod's backdrop must replace with one that exists. +constexpr int ANM2_SHEET_BACKDROPS[] = {BACKDROP_MEGA_SATAN, BACKDROP_ERROR_ROOM, BACKDROP_PLANETARIUM, + BACKDROP_CLOSET, BACKDROP_CLOSET_B, BACKDROP_DOGMA}; +// Where XMLBackdrop cuts a gfx name's numbered prefix ("01_Basement"): an underscore before this place. +constexpr size_t BACKDROP_PREFIX_END = 4; + +// The mods' backdrops by id, the id each name finds (the last one with it), and the configs of the game's backdrops +// a mod's backdrop took over until they are asked for again. +static std::map customBackdrops; +static std::map> backdropNames; +static std::map lentBackdrops; +static uint32_t requestedBackdrop = 0; + +static std::vector customGiantbooks; +static std::map> giantbookNames; + +static std::string text_lower(std::string_view text) +{ + std::string lower(text); + std::ranges::transform(lower, lower.begin(), [](unsigned char c) { return (char)std::tolower(c); }); + return lower; +} + +static int text_int(std::string_view text) +{ + return std::atoi(std::string(text).c_str()); +} + +static bool is_resource_found(std::string_view path) +{ + return resource_exists(path) || resource_exists(std::string(path) + std::string(JSON_EXTENSION)); +} + +// The attributes of a node, each missing one taken from its parents in order (XMLData's inheritdaddyatts). +XmlAttributes xml_attributes_read(DataNode node, std::initializer_list parents) +{ + XmlAttributes attributes; + + for (auto [name, value] : node_attrs(node)) attributes.emplace(text_lower(name), value); + for (DataNode parent : parents) + for (auto [name, value] : node_attrs(parent)) attributes.emplace(text_lower(name), value); + return attributes; +} + +// The document's top-level element of this tag, as rapidxml's first_node finds it. +std::optional data_root_get(Data& data, std::string_view tag) +{ + if (!data.isLoaded) return std::nullopt; + if (node_tag(data.root) != DOCUMENT_TAG) return node_tag(data.root) == tag ? std::optional(data.root) : std::nullopt; + for (DataNode child : node_children(data.root)) + if (node_tag(child) == tag) return child; + return std::nullopt; +} + +// (XMLData.cpp's BuildModdedXML) Hands load each loaded mod's copy of a file the game reads only from its resources, +// in mod order: from the mod's content-repentogon folder, else its content-dlc3, else its content folder. +void content_files_load(std::string_view fileName, const std::function& load) +{ + for (auto& mod : g_manager->modManager.mods) + { + if (!mod->isLoaded) continue; + std::string_view content = mod->contentDirectory; + std::string path = std::string(content.substr(0, content.size() - 1)) + + std::string(CONTENT_FOLDER_REPENTOGON) + std::string(fileName); + if (!is_resource_found(path)) path = mod->GetContentPath(fileName); + if (!is_resource_found(path)) continue; + + Data data; + data_load(data, path); + if (data.isLoaded) load(data, *mod); + } +} + +// XMLData's getFileName: a path's file name without its extension. +std::string file_name_get(std::string_view path) +{ + std::string_view name = path.substr(path.find_last_of("/\\") + 1); + return std::string(name.substr(0, name.find_last_of('.'))); +} + +// XMLBackdrop::ProcessAttributes: a backdrop's name attribute, else its gfx without the extension and number prefix. +static std::string backdrop_name_get(XmlAttributes& node) +{ + if (auto name = node.find("name"); name != node.end()) return name->second; + + std::string& gfx = node["gfx"]; + std::string name = gfx.substr(0, gfx.size() >= PNG_EXTENSION.size() ? gfx.size() - PNG_EXTENSION.size() : 0); + size_t prefix = name.find('_'); + if (prefix > 0 && prefix < BACKDROP_PREFIX_END) name = name.substr(prefix + 1); + return name; +} + +// (XMLData.cpp's backdrops pass) Names the game's backdrops and adds the mods' content backdrops.xml after them, +// numbered on from the highest id, each taking its file's and then the game's roots. +void backdrops_content_load(DataNode root) +{ + int maxId = -1; + + customBackdrops.clear(); + backdropNames.clear(); + lentBackdrops.clear(); + requestedBackdrop = 0; + for (DataNode node : node_children(root)) + { + XmlAttributes attributes = xml_attributes_read(node, {root}); + int id = text_int(attributes["id"]); + backdropNames[backdrop_name_get(attributes)] = id; + maxId = std::max(maxId, id); + } + + content_files_load("backdrops.xml", [&](Data& data, ModEntry&) { + std::optional modRoot = data_root_get(data, "backdrops"); + if (!modRoot) return; + for (DataNode node : node_children(*modRoot)) + { + XmlAttributes& attributes = customBackdrops[++maxId] = xml_attributes_read(node, {*modRoot, root}); + backdropNames[backdrop_name_get(attributes)] = maxId; + } + }); +} + +// A sheet path under root when the value has the extension, else the fallback (the default config's grid graphic, +// the same paths REPENTOGON writes). +static std::string sheet_path(XmlAttributes& node, std::string_view name, std::string_view root, + std::string_view extension, std::string_view fallback = {}) +{ + std::string& value = node[std::string(name)]; + return value.ends_with(extension) ? std::string(root) + value : std::string(fallback); +} + +// (XMLData.cpp's Backdrop::Init hook) Readies the backdrop Init draws for id. A mod's backdrop draws as its base +// (reftype, else the basement, or the burning basement for reversed water), lending it its sheets and grid graphics +// until the base is asked for again, which takes its own back. An unknown id draws as the game's. +// REPENTOGON's custom range starts after id 60. Here it starts after the game's last backdrop, so the game's own stay. +BackdropDraw backdrop_custom_apply(Backdrop& backdrop, uint32_t& id) +{ + requestedBackdrop = id; + if (auto lent = lentBackdrops.find((int)id); lent != lentBackdrops.end()) + { + backdrop.configs[id] = lent->second; + lentBackdrops.erase(lent); + return BACKDROP_DRAW_CUSTOM; + } + + auto found = customBackdrops.find((int)id); + if (id < BACKDROP_COUNT || found == customBackdrops.end()) return BACKDROP_DRAW_VANILLA; + + XmlAttributes& node = found->second; + int base = text_int(node["reftype"]); + if (base >= BACKDROP_COUNT) + { + g_game->console.PrintError("field 'reftype' should be between 1 and 60 \n"); + return BACKDROP_DRAW_NONE; + } + if (base < 1) base = node["reversewatergfx"] == "true" ? BACKDROP_BURNING_BASEMENT : BACKDROP_BASEMENT; + + std::string gfx = node["gfxroot"] + node["gfx"]; + bool isAnm2Sheet = std::ranges::find(ANM2_SHEET_BACKDROPS, base) != std::end(ANM2_SHEET_BACKDROPS); + bool isGfxReplaced = !isAnm2Sheet || gfx.ends_with(ANM2_EXTENSION); + if (isAnm2Sheet && isGfxReplaced && !is_resource_found(gfx)) + { + g_game->console.PrintError("[Backdrop:" + std::to_string(id) + "] file at path '" + gfx + "' does not exist \n"); + return BACKDROP_DRAW_NONE; + } + + lentBackdrops.try_emplace(base, backdrop.configs[base]); + BackdropConfig& config = backdrop.configs[base]; + BackdropConfig& defaults = backdrop.configs[0]; + std::string& gfxRoot = node["gfxroot"]; + std::string& gridRoot = node["gridgfxroot"]; + if (isGfxReplaced) config.gfx = gfx; + config.walls = text_int(node["walls"]); + config.wallVariants = text_int(node["wallvariants"]); + config.floors = text_int(node["floors"]); + config.floorVariants = text_int(node["floorvariants"]); + config.lFloorGfx = sheet_path(node, "lfloorgfx", gfxRoot, PNG_EXTENSION); + config.nFloorGfx = sheet_path(node, "nfloorgfx", gfxRoot, PNG_EXTENSION); + config.waterGfx = sheet_path(node, "watergfx", gfxRoot, PNG_EXTENSION); + config.props = sheet_path(node, "props", gridRoot, ANM2_EXTENSION); + config.rocks = sheet_path(node, "rocks", gridRoot, PNG_EXTENSION, defaults.rocks); + config.pit = sheet_path(node, "pit", gridRoot, PNG_EXTENSION, defaults.pit); + config.waterPit = sheet_path(node, "waterpit", gridRoot, PNG_EXTENSION, defaults.waterPit); + config.bridge = sheet_path(node, "bridge", gridRoot, PNG_EXTENSION, defaults.bridge); + config.door = sheet_path(node, "door", gridRoot, PNG_EXTENSION, defaults.door); + config.holeInWall = sheet_path(node, "holeinwall", gridRoot, PNG_EXTENSION, defaults.holeInWall); + id = (uint32_t)base; + return BACKDROP_DRAW_CUSTOM; +} + +// (LuaRoom.cpp's GetBackdropType) The backdrop the room was last given: a mod's own id, else the one it draws. +uint32_t backdrop_type_get(Backdrop& backdrop) +{ + return customBackdrops.contains((int)requestedBackdrop) ? requestedBackdrop : backdrop.backdropId; +} + +// Isaac.GetBackdropIdByName: the id of the last backdrop of that name, -1 for none. +int backdrop_id_find(std::string_view name) +{ + auto found = backdropNames.find(name); + return found == backdropNames.end() ? -1 : found->second; +} + +// (XMLData.cpp's giantbook pass and ItemOverlay::Show hook) Names the game's giant books (their name, else their gfx +// file's) and adds the mods' content giantbook.xml entries after them, numbered on from the highest id. A mod's entry +// starts as the first book (shown first, then changed), plays Appear without an animation, and tints its layers by +// all four channels, a missing one zero. +void giantbooks_content_load(DataNode root) +{ + int id = 0; + int maxId = -1; + + customGiantbooks.clear(); + giantbookNames.clear(); + for (DataNode node : node_children(root)) + { + XmlAttributes attributes = xml_attributes_read(node); + if (attributes.contains("id")) id = text_int(attributes["id"]); + if (attributes.contains("name")) giantbookNames[attributes["name"]] = id; + else if (attributes.contains("gfx")) giantbookNames[file_name_get(attributes["gfx"])] = id; + maxId = std::max(maxId, id); + } + + content_files_load("giantbook.xml", [&](Data& data, ModEntry&) { + std::optional modRoot = data_root_get(data, "giantbook"); + if (!modRoot) return; + for (DataNode node : node_children(*modRoot)) + { + XmlAttributes attributes = xml_attributes_read(node, {*modRoot, root}); + GiantbookEntry& entry = customGiantbooks.emplace_back(g_game->giantbookEntries[1]); + std::string& anm2Root = attributes["anm2root"]; + entry.id = ++maxId; + entry.animation = attributes.contains("anim") ? attributes["anim"] : std::string(APPEAR_ANIMATION); + if (attributes.contains("anm2")) + { + entry.anm2Path = anm2Root + attributes["anm2"]; + entry.gfxPath.clear(); + entry.layers.clear(); + } + if (attributes.contains("gfx")) entry.gfxPath = anm2Root + attributes["gfx"]; + if (attributes.contains("name")) giantbookNames[attributes["name"]] = entry.id; + else if (attributes.contains("gfx")) giantbookNames[file_name_get(attributes["gfx"])] = entry.id; + + for (DataNode layerNode : node_children(node)) + { + if (node_tag(layerNode) != "layer") continue; + XmlAttributes layer = xml_attributes_read(layerNode); + if (!layer.contains("name")) continue; + GiantbookLayer& tinted = entry.layers.emplace_back(GiantbookLayer{layer["name"], {}}); + std::string_view channels[] = {layer["r"], layer["g"], layer["b"], layer["a"]}; + for (size_t channel = 0; channel < std::size(channels); channel++) + tinted.color._tint[channel] = (float)text_int(channels[channel]) / COLOR_CHANNEL_MAX; + } + } + }); +} + +// A mod's giant book by id, null for none. +const GiantbookEntry* giantbook_custom_find(int id) +{ + auto found = std::ranges::find(customGiantbooks, id, &GiantbookEntry::id); + return found == customGiantbooks.end() ? nullptr : &*found; +} + +// Isaac.GetGiantBookIdByName: the id of the last giant book of that name, -1 for none. +int giantbook_id_find(std::string_view name) +{ + auto found = giantbookNames.find(name); + return found == giantbookNames.end() ? -1 : found->second; +} + +// Whether a mod's string table opens with REPENTOGON's . +static bool is_sta_versioned(DataNode root) +{ + for (DataNode child : node_children(root)) + if (node_tag(child) == "info") return node_attr(child, "rgon_sta_version") == STA_VERSION; + return false; +} + +// Merges a mod's string table into the game's: a new category or key is added (a key with every translation empty), +// and each translation the mod fills replaces the one at its place. +static void string_table_merge(StringTable& table, DataNode root) +{ + for (DataNode categoryNode : node_children(root)) + { + std::string_view categoryName = node_attr(categoryNode, "name"); + if (node_tag(categoryNode) != "category" || categoryName.empty()) continue; + StringTableCategory& category = table.categories[text_lower(categoryName)]; + + for (DataNode keyNode : node_children(categoryNode)) + { + std::string keyName = text_lower(node_attr(keyNode, "name")); + if (node_tag(keyNode) != "key" || keyName.empty()) continue; + auto [found, isAdded] = category.strings.try_emplace(keyName, table.languages.size()); + if (isAdded) category.keys.push_back(keyName); + + size_t column = 0; + for (DataNode stringNode : node_children(keyNode)) + { + if (node_tag(stringNode) != "string") continue; + if (column >= found->second.size()) break; + std::string text = node_text(stringNode); + if (!text.empty()) found->second[column] = text; + column++; + } + } + } +} + +// (XMLData.cpp's BuildModdedSta) Merges each enabled mod's stringtable.sta or stringtable_pc.sta into the table, in +// the order mods load (by metadata name, then folder). The string tables load before the mods are listed, so the mods +// folder is read here. +void string_table_mods_merge(StringTable& table, std::string_view fileName) +{ + std::map, std::string> files; + std::error_code error; + + for (auto& entry : std::filesystem::directory_iterator(platform.modsDirectory, error)) + { + if (!entry.is_directory(error) || std::filesystem::exists(entry.path().string() + std::string(DISABLE_MARKER))) + continue; + std::string folder = entry.path().filename().string(); + std::string modPath = text_lower(std::string(MODS_FOLDER) + folder); + Data metadata; + data_load(metadata, modPath + std::string(METADATA_PATH)); + std::string name; + if (std::optional root = data_root_get(metadata, "metadata")) + for (DataNode child : node_children(*root)) + if (node_tag(child) == "name") name = node_text(child); + + for (std::string_view content : CONTENT_FOLDERS) + { + std::string path = modPath + std::string(content) + std::string(fileName); + if (!is_resource_found(path)) continue; + files[{name, folder}] = path; + break; + } + } + + for (auto& [_, path] : files) + { + Data data; + data_load(data, path); + std::optional root = data_root_get(data, "stringtable"); + if (root && is_sta_versioned(*root)) string_table_merge(table, *root); + } +} diff --git a/src/repentogon/xml.h b/src/repentogon/xml.h new file mode 100644 index 0000000..ca73f6e --- /dev/null +++ b/src/repentogon/xml.h @@ -0,0 +1,42 @@ +#pragma once + +#include "engine/data.h" +#include +#include +#include +#include +#include +#include + +struct Backdrop; +struct GiantbookEntry; +struct ModEntry; +struct StringTable; + +// A node's attributes by lowercased name, as REPENTOGON's XMLAttributes keeps them. +using XmlAttributes = std::map>; + +// What Backdrop::Init draws for an id: the game's own backdrop, a mod's (or a base it lent its config to) drawn as its +// base, or nothing for a mod's backdrop that cannot draw. +enum BackdropDraw +{ + BACKDROP_DRAW_VANILLA, + BACKDROP_DRAW_CUSTOM, + BACKDROP_DRAW_NONE +}; + +XmlAttributes xml_attributes_read(DataNode node, std::initializer_list parents = {}); +std::optional data_root_get(Data& data, std::string_view tag); +void content_files_load(std::string_view fileName, const std::function& load); +std::string file_name_get(std::string_view path); + +void backdrops_content_load(DataNode root); +BackdropDraw backdrop_custom_apply(Backdrop& backdrop, uint32_t& id); +uint32_t backdrop_type_get(Backdrop& backdrop); +int backdrop_id_find(std::string_view name); + +void giantbooks_content_load(DataNode root); +const GiantbookEntry* giantbook_custom_find(int id); +int giantbook_id_find(std::string_view name); + +void string_table_mods_merge(StringTable& table, std::string_view fileName); diff --git a/src/ui/console.cpp b/src/ui/console.cpp index 461c537..d0f3175 100644 --- a/src/ui/console.cpp +++ b/src/ui/console.cpp @@ -15,6 +15,9 @@ #include "engine/render_passes.h" #include "level/room.h" #include "level/room_config.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/console.h" +#endif #ifdef ISAAC_OVERLAY #include "ui/overlay/overlay.h" #endif @@ -252,7 +255,11 @@ void Console::history_clear() { history.clear(); scroll = {}; +#ifdef ISAAC_REPENTOGON + Print(console_greeting_get(GREETING), CONSOLE_WHITE, 0); +#else Print(GREETING, CONSOLE_WHITE, 0); +#endif } // 00686220 Reads the command history Close saved, up to 64 commands with trailing whitespace trimmed, or removes the diff --git a/src/ui/console_commands.cpp b/src/ui/console_commands.cpp index 25c1fac..63d8f96 100644 --- a/src/ui/console_commands.cpp +++ b/src/ui/console_commands.cpp @@ -31,6 +31,8 @@ #include "engine/texture_cache.h" #ifdef ISAAC_REPENTOGON #include "repentogon/api_game.h" +#include "repentogon/console.h" +#include "repentogon/vanilla_fixes.h" #endif #include #include @@ -48,7 +50,6 @@ constexpr int COMBO_POOL_COUNT = 31; constexpr int COSTUME_TEST_MIN = 2; constexpr int COSTUME_TEST_RANGE = 5; constexpr int COSTUME_TEST_ITEMS = 733; -constexpr int CUTSCENE_LAST = 26; constexpr int DEBUG_FLAG_DAMAGE = 3; constexpr int DEBUG_FLAG_LUCK = 8; constexpr int TIME_FRAME_RATE = 30; @@ -752,7 +753,7 @@ static void cutscene_run(ConsoleCommand& command) if (command.words.size() != 2) return; uint32_t cutscene = word_int(command, 1); - if (cutscene <= CUTSCENE_LAST) g_manager->ShowCutscene(cutscene, CUTSCENE_KEEP_STATE, 1); + if (cutscene < g_manager->cutsceneManager.entries.size()) g_manager->ShowCutscene(cutscene, CUTSCENE_KEEP_STATE, 1); else command_print(command, "Invalid cutscene ID.\n"); } @@ -1089,6 +1090,9 @@ std::vector macro_names_get() // command. The output goes into output when given, as Isaac.ExecuteCommand captures it, else to the console. void Console::RunCommand(std::string_view text, std::string* output, Entity_Player* player) { +#ifdef ISAAC_REPENTOGON + if (is_daily_command_refused()) return; +#endif ConsoleCommand command{.words = text_split(text, ' '), .console = this, .player = player}; std::string* outer = capture; @@ -1096,6 +1100,13 @@ void Console::RunCommand(std::string_view text, std::string* output, Entity_Play if (command.words.empty()) return; if (!command.player) command.player = g_game->playerManager.GetPlayer(0); if (output) capture = output; +#ifdef ISAAC_REPENTOGON + if (is_console_hook_run(*this, command.words, command.player)) + { + capture = outer; + return; + } +#endif for (auto [name, run] : COMMANDS) { if (name != command.words[0]) continue; diff --git a/src/ui/cutscene.cpp b/src/ui/cutscene.cpp index 54681ee..60db3af 100644 --- a/src/ui/cutscene.cpp +++ b/src/ui/cutscene.cpp @@ -10,6 +10,10 @@ #include "ui/menu/manager.h" #include "engine/render_passes.h" #include "engine/texture_cache.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/ui_patches.h" +#include "repentogon/xml.h" +#endif #include #include #include @@ -224,6 +228,11 @@ void Cutscene::ANM2Part::Load() sprite.Reset(); sprite.Load(anm2Path, GRAPHICS_LOAD); load_subtitles(); +#ifdef ISAAC_REPENTOGON + std::vector& tracks = g_manager->musicManager.tracks; + auto track = std::ranges::find(tracks.rbegin(), tracks.rend(), musicName, &MusicTrack::name); + if (!musicName.empty() && track != tracks.rend()) music = track->id; +#endif } // (0095f4e0) Unloads the .anm2. @@ -457,6 +466,11 @@ static std::unique_ptr anm2_part_load(DataNode node, std::string_v if (!anm2.empty()) part->anm2Path = std::string(root) + std::string(anm2); part->anim = node_attr(node, "anim"); part->music = attr_int(node, "music"); +#ifdef ISAAC_REPENTOGON + std::string music(node_attr(node, "music")); + char* end = nullptr; + if (!music.empty() && (std::strtol(music.c_str(), &end, 0), *end)) part->musicName = music; +#endif part->musicDelay = attr_int(node, "musicDelay"); part->width = attr_int(node, "width"); part->height = attr_int(node, "height"); @@ -489,8 +503,43 @@ static std::unique_ptr temporary_part_load(DataNode node, Cutscene return part; } -// 0095cc00 Reads cutscenes.xml: each cutscene's name, fade and parts, paths under the root. A cutscene with an id out -// of range is dropped. False when the file is missing. +// A : its name, fade and parts, paths under the root. +static void entry_load(Cutscene& cutscene, CutsceneEntry& entry, int id, DataNode node, std::string_view root, + std::string_view path) +{ + std::string_view fadeColor = node_attr(node, "fadecolor"); + entry = CutsceneEntry(); + entry.id = id; + entry.name = node_attr(node, "name"); + entry.isFadeOut = !node_attr(node, "fadeout").empty(); + if (fadeColor == FADE_WHITE) entry.fadeColor = color_get(COLOR_WHITE); + if (fadeColor == FADE_BLACK) entry.fadeColor = color_get(COLOR_BLACK); + + for (DataNode partNode : node_children(node)) + { + std::string_view tag = node_tag(partNode); + std::unique_ptr part; + + if (tag == ANM2_PART_TAG) part = anm2_part_load(partNode, root); + else if (tag == VIDEO_PART_TAG) + { + part = video_part_load(partNode, root, cutscene); + if (part) entry.hasVideo = true; + } + else if (tag == TEMPORARY_PART_TAG) part = temporary_part_load(partNode, entry); + else + { + log_printf(LOG_INFO, "[warn] %.*s unknown tag %.*s.\n", (int)path.size(), path.data(), (int)tag.size(), + tag.data()); + continue; + } + if (part) entry.parts.push_back(std::move(part)); + } +} + +// 0095cc00 Reads cutscenes.xml: each cutscene by id, paths under the root. A cutscene with an id out of range is +// dropped. False when the file is missing. With REPENTOGON, the cutscenes of each mod's content cutscenes.xml follow, +// numbered on from 27 whatever id they give, their paths under the game's root (XMLData.cpp's cutscene ids). bool Cutscene::load_xml(std::string_view path) { Data data; @@ -503,40 +552,18 @@ bool Cutscene::load_xml(std::string_view path) std::string_view root = node_attr(data.root, "root"); for (DataNode node : node_children(data.root)) { - if (node_tag(node) != "cutscene") continue; - int id = attr_int(node, "id"); - if (id < 0 || id >= CUTSCENE_ENTRY_COUNT) continue; - - std::string_view fadeColor = node_attr(node, "fadecolor"); - CutsceneEntry& entry = entries[id] = CutsceneEntry(); - entry.id = id; - entry.name = node_attr(node, "name"); - entry.isFadeOut = !node_attr(node, "fadeout").empty(); - if (fadeColor == FADE_WHITE) entry.fadeColor = color_get(COLOR_WHITE); - if (fadeColor == FADE_BLACK) entry.fadeColor = color_get(COLOR_BLACK); - - for (DataNode partNode : node_children(node)) - { - std::string_view tag = node_tag(partNode); - std::unique_ptr part; - - if (tag == ANM2_PART_TAG) part = anm2_part_load(partNode, root); - else if (tag == VIDEO_PART_TAG) - { - part = video_part_load(partNode, root, *this); - if (part) entry.hasVideo = true; - } - else if (tag == TEMPORARY_PART_TAG) part = temporary_part_load(partNode, entry); - else - { - log_printf(LOG_INFO, "[warn] %.*s unknown tag %.*s.\n", (int)path.size(), path.data(), (int)tag.size(), - tag.data()); - continue; - } - if (part) entry.parts.push_back(std::move(part)); - } + if (node_tag(node) == "cutscene" && id >= 0 && id < CUTSCENE_ENTRY_COUNT) + entry_load(*this, entries[id], id, node, root, path); } +#ifdef ISAAC_REPENTOGON + entries.resize(CUTSCENE_ENTRY_COUNT); + content_files_load("cutscenes.xml", [&](Data& mod, ModEntry&) { + for (DataNode node : node_children(mod.root)) + if (node_tag(node) == "cutscene") + entry_load(*this, entries.emplace_back(), (int)entries.size() - 1, node, root, path); + }); +#endif return true; } @@ -579,9 +606,13 @@ static void credits_shuffle(Cutscene& cutscene) // 0095e7c0 Starts a cutscene: fades the music out, unloads the one playing and loads the new one's parts. // Id 0 plays nothing. The original logs an id past its entries and plays on past them. Here it stops. +// REPENTOGON's SkipIntro skips the first. void Cutscene::Show(int cutsceneId) { - if ((unsigned int)cutsceneId >= CUTSCENE_ENTRY_COUNT) +#ifdef ISAAC_REPENTOGON + if (is_cutscene_skipped()) return; +#endif + if ((unsigned int)cutsceneId >= entries.size()) { log_printf(LOG_ERROR, "Invalid cutscene ID \"%d\" \n", cutsceneId); return; diff --git a/src/ui/cutscene.h b/src/ui/cutscene.h index 4bdf542..8ea5f16 100644 --- a/src/ui/cutscene.h +++ b/src/ui/cutscene.h @@ -101,6 +101,10 @@ struct Cutscene int music = 0; int musicDelay = 0; int width = 0; +#ifdef ISAAC_REPENTOGON + // A music.xml track name in place of the music id, found as the part loads. + std::string musicName; +#endif void Load() override; void Unload() override; @@ -147,7 +151,8 @@ struct Cutscene int GetHeight() override; }; - std::array entries; + // With REPENTOGON, the cutscenes of the mods' content cutscenes.xml follow the game's, from id 27 on. + std::vector entries = std::vector(CUTSCENE_ENTRY_COUNT); VideoPlayer videoPlayer{}; Vector renderOffset{}; CutsceneState state = CUTSCENE_IDLE; diff --git a/src/ui/hud.cpp b/src/ui/hud.cpp index beb9e79..ae8a3c9 100644 --- a/src/ui/hud.cpp +++ b/src/ui/hud.cpp @@ -1268,13 +1268,21 @@ void HUD::render_counters(Vector& cursor, Vector shake) pickupHUDSprite.SetFrame(ANIMATION_IDLE, FRAME_COIN); bool isDeepPockets = players.FirstCollectibleOwner(COLLECTIBLE_DEEP_POCKETS, LAZARUS_SHARE_CHECK); - row(isDeepPockets ? "%03d" : "%02d", player->numCoins); + std::string coinFormat = isDeepPockets ? "%03d" : "%02d"; + std::string bombFormat = "%02d"; + std::string keyFormat = "%02d"; +#ifdef ISAAC_REPENTOGON + coinFormat = consumable_format_get(LIMIT_COINS, coinFormat.c_str()); + bombFormat = consumable_format_get(LIMIT_BOMBS, bombFormat.c_str()); + keyFormat = consumable_format_get(LIMIT_KEYS, keyFormat.c_str()); +#endif + row(coinFormat.c_str(), player->numCoins); if (!isAllBlueBabyB) { pickupHUDSprite.SetFrame((float)(player->numGigaBombs ? FRAME_GIGA_BOMB : player->hasGoldenBomb ? FRAME_GOLDEN_BOMB : FRAME_BOMB)); - row("%02d", player->numBombs); + row(bombFormat.c_str(), player->numBombs); } if (blueBabyB) { @@ -1282,7 +1290,7 @@ void HUD::render_counters(Vector& cursor, Vector shake) row(players.FirstBirthrightOwner(PLAYER_BLUEBABY_B) ? "%02d" : "%d", player->poopMana); } pickupHUDSprite.SetFrame((float)(player->hasGoldenKey ? FRAME_GOLDEN_KEY : FRAME_KEY)); - row("%02d", player->numKeys); + row(keyFormat.c_str(), player->numKeys); if (bethanyB) { pickupHUDSprite.SetFrame((float)FRAME_BLOOD_CHARGE); diff --git a/src/ui/menu/character.cpp b/src/ui/menu/character.cpp index 99fc2d0..7282509 100644 --- a/src/ui/menu/character.cpp +++ b/src/ui/menu/character.cpp @@ -487,7 +487,11 @@ void Menu_Character::Reset() for (int i = 0; i < CHARACTER_ENTRY_COUNT; i++) numCharacters += is_on_wheel(i); modCharacters.clear(); for (size_t i = PLAYER_TYPE_COUNT; i < players.size(); i++) +#ifdef ISAAC_REPENTOGON + if (!players[i].isHidden && !is_player_hidden_by_achievement((int)i) && players[i].bSkinParentName.empty()) +#else if (!players[i].isHidden && players[i].bSkinParentName.empty()) +#endif modCharacters.push_back({players[i].id, players[i].moddedTaintedPlayerID}); numCharacters += (int)modCharacters.size(); @@ -656,8 +660,12 @@ void Menu_Character::UpdateRotations() bool isTaintedThere = std::any_of(tainted, tainted + CHARACTER_ENTRY_COUNT, [](const Menu_Character_Entry& entry) { return entry.IsCharacterAvailable(); }); isTaintedThere = - isTaintedThere || std::any_of(modCharacters.begin(), modCharacters.end(), - [](const ModCharacter& mod) { return mod.playerType != mod.taintedPlayerType; }); + isTaintedThere || std::any_of(modCharacters.begin(), modCharacters.end(), [](const ModCharacter& mod) { +#ifdef ISAAC_REPENTOGON + if (!is_player_unlocked(mod.taintedPlayerType)) return false; +#endif + return mod.playerType != mod.taintedPlayerType; + }); pageSwapWidgetSprite.color._tint[3] = isTaintedThere ? 1.0f : 0.0f; page_layers_update(); @@ -678,6 +686,9 @@ void Menu_Character::page_layers_update() isGameCharacter ? &CHARACTER_ENTRIES[characterMenuShown][selectedCharacterID] : nullptr; isCharacterUnlocked = !entry || entry->IsCharacterAvailable(); +#ifdef ISAAC_REPENTOGON + if (!entry) isCharacterUnlocked = is_player_unlocked(GetPlayerTypeFromMenuID(selectedCharacterID, characterMenuShown)); +#endif if (!isGameCharacter) return; for (int layer = PAGE_LAYER_DETAILS_FIRST; layer < PAGE_LAYER_DETAILS_END; layer++) @@ -791,7 +802,9 @@ void Menu_Character::SelectRandomChar() for (int i = 0; i < (int)modCharacters.size(); i++) candidates.push_back(CHARACTER_ENTRY_COUNT + i); #ifdef ISAAC_REPENTOGON std::erase_if(candidates, [this](int menuId) { - return !is_character_selectable(GetPlayerTypeFromMenuID(menuId, characterMenuShown), CHARACTER_SELECT_CHECK); + int playerType = GetPlayerTypeFromMenuID(menuId, characterMenuShown); + if (menuId >= CHARACTER_ENTRY_COUNT && !is_player_unlocked(playerType)) return true; + return !is_character_selectable(playerType, CHARACTER_SELECT_CHECK); }); if (candidates.empty()) { diff --git a/src/ui/menu/daily_challenge.cpp b/src/ui/menu/daily_challenge.cpp index a96e86f..2d68008 100644 --- a/src/ui/menu/daily_challenge.cpp +++ b/src/ui/menu/daily_challenge.cpp @@ -3,6 +3,9 @@ #include "engine/log.h" #include "game/manager.h" #include "ui/menu/manager.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/options.h" +#endif #include #include @@ -215,14 +218,21 @@ void Menu_DailyChallenge::run_start() data.IncreaseEventCounter(EVENT_COUNTER_DAILIES_PLAYED, 1); } -// Moves the cursor a step, wrapping: playing needs the day unplayed, practice needs it played. +// Moves the cursor a step, wrapping: playing needs the day unplayed, practice needs it played. REPENTOGON keeps it +// off online play (Patches/ASMPatches/ASMMenu.cpp). void Menu_DailyChallenge::selection_move(int step) { auto isPlayItem = [](int item) { return item == DAILY_PLAY || item == DAILY_PLAY_ONLINE; }; int selected = selectedElement + step; + bool isOnlineSkipped = false; +#ifdef ISAAC_REPENTOGON + isOnlineSkipped = !repentogonOptions.isVanillaParity; +#endif + if (isOnlineSkipped && selected == DAILY_PLAY_ONLINE) selected += step; if (step > 0 && selected >= DAILY_ITEM_COUNT) selected = DAILY_PLAY; - if (step < 0 && selected == DAILY_PRACTICE && state != DAILY_STATE_PLAYED) selected = DAILY_PLAY_ONLINE; + if (step < 0 && selected == DAILY_PRACTICE && state != DAILY_STATE_PLAYED) + selected = isOnlineSkipped ? DAILY_PLAY : DAILY_PLAY_ONLINE; while (isPlayItem(selected) && state != DAILY_STATE_UNPLAYED) selected += step; if (step > 0 && selected == DAILY_PRACTICE && state != DAILY_STATE_PLAYED) selected = DAILY_LEADERBOARD; if (selected < DAILY_PLAY) selected = DAILY_LEADERBOARD; diff --git a/src/ui/menu/manager.cpp b/src/ui/menu/manager.cpp index 9dc5523..f8a4e99 100644 --- a/src/ui/menu/manager.cpp +++ b/src/ui/menu/manager.cpp @@ -9,6 +9,8 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/menus.h" +#include "repentogon/ui_patches.h" #endif constexpr const char* EMPTY_SCREEN_PNG = "gfx/ui/main menu/EmptyScreen.png"; @@ -92,10 +94,14 @@ static bool is_device_action(const KAGE::Input::InputDevice& device, ButtonActio } // Whether any device has the action held or pressed this frame, giving the first such device's id, as KAGE's -// input manager asks every device in turn (its query slot with the pressed or triggered test). +// input manager asks every device in turn (its query slot with the pressed or triggered test). REPENTOGON's main menu +// input mask may hold it back. bool is_action(ButtonAction action, ActionTest test, int* deviceId) { KAGE::Input::Manager& input = KAGE::Input::manager; +#ifdef ISAAC_REPENTOGON + if (is_action_masked(action)) return false; +#endif for (int i = 0; i < input.get_device_count(); i++) { @@ -393,9 +399,12 @@ void MenuManager::controller_update() } // 009897d0 Steps the menus: the shadow, the fly, the view, the controller, the fades, then the selected menu and the -// color modifier's easing. +// color modifier's easing. After REPENTOGON skipped the intro, the menu first fades in from black. void MenuManager::Update() { +#ifdef ISAAC_REPENTOGON + intro_skip_fade(*this); +#endif menuShadowSprite.Update(); fly_update(); view_update(); @@ -500,7 +509,7 @@ void MenuManager::Render() popup_buttons_place(); #ifdef ISAAC_REPENTOGON - unfiltered_notify("MainMenuRender", MC_MAIN_MENU_RENDER); + main_menu_render_notify(*this); #endif vignette_update(); overlay_render(); diff --git a/src/ui/menu/save.cpp b/src/ui/menu/save.cpp index 0775573..0008502 100644 --- a/src/ui/menu/save.cpp +++ b/src/ui/menu/save.cpp @@ -6,6 +6,7 @@ #include "game/persistent_game_data.h" #ifdef ISAAC_REPENTOGON #include "repentogon/menus.h" +#include "repentogon/ui_patches.h" #endif #include #include @@ -340,10 +341,13 @@ void Menu_Save::slot_delete() } // 009d98f0 Opens a save file: the game menu, or the corrupted file prompt offering its latest backup. -// The lobby an invite was waiting to join with this file is online, so none ever waits. +// The lobby an invite was waiting to join with this file is online, so none ever waits. REPENTOGON remembers the file. void Menu_Save::select_slot(uint32_t slot) { Manager& manager = *g_manager; +#ifdef ISAAC_REPENTOGON + save_slot_remember(slot); +#endif manager.SetSaveSlot(slot); if (manager.persistentGameData.isFileLoaded) diff --git a/src/ui/menu/title.cpp b/src/ui/menu/title.cpp index b273768..9eeeb20 100644 --- a/src/ui/menu/title.cpp +++ b/src/ui/menu/title.cpp @@ -1,6 +1,9 @@ #include "ui/menu/title.h" #include "game/manager.h" #include "ui/menu/manager.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/options.h" +#endif constexpr const char* TITLE_ANM2 = "gfx/ui/main menu/TitleMenu.anm2"; constexpr std::string_view TITLE_SHEET_FOLDER = "gfx/ui/main menu/"; @@ -71,6 +74,9 @@ void Menu_Title::Update() g_menuManager->push_menu(MENU_SAVE); } if (!is_action(ACTION_MENU_BACK, ACTION_TRIGGERED)) return; +#ifdef ISAAC_REPENTOGON + if (is_tweak_on(repentogonOptions.isDisableExitPrompt)) return game_quit(); // Patches/ASMPatches/ASMTweaks.cpp +#endif MessagePopup popup(&g_manager->font2_TeamMeatEx12, exit_popup_closed, nullptr, vector_make(EXIT_POPUP_WIDTH, POPUP_SIZE_FIT)); diff --git a/src/ui/nightmare_scene.cpp b/src/ui/nightmare_scene.cpp index fdd24a7..4d0db10 100644 --- a/src/ui/nightmare_scene.cpp +++ b/src/ui/nightmare_scene.cpp @@ -332,7 +332,11 @@ void NightmareScene::Show(bool isSameStageShown) bubbleSprite.Load(scenePath, GRAPHICS_LOAD); bubbleSprite.SetFrame(SCENE_ANIM, 0); +#ifdef ISAAC_REPENTOGON + bool isAlt = config && is_player_no_shake(config->id); +#else bool isAlt = config && std::ranges::find(ALT_PORTRAIT_PLAYERS, config->id) != ALT_PORTRAIT_PLAYERS.end(); +#endif backgroundSprite.GetLayer(PORTRAIT_LAYER)->isVisible = !isAlt; backgroundSprite.GetLayer(PORTRAIT_ALT_LAYER)->isVisible = isAlt; diff --git a/src/ui/overlay/console.cpp b/src/ui/overlay/console.cpp index 5b9a9a6..252e20a 100644 --- a/src/ui/overlay/console.cpp +++ b/src/ui/overlay/console.cpp @@ -4,6 +4,9 @@ #include "game/manager.h" #include "game/mod_manager.h" #include "game/sfx_manager.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/api_game.h" +#endif #include "ui/console.h" #include #include @@ -51,6 +54,25 @@ static int match_rank(std::string_view word, std::string_view typed) return 2; } +#ifdef ISAAC_REPENTOGON +// The console command whose words each AutocompleteType completes, by type. CUSTOM asks the mod, and the types +// without a command here complete nothing. +constexpr std::string_view AUTOCOMPLETE_COMMANDS[AUTOCOMPLETE_COUNT] = { + "", "spawn", "goto", "stage", "gridspawn", "debug", "giveitem", "challenge", "combo", "cutscene", + "macro", "playsfx", "curse", "metro", "delirious", "restart", "", "luamod", "", ""}; + +// The words a command a mod registered completes (ConsoleMega's autocomplete): its type's command's, or for CUSTOM +// those MC_CONSOLE_AUTOCOMPLETE returns. The input with its first word as that command when it has one. +static std::string mod_entries_add(const std::string& input, size_t space, std::vector& entries) +{ + std::string command = input.substr(0, space); + int type = console_autocomplete_type_get(command); + if (type == AUTOCOMPLETE_CUSTOM) entries = console_autocomplete_run(command, input.substr(space + 1)); + if (type <= AUTOCOMPLETE_NONE || type >= AUTOCOMPLETE_COUNT || AUTOCOMPLETE_COMMANDS[type].empty()) return input; + return std::string(AUTOCOMPLETE_COMMANDS[type]) + input.substr(space); +} +#endif + // The words the overlay completes where the original console suggests none, from the game's own data: the sounds for // playsfx, the challenges, the characters for restart and addplayer, the macros and the mods' folders for luamod. static void extra_entries_add(std::string_view command, std::vector& entries) @@ -99,7 +121,16 @@ void Overlay::suggestions_load() size_t space = input.find(' '); if (space == std::string::npos) + { for (std::string_view name : command_names_get()) add(name, input, "", " "); +#ifdef ISAAC_REPENTOGON + for (auto& [rank, suggestion] : ranked) + { + std::string_view name = std::string_view(suggestion.line).substr(0, suggestion.line.size() - 1); + suggestion.descriptor = console_description_get(name); + } +#endif + } else { std::string_view command = std::string_view(input).substr(0, space); @@ -107,8 +138,15 @@ void Overlay::suggestions_load() if (std::ranges::find(ROOM_COMMANDS, command) != std::end(ROOM_COMMANDS)) start = std::max(start, input.rfind('.') + 1); - std::vector entries = omnicomplete_get(input); - if (input.find(' ', space + 1) == std::string::npos) extra_entries_add(command, entries); + std::vector entries; + std::string completed = input; +#ifdef ISAAC_REPENTOGON + completed = mod_entries_add(input, space, entries); +#endif + std::vector found = omnicomplete_get(completed); + entries.insert(entries.end(), found.begin(), found.end()); + if (input.find(' ', space + 1) == std::string::npos) + extra_entries_add(std::string_view(completed).substr(0, completed.find(' ')), entries); for (std::string& entry : entries) add(entry, std::string_view(input).substr(start), std::string_view(input).substr(0, start), ""); } diff --git a/src/ui/overlay/custom_imgui.cpp b/src/ui/overlay/custom_imgui.cpp new file mode 100644 index 0000000..79af361 --- /dev/null +++ b/src/ui/overlay/custom_imgui.cpp @@ -0,0 +1,678 @@ +// REPENTOGON's mod menus, windows and notifications (CustomImGui.h's drawing, NotificationHandler.h), drawn by the +// overlay from the element tree its ImGui Lua API builds. +#ifdef ISAAC_REPENTOGON +#include "ui/overlay/overlay.h" +#include "game/game.h" +#include "lua/api.h" +#include "lua/engine.h" +#include "repentogon/custom_imgui.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +constexpr float WINDOW_WIDTH_FIRST = 300; +constexpr float WINDOW_HEIGHT_FIRST = 100; +constexpr float TOOLTIP_WRAP_EMS = 35; +constexpr float NOTIFICATION_TOP = 5; +constexpr float NOTIFICATION_GAP = 3; +constexpr float NOTIFICATION_ICON_GAP = 10; +constexpr float NOTIFICATION_TEXT_RAISE = 4; +constexpr uint64_t NOTIFICATION_FADE_MS = 2000; +constexpr const char* ICON_ELLIPSIS = ""; +constexpr const char* KEY_UNKNOWN = "Unknown"; + +constexpr const char* CALLBACK_NAMES[CUSTOM_CALLBACK_COUNT] = { + "Clicked", "Hovered", "Active", "Focused", "Visible", "Edited", "Activated", "Deactivated", + "DeactivatedAfterEdit", "ToggledOpen", "Render"}; + +// REPENTOGON's ImGuiColor, from its older Dear ImGui, as this one's colors. +constexpr ImGuiCol STYLE_COLORS[] = { + ImGuiCol_Text, ImGuiCol_TextDisabled, ImGuiCol_WindowBg, ImGuiCol_ChildBg, ImGuiCol_PopupBg, ImGuiCol_Border, + ImGuiCol_BorderShadow, ImGuiCol_FrameBg, ImGuiCol_FrameBgHovered, ImGuiCol_FrameBgActive, ImGuiCol_TitleBg, + ImGuiCol_TitleBgActive, ImGuiCol_TitleBgCollapsed, ImGuiCol_MenuBarBg, ImGuiCol_ScrollbarBg, + ImGuiCol_ScrollbarGrab, ImGuiCol_ScrollbarGrabHovered, ImGuiCol_ScrollbarGrabActive, ImGuiCol_CheckMark, + ImGuiCol_SliderGrab, ImGuiCol_SliderGrabActive, ImGuiCol_Button, ImGuiCol_ButtonHovered, ImGuiCol_ButtonActive, + ImGuiCol_Header, ImGuiCol_HeaderHovered, ImGuiCol_HeaderActive, ImGuiCol_Separator, ImGuiCol_SeparatorHovered, + ImGuiCol_SeparatorActive, ImGuiCol_ResizeGrip, ImGuiCol_ResizeGripHovered, ImGuiCol_ResizeGripActive, + ImGuiCol_Tab, ImGuiCol_TabHovered, ImGuiCol_TabSelected, ImGuiCol_TabDimmed, ImGuiCol_TabDimmedSelected, + ImGuiCol_PlotLines, ImGuiCol_PlotLinesHovered, ImGuiCol_PlotHistogram, ImGuiCol_PlotHistogramHovered, + ImGuiCol_TableHeaderBg, ImGuiCol_TableBorderStrong, ImGuiCol_TableBorderLight, ImGuiCol_TableRowBg, + ImGuiCol_TableRowBgAlt, ImGuiCol_TextSelectedBg, ImGuiCol_DragDropTarget, ImGuiCol_NavCursor, + ImGuiCol_NavWindowingHighlight, ImGuiCol_NavWindowingDimBg, ImGuiCol_ModalWindowDimBg}; + +// The game's key (Keyboard) or button action (ButtonAction) each ImGui key reports to a key input's function. +constexpr std::pair GAME_KEYS[] = { + {ImGuiKey_Tab, 258}, {ImGuiKey_LeftArrow, 263}, {ImGuiKey_RightArrow, 262}, {ImGuiKey_UpArrow, 265}, + {ImGuiKey_DownArrow, 264}, {ImGuiKey_PageUp, 266}, {ImGuiKey_PageDown, 267}, {ImGuiKey_Home, 268}, + {ImGuiKey_End, 269}, {ImGuiKey_Insert, 260}, {ImGuiKey_Delete, 261}, {ImGuiKey_Backspace, 259}, + {ImGuiKey_Space, 32}, {ImGuiKey_Enter, 257}, {ImGuiKey_Escape, 256}, {ImGuiKey_LeftCtrl, 341}, + {ImGuiKey_LeftShift, 340}, {ImGuiKey_LeftAlt, 342}, {ImGuiKey_LeftSuper, 343}, {ImGuiKey_RightCtrl, 345}, + {ImGuiKey_RightShift, 344}, {ImGuiKey_RightAlt, 346}, {ImGuiKey_RightSuper, 347}, {ImGuiKey_Menu, 348}, + {ImGuiKey_Apostrophe, 39}, {ImGuiKey_Comma, 44}, {ImGuiKey_Minus, 45}, {ImGuiKey_Period, 46}, + {ImGuiKey_Slash, 47}, {ImGuiKey_Semicolon, 59}, {ImGuiKey_Equal, 61}, {ImGuiKey_LeftBracket, 91}, + {ImGuiKey_Backslash, 92}, {ImGuiKey_RightBracket, 93}, {ImGuiKey_GraveAccent, 96}, {ImGuiKey_CapsLock, 280}, + {ImGuiKey_ScrollLock, 281}, {ImGuiKey_NumLock, 282}, {ImGuiKey_PrintScreen, 283}, {ImGuiKey_Pause, 284}, + {ImGuiKey_KeypadDecimal, 330}, {ImGuiKey_KeypadDivide, 331}, {ImGuiKey_KeypadMultiply, 332}, + {ImGuiKey_KeypadSubtract, 333}, {ImGuiKey_KeypadAdd, 334}, {ImGuiKey_KeypadEnter, 335}, + {ImGuiKey_KeypadEqual, 336}, {ImGuiKey_GamepadLStickLeft, 0}, {ImGuiKey_GamepadDpadLeft, 0}, + {ImGuiKey_GamepadLStickRight, 1}, {ImGuiKey_GamepadDpadRight, 1}, {ImGuiKey_GamepadLStickUp, 2}, + {ImGuiKey_GamepadDpadUp, 2}, {ImGuiKey_GamepadLStickDown, 3}, {ImGuiKey_GamepadDpadDown, 3}, + {ImGuiKey_GamepadRStickLeft, 4}, {ImGuiKey_GamepadFaceLeft, 4}, {ImGuiKey_GamepadRStickRight, 5}, + {ImGuiKey_GamepadFaceRight, 5}, {ImGuiKey_GamepadRStickUp, 6}, {ImGuiKey_GamepadFaceUp, 6}, + {ImGuiKey_GamepadRStickDown, 7}, {ImGuiKey_GamepadFaceDown, 7}, {ImGuiKey_GamepadL1, 8}, + {ImGuiKey_GamepadL2, 9}, {ImGuiKey_GamepadR1, 10}, {ImGuiKey_GamepadR2, 11}, {ImGuiKey_GamepadStart, 12}, + {ImGuiKey_GamepadBack, 13}}; +// The runs of ImGui keys whose game keys follow on from the first: digits, letters, F1 to F12 and the keypad digits. +constexpr std::tuple GAME_KEY_RUNS[] = {{ImGuiKey_0, ImGuiKey_9, 48}, + {ImGuiKey_A, ImGuiKey_Z, 65}, + {ImGuiKey_F1, ImGuiKey_F12, 290}, + {ImGuiKey_Keypad0, ImGuiKey_Keypad9, 320}}; + +// Each severity's icon (Font Awesome's circle-info, circle-check, circle-exclamation and circle-xmark) and color. +constexpr const char* SEVERITY_ICONS[NOTIFICATION_SEVERITY_COUNT] = {"", "", "", ""}; +constexpr ImVec4 SEVERITY_COLORS[NOTIFICATION_SEVERITY_COUNT] = { + {.25f, .75f, 1, 1}, {.25f, 1, .25f, 1}, {1, 1, 0, 1}, {1, .15f, .15f, 1}}; + +// The game's code for an ImGui key, -1 for one it has none for. +static int game_key_get(int key) +{ + for (auto [first, last, code] : GAME_KEY_RUNS) + if (key >= first && key <= last) return code + key - first; + auto found = std::ranges::find(GAME_KEYS, (ImGuiKey)key, &std::pair::first); + return found == std::end(GAME_KEYS) ? -1 : found->second; +} + +static const char* key_name_get(int key) +{ + return ImGui::IsNamedKey((ImGuiKey)key) ? ImGui::GetKeyName((ImGuiKey)key) : KEY_UNKNOWN; +} + +// The selected entry of a radio button or combobox. +static const char* list_value_get(CustomElement& element) +{ + bool isInRange = element.index >= 0 && element.index < (int)element.values.size(); + return isInRange ? element.values[element.index].c_str() : KEY_UNKNOWN; +} + +// Pushes what an element's function gets (PropagateCallbackData): its value, else how often it was clicked. +static int callback_data_push(lua_State* state, CustomElement& element) +{ + switch (element.type) + { + case CUSTOM_INPUT_INT: + case CUSTOM_DRAG_INT: + case CUSTOM_SLIDER_INT: + lua_pushinteger(state, element.currentIntVal); + return 1; + case CUSTOM_INPUT_FLOAT: + case CUSTOM_DRAG_FLOAT: + case CUSTOM_SLIDER_FLOAT: + lua_pushnumber(state, element.currentFloatVal); + return 1; + case CUSTOM_COLOR_EDIT: + { + int channels = element.isColorAlpha ? (int)std::size(element.rgba) : (int)std::size(element.rgba) - 1; + for (int channel = 0; channel < channels; channel++) lua_pushnumber(state, element.rgba[channel]); + return channels; + } + case CUSTOM_CHECKBOX: + lua_pushboolean(state, element.isChecked); + return 1; + case CUSTOM_RADIO_BUTTON: + case CUSTOM_COMBOBOX: + lua_pushinteger(state, element.index); + lua_pushstring(state, list_value_get(element)); + return 2; + case CUSTOM_INPUT_TEXT: + case CUSTOM_INPUT_TEXT_WITH_HINT: + case CUSTOM_INPUT_TEXT_MULTILINE: + lua_pushstring(state, element.inputText.c_str()); + return 1; + case CUSTOM_INPUT_CONTROLLER: + case CUSTOM_INPUT_KEYBOARD: + lua_pushinteger(state, game_key_get(element.currentIntVal)); + lua_pushstring(state, key_name_get(element.currentIntVal)); + return 2; + default: + lua_pushnumber(state, element.clickCounter); + return 1; + } +} + +// Runs an element's function for a callback, an error in the console when it raises one. +static void callback_run(CustomElement& element, int function, CustomCallback type) +{ + lua_State* state = lua_engine_get().state; + if (!function || !state) return; + + int top = lua_gettop(state); + lua_rawgeti(state, LUA_REGISTRYINDEX, function); + if (lua_pcall(state, callback_data_push(state, element), 1, 0) != LUA_OK) + { + const char* error = lua_tostring(state, -1); + g_game->console.PrintError(std::string("ImGui encountered an error in the '") + CALLBACK_NAMES[type] + + "' callback of element '" + element.id + "': " + (error ? error : "") + "\n"); + } + lua_settop(state, top); +} + +// Runs an element's Render function, before it draws. +static void render_callback_run(CustomElement& element) +{ + if (auto render = element.callbacks.find(CUSTOM_RENDER); render != element.callbacks.end()) + callback_run(element, render->second, CUSTOM_RENDER); +} + +// Runs an element's functions whose condition the item just drawn meets. A click also counts, toggles it and opens +// its popup. +static void callbacks_run(CustomElement& element) +{ + for (auto [type, function] : std::map(element.callbacks)) + { + bool isMet = false; + switch (type) + { + case CUSTOM_CLICKED: + isMet = ImGui::IsItemClicked(); + if (!isMet) break; + element.clickCounter++; + element.isActive = !element.isActive; + if (element.triggerPopup) ImGui::OpenPopup(element.triggerPopup->id.c_str()); + break; + case CUSTOM_HOVERED: + isMet = ImGui::IsItemHovered(); + break; + case CUSTOM_ACTIVE: + isMet = ImGui::IsItemActive(); + break; + case CUSTOM_FOCUSED: + isMet = ImGui::IsItemFocused(); + break; + case CUSTOM_VISIBLE: + isMet = ImGui::IsItemVisible(); + break; + case CUSTOM_EDITED: + isMet = ImGui::IsItemEdited(); + break; + case CUSTOM_ACTIVATED: + isMet = ImGui::IsItemActivated(); + element.isActive = element.isActive || isMet; + break; + case CUSTOM_DEACTIVATED: + isMet = ImGui::IsItemDeactivated(); + element.isActive = element.isActive && !isMet; + break; + case CUSTOM_DEACTIVATED_AFTER_EDIT: + isMet = ImGui::IsItemDeactivatedAfterEdit(); + break; + case CUSTOM_TOGGLED_OPEN: + isMet = ImGui::IsItemToggledOpen(); + break; + default: + break; + } + if (isMet) callback_run(element, function, type); + } +} + +// The element's id seed (Element::GetHash). +static int element_hash_get(CustomElement& element) +{ + size_t name = std::hash{}(element.name); + size_t id = std::hash{}(element.id); + size_t type = std::hash{}(element.type); + return (int)(name ^ (id << 1) ^ (type << 1)); +} + +// Pushes an element's style colors while it draws, or pops them. +static void colors_push(CustomElement& element) +{ + for (CustomColor& color : element.colors) + { + auto [red, green, blue, alpha] = color.rgba; + if (color.type >= 0 && color.type < (int)std::size(STYLE_COLORS)) + ImGui::PushStyleColor(STYLE_COLORS[color.type], {red, green, blue, alpha}); + } +} + +static void colors_pop(CustomElement& element) +{ + ImGui::PopStyleColor((int)std::ranges::count_if(element.colors, [](CustomColor& color) { + return color.type >= 0 && color.type < (int)std::size(STYLE_COLORS); + })); +} + +// A dimmed (?) whose tooltip is the text. +static void help_marker_render(const char* text) +{ + ImGui::TextDisabled("(?)"); + if (!ImGui::IsItemHovered(ImGuiHoveredFlags_DelayShort) || !ImGui::BeginTooltip()) return; + ImGui::PushTextWrapPos(ImGui::GetFontSize() * TOOLTIP_WRAP_EMS); + ImGui::TextUnformatted(text); + ImGui::PopTextWrapPos(); + ImGui::EndTooltip(); +} + +// A window's right click menu, which pins it to stay while the overlay is hidden. +static void window_context_menu_render(bool& isPinned) +{ + if (!ImGui::BeginPopupContextItem()) return; + ImGui::MenuItem("Pin Window", nullptr, &isPinned); + if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal) && ImGui::BeginTooltip()) + { + ImGui::PushTextWrapPos(ImGui::GetFontSize() * TOOLTIP_WRAP_EMS); + ImGui::TextUnformatted("**Pinning a window will keep it visible even after closing Dev Tools."); + ImGui::PopTextWrapPos(); + ImGui::EndTooltip(); + } + ImGui::EndPopup(); +} + +// A Change button that, once pressed, takes the next keyboard key or gamepad button (Escape cancels). The key taken, +// ImGuiKey_None until then. +static ImGuiKey key_change_render(bool isController, bool& isWaiting) +{ + if (ImGui::Button("Change")) isWaiting = true; + if (!isWaiting || !ImGui::BeginTooltip()) return ImGuiKey_None; + + ImGuiKey first = isController ? ImGuiKey_GamepadStart : ImGuiKey_Tab; + ImGuiKey last = isController ? ImGuiKey_GamepadRStickDown : ImGuiKey_KeypadEqual; + ImGuiKey taken = ImGuiKey_None; + ImGui::SetWindowFocus(); + ImGui::TextUnformatted(isController ? "**Press a button on your controller." : "**Press a key on your keyboard."); + ImGui::TextUnformatted("**Press ESC to cancel input"); + for (int key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key++) + { + if (!ImGui::IsKeyDown((ImGuiKey)key)) continue; + if (key == ImGuiKey_Escape) isWaiting = false; + else if (key >= first && key <= last) + { + isWaiting = false; + taken = (ImGuiKey)key; + } + } + ImGui::EndTooltip(); + return taken; +} + +// The menu bar's width left for the mods' menus, past the overflow menu's. +static float menu_space_get() +{ + float overflowWidth = ImGui::CalcTextSize(ICON_ELLIPSIS).x + ImGui::GetStyle().FramePadding.x * 2; + return ImGui::GetContentRegionAvail().x - overflowWidth - ImGui::GetStyle().WindowPadding.x * 2; +} + +static void elements_render(std::list& elements, std::vector* overflow); + +// Draws an element's children when its container opened. +static void children_render(CustomElement& element, std::vector* overflow) +{ + callbacks_run(element); + elements_render(element.children, overflow); +} + +// Draws one element and runs its functions. Top menus past the menu bar's end go to overflow instead. +static void element_render(CustomElement& element, std::vector* overflow) +{ + const char* name = element.name.c_str(); + ImVec2 size = {element.sizeX, element.sizeY}; + + switch (element.type) + { + case CUSTOM_COLLAPSING_HEADER: + if (ImGui::CollapsingHeader(name)) children_render(element, overflow); + break; + case CUSTOM_TREE_NODE: + if (!ImGui::TreeNode(name)) break; + children_render(element, overflow); + ImGui::TreePop(); + break; + case CUSTOM_POPUP: + if (std::exchange(element.isUserVisible, false)) ImGui::OpenPopup(element.id.c_str()); + if (!ImGui::BeginPopup(element.id.c_str())) break; + elements_render(element.children, overflow); + ImGui::EndPopup(); + break; + case CUSTOM_TAB_BAR: + if (!ImGui::BeginTabBar(element.id.c_str())) break; + children_render(element, overflow); + ImGui::EndTabBar(); + break; + case CUSTOM_TAB: + if (!ImGui::BeginTabItem(name)) break; + children_render(element, overflow); + ImGui::EndTabItem(); + break; + case CUSTOM_WINDOW: + if (ImGui::BeginChild(name, size, element.childFlags, element.windowFlags)) + children_render(element, overflow); + ImGui::EndChild(); + break; + case CUSTOM_MENU: + if (!ImGui::BeginMenu(name)) break; + children_render(element, overflow); + ImGui::EndMenu(); + break; + case CUSTOM_MENU_ITEM: + ImGui::MenuItem(name, nullptr, &element.isActive); + callbacks_run(element); + break; + case CUSTOM_TEXT: + ImGui::TextUnformatted(name); + callbacks_run(element); + break; + case CUSTOM_TEXT_WRAPPED: + ImGui::TextWrapped("%s", name); + callbacks_run(element); + break; + case CUSTOM_SEPARATOR_TEXT: + ImGui::SeparatorText(name); + callbacks_run(element); + break; + case CUSTOM_BULLET_TEXT: + ImGui::BulletText("%s", name); + callbacks_run(element); + break; + case CUSTOM_SEPARATOR: + ImGui::Separator(); + callbacks_run(element); + break; + case CUSTOM_SAME_LINE: + ImGui::SameLine(); + callbacks_run(element); + break; + case CUSTOM_BUTTON: + ImGui::Button(name, size); + callbacks_run(element); + break; + case CUSTOM_SMALL_BUTTON: + ImGui::SmallButton(name); + callbacks_run(element); + break; + case CUSTOM_INPUT_INT: + ImGui::InputInt(name, &element.currentIntVal, (int)element.step, (int)element.stepFast); + callbacks_run(element); + break; + case CUSTOM_INPUT_FLOAT: + ImGui::InputFloat(name, &element.currentFloatVal, element.step, element.stepFast); + callbacks_run(element); + break; + case CUSTOM_DRAG_INT: + ImGui::DragInt(name, &element.currentIntVal, element.speed, (int)element.minVal, (int)element.maxVal, + element.formatting.c_str()); + callbacks_run(element); + break; + case CUSTOM_DRAG_FLOAT: + ImGui::DragFloat(name, &element.currentFloatVal, element.speed, element.minVal, element.maxVal, + element.formatting.c_str()); + callbacks_run(element); + break; + case CUSTOM_SLIDER_INT: + ImGui::SliderInt(name, &element.currentIntVal, (int)element.minVal, (int)element.maxVal, + element.formatting.c_str()); + callbacks_run(element); + break; + case CUSTOM_SLIDER_FLOAT: + ImGui::SliderFloat(name, &element.currentFloatVal, element.minVal, element.maxVal, + element.formatting.c_str()); + callbacks_run(element); + break; + case CUSTOM_COLOR_EDIT: + if (element.isColorAlpha) ImGui::ColorEdit4(name, element.rgba); + else ImGui::ColorEdit3(name, element.rgba); + callbacks_run(element); + break; + case CUSTOM_CHECKBOX: + ImGui::Checkbox(name, &element.isChecked); + callbacks_run(element); + break; + case CUSTOM_RADIO_BUTTON: + for (int index = 0; index < (int)element.values.size(); index++) + { + ImGui::RadioButton(element.values[index].c_str(), &element.index, index); + callbacks_run(element); + if (element.isSameLine && index < (int)element.values.size() - 1) ImGui::SameLine(); + } + break; + case CUSTOM_COMBOBOX: + if (element.isSlider) + { + ImGui::SliderInt(name, &element.index, 0, (int)element.values.size() - 1, list_value_get(element)); + callbacks_run(element); + break; + } + if (!ImGui::BeginCombo(name, list_value_get(element))) break; + for (int index = 0; index < (int)element.values.size(); index++) + { + bool isSelected = element.index == index; + if (ImGui::Selectable(element.values[index].c_str(), isSelected)) + { + element.index = index; + callbacks_run(element); + } + if (isSelected) ImGui::SetItemDefaultFocus(); + } + ImGui::EndCombo(); + break; + case CUSTOM_INPUT_TEXT: + case CUSTOM_INPUT_TEXT_WITH_HINT: + if (element.hintText.empty()) ImGui::InputText(name, &element.inputText); + else ImGui::InputTextWithHint(name, element.hintText.c_str(), &element.inputText); + callbacks_run(element); + break; + case CUSTOM_INPUT_TEXT_MULTILINE: + ImGui::InputTextMultiline(name, &element.inputText, + {-FLT_MIN, ImGui::GetTextLineHeight() * element.lineCount}); + callbacks_run(element); + break; + case CUSTOM_INPUT_CONTROLLER: + case CUSTOM_INPUT_KEYBOARD: + { + if (element.inputText.empty()) element.inputText = key_name_get(element.currentIntVal); + ImGuiKey taken = key_change_render(element.type == CUSTOM_INPUT_CONTROLLER, element.isActive); + if (taken != ImGuiKey_None) + { + element.inputText = ImGui::GetKeyName(taken); + element.currentIntVal = taken; + if (auto edited = element.callbacks.find(CUSTOM_EDITED); edited != element.callbacks.end()) + callback_run(element, edited->second, CUSTOM_EDITED); + } + ImGui::SameLine(); + ImGui::InputText(name, &element.inputText, ImGuiInputTextFlags_ReadOnly); + break; + } + case CUSTOM_PLOT_LINES: + ImGui::PlotLines(name, element.plotValues.data(), (int)element.plotValues.size(), 0, + element.hintText.c_str(), element.minVal, element.maxVal, size); + callbacks_run(element); + break; + case CUSTOM_PLOT_HISTOGRAM: + ImGui::PlotHistogram(name, element.plotValues.data(), (int)element.plotValues.size(), 0, + element.hintText.c_str(), element.minVal, element.maxVal, size); + callbacks_run(element); + break; + case CUSTOM_PROGRESS_BAR: + ImGui::ProgressBar(element.currentFloatVal, size, + element.hintText == PROGRESS_DEFAULT ? nullptr : element.hintText.c_str()); + if (!element.name.empty()) + { + ImGui::SameLine(0, ImGui::GetStyle().ItemInnerSpacing.x); + ImGui::TextUnformatted(name); + } + callbacks_run(element); + break; + } +} + +// Draws an element in a list (DrawElements): its Render function first, then the element with its id seed, width and +// colors, then its tooltip and help marker. A top menu past the menu bar's end goes to overflow instead. +static void element_wrap_render(CustomElement& element, std::vector* overflow) +{ + render_callback_run(element); + if (element.isRemoved) return; + + bool isSized = element.type != CUSTOM_WINDOW && element.type != CUSTOM_BUTTON && + element.type != CUSTOM_PLOT_LINES && element.type != CUSTOM_PLOT_HISTOGRAM; + bool isTopMenu = overflow && element.type == CUSTOM_MENU && !element.parent; + float menuWidth = ImGui::CalcTextSize(element.name.c_str()).x + ImGui::GetStyle().FramePadding.x * 2; + if (isTopMenu && menu_space_get() - menuWidth <= 0) + { + overflow->push_back(&element); + return; + } + + ImGui::PushID(element_hash_get(element)); + if (isSized) ImGui::PushItemWidth(element.sizeX); + colors_push(element); + element_render(element, overflow); + colors_pop(element); + if (!element.tooltipText.empty() && ImGui::IsItemHovered()) ImGui::SetTooltip("%s", element.tooltipText.c_str()); + if (!element.helpmarkerText.empty()) + { + ImGui::SameLine(); + help_marker_render(element.helpmarkerText.c_str()); + } + if (isSized) ImGui::PopItemWidth(); + ImGui::PopID(); +} + +static void elements_render(std::list& elements, std::vector* overflow) +{ + for (CustomElement& element : elements) + if (!element.isRemoved) element_wrap_render(element, overflow); +} + +// The open state each mod window had when the layout was saved, by title, restored once the windows draw. +static std::map savedVisibility; + +// Keeps the mods' windows' open and pinned states in the layout file, as REPENTOGON's window settings do. Only the +// open state is read back, as REPENTOGON does. +void Overlay::custom_settings_register() +{ + ImGuiSettingsHandler handler; + handler.TypeName = "RepentogonWindow"; + handler.TypeHash = ImHashStr(handler.TypeName); + handler.ReadOpenFn = [](ImGuiContext*, ImGuiSettingsHandler*, const char* name) -> void* { + return &savedVisibility[name]; + }; + handler.ReadLineFn = [](ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line) { + int isShown = 0; + if (sscanf(line, "Visible=%d", &isShown) == 1) *(bool*)entry = isShown; + }; + handler.WriteAllFn = [](ImGuiContext*, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buffer) { + for (CustomElement& window : customImGui.windows) + { + if (window.isRemoved) continue; + buffer->appendf("[%s][%s]\nVisible=%d\nPinned=%d\n\n", handler->TypeName, window.name.c_str(), + window.isEvaluatedVisible, window.isWindowPinned); + } + }; + ImGui::AddSettingsHandler(&handler); +} + +// The mods' menus in the menu bar (DrawMenu), those past its end in a ... menu. +void Overlay::custom_menus_render() +{ + std::vector overflow; + customImGui.isDrawing = true; + elements_render(customImGui.menus, &overflow); + if (!overflow.empty()) + { + ImGui::SetCursorPosX(ImGui::GetCursorPosX() + menu_space_get()); + if (ImGui::BeginMenu(ICON_ELLIPSIS)) + { + for (CustomElement* menu : overflow) element_wrap_render(*menu, nullptr); + ImGui::EndMenu(); + } + } + customImGui.isDrawing = false; + customImGui.elements_sweep(); +} + +// The mods' windows (DrawWindows): the open ones while the overlay shows, only the pinned ones, fixed in place and +// letting the input through, while it is hidden. +void Overlay::custom_windows_render() +{ + constexpr ImGuiWindowFlags HIDDEN_FLAGS = + ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoInputs; + + customImGui.isDrawing = true; + for (CustomElement& window : customImGui.windows) + { + if (window.isRemoved) continue; + if (auto saved = savedVisibility.find(window.name); saved != savedVisibility.end()) + { + window.visible_set(saved->second); + window.visible_evaluate(); + savedVisibility.erase(saved); + } + ImGui::PushID(element_hash_get(window)); + ImGui::SetNextWindowSize({WINDOW_WIDTH_FIRST, WINDOW_HEIGHT_FIRST}, ImGuiCond_FirstUseEver); + colors_push(window); + if ((isVisible || window.isWindowPinned) && window.isEvaluatedVisible) + { + render_callback_run(window); + int flags = window.windowFlags | (isVisible ? 0 : HIDDEN_FLAGS); + if (ImGui::Begin(window.name.c_str(), &window.isEvaluatedVisible, flags)) + { + if (std::exchange(window.isPositionRequested, false)) + ImGui::SetWindowPos({window.positionX, window.positionY}); + if (std::exchange(window.isSizeRequested, false)) ImGui::SetWindowSize({window.sizeX, window.sizeY}); + window_context_menu_render(window.isWindowPinned); + elements_render(window.children, nullptr); + } + ImGui::End(); + } + colors_pop(window); + ImGui::PopID(); + } + customImGui.isDrawing = false; + customImGui.elements_sweep(); +} + +// The notifications at the top centre, newest first, each fading out over its last two seconds before it goes. +void Overlay::notifications_render() +{ + constexpr ImGuiWindowFlags FLAGS = ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | + ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoNav | + ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoInputs; + uint64_t now = SDL_GetTicks(); + float top = NOTIFICATION_TOP + (isVisible ? ImGui::GetFrameHeight() : 0); + std::deque& notifications = customImGui.notifications; + + for (size_t index = 0; index < notifications.size(); index++) + { + CustomNotification& notification = notifications[index]; + ImVec4 color = SEVERITY_COLORS[notification.severity]; + uint64_t fadeStart = notification.deletionTime - std::min(notification.deletionTime, NOTIFICATION_FADE_MS); + bool isFading = fadeStart < now; + + ImGui::SetNextWindowPos({ImGui::GetMainViewport()->GetCenter().x, top}, ImGuiCond_Always, {.5f, 0}); + if (isFading) + { + color.w = 1 - (float)(now - fadeStart) / NOTIFICATION_FADE_MS; + ImGui::SetNextWindowBgAlpha(color.w); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4()); + } + if (ImGui::Begin(("##" + std::to_string(index)).c_str(), nullptr, FLAGS)) + { + ImGui::BringWindowToDisplayFront(ImGui::GetCurrentWindow()); + ImGui::SetWindowSize({}, ImGuiCond_Always); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() - NOTIFICATION_TEXT_RAISE); + ImGui::TextColored(color, "%s", SEVERITY_ICONS[notification.severity]); + ImGui::SameLine(0, NOTIFICATION_ICON_GAP); + ImGui::TextColored(color, "%s", notification.text.c_str()); + top += ImGui::GetWindowSize().y + NOTIFICATION_GAP; + } + ImGui::End(); + if (isFading) ImGui::PopStyleColor(); + } + std::erase_if(notifications, [&](CustomNotification& notification) { return notification.deletionTime < now; }); +} +#endif diff --git a/src/ui/overlay/overlay.cpp b/src/ui/overlay/overlay.cpp index c78faae..325fa54 100644 --- a/src/ui/overlay/overlay.cpp +++ b/src/ui/overlay/overlay.cpp @@ -3,6 +3,9 @@ #include "engine/data.h" #include "engine/gl.h" #include "engine/platform.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/custom_imgui.h" +#endif #include #include #include @@ -33,9 +36,10 @@ constexpr ImWchar ICON_TERMINAL = 0xF120; constexpr ImWchar ICON_GEARS = 0xF085; constexpr ImWchar ICON_SPARKLES = 0xE2CA; // wand-magic-sparkles constexpr ImWchar ICON_BUG = 0xF188; -constexpr ImWchar ICON_RANGES[] = {ICON_GEARS, ICON_GEARS, ICON_HIDE, ICON_HIDE, ICON_TERMINAL, - ICON_TERMINAL, ICON_TOOLS, ICON_TOOLS, ICON_BUG, ICON_BUG, - ICON_SPARKLES, ICON_SPARKLES, 0}; +// Font Awesome's whole private use range, as mods' menus name any of its icons. +constexpr ImWchar ICON_FIRST = 0xE000; +constexpr ImWchar ICON_LAST = 0xF8FF; +constexpr ImWchar ICON_RANGES[] = {ICON_FIRST, ICON_LAST, 0}; // Each window's name and icon, in OverlayWindow order. constexpr const char* WINDOW_NAMES[OVERLAY_WINDOW_COUNT] = {"Console", "Game Options", "Mods", "Debug"}; @@ -108,6 +112,9 @@ void Overlay::load() fonts_load(); ImGui_ImplSDL3_InitForOpenGL(platform.window, platform.context); ImGui_ImplOpenGL3_Init(GLSL_VERSION); +#ifdef ISAAC_REPENTOGON + custom_settings_register(); +#endif ImGui::LoadIniSettingsFromDisk(io.IniFilename); isDockPending = std::ranges::none_of(WINDOW_NAMES, [](const char* name) { ImGuiWindowSettings* settings = ImGui::FindWindowSettingsByID(ImHashStr(name)); @@ -181,6 +188,9 @@ void Overlay::menu_bar_render() ImGui::MenuItem(icon_label(WINDOW_ICONS[window], WINDOW_NAMES[window]).c_str(), nullptr, &isOpen[window]); ImGui::EndMenu(); } +#ifdef ISAAC_REPENTOGON + custom_menus_render(); +#endif ImGui::EndMainMenuBar(); } @@ -193,20 +203,26 @@ static bool* close_get(const char* name, bool& isOpen) } // Draws the overlay over the finished frame, on the window's own framebuffer. Unifont grows by whole multiples with -// the window, and the metrics with it. +// the window, and the metrics with it. While hidden it draws only the mods' pinned windows and notifications. void Overlay::render() { constexpr void (Overlay::*WINDOW_RENDERS[OVERLAY_WINDOW_COUNT])() = { &Overlay::console_render, &Overlay::options_render, &Overlay::mods_render, &Overlay::debug_render}; - if (!isReady || !isVisible) return; + if (!isReady) return; +#ifdef ISAAC_REPENTOGON + customImGui.windows_evaluate(); + if (!isVisible && !customImGui.is_shown_hidden()) return; +#else + if (!isVisible) return; +#endif ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplSDL3_NewFrame(); float displayScale = std::max(1.0f, std::round(ImGui::GetIO().DisplaySize.y / SCALE_HEIGHT)); if (displayScale != std::exchange(scale, displayScale)) style_load(displayScale); ImGui::NewFrame(); - menu_bar_render(); + if (isVisible) menu_bar_render(); // The first dock picks its own front tab, so the console comes to the front a frame later. bool isDocking = std::exchange(isDockPending, false); @@ -219,7 +235,7 @@ void Overlay::render() for (const char* name : WINDOW_NAMES) ImGui::DockBuilderDockWindow(name, dock); ImGui::DockBuilderFinish(dock); } - for (int window = 0; window < OVERLAY_WINDOW_COUNT; window++) + for (int window = 0; window < OVERLAY_WINDOW_COUNT && isVisible; window++) { if (!isOpen[window]) continue; if (window == OVERLAY_CONSOLE && !isDocking && std::exchange(isConsoleFrontPending, false)) @@ -228,6 +244,10 @@ void Overlay::render() (this->*WINDOW_RENDERS[window])(); ImGui::End(); } +#ifdef ISAAC_REPENTOGON + custom_windows_render(); + notifications_render(); +#endif ImGui::Render(); int framebuffer = 0; diff --git a/src/ui/overlay/overlay.h b/src/ui/overlay/overlay.h index c96efb0..bef87d4 100644 --- a/src/ui/overlay/overlay.h +++ b/src/ui/overlay/overlay.h @@ -89,6 +89,10 @@ private: void mod_render(ModEntry& mod, float width); unsigned int thumbnail_get(ModEntry& mod); void debug_render(); + void custom_settings_register(); + void custom_menus_render(); + void custom_windows_render(); + void notifications_render(); }; extern Overlay overlay; diff --git a/src/ui/pause_screen.cpp b/src/ui/pause_screen.cpp index 99e235a..c5c4ccb 100644 --- a/src/ui/pause_screen.cpp +++ b/src/ui/pause_screen.cpp @@ -20,6 +20,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/player.h" #endif constexpr const char* PAUSE_ANM2 = "gfx/ui/PauseScreen_small.anm2"; @@ -997,7 +998,11 @@ void PauseScreen::selection_confirm(int controller) menuSprite.overlayAnimState.SetAnimationData(nullptr); Entity_Player* player = g_game->GetPlayer(0); +#ifdef ISAAC_REPENTOGON + if (player->isDead && extra_lives_all_get(*player) < 1) +#else if (player->isDead && player->GetExtraLives() < 1) +#endif game_save_delete(); game_fade_out(); break; diff --git a/src/ui/popups.cpp b/src/ui/popups.cpp index 1489844..1045485 100644 --- a/src/ui/popups.cpp +++ b/src/ui/popups.cpp @@ -10,6 +10,9 @@ #include #include #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/achievements.h" +#endif constexpr const char* POPUP_WHITE_PNG = "gfx/ui/Popup_White.png"; constexpr const char* POPUP_BEIGE_PNG = "gfx/ui/Popup_Beige.png"; @@ -901,7 +904,11 @@ void AchievementOverlay::Update() state = OVERLAY_APPEARING; bool isSmall = g_manager->optionsConfig.popupsMode == POPUPS_SMALL; +#ifdef ISAAC_REPENTOGON + AchievementEntry& entry = *achievement_entry_get(*this, currentEntry); +#else AchievementEntry& entry = entries[currentEntry]; +#endif LayerState* paper = sprite.GetLayer(OVERLAY_PAPER_LAYER); sprite.scale = isSmall ? vector_make(OVERLAY_SMALL_SCALE, OVERLAY_SMALL_SCALE) : vector_make(1, 1); if (paper) paper->isVisible = !isSmall; diff --git a/src/ui/stat_hud.cpp b/src/ui/stat_hud.cpp index 34a879e..4ba5aac 100644 --- a/src/ui/stat_hud.cpp +++ b/src/ui/stat_hud.cpp @@ -3,6 +3,9 @@ #include "game/game.h" #include "game/manager.h" #include "level/room.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/ui_patches.h" +#endif #include #include #include @@ -125,7 +128,8 @@ void StatHUD::Update() // 0084ca00 Recomputes the stats the flags name for a shown player, a change animating unless the player was just // spawned. Range counts in tiles and tears per second. The deal chance (none when no deal can spawn) splits between the -// devil and the angel by the angel chance, or shows whole for both with Duality. +// devil and the angel by the angel chance, or shows whole for both with Duality. REPENTOGON's StatHUDPlanetarium has +// the unused stat take the planetarium chance. void StatHUD::RecomputeStats(int playerId, uint32_t flags) { if (playerId < 0 || !players[playerId].player) return; @@ -147,7 +151,11 @@ void StatHUD::RecomputeStats(int playerId, uint32_t flags) stats[STAT_DEVIL_CHANCE].set(devilShare * dealChance * PERCENT, isAnimated); stats[STAT_ANGEL_CHANCE].set(angelShare * dealChance * PERCENT, isAnimated); } +#ifdef ISAAC_REPENTOGON + if (flags & STAT_FLAG_UNUSED) stats[STAT_UNUSED].set(planetarium_chance_get(), isAnimated); +#else if (flags & STAT_FLAG_UNUSED) stats[STAT_UNUSED].set(0, isAnimated); +#endif if (flags & STAT_FLAG_PLANETARIUM_CHANCE) stats[STAT_PLANETARIUM_CHANCE].set(game.itemPool.unkFloat674 * PERCENT, isAnimated); } @@ -167,12 +175,14 @@ void StatHUD::update_player(Entity_Player* oldPlayer, Entity_Player* newPlayer) } // The texts of a stat: its value, and its change (empty for none). With a Rosary Bead the devil chance reads 0% and -// the angel chance the whole deal chance, its change shown as long as the devil's. +// the angel chance the whole deal chance, its change shown as long as the devil's. REPENTOGON's planetarium chance +// (the unused stat) reads as a percentage too. static void stat_text_get(StatHUDPlayer& slot, int statIndex, char* valueText, char* changeText) { StatTracker& stat = slot.stats[statIndex]; - bool isPercent = statIndex == STAT_DEVIL_CHANCE || statIndex == STAT_ANGEL_CHANCE; - bool isRosary = isPercent && slot.player->HasTrinket(TRINKET_ROSARY_BEAD, ITEM_CHECK_MODIFIED); + bool isDeal = statIndex == STAT_DEVIL_CHANCE || statIndex == STAT_ANGEL_CHANCE; + bool isPercent = isDeal || statIndex == STAT_UNUSED; + bool isRosary = isDeal && slot.player->HasTrinket(TRINKET_ROSARY_BEAD, ITEM_CHECK_MODIFIED); float value = stat.value; float change = stat.change; @@ -221,17 +231,23 @@ static void stat_text_render(StatHUDPlayer& slot, int statIndex, Vector at, floa // 0084c2c0 With the found HUD on and a player shown, draws the stat icons down from a position (the deal chances as // one with Duality), then each player's texts beside them: the second player's a little lower and to the right, and -// none for the stats players share (the deal chances, and speed for Jacob and Esau). +// none for the stats players share (the deal chances, and speed for Jacob and Esau). REPENTOGON's StatHUDPlanetarium +// adds the planetarium chance below, shared too. void StatHUD::Render(Vector at) { if (!g_manager->optionsConfig.isFoundHudEnabled || (!players[0].player && !players[1].player)) return; + int statCount = STAT_UNUSED; +#ifdef ISAAC_REPENTOGON + if (is_planetarium_chance_shown()) statCount++; +#endif + bool isTwoPlayers = players[0].player && players[1].player; float rowSpacing = isTwoPlayers ? ROW_SPACING_TWO_PLAYERS : ROW_SPACING; float textRaise = isTwoPlayers ? TEXT_RAISE_TWO_PLAYERS : TEXT_RAISE; SpriteDraw icon; icon.position = at; - for (int i = 0; i < STAT_UNUSED; i++) + for (int i = 0; i < statCount; i++) { bool isDealShared = i == STAT_DEVIL_CHANCE && isDualityOwned; if (sprite.animState.animData && isDealShared) @@ -253,11 +269,11 @@ void StatHUD::Render(Vector at) bool isJacobOrEsau = playerType == PLAYER_JACOB || playerType == PLAYER_ESAU; float column = (float)playerIndex * PLAYER_COLUMN_SHIFT + at.x; float rowY = at.y; - for (int i = 0; i < STAT_UNUSED; i++, rowY += rowSpacing) + for (int i = 0; i < statCount; i++, rowY += rowSpacing) { if (i == STAT_ANGEL_CHANCE && isDualityOwned) continue; - bool isShared = i == STAT_DEVIL_CHANCE || i == STAT_ANGEL_CHANCE || (i == STAT_SPEED && isJacobOrEsau); + bool isShared = i >= STAT_DEVIL_CHANCE || (i == STAT_SPEED && isJacobOrEsau); if (isShared && playerIndex != 0) continue; float y = isShared ? rowY : (float)playerIndex * PLAYER_ROW_SHIFT + textRaise + rowY; Vector textAt = vector_make(column + shake.x + HUD_TEXT_OFFSET_X, y + shake.y + HUD_TEXT_OFFSET_Y);