isaacscript-common 1.2.81 → 1.2.84
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/dist/features/isPonyActive.d.ts +6 -0
- package/dist/features/isPonyActive.lua +50 -0
- package/dist/functions/log.lua +3 -9
- package/dist/functions/player.d.ts +4 -16
- package/dist/functions/revive.d.ts +8 -2
- package/dist/functions/revive.lua +13 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.lua +5 -0
- package/dist/types/PlayerIndex.d.ts +14 -0
- package/dist/types/PlayerIndex.lua +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/**
|
|
3
|
+
* When used on The Forgotten, switches to The Soul. When used on The Soul, switches to The
|
|
4
|
+
* Forgotten. This takes 1 game frame to take effect.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isPonyActive(player: EntityPlayer): boolean;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____lualib = require("lualib_bundle")
|
|
3
|
+
local Set = ____lualib.Set
|
|
4
|
+
local __TS__New = ____lualib.__TS__New
|
|
5
|
+
local ____exports = {}
|
|
6
|
+
local postPEffectUpdate, FLAGS_WHEN_PONY_IS_ACTIVE, v
|
|
7
|
+
local ____errors = require("errors")
|
|
8
|
+
local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
|
|
9
|
+
local ____flag = require("functions.flag")
|
|
10
|
+
local hasFlag = ____flag.hasFlag
|
|
11
|
+
local ____player = require("functions.player")
|
|
12
|
+
local getPlayerIndex = ____player.getPlayerIndex
|
|
13
|
+
local ____exports = require("features.saveDataManager.exports")
|
|
14
|
+
local saveDataManager = ____exports.saveDataManager
|
|
15
|
+
function postPEffectUpdate(self, player)
|
|
16
|
+
local effects = player:GetEffects()
|
|
17
|
+
local entityFlags = player:GetEntityFlags()
|
|
18
|
+
local hasPonyCollectibleEffect = effects:HasCollectibleEffect(CollectibleType.COLLECTIBLE_PONY) or effects:HasCollectibleEffect(CollectibleType.COLLECTIBLE_WHITE_PONY)
|
|
19
|
+
local playerIndex = getPlayerIndex(nil, player)
|
|
20
|
+
local isPonyActiveOnPreviousFrame = v.run.playersIsPonyActive:has(playerIndex)
|
|
21
|
+
local hasPonyFlags = hasFlag(
|
|
22
|
+
nil,
|
|
23
|
+
entityFlags,
|
|
24
|
+
table.unpack(FLAGS_WHEN_PONY_IS_ACTIVE)
|
|
25
|
+
)
|
|
26
|
+
local isPonyActiveNow = hasPonyCollectibleEffect or isPonyActiveOnPreviousFrame and hasPonyFlags
|
|
27
|
+
if isPonyActiveNow then
|
|
28
|
+
v.run.playersIsPonyActive:add(playerIndex)
|
|
29
|
+
else
|
|
30
|
+
v.run.playersIsPonyActive:delete(playerIndex)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
local FEATURE_NAME = "pony activation detector"
|
|
34
|
+
FLAGS_WHEN_PONY_IS_ACTIVE = {EntityFlag.FLAG_NO_KNOCKBACK, EntityFlag.FLAG_NO_PHYSICS_KNOCKBACK, EntityFlag.FLAG_NO_DAMAGE_BLINK}
|
|
35
|
+
local initialized = false
|
|
36
|
+
v = {run = {playersIsPonyActive = __TS__New(Set)}}
|
|
37
|
+
function ____exports.isPonyActiveInit(self, mod)
|
|
38
|
+
initialized = true
|
|
39
|
+
saveDataManager(nil, "isPonyActive", v)
|
|
40
|
+
mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, postPEffectUpdate)
|
|
41
|
+
end
|
|
42
|
+
function ____exports.isPonyActive(self, player)
|
|
43
|
+
if not initialized then
|
|
44
|
+
local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
|
|
45
|
+
error(msg)
|
|
46
|
+
end
|
|
47
|
+
local playerIndex = getPlayerIndex(nil, player)
|
|
48
|
+
return v.run.playersIsPonyActive:has(playerIndex)
|
|
49
|
+
end
|
|
50
|
+
return ____exports
|
package/dist/functions/log.lua
CHANGED
|
@@ -43,13 +43,11 @@ function ____exports.logAllFlags(flags, flagEnum, description)
|
|
|
43
43
|
end
|
|
44
44
|
____exports.log(("Logging all " .. description) .. "flags:")
|
|
45
45
|
local hasNoFlags = true
|
|
46
|
-
local i = 1
|
|
47
46
|
for key, value in pairs(flagEnum) do
|
|
48
47
|
if hasFlag(nil, flags, value) then
|
|
49
|
-
____exports.log((((
|
|
48
|
+
____exports.log((((" Has flag: " .. tostring(key)) .. " (") .. tostring(value)) .. ")")
|
|
50
49
|
hasNoFlags = false
|
|
51
50
|
end
|
|
52
|
-
i = i + 1
|
|
53
51
|
end
|
|
54
52
|
if hasNoFlags then
|
|
55
53
|
____exports.log(" n/a (no flags)")
|
|
@@ -65,15 +63,13 @@ function ____exports.logAllGameStateFlags()
|
|
|
65
63
|
local game = Game()
|
|
66
64
|
____exports.log("Logging all game state flags:")
|
|
67
65
|
local hasNoFlags = true
|
|
68
|
-
local i = 1
|
|
69
66
|
for key, value in pairs(GameStateFlag) do
|
|
70
67
|
local gameStateFlag = value
|
|
71
68
|
local flagValue = game:GetStateFlag(gameStateFlag)
|
|
72
69
|
if flagValue then
|
|
73
|
-
____exports.log((((
|
|
70
|
+
____exports.log((((" Has flag: " .. key) .. " (") .. tostring(value)) .. ")")
|
|
74
71
|
hasNoFlags = false
|
|
75
72
|
end
|
|
76
|
-
i = i + 1
|
|
77
73
|
end
|
|
78
74
|
if hasNoFlags then
|
|
79
75
|
____exports.log(" n/a (no flags)")
|
|
@@ -87,14 +83,12 @@ function ____exports.logAllSeedEffects()
|
|
|
87
83
|
local seeds = game:GetSeeds()
|
|
88
84
|
____exports.log("Logging all seed effects:")
|
|
89
85
|
local hasNoSeedEffects = true
|
|
90
|
-
local i = 1
|
|
91
86
|
for key, value in pairs(SeedEffect) do
|
|
92
87
|
local seedEffect = value
|
|
93
88
|
if seeds:HasSeedEffect(seedEffect) then
|
|
94
|
-
____exports.log((((
|
|
89
|
+
____exports.log((((" " .. key) .. " (") .. tostring(value)) .. ")")
|
|
95
90
|
hasNoSeedEffects = false
|
|
96
91
|
end
|
|
97
|
-
i = i + 1
|
|
98
92
|
end
|
|
99
93
|
if hasNoSeedEffects then
|
|
100
94
|
____exports.log(" n/a (no seed effects)")
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
2
|
import { HealthType } from "../types/HealthType";
|
|
3
|
-
|
|
4
|
-
* PlayerIndex is a specific type of string; see the documentation for the [[`getPlayerIndex`]]
|
|
5
|
-
* function. Mods can signify that data structures handle EntityPlayers by using this type:
|
|
6
|
-
*
|
|
7
|
-
* ```
|
|
8
|
-
* const myPlayerMap = new Map<PlayerIndex, string>();
|
|
9
|
-
* ```
|
|
10
|
-
*
|
|
11
|
-
* This type is branded for extra type safety.
|
|
12
|
-
*/
|
|
13
|
-
export declare type PlayerIndex = int & {
|
|
14
|
-
__playerIndexBrand: unknown;
|
|
15
|
-
};
|
|
3
|
+
import { PlayerIndex } from "../types/PlayerIndex";
|
|
16
4
|
export declare function addCollectibleCostume(player: EntityPlayer, collectibleType: CollectibleType | int): void;
|
|
17
5
|
export declare function addTrinketCostume(player: EntityPlayer, trinketType: TrinketType | int): void;
|
|
18
6
|
/** Iterates over all players and checks if any player is close enough to the specified position. */
|
|
@@ -97,9 +85,9 @@ export declare function getLastHeart(player: EntityPlayer): HealthType;
|
|
|
97
85
|
*/
|
|
98
86
|
export declare function getNewestPlayer(): EntityPlayer;
|
|
99
87
|
/**
|
|
100
|
-
* Returns the number of slots that the player has remaining for heart containers, accounting
|
|
101
|
-
* broken hearts. For example, if the player is Judas and has 1 red heart containers and 2 full
|
|
102
|
-
* hearts and 3 broken hearts, then this function would return 6 (i.e. 12 - 1 - 2 - 3).
|
|
88
|
+
* Returns the number of slots that the player has remaining for new heart containers, accounting
|
|
89
|
+
* for broken hearts. For example, if the player is Judas and has 1 red heart containers and 2 full
|
|
90
|
+
* soul hearts and 3 broken hearts, then this function would return 6 (i.e. 12 - 1 - 2 - 3).
|
|
103
91
|
*/
|
|
104
92
|
export declare function getPlayerAvailableHeartSlots(player: EntityPlayer): int;
|
|
105
93
|
/**
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare function isDamageToPlayerFatal(player: EntityPlayer, damageAmount: int, damageSource: EntityRef, lastDamageGameFrame: int): boolean;
|
|
7
7
|
/**
|
|
8
|
-
* The `EntityPlayer.WillPlayerRevive()` function does not properly account for Mysterious Paper,
|
|
9
|
-
*
|
|
8
|
+
* The `EntityPlayer.WillPlayerRevive()` function does not properly account for Mysterious Paper, so
|
|
9
|
+
* use this helper function instead for more robust revival detection.
|
|
10
10
|
*/
|
|
11
11
|
export declare function willPlayerRevive(player: EntityPlayer): boolean;
|
|
12
12
|
/**
|
|
@@ -18,6 +18,12 @@ export declare function willPlayerRevive(player: EntityPlayer): boolean;
|
|
|
18
18
|
* Mysterious Paper be Missing Power is: `gameFrameCount % 4 === 3`
|
|
19
19
|
*/
|
|
20
20
|
export declare function willMysteriousPaperRevive(player: EntityPlayer): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Helper function to determine if the player will be revived by the Heartbreak collectible if they
|
|
23
|
+
* take fatal damage. This is contingent on the character that they are playing as and the amount of
|
|
24
|
+
* broken hearts that they already have.
|
|
25
|
+
*/
|
|
26
|
+
export declare function willReviveFromHeartbreak(player: EntityPlayer): boolean;
|
|
21
27
|
/**
|
|
22
28
|
* Helper function to determine if the Spirit Shackles item is in an enabled state. (It can be
|
|
23
29
|
* either enabled or disabled.)
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
local ____exports = {}
|
|
3
3
|
local ____player = require("functions.player")
|
|
4
4
|
local getDeathAnimationName = ____player.getDeathAnimationName
|
|
5
|
-
local
|
|
5
|
+
local getPlayerMaxHeartContainers = ____player.getPlayerMaxHeartContainers
|
|
6
6
|
local getPlayerNumHitsRemaining = ____player.getPlayerNumHitsRemaining
|
|
7
7
|
local hasLostCurse = ____player.hasLostCurse
|
|
8
|
+
local isKeeper = ____player.isKeeper
|
|
8
9
|
local ____sprite = require("functions.sprite")
|
|
9
10
|
local getFinalFrameOfAnimation = ____sprite.getFinalFrameOfAnimation
|
|
10
11
|
local ____trinketGive = require("functions.trinketGive")
|
|
@@ -19,6 +20,16 @@ function ____exports.willMysteriousPaperRevive(self, player)
|
|
|
19
20
|
local frameOfDeath = gameFrameCount + deathAnimationFrames + 1
|
|
20
21
|
return frameOfDeath % 4 == 3
|
|
21
22
|
end
|
|
23
|
+
function ____exports.willReviveFromHeartbreak(self, player)
|
|
24
|
+
if not player:HasCollectible(CollectibleType.COLLECTIBLE_HEARTBREAK) then
|
|
25
|
+
return false
|
|
26
|
+
end
|
|
27
|
+
local maxHeartContainers = getPlayerMaxHeartContainers(nil, player)
|
|
28
|
+
local numBrokenHeartsThatWillBeAdded = isKeeper(nil, player) and 1 or 2
|
|
29
|
+
local brokenHearts = player:GetBrokenHearts()
|
|
30
|
+
local numBrokenHeartsAfterRevival = numBrokenHeartsThatWillBeAdded + brokenHearts
|
|
31
|
+
return maxHeartContainers > numBrokenHeartsAfterRevival
|
|
32
|
+
end
|
|
22
33
|
function ____exports.willReviveFromSpiritShackles(self, player)
|
|
23
34
|
if not player:HasCollectible(CollectibleType.COLLECTIBLE_SPIRIT_SHACKLES) then
|
|
24
35
|
return false
|
|
@@ -53,8 +64,7 @@ function ____exports.isDamageToPlayerFatal(self, player, damageAmount, damageSou
|
|
|
53
64
|
if damageAmount < playerNumAllHearts then
|
|
54
65
|
return false
|
|
55
66
|
end
|
|
56
|
-
|
|
57
|
-
if player:HasCollectible(CollectibleType.COLLECTIBLE_HEARTBREAK) and playerAvailableHeartSlots >= 2 then
|
|
67
|
+
if ____exports.willReviveFromHeartbreak(nil, player) then
|
|
58
68
|
return false
|
|
59
69
|
end
|
|
60
70
|
if player:HasCollectible(CollectibleType.COLLECTIBLE_BROKEN_GLASS_CANNON) and gameFrameCount == lastDamageGameFrame then
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { deployJSONRoom, deployRandomJSONRoom, emptyRoom, } from "./features/dep
|
|
|
4
4
|
export { disableAllInputs, disableAllInputsExceptFor, disableMovementInputs, disableShootingInputs, enableAllInputs, enableAllInputsExceptFor, } from "./features/disableInputs";
|
|
5
5
|
export { forgottenSwitch } from "./features/forgottenSwitch";
|
|
6
6
|
export { getCollectibleItemPoolType } from "./features/getCollectibleItemPoolType";
|
|
7
|
+
export { isPonyActive } from "./features/isPonyActive";
|
|
7
8
|
export { preventCollectibleRotate } from "./features/preventCollectibleRotate";
|
|
8
9
|
export { runInNGameFrames, runInNRenderFrames, runNextGameFrame, runNextRenderFrame, } from "./features/runInNFrames";
|
|
9
10
|
export * from "./features/saveDataManager/exports";
|
|
@@ -92,6 +93,7 @@ export * from "./types/PickingUpItem";
|
|
|
92
93
|
export * from "./types/PillEffectClass";
|
|
93
94
|
export * from "./types/PillEffectType";
|
|
94
95
|
export * from "./types/PlayerHealth";
|
|
96
|
+
export * from "./types/PlayerIndex";
|
|
95
97
|
export * from "./types/PocketItemDescription";
|
|
96
98
|
export * from "./types/PocketItemType";
|
|
97
99
|
export * from "./types/TrinketSituation";
|
package/dist/index.lua
CHANGED
|
@@ -49,6 +49,11 @@ do
|
|
|
49
49
|
local getCollectibleItemPoolType = ____getCollectibleItemPoolType.getCollectibleItemPoolType
|
|
50
50
|
____exports.getCollectibleItemPoolType = getCollectibleItemPoolType
|
|
51
51
|
end
|
|
52
|
+
do
|
|
53
|
+
local ____isPonyActive = require("features.isPonyActive")
|
|
54
|
+
local isPonyActive = ____isPonyActive.isPonyActive
|
|
55
|
+
____exports.isPonyActive = isPonyActive
|
|
56
|
+
end
|
|
52
57
|
do
|
|
53
58
|
local ____preventCollectibleRotate = require("features.preventCollectibleRotate")
|
|
54
59
|
local preventCollectibleRotate = ____preventCollectibleRotate.preventCollectibleRotate
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/**
|
|
3
|
+
* PlayerIndex is a specific type of string; see the documentation for the [[`getPlayerIndex`]]
|
|
4
|
+
* function. Mods can signify that data structures handle EntityPlayers by using this type:
|
|
5
|
+
*
|
|
6
|
+
* ```
|
|
7
|
+
* const myPlayerMap = new Map<PlayerIndex, string>();
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* This type is branded for extra type safety.
|
|
11
|
+
*/
|
|
12
|
+
export declare type PlayerIndex = int & {
|
|
13
|
+
__playerIndexBrand: unknown;
|
|
14
|
+
};
|