isaacscript-common 2.3.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cachedClasses.lua +24 -0
- package/callbacks/customRevive.lua +2 -0
- package/callbacks/itemPickup.lua +2 -0
- package/callbacks/postBombInitLate.lua +2 -0
- package/callbacks/postBoneSwing.lua +2 -0
- package/callbacks/postCollectibleInitFirst.lua +2 -0
- package/callbacks/postCursedTeleport.lua +2 -0
- package/callbacks/postCustomDoorEnter.lua +44 -0
- package/callbacks/postDoorRender.lua +2 -0
- package/callbacks/postDoorUpdate.lua +2 -0
- package/callbacks/postEffectInitLate.lua +2 -0
- package/callbacks/postEffectStateChanged.lua +2 -0
- package/callbacks/postEsauJr.lua +2 -0
- package/callbacks/postFamiliarInitLate.lua +2 -0
- package/callbacks/postFamiliarStateChanged.lua +2 -0
- package/callbacks/postFlip.lua +2 -0
- package/callbacks/postGreedModeWave.lua +2 -0
- package/callbacks/postGridEntity.lua +2 -0
- package/callbacks/postGridEntityCollision.lua +2 -0
- package/callbacks/postGridEntityRender.lua +2 -0
- package/callbacks/postHolyMantleRemoved.lua +2 -0
- package/callbacks/postKnifeInitLate.lua +2 -0
- package/callbacks/postLaserInitLate.lua +2 -0
- package/callbacks/postNPCInitLate.lua +2 -0
- package/callbacks/postNPCStateChanged.lua +2 -0
- package/callbacks/postNewRoomEarly.lua +2 -0
- package/callbacks/postPickupCollect.lua +2 -0
- package/callbacks/postPickupInitLate.lua +2 -0
- package/callbacks/postPickupStateChanged.lua +2 -0
- package/callbacks/postPitRender.lua +2 -0
- package/callbacks/postPitUpdate.lua +2 -0
- package/callbacks/postPlayerChangeHealth.lua +2 -0
- package/callbacks/postPlayerChangeType.lua +2 -0
- package/callbacks/postPlayerFatalDamage.lua +2 -0
- package/callbacks/postPlayerInitLate.lua +2 -0
- package/callbacks/postPlayerReordered.lua +2 -0
- package/callbacks/postPoopRender.lua +2 -0
- package/callbacks/postPoopUpdate.lua +2 -0
- package/callbacks/postPressurePlateRender.lua +2 -0
- package/callbacks/postPressurePlateUpdate.lua +2 -0
- package/callbacks/postProjectileInitLate.lua +2 -0
- package/callbacks/postPurchase.lua +2 -0
- package/callbacks/postRockRender.lua +2 -0
- package/callbacks/postRockUpdate.lua +2 -0
- package/callbacks/postRoomClearChanged.lua +2 -0
- package/callbacks/postSacrifice.lua +2 -0
- package/callbacks/postSlotInitUpdate.lua +2 -0
- package/callbacks/postSlotRender.lua +2 -0
- package/callbacks/postSpikesRender.lua +2 -0
- package/callbacks/postSpikesUpdate.lua +2 -0
- package/callbacks/postTNTRender.lua +2 -0
- package/callbacks/postTNTUpdate.lua +2 -0
- package/callbacks/postTearInitLate.lua +2 -0
- package/callbacks/postTearInitVeryLate.lua +2 -0
- package/callbacks/postTransformation.lua +2 -0
- package/callbacks/postTrinketBreak.lua +2 -0
- package/callbacks/preBerserkDeath.lua +2 -0
- package/callbacks/preNewLevel.lua +2 -0
- package/callbacks/reorderedCallbacks.lua +16 -0
- package/callbacks/subscriptions/postBombInitLate.lua +6 -0
- package/callbacks/subscriptions/postBoneSwing.lua +6 -0
- package/callbacks/subscriptions/postCollectibleInitFirst.lua +6 -0
- package/callbacks/subscriptions/postCursedTeleport.lua +6 -0
- package/callbacks/subscriptions/postCustomDoorEnter.lua +6 -0
- package/callbacks/subscriptions/postCustomRevive.lua +6 -0
- package/callbacks/subscriptions/postDoorRender.lua +6 -0
- package/callbacks/subscriptions/postDoorUpdate.lua +6 -0
- package/callbacks/subscriptions/postEffectInitLate.lua +6 -0
- package/callbacks/subscriptions/postEffectStateChanged.lua +6 -0
- package/callbacks/subscriptions/postEsauJr.lua +6 -0
- package/callbacks/subscriptions/postFamiliarInitLate.lua +6 -0
- package/callbacks/subscriptions/postFamiliarStateChanged.lua +6 -0
- package/callbacks/subscriptions/postFirstEsauJr.lua +6 -0
- package/callbacks/subscriptions/postFirstFlip.lua +6 -0
- package/callbacks/subscriptions/postFlip.lua +6 -0
- package/callbacks/subscriptions/postGameStartedReordered.lua +6 -0
- package/callbacks/subscriptions/postGreedModeWave.lua +6 -0
- package/callbacks/subscriptions/postGridEntityBroken.lua +6 -0
- package/callbacks/subscriptions/postGridEntityCollision.lua +6 -0
- package/callbacks/subscriptions/postGridEntityInit.lua +6 -0
- package/callbacks/subscriptions/postGridEntityRemove.lua +6 -0
- package/callbacks/subscriptions/postGridEntityRender.lua +6 -0
- package/callbacks/subscriptions/postGridEntityStateChanged.lua +6 -0
- package/callbacks/subscriptions/postGridEntityUpdate.lua +6 -0
- package/callbacks/subscriptions/postHolyMantleRemoved.lua +6 -0
- package/callbacks/subscriptions/postItemDischarged.lua +6 -0
- package/callbacks/subscriptions/postItemPickup.lua +6 -0
- package/callbacks/subscriptions/postKnifeInitLate.lua +6 -0
- package/callbacks/subscriptions/postLaserInitLate.lua +6 -0
- package/callbacks/subscriptions/postNPCInitLate.lua +6 -0
- package/callbacks/subscriptions/postNPCStateChanged.lua +6 -0
- package/callbacks/subscriptions/postNewLevelReordered.lua +6 -0
- package/callbacks/subscriptions/postNewRoomEarly.lua +6 -0
- package/callbacks/subscriptions/postNewRoomReordered.lua +6 -0
- package/callbacks/subscriptions/postPEffectUpdateReordered.lua +6 -0
- package/callbacks/subscriptions/postPickupCollect.lua +6 -0
- package/callbacks/subscriptions/postPickupInitLate.lua +6 -0
- package/callbacks/subscriptions/postPickupStateChanged.lua +6 -0
- package/callbacks/subscriptions/postPitRender.lua +6 -0
- package/callbacks/subscriptions/postPitUpdate.lua +6 -0
- package/callbacks/subscriptions/postPlayerChangeHealth.lua +6 -0
- package/callbacks/subscriptions/postPlayerChangeType.lua +6 -0
- package/callbacks/subscriptions/postPlayerFatalDamage.lua +6 -0
- package/callbacks/subscriptions/postPlayerInitLate.lua +6 -0
- package/callbacks/subscriptions/postPlayerInitReordered.lua +6 -0
- package/callbacks/subscriptions/postPlayerRenderReordered.lua +6 -0
- package/callbacks/subscriptions/postPlayerUpdateReordered.lua +6 -0
- package/callbacks/subscriptions/postPoopRender.lua +6 -0
- package/callbacks/subscriptions/postPoopUpdate.lua +6 -0
- package/callbacks/subscriptions/postPressurePlateRender.lua +6 -0
- package/callbacks/subscriptions/postPressurePlateUpdate.lua +6 -0
- package/callbacks/subscriptions/postProjectileInitLate.lua +6 -0
- package/callbacks/subscriptions/postPurchase.lua +6 -0
- package/callbacks/subscriptions/postRockRender.lua +6 -0
- package/callbacks/subscriptions/postRockUpdate.lua +6 -0
- package/callbacks/subscriptions/postRoomClearChanged.lua +6 -0
- package/callbacks/subscriptions/postSacrifice.lua +6 -0
- package/callbacks/subscriptions/postSlotAnimationChanged.lua +6 -0
- package/callbacks/subscriptions/postSlotDestroyed.lua +6 -0
- package/callbacks/subscriptions/postSlotInit.lua +6 -0
- package/callbacks/subscriptions/postSlotRender.lua +6 -0
- package/callbacks/subscriptions/postSlotUpdate.lua +6 -0
- package/callbacks/subscriptions/postSpikesRender.lua +6 -0
- package/callbacks/subscriptions/postSpikesUpdate.lua +6 -0
- package/callbacks/subscriptions/postTNTRender.lua +6 -0
- package/callbacks/subscriptions/postTNTUpdate.lua +6 -0
- package/callbacks/subscriptions/postTearInitLate.lua +6 -0
- package/callbacks/subscriptions/postTearInitVeryLate.lua +6 -0
- package/callbacks/subscriptions/postTransformation.lua +6 -0
- package/callbacks/subscriptions/postTrinketBreak.lua +6 -0
- package/callbacks/subscriptions/preBerserkDeath.lua +6 -0
- package/callbacks/subscriptions/preCustomRevive.lua +6 -0
- package/callbacks/subscriptions/preItemPickup.lua +6 -0
- package/callbacks/subscriptions/preNewLevel.lua +6 -0
- package/classes/DefaultMap.d.ts +70 -39
- package/classes/DefaultMap.lua +94 -43
- package/classes/ModUpgraded.d.ts +3 -3
- package/classes/ModUpgraded.lua +5 -0
- package/constants.lua +41 -0
- package/constantsFirstLast.lua +63 -0
- package/enums/HealthType.lua +3 -0
- package/enums/ModCallbackCustom.d.ts +1 -1
- package/enums/ModCallbackCustom.lua +6 -0
- package/enums/private/CopyableIsaacAPIClassType.lua +1 -0
- package/enums/private/SerializationBrand.lua +5 -0
- package/features/characterHealthConversion.lua +6 -0
- package/features/characterStats.lua +17 -0
- package/features/debugDisplay/exports.lua +90 -0
- package/features/deployJSONRoom.lua +56 -0
- package/features/disableInputs.lua +45 -0
- package/features/disableSound.lua +14 -0
- package/features/extraConsoleCommands/commandsDisplay.lua +90 -0
- package/features/extraConsoleCommands/init.lua +16 -0
- package/features/extraConsoleCommands/listCommands.lua +172 -0
- package/features/fadeInRemover.lua +10 -0
- package/features/fastReset.lua +10 -0
- package/features/forgottenSwitch.lua +4 -0
- package/features/getCollectibleItemPoolType.lua +5 -0
- package/features/playerInventory.lua +18 -0
- package/features/ponyDetection.lua +4 -0
- package/features/preventCollectibleRotation.lua +9 -0
- package/features/runInNFrames.lua +50 -0
- package/features/saveDataManager/constants.lua +1 -0
- package/features/saveDataManager/exports.lua +115 -0
- package/features/saveDataManager/main.lua +6 -0
- package/features/saveDataManager/maps.lua +3 -0
- package/features/saveDataManager/merge.lua +20 -0
- package/features/sirenHelpers.lua +13 -0
- package/features/taintedLazarusPlayers.lua +11 -0
- package/featuresInitialized.lua +6 -0
- package/functions/array.lua +85 -0
- package/functions/benchmark.lua +6 -0
- package/functions/boss.lua +35 -0
- package/functions/cacheFlag.lua +4 -0
- package/functions/cards.lua +60 -0
- package/functions/challenges.lua +1 -0
- package/functions/character.lua +23 -0
- package/functions/charge.lua +39 -0
- package/functions/chargeBar.lua +4 -0
- package/functions/collectibleCacheFlag.lua +15 -0
- package/functions/collectibleSet.lua +3 -0
- package/functions/collectibleTag.lua +9 -0
- package/functions/collectibles.lua +131 -0
- package/functions/color.lua +18 -0
- package/functions/debug.lua +18 -0
- package/functions/deepCopy.lua +25 -0
- package/functions/doors.lua +53 -0
- package/functions/entity.lua +88 -0
- package/functions/entitySpecific.lua +182 -0
- package/functions/entityTypes.d.ts +1 -1
- package/functions/entityTypes.lua +1 -0
- package/functions/enums.lua +62 -0
- package/functions/familiars.lua +52 -0
- package/functions/flag.lua +77 -0
- package/functions/flying.lua +10 -0
- package/functions/globals.lua +6 -0
- package/functions/gridEntity.lua +105 -0
- package/functions/gridEntitySpecific.lua +8 -0
- package/functions/input.lua +11 -0
- package/functions/isaacAPIClass.lua +12 -0
- package/functions/jsonHelpers.lua +11 -0
- package/functions/jsonRoom.lua +5 -0
- package/functions/kColor.lua +9 -0
- package/functions/language.lua +5 -0
- package/functions/log.lua +28 -0
- package/functions/map.lua +18 -0
- package/functions/math.lua +26 -0
- package/functions/npc.lua +24 -0
- package/functions/pickupVariants.d.ts +11 -11
- package/functions/pickupVariants.lua +11 -0
- package/functions/pickups.lua +67 -0
- package/functions/pills.lua +45 -0
- package/functions/player.lua +166 -0
- package/functions/playerDataStructures.lua +65 -0
- package/functions/playerHealth.lua +10 -0
- package/functions/playerIndex.lua +47 -0
- package/functions/pocketItems.lua +18 -0
- package/functions/positionVelocity.lua +46 -0
- package/functions/random.lua +32 -0
- package/functions/revive.lua +15 -0
- package/functions/rng.lua +19 -0
- package/functions/roomData.lua +68 -0
- package/functions/roomGrid.lua +21 -0
- package/functions/roomShape.lua +22 -0
- package/functions/rooms.lua +100 -0
- package/functions/run.lua +5 -0
- package/functions/seeds.lua +4 -0
- package/functions/serialization.lua +4 -0
- package/functions/set.lua +22 -0
- package/functions/spawnCollectible.lua +24 -0
- package/functions/sprite.lua +25 -0
- package/functions/stage.lua +16 -0
- package/functions/string.lua +6 -0
- package/functions/table.lua +19 -0
- package/functions/tears.lua +12 -0
- package/functions/transformations.lua +18 -0
- package/functions/trinketCacheFlag.lua +3 -0
- package/functions/trinketGive.lua +24 -0
- package/functions/trinkets.lua +52 -0
- package/functions/tstlClass.lua +9 -0
- package/functions/ui.lua +16 -0
- package/functions/utils.d.ts +1 -0
- package/functions/utils.lua +88 -0
- package/functions/vector.lua +9 -0
- package/lualib_bundle.lua +21 -34
- package/maps/cardMap.lua +1 -0
- package/maps/characterMap.lua +1 -0
- package/maps/defaultPlayerStatMap.lua +1 -0
- package/maps/gridEntityXMLMap.lua +2 -0
- package/maps/pillEffectMap.lua +1 -0
- package/maps/roomShapeToTopLeftWallGridIndexMap.lua +2 -0
- package/maps/roomTypeMap.lua +1 -0
- package/objects/LRoomShapeToRectangles.lua +2 -0
- package/objects/colors.lua +4 -0
- package/objects/roomShapeBounds.lua +2 -0
- package/objects/roomShapeLayoutSizes.lua +4 -0
- package/objects/roomShapeToBottomRightPosition.lua +2 -0
- package/objects/roomShapeToDoorSlotsToGridIndexDelta.lua +2 -0
- package/objects/roomShapeToTopLeftPosition.lua +2 -0
- package/objects/roomShapeVolumes.lua +3 -0
- package/package.json +2 -2
- package/patchErrorFunctions.lua +8 -0
- package/sets/bossSets.lua +23 -0
- package/sets/charactersWithNoRedHeartsSet.lua +2 -0
- package/sets/charactersWithNoSoulHeartsSet.lua +2 -0
- package/sets/lostStyleCharactersSet.lua +2 -0
- package/types/PickingUpItem.lua +7 -0
- package/upgradeMod.d.ts +4 -4
- package/upgradeMod.lua +18 -0
package/functions/pills.lua
CHANGED
|
@@ -27,38 +27,75 @@ local ____enums = require("functions.enums")
|
|
|
27
27
|
local getEnumValues = ____enums.getEnumValues
|
|
28
28
|
local ____utils = require("functions.utils")
|
|
29
29
|
local irange = ____utils.irange
|
|
30
|
+
--- Add this to a `PillColor` to get the corresponding giant pill color.
|
|
31
|
+
--
|
|
32
|
+
-- Corresponds to the vanilla `PillColor.GIANT_FLAG` value.
|
|
33
|
+
--
|
|
34
|
+
-- 1 << 11
|
|
30
35
|
local HORSE_PILL_ADJUSTMENT = 2048
|
|
36
|
+
--- Helper function to get an array with every non-null pill color. This includes all gold colors and
|
|
37
|
+
-- all horse colors.
|
|
31
38
|
function ____exports.getAllPillColors(self)
|
|
32
39
|
local pillColors = getEnumValues(nil, PillColor)
|
|
33
40
|
__TS__ArraySlice(pillColors)
|
|
34
41
|
return pillColors
|
|
35
42
|
end
|
|
43
|
+
--- Helper function to get an array with every valid pill effect. This includes modded pill effects.
|
|
36
44
|
function ____exports.getAllPillEffects(self)
|
|
37
45
|
return irange(nil, FIRST_PILL_EFFECT, LAST_PILL_EFFECT)
|
|
38
46
|
end
|
|
47
|
+
--- Helper function to get the corresponding horse pill color from a normal pill color.
|
|
48
|
+
--
|
|
49
|
+
-- For example, passing `PillColor.BLUE_BLUE` would result in 2049, which is the value that
|
|
50
|
+
-- corresponds to the horse pill color for blue/blue.
|
|
39
51
|
function ____exports.getHorsePillColor(self, pillColor)
|
|
40
52
|
return pillColor + HORSE_PILL_ADJUSTMENT
|
|
41
53
|
end
|
|
54
|
+
--- Helper function to get an array with every non-gold horse pill color.
|
|
42
55
|
function ____exports.getHorsePillColors(self)
|
|
43
56
|
return irange(nil, FIRST_HORSE_PILL_COLOR, LAST_HORSE_PILL_COLOR)
|
|
44
57
|
end
|
|
58
|
+
--- Helper function to get an array with every modded pill effect.
|
|
59
|
+
--
|
|
60
|
+
-- Returns an empty array if there are no modded pill effects.
|
|
45
61
|
function ____exports.getModdedPillEffects(self)
|
|
46
62
|
if LAST_VANILLA_PILL_EFFECT == LAST_PILL_EFFECT then
|
|
47
63
|
return {}
|
|
48
64
|
end
|
|
49
65
|
return irange(nil, FIRST_MODDED_PILL_EFFECT, LAST_PILL_EFFECT)
|
|
50
66
|
end
|
|
67
|
+
--- Helper function to get the corresponding normal pill color from a horse pill color.
|
|
68
|
+
--
|
|
69
|
+
-- For example, passing 2049 would result in `PillColor.BLUE_BLUE`.
|
|
70
|
+
--
|
|
71
|
+
-- If called with a non-horse pill color, this function will return back the same color.
|
|
51
72
|
function ____exports.getNormalPillColorFromHorse(self, pillColor)
|
|
52
73
|
local normalPillColor = pillColor - HORSE_PILL_ADJUSTMENT
|
|
53
74
|
return normalPillColor > PillColor.NULL and normalPillColor or pillColor
|
|
54
75
|
end
|
|
76
|
+
--- Helper function to get an array with every non-gold and non-horse pill color.
|
|
55
77
|
function ____exports.getNormalPillColors(self)
|
|
56
78
|
return irange(nil, FIRST_PILL_COLOR, LAST_NORMAL_PILL_COLOR)
|
|
57
79
|
end
|
|
80
|
+
--- Helper function to get a pill effect class from a PillEffect enum value. In this context, the
|
|
81
|
+
-- class is equal to the numerical prefix in the "class" tag in the "pocketitems.xml" file. Use the
|
|
82
|
+
-- `getPillEffectType` helper function to determine whether or not the pill effect is positive,
|
|
83
|
+
-- negative, or neutral.
|
|
84
|
+
--
|
|
85
|
+
-- Due to limitations in the API, this function will not work properly for modded pill effects, and
|
|
86
|
+
-- will always return `DEFAULT_PILL_EFFECT_CLASS` in those cases.
|
|
58
87
|
function ____exports.getPillEffectClass(self, pillEffect)
|
|
59
88
|
local pillEffectClass = PILL_EFFECT_CLASSES[pillEffect]
|
|
60
89
|
return pillEffectClass == nil and DEFAULT_PILL_EFFECT_CLASS or pillEffectClass
|
|
61
90
|
end
|
|
91
|
+
--- Helper function to get a pill effect name from a PillEffect enum value.
|
|
92
|
+
--
|
|
93
|
+
-- For example:
|
|
94
|
+
--
|
|
95
|
+
-- ```ts
|
|
96
|
+
-- const pillEffect = PillEffect.BAD_GAS;
|
|
97
|
+
-- const pillEffectName = getPillEffectName(pillEffect); // trinketName is "Bad Gas"
|
|
98
|
+
-- ```
|
|
62
99
|
function ____exports.getPillEffectName(self, pillEffect)
|
|
63
100
|
local pillEffectName = PILL_EFFECT_NAMES[pillEffect]
|
|
64
101
|
if pillEffectName ~= nil and pillEffectName ~= DEFAULT_PILL_EFFECT_NAME then
|
|
@@ -70,10 +107,18 @@ function ____exports.getPillEffectName(self, pillEffect)
|
|
|
70
107
|
end
|
|
71
108
|
return DEFAULT_PILL_EFFECT_NAME
|
|
72
109
|
end
|
|
110
|
+
--- Helper function to get a pill effect type from a PillEffect enum value. In this context, the type
|
|
111
|
+
-- is equal to positive, negative, or neutral. This is derived from the suffix of the the "class"
|
|
112
|
+
-- tag in the "pocketitems.xml" file. Use the `getPillEffectClass` helper function to determine the
|
|
113
|
+
-- "power" of the pill.
|
|
114
|
+
--
|
|
115
|
+
-- Due to limitations in the API, this function will not work properly for modded pill effects, and
|
|
116
|
+
-- will always return `DEFAULT_PILL_EFFECT_TYPE` in those cases.
|
|
73
117
|
function ____exports.getPillEffectType(self, pillEffect)
|
|
74
118
|
local pillEffectClass = PILL_EFFECT_TYPES[pillEffect]
|
|
75
119
|
return pillEffectClass == nil and DEFAULT_PILL_EFFECT_TYPE or pillEffectClass
|
|
76
120
|
end
|
|
121
|
+
--- Helper function to get an array with every vanilla pill effect.
|
|
77
122
|
function ____exports.getVanillaPillEffects(self)
|
|
78
123
|
return irange(nil, FIRST_PILL_EFFECT, LAST_VANILLA_PILL_EFFECT)
|
|
79
124
|
end
|
package/functions/player.lua
CHANGED
|
@@ -49,6 +49,7 @@ local addTearsStat = ____tears.addTearsStat
|
|
|
49
49
|
local ____utils = require("functions.utils")
|
|
50
50
|
local ensureAllCases = ____utils.ensureAllCases
|
|
51
51
|
local ____repeat = ____utils["repeat"]
|
|
52
|
+
--- Helper function to get an array containing the characters of all of the current players.
|
|
52
53
|
function ____exports.getCharacters(self)
|
|
53
54
|
local players = getPlayers(nil)
|
|
54
55
|
return __TS__ArrayMap(
|
|
@@ -56,6 +57,10 @@ function ____exports.getCharacters(self)
|
|
|
56
57
|
function(____, player) return player:GetPlayerType() end
|
|
57
58
|
)
|
|
58
59
|
end
|
|
60
|
+
--- Returns the maximum heart containers that the provided player can have. Normally, this is 12, but
|
|
61
|
+
-- it can change depending on the character (e.g. Keeper) and other things (e.g. Mother's Kiss).
|
|
62
|
+
-- This function does not account for Broken Hearts; use the `getPlayerAvailableHeartSlots` helper
|
|
63
|
+
-- function for that.
|
|
59
64
|
function ____exports.getPlayerMaxHeartContainers(self, player)
|
|
60
65
|
local character = player:GetPlayerType()
|
|
61
66
|
local characterMaxHeartContainers = getCharacterMaxHeartContainers(nil, character)
|
|
@@ -72,12 +77,18 @@ function ____exports.getPlayerMaxHeartContainers(self, player)
|
|
|
72
77
|
end
|
|
73
78
|
return characterMaxHeartContainers
|
|
74
79
|
end
|
|
80
|
+
--- Helper function to check if a player is a specific character (i.e. `PlayerType`).
|
|
81
|
+
--
|
|
82
|
+
-- This function is variadic, meaning that you can supply as many characters as you want to check
|
|
83
|
+
-- for. Returns true if the player is any of the supplied characters.
|
|
75
84
|
function ____exports.isCharacter(self, player, ...)
|
|
76
85
|
local characters = {...}
|
|
77
86
|
local characterSet = __TS__New(Set, characters)
|
|
78
87
|
local character = player:GetPlayerType()
|
|
79
88
|
return characterSet:has(character)
|
|
80
89
|
end
|
|
90
|
+
--- Helper function for detecting when a player is Keeper or Tainted Keeper. Useful for situations
|
|
91
|
+
-- where you want to know if the health is coin hearts, for example.
|
|
81
92
|
function ____exports.isKeeper(self, player)
|
|
82
93
|
local character = player:GetPlayerType()
|
|
83
94
|
return character == PlayerType.KEEPER or character == PlayerType.KEEPER_B
|
|
@@ -110,6 +121,19 @@ function ____exports.addCollectibleCostume(self, player, collectibleType)
|
|
|
110
121
|
end
|
|
111
122
|
player:AddCostume(itemConfigItem, false)
|
|
112
123
|
end
|
|
124
|
+
--- Helper function to add a stat to a player based on the `CacheFlag` provided. Call this function
|
|
125
|
+
-- from the EvaluateCache callback.
|
|
126
|
+
--
|
|
127
|
+
-- Note that for `CacheFlag.FIRE_DELAY`, the "amount" argument will be interpreted as the tear stat
|
|
128
|
+
-- to add (and not the amount to mutate `EntityPlayer.MaxFireDelay` by).
|
|
129
|
+
--
|
|
130
|
+
-- This function supports the following cache flags:
|
|
131
|
+
-- - CacheFlag.DAMAGE (1 << 0)
|
|
132
|
+
-- - CacheFlag.FIRE_DELAY (1 << 1)
|
|
133
|
+
-- - CacheFlag.SHOT_SPEED (1 << 2)
|
|
134
|
+
-- - CacheFlag.RANGE (1 << 3)
|
|
135
|
+
-- - CacheFlag.SPEED (1 << 4)
|
|
136
|
+
-- - CacheFlag.LUCK (1 << 10)
|
|
113
137
|
function ____exports.addStat(self, player, cacheFlag, amount)
|
|
114
138
|
if not STAT_CACHE_FLAGS_SET:has(cacheFlag) then
|
|
115
139
|
error("You cannot add a stat to a player with the cache flag of: " .. tostring(cacheFlag))
|
|
@@ -186,6 +210,10 @@ function ____exports.anyPlayerHasTrinket(self, trinketType)
|
|
|
186
210
|
function(____, player) return player:HasTrinket(trinketType) end
|
|
187
211
|
)
|
|
188
212
|
end
|
|
213
|
+
--- Helper function to determine if the given character is present.
|
|
214
|
+
--
|
|
215
|
+
-- This function is variadic, meaning that you can supply as many characters as you want to check
|
|
216
|
+
-- for. Returns true if any of the characters supplied are present.
|
|
189
217
|
function ____exports.anyPlayerIs(self, ...)
|
|
190
218
|
local matchingCharacters = {...}
|
|
191
219
|
local matchingCharacterSet = __TS__New(Set, matchingCharacters)
|
|
@@ -195,10 +223,19 @@ function ____exports.anyPlayerIs(self, ...)
|
|
|
195
223
|
function(____, character) return matchingCharacterSet:has(character) end
|
|
196
224
|
)
|
|
197
225
|
end
|
|
226
|
+
--- Helper function to determine if a player will destroy a rock/pot/skull if they walk over it.
|
|
227
|
+
--
|
|
228
|
+
-- The following situations allow for this to be true:
|
|
229
|
+
-- - the player has Leo (collectible 302)
|
|
230
|
+
-- - the player has Thunder Thighs (collectible 314)
|
|
231
|
+
-- - the player is under the effects of Mega Mush (collectible 625)
|
|
232
|
+
-- - the player has Stompy (transformation 13)
|
|
198
233
|
function ____exports.canPlayerCrushRocks(self, player)
|
|
199
234
|
local effects = player:GetEffects()
|
|
200
235
|
return player:HasCollectible(CollectibleType.LEO) or player:HasCollectible(CollectibleType.THUNDER_THIGHS) or effects:HasCollectibleEffect(CollectibleType.MEGA_MUSH) or player:HasPlayerForm(PlayerForm.STOMPY)
|
|
201
236
|
end
|
|
237
|
+
--- Helper function to find the active slot that the player has the corresponding collectible type
|
|
238
|
+
-- in. Returns undefined if the player does not have the collectible in any active slot.
|
|
202
239
|
function ____exports.getActiveItemSlot(self, player, collectibleType)
|
|
203
240
|
local activeSlots = getEnumValues(nil, ActiveSlot)
|
|
204
241
|
return __TS__ArrayFind(
|
|
@@ -209,6 +246,10 @@ function ____exports.getActiveItemSlot(self, player, collectibleType)
|
|
|
209
246
|
end
|
|
210
247
|
)
|
|
211
248
|
end
|
|
249
|
+
--- Helper function to get how long Azazel's Brimstone laser should be. You can pass either an
|
|
250
|
+
-- `EntityPlayer` object or a tear height stat.
|
|
251
|
+
--
|
|
252
|
+
-- The formula for calculating it is: 32 - 2.5 * player.TearHeight
|
|
212
253
|
function ____exports.getAzazelBrimstoneDistance(self, playerOrTearHeight)
|
|
213
254
|
local tearHeight = tonumber(playerOrTearHeight)
|
|
214
255
|
if tearHeight == nil then
|
|
@@ -232,6 +273,8 @@ function ____exports.getClosestPlayer(self, position)
|
|
|
232
273
|
end
|
|
233
274
|
return closestPlayer
|
|
234
275
|
end
|
|
276
|
+
--- Helper function to get an array of temporary effects for a player. This is helpful so that you
|
|
277
|
+
-- don't have to manually create an array from an `EffectsList` object.
|
|
235
278
|
function ____exports.getEffectsList(self, player)
|
|
236
279
|
local effects = player:GetEffects()
|
|
237
280
|
local effectsList = effects:GetEffectsList()
|
|
@@ -248,6 +291,8 @@ function ____exports.getEffectsList(self, player)
|
|
|
248
291
|
end
|
|
249
292
|
return effectArray
|
|
250
293
|
end
|
|
294
|
+
--- Helper function to return the player with the highest ID, according to the `Isaac.GetPlayer`
|
|
295
|
+
-- method.
|
|
251
296
|
function ____exports.getFinalPlayer(self)
|
|
252
297
|
local players = getPlayers(nil)
|
|
253
298
|
local lastPlayer = getLastElement(nil, players)
|
|
@@ -256,6 +301,9 @@ function ____exports.getFinalPlayer(self)
|
|
|
256
301
|
end
|
|
257
302
|
return lastPlayer
|
|
258
303
|
end
|
|
304
|
+
--- Helper function to get the first player with the lowest frame count. Useful to find a freshly
|
|
305
|
+
-- spawned player after using items like Esau Jr. Don't use this function if two or more players
|
|
306
|
+
-- will be spawned on the same frame.
|
|
259
307
|
function ____exports.getNewestPlayer(self)
|
|
260
308
|
local newestPlayer = nil
|
|
261
309
|
local lowestFrame = math.huge
|
|
@@ -270,6 +318,9 @@ function ____exports.getNewestPlayer(self)
|
|
|
270
318
|
end
|
|
271
319
|
return newestPlayer
|
|
272
320
|
end
|
|
321
|
+
--- Returns the number of slots that the player has remaining for new heart containers, accounting
|
|
322
|
+
-- for broken hearts. For example, if the player is Judas and has 1 red heart containers and 2 full
|
|
323
|
+
-- soul hearts and 3 broken hearts, then this function would return 6 (i.e. 12 - 1 - 2 - 3).
|
|
273
324
|
function ____exports.getPlayerAvailableHeartSlots(self, player)
|
|
274
325
|
local maxHeartContainers = ____exports.getPlayerMaxHeartContainers(nil, player)
|
|
275
326
|
local effectiveMaxHearts = player:GetEffectiveMaxHearts()
|
|
@@ -281,11 +332,19 @@ function ____exports.getPlayerAvailableHeartSlots(self, player)
|
|
|
281
332
|
local totalOccupiedHeartSlots = totalHeartContainers + brokenHearts
|
|
282
333
|
return maxHeartContainers - totalOccupiedHeartSlots
|
|
283
334
|
end
|
|
335
|
+
--- Returns the number of black hearts that the player has, excluding any soul hearts. For example,
|
|
336
|
+
-- if the player has one full black heart, one full soul heart, and one half black heart, this
|
|
337
|
+
-- function returns 3.
|
|
338
|
+
--
|
|
339
|
+
-- This is different from the `EntityPlayer.GetBlackHearts` method, since that returns a bitmask.
|
|
284
340
|
function ____exports.getPlayerBlackHearts(self, player)
|
|
285
341
|
local blackHeartsBitmask = player:GetBlackHearts()
|
|
286
342
|
local blackHeartBits = countSetBits(nil, blackHeartsBitmask)
|
|
287
343
|
return blackHeartBits * 2
|
|
288
344
|
end
|
|
345
|
+
--- Iterates over all players and checks if any are close enough to the specified position.
|
|
346
|
+
--
|
|
347
|
+
-- @returns The first player found when iterating upwards from index 0.
|
|
289
348
|
function ____exports.getPlayerCloserThan(self, position, distance)
|
|
290
349
|
local players = getPlayers(nil)
|
|
291
350
|
return __TS__ArrayFind(
|
|
@@ -293,6 +352,10 @@ function ____exports.getPlayerCloserThan(self, position, distance)
|
|
|
293
352
|
function(____, player) return player.Position:Distance(position) <= distance end
|
|
294
353
|
)
|
|
295
354
|
end
|
|
355
|
+
--- Helper function to return the total amount of collectibles that a player has that match the
|
|
356
|
+
-- collectible type(s) provided.
|
|
357
|
+
--
|
|
358
|
+
-- This function is variadic, meaning that you can specify N collectible types.
|
|
296
359
|
function ____exports.getPlayerCollectibleCount(self, player, ...)
|
|
297
360
|
local collectibleTypes = {...}
|
|
298
361
|
local numCollectibles = 0
|
|
@@ -301,6 +364,8 @@ function ____exports.getPlayerCollectibleCount(self, player, ...)
|
|
|
301
364
|
end
|
|
302
365
|
return numCollectibles
|
|
303
366
|
end
|
|
367
|
+
--- Iterates over every item in the game and returns a map containing the number of each item that
|
|
368
|
+
-- the player has.
|
|
304
369
|
function ____exports.getPlayerCollectibleMap(self, player)
|
|
305
370
|
local collectibleSet = getCollectibleSet(nil)
|
|
306
371
|
local collectibleMap = __TS__New(Map)
|
|
@@ -312,11 +377,19 @@ function ____exports.getPlayerCollectibleMap(self, player)
|
|
|
312
377
|
end
|
|
313
378
|
return collectibleMap
|
|
314
379
|
end
|
|
380
|
+
--- Returns the number of red hearts that the player has, excluding any rotten hearts. For example,
|
|
381
|
+
-- if the player has one full black heart, one full soul heart, and one half black heart, this
|
|
382
|
+
-- function returns 3.
|
|
383
|
+
--
|
|
384
|
+
-- This is different from the `EntityPlayer.GetHearts` method, since that returns a value that
|
|
385
|
+
-- includes rotten hearts.
|
|
315
386
|
function ____exports.getPlayerHearts(self, player)
|
|
316
387
|
local rottenHearts = player:GetRottenHearts()
|
|
317
388
|
local hearts = player:GetHearts()
|
|
318
389
|
return hearts - rottenHearts * 2
|
|
319
390
|
end
|
|
391
|
+
--- Helper function that returns the type of the rightmost heart. This does not including golden
|
|
392
|
+
-- hearts or broken hearts, since they cannot be damaged directly.
|
|
320
393
|
function ____exports.getPlayerLastHeart(self, player)
|
|
321
394
|
local hearts = player:GetHearts()
|
|
322
395
|
local effectiveMaxHearts = player:GetEffectiveMaxHearts()
|
|
@@ -358,10 +431,20 @@ function ____exports.getPlayerLastHeart(self, player)
|
|
|
358
431
|
end
|
|
359
432
|
return HealthType.RED
|
|
360
433
|
end
|
|
434
|
+
--- Helper function to get the proper name of the player. Use this instead of the
|
|
435
|
+
-- `EntityPlayer.GetName` method because it accounts for Blue Baby, Lazarus II, and Tainted
|
|
436
|
+
-- characters.
|
|
361
437
|
function ____exports.getPlayerName(self, player)
|
|
362
438
|
local character = player:GetPlayerType()
|
|
363
439
|
return ____exports.isModdedPlayer(nil, player) and player:GetName() or getCharacterName(nil, character)
|
|
364
440
|
end
|
|
441
|
+
--- Returns the combined value of all of the player's red hearts, soul/black hearts, and bone hearts,
|
|
442
|
+
-- minus the value of the player's rotten hearts.
|
|
443
|
+
--
|
|
444
|
+
-- This is equivalent to the number of hits that the player can currently take, but does not take
|
|
445
|
+
-- into account double damage from champion enemies and/or being on later floors. (For example, on
|
|
446
|
+
-- Womb 1, players who have 1 soul heart remaining would die in 1 hit to anything, even though this
|
|
447
|
+
-- function would report that they have 2 hits remaining.)
|
|
365
448
|
function ____exports.getPlayerNumHitsRemaining(self, player)
|
|
366
449
|
local hearts = player:GetHearts()
|
|
367
450
|
local soulHearts = player:GetSoulHearts()
|
|
@@ -370,11 +453,21 @@ function ____exports.getPlayerNumHitsRemaining(self, player)
|
|
|
370
453
|
local rottenHearts = player:GetRottenHearts()
|
|
371
454
|
return hearts + soulHearts + boneHearts + eternalHearts - rottenHearts
|
|
372
455
|
end
|
|
456
|
+
--- Returns the number of soul hearts that the player has, excluding any black hearts. For example,
|
|
457
|
+
-- if the player has one full black heart, one full soul heart, and one half black heart, this
|
|
458
|
+
-- function returns 2.
|
|
459
|
+
--
|
|
460
|
+
-- This is different from the `EntityPlayer.GetSoulHearts` method, since that returns the combined
|
|
461
|
+
-- number of soul hearts and black hearts.
|
|
373
462
|
function ____exports.getPlayerSoulHearts(self, player)
|
|
374
463
|
local soulHearts = player:GetSoulHearts()
|
|
375
464
|
local blackHearts = ____exports.getPlayerBlackHearts(nil, player)
|
|
376
465
|
return soulHearts - blackHearts
|
|
377
466
|
end
|
|
467
|
+
--- Helper function to get all of the players that are a certain character.
|
|
468
|
+
--
|
|
469
|
+
-- This function is variadic, meaning that you can supply as many characters as you want to check
|
|
470
|
+
-- for. Returns true if any of the characters supplied are present.
|
|
378
471
|
function ____exports.getPlayersOfType(self, ...)
|
|
379
472
|
local characters = {...}
|
|
380
473
|
local charactersSet = __TS__New(Set, characters)
|
|
@@ -387,6 +480,10 @@ function ____exports.getPlayersOfType(self, ...)
|
|
|
387
480
|
end
|
|
388
481
|
)
|
|
389
482
|
end
|
|
483
|
+
--- Helper function to get only the players that have a certain collectible.
|
|
484
|
+
--
|
|
485
|
+
-- This function is variadic, meaning that you can supply as many collectible types as you want to
|
|
486
|
+
-- check for. It only returns the players that have all of the collectibles.
|
|
390
487
|
function ____exports.getPlayersWithCollectible(self, ...)
|
|
391
488
|
local collectibleTypes = {...}
|
|
392
489
|
local players = getPlayers(nil)
|
|
@@ -398,6 +495,10 @@ function ____exports.getPlayersWithCollectible(self, ...)
|
|
|
398
495
|
) end
|
|
399
496
|
)
|
|
400
497
|
end
|
|
498
|
+
--- Helper function to get only the players that have a certain trinket.
|
|
499
|
+
--
|
|
500
|
+
-- This function is variadic, meaning that you can supply as many trinket types as you want to check
|
|
501
|
+
-- for. It only returns the players that have all of the trinkets.
|
|
401
502
|
function ____exports.getPlayersWithTrinket(self, ...)
|
|
402
503
|
local trinketTypes = {...}
|
|
403
504
|
local players = getPlayers(nil)
|
|
@@ -409,12 +510,22 @@ function ____exports.getPlayersWithTrinket(self, ...)
|
|
|
409
510
|
) end
|
|
410
511
|
)
|
|
411
512
|
end
|
|
513
|
+
--- Helper function to determine how many heart containers that Tainted Magdalene has that will not
|
|
514
|
+
-- be automatically depleted over time. By default, this is 2, but this function will return 4 so
|
|
515
|
+
-- that it is consistent with the `player.GetHearts` and `player.GetMaxHearts` methods.
|
|
516
|
+
--
|
|
517
|
+
-- If Tainted Magdalene has Birthright, she will gained an additional non-temporary heart container.
|
|
518
|
+
--
|
|
519
|
+
-- This function does not validate whether or not the provided player is Tainted Magdalene; that
|
|
520
|
+
-- should be accomplished before invoking this function.
|
|
412
521
|
function ____exports.getTaintedMagdaleneNonTemporaryMaxHearts(self, player)
|
|
413
522
|
local maxHearts = player:GetMaxHearts()
|
|
414
523
|
local hasBirthright = player:HasCollectible(CollectibleType.BIRTHRIGHT)
|
|
415
524
|
local maxNonTemporaryMaxHearts = hasBirthright and 6 or 4
|
|
416
525
|
return math.min(maxHearts, maxNonTemporaryMaxHearts)
|
|
417
526
|
end
|
|
527
|
+
--- Returns the total number of collectibles amongst all players. For example, if player 1 has 1 Sad
|
|
528
|
+
-- Onion and player 2 has 2 Sad Onions, then this function would return 3.
|
|
418
529
|
function ____exports.getTotalPlayerCollectibles(self, collectibleType)
|
|
419
530
|
local players = getPlayers(nil)
|
|
420
531
|
local numCollectiblesArray = __TS__ArrayMap(
|
|
@@ -423,10 +534,16 @@ function ____exports.getTotalPlayerCollectibles(self, collectibleType)
|
|
|
423
534
|
)
|
|
424
535
|
return sumArray(nil, numCollectiblesArray)
|
|
425
536
|
end
|
|
537
|
+
--- After touching a white fire, a player will turn into The Lost until they clear a room.
|
|
426
538
|
function ____exports.hasLostCurse(self, player)
|
|
427
539
|
local effects = player:GetEffects()
|
|
428
540
|
return effects:HasNullEffect(NullItemID.LOST_CURSE)
|
|
429
541
|
end
|
|
542
|
+
--- Returns whether or not the player can hold an additional active item, beyond what they are
|
|
543
|
+
-- currently carrying. This takes the Schoolbag into account.
|
|
544
|
+
--
|
|
545
|
+
-- If the player is the Tainted Soul, this always returns false, since that character cannot pick up
|
|
546
|
+
-- items. (Only Tainted Forgotten can pick up items.)
|
|
430
547
|
function ____exports.hasOpenActiveItemSlot(self, player)
|
|
431
548
|
if ____exports.isCharacter(nil, player, PlayerType.THE_SOUL_B) then
|
|
432
549
|
return false
|
|
@@ -443,10 +560,15 @@ function ____exports.isActiveSlotEmpty(self, player, activeSlot)
|
|
|
443
560
|
local activeCollectibleType = player:GetActiveItem(activeSlot)
|
|
444
561
|
return activeCollectibleType == CollectibleType.NULL
|
|
445
562
|
end
|
|
563
|
+
--- Helper function for detecting when a player is Bethany or Tainted Bethany. This is useful if you
|
|
564
|
+
-- need to adjust UI elements to account for Bethany's soul charges or Tainted Bethany's blood
|
|
565
|
+
-- charges.
|
|
446
566
|
function ____exports.isBethany(self, player)
|
|
447
567
|
local character = player:GetPlayerType()
|
|
448
568
|
return character == PlayerType.BETHANY or character == PlayerType.BETHANY_B
|
|
449
569
|
end
|
|
570
|
+
--- Helper function for detecting when a player is Eden or Tainted Eden. Useful for situations where
|
|
571
|
+
-- you want to know if the starting stats were randomized, for example.
|
|
450
572
|
function ____exports.isEden(self, player)
|
|
451
573
|
local character = player:GetPlayerType()
|
|
452
574
|
return character == PlayerType.EDEN or character == PlayerType.EDEN_B
|
|
@@ -454,14 +576,18 @@ end
|
|
|
454
576
|
function ____exports.isFirstPlayer(self, player)
|
|
455
577
|
return getPlayerIndexVanilla(nil, player) == 0
|
|
456
578
|
end
|
|
579
|
+
--- Helper function for detecting when a player is Jacob or Esau. This will only match the
|
|
580
|
+
-- non-tainted versions of these characters.
|
|
457
581
|
function ____exports.isJacobOrEsau(self, player)
|
|
458
582
|
local character = player:GetPlayerType()
|
|
459
583
|
return character == PlayerType.JACOB or character == PlayerType.ESAU
|
|
460
584
|
end
|
|
585
|
+
--- Helper function for detecting when a player is The Lost or Tainted Lost.
|
|
461
586
|
function ____exports.isLost(self, player)
|
|
462
587
|
local character = player:GetPlayerType()
|
|
463
588
|
return character == PlayerType.THE_LOST or character == PlayerType.THE_LOST_B
|
|
464
589
|
end
|
|
590
|
+
--- Helper function for detecting if a player is one of the Tainted characters.
|
|
465
591
|
function ____exports.isTainted(self, player)
|
|
466
592
|
local character = player:GetPlayerType()
|
|
467
593
|
local ____isVanillaPlayer_result_0
|
|
@@ -472,16 +598,25 @@ function ____exports.isTainted(self, player)
|
|
|
472
598
|
end
|
|
473
599
|
return ____isVanillaPlayer_result_0
|
|
474
600
|
end
|
|
601
|
+
--- Helper function for detecting when a player is Tainted Lazarus or Dead Tainted Lazarus.
|
|
475
602
|
function ____exports.isTaintedLazarus(self, player)
|
|
476
603
|
local character = player:GetPlayerType()
|
|
477
604
|
return character == PlayerType.LAZARUS_B or character == PlayerType.LAZARUS_2_B
|
|
478
605
|
end
|
|
606
|
+
--- Helper function to add one or more collectibles to a player.
|
|
607
|
+
--
|
|
608
|
+
-- This function is variadic, meaning that you can supply as many collectible types as you want to
|
|
609
|
+
-- add.
|
|
479
610
|
function ____exports.playerAddCollectible(self, player, ...)
|
|
480
611
|
local collectibleTypes = {...}
|
|
481
612
|
for ____, collectibleType in ipairs(collectibleTypes) do
|
|
482
613
|
player:AddCollectible(collectibleType)
|
|
483
614
|
end
|
|
484
615
|
end
|
|
616
|
+
--- Helper function to check to see if a player has one or more collectibles.
|
|
617
|
+
--
|
|
618
|
+
-- This function is variadic, meaning that you can supply as many collectible types as you want to
|
|
619
|
+
-- check for. Returns true if the player has any of the supplied collectible types.
|
|
485
620
|
function ____exports.playerHasCollectible(self, player, ...)
|
|
486
621
|
local collectibleTypes = {...}
|
|
487
622
|
return __TS__ArraySome(
|
|
@@ -489,6 +624,8 @@ function ____exports.playerHasCollectible(self, player, ...)
|
|
|
489
624
|
function(____, collectibleType) return player:HasCollectible(collectibleType) end
|
|
490
625
|
)
|
|
491
626
|
end
|
|
627
|
+
--- Helper function to remove a collectible costume from a player. Use this helper function to avoid
|
|
628
|
+
-- having to request the collectible from the item config.
|
|
492
629
|
function ____exports.removeCollectibleCostume(self, player, collectibleType)
|
|
493
630
|
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
|
494
631
|
if itemConfigItem == nil then
|
|
@@ -496,6 +633,10 @@ function ____exports.removeCollectibleCostume(self, player, collectibleType)
|
|
|
496
633
|
end
|
|
497
634
|
player:RemoveCostume(itemConfigItem)
|
|
498
635
|
end
|
|
636
|
+
--- Helper function to remove the Dead Eye multiplier from a player.
|
|
637
|
+
--
|
|
638
|
+
-- Note that each time the `EntityPlayer.ClearDeadEyeCharge` method is called, it only has a chance
|
|
639
|
+
-- of working, so this function calls it 100 times to be safe.
|
|
499
640
|
function ____exports.removeDeadEyeMultiplier(self, player)
|
|
500
641
|
____repeat(
|
|
501
642
|
nil,
|
|
@@ -505,6 +646,8 @@ function ____exports.removeDeadEyeMultiplier(self, player)
|
|
|
505
646
|
end
|
|
506
647
|
)
|
|
507
648
|
end
|
|
649
|
+
--- Helper function to remove a trinket costume from a player. Use this helper function to avoid
|
|
650
|
+
-- having to request the trinket from the item config.
|
|
508
651
|
function ____exports.removeTrinketCostume(self, player, trinketType)
|
|
509
652
|
local itemConfigTrinket = itemConfig:GetTrinket(trinketType)
|
|
510
653
|
if itemConfigTrinket == nil then
|
|
@@ -512,6 +655,20 @@ function ____exports.removeTrinketCostume(self, player, trinketType)
|
|
|
512
655
|
end
|
|
513
656
|
player:RemoveCostume(itemConfigTrinket)
|
|
514
657
|
end
|
|
658
|
+
--- Helper function to set an active collectible to a particular slot. This has different behavior
|
|
659
|
+
-- than calling the `player.AddCollectible` method with the `activeSlot` argument, because this
|
|
660
|
+
-- function will not shift existing items into the Schoolbag and it handles
|
|
661
|
+
-- `ActiveSlot.SLOT_POCKET2`.
|
|
662
|
+
--
|
|
663
|
+
-- Note that if an item is set to `ActiveSlot.SLOT_POCKET2`, it will disappear after being used and
|
|
664
|
+
-- will be automatically removed upon entering a new room.
|
|
665
|
+
--
|
|
666
|
+
-- @param player The player to give the item to.
|
|
667
|
+
-- @param collectibleType The collectible type of the item to give.
|
|
668
|
+
-- @param activeSlot The slot to set.
|
|
669
|
+
-- @param charge Optional. The argument of charges to set. If not specified, the item will be set
|
|
670
|
+
-- with maximum charges.
|
|
671
|
+
-- @param keepInPools Optional. Whether or not to remove the item from pools. Default is false.
|
|
515
672
|
function ____exports.setActiveItem(self, player, collectibleType, activeSlot, charge, keepInPools)
|
|
516
673
|
if keepInPools == nil then
|
|
517
674
|
keepInPools = false
|
|
@@ -576,6 +733,13 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
576
733
|
end
|
|
577
734
|
until true
|
|
578
735
|
end
|
|
736
|
+
--- Helper function to blindfold the player by using a hack with the challenge variable.
|
|
737
|
+
--
|
|
738
|
+
-- The method used in this function was discovered by im_tem.
|
|
739
|
+
--
|
|
740
|
+
-- @param player The player to apply or remove the blindfold state from.
|
|
741
|
+
-- @param enabled Whether or not to apply or remove the blindfold.
|
|
742
|
+
-- @param modifyCostume Optional. Whether to add or remove the blindfold costume. Default is true.
|
|
579
743
|
function ____exports.setBlindfold(self, player, enabled, modifyCostume)
|
|
580
744
|
if modifyCostume == nil then
|
|
581
745
|
modifyCostume = true
|
|
@@ -598,6 +762,8 @@ function ____exports.setBlindfold(self, player, enabled, modifyCostume)
|
|
|
598
762
|
end
|
|
599
763
|
end
|
|
600
764
|
end
|
|
765
|
+
--- Helper function to use an active item without showing an animation, keeping the item, or adding
|
|
766
|
+
-- any costumes.
|
|
601
767
|
function ____exports.useActiveItemTemp(self, player, collectibleType)
|
|
602
768
|
player:UseActiveItem(
|
|
603
769
|
collectibleType,
|
|
@@ -4,33 +4,98 @@ local Set = ____lualib.Set
|
|
|
4
4
|
local ____exports = {}
|
|
5
5
|
local ____playerIndex = require("functions.playerIndex")
|
|
6
6
|
local getPlayerIndex = ____playerIndex.getPlayerIndex
|
|
7
|
+
--- Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
|
|
8
|
+
-- `Map.set` method if you have a map of this type.
|
|
9
|
+
--
|
|
10
|
+
-- For example:
|
|
11
|
+
--
|
|
12
|
+
-- ```ts
|
|
13
|
+
-- const v = {
|
|
14
|
+
-- run: {
|
|
15
|
+
-- playersSpeedBoost: new Map<PlayerIndex, int>(),
|
|
16
|
+
-- },
|
|
17
|
+
-- };
|
|
18
|
+
--
|
|
19
|
+
-- function incrementSpeedBoost(player: EntityPlayer) {
|
|
20
|
+
-- const oldSpeedBoost = mapGetPlayer(v.run.playersSpeedBoost, player);
|
|
21
|
+
-- const newSpeedBoost = oldSpeedBoost + 0.1;
|
|
22
|
+
-- mapSetPlayer(v.run.playersSpeedBoost, player);
|
|
23
|
+
-- }
|
|
24
|
+
-- ```
|
|
7
25
|
function ____exports.mapSetPlayer(self, map, player, value)
|
|
8
26
|
local playerIndex = getPlayerIndex(nil, player)
|
|
9
27
|
map:set(playerIndex, value)
|
|
10
28
|
end
|
|
29
|
+
--- Helper function to make using default maps with an index of `PlayerIndex` easier. Use this
|
|
30
|
+
-- instead of the `DefaultMap.getAndSetDefault` method if you have a default map of this type.
|
|
31
|
+
--
|
|
32
|
+
-- For example:
|
|
33
|
+
--
|
|
34
|
+
-- ```ts
|
|
35
|
+
-- const v = {
|
|
36
|
+
-- run: {
|
|
37
|
+
-- playersSpeedBoost: new DefaultMap<PlayerIndex, int>(0),
|
|
38
|
+
-- },
|
|
39
|
+
-- };
|
|
40
|
+
--
|
|
41
|
+
-- function evaluateCacheSpeed(player: EntityPlayer) {
|
|
42
|
+
-- player.MoveSpeed = defaultMapGetPlayer(v.run.playersSpeedBoost, player);
|
|
43
|
+
-- }
|
|
44
|
+
-- ```
|
|
11
45
|
function ____exports.defaultMapGetPlayer(self, map, player, ...)
|
|
12
46
|
local playerIndex = getPlayerIndex(nil, player)
|
|
13
47
|
return map:getAndSetDefault(playerIndex, ...)
|
|
14
48
|
end
|
|
49
|
+
--- Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
|
|
50
|
+
-- `Map.set` method if you have a map of this type.
|
|
51
|
+
--
|
|
52
|
+
-- Since `Map` and `DefaultMap` set values in the same way, this function is simply an alias for the
|
|
53
|
+
-- `mapSetPlayer` helper function.
|
|
15
54
|
function ____exports.defaultMapSetPlayer(self, map, player, value)
|
|
16
55
|
____exports.mapSetPlayer(nil, map, player, value)
|
|
17
56
|
end
|
|
57
|
+
--- Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
|
|
58
|
+
-- `Map.get` method if you have a map of this type.
|
|
59
|
+
--
|
|
60
|
+
-- For example:
|
|
61
|
+
--
|
|
62
|
+
-- ```ts
|
|
63
|
+
-- const v = {
|
|
64
|
+
-- run: {
|
|
65
|
+
-- playersSpeedBoost: new Map<PlayerIndex, int>(),
|
|
66
|
+
-- },
|
|
67
|
+
-- };
|
|
68
|
+
--
|
|
69
|
+
-- function incrementSpeedBoost(player: EntityPlayer) {
|
|
70
|
+
-- const oldSpeedBoost = mapGetPlayer(v.run.playersSpeedBoost, player);
|
|
71
|
+
-- const newSpeedBoost = oldSpeedBoost + 0.1;
|
|
72
|
+
-- mapSetPlayer(v.run.playersSpeedBoost, player);
|
|
73
|
+
-- }
|
|
74
|
+
-- ```
|
|
18
75
|
function ____exports.mapGetPlayer(self, map, player)
|
|
19
76
|
local playerIndex = getPlayerIndex(nil, player)
|
|
20
77
|
return map:get(playerIndex)
|
|
21
78
|
end
|
|
79
|
+
--- Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
|
|
80
|
+
-- `Map.has` method if you have a map of this type.
|
|
22
81
|
function ____exports.mapHasPlayer(self, map, player)
|
|
23
82
|
local playerIndex = getPlayerIndex(nil, player)
|
|
24
83
|
return map:has(playerIndex)
|
|
25
84
|
end
|
|
85
|
+
--- Helper function to make using sets with an type of `PlayerIndex` easier. Use this instead of the
|
|
86
|
+
-- `Set.add` method if you have a set of this type.
|
|
26
87
|
function ____exports.setAddPlayer(self, set, player)
|
|
27
88
|
local playerIndex = getPlayerIndex(nil, player)
|
|
28
89
|
return set:add(playerIndex)
|
|
29
90
|
end
|
|
91
|
+
--- Helper function to make using sets with an type of `PlayerIndex` easier. Use this instead of the
|
|
92
|
+
-- `Set.delete` method if you have a set of this type.
|
|
30
93
|
function ____exports.setDeletePlayer(self, set, player)
|
|
31
94
|
local playerIndex = getPlayerIndex(nil, player)
|
|
32
95
|
return set:delete(playerIndex)
|
|
33
96
|
end
|
|
97
|
+
--- Helper function to make using sets with an type of `PlayerIndex` easier. Use this instead of the
|
|
98
|
+
-- `Set.has` method if you have a set of this type.
|
|
34
99
|
function ____exports.setHasPlayer(self, set, player)
|
|
35
100
|
local playerIndex = getPlayerIndex(nil, player)
|
|
36
101
|
return set:has(playerIndex)
|
|
@@ -89,6 +89,11 @@ function ____exports.addPlayerHealthType(self, player, healthType, numHearts)
|
|
|
89
89
|
end
|
|
90
90
|
until true
|
|
91
91
|
end
|
|
92
|
+
--- Helper function to get an object representing the player's health. You can use this in
|
|
93
|
+
-- combination with the `setPlayerHealth` function to restore the player's health back to a certain
|
|
94
|
+
-- configuration at a later time.
|
|
95
|
+
--
|
|
96
|
+
-- This is based on the `REVEL.StoreHealth` function in the Revelations mod.
|
|
92
97
|
function ____exports.getPlayerHealth(self, player)
|
|
93
98
|
local character = player:GetPlayerType()
|
|
94
99
|
local soulHeartTypes = {}
|
|
@@ -234,6 +239,11 @@ function ____exports.removeAllPlayerHealth(self, player)
|
|
|
234
239
|
end
|
|
235
240
|
end
|
|
236
241
|
end
|
|
242
|
+
--- Helper function to set a player's health to a specific state. You can use this in combination
|
|
243
|
+
-- with the `getPlayerHealth` function to restore the player's health back to a certain
|
|
244
|
+
-- configuration at a later time.
|
|
245
|
+
--
|
|
246
|
+
-- Based on the `REVEL.LoadHealth` function in the Revelations mod.
|
|
237
247
|
function ____exports.setPlayerHealth(self, player, playerHealth)
|
|
238
248
|
local character = player:GetPlayerType()
|
|
239
249
|
local subPlayer = player:GetSubPlayer()
|