isaacscript-common 3.12.0 → 3.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.
- package/callbacks/postDiceRoomActivated.lua +6 -4
- package/constants.d.ts +2 -4
- package/constants.lua +0 -2
- package/functions/ambush.d.ts +7 -0
- package/functions/ambush.lua +50 -0
- package/functions/collectibles.d.ts +5 -0
- package/functions/collectibles.lua +50 -30
- package/functions/effects.d.ts +6 -0
- package/functions/effects.lua +12 -0
- package/index.d.ts +2 -0
- package/index.lua +16 -0
- package/package.json +1 -1
|
@@ -3,10 +3,10 @@ local hasSubscriptions, postEffectUpdateDiceFloor, v
|
|
|
3
3
|
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
4
4
|
local EffectVariant = ____isaac_2Dtypescript_2Ddefinitions.EffectVariant
|
|
5
5
|
local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
|
|
6
|
-
local ____constants = require("constants")
|
|
7
|
-
local DICE_FLOOR_TRIGGER_DISTANCE = ____constants.DICE_FLOOR_TRIGGER_DISTANCE
|
|
8
6
|
local ____exports = require("features.saveDataManager.exports")
|
|
9
7
|
local saveDataManager = ____exports.saveDataManager
|
|
8
|
+
local ____effects = require("functions.effects")
|
|
9
|
+
local isCloseEnoughToTriggerDiceFloor = ____effects.isCloseEnoughToTriggerDiceFloor
|
|
10
10
|
local ____player = require("functions.player")
|
|
11
11
|
local getClosestPlayer = ____player.getClosestPlayer
|
|
12
12
|
local ____postDiceRoomActivated = require("callbacks.subscriptions.postDiceRoomActivated")
|
|
@@ -22,9 +22,11 @@ function postEffectUpdateDiceFloor(self, effect)
|
|
|
22
22
|
if v.room.diceRoomActivated then
|
|
23
23
|
return
|
|
24
24
|
end
|
|
25
|
+
if effect.FrameCount == 0 then
|
|
26
|
+
return
|
|
27
|
+
end
|
|
25
28
|
local closestPlayer = getClosestPlayer(nil, effect.Position)
|
|
26
|
-
|
|
27
|
-
if distance <= DICE_FLOOR_TRIGGER_DISTANCE then
|
|
29
|
+
if isCloseEnoughToTriggerDiceFloor(nil, closestPlayer, effect) then
|
|
28
30
|
v.room.diceRoomActivated = true
|
|
29
31
|
postDiceRoomActivatedFire(nil, closestPlayer, effect.SubType)
|
|
30
32
|
end
|
package/constants.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Constants
|
|
3
3
|
*/
|
|
4
|
-
import { ItemPoolType, LevelStage, RoomType } from "isaac-typescript-definitions";
|
|
4
|
+
import { CollectibleType, ItemPoolType, LevelStage, RoomType } from "isaac-typescript-definitions";
|
|
5
5
|
/**
|
|
6
6
|
* The distance of the laser when Azazel does not have any range up items yet. For more info, see
|
|
7
7
|
* the documentation for the `getAzazelBrimstoneDistance` function.
|
|
@@ -15,8 +15,6 @@ export declare const BLIND_ITEM_PNG_PATH = "gfx/items/collectibles/questionmark.
|
|
|
15
15
|
/** Bombs explode when their frame count is equal to this value. */
|
|
16
16
|
export declare const BOMB_EXPLODE_FRAME = 45;
|
|
17
17
|
export declare const DEFAULT_ITEM_POOL_TYPE = ItemPoolType.TREASURE;
|
|
18
|
-
/** For `EntityType.EFFECT` (1000), `EffectVariant.DICE_FLOOR` (76) */
|
|
19
|
-
export declare const DICE_FLOOR_TRIGGER_DISTANCE = 75;
|
|
20
18
|
/** This is also the distance that a player spawns from the door that they enter a room from. */
|
|
21
19
|
export declare const DISTANCE_OF_GRID_TILE = 40;
|
|
22
20
|
export declare const DOOR_HITBOX_RADIUS = 11;
|
|
@@ -36,7 +34,7 @@ export declare const EMPTY_PNG_PATH = "gfx/none.png";
|
|
|
36
34
|
* encountered by the player. The first TMTRAINER item takes the final possible 32 bit number. The
|
|
37
35
|
* second TMTRAINER item subtracts one from that, and so on.
|
|
38
36
|
*/
|
|
39
|
-
export declare const FIRST_GLITCHED_COLLECTIBLE_TYPE:
|
|
37
|
+
export declare const FIRST_GLITCHED_COLLECTIBLE_TYPE: CollectibleType;
|
|
40
38
|
export declare const GAME_FRAMES_PER_SECOND = 30;
|
|
41
39
|
export declare const GRID_INDEX_CENTER_OF_1X1_ROOM = 67;
|
|
42
40
|
export declare const ISAAC_FRAMES_PER_SECOND = 60;
|
package/constants.lua
CHANGED
|
@@ -19,8 +19,6 @@ ____exports.BLIND_ITEM_PNG_PATH = "gfx/items/collectibles/questionmark.png"
|
|
|
19
19
|
--- Bombs explode when their frame count is equal to this value.
|
|
20
20
|
____exports.BOMB_EXPLODE_FRAME = 45
|
|
21
21
|
____exports.DEFAULT_ITEM_POOL_TYPE = ItemPoolType.TREASURE
|
|
22
|
-
--- For `EntityType.EFFECT` (1000), `EffectVariant.DICE_FLOOR` (76)
|
|
23
|
-
____exports.DICE_FLOOR_TRIGGER_DISTANCE = 75
|
|
24
22
|
--- This is also the distance that a player spawns from the door that they enter a room from.
|
|
25
23
|
____exports.DISTANCE_OF_GRID_TILE = 40
|
|
26
24
|
____exports.DOOR_HITBOX_RADIUS = 11
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper function to start a Challenge Room or the Boss Rush.
|
|
3
|
+
*
|
|
4
|
+
* Specifically, this is performed by spawning a sack on top of the player, waiting a game frame,
|
|
5
|
+
* and then removing the sack and the pickups that the sack dropped.
|
|
6
|
+
*/
|
|
7
|
+
export declare function startAmbush(): void;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
3
|
+
local ____exports = {}
|
|
4
|
+
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
5
|
+
local PickupVariant = ____isaac_2Dtypescript_2Ddefinitions.PickupVariant
|
|
6
|
+
local ____runInNFrames = require("features.runInNFrames")
|
|
7
|
+
local runNextGameFrame = ____runInNFrames.runNextGameFrame
|
|
8
|
+
local ____entity = require("functions.entity")
|
|
9
|
+
local removeEntities = ____entity.removeEntities
|
|
10
|
+
local ____entitySpecific = require("functions.entitySpecific")
|
|
11
|
+
local spawnPickupWithSeed = ____entitySpecific.spawnPickupWithSeed
|
|
12
|
+
local ____pickups = require("functions.pickups")
|
|
13
|
+
local getCoins = ____pickups.getCoins
|
|
14
|
+
--- Hard-coding this makes it easier to clean up the pickups afterwards.
|
|
15
|
+
local SACK_SEED_THAT_SPAWNS_TWO_COINS = 6
|
|
16
|
+
--- Helper function to start a Challenge Room or the Boss Rush.
|
|
17
|
+
--
|
|
18
|
+
-- Specifically, this is performed by spawning a sack on top of the player, waiting a game frame,
|
|
19
|
+
-- and then removing the sack and the pickups that the sack dropped.
|
|
20
|
+
function ____exports.startAmbush(self)
|
|
21
|
+
local player = Isaac.GetPlayer()
|
|
22
|
+
local sack = spawnPickupWithSeed(
|
|
23
|
+
nil,
|
|
24
|
+
PickupVariant.SACK,
|
|
25
|
+
0,
|
|
26
|
+
player.Position,
|
|
27
|
+
SACK_SEED_THAT_SPAWNS_TWO_COINS
|
|
28
|
+
)
|
|
29
|
+
local sprite = sack:GetSprite()
|
|
30
|
+
sprite:Stop()
|
|
31
|
+
local sackPtr = EntityPtr(sack)
|
|
32
|
+
runNextGameFrame(
|
|
33
|
+
nil,
|
|
34
|
+
function()
|
|
35
|
+
local futureSack = sackPtr.Ref
|
|
36
|
+
if futureSack == nil then
|
|
37
|
+
return
|
|
38
|
+
end
|
|
39
|
+
futureSack:Remove()
|
|
40
|
+
local sackPtrHash = GetPtrHash(futureSack)
|
|
41
|
+
local coins = getCoins(nil)
|
|
42
|
+
local coinsFromSack = __TS__ArrayFilter(
|
|
43
|
+
coins,
|
|
44
|
+
function(____, pickup) return GetPtrHash(pickup) == sackPtrHash end
|
|
45
|
+
)
|
|
46
|
+
removeEntities(nil, coinsFromSack)
|
|
47
|
+
end
|
|
48
|
+
)
|
|
49
|
+
end
|
|
50
|
+
return ____exports
|
|
@@ -191,6 +191,11 @@ export declare function setCollectibleBlind(collectible: EntityPickup): void;
|
|
|
191
191
|
* For more information, see the documentation for the "clearSprite" helper function.
|
|
192
192
|
*/
|
|
193
193
|
export declare function setCollectibleEmpty(collectible: EntityPickup): void;
|
|
194
|
+
/**
|
|
195
|
+
* Helper function to change a collectible into a "glitched" item (like the ones that appear when
|
|
196
|
+
* the player has TMTRAINER).
|
|
197
|
+
*/
|
|
198
|
+
export declare function setCollectibleGlitched(collectible: EntityPickup): void;
|
|
194
199
|
/**
|
|
195
200
|
* Helper function to change the sprite of a collectible pedestal entity.
|
|
196
201
|
*
|
|
@@ -13,6 +13,7 @@ local game = ____cachedClasses.game
|
|
|
13
13
|
local itemConfig = ____cachedClasses.itemConfig
|
|
14
14
|
local ____constants = require("constants")
|
|
15
15
|
local BLIND_ITEM_PNG_PATH = ____constants.BLIND_ITEM_PNG_PATH
|
|
16
|
+
local DEFAULT_ITEM_POOL_TYPE = ____constants.DEFAULT_ITEM_POOL_TYPE
|
|
16
17
|
local ____constantsFirstLast = require("constantsFirstLast")
|
|
17
18
|
local FIRST_COLLECTIBLE_TYPE = ____constantsFirstLast.FIRST_COLLECTIBLE_TYPE
|
|
18
19
|
local FIRST_MODDED_COLLECTIBLE_TYPE = ____constantsFirstLast.FIRST_MODDED_COLLECTIBLE_TYPE
|
|
@@ -44,6 +45,22 @@ function initQuestionMarkSprite(self)
|
|
|
44
45
|
sprite:LoadGraphics()
|
|
45
46
|
return sprite
|
|
46
47
|
end
|
|
48
|
+
function ____exports.clearCollectibleSprite(self, collectible)
|
|
49
|
+
____exports.setCollectibleSprite(nil, collectible, nil)
|
|
50
|
+
end
|
|
51
|
+
--- Helper function to remove the collectible from a collectible pedestal and make it appear as if a
|
|
52
|
+
-- player has already taken the item. This is accomplished by changing the sub-type to
|
|
53
|
+
-- `CollectibleType.NULL` and then setting the sprite to an empty/missing PNG file.
|
|
54
|
+
--
|
|
55
|
+
-- For more information, see the documentation for the "clearSprite" helper function.
|
|
56
|
+
function ____exports.setCollectibleEmpty(self, collectible)
|
|
57
|
+
if not isCollectible(nil, collectible) then
|
|
58
|
+
local entityID = getEntityID(nil, collectible)
|
|
59
|
+
error("The \"setCollectibleEmpty\" function was given a non-collectible: " .. entityID)
|
|
60
|
+
end
|
|
61
|
+
collectible.SubType = CollectibleType.NULL
|
|
62
|
+
____exports.clearCollectibleSprite(nil, collectible)
|
|
63
|
+
end
|
|
47
64
|
--- Helper function to change the sprite of a collectible pedestal entity.
|
|
48
65
|
--
|
|
49
66
|
-- For more information about removing the collectible sprite, see the documentation for the
|
|
@@ -67,13 +84,30 @@ function ____exports.setCollectibleSprite(self, collectible, pngPath)
|
|
|
67
84
|
sprite:LoadGraphics()
|
|
68
85
|
end
|
|
69
86
|
end
|
|
87
|
+
--- Helper function to change the collectible on a pedestal. Simply updating the `SubType` property
|
|
88
|
+
-- is not sufficient because the sprite will not change.
|
|
89
|
+
function ____exports.setCollectibleSubType(self, collectible, newCollectibleType)
|
|
90
|
+
if not isCollectible(nil, collectible) then
|
|
91
|
+
local entityID = getEntityID(nil, collectible)
|
|
92
|
+
error("The \"setCollectibleSubType\" function was given a non-collectible: " .. entityID)
|
|
93
|
+
end
|
|
94
|
+
if newCollectibleType == CollectibleType.NULL then
|
|
95
|
+
____exports.setCollectibleEmpty(nil, collectible)
|
|
96
|
+
return
|
|
97
|
+
end
|
|
98
|
+
collectible:Morph(
|
|
99
|
+
EntityType.PICKUP,
|
|
100
|
+
PickupVariant.COLLECTIBLE,
|
|
101
|
+
newCollectibleType,
|
|
102
|
+
true,
|
|
103
|
+
true,
|
|
104
|
+
true
|
|
105
|
+
)
|
|
106
|
+
end
|
|
70
107
|
COLLECTIBLE_SPRITE_LAYER = 1
|
|
71
108
|
COLLECTIBLE_SHADOW_LAYER = 4
|
|
72
109
|
local GLITCHED_ITEM_THRESHOLD = 4000000000
|
|
73
110
|
local questionMarkSprite = initQuestionMarkSprite(nil)
|
|
74
|
-
function ____exports.clearCollectibleSprite(self, collectible)
|
|
75
|
-
____exports.setCollectibleSprite(nil, collectible, nil)
|
|
76
|
-
end
|
|
77
111
|
--- Helper function to check if two collectible sprites have the same sprite sheet loaded.
|
|
78
112
|
function ____exports.collectibleSpriteEquals(self, sprite1, sprite2)
|
|
79
113
|
local xStart = -1
|
|
@@ -384,38 +418,24 @@ function ____exports.setCollectibleBlind(self, collectible)
|
|
|
384
418
|
end
|
|
385
419
|
____exports.setCollectibleSprite(nil, collectible, BLIND_ITEM_PNG_PATH)
|
|
386
420
|
end
|
|
387
|
-
--- Helper function to
|
|
388
|
-
-- player has
|
|
389
|
-
|
|
390
|
-
--
|
|
391
|
-
-- For more information, see the documentation for the "clearSprite" helper function.
|
|
392
|
-
function ____exports.setCollectibleEmpty(self, collectible)
|
|
421
|
+
--- Helper function to change a collectible into a "glitched" item (like the ones that appear when
|
|
422
|
+
-- the player has TMTRAINER).
|
|
423
|
+
function ____exports.setCollectibleGlitched(self, collectible)
|
|
393
424
|
if not isCollectible(nil, collectible) then
|
|
394
425
|
local entityID = getEntityID(nil, collectible)
|
|
395
|
-
error("The \"
|
|
426
|
+
error("The \"setCollectibleGlitched\" function was given a non-collectible: " .. entityID)
|
|
396
427
|
end
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
-- is not sufficient because the sprite will not change.
|
|
402
|
-
function ____exports.setCollectibleSubType(self, collectible, newCollectibleType)
|
|
403
|
-
if not isCollectible(nil, collectible) then
|
|
404
|
-
local entityID = getEntityID(nil, collectible)
|
|
405
|
-
error("The \"setCollectibleSubType\" function was given a non-collectible: " .. entityID)
|
|
428
|
+
local player = Isaac.GetPlayer()
|
|
429
|
+
local hasTMTRAINER = player:HasCollectible(CollectibleType.TMTRAINER)
|
|
430
|
+
if not hasTMTRAINER then
|
|
431
|
+
player:AddCollectible(CollectibleType.TMTRAINER, 0, false)
|
|
406
432
|
end
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
433
|
+
local itemPool = game:GetItemPool()
|
|
434
|
+
local collectibleType = itemPool:GetCollectible(DEFAULT_ITEM_POOL_TYPE)
|
|
435
|
+
____exports.setCollectibleSubType(nil, collectible, collectibleType)
|
|
436
|
+
if not hasTMTRAINER then
|
|
437
|
+
player:RemoveCollectible(CollectibleType.TMTRAINER)
|
|
410
438
|
end
|
|
411
|
-
collectible:Morph(
|
|
412
|
-
EntityType.PICKUP,
|
|
413
|
-
PickupVariant.COLLECTIBLE,
|
|
414
|
-
newCollectibleType,
|
|
415
|
-
true,
|
|
416
|
-
true,
|
|
417
|
-
true
|
|
418
|
-
)
|
|
419
439
|
end
|
|
420
440
|
--- Helper function to put a message in the log.txt file to let the Rebirth Item Tracker know that
|
|
421
441
|
-- the build has been rerolled.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/** For `EntityType.EFFECT` (1000), `EffectVariant.DICE_FLOOR` (76) */
|
|
4
|
+
export declare const DICE_FLOOR_TRIGGER_SQUARE_SIZE = 75;
|
|
5
|
+
/** Helper function to see if a player is close enough to activate a Dice Room floor. */
|
|
6
|
+
export declare function isCloseEnoughToTriggerDiceFloor(player: EntityPlayer, diceFloor: EntityEffect): boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____math = require("functions.math")
|
|
3
|
+
local inRectangle = ____math.inRectangle
|
|
4
|
+
--- For `EntityType.EFFECT` (1000), `EffectVariant.DICE_FLOOR` (76)
|
|
5
|
+
____exports.DICE_FLOOR_TRIGGER_SQUARE_SIZE = 75
|
|
6
|
+
--- Helper function to see if a player is close enough to activate a Dice Room floor.
|
|
7
|
+
function ____exports.isCloseEnoughToTriggerDiceFloor(self, player, diceFloor)
|
|
8
|
+
local topLeft = diceFloor.Position + Vector(-____exports.DICE_FLOOR_TRIGGER_SQUARE_SIZE, -____exports.DICE_FLOOR_TRIGGER_SQUARE_SIZE)
|
|
9
|
+
local bottomRight = diceFloor.Position + Vector(____exports.DICE_FLOOR_TRIGGER_SQUARE_SIZE, ____exports.DICE_FLOOR_TRIGGER_SQUARE_SIZE)
|
|
10
|
+
return inRectangle(nil, player.Position, topLeft, bottomRight)
|
|
11
|
+
end
|
|
12
|
+
return ____exports
|
package/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export { runInNGameFrames, runInNRenderFrames, runNextGameFrame, runNextRenderFr
|
|
|
28
28
|
export * from "./features/saveDataManager/exports";
|
|
29
29
|
export { hasSirenStolenFamiliar, setFamiliarNoSirenSteal, } from "./features/sirenHelpers";
|
|
30
30
|
export { getTaintedLazarusSubPlayer } from "./features/taintedLazarusPlayers";
|
|
31
|
+
export * from "./functions/ambush";
|
|
31
32
|
export * from "./functions/array";
|
|
32
33
|
export * from "./functions/benchmark";
|
|
33
34
|
export * from "./functions/bitwise";
|
|
@@ -51,6 +52,7 @@ export * from "./functions/direction";
|
|
|
51
52
|
export * from "./functions/doors";
|
|
52
53
|
export * from "./functions/easing";
|
|
53
54
|
export * from "./functions/eden";
|
|
55
|
+
export * from "./functions/effects";
|
|
54
56
|
export * from "./functions/entity";
|
|
55
57
|
export * from "./functions/entitySpecific";
|
|
56
58
|
export * from "./functions/entityTypes";
|
package/index.lua
CHANGED
|
@@ -223,6 +223,14 @@ do
|
|
|
223
223
|
local getTaintedLazarusSubPlayer = ____taintedLazarusPlayers.getTaintedLazarusSubPlayer
|
|
224
224
|
____exports.getTaintedLazarusSubPlayer = getTaintedLazarusSubPlayer
|
|
225
225
|
end
|
|
226
|
+
do
|
|
227
|
+
local ____export = require("functions.ambush")
|
|
228
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
229
|
+
if ____exportKey ~= "default" then
|
|
230
|
+
____exports[____exportKey] = ____exportValue
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
end
|
|
226
234
|
do
|
|
227
235
|
local ____export = require("functions.array")
|
|
228
236
|
for ____exportKey, ____exportValue in pairs(____export) do
|
|
@@ -401,6 +409,14 @@ do
|
|
|
401
409
|
end
|
|
402
410
|
end
|
|
403
411
|
end
|
|
412
|
+
do
|
|
413
|
+
local ____export = require("functions.effects")
|
|
414
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
415
|
+
if ____exportKey ~= "default" then
|
|
416
|
+
____exports[____exportKey] = ____exportValue
|
|
417
|
+
end
|
|
418
|
+
end
|
|
419
|
+
end
|
|
404
420
|
do
|
|
405
421
|
local ____export = require("functions.entity")
|
|
406
422
|
for ____exportKey, ____exportValue in pairs(____export) do
|