isaacscript-common 1.0.595 → 1.0.599

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.
@@ -4,6 +4,8 @@ local hasSubscriptions, postPEffectUpdateReordered
4
4
  local ____player = require("functions.player")
5
5
  local getPlayerNumAllHearts = ____player.getPlayerNumAllHearts
6
6
  local isChildPlayer = ____player.isChildPlayer
7
+ local ____revive = require("functions.revive")
8
+ local willPlayerRevive = ____revive.willPlayerRevive
7
9
  local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
8
10
  local ModCallbacksCustom = ____ModCallbacksCustom.ModCallbacksCustom
9
11
  local ____preBerserkDeath = require("callbacks.subscriptions.preBerserkDeath")
@@ -22,7 +24,7 @@ function postPEffectUpdateReordered(self, player)
22
24
  local effects = player:GetEffects()
23
25
  local berserkEffect = effects:GetCollectibleEffect(CollectibleType.COLLECTIBLE_BERSERK)
24
26
  local playerNumAllHearts = getPlayerNumAllHearts(nil, player)
25
- if berserkEffect ~= nil and berserkEffect.Cooldown == 1 and playerNumAllHearts == 0 then
27
+ if berserkEffect ~= nil and berserkEffect.Cooldown == 1 and playerNumAllHearts == 0 and not willPlayerRevive(nil, player) then
26
28
  preBerserkDeathFire(nil, player)
27
29
  end
28
30
  end
@@ -105,6 +105,7 @@ export declare const MOVEMENT_ACTIONS: Set<ButtonAction>;
105
105
  export declare const ONE_BY_ONE_ROOM_GRID_SIZE = 135;
106
106
  export declare const SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES: Set<CollectibleType>;
107
107
  export declare const SHOOTING_ACTIONS: Set<ButtonAction>;
108
+ export declare const STORY_BOSSES: Set<EntityType>;
108
109
  /**
109
110
  * This is the number of draw coordinates that each heart spans on the UI in the upper left hand
110
111
  * corner.
@@ -98,5 +98,20 @@ ____exports.SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES = __TS__New(Set, {
98
98
  CollectibleType.COLLECTIBLE_R_KEY
99
99
  })
100
100
  ____exports.SHOOTING_ACTIONS = __TS__New(Set, {ButtonAction.ACTION_SHOOTLEFT, ButtonAction.ACTION_SHOOTRIGHT, ButtonAction.ACTION_SHOOTUP, ButtonAction.ACTION_SHOOTDOWN})
101
+ ____exports.STORY_BOSSES = __TS__New(Set, {
102
+ EntityType.ENTITY_MOM,
103
+ EntityType.ENTITY_MOMS_HEART,
104
+ EntityType.ENTITY_SATAN,
105
+ EntityType.ENTITY_ISAAC,
106
+ EntityType.ENTITY_THE_LAMB,
107
+ EntityType.ENTITY_MEGA_SATAN,
108
+ EntityType.ENTITY_MEGA_SATAN_2,
109
+ EntityType.ENTITY_ULTRA_GREED,
110
+ EntityType.ENTITY_HUSH,
111
+ EntityType.ENTITY_DELIRIUM,
112
+ EntityType.ENTITY_MOTHER,
113
+ EntityType.ENTITY_DOGMA,
114
+ EntityType.ENTITY_BEAST
115
+ })
101
116
  ____exports.UI_HEART_WIDTH = 12
102
117
  return ____exports
@@ -165,6 +165,12 @@ export declare function getTears(matchingVariant?: number, matchingSubType?: num
165
165
  * @param threshold Optional. The threshold from 0 to consider to be moving. 0.01 by default.
166
166
  */
167
167
  export declare function isEntityMoving(entity: Entity, threshold?: number): boolean;
168
+ /**
169
+ * Helper function to determine if the current entity is an end-game story boss, like Isaac, Blue
170
+ * Baby, Mega Satan, The Beast, and so on. This is useful because certain effects should only apply
171
+ * to non-story bosses, like Vanishing Twin. Also see the `STORY_BOSSES` constant.
172
+ */
173
+ export declare function isStoryBoss(entity: Entity): boolean;
168
174
  /**
169
175
  * Helper function to remove all of the entities in the supplied array.
170
176
  *
@@ -1,6 +1,8 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  require("lualib_bundle");
3
3
  local ____exports = {}
4
+ local ____constants = require("constants")
5
+ local STORY_BOSSES = ____constants.STORY_BOSSES
4
6
  local ____random = require("functions.random")
5
7
  local getRandom = ____random.getRandom
6
8
  local nextSeed = ____random.nextSeed
@@ -230,6 +232,9 @@ function ____exports.isEntityMoving(self, entity, threshold)
230
232
  end
231
233
  return entity.Velocity:Length() >= threshold
232
234
  end
235
+ function ____exports.isStoryBoss(self, entity)
236
+ return STORY_BOSSES:has(entity.Type)
237
+ end
233
238
  function ____exports.removeEntities(self, entities, cap)
234
239
  if #entities == 0 then
235
240
  return false
@@ -142,7 +142,13 @@ export declare function getPlayerNumAllHearts(player: EntityPlayer): int;
142
142
  * the player (i.e. Esau & Tainted Soul). False by default.
143
143
  */
144
144
  export declare function getPlayers(performExclusions?: boolean): EntityPlayer[];
145
- export declare function getPlayersOfType(playerType: PlayerType): EntityPlayer[];
145
+ /**
146
+ * Helper function to get all of the players that are a certain character.
147
+ *
148
+ * This function is variadic, meaning that you can supply as many characters as you want to check
149
+ * for. Returns true if any of the characters supplied are present.
150
+ */
151
+ export declare function getPlayersOfType(...characters: PlayerType[]): EntityPlayer[];
146
152
  /**
147
153
  * Helper function to return the active charge and the battery charge combined. This is useful
148
154
  * because you are not able to set the battery charge directly.
@@ -302,11 +302,13 @@ function ____exports.getPlayerNumAllHearts(self, player)
302
302
  local rottenHearts = player:GetRottenHearts()
303
303
  return hearts + soulHearts + boneHearts + eternalHearts - rottenHearts
304
304
  end
305
- function ____exports.getPlayersOfType(self, playerType)
305
+ function ____exports.getPlayersOfType(self, ...)
306
+ local characters = {...}
307
+ local charactersSet = __TS__New(Set, characters)
306
308
  local players = {}
307
309
  for ____, player in ipairs(____exports.getPlayers(nil)) do
308
310
  local character = player:GetPlayerType()
309
- if character == playerType then
311
+ if charactersSet:has(character) then
310
312
  __TS__ArrayPush(players, player)
311
313
  end
312
314
  end
@@ -11,6 +11,7 @@ export declare function getStage(): LevelStage;
11
11
  export declare function getStageType(): StageType;
12
12
  /** Helper function to directly warp to a specific stage using the "stage" console command. */
13
13
  export declare function goToStage(stage: LevelStage, stageType: StageType): void;
14
+ export declare function isRepentanceStage(stageType: int): boolean;
14
15
  export declare function onCathedral(): boolean;
15
16
  export declare function onChest(): boolean;
16
17
  export declare function onDarkRoom(): boolean;
@@ -2,47 +2,50 @@
2
2
  local ____exports = {}
3
3
  local ____util = require("functions.util")
4
4
  local ensureAllCases = ____util.ensureAllCases
5
+ function ____exports.isRepentanceStage(self, stageType)
6
+ return stageType == StageType.STAGETYPE_REPENTANCE or stageType == StageType.STAGETYPE_REPENTANCE_B
7
+ end
5
8
  function ____exports.onRepentanceStage(self)
6
9
  local game = Game()
7
10
  local level = game:GetLevel()
8
11
  local stageType = level:GetStageType()
9
- return stageType == StageType.STAGETYPE_REPENTANCE or stageType == StageType.STAGETYPE_REPENTANCE_B
12
+ return ____exports.isRepentanceStage(nil, stageType)
10
13
  end
11
14
  function ____exports.stageTypeToLetter(self, stageType)
12
15
  repeat
13
- local ____switch14 = stageType
14
- local ____cond14 = ____switch14 == StageType.STAGETYPE_ORIGINAL
15
- if ____cond14 then
16
+ local ____switch15 = stageType
17
+ local ____cond15 = ____switch15 == StageType.STAGETYPE_ORIGINAL
18
+ if ____cond15 then
16
19
  do
17
20
  return ""
18
21
  end
19
22
  end
20
- ____cond14 = ____cond14 or ____switch14 == StageType.STAGETYPE_WOTL
21
- if ____cond14 then
23
+ ____cond15 = ____cond15 or ____switch15 == StageType.STAGETYPE_WOTL
24
+ if ____cond15 then
22
25
  do
23
26
  return "a"
24
27
  end
25
28
  end
26
- ____cond14 = ____cond14 or ____switch14 == StageType.STAGETYPE_AFTERBIRTH
27
- if ____cond14 then
29
+ ____cond15 = ____cond15 or ____switch15 == StageType.STAGETYPE_AFTERBIRTH
30
+ if ____cond15 then
28
31
  do
29
32
  return "b"
30
33
  end
31
34
  end
32
- ____cond14 = ____cond14 or ____switch14 == StageType.STAGETYPE_GREEDMODE
33
- if ____cond14 then
35
+ ____cond15 = ____cond15 or ____switch15 == StageType.STAGETYPE_GREEDMODE
36
+ if ____cond15 then
34
37
  do
35
38
  return ""
36
39
  end
37
40
  end
38
- ____cond14 = ____cond14 or ____switch14 == StageType.STAGETYPE_REPENTANCE
39
- if ____cond14 then
41
+ ____cond15 = ____cond15 or ____switch15 == StageType.STAGETYPE_REPENTANCE
42
+ if ____cond15 then
40
43
  do
41
44
  return "c"
42
45
  end
43
46
  end
44
- ____cond14 = ____cond14 or ____switch14 == StageType.STAGETYPE_REPENTANCE_B
45
- if ____cond14 then
47
+ ____cond15 = ____cond15 or ____switch15 == StageType.STAGETYPE_REPENTANCE_B
48
+ if ____cond15 then
46
49
  do
47
50
  return "d"
48
51
  end
@@ -1335,6 +1335,15 @@ Map = Map
1335
1335
 
1336
1336
  __TS__MathAtan2 = math.atan2 or math.atan
1337
1337
 
1338
+ function __TS__MathSign(val)
1339
+ if val > 0 then
1340
+ return 1
1341
+ elseif val < 0 then
1342
+ return -1
1343
+ end
1344
+ return 0
1345
+ end
1346
+
1338
1347
  function __TS__Number(value)
1339
1348
  local valueType = type(value)
1340
1349
  if valueType == "number" then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.595",
3
+ "version": "1.0.599",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -25,11 +25,11 @@
25
25
  "dist/**/*.d.ts"
26
26
  ],
27
27
  "devDependencies": {
28
- "isaac-typescript-definitions": "^1.0.331",
28
+ "isaac-typescript-definitions": "^1.0.332",
29
29
  "isaacscript-lint": "^1.0.79",
30
30
  "isaacscript-tsconfig": "^1.1.8",
31
- "typedoc": "^0.22.10",
32
- "typescript": "^4.5.4",
33
- "typescript-to-lua": "^1.3.1"
31
+ "typedoc": "^0.22.11",
32
+ "typescript": "^4.5.5",
33
+ "typescript-to-lua": "^1.3.3"
34
34
  }
35
35
  }