isaacscript-common 1.2.33 → 1.2.36

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.
@@ -7,15 +7,23 @@
7
7
  * This function is meant to be called in the EvaluateCache callback (when the cache flag is equal
8
8
  * to `CacheFlag.CACHE_FAMILIARS`).
9
9
  *
10
+ * Note that if you want your custom familiar to work properly with Box of Friends, you must keep
11
+ * track of the number of times that it has been used per room and then pass that as the
12
+ * `numTempFamiliars` argument.
13
+ *
10
14
  * @param player The player that has the collectibles for this familiar.
11
15
  * @param collectibleType The collectible type of the collectible associated with this familiar.
16
+ * @param numTempFamiliars The amount of extra familiars that should exist that are not associated
17
+ * with a collectible. Usually, this should be 0. For example, if the player has one familiar and
18
+ * has used Box of Friends once in the current room, then 1 should be passed (so that 2 total
19
+ * familiars will be spawned).
12
20
  * @param familiarVariant The variant of the familiar to spawn or remove.
13
21
  * @param familiarSubType The sub-type of the familiar to spawn
14
22
  * @returns The amount of familiars that were added or removed. For example, the player has 0
15
23
  * collectibles and there were 2 familiars, this function would remove the 2 familiars and return
16
24
  * -2.
17
25
  */
18
- export declare function checkFamiliar(player: EntityPlayer, collectibleType: int, familiarVariant: int, familiarSubType?: int): int;
26
+ export declare function checkFamiliar(player: EntityPlayer, collectibleType: int, numTempFamiliars: int, familiarVariant: int, familiarSubType?: int): int;
19
27
  /**
20
28
  * Helper function to get all of the familiars in the room.
21
29
  *
@@ -26,7 +26,7 @@ function ____exports.getFamiliars(self, matchingVariant, matchingSubType)
26
26
  end
27
27
  return familiars
28
28
  end
29
- function ____exports.checkFamiliar(self, player, collectibleType, familiarVariant, familiarSubType)
29
+ function ____exports.checkFamiliar(self, player, collectibleType, numTempFamiliars, familiarVariant, familiarSubType)
30
30
  local game = Game()
31
31
  local familiarSubTypeToSearchFor = familiarSubType == nil and -1 or familiarSubType
32
32
  local playerPtrHash = GetPtrHash(player)
@@ -36,11 +36,12 @@ function ____exports.checkFamiliar(self, player, collectibleType, familiarVarian
36
36
  function(____, familiar) return GetPtrHash(familiar.Player) == playerPtrHash end
37
37
  )
38
38
  local numCollectibles = player:GetCollectibleNum(collectibleType)
39
- if #familiarsForThisPlayer == numCollectibles then
39
+ local numFamiliarsThatShouldExist = numCollectibles + numTempFamiliars
40
+ if #familiarsForThisPlayer == numFamiliarsThatShouldExist then
40
41
  return 0
41
42
  end
42
- if #familiarsForThisPlayer > numCollectibles then
43
- local numFamiliarsToRemove = #familiarsForThisPlayer - numCollectibles
43
+ if #familiarsForThisPlayer > numFamiliarsThatShouldExist then
44
+ local numFamiliarsToRemove = #familiarsForThisPlayer - numFamiliarsThatShouldExist
44
45
  do
45
46
  local i = 0
46
47
  while i < numFamiliarsToRemove do
@@ -51,7 +52,7 @@ function ____exports.checkFamiliar(self, player, collectibleType, familiarVarian
51
52
  end
52
53
  return numFamiliarsToRemove * -1
53
54
  end
54
- local numFamiliarsToSpawn = numCollectibles - #familiarsForThisPlayer
55
+ local numFamiliarsToSpawn = numFamiliarsThatShouldExist - #familiarsForThisPlayer
55
56
  local collectibleRNG = player:GetCollectibleRNG(collectibleType)
56
57
  local familiarSubTypeToUse = familiarSubType == nil and 0 or familiarSubType
57
58
  do
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.33",
3
+ "version": "1.2.36",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",