isaacscript-common 59.4.0 → 59.5.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.
Files changed (53) hide show
  1. package/dist/index.rollup.d.ts +86 -1
  2. package/dist/isaacscript-common.lua +160 -50
  3. package/dist/src/classes/ModUpgraded.d.ts.map +1 -1
  4. package/dist/src/classes/ModUpgraded.lua +2 -2
  5. package/dist/src/classes/callbacks/PostCursedTeleport.d.ts.map +1 -1
  6. package/dist/src/classes/callbacks/PostCursedTeleport.lua +3 -2
  7. package/dist/src/classes/callbacks/PostItemDischarge.d.ts.map +1 -1
  8. package/dist/src/classes/callbacks/PostPickupInitFirst.d.ts.map +1 -1
  9. package/dist/src/classes/callbacks/PostPickupInitFirst.lua +3 -5
  10. package/dist/src/classes/features/callbackLogic/GameReorderedCallbacks.d.ts.map +1 -1
  11. package/dist/src/classes/features/callbackLogic/GameReorderedCallbacks.lua +5 -5
  12. package/dist/src/classes/features/other/CustomTrapdoors.d.ts.map +1 -1
  13. package/dist/src/classes/features/other/CustomTrapdoors.lua +10 -12
  14. package/dist/src/classes/features/other/PickupIndexCreation.d.ts.map +1 -1
  15. package/dist/src/classes/features/other/PickupIndexCreation.lua +3 -2
  16. package/dist/src/classes/features/other/PreventCollectibleRotation.d.ts.map +1 -1
  17. package/dist/src/classes/features/other/PreventCollectibleRotation.lua +3 -2
  18. package/dist/src/classes/features/other/SaveDataManager.d.ts.map +1 -1
  19. package/dist/src/classes/features/other/SaveDataManager.lua +3 -4
  20. package/dist/src/classes/features/other/customStages/streakText.d.ts.map +1 -1
  21. package/dist/src/classes/features/other/customStages/streakText.lua +6 -5
  22. package/dist/src/functions/challenges.d.ts.map +1 -1
  23. package/dist/src/functions/challenges.lua +8 -2
  24. package/dist/src/functions/debugFunctions.d.ts +7 -1
  25. package/dist/src/functions/debugFunctions.d.ts.map +1 -1
  26. package/dist/src/functions/debugFunctions.lua +22 -16
  27. package/dist/src/functions/frames.d.ts +68 -0
  28. package/dist/src/functions/frames.d.ts.map +1 -0
  29. package/dist/src/functions/frames.lua +119 -0
  30. package/dist/src/functions/revive.d.ts.map +1 -1
  31. package/dist/src/functions/revive.lua +3 -4
  32. package/dist/src/functions/run.d.ts.map +1 -1
  33. package/dist/src/functions/run.lua +3 -1
  34. package/dist/src/index.d.ts +1 -0
  35. package/dist/src/index.d.ts.map +1 -1
  36. package/dist/src/index.lua +8 -0
  37. package/package.json +1 -1
  38. package/src/classes/ModUpgraded.ts +2 -3
  39. package/src/classes/callbacks/PostCursedTeleport.ts +2 -2
  40. package/src/classes/callbacks/PostItemDischarge.ts +2 -0
  41. package/src/classes/callbacks/PostPickupInitFirst.ts +2 -4
  42. package/src/classes/features/callbackLogic/GameReorderedCallbacks.ts +4 -6
  43. package/src/classes/features/other/CustomTrapdoors.ts +11 -14
  44. package/src/classes/features/other/PickupIndexCreation.ts +2 -2
  45. package/src/classes/features/other/PreventCollectibleRotation.ts +2 -3
  46. package/src/classes/features/other/SaveDataManager.ts +2 -3
  47. package/src/classes/features/other/customStages/streakText.ts +10 -6
  48. package/src/functions/challenges.ts +11 -2
  49. package/src/functions/debugFunctions.ts +10 -1
  50. package/src/functions/frames.ts +172 -0
  51. package/src/functions/revive.ts +2 -3
  52. package/src/functions/run.ts +3 -1
  53. package/src/index.ts +1 -0
@@ -0,0 +1,172 @@
1
+ import { game } from "../core/cachedClasses";
2
+
3
+ export function getElapsedGameFramesSince(gameFrameCount: int): int {
4
+ const thisGameFrameCount = game.GetFrameCount();
5
+ return thisGameFrameCount - gameFrameCount;
6
+ }
7
+
8
+ export function getElapsedRenderFramesSince(renderFrameCount: int): int {
9
+ const thisRenderFrameCount = Isaac.GetFrameCount();
10
+ return thisRenderFrameCount - renderFrameCount;
11
+ }
12
+
13
+ export function getElapsedRoomFramesSince(roomFrameCount: int): int {
14
+ const room = game.GetRoom();
15
+ const thisRoomFrameCount = room.GetFrameCount();
16
+ return thisRoomFrameCount - roomFrameCount;
17
+ }
18
+
19
+ /**
20
+ * Helper function to check if the current game frame count is higher than a specific game frame
21
+ * count.
22
+ *
23
+ * This returns false if the submitted game frame count is null or undefined.
24
+ */
25
+ export function isPastGameFrame(
26
+ gameFrameCount: int | null | undefined,
27
+ ): boolean {
28
+ if (gameFrameCount === null || gameFrameCount === undefined) {
29
+ return false;
30
+ }
31
+
32
+ const thisGameFrameCount = game.GetFrameCount();
33
+ return thisGameFrameCount > gameFrameCount;
34
+ }
35
+
36
+ /**
37
+ * Helper function to check if the current render frame count is higher than a specific render frame
38
+ * count.
39
+ *
40
+ * This returns false if the submitted render frame count is null or undefined.
41
+ */
42
+ export function isPastRenderFrame(
43
+ renderFrameCount: int | null | undefined,
44
+ ): boolean {
45
+ if (renderFrameCount === null || renderFrameCount === undefined) {
46
+ return false;
47
+ }
48
+
49
+ const thisRenderFrameCount = Isaac.GetFrameCount();
50
+ return thisRenderFrameCount >= renderFrameCount;
51
+ }
52
+
53
+ /**
54
+ * Helper function to check if the current room frame count is higher than a specific room frame
55
+ * count.
56
+ *
57
+ * This returns false if the submitted room frame count is null or undefined.
58
+ */
59
+ export function isPastRoomFrame(
60
+ roomFrameCount: int | null | undefined,
61
+ ): boolean {
62
+ if (roomFrameCount === null || roomFrameCount === undefined) {
63
+ return false;
64
+ }
65
+
66
+ const room = game.GetRoom();
67
+
68
+ const thisGameFrameCount = room.GetFrameCount();
69
+ return thisGameFrameCount > roomFrameCount;
70
+ }
71
+
72
+ /**
73
+ * Helper function to check if the current game frame count is exactly equal to a specific game
74
+ * frame count.
75
+ *
76
+ * This returns false if the submitted game frame count is null or undefined.
77
+ */
78
+ export function onGameFrame(gameFrameCount: int | null | undefined): boolean {
79
+ if (gameFrameCount === null || gameFrameCount === undefined) {
80
+ return false;
81
+ }
82
+
83
+ const thisGameFrameCount = game.GetFrameCount();
84
+ return thisGameFrameCount === gameFrameCount;
85
+ }
86
+
87
+ /**
88
+ * Helper function to check if the current game frame count is equal to or higher than a specific
89
+ * game frame count.
90
+ *
91
+ * This returns false if the submitted game frame count is null or undefined.
92
+ */
93
+ export function onOrPastGameFrame(
94
+ gameFrameCount: int | null | undefined,
95
+ ): boolean {
96
+ if (gameFrameCount === null || gameFrameCount === undefined) {
97
+ return false;
98
+ }
99
+
100
+ const thisGameFrameCount = game.GetFrameCount();
101
+ return thisGameFrameCount >= gameFrameCount;
102
+ }
103
+
104
+ /**
105
+ * Helper function to check if the current render frame count is equal to or higher than a specific
106
+ * render frame count.
107
+ *
108
+ * This returns false if the submitted render frame count is null or undefined.
109
+ */
110
+ export function onOrPastRenderFrame(
111
+ renderFrameCount: int | null | undefined,
112
+ ): boolean {
113
+ if (renderFrameCount === null || renderFrameCount === undefined) {
114
+ return false;
115
+ }
116
+
117
+ const thisRenderFrameCount = Isaac.GetFrameCount();
118
+ return thisRenderFrameCount >= renderFrameCount;
119
+ }
120
+
121
+ /**
122
+ * Helper function to check if the current room frame count is equal to or higher than a specific
123
+ * room frame count.
124
+ *
125
+ * This returns false if the submitted room frame count is null or undefined.
126
+ */
127
+ export function onOrPastRoomFrame(
128
+ roomFrameCount: int | null | undefined,
129
+ ): boolean {
130
+ if (roomFrameCount === null || roomFrameCount === undefined) {
131
+ return false;
132
+ }
133
+
134
+ const room = game.GetRoom();
135
+
136
+ const thisGameFrameCount = room.GetFrameCount();
137
+ return thisGameFrameCount >= roomFrameCount;
138
+ }
139
+
140
+ /**
141
+ * Helper function to check if the current render frame count is exactly equal to a specific render
142
+ * frame count.
143
+ *
144
+ * This returns false if the submitted render frame count is null or undefined.
145
+ */
146
+ export function onRenderFrame(
147
+ renderFrameCount: int | null | undefined,
148
+ ): boolean {
149
+ if (renderFrameCount === null || renderFrameCount === undefined) {
150
+ return false;
151
+ }
152
+
153
+ const thisRenderFrameCount = Isaac.GetFrameCount();
154
+ return thisRenderFrameCount >= renderFrameCount;
155
+ }
156
+
157
+ /**
158
+ * Helper function to check if the current room frame count is exactly equal to a specific room
159
+ * frame count.
160
+ *
161
+ * This returns false if the submitted room frame count is null or undefined.
162
+ */
163
+ export function onRoomFrame(roomFrameCount: int | null | undefined): boolean {
164
+ if (roomFrameCount === null || roomFrameCount === undefined) {
165
+ return false;
166
+ }
167
+
168
+ const room = game.GetRoom();
169
+
170
+ const thisGameFrameCount = room.GetFrameCount();
171
+ return thisGameFrameCount === roomFrameCount;
172
+ }
@@ -5,13 +5,13 @@ import {
5
5
  PlayerType,
6
6
  TrinketType,
7
7
  } from "isaac-typescript-definitions";
8
- import { game } from "../core/cachedClasses";
9
8
  import {
10
9
  MAX_TAINTED_SAMSON_BERSERK_CHARGE,
11
10
  TAINTED_SAMSON_BERSERK_CHARGE_FROM_TAKING_DAMAGE,
12
11
  } from "../core/constants";
13
12
  import { MysteriousPaperEffect } from "../enums/MysteriousPaperEffect";
14
13
  import { getCharacterDeathAnimationName } from "./characters";
14
+ import { onGameFrame } from "./frames";
15
15
  import { getPlayerMaxHeartContainers } from "./playerHealth";
16
16
  import { getPlayerNumHitsRemaining, hasLostCurse, isKeeper } from "./players";
17
17
  import { getLastFrameOfAnimation } from "./sprites";
@@ -28,7 +28,6 @@ export function isDamageToPlayerFatal(
28
28
  source: EntityRef,
29
29
  lastDamageGameFrame: int | undefined,
30
30
  ): boolean {
31
- const gameFrameCount = game.GetFrameCount();
32
31
  const character = player.GetPlayerType();
33
32
  const effects = player.GetEffects();
34
33
  const isBerserk = effects.HasCollectibleEffect(CollectibleType.BERSERK);
@@ -91,7 +90,7 @@ export function isDamageToPlayerFatal(
91
90
  // damage on the same frame.
92
91
  if (
93
92
  player.HasCollectible(CollectibleType.BROKEN_GLASS_CANNON) &&
94
- gameFrameCount === lastDamageGameFrame
93
+ onGameFrame(lastDamageGameFrame)
95
94
  ) {
96
95
  return false;
97
96
  }
@@ -136,7 +136,9 @@ export function setRunSeed(startSeedOrStartSeedString: Seed | string): void {
136
136
  ? startSeedOrStartSeedString
137
137
  : Seeds.Seed2String(startSeedOrStartSeedString);
138
138
 
139
- Isaac.ExecuteCommand(`seed ${startSeedString}`);
139
+ const command = `seed ${startSeedString}`;
140
+ log(`Restarting the run to set a seed with a console command of: ${command}`);
141
+ Isaac.ExecuteCommand(command);
140
142
  }
141
143
 
142
144
  /**
package/src/index.ts CHANGED
@@ -54,6 +54,7 @@ export * from "./functions/enums";
54
54
  export * from "./functions/external";
55
55
  export * from "./functions/familiars";
56
56
  export * from "./functions/flag";
57
+ export * from "./functions/frames";
57
58
  export * from "./functions/globals";
58
59
  export * from "./functions/gridEntities";
59
60
  export * from "./functions/gridEntitiesSpecific";