isaacscript-common 1.0.529 → 1.0.533
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.
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
local ____exports = {}
|
|
3
3
|
local hasSubscriptions, entityTakeDmgPlayer, damageIsFatal
|
|
4
4
|
local ____player = require("functions.player")
|
|
5
|
+
local getPlayerAvailableHeartSlots = ____player.getPlayerAvailableHeartSlots
|
|
5
6
|
local getPlayerNumAllHearts = ____player.getPlayerNumAllHearts
|
|
6
7
|
local hasLostCurse = ____player.hasLostCurse
|
|
7
8
|
local ____revive = require("functions.revive")
|
|
@@ -41,6 +42,10 @@ function damageIsFatal(self, player, damageAmount)
|
|
|
41
42
|
if damageAmount < playerNumAllHearts then
|
|
42
43
|
return false
|
|
43
44
|
end
|
|
45
|
+
local playerAvailableHeartSlots = getPlayerAvailableHeartSlots(nil, player)
|
|
46
|
+
if player:HasCollectible(CollectibleType.COLLECTIBLE_HEARTBREAK) and (playerAvailableHeartSlots >= 2) then
|
|
47
|
+
return false
|
|
48
|
+
end
|
|
44
49
|
local hearts = player:GetHearts()
|
|
45
50
|
local eternalHearts = player:GetEternalHearts()
|
|
46
51
|
local soulHearts = player:GetSoulHearts()
|
|
@@ -47,6 +47,7 @@ export declare function getClosestPlayer(position: Vector): EntityPlayer;
|
|
|
47
47
|
* Tainted Forgotten have a 20 frame death animation (i.e. the "ForgottenDeath" animation).
|
|
48
48
|
*/
|
|
49
49
|
export declare function getDeathAnimationName(player: EntityPlayer): string;
|
|
50
|
+
export declare function getFinalPlayer(): EntityPlayer;
|
|
50
51
|
/**
|
|
51
52
|
* Helper function that returns the type of the rightmost heart, not including golden hearts since
|
|
52
53
|
* they can't be damaged directly.
|
|
@@ -58,7 +59,18 @@ export declare function getLastHeart(player: EntityPlayer): HealthType;
|
|
|
58
59
|
* will be spawned on the same frame.
|
|
59
60
|
*/
|
|
60
61
|
export declare function getNewestPlayer(): EntityPlayer;
|
|
61
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Returns the number of slots that the player has remaining for heart containers, accounting for
|
|
64
|
+
* broken hearts. For example, if the player is Judas and has 1 red heart containers and 2 full soul
|
|
65
|
+
* hearts and 3 broken hearts, then this function would return 6 (i.e. 12 - 1 - 2 - 3).
|
|
66
|
+
*/
|
|
67
|
+
export declare function getPlayerAvailableHeartSlots(player: EntityPlayer): int;
|
|
68
|
+
/**
|
|
69
|
+
* Returns the maximum heart containers that the provided character can have. Normally, this is 12,
|
|
70
|
+
* but with Keeper it is 3, with Tainted Keeper it is 2. Does not account for Birthright or Mother's
|
|
71
|
+
* Kiss; use the `getPlayerMaxHeartContainers()` function for that.
|
|
72
|
+
*/
|
|
73
|
+
export declare function getCharacterMaxHeartContainers(character: PlayerType): int;
|
|
62
74
|
/**
|
|
63
75
|
* Iterates over all players and checks if any are close enough to the specified position.
|
|
64
76
|
*
|
|
@@ -71,15 +83,6 @@ export declare function getPlayerCloserThan(position: Vector, distance: float):
|
|
|
71
83
|
*/
|
|
72
84
|
export declare function getPlayerCollectibleMap(player: EntityPlayer): Map<CollectibleType | int, int>;
|
|
73
85
|
export declare function getPlayerFromIndex(playerIndex: PlayerIndex): EntityPlayer | undefined;
|
|
74
|
-
/**
|
|
75
|
-
* This function always excludes players with a non-undefined parent, since they are not real
|
|
76
|
-
* players. (e.g. the Strawman Keeper)
|
|
77
|
-
*
|
|
78
|
-
* @param performExclusions Whether or not to exclude characters that are not directly controlled by
|
|
79
|
-
* the player (i.e. Esau & Tainted Soul). False by default.
|
|
80
|
-
*/
|
|
81
|
-
export declare function getPlayers(performExclusions?: boolean): EntityPlayer[];
|
|
82
|
-
export declare function getPlayersOfType(playerType: PlayerType): EntityPlayer[];
|
|
83
86
|
/**
|
|
84
87
|
* Mods often have to track variables relating to the player. In naive mods, information will only
|
|
85
88
|
* be stored about the first player. However, in order to be robust, mods must handle up to 4
|
|
@@ -108,11 +111,26 @@ export declare function getPlayerIndex(player: EntityPlayer): PlayerIndex;
|
|
|
108
111
|
* `Isaac.GetPlayer()` function.
|
|
109
112
|
*/
|
|
110
113
|
export declare function getPlayerIndexVanilla(playerToFind: EntityPlayer): int | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Returns the maximum heart containers that the provided player can have. Normally, this is 12, but
|
|
116
|
+
* it can change depending on the character (e.g. Keeper) and other things (e.g. Mother's Kiss).
|
|
117
|
+
* Does not account for Broken Hearts; use the `getPlayerAvailableHeartSlots()` function for that.
|
|
118
|
+
*/
|
|
119
|
+
export declare function getPlayerMaxHeartContainers(player: EntityPlayer): int;
|
|
111
120
|
/**
|
|
112
121
|
* Returns the combined value of all of the player's red hearts, soul/black hearts, and bone hearts.
|
|
113
122
|
* This is equivalent to the number of hits that the player can currently take.
|
|
114
123
|
*/
|
|
115
124
|
export declare function getPlayerNumAllHearts(player: EntityPlayer): int;
|
|
125
|
+
/**
|
|
126
|
+
* This function always excludes players with a non-undefined parent, since they are not real
|
|
127
|
+
* players. (e.g. the Strawman Keeper)
|
|
128
|
+
*
|
|
129
|
+
* @param performExclusions Whether or not to exclude characters that are not directly controlled by
|
|
130
|
+
* the player (i.e. Esau & Tainted Soul). False by default.
|
|
131
|
+
*/
|
|
132
|
+
export declare function getPlayers(performExclusions?: boolean): EntityPlayer[];
|
|
133
|
+
export declare function getPlayersOfType(playerType: PlayerType): EntityPlayer[];
|
|
116
134
|
/**
|
|
117
135
|
* Helper function to return the active charge and the battery charge combined. This is useful
|
|
118
136
|
* because you are not able to set the battery charge directly.
|
|
@@ -6,6 +6,7 @@ local ____constants = require("constants")
|
|
|
6
6
|
local CHARACTERS_WITH_NO_RED_HEARTS = ____constants.CHARACTERS_WITH_NO_RED_HEARTS
|
|
7
7
|
local CHARACTERS_WITH_NO_SOUL_HEARTS = ____constants.CHARACTERS_WITH_NO_SOUL_HEARTS
|
|
8
8
|
local LOST_STYLE_PLAYER_TYPES = ____constants.LOST_STYLE_PLAYER_TYPES
|
|
9
|
+
local MAX_PLAYER_HEART_CONTAINERS = ____constants.MAX_PLAYER_HEART_CONTAINERS
|
|
9
10
|
local ____HealthType = require("types.HealthType")
|
|
10
11
|
local HealthType = ____HealthType.HealthType
|
|
11
12
|
local ____bitwise = require("functions.bitwise")
|
|
@@ -17,6 +18,35 @@ local ____collectibleSet = require("functions.collectibleSet")
|
|
|
17
18
|
local getCollectibleSet = ____collectibleSet.getCollectibleSet
|
|
18
19
|
local ____util = require("functions.util")
|
|
19
20
|
local ensureAllCases = ____util.ensureAllCases
|
|
21
|
+
function ____exports.getCharacterMaxHeartContainers(self, character)
|
|
22
|
+
if character == PlayerType.PLAYER_KEEPER then
|
|
23
|
+
return 3
|
|
24
|
+
end
|
|
25
|
+
if character == PlayerType.PLAYER_KEEPER_B then
|
|
26
|
+
return 2
|
|
27
|
+
end
|
|
28
|
+
return 12
|
|
29
|
+
end
|
|
30
|
+
function ____exports.getPlayerIndex(self, player)
|
|
31
|
+
local character = player:GetPlayerType()
|
|
32
|
+
local collectibleToUse = ((character == PlayerType.PLAYER_LAZARUS2_B) and CollectibleType.COLLECTIBLE_INNER_EYE) or CollectibleType.COLLECTIBLE_SAD_ONION
|
|
33
|
+
local collectibleRNG = player:GetCollectibleRNG(collectibleToUse)
|
|
34
|
+
local seed = collectibleRNG:GetSeed()
|
|
35
|
+
return seed
|
|
36
|
+
end
|
|
37
|
+
function ____exports.getPlayerMaxHeartContainers(self, player)
|
|
38
|
+
local character = player:GetPlayerType()
|
|
39
|
+
local maxHeartContainers = ____exports.getCharacterMaxHeartContainers(nil, character)
|
|
40
|
+
if (character == PlayerType.PLAYER_MAGDALENE) and player:HasCollectible(CollectibleType.COLLECTIBLE_BIRTHRIGHT) then
|
|
41
|
+
maxHeartContainers = maxHeartContainers + 6
|
|
42
|
+
end
|
|
43
|
+
local numMothersKisses = player:GetTrinketMultiplier(TrinketType.TRINKET_MOTHERS_KISS)
|
|
44
|
+
maxHeartContainers = maxHeartContainers + numMothersKisses
|
|
45
|
+
if maxHeartContainers > MAX_PLAYER_HEART_CONTAINERS then
|
|
46
|
+
maxHeartContainers = MAX_PLAYER_HEART_CONTAINERS
|
|
47
|
+
end
|
|
48
|
+
return maxHeartContainers
|
|
49
|
+
end
|
|
20
50
|
function ____exports.getPlayers(self, performExclusions)
|
|
21
51
|
if performExclusions == nil then
|
|
22
52
|
performExclusions = false
|
|
@@ -29,30 +59,23 @@ function ____exports.getPlayers(self, performExclusions)
|
|
|
29
59
|
do
|
|
30
60
|
local player = Isaac.GetPlayer(i)
|
|
31
61
|
if player == nil then
|
|
32
|
-
goto
|
|
62
|
+
goto __continue66
|
|
33
63
|
end
|
|
34
64
|
if ____exports.isChildPlayer(nil, player) then
|
|
35
|
-
goto
|
|
65
|
+
goto __continue66
|
|
36
66
|
end
|
|
37
67
|
local character = player:GetPlayerType()
|
|
38
68
|
if performExclusions and EXCLUDED_CHARACTERS:has(character) then
|
|
39
|
-
goto
|
|
69
|
+
goto __continue66
|
|
40
70
|
end
|
|
41
71
|
__TS__ArrayPush(players, player)
|
|
42
72
|
end
|
|
43
|
-
::
|
|
73
|
+
::__continue66::
|
|
44
74
|
i = i + 1
|
|
45
75
|
end
|
|
46
76
|
end
|
|
47
77
|
return players
|
|
48
78
|
end
|
|
49
|
-
function ____exports.getPlayerIndex(self, player)
|
|
50
|
-
local character = player:GetPlayerType()
|
|
51
|
-
local collectibleToUse = ((character == PlayerType.PLAYER_LAZARUS2_B) and CollectibleType.COLLECTIBLE_INNER_EYE) or CollectibleType.COLLECTIBLE_SAD_ONION
|
|
52
|
-
local collectibleRNG = player:GetCollectibleRNG(collectibleToUse)
|
|
53
|
-
local seed = collectibleRNG:GetSeed()
|
|
54
|
-
return seed
|
|
55
|
-
end
|
|
56
79
|
function ____exports.isChildPlayer(self, player)
|
|
57
80
|
return player.Parent ~= nil
|
|
58
81
|
end
|
|
@@ -155,6 +178,10 @@ function ____exports.getDeathAnimationName(self, player)
|
|
|
155
178
|
end
|
|
156
179
|
return "Death"
|
|
157
180
|
end
|
|
181
|
+
function ____exports.getFinalPlayer(self)
|
|
182
|
+
local players = ____exports.getPlayers(nil)
|
|
183
|
+
return players[#players]
|
|
184
|
+
end
|
|
158
185
|
function ____exports.getLastHeart(self, player)
|
|
159
186
|
local hearts = player:GetHearts()
|
|
160
187
|
local effectiveMaxHearts = player:GetEffectiveMaxHearts()
|
|
@@ -212,9 +239,16 @@ function ____exports.getNewestPlayer(self)
|
|
|
212
239
|
end
|
|
213
240
|
return newestPlayer
|
|
214
241
|
end
|
|
215
|
-
function ____exports.
|
|
216
|
-
local
|
|
217
|
-
|
|
242
|
+
function ____exports.getPlayerAvailableHeartSlots(self, player)
|
|
243
|
+
local maxHeartContainers = ____exports.getPlayerMaxHeartContainers(nil, player)
|
|
244
|
+
local effectiveMaxHearts = player:GetEffectiveMaxHearts()
|
|
245
|
+
local normalAndBoneHeartContainers = effectiveMaxHearts / 2
|
|
246
|
+
local soulHearts = player:GetSoulHearts()
|
|
247
|
+
local soulHeartContainers = math.ceil(soulHearts / 2)
|
|
248
|
+
local totalHeartContainers = normalAndBoneHeartContainers + soulHeartContainers
|
|
249
|
+
local brokenHearts = player:GetBrokenHearts()
|
|
250
|
+
local totalOccupiedHeartSlots = totalHeartContainers + brokenHearts
|
|
251
|
+
return maxHeartContainers - totalOccupiedHeartSlots
|
|
218
252
|
end
|
|
219
253
|
function ____exports.getPlayerCloserThan(self, position, distance)
|
|
220
254
|
for ____, player in ipairs(
|
|
@@ -250,18 +284,6 @@ function ____exports.getPlayerFromIndex(self, playerIndex)
|
|
|
250
284
|
end
|
|
251
285
|
return nil
|
|
252
286
|
end
|
|
253
|
-
function ____exports.getPlayersOfType(self, playerType)
|
|
254
|
-
local players = {}
|
|
255
|
-
for ____, player in ipairs(
|
|
256
|
-
____exports.getPlayers(nil)
|
|
257
|
-
) do
|
|
258
|
-
local character = player:GetPlayerType()
|
|
259
|
-
if character == playerType then
|
|
260
|
-
__TS__ArrayPush(players, player)
|
|
261
|
-
end
|
|
262
|
-
end
|
|
263
|
-
return players
|
|
264
|
-
end
|
|
265
287
|
function ____exports.getPlayerIndexVanilla(self, playerToFind)
|
|
266
288
|
local game = Game()
|
|
267
289
|
local playerToFindHash = GetPtrHash(playerToFind)
|
|
@@ -271,14 +293,14 @@ function ____exports.getPlayerIndexVanilla(self, playerToFind)
|
|
|
271
293
|
do
|
|
272
294
|
local player = Isaac.GetPlayer(i)
|
|
273
295
|
if player == nil then
|
|
274
|
-
goto
|
|
296
|
+
goto __continue58
|
|
275
297
|
end
|
|
276
298
|
local playerHash = GetPtrHash(player)
|
|
277
299
|
if playerHash == playerToFindHash then
|
|
278
300
|
return i
|
|
279
301
|
end
|
|
280
302
|
end
|
|
281
|
-
::
|
|
303
|
+
::__continue58::
|
|
282
304
|
i = i + 1
|
|
283
305
|
end
|
|
284
306
|
end
|
|
@@ -289,7 +311,20 @@ function ____exports.getPlayerNumAllHearts(self, player)
|
|
|
289
311
|
local soulHearts = player:GetSoulHearts()
|
|
290
312
|
local boneHearts = player:GetBoneHearts()
|
|
291
313
|
local eternalHearts = player:GetEternalHearts()
|
|
292
|
-
|
|
314
|
+
local rottenHearts = player:GetRottenHearts()
|
|
315
|
+
return (((hearts + soulHearts) + boneHearts) + eternalHearts) - rottenHearts
|
|
316
|
+
end
|
|
317
|
+
function ____exports.getPlayersOfType(self, playerType)
|
|
318
|
+
local players = {}
|
|
319
|
+
for ____, player in ipairs(
|
|
320
|
+
____exports.getPlayers(nil)
|
|
321
|
+
) do
|
|
322
|
+
local character = player:GetPlayerType()
|
|
323
|
+
if character == playerType then
|
|
324
|
+
__TS__ArrayPush(players, player)
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
return players
|
|
293
328
|
end
|
|
294
329
|
function ____exports.getTotalCharge(self, player, activeSlot)
|
|
295
330
|
local activeCharge = player:GetActiveCharge(activeSlot)
|
|
@@ -386,9 +421,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
386
421
|
itemPool:RemoveCollectible(collectibleType)
|
|
387
422
|
end
|
|
388
423
|
repeat
|
|
389
|
-
local
|
|
390
|
-
local
|
|
391
|
-
if
|
|
424
|
+
local ____switch96 = activeSlot
|
|
425
|
+
local ____cond96 = ____switch96 == ActiveSlot.SLOT_PRIMARY
|
|
426
|
+
if ____cond96 then
|
|
392
427
|
do
|
|
393
428
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
394
429
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -397,8 +432,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
397
432
|
break
|
|
398
433
|
end
|
|
399
434
|
end
|
|
400
|
-
|
|
401
|
-
if
|
|
435
|
+
____cond96 = ____cond96 or (____switch96 == ActiveSlot.SLOT_SECONDARY)
|
|
436
|
+
if ____cond96 then
|
|
402
437
|
do
|
|
403
438
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
404
439
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -413,16 +448,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
413
448
|
break
|
|
414
449
|
end
|
|
415
450
|
end
|
|
416
|
-
|
|
417
|
-
if
|
|
451
|
+
____cond96 = ____cond96 or (____switch96 == ActiveSlot.SLOT_POCKET)
|
|
452
|
+
if ____cond96 then
|
|
418
453
|
do
|
|
419
454
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
420
455
|
player:SetActiveCharge(charge, activeSlot)
|
|
421
456
|
break
|
|
422
457
|
end
|
|
423
458
|
end
|
|
424
|
-
|
|
425
|
-
if
|
|
459
|
+
____cond96 = ____cond96 or (____switch96 == ActiveSlot.SLOT_POCKET2)
|
|
460
|
+
if ____cond96 then
|
|
426
461
|
do
|
|
427
462
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
428
463
|
break
|
package/dist/upgradeMod.lua
CHANGED
|
@@ -81,8 +81,6 @@ local areFeaturesInitialized = ____initialized.areFeaturesInitialized
|
|
|
81
81
|
local setFeaturesInitialized = ____initialized.setFeaturesInitialized
|
|
82
82
|
local ____patchErrorFunctions = require("patchErrorFunctions")
|
|
83
83
|
local patchErrorFunction = ____patchErrorFunctions.patchErrorFunction
|
|
84
|
-
local ____patchPrintFunction = require("patchPrintFunction")
|
|
85
|
-
local patchPrintFunction = ____patchPrintFunction.patchPrintFunction
|
|
86
84
|
local ____ModUpgraded = require("types.ModUpgraded")
|
|
87
85
|
local ModUpgraded = ____ModUpgraded.ModUpgraded
|
|
88
86
|
function initCustomCallbacks(self, mod)
|
|
@@ -129,7 +127,6 @@ function ____exports.upgradeMod(self, modVanilla, verbose)
|
|
|
129
127
|
verbose = false
|
|
130
128
|
end
|
|
131
129
|
patchErrorFunction(nil)
|
|
132
|
-
patchPrintFunction(nil)
|
|
133
130
|
local mod = __TS__New(ModUpgraded, modVanilla, verbose)
|
|
134
131
|
if not areFeaturesInitialized(nil) then
|
|
135
132
|
setFeaturesInitialized(nil)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.533",
|
|
4
4
|
"description": "Helper functions for IsaacScript mods",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist/**/*.d.ts"
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"isaac-typescript-definitions": "^1.0.
|
|
28
|
+
"isaac-typescript-definitions": "^1.0.298",
|
|
29
29
|
"isaacscript-lint": "^1.0.72",
|
|
30
30
|
"typedoc": "^0.22.10",
|
|
31
31
|
"typescript": "4.4.4",
|