isaacscript-common 1.2.114 → 1.2.117

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,6 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
- local hasSubscriptions, postRender, postNewRoom, postPEffectUpdateReordered, checkWaitingForItemAnimation, postPlayerFatalDamage, preBerserkDeath, playerIsAboutToDie, CustomReviveState, v
3
+ local hasSubscriptions, postRender, postPEffectUpdateReordered, checkWaitingForItemAnimation, postPlayerFatalDamage, preBerserkDeath, playerIsAboutToDie, CustomReviveState, v
4
4
  local ____exports = require("features.saveDataManager.exports")
5
5
  local saveDataManager = ____exports.saveDataManager
6
6
  local ____collectibles = require("functions.collectibles")
@@ -27,15 +27,6 @@ function postRender(self)
27
27
  local sfx = SFXManager()
28
28
  sfx:Stop(SoundEffect.SOUND_1UP)
29
29
  end
30
- function postNewRoom(self)
31
- if v.run.state == CustomReviveState.CHANGING_ROOMS then
32
- v.run.state = CustomReviveState.WAITING_FOR_ITEM_ANIMATION
33
- elseif v.run.state == CustomReviveState.WAITING_FOR_ITEM_ANIMATION then
34
- v.run.state = CustomReviveState.DISABLED
35
- v.run.revivalType = nil
36
- v.run.dyingPlayerIndex = nil
37
- end
38
- end
39
30
  function postPEffectUpdateReordered(self, player)
40
31
  checkWaitingForItemAnimation(nil, player)
41
32
  end
@@ -85,7 +76,7 @@ function playerIsAboutToDie(self, player)
85
76
  if revivalType == nil then
86
77
  return
87
78
  end
88
- v.run.state = CustomReviveState.CHANGING_ROOMS
79
+ v.run.state = CustomReviveState.WAITING_FOR_ITEM_ANIMATION
89
80
  v.run.revivalType = revivalType
90
81
  v.run.dyingPlayerIndex = getPlayerIndex(nil, player)
91
82
  player:AddCollectible(CollectibleType.COLLECTIBLE_1UP, 0, false)
@@ -95,15 +86,12 @@ end
95
86
  CustomReviveState = CustomReviveState or ({})
96
87
  CustomReviveState.DISABLED = 0
97
88
  CustomReviveState[CustomReviveState.DISABLED] = "DISABLED"
98
- CustomReviveState.CHANGING_ROOMS = 1
99
- CustomReviveState[CustomReviveState.CHANGING_ROOMS] = "CHANGING_ROOMS"
100
- CustomReviveState.WAITING_FOR_ITEM_ANIMATION = 2
89
+ CustomReviveState.WAITING_FOR_ITEM_ANIMATION = 1
101
90
  CustomReviveState[CustomReviveState.WAITING_FOR_ITEM_ANIMATION] = "WAITING_FOR_ITEM_ANIMATION"
102
91
  v = {run = {state = CustomReviveState.DISABLED, revivalType = nil, dyingPlayerIndex = nil}}
103
92
  function ____exports.customReviveCallbacksInit(self, mod)
104
93
  saveDataManager(nil, "customRevive", v, hasSubscriptions)
105
94
  mod:AddCallback(ModCallbacks.MC_POST_RENDER, postRender)
106
- mod:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, postNewRoom)
107
95
  mod:AddCallbackCustom(ModCallbacksCustom.MC_POST_PEFFECT_UPDATE_REORDERED, postPEffectUpdateReordered)
108
96
  mod:AddCallbackCustom(ModCallbacksCustom.MC_POST_PLAYER_FATAL_DAMAGE, postPlayerFatalDamage)
109
97
  mod:AddCallbackCustom(ModCallbacksCustom.MC_PRE_BERSERK_DEATH, preBerserkDeath)
@@ -137,17 +137,17 @@ function ____exports.logPlayerHealth(player)
137
137
  local playerName = getPlayerName(nil, player)
138
138
  local playerHealth = getPlayerHealth(nil, player)
139
139
  ____exports.log(("Player health for " .. playerName) .. ":")
140
- ____exports.log("- Max hearts: " .. tostring(playerHealth.maxHearts))
141
- ____exports.log("- Hearts: " .. tostring(playerHealth.hearts))
142
- ____exports.log("- Eternal hearts: " .. tostring(playerHealth.eternalHearts))
143
- ____exports.log("- Soul hearts: " .. tostring(playerHealth.soulHearts))
144
- ____exports.log("- Bone hearts: " .. tostring(playerHealth.boneHearts))
145
- ____exports.log("- Golden hearts: " .. tostring(playerHealth.goldenHearts))
146
- ____exports.log("- Rotten hearts: " .. tostring(playerHealth.rottenHearts))
147
- ____exports.log("- Broken hearts: " .. tostring(playerHealth.brokenHearts))
148
- ____exports.log("- Soul charges: " .. tostring(playerHealth.soulCharges))
149
- ____exports.log("- Blood charges: " .. tostring(playerHealth.bloodCharges))
150
- ____exports.log(("- Soul heart types: [" .. table.concat(playerHealth.soulHeartTypes, "," or ",")) .. "]")
140
+ ____exports.log(" Max hearts: " .. tostring(playerHealth.maxHearts))
141
+ ____exports.log(" Hearts: " .. tostring(playerHealth.hearts))
142
+ ____exports.log(" Eternal hearts: " .. tostring(playerHealth.eternalHearts))
143
+ ____exports.log(" Soul hearts: " .. tostring(playerHealth.soulHearts))
144
+ ____exports.log(" Bone hearts: " .. tostring(playerHealth.boneHearts))
145
+ ____exports.log(" Golden hearts: " .. tostring(playerHealth.goldenHearts))
146
+ ____exports.log(" Rotten hearts: " .. tostring(playerHealth.rottenHearts))
147
+ ____exports.log(" Broken hearts: " .. tostring(playerHealth.brokenHearts))
148
+ ____exports.log(" Soul charges: " .. tostring(playerHealth.soulCharges))
149
+ ____exports.log(" Blood charges: " .. tostring(playerHealth.bloodCharges))
150
+ ____exports.log((" Soul heart types: [" .. table.concat(playerHealth.soulHeartTypes, "," or ",")) .. "]")
151
151
  end
152
152
  function ____exports.logRoom()
153
153
  local roomGridIndex = getRoomGridIndex(nil)
@@ -218,7 +218,7 @@ export declare function getSubPlayerParent(subPlayer: EntitySubPlayer): EntityPl
218
218
  * This function does not validate whether or not the provided player is Tainted Magdalene; that
219
219
  * should be accomplished before invoking this function.
220
220
  */
221
- export declare function getTaintedMagdaleneNonTemporaryMaxHearts(player: EntityPlayer): 4 | 6;
221
+ export declare function getTaintedMagdaleneNonTemporaryMaxHearts(player: EntityPlayer): number;
222
222
  /**
223
223
  * Helper function to return the active charge and the battery charge combined. This is useful
224
224
  * because you are not able to set the battery charge directly.
@@ -504,8 +504,10 @@ function ____exports.getSoulHearts(self, player)
504
504
  return soulHearts - blackHearts
505
505
  end
506
506
  function ____exports.getTaintedMagdaleneNonTemporaryMaxHearts(self, player)
507
+ local maxHearts = player:GetMaxHearts()
507
508
  local hasBirthright = player:HasCollectible(CollectibleType.COLLECTIBLE_BIRTHRIGHT)
508
- return hasBirthright and 6 or 4
509
+ local maxNonTemporaryMaxHearts = hasBirthright and 6 or 4
510
+ return math.min(maxHearts, maxNonTemporaryMaxHearts)
509
511
  end
510
512
  function ____exports.getTotalCharge(self, player, activeSlot)
511
513
  local activeCharge = player:GetActiveCharge(activeSlot)
@@ -5,6 +5,10 @@ local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
5
5
  local ____exports = {}
6
6
  local ____constants = require("constants")
7
7
  local MAX_PLAYER_HEART_CONTAINERS = ____constants.MAX_PLAYER_HEART_CONTAINERS
8
+ local ____player = require("functions.player")
9
+ local getHearts = ____player.getHearts
10
+ local ____utils = require("functions.utils")
11
+ local ____repeat = ____utils["repeat"]
8
12
  function ____exports.removeAllPlayerHealth(self, player)
9
13
  local character = player:GetPlayerType()
10
14
  local goldenHearts = player:GetGoldenHearts()
@@ -29,7 +33,7 @@ function ____exports.getPlayerHealth(self, player)
29
33
  local character = player:GetPlayerType()
30
34
  local soulHeartTypes = {}
31
35
  local maxHearts = player:GetMaxHearts()
32
- local hearts = player:GetHearts()
36
+ local hearts = getHearts(nil, player)
33
37
  local soulHearts = player:GetSoulHearts()
34
38
  local boneHearts = player:GetBoneHearts()
35
39
  local goldenHearts = player:GetGoldenHearts()
@@ -47,7 +51,6 @@ function ____exports.getPlayerHealth(self, player)
47
51
  maxHearts = subPlayer:GetBoneHearts() * 2
48
52
  hearts = subPlayer:GetHearts()
49
53
  end
50
- hearts = hearts - rottenHearts * 2
51
54
  local extraHearts = math.ceil(soulHearts / 2) + boneHearts
52
55
  local currentSoulHeart = 0
53
56
  do
@@ -91,6 +94,7 @@ end
91
94
  function ____exports.setPlayerHealth(self, player, playerHealth)
92
95
  local character = player:GetPlayerType()
93
96
  local subPlayer = player:GetSubPlayer()
97
+ local isTaintedMagdalene = character == PlayerType.PLAYER_MAGDALENE_B
94
98
  ____exports.removeAllPlayerHealth(nil, player)
95
99
  if character == PlayerType.PLAYER_THESOUL and subPlayer ~= nil then
96
100
  subPlayer:AddMaxHearts(playerHealth.maxHearts, false)
@@ -119,7 +123,16 @@ function ____exports.setPlayerHealth(self, player, playerHealth)
119
123
  end
120
124
  )
121
125
  player:AddRottenHearts(playerHealth.rottenHearts)
122
- player:AddHearts(playerHealth.hearts)
126
+ ____repeat(
127
+ nil,
128
+ playerHealth.hearts,
129
+ function()
130
+ player:AddHearts(1)
131
+ if isTaintedMagdalene then
132
+ player:AddHearts(-1)
133
+ end
134
+ end
135
+ )
123
136
  player:AddGoldenHearts(playerHealth.goldenHearts)
124
137
  player:AddBrokenHearts(playerHealth.brokenHearts)
125
138
  if character == PlayerType.PLAYER_BETHANY then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.114",
3
+ "version": "1.2.117",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "devDependencies": {
28
28
  "@zamiell/typescript-to-lua": "^1.4.2",
29
- "isaac-typescript-definitions": "^1.0.358",
29
+ "isaac-typescript-definitions": "^1.0.359",
30
30
  "isaacscript-lint": "^1.0.84",
31
31
  "isaacscript-tsconfig": "^1.1.8",
32
32
  "typedoc": "^0.22.13",