isaacscript-common 1.2.63 → 1.2.64
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.
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____lualib = require("lualib_bundle")
|
|
3
|
-
local Map = ____lualib.Map
|
|
4
3
|
local __TS__New = ____lualib.__TS__New
|
|
5
4
|
local ____exports = {}
|
|
6
5
|
local hasSubscriptions, entityTakeDmgPlayer, v
|
|
@@ -9,9 +8,11 @@ local saveDataManager = ____exports.saveDataManager
|
|
|
9
8
|
local ____player = require("functions.player")
|
|
10
9
|
local getPlayerIndex = ____player.getPlayerIndex
|
|
11
10
|
local isChildPlayer = ____player.isChildPlayer
|
|
12
|
-
local isDamageToPlayerFatal = ____player.isDamageToPlayerFatal
|
|
13
11
|
local ____revive = require("functions.revive")
|
|
12
|
+
local isDamageToPlayerFatal = ____revive.isDamageToPlayerFatal
|
|
14
13
|
local willPlayerRevive = ____revive.willPlayerRevive
|
|
14
|
+
local ____DefaultMap = require("types.DefaultMap")
|
|
15
|
+
local DefaultMap = ____DefaultMap.DefaultMap
|
|
15
16
|
local ____postPlayerFatalDamage = require("callbacks.subscriptions.postPlayerFatalDamage")
|
|
16
17
|
local postPlayerFatalDamageFire = ____postPlayerFatalDamage.postPlayerFatalDamageFire
|
|
17
18
|
local postPlayerFatalDamageHasSubscriptions = ____postPlayerFatalDamage.postPlayerFatalDamageHasSubscriptions
|
|
@@ -32,8 +33,7 @@ function entityTakeDmgPlayer(self, tookDamage, damageAmount, damageFlags, damage
|
|
|
32
33
|
local game = Game()
|
|
33
34
|
local gameFrameCount = game:GetFrameCount()
|
|
34
35
|
local playerIndex = getPlayerIndex(nil, player)
|
|
35
|
-
local
|
|
36
|
-
v.run.playerLastDamageFrame:set(playerIndex, gameFrameCount)
|
|
36
|
+
local lastDamageGameFrame = v.run.playersLastDamageGameFrame:getAndSetDefault(playerIndex, gameFrameCount)
|
|
37
37
|
if willPlayerRevive(nil, player) then
|
|
38
38
|
return nil
|
|
39
39
|
end
|
|
@@ -42,7 +42,7 @@ function entityTakeDmgPlayer(self, tookDamage, damageAmount, damageFlags, damage
|
|
|
42
42
|
player,
|
|
43
43
|
damageAmount,
|
|
44
44
|
damageSource,
|
|
45
|
-
|
|
45
|
+
lastDamageGameFrame
|
|
46
46
|
) then
|
|
47
47
|
return nil
|
|
48
48
|
end
|
|
@@ -59,7 +59,10 @@ function entityTakeDmgPlayer(self, tookDamage, damageAmount, damageFlags, damage
|
|
|
59
59
|
end
|
|
60
60
|
return nil
|
|
61
61
|
end
|
|
62
|
-
v = {run = {
|
|
62
|
+
v = {run = {playersLastDamageGameFrame = __TS__New(
|
|
63
|
+
DefaultMap,
|
|
64
|
+
function(____, _key, gameFrameCount) return gameFrameCount end
|
|
65
|
+
)}}
|
|
63
66
|
function ____exports.postPlayerFatalDamageCallbackInit(self, mod)
|
|
64
67
|
saveDataManager(nil, "postPlayerFatalDamage", v)
|
|
65
68
|
mod:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, entityTakeDmgPlayer, EntityType.ENTITY_PLAYER)
|
|
@@ -210,8 +210,6 @@ export declare function isBethany(player: EntityPlayer): boolean;
|
|
|
210
210
|
* (For example, the Strawman Keeper.)
|
|
211
211
|
*/
|
|
212
212
|
export declare function isChildPlayer(player: EntityPlayer): boolean;
|
|
213
|
-
/** Uses the player's current health and character to determine if incoming damage will be fatal. */
|
|
214
|
-
export declare function isDamageToPlayerFatal(player: EntityPlayer, damageAmount: int, damageSource: EntityRef, lastDamageFrame?: int): boolean;
|
|
215
213
|
export declare function isFirstPlayer(player: EntityPlayer): boolean;
|
|
216
214
|
/**
|
|
217
215
|
* Helper function for detecting when a player is Jacob or Esau. This will only match the
|
|
@@ -484,44 +484,6 @@ function ____exports.isBethany(self, player)
|
|
|
484
484
|
local character = player:GetPlayerType()
|
|
485
485
|
return character == PlayerType.PLAYER_BETHANY or character == PlayerType.PLAYER_BETHANY_B
|
|
486
486
|
end
|
|
487
|
-
function ____exports.isDamageToPlayerFatal(self, player, damageAmount, damageSource, lastDamageFrame)
|
|
488
|
-
local game = Game()
|
|
489
|
-
local gameFrameCount = game:GetFrameCount()
|
|
490
|
-
local character = player:GetPlayerType()
|
|
491
|
-
local effects = player:GetEffects()
|
|
492
|
-
local isBerserk = effects:HasCollectibleEffect(CollectibleType.COLLECTIBLE_BERSERK)
|
|
493
|
-
if character == PlayerType.PLAYER_JACOB_B and damageSource.Type == EntityType.ENTITY_DARK_ESAU then
|
|
494
|
-
return false
|
|
495
|
-
end
|
|
496
|
-
if isBerserk then
|
|
497
|
-
return false
|
|
498
|
-
end
|
|
499
|
-
if character == PlayerType.PLAYER_JACOB2_B then
|
|
500
|
-
return true
|
|
501
|
-
end
|
|
502
|
-
if ____exports.hasLostCurse(nil, player) then
|
|
503
|
-
return true
|
|
504
|
-
end
|
|
505
|
-
local playerNumAllHearts = ____exports.getPlayerNumHitsRemaining(nil, player)
|
|
506
|
-
if damageAmount < playerNumAllHearts then
|
|
507
|
-
return false
|
|
508
|
-
end
|
|
509
|
-
local playerAvailableHeartSlots = ____exports.getPlayerAvailableHeartSlots(nil, player)
|
|
510
|
-
if player:HasCollectible(CollectibleType.COLLECTIBLE_HEARTBREAK) and playerAvailableHeartSlots >= 2 then
|
|
511
|
-
return false
|
|
512
|
-
end
|
|
513
|
-
if player:HasCollectible(CollectibleType.COLLECTIBLE_BROKEN_GLASS_CANNON) and gameFrameCount == lastDamageFrame then
|
|
514
|
-
return false
|
|
515
|
-
end
|
|
516
|
-
local hearts = player:GetHearts()
|
|
517
|
-
local eternalHearts = player:GetEternalHearts()
|
|
518
|
-
local soulHearts = player:GetSoulHearts()
|
|
519
|
-
local boneHearts = player:GetBoneHearts()
|
|
520
|
-
if hearts > 0 and soulHearts > 0 or hearts > 0 and boneHearts > 0 or soulHearts > 0 and boneHearts > 0 or soulHearts > 0 and eternalHearts > 0 or boneHearts >= 2 then
|
|
521
|
-
return false
|
|
522
|
-
end
|
|
523
|
-
return true
|
|
524
|
-
end
|
|
525
487
|
function ____exports.isFirstPlayer(self, player)
|
|
526
488
|
return ____exports.getPlayerIndexVanilla(nil, player) == 0
|
|
527
489
|
end
|
|
@@ -586,9 +548,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
586
548
|
itemPool:RemoveCollectible(collectibleType)
|
|
587
549
|
end
|
|
588
550
|
repeat
|
|
589
|
-
local
|
|
590
|
-
local
|
|
591
|
-
if
|
|
551
|
+
local ____switch118 = activeSlot
|
|
552
|
+
local ____cond118 = ____switch118 == ActiveSlot.SLOT_PRIMARY
|
|
553
|
+
if ____cond118 then
|
|
592
554
|
do
|
|
593
555
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
594
556
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -597,8 +559,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
597
559
|
break
|
|
598
560
|
end
|
|
599
561
|
end
|
|
600
|
-
|
|
601
|
-
if
|
|
562
|
+
____cond118 = ____cond118 or ____switch118 == ActiveSlot.SLOT_SECONDARY
|
|
563
|
+
if ____cond118 then
|
|
602
564
|
do
|
|
603
565
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
604
566
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -613,16 +575,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
613
575
|
break
|
|
614
576
|
end
|
|
615
577
|
end
|
|
616
|
-
|
|
617
|
-
if
|
|
578
|
+
____cond118 = ____cond118 or ____switch118 == ActiveSlot.SLOT_POCKET
|
|
579
|
+
if ____cond118 then
|
|
618
580
|
do
|
|
619
581
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
620
582
|
player:SetActiveCharge(charge, activeSlot)
|
|
621
583
|
break
|
|
622
584
|
end
|
|
623
585
|
end
|
|
624
|
-
|
|
625
|
-
if
|
|
586
|
+
____cond118 = ____cond118 or ____switch118 == ActiveSlot.SLOT_POCKET2
|
|
587
|
+
if ____cond118 then
|
|
626
588
|
do
|
|
627
589
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
628
590
|
break
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/**
|
|
3
|
+
* Uses the player's current health and other miscellaneous things to determine if incoming damage
|
|
4
|
+
* will be fatal.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isDamageToPlayerFatal(player: EntityPlayer, damageAmount: int, damageSource: EntityRef, lastDamageGameFrame: int): boolean;
|
|
2
7
|
/**
|
|
3
8
|
* The `EntityPlayer.WillPlayerRevive()` function does not properly account for Mysterious Paper,
|
|
4
9
|
* so use this helper function instead for more robust revival detection.
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
local ____exports = {}
|
|
3
3
|
local ____player = require("functions.player")
|
|
4
4
|
local getDeathAnimationName = ____player.getDeathAnimationName
|
|
5
|
+
local getPlayerAvailableHeartSlots = ____player.getPlayerAvailableHeartSlots
|
|
6
|
+
local getPlayerNumHitsRemaining = ____player.getPlayerNumHitsRemaining
|
|
7
|
+
local hasLostCurse = ____player.hasLostCurse
|
|
5
8
|
local ____sprite = require("functions.sprite")
|
|
6
9
|
local getFinalFrameOfAnimation = ____sprite.getFinalFrameOfAnimation
|
|
7
10
|
local ____trinketGive = require("functions.trinketGive")
|
|
@@ -16,12 +19,6 @@ function ____exports.willMysteriousPaperRevive(self, player)
|
|
|
16
19
|
local frameOfDeath = gameFrameCount + deathAnimationFrames + 1
|
|
17
20
|
return frameOfDeath % 4 == 3
|
|
18
21
|
end
|
|
19
|
-
function ____exports.willPlayerRevive(self, player)
|
|
20
|
-
local trinketSituation = temporarilyRemoveTrinket(nil, player, TrinketType.TRINKET_MYSTERIOUS_PAPER)
|
|
21
|
-
local willRevive = player:WillPlayerRevive() or trinketSituation ~= nil and ____exports.willMysteriousPaperRevive(nil, player)
|
|
22
|
-
giveTrinketsBack(nil, player, trinketSituation)
|
|
23
|
-
return willRevive
|
|
24
|
-
end
|
|
25
22
|
function ____exports.willReviveFromSpiritShackles(self, player)
|
|
26
23
|
if not player:HasCollectible(CollectibleType.COLLECTIBLE_SPIRIT_SHACKLES) then
|
|
27
24
|
return false
|
|
@@ -31,4 +28,51 @@ function ____exports.willReviveFromSpiritShackles(self, player)
|
|
|
31
28
|
local playerInSoulForm = effects:HasNullEffect(NullItemID.ID_SPIRIT_SHACKLES_SOUL)
|
|
32
29
|
return spiritShacklesEnabled and not playerInSoulForm
|
|
33
30
|
end
|
|
31
|
+
function ____exports.isDamageToPlayerFatal(self, player, damageAmount, damageSource, lastDamageGameFrame)
|
|
32
|
+
local game = Game()
|
|
33
|
+
local gameFrameCount = game:GetFrameCount()
|
|
34
|
+
local character = player:GetPlayerType()
|
|
35
|
+
local effects = player:GetEffects()
|
|
36
|
+
local isBerserk = effects:HasCollectibleEffect(CollectibleType.COLLECTIBLE_BERSERK)
|
|
37
|
+
if character == PlayerType.PLAYER_JACOB_B and damageSource.Type == EntityType.ENTITY_DARK_ESAU then
|
|
38
|
+
return false
|
|
39
|
+
end
|
|
40
|
+
if isBerserk then
|
|
41
|
+
return false
|
|
42
|
+
end
|
|
43
|
+
if ____exports.willReviveFromSpiritShackles(nil, player) then
|
|
44
|
+
return false
|
|
45
|
+
end
|
|
46
|
+
if character == PlayerType.PLAYER_JACOB2_B then
|
|
47
|
+
return true
|
|
48
|
+
end
|
|
49
|
+
if hasLostCurse(nil, player) then
|
|
50
|
+
return true
|
|
51
|
+
end
|
|
52
|
+
local playerNumAllHearts = getPlayerNumHitsRemaining(nil, player)
|
|
53
|
+
if damageAmount < playerNumAllHearts then
|
|
54
|
+
return false
|
|
55
|
+
end
|
|
56
|
+
local playerAvailableHeartSlots = getPlayerAvailableHeartSlots(nil, player)
|
|
57
|
+
if player:HasCollectible(CollectibleType.COLLECTIBLE_HEARTBREAK) and playerAvailableHeartSlots >= 2 then
|
|
58
|
+
return false
|
|
59
|
+
end
|
|
60
|
+
if player:HasCollectible(CollectibleType.COLLECTIBLE_BROKEN_GLASS_CANNON) and gameFrameCount == lastDamageGameFrame then
|
|
61
|
+
return false
|
|
62
|
+
end
|
|
63
|
+
local hearts = player:GetHearts()
|
|
64
|
+
local eternalHearts = player:GetEternalHearts()
|
|
65
|
+
local soulHearts = player:GetSoulHearts()
|
|
66
|
+
local boneHearts = player:GetBoneHearts()
|
|
67
|
+
if hearts > 0 and soulHearts > 0 or hearts > 0 and boneHearts > 0 or soulHearts > 0 and boneHearts > 0 or soulHearts > 0 and eternalHearts > 0 or boneHearts >= 2 then
|
|
68
|
+
return false
|
|
69
|
+
end
|
|
70
|
+
return true
|
|
71
|
+
end
|
|
72
|
+
function ____exports.willPlayerRevive(self, player)
|
|
73
|
+
local trinketSituation = temporarilyRemoveTrinket(nil, player, TrinketType.TRINKET_MYSTERIOUS_PAPER)
|
|
74
|
+
local willRevive = player:WillPlayerRevive() or trinketSituation ~= nil and ____exports.willMysteriousPaperRevive(nil, player)
|
|
75
|
+
giveTrinketsBack(nil, player, trinketSituation)
|
|
76
|
+
return willRevive
|
|
77
|
+
end
|
|
34
78
|
return ____exports
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.64",
|
|
4
4
|
"description": "Helper functions for IsaacScript mods",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@zamiell/typescript-to-lua": "^1.4.0",
|
|
29
29
|
"isaac-typescript-definitions": "^1.0.349",
|
|
30
|
-
"isaacscript-lint": "^1.0.
|
|
30
|
+
"isaacscript-lint": "^1.0.81",
|
|
31
31
|
"isaacscript-tsconfig": "^1.1.8",
|
|
32
32
|
"typedoc": "^0.22.12",
|
|
33
33
|
"typescript": "^4.5.5"
|