isaacscript-common 6.14.0 → 6.15.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.
@@ -101,10 +101,14 @@ export declare function getCollectibleMaxCharges(collectibleType: CollectibleTyp
101
101
  * ```
102
102
  */
103
103
  export declare function getCollectibleName(collectibleType: CollectibleType): string;
104
+ /**
105
+ * Helper function to get the "pedestal type" of a collectible. For example, it might be sitting on
106
+ * top of a broken Blood Donation Machine, or it might be sitting on top of an opened Spiked Chest.
107
+ */
104
108
  export declare function getCollectiblePedestalType(collectible: EntityPickup): CollectiblePedestalType;
105
109
  /**
106
- * Helper function to get the path to a collectible's quality. Returns 0 if the provided collectible
107
- * type was not valid.
110
+ * Helper function to get a collectible's quality. For example, Mom's Knife has a quality of 4.
111
+ * Returns 0 if the provided collectible type was not valid.
108
112
  */
109
113
  export declare function getCollectibleQuality(collectibleType: CollectibleType): int;
110
114
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"collectibles.d.ts","sourceRoot":"","sources":["../../src/functions/collectibles.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,eAAe,EAEf,aAAa,EAEb,QAAQ,EACR,WAAW,EAGZ,MAAM,8BAA8B,CAAC;AAkBtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAyB7D,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAEtE;AAED,6FAA6F;AAC7F,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAsBT;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,eAAe,GAC/B,MAAM,CAeR;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,eAAe,EAAE,eAAe,GAC/B,GAAG,CAYL;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,eAAe,EAChC,M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,EAAE,eAAe,GAClC,IAAI,CA2BN;AAED;;;GAGG;AACH,wBAAgB,qCAAqC,IAAI,IAAI,CAK5D"}
@@ -294,6 +294,8 @@ function ____exports.getCollectibleName(self, collectibleType)
294
294
  end
295
295
  return DEFAULT_COLLECTIBLE_NAME
296
296
  end
297
+ --- Helper function to get the "pedestal type" of a collectible. For example, it might be sitting on
298
+ -- top of a broken Blood Donation Machine, or it might be sitting on top of an opened Spiked Chest.
297
299
  function ____exports.getCollectiblePedestalType(self, collectible)
298
300
  if not isCollectible(nil, collectible) then
299
301
  local entityID = getEntityID(nil, collectible)
@@ -302,8 +304,8 @@ function ____exports.getCollectiblePedestalType(self, collectible)
302
304
  local sprite = collectible:GetSprite()
303
305
  return sprite:GetOverlayFrame()
304
306
  end
305
- --- Helper function to get the path to a collectible's quality. Returns 0 if the provided collectible
306
- -- type was not valid.
307
+ --- Helper function to get a collectible's quality. For example, Mom's Knife has a quality of 4.
308
+ -- Returns 0 if the provided collectible type was not valid.
307
309
  function ____exports.getCollectibleQuality(self, collectibleType)
308
310
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
309
311
  if itemConfigItem == nil then
@@ -0,0 +1,10 @@
1
+ import { CollectibleType, ItemPoolType } from "isaac-typescript-definitions";
2
+ /**
3
+ * Helper function to see if the given collectible is still present in the given item pool.
4
+ *
5
+ * If the collectible is non-offensive, any Tainted Losts will be temporarily changed to Isaac and
6
+ * then changed back. (This is because Tainted Lost is not able to retrieve non-offensive
7
+ * collectibles from item pools).
8
+ */
9
+ export declare function isCollectibleInItemPool(collectibleType: CollectibleType, itemPoolType: ItemPoolType): boolean;
10
+ //# sourceMappingURL=itemPool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"itemPool.d.ts","sourceRoot":"","sources":["../../src/functions/itemPool.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,YAAY,EAGb,MAAM,8BAA8B,CAAC;AAoBtC;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,GACzB,OAAO,CAsDT"}
@@ -0,0 +1,116 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Map = ____lualib.Map
3
+ local __TS__Iterator = ____lualib.__TS__Iterator
4
+ local __TS__New = ____lualib.__TS__New
5
+ local ____exports = {}
6
+ local removeItemsAndTrinketsThatAffectItemPools, restoreItemsAndTrinketsThatAffectItemPools, COLLECTIBLES_THAT_AFFECT_ITEM_POOLS, TRINKETS_THAT_AFFECT_ITEM_POOLS
7
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
8
+ local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
9
+ local ItemConfigTag = ____isaac_2Dtypescript_2Ddefinitions.ItemConfigTag
10
+ local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
11
+ local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
12
+ local ____cachedClasses = require("cachedClasses")
13
+ local game = ____cachedClasses.game
14
+ local ____collectibleSet = require("functions.collectibleSet")
15
+ local getCollectibleSet = ____collectibleSet.getCollectibleSet
16
+ local ____collectibleTag = require("functions.collectibleTag")
17
+ local collectibleHasTag = ____collectibleTag.collectibleHasTag
18
+ local ____playerDataStructures = require("functions.playerDataStructures")
19
+ local mapGetPlayer = ____playerDataStructures.mapGetPlayer
20
+ local mapSetPlayer = ____playerDataStructures.mapSetPlayer
21
+ local ____playerIndex = require("functions.playerIndex")
22
+ local getPlayers = ____playerIndex.getPlayers
23
+ local ____players = require("functions.players")
24
+ local getPlayersOfType = ____players.getPlayersOfType
25
+ local ____utils = require("functions.utils")
26
+ local ____repeat = ____utils["repeat"]
27
+ function removeItemsAndTrinketsThatAffectItemPools(self)
28
+ local removedItemsMap = __TS__New(Map)
29
+ local removedTrinketsMap = __TS__New(Map)
30
+ for ____, player in ipairs(getPlayers(nil)) do
31
+ local removedItems = {}
32
+ for ____, itemToRemove in ipairs(COLLECTIBLES_THAT_AFFECT_ITEM_POOLS) do
33
+ if player:HasCollectible(itemToRemove) then
34
+ local numCollectibles = player:GetCollectibleNum(itemToRemove)
35
+ ____repeat(
36
+ nil,
37
+ numCollectibles,
38
+ function()
39
+ player:RemoveCollectible(itemToRemove)
40
+ removedItems[#removedItems + 1] = itemToRemove
41
+ end
42
+ )
43
+ end
44
+ end
45
+ mapSetPlayer(nil, removedItemsMap, player, removedItems)
46
+ local removedTrinkets = {}
47
+ for ____, trinketToRemove in ipairs(TRINKETS_THAT_AFFECT_ITEM_POOLS) do
48
+ if player:HasTrinket(trinketToRemove) then
49
+ local numTrinkets = player:GetTrinketMultiplier(trinketToRemove)
50
+ ____repeat(
51
+ nil,
52
+ numTrinkets,
53
+ function()
54
+ player:TryRemoveTrinket(trinketToRemove)
55
+ removedTrinkets[#removedTrinkets + 1] = trinketToRemove
56
+ end
57
+ )
58
+ end
59
+ end
60
+ mapSetPlayer(nil, removedTrinketsMap, player, removedTrinkets)
61
+ end
62
+ return {removedItemsMap, removedTrinketsMap}
63
+ end
64
+ function restoreItemsAndTrinketsThatAffectItemPools(self, removedItemsMap, removedTrinketsMap)
65
+ for ____, player in ipairs(getPlayers(nil)) do
66
+ local removedItems = mapGetPlayer(nil, removedItemsMap, player)
67
+ if removedItems ~= nil then
68
+ for ____, collectibleType in ipairs(removedItems) do
69
+ player:AddCollectible(collectibleType, 0, false)
70
+ end
71
+ end
72
+ local removedTrinkets = mapGetPlayer(nil, removedTrinketsMap, player)
73
+ if removedTrinkets ~= nil then
74
+ for ____, trinketType in ipairs(removedTrinkets) do
75
+ player:AddTrinket(trinketType, false)
76
+ end
77
+ end
78
+ end
79
+ end
80
+ COLLECTIBLES_THAT_AFFECT_ITEM_POOLS = {CollectibleType.CHAOS, CollectibleType.SACRED_ORB, CollectibleType.TMTRAINER}
81
+ TRINKETS_THAT_AFFECT_ITEM_POOLS = {TrinketType.NO}
82
+ --- Helper function to see if the given collectible is still present in the given item pool.
83
+ --
84
+ -- If the collectible is non-offensive, any Tainted Losts will be temporarily changed to Isaac and
85
+ -- then changed back. (This is because Tainted Lost is not able to retrieve non-offensive
86
+ -- collectibles from item pools).
87
+ function ____exports.isCollectibleInItemPool(self, collectibleType, itemPoolType)
88
+ local taintedLosts = getPlayersOfType(nil, PlayerType.THE_LOST_B)
89
+ local isOffensive = collectibleHasTag(nil, collectibleType, ItemConfigTag.OFFENSIVE)
90
+ local changedPlayerTypes = false
91
+ if not isOffensive then
92
+ changedPlayerTypes = true
93
+ for ____, player in ipairs(taintedLosts) do
94
+ player:ChangePlayerType(PlayerType.ISAAC)
95
+ end
96
+ end
97
+ local removedItemsMap, removedTrinketsMap = table.unpack(removeItemsAndTrinketsThatAffectItemPools(nil))
98
+ local itemPool = game:GetItemPool()
99
+ local collectibleSet = getCollectibleSet(nil)
100
+ for ____, collectibleTypeInSet in __TS__Iterator(collectibleSet:values()) do
101
+ if collectibleTypeInSet ~= collectibleType then
102
+ itemPool:AddRoomBlacklist(collectibleTypeInSet)
103
+ end
104
+ end
105
+ local retrievedCollectibleType = itemPool:GetCollectible(itemPoolType, false, 1)
106
+ local collectibleUnlocked = retrievedCollectibleType == collectibleType
107
+ itemPool:ResetRoomBlacklist()
108
+ restoreItemsAndTrinketsThatAffectItemPools(nil, removedItemsMap, removedTrinketsMap)
109
+ if changedPlayerTypes then
110
+ for ____, player in ipairs(taintedLosts) do
111
+ player:ChangePlayerType(PlayerType.THE_LOST_B)
112
+ end
113
+ end
114
+ return collectibleUnlocked
115
+ end
116
+ return ____exports
@@ -9,10 +9,6 @@ import { RockAltType } from "../enums/RockAltType";
9
9
  * Note that most of the time, this function will do nothing, similar to how most of the time, when
10
10
  * an individual urn is destroyed, nothing will spawn.
11
11
  *
12
- * For the purposes of spawning collectibles, this function assumes that the player has not seen the
13
- * collectible yet in the current run. In vanilla, it is only possible to get a e.g. Quarter if the
14
- * collectible still exists in the Treasure Room pool.
15
- *
16
12
  * The logic in this function is based on the rewards listed on the wiki:
17
13
  * https://bindingofisaacrebirth.fandom.com/wiki/Rocks
18
14
  *
@@ -1 +1 @@
1
- {"version":3,"file":"rockAlt.d.ts","sourceRoot":"","sources":["../../src/functions/rockAlt.ts"],"names":[],"mappings":";;;AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAQnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,WAAW,EACxB,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,OAAO,CA4ET"}
1
+ {"version":3,"file":"rockAlt.d.ts","sourceRoot":"","sources":["../../src/functions/rockAlt.ts"],"names":[],"mappings":";;;AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAgBnD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,WAAW,EACxB,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,OAAO,CAwBT"}
@@ -1,14 +1,32 @@
1
1
  local ____exports = {}
2
+ local spawnRockAltRewardUrn, spawnRockAltRewardMushroom, spawnRockAltRewardSkull, spawnRockAltRewardPolyp, spawnRockAltRewardBucket
2
3
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
4
+ local Card = ____isaac_2Dtypescript_2Ddefinitions.Card
3
5
  local CoinSubType = ____isaac_2Dtypescript_2Ddefinitions.CoinSubType
4
6
  local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
7
+ local EffectVariant = ____isaac_2Dtypescript_2Ddefinitions.EffectVariant
8
+ local EntityType = ____isaac_2Dtypescript_2Ddefinitions.EntityType
9
+ local HeartSubType = ____isaac_2Dtypescript_2Ddefinitions.HeartSubType
10
+ local ItemPoolType = ____isaac_2Dtypescript_2Ddefinitions.ItemPoolType
11
+ local PillColor = ____isaac_2Dtypescript_2Ddefinitions.PillColor
12
+ local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
5
13
  local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
14
+ local ____cachedClasses = require("cachedClasses")
15
+ local game = ____cachedClasses.game
6
16
  local ____constants = require("constants")
7
17
  local DISTANCE_OF_GRID_TILE = ____constants.DISTANCE_OF_GRID_TILE
8
18
  local ____RockAltType = require("enums.RockAltType")
9
19
  local RockAltType = ____RockAltType.RockAltType
20
+ local ____entitiesSpecific = require("functions.entitiesSpecific")
21
+ local spawnEffectWithSeed = ____entitiesSpecific.spawnEffectWithSeed
22
+ local spawnNPCWithSeed = ____entitiesSpecific.spawnNPCWithSeed
23
+ local ____itemPool = require("functions.itemPool")
24
+ local isCollectibleInItemPool = ____itemPool.isCollectibleInItemPool
10
25
  local ____pickupsSpecific = require("functions.pickupsSpecific")
26
+ local spawnCardWithSeed = ____pickupsSpecific.spawnCardWithSeed
11
27
  local spawnCoinWithSeed = ____pickupsSpecific.spawnCoinWithSeed
28
+ local spawnHeartWithSeed = ____pickupsSpecific.spawnHeartWithSeed
29
+ local spawnPillWithSeed = ____pickupsSpecific.spawnPillWithSeed
12
30
  local spawnTrinketWithSeed = ____pickupsSpecific.spawnTrinketWithSeed
13
31
  local ____random = require("functions.random")
14
32
  local getRandom = ____random.getRandom
@@ -22,16 +40,199 @@ local ____utils = require("functions.utils")
22
40
  local ____repeat = ____utils["repeat"]
23
41
  local ____vector = require("functions.vector")
24
42
  local getRandomVector = ____vector.getRandomVector
43
+ function spawnRockAltRewardUrn(self, position, rng)
44
+ local chance = getRandom(nil, rng)
45
+ local totalChance = 0
46
+ totalChance = totalChance + 0.68
47
+ if chance < totalChance then
48
+ return false
49
+ end
50
+ totalChance = totalChance + 0.0944
51
+ if chance < totalChance then
52
+ local numCoinsChance = getRandom(nil, rng)
53
+ local numCoins = numCoinsChance < 0.5 and 1 or 2
54
+ local length = DISTANCE_OF_GRID_TILE
55
+ ____repeat(
56
+ nil,
57
+ numCoins,
58
+ function()
59
+ local randomVector = getRandomVector(nil, rng)
60
+ local velocity = randomVector * length
61
+ spawnCoinWithSeed(
62
+ nil,
63
+ CoinSubType.NULL,
64
+ position,
65
+ rng,
66
+ velocity
67
+ )
68
+ end
69
+ )
70
+ return true
71
+ end
72
+ totalChance = totalChance + 0.025
73
+ if chance < totalChance then
74
+ spawnTrinketWithSeed(nil, TrinketType.SWALLOWED_PENNY, position, rng)
75
+ return true
76
+ end
77
+ totalChance = totalChance + 0.005
78
+ if chance < totalChance then
79
+ local stillInPools = isCollectibleInItemPool(nil, CollectibleType.QUARTER, ItemPoolType.DEVIL)
80
+ if stillInPools then
81
+ spawnCollectible(nil, CollectibleType.QUARTER, position, rng)
82
+ return true
83
+ end
84
+ return false
85
+ end
86
+ local numSpidersChance = getRandom(nil, rng)
87
+ local numSpiders = numSpidersChance < 0.5 and 1 or 2
88
+ local length = DISTANCE_OF_GRID_TILE * 3
89
+ ____repeat(
90
+ nil,
91
+ numSpiders,
92
+ function()
93
+ local randomVector = getRandomVector(nil, rng)
94
+ local offset = randomVector * length
95
+ local targetPos = position + offset
96
+ EntityNPC.ThrowSpider(
97
+ position,
98
+ nil,
99
+ targetPos,
100
+ false,
101
+ 0
102
+ )
103
+ end
104
+ )
105
+ return true
106
+ end
107
+ function spawnRockAltRewardMushroom(self, position, rng)
108
+ local room = game:GetRoom()
109
+ local roomType = room:GetType()
110
+ local chance = getRandom(nil, rng)
111
+ local totalChance = 0
112
+ totalChance = totalChance + 0.68
113
+ if chance < totalChance then
114
+ return false
115
+ end
116
+ totalChance = totalChance + 0.0982
117
+ if chance < totalChance then
118
+ spawnPillWithSeed(nil, PillColor.NULL, position, rng)
119
+ return true
120
+ end
121
+ totalChance = totalChance + 0.025
122
+ if chance < totalChance then
123
+ spawnTrinketWithSeed(nil, TrinketType.LIBERTY_CAP, position, rng)
124
+ return true
125
+ end
126
+ totalChance = totalChance + 0.005
127
+ if chance < totalChance then
128
+ if roomType == RoomType.SECRET then
129
+ local wavyCapChance = getRandom(nil, rng)
130
+ if wavyCapChance < 0.0272 then
131
+ local stillInPools = isCollectibleInItemPool(nil, CollectibleType.WAVY_CAP, ItemPoolType.SECRET)
132
+ if stillInPools then
133
+ spawnCollectible(nil, CollectibleType.WAVY_CAP, position, rng)
134
+ return true
135
+ end
136
+ end
137
+ end
138
+ local magicMushroomStillInPools = isCollectibleInItemPool(nil, CollectibleType.MAGIC_MUSHROOM, ItemPoolType.TREASURE)
139
+ local miniMushStillInPools = isCollectibleInItemPool(nil, CollectibleType.MINI_MUSH, ItemPoolType.TREASURE)
140
+ if magicMushroomStillInPools and miniMushStillInPools then
141
+ local collectibleChance = getRandom(nil, rng)
142
+ local collectibleType = collectibleChance < 0.5 and CollectibleType.MAGIC_MUSHROOM or CollectibleType.MINI_MUSH
143
+ spawnCollectible(nil, collectibleType, position, rng)
144
+ return true
145
+ end
146
+ if magicMushroomStillInPools then
147
+ spawnCollectible(nil, CollectibleType.MINI_MUSH, position, rng)
148
+ return true
149
+ end
150
+ if miniMushStillInPools then
151
+ spawnCollectible(nil, CollectibleType.MAGIC_MUSHROOM, position, rng)
152
+ return true
153
+ end
154
+ return false
155
+ end
156
+ spawnEffectWithSeed(
157
+ nil,
158
+ EffectVariant.FART,
159
+ 0,
160
+ position,
161
+ rng
162
+ )
163
+ return true
164
+ end
165
+ function spawnRockAltRewardSkull(self, position, rng)
166
+ local chance = getRandom(nil, rng)
167
+ local totalChance = 0
168
+ totalChance = totalChance + 0.68
169
+ if chance < totalChance then
170
+ return false
171
+ end
172
+ totalChance = totalChance + 0.095
173
+ if chance < totalChance then
174
+ spawnCardWithSeed(nil, Card.NULL, position, rng)
175
+ return true
176
+ end
177
+ totalChance = totalChance + 0.025
178
+ if chance < totalChance then
179
+ spawnHeartWithSeed(nil, HeartSubType.BLACK, position, rng)
180
+ return true
181
+ end
182
+ totalChance = totalChance + 0.005
183
+ if chance < totalChance then
184
+ local ghostBabyStillInPools = isCollectibleInItemPool(nil, CollectibleType.GHOST_BABY, ItemPoolType.TREASURE)
185
+ local dryBabyStillInPools = isCollectibleInItemPool(nil, CollectibleType.DRY_BABY, ItemPoolType.TREASURE)
186
+ if ghostBabyStillInPools and dryBabyStillInPools then
187
+ local collectibleChance = getRandom(nil, rng)
188
+ local collectibleType = collectibleChance < 0.5 and CollectibleType.GHOST_BABY or CollectibleType.DRY_BABY
189
+ spawnCollectible(nil, collectibleType, position, rng)
190
+ return true
191
+ end
192
+ if ghostBabyStillInPools then
193
+ spawnCollectible(nil, CollectibleType.DRY_BABY, position, rng)
194
+ return true
195
+ end
196
+ if dryBabyStillInPools then
197
+ spawnCollectible(nil, CollectibleType.GHOST_BABY, position, rng)
198
+ return true
199
+ end
200
+ return false
201
+ end
202
+ spawnNPCWithSeed(
203
+ nil,
204
+ EntityType.HOST,
205
+ 0,
206
+ 0,
207
+ position,
208
+ rng
209
+ )
210
+ return true
211
+ end
212
+ function spawnRockAltRewardPolyp(self, _position, rng)
213
+ local chance = getRandom(nil, rng)
214
+ local totalChance = 0
215
+ totalChance = totalChance + 0.68
216
+ if chance < totalChance then
217
+ return false
218
+ end
219
+ return false
220
+ end
221
+ function spawnRockAltRewardBucket(self, _position, rng)
222
+ local chance = getRandom(nil, rng)
223
+ local totalChance = 0
224
+ totalChance = totalChance + 0.68
225
+ if chance < totalChance then
226
+ return false
227
+ end
228
+ return false
229
+ end
25
230
  --- Helper function for emulating what happens when a vanilla `GridEntityType.ROCK_ALT` grid entity
26
231
  -- breaks.
27
232
  --
28
233
  -- Note that most of the time, this function will do nothing, similar to how most of the time, when
29
234
  -- an individual urn is destroyed, nothing will spawn.
30
235
  --
31
- -- For the purposes of spawning collectibles, this function assumes that the player has not seen the
32
- -- collectible yet in the current run. In vanilla, it is only possible to get a e.g. Quarter if the
33
- -- collectible still exists in the Treasure Room pool.
34
- --
35
236
  -- The logic in this function is based on the rewards listed on the wiki:
36
237
  -- https://bindingofisaacrebirth.fandom.com/wiki/Rocks
37
238
  --
@@ -47,92 +248,36 @@ function ____exports.spawnRockAltReward(self, position, rockAltType, seedOrRNG)
47
248
  seedOrRNG = getRandomSeed(nil)
48
249
  end
49
250
  local rng = isRNG(nil, seedOrRNG) and seedOrRNG or newRNG(nil, seedOrRNG)
50
- local chance = getRandom(nil, rng)
51
251
  repeat
52
252
  local ____switch3 = rockAltType
53
253
  local ____cond3 = ____switch3 == RockAltType.URN
54
254
  if ____cond3 then
55
255
  do
56
- local totalChance = 0
57
- totalChance = totalChance + 0.68
58
- if chance < totalChance then
59
- return false
60
- end
61
- totalChance = totalChance + 0.0944
62
- if chance < totalChance then
63
- local numCoinsChance = getRandom(nil, rng)
64
- local numCoins = numCoinsChance < 0.5 and 1 or 2
65
- ____repeat(
66
- nil,
67
- numCoins,
68
- function()
69
- local velocity = getRandomVector(nil, rng)
70
- spawnCoinWithSeed(
71
- nil,
72
- CoinSubType.NULL,
73
- position,
74
- rng,
75
- velocity
76
- )
77
- end
78
- )
79
- return true
80
- end
81
- totalChance = totalChance + 0.025
82
- if chance < totalChance then
83
- spawnTrinketWithSeed(nil, TrinketType.SWALLOWED_PENNY, position, rng)
84
- end
85
- totalChance = totalChance + 0.005
86
- if chance < totalChance then
87
- spawnCollectible(nil, CollectibleType.QUARTER, position, rng)
88
- end
89
- totalChance = totalChance + 0.1948
90
- if chance < totalChance then
91
- local numSpidersChance = getRandom(nil, rng)
92
- local numSpiders = numSpidersChance < 0.5 and 1 or 2
93
- ____repeat(
94
- nil,
95
- numSpiders,
96
- function()
97
- local randomVector = getRandomVector(nil, rng)
98
- local length = DISTANCE_OF_GRID_TILE * 3
99
- local offset = randomVector * length
100
- local targetPos = position + offset
101
- EntityNPC.ThrowSpider(
102
- position,
103
- nil,
104
- targetPos,
105
- false,
106
- 0
107
- )
108
- end
109
- )
110
- end
111
- return false
256
+ return spawnRockAltRewardUrn(nil, position, rng)
112
257
  end
113
258
  end
114
259
  ____cond3 = ____cond3 or ____switch3 == RockAltType.MUSHROOM
115
260
  if ____cond3 then
116
261
  do
117
- return false
262
+ return spawnRockAltRewardMushroom(nil, position, rng)
118
263
  end
119
264
  end
120
265
  ____cond3 = ____cond3 or ____switch3 == RockAltType.SKULL
121
266
  if ____cond3 then
122
267
  do
123
- return false
268
+ return spawnRockAltRewardSkull(nil, position, rng)
124
269
  end
125
270
  end
126
271
  ____cond3 = ____cond3 or ____switch3 == RockAltType.POLYP
127
272
  if ____cond3 then
128
273
  do
129
- return false
274
+ return spawnRockAltRewardPolyp(nil, position, rng)
130
275
  end
131
276
  end
132
277
  ____cond3 = ____cond3 or ____switch3 == RockAltType.BUCKET
133
278
  if ____cond3 then
134
279
  do
135
- return false
280
+ return spawnRockAltRewardBucket(nil, position, rng)
136
281
  end
137
282
  end
138
283
  until true
@@ -1,16 +1,17 @@
1
1
  import { CollectibleType, ItemPoolType } from "isaac-typescript-definitions";
2
2
  /**
3
- * Helper function to see if the given collectible is unlocked on the player's save file. This
3
+ * Helper function to see if the given collectible is unlocked on the current save file. This
4
4
  * requires providing the corresponding item pool that the collectible is located in.
5
5
  *
6
- * - If any player currently has the item, then it is assumed to be unlocked. (This is because Eden
7
- * may have randomly started with the provided collectible, and it will be subsequently removed
8
- * from all pools.)
6
+ * - If any player currently has the collectible, then it is assumed to be unlocked. (This is
7
+ * because in almost all cases, when a collectible is added to a player's inventory, it is
8
+ * subsequently removed from all pools.)
9
9
  * - If the collectible is located in more than one item pool, then any item pool can be provided.
10
10
  * - If the collectible is not located in any item pools, then this function will always return
11
11
  * false.
12
- * - If any player is Tainted Lost, they will be temporarily changed to Isaac and then temporarily
13
- * changed back (because Tainted Lost is not able to retrieve some collectibles from item pools).
12
+ * - If the collectible is non-offensive, any Tainted Losts will be temporarily changed to Isaac and
13
+ * then changed back. (This is because Tainted Lost is not able to retrieve non-offensive
14
+ * collectibles from item pools).
14
15
  */
15
- export declare function isCollectibleUnlocked(collectibleTypeToCheckFor: CollectibleType, itemPoolToCheckFor: ItemPoolType): boolean;
16
+ export declare function isCollectibleUnlocked(collectibleType: CollectibleType, itemPoolType: ItemPoolType): boolean;
16
17
  //# sourceMappingURL=saveFile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"saveFile.d.ts","sourceRoot":"","sources":["../../src/functions/saveFile.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,YAAY,EAGb,MAAM,8BAA8B,CAAC;AAmBtC;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,yBAAyB,EAAE,eAAe,EAC1C,kBAAkB,EAAE,YAAY,GAC/B,OAAO,CA4FT"}
1
+ {"version":3,"file":"saveFile.d.ts","sourceRoot":"","sources":["../../src/functions/saveFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG7E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,GACzB,OAAO,CAMT"}