isaacscript-common 1.0.529 → 1.0.530
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,13 @@ 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.getPlayerIndex(self, player)
|
|
22
|
+
local character = player:GetPlayerType()
|
|
23
|
+
local collectibleToUse = ((character == PlayerType.PLAYER_LAZARUS2_B) and CollectibleType.COLLECTIBLE_INNER_EYE) or CollectibleType.COLLECTIBLE_SAD_ONION
|
|
24
|
+
local collectibleRNG = player:GetCollectibleRNG(collectibleToUse)
|
|
25
|
+
local seed = collectibleRNG:GetSeed()
|
|
26
|
+
return seed
|
|
27
|
+
end
|
|
20
28
|
function ____exports.getPlayers(self, performExclusions)
|
|
21
29
|
if performExclusions == nil then
|
|
22
30
|
performExclusions = false
|
|
@@ -29,30 +37,23 @@ function ____exports.getPlayers(self, performExclusions)
|
|
|
29
37
|
do
|
|
30
38
|
local player = Isaac.GetPlayer(i)
|
|
31
39
|
if player == nil then
|
|
32
|
-
goto
|
|
40
|
+
goto __continue66
|
|
33
41
|
end
|
|
34
42
|
if ____exports.isChildPlayer(nil, player) then
|
|
35
|
-
goto
|
|
43
|
+
goto __continue66
|
|
36
44
|
end
|
|
37
45
|
local character = player:GetPlayerType()
|
|
38
46
|
if performExclusions and EXCLUDED_CHARACTERS:has(character) then
|
|
39
|
-
goto
|
|
47
|
+
goto __continue66
|
|
40
48
|
end
|
|
41
49
|
__TS__ArrayPush(players, player)
|
|
42
50
|
end
|
|
43
|
-
::
|
|
51
|
+
::__continue66::
|
|
44
52
|
i = i + 1
|
|
45
53
|
end
|
|
46
54
|
end
|
|
47
55
|
return players
|
|
48
56
|
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
57
|
function ____exports.isChildPlayer(self, player)
|
|
57
58
|
return player.Parent ~= nil
|
|
58
59
|
end
|
|
@@ -155,6 +156,10 @@ function ____exports.getDeathAnimationName(self, player)
|
|
|
155
156
|
end
|
|
156
157
|
return "Death"
|
|
157
158
|
end
|
|
159
|
+
function ____exports.getFinalPlayer(self)
|
|
160
|
+
local players = ____exports.getPlayers(nil)
|
|
161
|
+
return players[#players]
|
|
162
|
+
end
|
|
158
163
|
function ____exports.getLastHeart(self, player)
|
|
159
164
|
local hearts = player:GetHearts()
|
|
160
165
|
local effectiveMaxHearts = player:GetEffectiveMaxHearts()
|
|
@@ -212,9 +217,23 @@ function ____exports.getNewestPlayer(self)
|
|
|
212
217
|
end
|
|
213
218
|
return newestPlayer
|
|
214
219
|
end
|
|
215
|
-
function ____exports.
|
|
216
|
-
local
|
|
217
|
-
|
|
220
|
+
function ____exports.getPlayerAvailableHeartSlots(self, player)
|
|
221
|
+
local effectiveMaxHearts = player:GetEffectiveMaxHearts()
|
|
222
|
+
local normalAndBoneHeartContainers = effectiveMaxHearts / 2
|
|
223
|
+
local soulHearts = player:GetSoulHearts()
|
|
224
|
+
local soulHeartContainers = math.ceil(soulHearts / 2)
|
|
225
|
+
local totalHeartContainers = normalAndBoneHeartContainers + soulHeartContainers
|
|
226
|
+
local brokenHearts = player:GetBrokenHearts()
|
|
227
|
+
return totalHeartContainers - brokenHearts
|
|
228
|
+
end
|
|
229
|
+
function ____exports.getCharacterMaxHeartContainers(self, character)
|
|
230
|
+
if character == PlayerType.PLAYER_KEEPER then
|
|
231
|
+
return 3
|
|
232
|
+
end
|
|
233
|
+
if character == PlayerType.PLAYER_KEEPER_B then
|
|
234
|
+
return 2
|
|
235
|
+
end
|
|
236
|
+
return 12
|
|
218
237
|
end
|
|
219
238
|
function ____exports.getPlayerCloserThan(self, position, distance)
|
|
220
239
|
for ____, player in ipairs(
|
|
@@ -250,18 +269,6 @@ function ____exports.getPlayerFromIndex(self, playerIndex)
|
|
|
250
269
|
end
|
|
251
270
|
return nil
|
|
252
271
|
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
272
|
function ____exports.getPlayerIndexVanilla(self, playerToFind)
|
|
266
273
|
local game = Game()
|
|
267
274
|
local playerToFindHash = GetPtrHash(playerToFind)
|
|
@@ -271,19 +278,32 @@ function ____exports.getPlayerIndexVanilla(self, playerToFind)
|
|
|
271
278
|
do
|
|
272
279
|
local player = Isaac.GetPlayer(i)
|
|
273
280
|
if player == nil then
|
|
274
|
-
goto
|
|
281
|
+
goto __continue58
|
|
275
282
|
end
|
|
276
283
|
local playerHash = GetPtrHash(player)
|
|
277
284
|
if playerHash == playerToFindHash then
|
|
278
285
|
return i
|
|
279
286
|
end
|
|
280
287
|
end
|
|
281
|
-
::
|
|
288
|
+
::__continue58::
|
|
282
289
|
i = i + 1
|
|
283
290
|
end
|
|
284
291
|
end
|
|
285
292
|
return nil
|
|
286
293
|
end
|
|
294
|
+
function ____exports.getPlayerMaxHeartContainers(self, player)
|
|
295
|
+
local character = player:GetPlayerType()
|
|
296
|
+
local maxHeartContainers = ____exports.getCharacterMaxHeartContainers(nil, character)
|
|
297
|
+
if (character == PlayerType.PLAYER_MAGDALENE) and player:HasCollectible(CollectibleType.COLLECTIBLE_BIRTHRIGHT) then
|
|
298
|
+
maxHeartContainers = maxHeartContainers + 6
|
|
299
|
+
end
|
|
300
|
+
local numMothersKisses = player:GetTrinketMultiplier(TrinketType.TRINKET_MOTHERS_KISS)
|
|
301
|
+
maxHeartContainers = maxHeartContainers + numMothersKisses
|
|
302
|
+
if maxHeartContainers > MAX_PLAYER_HEART_CONTAINERS then
|
|
303
|
+
maxHeartContainers = MAX_PLAYER_HEART_CONTAINERS
|
|
304
|
+
end
|
|
305
|
+
return maxHeartContainers
|
|
306
|
+
end
|
|
287
307
|
function ____exports.getPlayerNumAllHearts(self, player)
|
|
288
308
|
local hearts = player:GetHearts()
|
|
289
309
|
local soulHearts = player:GetSoulHearts()
|
|
@@ -291,6 +311,18 @@ function ____exports.getPlayerNumAllHearts(self, player)
|
|
|
291
311
|
local eternalHearts = player:GetEternalHearts()
|
|
292
312
|
return ((hearts + soulHearts) + boneHearts) + eternalHearts
|
|
293
313
|
end
|
|
314
|
+
function ____exports.getPlayersOfType(self, playerType)
|
|
315
|
+
local players = {}
|
|
316
|
+
for ____, player in ipairs(
|
|
317
|
+
____exports.getPlayers(nil)
|
|
318
|
+
) do
|
|
319
|
+
local character = player:GetPlayerType()
|
|
320
|
+
if character == playerType then
|
|
321
|
+
__TS__ArrayPush(players, player)
|
|
322
|
+
end
|
|
323
|
+
end
|
|
324
|
+
return players
|
|
325
|
+
end
|
|
294
326
|
function ____exports.getTotalCharge(self, player, activeSlot)
|
|
295
327
|
local activeCharge = player:GetActiveCharge(activeSlot)
|
|
296
328
|
local batteryCharge = player:GetBatteryCharge(activeSlot)
|
|
@@ -386,9 +418,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
386
418
|
itemPool:RemoveCollectible(collectibleType)
|
|
387
419
|
end
|
|
388
420
|
repeat
|
|
389
|
-
local
|
|
390
|
-
local
|
|
391
|
-
if
|
|
421
|
+
local ____switch96 = activeSlot
|
|
422
|
+
local ____cond96 = ____switch96 == ActiveSlot.SLOT_PRIMARY
|
|
423
|
+
if ____cond96 then
|
|
392
424
|
do
|
|
393
425
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
394
426
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -397,8 +429,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
397
429
|
break
|
|
398
430
|
end
|
|
399
431
|
end
|
|
400
|
-
|
|
401
|
-
if
|
|
432
|
+
____cond96 = ____cond96 or (____switch96 == ActiveSlot.SLOT_SECONDARY)
|
|
433
|
+
if ____cond96 then
|
|
402
434
|
do
|
|
403
435
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
404
436
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -413,16 +445,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
413
445
|
break
|
|
414
446
|
end
|
|
415
447
|
end
|
|
416
|
-
|
|
417
|
-
if
|
|
448
|
+
____cond96 = ____cond96 or (____switch96 == ActiveSlot.SLOT_POCKET)
|
|
449
|
+
if ____cond96 then
|
|
418
450
|
do
|
|
419
451
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
420
452
|
player:SetActiveCharge(charge, activeSlot)
|
|
421
453
|
break
|
|
422
454
|
end
|
|
423
455
|
end
|
|
424
|
-
|
|
425
|
-
if
|
|
456
|
+
____cond96 = ____cond96 or (____switch96 == ActiveSlot.SLOT_POCKET2)
|
|
457
|
+
if ____cond96 then
|
|
426
458
|
do
|
|
427
459
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
428
460
|
break
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.530",
|
|
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.297",
|
|
29
29
|
"isaacscript-lint": "^1.0.72",
|
|
30
30
|
"typedoc": "^0.22.10",
|
|
31
31
|
"typescript": "4.4.4",
|