isaacscript-common 1.0.481 → 1.0.485
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/dist/callbacks/postPlayerFatalDamage.lua +5 -1
- package/dist/features/deployJSONRoom.lua +2 -0
- package/dist/functions/entity.d.ts +46 -0
- package/dist/functions/entity.lua +46 -0
- package/dist/functions/gridEntity.d.ts +22 -1
- package/dist/functions/gridEntity.lua +13 -4
- package/dist/functions/log.d.ts +11 -14
- package/dist/functions/log.lua +3 -0
- package/dist/functions/player.d.ts +16 -0
- package/dist/functions/player.lua +69 -0
- package/dist/functions/rooms.d.ts +7 -0
- package/dist/functions/rooms.lua +18 -2
- package/package.json +1 -1
|
@@ -21,7 +21,7 @@ function entityTakeDmgPlayer(self, tookDamage, damageAmount, _damageFlags, _dama
|
|
|
21
21
|
if willPlayerRevive(nil, player) then
|
|
22
22
|
return nil
|
|
23
23
|
end
|
|
24
|
-
if (not
|
|
24
|
+
if (not damageIsFatal(nil, player, damageAmount)) and (not hasLostCurse(nil, player)) then
|
|
25
25
|
return nil
|
|
26
26
|
end
|
|
27
27
|
local shouldSustainDeath = postPlayerFatalDamage:fire(player)
|
|
@@ -31,6 +31,10 @@ function entityTakeDmgPlayer(self, tookDamage, damageAmount, _damageFlags, _dama
|
|
|
31
31
|
return nil
|
|
32
32
|
end
|
|
33
33
|
function damageIsFatal(self, player, damageAmount)
|
|
34
|
+
local character = player:GetPlayerType()
|
|
35
|
+
if character == PlayerType.PLAYER_JACOB2_B then
|
|
36
|
+
return true
|
|
37
|
+
end
|
|
34
38
|
local playerNumAllHearts = getPlayerNumAllHearts(nil, player)
|
|
35
39
|
if damageAmount < playerNumAllHearts then
|
|
36
40
|
return false
|
|
@@ -201,6 +201,8 @@ function spawnAllEntities(self, jsonRoom, seed, verbose)
|
|
|
201
201
|
log("Setting the room to be uncleared since there were one or more battle NPCs spawned.")
|
|
202
202
|
end
|
|
203
203
|
setRoomUncleared(nil)
|
|
204
|
+
elseif verbose then
|
|
205
|
+
log("Leaving the room cleared since there were no battle NPCs spawned.")
|
|
204
206
|
end
|
|
205
207
|
return seed
|
|
206
208
|
end
|
|
@@ -60,6 +60,25 @@ export declare function getEffects(matchingVariant?: number, matchingSubType?: n
|
|
|
60
60
|
* returned. False by default. Will only be taken into account if `matchingEntityType` is specified.
|
|
61
61
|
*/
|
|
62
62
|
export declare function getEntities(matchingEntityType?: EntityType | int, matchingVariant?: number, matchingSubType?: number, ignoreFriendly?: boolean): Entity[];
|
|
63
|
+
/**
|
|
64
|
+
* Helper function to get a map containing the positions of every entity in the current room.
|
|
65
|
+
*
|
|
66
|
+
* This is useful for rewinding entity positions at a later time. Also see `setEntityPositions()`.
|
|
67
|
+
*
|
|
68
|
+
* @param entities Optional. If provided, will only get the positions of the provided entities. This
|
|
69
|
+
* can be used to cache the entities to avoid invoking `Isaac.GetRoomEntities()` multiple times.
|
|
70
|
+
*/
|
|
71
|
+
export declare function getEntityPositions(entities?: Entity[]): Map<PtrHash, Vector>;
|
|
72
|
+
/**
|
|
73
|
+
* Helper function to get a map containing the velocities of every entity in the current room.
|
|
74
|
+
*
|
|
75
|
+
* This is useful for rewinding entity velocities at a later time. Also see `setEntityVelocities()`.
|
|
76
|
+
*
|
|
77
|
+
* @param entities Optional. If provided, will only get the velocities of the provided entities.
|
|
78
|
+
* This can be used to cache the entities to avoid invoking `Isaac.GetRoomEntities()` multiple
|
|
79
|
+
* times.
|
|
80
|
+
*/
|
|
81
|
+
export declare function getEntityVelocities(entities?: Entity[]): Map<PtrHash, Vector>;
|
|
63
82
|
/**
|
|
64
83
|
* Helper function to get all of the familiars in the room.
|
|
65
84
|
*
|
|
@@ -144,4 +163,31 @@ export declare function removeAllMatchingEntities(entityType: int, entityVariant
|
|
|
144
163
|
export declare function removeAllPickups(): void;
|
|
145
164
|
export declare function removeAllProjectiles(): void;
|
|
146
165
|
export declare function removeAllTears(): void;
|
|
166
|
+
/**
|
|
167
|
+
* Helper function to set the position of every entity in the room based on a map of positions. If
|
|
168
|
+
* an entity is found that does not have matching element in the provided map, then that entity will
|
|
169
|
+
* be skipped.
|
|
170
|
+
*
|
|
171
|
+
* This function is useful for rewinding entity positions at a later time. Also see
|
|
172
|
+
* `getEntityPositions()`.
|
|
173
|
+
*
|
|
174
|
+
* @param entityPositions The map providing the positions for every entity.
|
|
175
|
+
* @param entities Optional. If provided, will only set the positions of the provided entities. This
|
|
176
|
+
* can be used to cache the entities to avoid invoking `Isaac.GetRoomEntities()` multiple times.
|
|
177
|
+
*/
|
|
178
|
+
export declare function setEntityPositions(entityPositions: Map<PtrHash, Vector>, entities?: Entity[]): void;
|
|
147
179
|
export declare function setEntityRandomColor(entity: Entity): void;
|
|
180
|
+
/**
|
|
181
|
+
* Helper function to set the velocity of every entity in the room based on a map of velocities. If
|
|
182
|
+
* an entity is found that does not have matching element in the provided map, then that entity will
|
|
183
|
+
* be skipped.
|
|
184
|
+
*
|
|
185
|
+
* This function is useful for rewinding entity velocities at a later time. Also see
|
|
186
|
+
* `getEntityVelocities()`.
|
|
187
|
+
*
|
|
188
|
+
* @param entityVelocities The map providing the velocities for every entity.
|
|
189
|
+
* @param entities Optional. If provided, will only set the velocities of the provided entities.
|
|
190
|
+
* This can be used to cache the entities to avoid invoking `Isaac.GetRoomEntities()` multiple
|
|
191
|
+
* times.
|
|
192
|
+
*/
|
|
193
|
+
export declare function setEntityVelocities(entityVelocities: Map<PtrHash, Vector>, entities?: Entity[]): void;
|
|
@@ -76,6 +76,28 @@ function ____exports.getEntities(self, matchingEntityType, matchingVariant, matc
|
|
|
76
76
|
end
|
|
77
77
|
return Isaac.FindByType(matchingEntityType, matchingVariant, matchingSubType, ignoreFriendly)
|
|
78
78
|
end
|
|
79
|
+
function ____exports.getEntityPositions(self, entities)
|
|
80
|
+
if entities == nil then
|
|
81
|
+
entities = ____exports.getEntities(nil)
|
|
82
|
+
end
|
|
83
|
+
local entityPositions = __TS__New(Map)
|
|
84
|
+
for ____, entity in ipairs(entities) do
|
|
85
|
+
local ptrHash = GetPtrHash(entity)
|
|
86
|
+
entityPositions:set(ptrHash, entity.Position)
|
|
87
|
+
end
|
|
88
|
+
return entityPositions
|
|
89
|
+
end
|
|
90
|
+
function ____exports.getEntityVelocities(self, entities)
|
|
91
|
+
if entities == nil then
|
|
92
|
+
entities = ____exports.getEntities(nil)
|
|
93
|
+
end
|
|
94
|
+
local entityVelocities = __TS__New(Map)
|
|
95
|
+
for ____, entity in ipairs(entities) do
|
|
96
|
+
local ptrHash = GetPtrHash(entity)
|
|
97
|
+
entityVelocities:set(ptrHash, entity.Velocity)
|
|
98
|
+
end
|
|
99
|
+
return entityVelocities
|
|
100
|
+
end
|
|
79
101
|
function ____exports.getFamiliars(self, matchingVariant, matchingSubType)
|
|
80
102
|
if matchingVariant == nil then
|
|
81
103
|
matchingVariant = -1
|
|
@@ -251,6 +273,18 @@ function ____exports.removeAllTears(self)
|
|
|
251
273
|
tear:Remove()
|
|
252
274
|
end
|
|
253
275
|
end
|
|
276
|
+
function ____exports.setEntityPositions(self, entityPositions, entities)
|
|
277
|
+
if entities == nil then
|
|
278
|
+
entities = ____exports.getEntities(nil)
|
|
279
|
+
end
|
|
280
|
+
for ____, entity in ipairs(entities) do
|
|
281
|
+
local ptrHash = GetPtrHash(entity)
|
|
282
|
+
local entityPosition = entityPositions:get(ptrHash)
|
|
283
|
+
if entityPosition ~= nil then
|
|
284
|
+
entity.Position = entityPosition
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
end
|
|
254
288
|
function ____exports.setEntityRandomColor(self, entity)
|
|
255
289
|
local colorValues = {}
|
|
256
290
|
local seed = entity.InitSeed
|
|
@@ -266,4 +300,16 @@ function ____exports.setEntityRandomColor(self, entity)
|
|
|
266
300
|
local color = Color(colorValues[1], colorValues[2], colorValues[3])
|
|
267
301
|
entity:SetColor(color, 100000, 100000, false, false)
|
|
268
302
|
end
|
|
303
|
+
function ____exports.setEntityVelocities(self, entityVelocities, entities)
|
|
304
|
+
if entities == nil then
|
|
305
|
+
entities = ____exports.getEntities(nil)
|
|
306
|
+
end
|
|
307
|
+
for ____, entity in ipairs(entities) do
|
|
308
|
+
local ptrHash = GetPtrHash(entity)
|
|
309
|
+
local entityVelocity = entityVelocities:get(ptrHash)
|
|
310
|
+
if entityVelocity ~= nil then
|
|
311
|
+
entity.Velocity = entityVelocity
|
|
312
|
+
end
|
|
313
|
+
end
|
|
314
|
+
end
|
|
269
315
|
return ____exports
|
|
@@ -38,9 +38,30 @@ export declare function isAllPressurePlatesPushed(): boolean;
|
|
|
38
38
|
* at the VarData of the entity.)
|
|
39
39
|
*/
|
|
40
40
|
export declare function isPostBossVoidPortal(gridEntity: GridEntity): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Helper function to remove most grid entities in the room.
|
|
43
|
+
*
|
|
44
|
+
* Example:
|
|
45
|
+
* ```
|
|
46
|
+
* removeAllGridEntitiesExceptFor(
|
|
47
|
+
* GridEntityType.GRID_WALL,
|
|
48
|
+
* GridEntityType.GRID_DOOR,
|
|
49
|
+
* );
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
41
52
|
export declare function removeAllGridEntitiesExceptFor(...gridEntityTypes: GridEntityType[]): void;
|
|
42
53
|
export declare function removeAllMatchingGridEntities(gridEntityType: GridEntityType): void;
|
|
43
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Helper function to remove a grid entity simply by providing the grid entity object.
|
|
56
|
+
*
|
|
57
|
+
* @param gridEntity The grid entity to remove.
|
|
58
|
+
* @param updateRoom Optional. Whether or not to update the room after the grid entity is removed.
|
|
59
|
+
* True by default. This is generally a good idea because if the room is not updated, you will be
|
|
60
|
+
* unable to spawn another grid entity on the same tile until a frame has passed. However, doing
|
|
61
|
+
* this is expensive, since it involves a call to `Isaac.GetRoomEntities()`, so set it to false if
|
|
62
|
+
* you need to invoke this function multiple times.
|
|
63
|
+
*/
|
|
64
|
+
export declare function removeGridEntity(gridEntity: GridEntity, updateRoom?: boolean): void;
|
|
44
65
|
/**
|
|
45
66
|
* Helper function to make a grid entity invisible. This is accomplished by setting its sprite to
|
|
46
67
|
* "gfx/none.png" (a non-existent PNG file).
|
|
@@ -3,12 +3,19 @@ require("lualib_bundle");
|
|
|
3
3
|
local ____exports = {}
|
|
4
4
|
local ____constants = require("constants")
|
|
5
5
|
local GRID_ENTITY_XML_MAP = ____constants.GRID_ENTITY_XML_MAP
|
|
6
|
-
|
|
6
|
+
local ____rooms = require("functions.rooms")
|
|
7
|
+
local roomUpdateSafe = ____rooms.roomUpdateSafe
|
|
8
|
+
function ____exports.removeGridEntity(self, gridEntity, updateRoom)
|
|
9
|
+
if updateRoom == nil then
|
|
10
|
+
updateRoom = true
|
|
11
|
+
end
|
|
7
12
|
local game = Game()
|
|
8
13
|
local room = game:GetRoom()
|
|
9
14
|
local gridIndex = gridEntity:GetGridIndex()
|
|
10
15
|
room:RemoveGridEntity(gridIndex, 0, false)
|
|
11
|
-
|
|
16
|
+
if updateRoom then
|
|
17
|
+
roomUpdateSafe(nil)
|
|
18
|
+
end
|
|
12
19
|
end
|
|
13
20
|
function ____exports.spawnGridEntityWithVariant(self, gridEntityType, variant, gridIndex)
|
|
14
21
|
local game = Game()
|
|
@@ -113,15 +120,17 @@ function ____exports.removeAllGridEntitiesExceptFor(self, ...)
|
|
|
113
120
|
for ____, gridEntity in ipairs(gridEntities) do
|
|
114
121
|
local gridEntityType = gridEntity:GetType()
|
|
115
122
|
if not gridEntityTypeExceptions:has(gridEntityType) then
|
|
116
|
-
____exports.removeGridEntity(nil, gridEntity)
|
|
123
|
+
____exports.removeGridEntity(nil, gridEntity, false)
|
|
117
124
|
end
|
|
118
125
|
end
|
|
126
|
+
roomUpdateSafe(nil)
|
|
119
127
|
end
|
|
120
128
|
function ____exports.removeAllMatchingGridEntities(self, gridEntityType)
|
|
121
129
|
local gridEntities = ____exports.getGridEntities(nil, gridEntityType)
|
|
122
130
|
for ____, gridEntity in ipairs(gridEntities) do
|
|
123
|
-
____exports.removeGridEntity(nil, gridEntity)
|
|
131
|
+
____exports.removeGridEntity(nil, gridEntity, false)
|
|
124
132
|
end
|
|
133
|
+
roomUpdateSafe(nil)
|
|
125
134
|
end
|
|
126
135
|
function ____exports.setGridEntityInvisible(self, gridEntity)
|
|
127
136
|
local sprite = gridEntity:GetSprite()
|
package/dist/functions/log.d.ts
CHANGED
|
@@ -5,31 +5,28 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare function getDebugPrependString(msg: string, numParentFunctions?: number): string;
|
|
7
7
|
/**
|
|
8
|
-
* Helper function to avoid typing out `Isaac.DebugString()`.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Helper function to avoid typing out `Isaac.DebugString()`. If you have the --luadebug launch flag
|
|
9
|
+
* turned on or the Racing+ sandbox enabled, then this function will also prepend the function name
|
|
10
|
+
* and the line number before the string.
|
|
11
11
|
*/
|
|
12
12
|
export declare function log(this: void, msg: string): void;
|
|
13
|
-
/**
|
|
14
|
-
* Helper function for printing out every damage flag that is turned on. Helpful when debugging.
|
|
15
|
-
*/
|
|
13
|
+
/** Helper function for printing out every damage flag that is turned on. Helpful when debugging. */
|
|
16
14
|
export declare function logAllDamageFlags(this: void, flags: int): void;
|
|
17
|
-
/**
|
|
18
|
-
* Helper function for printing out every entity flag that is turned on. Helpful when debugging.
|
|
19
|
-
*/
|
|
15
|
+
/** Helper function for printing out every entity flag that is turned on. Helpful when debugging. */
|
|
20
16
|
export declare function logAllEntityFlags(this: void, flags: int): void;
|
|
17
|
+
/** Helper function for printing out every flag that is turned on. Helpful when debugging. */
|
|
18
|
+
export declare function logAllFlags(this: void, flags: int, flagEnum: LuaTable, description?: string): void;
|
|
21
19
|
/**
|
|
22
|
-
* Helper function for printing out every flag that is turned on. Helpful when debugging.
|
|
20
|
+
* Helper function for printing out every game state flag that is turned on. Helpful when debugging.
|
|
23
21
|
*/
|
|
24
|
-
export declare function logAllFlags(this: void, flags: int, flagEnum: LuaTable, description?: string): void;
|
|
25
22
|
export declare function logAllGameStateFlags(this: void): void;
|
|
26
23
|
/**
|
|
27
24
|
* Helper function for printing out every projectile flag that is turned on. Helpful when debugging.
|
|
28
25
|
*/
|
|
29
26
|
export declare function logAllProjectileFlags(this: void, flags: int): void;
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
*/
|
|
27
|
+
/** Helper function for printing out every use flag that is turned on. Helpful when debugging. */
|
|
28
|
+
export declare function logAllTearFlags(this: void, flags: int): void;
|
|
29
|
+
/** Helper function for printing out every use flag that is turned on. Helpful when debugging. */
|
|
33
30
|
export declare function logAllUseFlags(this: void, flags: int): void;
|
|
34
31
|
export declare function logArray<T>(this: void, array: T[]): void;
|
|
35
32
|
export declare function logColor(this: void, color: Color): void;
|
package/dist/functions/log.lua
CHANGED
|
@@ -68,6 +68,9 @@ end
|
|
|
68
68
|
function ____exports.logAllProjectileFlags(flags)
|
|
69
69
|
____exports.logAllFlags(flags, ProjectileFlags, "projectile")
|
|
70
70
|
end
|
|
71
|
+
function ____exports.logAllTearFlags(flags)
|
|
72
|
+
____exports.logAllFlags(flags, TearFlags, "tear")
|
|
73
|
+
end
|
|
71
74
|
function ____exports.logAllUseFlags(flags)
|
|
72
75
|
____exports.logAllFlags(flags, UseFlag, "use")
|
|
73
76
|
end
|
|
@@ -198,6 +198,22 @@ export declare function removeCollectibleCostume(player: EntityPlayer, collectib
|
|
|
198
198
|
*/
|
|
199
199
|
export declare function removeDeadEyeMultiplier(player: EntityPlayer): void;
|
|
200
200
|
export declare function removeTrinketCostume(player: EntityPlayer, trinketType: TrinketType | int): void;
|
|
201
|
+
/**
|
|
202
|
+
* Helper function to set an active collectible to a particular slot. This has different behavior
|
|
203
|
+
* than calling `player.AddCollectible()` with the `activeSlot` argument, because this function will
|
|
204
|
+
* not shift existing items into the Schoolbag and it handles `ActiveSlot.SLOT_POCKET2`.
|
|
205
|
+
*
|
|
206
|
+
* Note that if an item is set to `ActiveSlot.SLOT_POCKET2`, it will disappear after being used and
|
|
207
|
+
* will be automatically removed upon entering a new room.
|
|
208
|
+
*
|
|
209
|
+
* @param player The player to give the item to.
|
|
210
|
+
* @param collectibleType The collectible type of the item to give.
|
|
211
|
+
* @param activeSlot The slot to set.
|
|
212
|
+
* @param charge Optional. The argument of charges to set. If not specified, the item will be set
|
|
213
|
+
* with maximum charges.
|
|
214
|
+
* @param keepInPools Optional. Whether or not to remove the item from pools. False by default.
|
|
215
|
+
*/
|
|
216
|
+
export declare function setActiveItem(player: EntityPlayer, collectibleType: CollectibleType, activeSlot: ActiveSlot, charge?: int, keepInPools?: boolean): void;
|
|
201
217
|
/**
|
|
202
218
|
* If you want to stop the player from shooting without the blindfold costume, then simply call
|
|
203
219
|
* `player.TryRemoveNullCostume(NullItemID.ID_BLINDFOLD)` after invoking this function.
|
|
@@ -11,8 +11,12 @@ local PocketItemType = ____PocketItemType.PocketItemType
|
|
|
11
11
|
local ____bitwise = require("functions.bitwise")
|
|
12
12
|
local getKBitOfN = ____bitwise.getKBitOfN
|
|
13
13
|
local getNumBitsOfN = ____bitwise.getNumBitsOfN
|
|
14
|
+
local ____collectibles = require("functions.collectibles")
|
|
15
|
+
local getCollectibleMaxCharges = ____collectibles.getCollectibleMaxCharges
|
|
14
16
|
local ____collectibleSet = require("functions.collectibleSet")
|
|
15
17
|
local getCollectibleSet = ____collectibleSet.getCollectibleSet
|
|
18
|
+
local ____util = require("functions.util")
|
|
19
|
+
local ensureAllCases = ____util.ensureAllCases
|
|
16
20
|
function ____exports.getPlayers(self, performExclusions)
|
|
17
21
|
if performExclusions == nil then
|
|
18
22
|
performExclusions = false
|
|
@@ -436,6 +440,71 @@ function ____exports.removeTrinketCostume(self, player, trinketType)
|
|
|
436
440
|
end
|
|
437
441
|
player:RemoveCostume(itemConfigTrinket)
|
|
438
442
|
end
|
|
443
|
+
function ____exports.setActiveItem(self, player, collectibleType, activeSlot, charge, keepInPools)
|
|
444
|
+
if keepInPools == nil then
|
|
445
|
+
keepInPools = false
|
|
446
|
+
end
|
|
447
|
+
local game = Game()
|
|
448
|
+
local itemPool = game:GetItemPool()
|
|
449
|
+
local primaryCollectibleType = player:GetActiveItem(ActiveSlot.SLOT_PRIMARY)
|
|
450
|
+
local primaryCharge = player:GetActiveCharge(ActiveSlot.SLOT_PRIMARY)
|
|
451
|
+
local secondaryCollectibleType = player:GetActiveItem(ActiveSlot.SLOT_SECONDARY)
|
|
452
|
+
if charge == nil then
|
|
453
|
+
charge = getCollectibleMaxCharges(nil, collectibleType)
|
|
454
|
+
end
|
|
455
|
+
if not keepInPools then
|
|
456
|
+
itemPool:RemoveCollectible(collectibleType)
|
|
457
|
+
end
|
|
458
|
+
repeat
|
|
459
|
+
local ____switch106 = activeSlot
|
|
460
|
+
local ____cond106 = ____switch106 == ActiveSlot.SLOT_PRIMARY
|
|
461
|
+
if ____cond106 then
|
|
462
|
+
do
|
|
463
|
+
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
464
|
+
player:RemoveCollectible(primaryCollectibleType)
|
|
465
|
+
end
|
|
466
|
+
player:AddCollectible(collectibleType, charge, false)
|
|
467
|
+
break
|
|
468
|
+
end
|
|
469
|
+
end
|
|
470
|
+
____cond106 = ____cond106 or (____switch106 == ActiveSlot.SLOT_SECONDARY)
|
|
471
|
+
if ____cond106 then
|
|
472
|
+
do
|
|
473
|
+
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
474
|
+
player:RemoveCollectible(primaryCollectibleType)
|
|
475
|
+
end
|
|
476
|
+
if secondaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
477
|
+
player:RemoveCollectible(secondaryCollectibleType)
|
|
478
|
+
end
|
|
479
|
+
player:AddCollectible(secondaryCollectibleType, charge, false)
|
|
480
|
+
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
481
|
+
player:AddCollectible(primaryCollectibleType, primaryCharge, false)
|
|
482
|
+
end
|
|
483
|
+
break
|
|
484
|
+
end
|
|
485
|
+
end
|
|
486
|
+
____cond106 = ____cond106 or (____switch106 == ActiveSlot.SLOT_POCKET)
|
|
487
|
+
if ____cond106 then
|
|
488
|
+
do
|
|
489
|
+
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
490
|
+
player:SetActiveCharge(charge, activeSlot)
|
|
491
|
+
break
|
|
492
|
+
end
|
|
493
|
+
end
|
|
494
|
+
____cond106 = ____cond106 or (____switch106 == ActiveSlot.SLOT_POCKET2)
|
|
495
|
+
if ____cond106 then
|
|
496
|
+
do
|
|
497
|
+
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
498
|
+
break
|
|
499
|
+
end
|
|
500
|
+
end
|
|
501
|
+
do
|
|
502
|
+
do
|
|
503
|
+
ensureAllCases(nil, activeSlot)
|
|
504
|
+
end
|
|
505
|
+
end
|
|
506
|
+
until true
|
|
507
|
+
end
|
|
439
508
|
function ____exports.setBlindfold(self, player, enabled)
|
|
440
509
|
local game = Game()
|
|
441
510
|
local character = player:GetPlayerType()
|
|
@@ -108,6 +108,13 @@ export declare function inDimension(dimension: Dimension): boolean;
|
|
|
108
108
|
export declare function inLRoom(): boolean;
|
|
109
109
|
export declare function inGenesisRoom(): boolean;
|
|
110
110
|
export declare function inStartingRoom(): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* If `Room.Update()` is called in a PostNewRoom callback, then some entities will slide around
|
|
113
|
+
* (such as the player). Since those entity velocities are already at zero, setting them to zero
|
|
114
|
+
* will have no effect. Thus, a generic solution is to record all of the entity positions/velocities
|
|
115
|
+
* before updating the room, and then restore those positions/velocities.
|
|
116
|
+
*/
|
|
117
|
+
export declare function roomUpdateSafe(): void;
|
|
111
118
|
/**
|
|
112
119
|
* Helper function to convert an uncleared room to a cleared room in the PostNewRoom callback. This
|
|
113
120
|
* is useful because if enemies are removed in this callback, a room drop will be awarded and the
|
package/dist/functions/rooms.lua
CHANGED
|
@@ -11,6 +11,12 @@ local ____doors = require("functions.doors")
|
|
|
11
11
|
local closeAllDoors = ____doors.closeAllDoors
|
|
12
12
|
local getDoors = ____doors.getDoors
|
|
13
13
|
local isHiddenSecretRoomDoor = ____doors.isHiddenSecretRoomDoor
|
|
14
|
+
local ____entity = require("functions.entity")
|
|
15
|
+
local getEntities = ____entity.getEntities
|
|
16
|
+
local getEntityPositions = ____entity.getEntityPositions
|
|
17
|
+
local getEntityVelocities = ____entity.getEntityVelocities
|
|
18
|
+
local setEntityPositions = ____entity.setEntityPositions
|
|
19
|
+
local setEntityVelocities = ____entity.setEntityVelocities
|
|
14
20
|
local ____flag = require("functions.flag")
|
|
15
21
|
local hasFlag = ____flag.hasFlag
|
|
16
22
|
function ____exports.getRoomIndex(self)
|
|
@@ -196,6 +202,16 @@ function ____exports.inStartingRoom(self)
|
|
|
196
202
|
local roomIndex = ____exports.getRoomIndex(nil)
|
|
197
203
|
return roomIndex == startingRoomIndex
|
|
198
204
|
end
|
|
205
|
+
function ____exports.roomUpdateSafe(self)
|
|
206
|
+
local game = Game()
|
|
207
|
+
local room = game:GetRoom()
|
|
208
|
+
local entities = getEntities(nil)
|
|
209
|
+
local entityPositions = getEntityPositions(nil, entities)
|
|
210
|
+
local entityVelocities = getEntityVelocities(nil, entities)
|
|
211
|
+
room:Update()
|
|
212
|
+
setEntityPositions(nil, entityPositions, entities)
|
|
213
|
+
setEntityVelocities(nil, entityVelocities, entities)
|
|
214
|
+
end
|
|
199
215
|
function ____exports.setRoomCleared(self)
|
|
200
216
|
local game = Game()
|
|
201
217
|
local room = game:GetRoom()
|
|
@@ -210,14 +226,14 @@ function ____exports.setRoomCleared(self)
|
|
|
210
226
|
) do
|
|
211
227
|
do
|
|
212
228
|
if isHiddenSecretRoomDoor(nil, door) then
|
|
213
|
-
goto
|
|
229
|
+
goto __continue39
|
|
214
230
|
end
|
|
215
231
|
door.State = DoorState.STATE_OPEN
|
|
216
232
|
local sprite = door:GetSprite()
|
|
217
233
|
sprite:Play("Opened", true)
|
|
218
234
|
door.ExtraVisible = false
|
|
219
235
|
end
|
|
220
|
-
::
|
|
236
|
+
::__continue39::
|
|
221
237
|
end
|
|
222
238
|
sfx:Stop(SoundEffect.SOUND_DOOR_HEAVY_OPEN)
|
|
223
239
|
game:ShakeScreen(0)
|