isaacscript-common 3.4.2 → 3.6.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/callbacks/postCollectibleInitFirst.lua +2 -1
- package/callbacks/postPlayerChangeHealth.lua +2 -2
- package/callbacks/subscriptions/postPickupCollect.d.ts +5 -5
- package/callbacks/subscriptions/postPickupInitFirst.d.ts +5 -3
- package/callbacks/subscriptions/postPickupInitLate.d.ts +5 -3
- package/callbacks/subscriptions/postPickupStateChanged.d.ts +5 -6
- package/callbacks/subscriptions/postPlayerChangeHealth.d.ts +1 -1
- package/callbacks/subscriptions/postPlayerChangeHealth.lua +2 -2
- package/enums/ModCallbackCustom.d.ts +5 -3
- package/features/preventCollectibleRotation.lua +2 -1
- package/functions/player.d.ts +27 -0
- package/functions/player.lua +61 -30
- package/package.json +2 -2
|
@@ -16,7 +16,8 @@ local postCollectibleInitFirstHasSubscriptions = ____postCollectibleInitFirst.po
|
|
|
16
16
|
function hasSubscriptions(self)
|
|
17
17
|
return postCollectibleInitFirstHasSubscriptions(nil)
|
|
18
18
|
end
|
|
19
|
-
function postPickupInitCollectible(self,
|
|
19
|
+
function postPickupInitCollectible(self, pickup)
|
|
20
|
+
local collectible = pickup
|
|
20
21
|
local collectibleIndex = getCollectibleIndex(nil, collectible)
|
|
21
22
|
if v.run.seenCollectibles:has(collectibleIndex) then
|
|
22
23
|
return
|
|
@@ -34,8 +34,8 @@ function postPEffectUpdateReordered(self, player)
|
|
|
34
34
|
local currentHealthValue = getPlayerHealthType(nil, player, healthType)
|
|
35
35
|
playerHealthMap:set(healthType, currentHealthValue)
|
|
36
36
|
if storedHealthValue ~= nil and storedHealthValue ~= currentHealthValue then
|
|
37
|
-
local
|
|
38
|
-
postPlayerChangeHealthFire(nil, player, healthType,
|
|
37
|
+
local difference = currentHealthValue - storedHealthValue
|
|
38
|
+
postPlayerChangeHealthFire(nil, player, healthType, difference)
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
]
|
|
1
|
+
import { PickupVariant } from "isaac-typescript-definitions";
|
|
2
|
+
export declare type PostPickupCollectRegisterParameters = [
|
|
3
|
+
callback: (pickup: EntityPickup, player: EntityPlayer) => void,
|
|
4
|
+
pickupVariant?: PickupVariant
|
|
5
|
+
];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export declare type PostPickupInitFirstRegisterParameters =
|
|
3
|
-
|
|
1
|
+
import { PickupVariant } from "isaac-typescript-definitions";
|
|
2
|
+
export declare type PostPickupInitFirstRegisterParameters = [
|
|
3
|
+
callback: (pickup: EntityPickup) => void,
|
|
4
|
+
pickupVariant?: PickupVariant
|
|
5
|
+
];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export declare type PostPickupInitLateRegisterParameters =
|
|
3
|
-
|
|
1
|
+
import { PickupVariant } from "isaac-typescript-definitions";
|
|
2
|
+
export declare type PostPickupInitLateRegisterParameters = [
|
|
3
|
+
callback: (pickup: EntityPickup) => void,
|
|
4
|
+
pickupVariant?: PickupVariant
|
|
5
|
+
];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
], void>;
|
|
1
|
+
import { PickupVariant } from "isaac-typescript-definitions";
|
|
2
|
+
export declare type PostPickupStateChangedRegisterParameters = [
|
|
3
|
+
callback: (pickup: EntityPickup, previousState: int, currentState: int) => void,
|
|
4
|
+
pickupVariant?: PickupVariant
|
|
5
|
+
];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PlayerType, PlayerVariant } from "isaac-typescript-definitions";
|
|
2
2
|
import { HealthType } from "../../enums/HealthType";
|
|
3
3
|
export declare type PostPlayerChangeHealthRegisterParameters = [
|
|
4
|
-
callback: (player: EntityPlayer, healthType: HealthType,
|
|
4
|
+
callback: (player: EntityPlayer, healthType: HealthType, difference: int) => void,
|
|
5
5
|
playerVariant?: PlayerVariant,
|
|
6
6
|
character?: PlayerType
|
|
7
7
|
];
|
|
@@ -13,7 +13,7 @@ function ____exports.postPlayerChangeHealthRegister(self, ...)
|
|
|
13
13
|
end
|
|
14
14
|
---
|
|
15
15
|
-- @internal
|
|
16
|
-
function ____exports.postPlayerChangeHealthFire(self, player, healthType,
|
|
16
|
+
function ____exports.postPlayerChangeHealthFire(self, player, healthType, difference)
|
|
17
17
|
local character = player:GetPlayerType()
|
|
18
18
|
for ____, ____value in ipairs(subscriptions) do
|
|
19
19
|
local callback = ____value[1]
|
|
@@ -26,7 +26,7 @@ function ____exports.postPlayerChangeHealthFire(self, player, healthType, amount
|
|
|
26
26
|
if callbackCharacter ~= nil and callbackCharacter ~= character then
|
|
27
27
|
goto __continue5
|
|
28
28
|
end
|
|
29
|
-
callback(nil, player, healthType,
|
|
29
|
+
callback(nil, player, healthType, difference)
|
|
30
30
|
end
|
|
31
31
|
::__continue5::
|
|
32
32
|
end
|
|
@@ -628,7 +628,7 @@ export declare enum ModCallbackCustom {
|
|
|
628
628
|
* function postPlayerChangeHealth(
|
|
629
629
|
* player: EntityPlayer,
|
|
630
630
|
* healthType: HealthType,
|
|
631
|
-
*
|
|
631
|
+
* difference: int,
|
|
632
632
|
* ) {}
|
|
633
633
|
* ```
|
|
634
634
|
*/
|
|
@@ -986,7 +986,8 @@ export declare enum ModCallbackCustom {
|
|
|
986
986
|
*/
|
|
987
987
|
POST_SPIKES_UPDATE = 67,
|
|
988
988
|
/**
|
|
989
|
-
* Fires on the first `POST_TEAR_UPDATE` frame for each tear
|
|
989
|
+
* Fires on the first `POST_TEAR_UPDATE` frame for each tear (which is when
|
|
990
|
+
* `EntityTear.FrameCount` is equal to 0).
|
|
990
991
|
*
|
|
991
992
|
* This callback is useful because many attributes cannot be set or retrieved properly in the
|
|
992
993
|
* normal `POST_TEAR_INIT` callback.
|
|
@@ -1000,7 +1001,8 @@ export declare enum ModCallbackCustom {
|
|
|
1000
1001
|
*/
|
|
1001
1002
|
POST_TEAR_INIT_LATE = 68,
|
|
1002
1003
|
/**
|
|
1003
|
-
* Fires on the second `POST_TEAR_UPDATE` frame for each tear (
|
|
1004
|
+
* Fires on the second `POST_TEAR_UPDATE` frame for each tear (which is when
|
|
1005
|
+
* `EntityTear.FrameCount` is equal to 1).
|
|
1004
1006
|
*
|
|
1005
1007
|
* This callback is useful because Incubus tears are not distinguishable until the second frame.
|
|
1006
1008
|
*
|
|
@@ -23,7 +23,8 @@ local saveDataManager = ____exports.saveDataManager
|
|
|
23
23
|
function useCardSoulOfIsaac(self)
|
|
24
24
|
v.room.trackedCollectibles:clear()
|
|
25
25
|
end
|
|
26
|
-
function postPickupUpdateCollectible(self,
|
|
26
|
+
function postPickupUpdateCollectible(self, pickup)
|
|
27
|
+
local collectible = pickup
|
|
27
28
|
if collectible.SubType == CollectibleType.NULL then
|
|
28
29
|
return
|
|
29
30
|
end
|
package/functions/player.d.ts
CHANGED
|
@@ -37,6 +37,33 @@ export declare function anyPlayerIs(...matchingCharacters: PlayerType[]): boolea
|
|
|
37
37
|
* - the player has Stompy (transformation 13)
|
|
38
38
|
*/
|
|
39
39
|
export declare function canPlayerCrushRocks(player: EntityPlayer): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Returns whether or not all of the player's soul-heart-type hearts are black hearts.
|
|
42
|
+
*
|
|
43
|
+
* Note that this function does not consider red heart containers.
|
|
44
|
+
*
|
|
45
|
+
* For example:
|
|
46
|
+
*
|
|
47
|
+
* - If the player has one black heart, this function would return true.
|
|
48
|
+
* - If the player has one soul heart and two black hearts, this function would return false.
|
|
49
|
+
* - If the player has no black hearts, this function will return false.
|
|
50
|
+
* - If the player has one red heart container and three black hearts, this function would return
|
|
51
|
+
* true.
|
|
52
|
+
*/
|
|
53
|
+
export declare function doesPlayerHaveAllBlackHearts(player: EntityPlayer): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Returns whether or not all of the player's soul-heart-type hearts are soul hearts.
|
|
56
|
+
*
|
|
57
|
+
* Note that this function does not consider red heart containers.
|
|
58
|
+
*
|
|
59
|
+
* For example:
|
|
60
|
+
*
|
|
61
|
+
* - If the player has two soul hearts and one black heart, this function would return false.
|
|
62
|
+
* - If the player has no soul hearts, this function will return false.
|
|
63
|
+
* - If the player has one red heart container and three soul hearts, this function would return
|
|
64
|
+
* true.
|
|
65
|
+
*/
|
|
66
|
+
export declare function doesPlayerHaveAllSoulHearts(player: EntityPlayer): boolean;
|
|
40
67
|
/**
|
|
41
68
|
* Helper function to find the active slot that the player has the corresponding collectible type
|
|
42
69
|
* in. Returns undefined if the player does not have the collectible in any active slot.
|
package/functions/player.lua
CHANGED
|
@@ -58,6 +58,16 @@ function ____exports.getCharacters(self)
|
|
|
58
58
|
function(____, player) return player:GetPlayerType() end
|
|
59
59
|
)
|
|
60
60
|
end
|
|
61
|
+
--- Returns the number of black hearts that the player has, excluding any soul hearts. For example,
|
|
62
|
+
-- if the player has one full black heart, one full soul heart, and one half black heart, this
|
|
63
|
+
-- function returns 3.
|
|
64
|
+
--
|
|
65
|
+
-- This is different from the `EntityPlayer.GetBlackHearts` method, since that returns a bitmask.
|
|
66
|
+
function ____exports.getPlayerBlackHearts(self, player)
|
|
67
|
+
local blackHeartsBitmask = player:GetBlackHearts()
|
|
68
|
+
local blackHeartBits = countSetBits(nil, blackHeartsBitmask)
|
|
69
|
+
return blackHeartBits * 2
|
|
70
|
+
end
|
|
61
71
|
--- Returns the maximum heart containers that the provided player can have. Normally, this is 12, but
|
|
62
72
|
-- it can change depending on the character (e.g. Keeper) and other things (e.g. Mother's Kiss).
|
|
63
73
|
-- This function does not account for Broken Hearts; use the `getPlayerAvailableHeartSlots` helper
|
|
@@ -78,6 +88,17 @@ function ____exports.getPlayerMaxHeartContainers(self, player)
|
|
|
78
88
|
end
|
|
79
89
|
return characterMaxHeartContainers
|
|
80
90
|
end
|
|
91
|
+
--- Returns the number of soul hearts that the player has, excluding any black hearts. For example,
|
|
92
|
+
-- if the player has one full black heart, one full soul heart, and one half black heart, this
|
|
93
|
+
-- function returns 2.
|
|
94
|
+
--
|
|
95
|
+
-- This is different from the `EntityPlayer.GetSoulHearts` method, since that returns the combined
|
|
96
|
+
-- number of soul hearts and black hearts.
|
|
97
|
+
function ____exports.getPlayerSoulHearts(self, player)
|
|
98
|
+
local soulHearts = player:GetSoulHearts()
|
|
99
|
+
local blackHearts = ____exports.getPlayerBlackHearts(nil, player)
|
|
100
|
+
return soulHearts - blackHearts
|
|
101
|
+
end
|
|
81
102
|
--- Helper function to check if a player is a specific character (i.e. `PlayerType`).
|
|
82
103
|
--
|
|
83
104
|
-- This function is variadic, meaning that you can supply as many characters as you want to check
|
|
@@ -235,6 +256,37 @@ function ____exports.canPlayerCrushRocks(self, player)
|
|
|
235
256
|
local effects = player:GetEffects()
|
|
236
257
|
return player:HasCollectible(CollectibleType.LEO) or player:HasCollectible(CollectibleType.THUNDER_THIGHS) or effects:HasCollectibleEffect(CollectibleType.MEGA_MUSH) or player:HasPlayerForm(PlayerForm.STOMPY)
|
|
237
258
|
end
|
|
259
|
+
--- Returns whether or not all of the player's soul-heart-type hearts are black hearts.
|
|
260
|
+
--
|
|
261
|
+
-- Note that this function does not consider red heart containers.
|
|
262
|
+
--
|
|
263
|
+
-- For example:
|
|
264
|
+
--
|
|
265
|
+
-- - If the player has one black heart, this function would return true.
|
|
266
|
+
-- - If the player has one soul heart and two black hearts, this function would return false.
|
|
267
|
+
-- - If the player has no black hearts, this function will return false.
|
|
268
|
+
-- - If the player has one red heart container and three black hearts, this function would return
|
|
269
|
+
-- true.
|
|
270
|
+
function ____exports.doesPlayerHaveAllBlackHearts(self, player)
|
|
271
|
+
local soulHearts = ____exports.getPlayerSoulHearts(nil, player)
|
|
272
|
+
local blackHearts = ____exports.getPlayerBlackHearts(nil, player)
|
|
273
|
+
return blackHearts > 0 and soulHearts == 0
|
|
274
|
+
end
|
|
275
|
+
--- Returns whether or not all of the player's soul-heart-type hearts are soul hearts.
|
|
276
|
+
--
|
|
277
|
+
-- Note that this function does not consider red heart containers.
|
|
278
|
+
--
|
|
279
|
+
-- For example:
|
|
280
|
+
--
|
|
281
|
+
-- - If the player has two soul hearts and one black heart, this function would return false.
|
|
282
|
+
-- - If the player has no soul hearts, this function will return false.
|
|
283
|
+
-- - If the player has one red heart container and three soul hearts, this function would return
|
|
284
|
+
-- true.
|
|
285
|
+
function ____exports.doesPlayerHaveAllSoulHearts(self, player)
|
|
286
|
+
local soulHearts = ____exports.getPlayerSoulHearts(nil, player)
|
|
287
|
+
local blackHearts = ____exports.getPlayerBlackHearts(nil, player)
|
|
288
|
+
return soulHearts > 0 and blackHearts == 0
|
|
289
|
+
end
|
|
238
290
|
--- Helper function to find the active slot that the player has the corresponding collectible type
|
|
239
291
|
-- in. Returns undefined if the player does not have the collectible in any active slot.
|
|
240
292
|
function ____exports.getActiveItemSlot(self, player, collectibleType)
|
|
@@ -333,16 +385,6 @@ function ____exports.getPlayerAvailableHeartSlots(self, player)
|
|
|
333
385
|
local totalOccupiedHeartSlots = totalHeartContainers + brokenHearts
|
|
334
386
|
return maxHeartContainers - totalOccupiedHeartSlots
|
|
335
387
|
end
|
|
336
|
-
--- Returns the number of black hearts that the player has, excluding any soul hearts. For example,
|
|
337
|
-
-- if the player has one full black heart, one full soul heart, and one half black heart, this
|
|
338
|
-
-- function returns 3.
|
|
339
|
-
--
|
|
340
|
-
-- This is different from the `EntityPlayer.GetBlackHearts` method, since that returns a bitmask.
|
|
341
|
-
function ____exports.getPlayerBlackHearts(self, player)
|
|
342
|
-
local blackHeartsBitmask = player:GetBlackHearts()
|
|
343
|
-
local blackHeartBits = countSetBits(nil, blackHeartsBitmask)
|
|
344
|
-
return blackHeartBits * 2
|
|
345
|
-
end
|
|
346
388
|
--- Iterates over all players and checks if any are close enough to the specified position.
|
|
347
389
|
--
|
|
348
390
|
-- @returns The first player found when iterating upwards from index 0.
|
|
@@ -478,17 +520,6 @@ function ____exports.getPlayerNumHitsRemaining(self, player)
|
|
|
478
520
|
local rottenHearts = player:GetRottenHearts()
|
|
479
521
|
return hearts + soulHearts + boneHearts + eternalHearts - rottenHearts
|
|
480
522
|
end
|
|
481
|
-
--- Returns the number of soul hearts that the player has, excluding any black hearts. For example,
|
|
482
|
-
-- if the player has one full black heart, one full soul heart, and one half black heart, this
|
|
483
|
-
-- function returns 2.
|
|
484
|
-
--
|
|
485
|
-
-- This is different from the `EntityPlayer.GetSoulHearts` method, since that returns the combined
|
|
486
|
-
-- number of soul hearts and black hearts.
|
|
487
|
-
function ____exports.getPlayerSoulHearts(self, player)
|
|
488
|
-
local soulHearts = player:GetSoulHearts()
|
|
489
|
-
local blackHearts = ____exports.getPlayerBlackHearts(nil, player)
|
|
490
|
-
return soulHearts - blackHearts
|
|
491
|
-
end
|
|
492
523
|
--- Helper function to get all of the players that are a certain character.
|
|
493
524
|
--
|
|
494
525
|
-- This function is variadic, meaning that you can supply as many characters as you want to check
|
|
@@ -719,9 +750,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
719
750
|
itemPool:RemoveCollectible(collectibleType)
|
|
720
751
|
end
|
|
721
752
|
repeat
|
|
722
|
-
local
|
|
723
|
-
local
|
|
724
|
-
if
|
|
753
|
+
local ____switch124 = activeSlot
|
|
754
|
+
local ____cond124 = ____switch124 == ActiveSlot.PRIMARY
|
|
755
|
+
if ____cond124 then
|
|
725
756
|
do
|
|
726
757
|
if primaryCollectibleType ~= CollectibleType.NULL then
|
|
727
758
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -730,8 +761,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
730
761
|
break
|
|
731
762
|
end
|
|
732
763
|
end
|
|
733
|
-
|
|
734
|
-
if
|
|
764
|
+
____cond124 = ____cond124 or ____switch124 == ActiveSlot.SECONDARY
|
|
765
|
+
if ____cond124 then
|
|
735
766
|
do
|
|
736
767
|
if primaryCollectibleType ~= CollectibleType.NULL then
|
|
737
768
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -746,16 +777,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
746
777
|
break
|
|
747
778
|
end
|
|
748
779
|
end
|
|
749
|
-
|
|
750
|
-
if
|
|
780
|
+
____cond124 = ____cond124 or ____switch124 == ActiveSlot.POCKET
|
|
781
|
+
if ____cond124 then
|
|
751
782
|
do
|
|
752
783
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
753
784
|
player:SetActiveCharge(charge, activeSlot)
|
|
754
785
|
break
|
|
755
786
|
end
|
|
756
787
|
end
|
|
757
|
-
|
|
758
|
-
if
|
|
788
|
+
____cond124 = ____cond124 or ____switch124 == ActiveSlot.POCKET_SINGLE_USE
|
|
789
|
+
if ____cond124 then
|
|
759
790
|
do
|
|
760
791
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
761
792
|
break
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Helper functions and features for IsaacScript mods.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -22,6 +22,6 @@
|
|
|
22
22
|
"main": "index",
|
|
23
23
|
"types": "index.d.ts",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"isaac-typescript-definitions": "^2.
|
|
25
|
+
"isaac-typescript-definitions": "^2.1.1"
|
|
26
26
|
}
|
|
27
27
|
}
|