isaacscript-common 30.4.5 → 30.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.
@@ -1002,9 +1002,24 @@ export declare type AnyGridEntity = GridEntity | GridEntityDoor | GridEntityPit
1002
1002
  */
1003
1003
  export declare function anyPlayerCloserThan(position: Vector, distance: float): boolean;
1004
1004
 
1005
- export declare function anyPlayerHasCollectible(collectibleType: CollectibleType): boolean;
1005
+ /**
1006
+ * Helper function to check to see if any player has a particular collectible.
1007
+ *
1008
+ * @param collectibleType The collectible type to check for.
1009
+ * @param ignoreModifiers If set to true, only counts collectibles the player actually owns and
1010
+ * ignores effects granted by items like Zodiac, 3 Dollar Bill and Lemegeton.
1011
+ * Default is false.
1012
+ */
1013
+ export declare function anyPlayerHasCollectible(collectibleType: CollectibleType, ignoreModifiers?: boolean): boolean;
1006
1014
 
1007
- export declare function anyPlayerHasTrinket(trinketType: TrinketType): boolean;
1015
+ /**
1016
+ * Helper function to check to see if any player has a particular trinket.
1017
+ *
1018
+ * @param trinketType The trinket type to check for.
1019
+ * @param ignoreModifiers If set to true, only counts trinkets the player actually holds and ignores
1020
+ * effects granted by other items. Default is false.
1021
+ */
1022
+ export declare function anyPlayerHasTrinket(trinketType: TrinketType, ignoreModifiers?: boolean): boolean;
1008
1023
 
1009
1024
  /**
1010
1025
  * Helper function to determine if the given character is present.
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 30.4.5
3
+ isaacscript-common 30.5.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -21644,18 +21644,18 @@ function ____exports.addTrinketCostume(self, player, trinketType)
21644
21644
  end
21645
21645
  player:AddCostume(itemConfigTrinket, false)
21646
21646
  end
21647
- function ____exports.anyPlayerHasCollectible(self, collectibleType)
21647
+ function ____exports.anyPlayerHasCollectible(self, collectibleType, ignoreModifiers)
21648
21648
  local players = getAllPlayers(nil)
21649
21649
  return __TS__ArraySome(
21650
21650
  players,
21651
- function(____, player) return player:HasCollectible(collectibleType) end
21651
+ function(____, player) return player:HasCollectible(collectibleType, ignoreModifiers) end
21652
21652
  )
21653
21653
  end
21654
- function ____exports.anyPlayerHasTrinket(self, trinketType)
21654
+ function ____exports.anyPlayerHasTrinket(self, trinketType, ignoreModifiers)
21655
21655
  local players = getAllPlayers(nil)
21656
21656
  return __TS__ArraySome(
21657
21657
  players,
21658
- function(____, player) return player:HasTrinket(trinketType) end
21658
+ function(____, player) return player:HasTrinket(trinketType, ignoreModifiers) end
21659
21659
  )
21660
21660
  end
21661
21661
  function ____exports.anyPlayerIs(self, ...)
@@ -31450,6 +31450,11 @@ local __TS__Class = ____lualib.__TS__Class
31450
31450
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
31451
31451
  local __TS__ArrayFind = ____lualib.__TS__ArrayFind
31452
31452
  local ____exports = {}
31453
+ local markUsedItemOnThisFrame, v
31454
+ local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
31455
+ local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
31456
+ local ____cachedClasses = require("src.core.cachedClasses")
31457
+ local game = ____cachedClasses.game
31453
31458
  local ____ModCallbackCustom = require("src.enums.ModCallbackCustom")
31454
31459
  local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
31455
31460
  local ____entitiesSpecific = require("src.functions.entitiesSpecific")
@@ -31461,7 +31466,14 @@ local ____DefaultMap = require("src.classes.DefaultMap")
31461
31466
  local DefaultMap = ____DefaultMap.DefaultMap
31462
31467
  local ____CustomCallback = require("src.classes.private.CustomCallback")
31463
31468
  local CustomCallback = ____CustomCallback.CustomCallback
31464
- local v = {room = {playersHoldingItemOnLastFrameMap = __TS__New(DefaultMap, false)}}
31469
+ function markUsedItemOnThisFrame(self, player)
31470
+ local gameFrameCount = game:GetFrameCount()
31471
+ mapSetPlayer(nil, v.room.playersUsedItemOnFrame, player, gameFrameCount)
31472
+ end
31473
+ v = {room = {
31474
+ playersHoldingItemOnLastFrameMap = __TS__New(DefaultMap, false),
31475
+ playersUsedItemOnFrame = __TS__New(DefaultMap, 0)
31476
+ }}
31465
31477
  ____exports.PostPurchase = __TS__Class()
31466
31478
  local PostPurchase = ____exports.PostPurchase
31467
31479
  PostPurchase.name = "PostPurchase"
@@ -31474,16 +31486,34 @@ function PostPurchase.prototype.____constructor(self)
31474
31486
  local callbackPickupVariant, callbackPickupSubType = table.unpack(optionalArgs)
31475
31487
  return (callbackPickupVariant == nil or callbackPickupVariant == pickup.Variant) and (callbackPickupSubType == nil or callbackPickupSubType == pickup.SubType)
31476
31488
  end
31489
+ self.postUseItem = function(____, _collectibleType, _rng, player)
31490
+ markUsedItemOnThisFrame(nil, player)
31491
+ return nil
31492
+ end
31493
+ self.postUseCard = function(____, _cardType, player)
31494
+ markUsedItemOnThisFrame(nil, player)
31495
+ return nil
31496
+ end
31497
+ self.postUsePill = function(____, _pillEffect, player)
31498
+ markUsedItemOnThisFrame(nil, player)
31499
+ return nil
31500
+ end
31477
31501
  self.postPEffectUpdateReordered = function(____, player)
31478
31502
  local isHoldingItem = player:IsHoldingItem()
31479
31503
  local wasHoldingItemOnLastFrame = defaultMapGetPlayer(nil, v.room.playersHoldingItemOnLastFrameMap, player)
31480
31504
  mapSetPlayer(nil, v.room.playersHoldingItemOnLastFrameMap, player, isHoldingItem)
31481
- if not wasHoldingItemOnLastFrame and isHoldingItem then
31505
+ if not wasHoldingItemOnLastFrame and isHoldingItem and not self:playerUsedItemRecently(player) then
31482
31506
  self:playerPickedUpNewItem(player)
31483
31507
  end
31484
31508
  end
31509
+ self.callbacksUsed = {{ModCallback.POST_USE_ITEM, self.postUseItem}, {ModCallback.POST_USE_CARD, self.postUseCard}, {ModCallback.POST_USE_PILL, self.postUsePill}}
31485
31510
  self.customCallbacksUsed = {{ModCallbackCustom.POST_PEFFECT_UPDATE_REORDERED, self.postPEffectUpdateReordered}}
31486
31511
  end
31512
+ function PostPurchase.prototype.playerUsedItemRecently(self, player)
31513
+ local gameFrameCount = game:GetFrameCount()
31514
+ local usedCollectibleOnFrame = defaultMapGetPlayer(nil, v.room.playersUsedItemOnFrame, player)
31515
+ return gameFrameCount == usedCollectibleOnFrame or gameFrameCount == usedCollectibleOnFrame + 1
31516
+ end
31487
31517
  function PostPurchase.prototype.playerPickedUpNewItem(self, player)
31488
31518
  local pickups = getPickups(nil)
31489
31519
  local disappearingPickup = __TS__ArrayFind(
@@ -7,11 +7,16 @@ export declare class PostPurchase extends CustomCallback<T> {
7
7
  v: {
8
8
  room: {
9
9
  playersHoldingItemOnLastFrameMap: DefaultMap<PlayerIndex, boolean, []>;
10
+ playersUsedItemOnFrame: DefaultMap<PlayerIndex, number, []>;
10
11
  };
11
12
  };
12
13
  constructor();
13
14
  protected shouldFire: (fireArgs: [player: EntityPlayer, pickup: EntityPickup], optionalArgs: [pickupVariant?: import("isaac-typescript-definitions").PickupVariant | undefined, subType?: number | undefined]) => boolean;
15
+ private postUseItem;
16
+ private postUseCard;
17
+ private postUsePill;
14
18
  private postPEffectUpdateReordered;
19
+ private playerUsedItemRecently;
15
20
  private playerPickedUpNewItem;
16
21
  }
17
22
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"PostPurchase.d.ts","sourceRoot":"","sources":["../../../../src/classes/callbacks/PostPurchase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAMlE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EACL,cAAc,EAGf,MAAM,2BAA2B,CAAC;AAEnC,KAAK,CAAC,GAAG,iBAAiB,CAAC,aAAa,CAAC;AAUzC,qBAAa,YAAa,SAAQ,cAAc,CAAC,CAAC,CAAC;IACjC,CAAC;;;;MAAK;;IAatB,UAAmB,UAAU,8LAG1B,OAAO,CAUR;IAGF,OAAO,CAAC,0BAA0B,CAehC;IAEF,OAAO,CAAC,qBAAqB;CAS9B"}
1
+ {"version":3,"file":"PostPurchase.d.ts","sourceRoot":"","sources":["../../../../src/classes/callbacks/PostPurchase.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAMlE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EACL,cAAc,EAGf,MAAM,2BAA2B,CAAC;AAEnC,KAAK,CAAC,GAAG,iBAAiB,CAAC,aAAa,CAAC;AAWzC,qBAAa,YAAa,SAAQ,cAAc,CAAC,CAAC,CAAC;IACjC,CAAC;;;;;MAAK;;IAwBtB,UAAmB,UAAU,8LAG1B,OAAO,CAUR;IAGF,OAAO,CAAC,WAAW,CAOjB;IAGF,OAAO,CAAC,WAAW,CAGjB;IAGF,OAAO,CAAC,WAAW,CAGjB;IAGF,OAAO,CAAC,0BAA0B,CAqBhC;IAEF,OAAO,CAAC,sBAAsB;IAY9B,OAAO,CAAC,qBAAqB;CAS9B"}
@@ -4,6 +4,11 @@ local __TS__Class = ____lualib.__TS__Class
4
4
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
5
5
  local __TS__ArrayFind = ____lualib.__TS__ArrayFind
6
6
  local ____exports = {}
7
+ local markUsedItemOnThisFrame, v
8
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
9
+ local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
10
+ local ____cachedClasses = require("src.core.cachedClasses")
11
+ local game = ____cachedClasses.game
7
12
  local ____ModCallbackCustom = require("src.enums.ModCallbackCustom")
8
13
  local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
9
14
  local ____entitiesSpecific = require("src.functions.entitiesSpecific")
@@ -15,7 +20,14 @@ local ____DefaultMap = require("src.classes.DefaultMap")
15
20
  local DefaultMap = ____DefaultMap.DefaultMap
16
21
  local ____CustomCallback = require("src.classes.private.CustomCallback")
17
22
  local CustomCallback = ____CustomCallback.CustomCallback
18
- local v = {room = {playersHoldingItemOnLastFrameMap = __TS__New(DefaultMap, false)}}
23
+ function markUsedItemOnThisFrame(self, player)
24
+ local gameFrameCount = game:GetFrameCount()
25
+ mapSetPlayer(nil, v.room.playersUsedItemOnFrame, player, gameFrameCount)
26
+ end
27
+ v = {room = {
28
+ playersHoldingItemOnLastFrameMap = __TS__New(DefaultMap, false),
29
+ playersUsedItemOnFrame = __TS__New(DefaultMap, 0)
30
+ }}
19
31
  ____exports.PostPurchase = __TS__Class()
20
32
  local PostPurchase = ____exports.PostPurchase
21
33
  PostPurchase.name = "PostPurchase"
@@ -28,16 +40,34 @@ function PostPurchase.prototype.____constructor(self)
28
40
  local callbackPickupVariant, callbackPickupSubType = table.unpack(optionalArgs)
29
41
  return (callbackPickupVariant == nil or callbackPickupVariant == pickup.Variant) and (callbackPickupSubType == nil or callbackPickupSubType == pickup.SubType)
30
42
  end
43
+ self.postUseItem = function(____, _collectibleType, _rng, player)
44
+ markUsedItemOnThisFrame(nil, player)
45
+ return nil
46
+ end
47
+ self.postUseCard = function(____, _cardType, player)
48
+ markUsedItemOnThisFrame(nil, player)
49
+ return nil
50
+ end
51
+ self.postUsePill = function(____, _pillEffect, player)
52
+ markUsedItemOnThisFrame(nil, player)
53
+ return nil
54
+ end
31
55
  self.postPEffectUpdateReordered = function(____, player)
32
56
  local isHoldingItem = player:IsHoldingItem()
33
57
  local wasHoldingItemOnLastFrame = defaultMapGetPlayer(nil, v.room.playersHoldingItemOnLastFrameMap, player)
34
58
  mapSetPlayer(nil, v.room.playersHoldingItemOnLastFrameMap, player, isHoldingItem)
35
- if not wasHoldingItemOnLastFrame and isHoldingItem then
59
+ if not wasHoldingItemOnLastFrame and isHoldingItem and not self:playerUsedItemRecently(player) then
36
60
  self:playerPickedUpNewItem(player)
37
61
  end
38
62
  end
63
+ self.callbacksUsed = {{ModCallback.POST_USE_ITEM, self.postUseItem}, {ModCallback.POST_USE_CARD, self.postUseCard}, {ModCallback.POST_USE_PILL, self.postUsePill}}
39
64
  self.customCallbacksUsed = {{ModCallbackCustom.POST_PEFFECT_UPDATE_REORDERED, self.postPEffectUpdateReordered}}
40
65
  end
66
+ function PostPurchase.prototype.playerUsedItemRecently(self, player)
67
+ local gameFrameCount = game:GetFrameCount()
68
+ local usedCollectibleOnFrame = defaultMapGetPlayer(nil, v.room.playersUsedItemOnFrame, player)
69
+ return gameFrameCount == usedCollectibleOnFrame or gameFrameCount == usedCollectibleOnFrame + 1
70
+ end
41
71
  function PostPurchase.prototype.playerPickedUpNewItem(self, player)
42
72
  local pickups = getPickups(nil)
43
73
  local disappearingPickup = __TS__ArrayFind(
@@ -8,8 +8,23 @@ import { ActiveSlot, CollectibleType, ControllerIndex, PlayerForm, PlayerType, T
8
8
  export declare function addCollectible(player: EntityPlayer, ...collectibleTypes: CollectibleType[]): void;
9
9
  export declare function addCollectibleCostume(player: EntityPlayer, collectibleType: CollectibleType): void;
10
10
  export declare function addTrinketCostume(player: EntityPlayer, trinketType: TrinketType): void;
11
- export declare function anyPlayerHasCollectible(collectibleType: CollectibleType): boolean;
12
- export declare function anyPlayerHasTrinket(trinketType: TrinketType): boolean;
11
+ /**
12
+ * Helper function to check to see if any player has a particular collectible.
13
+ *
14
+ * @param collectibleType The collectible type to check for.
15
+ * @param ignoreModifiers If set to true, only counts collectibles the player actually owns and
16
+ * ignores effects granted by items like Zodiac, 3 Dollar Bill and Lemegeton.
17
+ * Default is false.
18
+ */
19
+ export declare function anyPlayerHasCollectible(collectibleType: CollectibleType, ignoreModifiers?: boolean): boolean;
20
+ /**
21
+ * Helper function to check to see if any player has a particular trinket.
22
+ *
23
+ * @param trinketType The trinket type to check for.
24
+ * @param ignoreModifiers If set to true, only counts trinkets the player actually holds and ignores
25
+ * effects granted by other items. Default is false.
26
+ */
27
+ export declare function anyPlayerHasTrinket(trinketType: TrinketType, ignoreModifiers?: boolean): boolean;
13
28
  /**
14
29
  * Helper function to determine if the given character is present.
15
30
  *
@@ -1 +1 @@
1
- {"version":3,"file":"players.d.ts","sourceRoot":"","sources":["../../../src/functions/players.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,eAAe,EACf,eAAe,EAEf,UAAU,EACV,UAAU,EACV,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAkBtC;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,YAAY,EACpB,GAAG,gBAAgB,EAAE,eAAe,EAAE,GACrC,IAAI,CAIN;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,IAAI,CAON;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,WAAW,GACvB,IAAI,CAON;AAED,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAGT;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAGrE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,kBAAkB,EAAE,UAAU,EAAE,GAAG,OAAO,CAIxE;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CASjE;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAWzD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,UAAU,EAAE,CAKd;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,kBAAkB,EAAE,YAAY,GAAG,KAAK,GACvC,KAAK,CAMP;AAED,+FAA+F;AAC/F,wBAAgB,aAAa,IAAI,UAAU,EAAE,CAG5C;AAED,wBAAgB,gBAAgB,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B,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,EAChC,UAAU,aAAqB,EAC/B,MAAM,CAAC,EAAE,GAAG,EACZ,WAAW,UAAQ,GAClB,IAAI,CA6DN;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,aAAa,UAAO,GACnB,IAAI,CAsBN;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,IAAI,CAEN"}
1
+ {"version":3,"file":"players.d.ts","sourceRoot":"","sources":["../../../src/functions/players.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,eAAe,EACf,eAAe,EAEf,UAAU,EACV,UAAU,EACV,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAkBtC;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,YAAY,EACpB,GAAG,gBAAgB,EAAE,eAAe,EAAE,GACrC,IAAI,CAIN;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,IAAI,CAON;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,WAAW,GACvB,IAAI,CAON;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,eAAe,EAChC,eAAe,CAAC,EAAE,OAAO,GACxB,OAAO,CAKT;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,WAAW,EACxB,eAAe,CAAC,EAAE,OAAO,GACxB,OAAO,CAKT;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,kBAAkB,EAAE,UAAU,EAAE,GAAG,OAAO,CAIxE;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAS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pB,eAAe,EAAE,eAAe,GAC/B,IAAI,CAON;AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAC7C,GAAG,gBAAgB,EAAE,eAAe,EAAE,GACrC,IAAI,CAQN;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAIlE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,WAAW,GACvB,IAAI,CAON;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,EAChC,UAAU,aAAqB,EAC/B,MAAM,CAAC,EAAE,GAAG,EACZ,WAAW,UAAQ,GAClB,IAAI,CA6DN;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,aAAa,UAAO,GACnB,IAAI,CAsBN;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,IAAI,CAEN"}
@@ -88,18 +88,29 @@ function ____exports.addTrinketCostume(self, player, trinketType)
88
88
  end
89
89
  player:AddCostume(itemConfigTrinket, false)
90
90
  end
91
- function ____exports.anyPlayerHasCollectible(self, collectibleType)
91
+ --- Helper function to check to see if any player has a particular collectible.
92
+ --
93
+ -- @param collectibleType The collectible type to check for.
94
+ -- @param ignoreModifiers If set to true, only counts collectibles the player actually owns and
95
+ -- ignores effects granted by items like Zodiac, 3 Dollar Bill and Lemegeton.
96
+ -- Default is false.
97
+ function ____exports.anyPlayerHasCollectible(self, collectibleType, ignoreModifiers)
92
98
  local players = getAllPlayers(nil)
93
99
  return __TS__ArraySome(
94
100
  players,
95
- function(____, player) return player:HasCollectible(collectibleType) end
101
+ function(____, player) return player:HasCollectible(collectibleType, ignoreModifiers) end
96
102
  )
97
103
  end
98
- function ____exports.anyPlayerHasTrinket(self, trinketType)
104
+ --- Helper function to check to see if any player has a particular trinket.
105
+ --
106
+ -- @param trinketType The trinket type to check for.
107
+ -- @param ignoreModifiers If set to true, only counts trinkets the player actually holds and ignores
108
+ -- effects granted by other items. Default is false.
109
+ function ____exports.anyPlayerHasTrinket(self, trinketType, ignoreModifiers)
99
110
  local players = getAllPlayers(nil)
100
111
  return __TS__ArraySome(
101
112
  players,
102
- function(____, player) return player:HasTrinket(trinketType) end
113
+ function(____, player) return player:HasTrinket(trinketType, ignoreModifiers) end
103
114
  )
104
115
  end
105
116
  --- Helper function to determine if the given character is present.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "30.4.5",
3
+ "version": "30.5.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -1,3 +1,10 @@
1
+ import {
2
+ CardType,
3
+ CollectibleType,
4
+ ModCallback,
5
+ PillEffect,
6
+ } from "isaac-typescript-definitions";
7
+ import { game } from "../../core/cachedClasses";
1
8
  import { ModCallbackCustom } from "../../enums/ModCallbackCustom";
2
9
  import { getPickups } from "../../functions/entitiesSpecific";
3
10
  import {
@@ -19,6 +26,7 @@ const v = {
19
26
  playersHoldingItemOnLastFrameMap: new DefaultMap<PlayerIndex, boolean>(
20
27
  false,
21
28
  ),
29
+ playersUsedItemOnFrame: new DefaultMap<PlayerIndex, int>(0),
22
30
  },
23
31
  };
24
32
 
@@ -28,6 +36,17 @@ export class PostPurchase extends CustomCallback<T> {
28
36
  constructor() {
29
37
  super();
30
38
 
39
+ this.callbacksUsed = [
40
+ // 3
41
+ [ModCallback.POST_USE_ITEM, this.postUseItem],
42
+
43
+ // 5
44
+ [ModCallback.POST_USE_CARD, this.postUseCard],
45
+
46
+ // 10
47
+ [ModCallback.POST_USE_PILL, this.postUsePill],
48
+ ];
49
+
31
50
  this.customCallbacksUsed = [
32
51
  [
33
52
  ModCallbackCustom.POST_PEFFECT_UPDATE_REORDERED,
@@ -51,6 +70,28 @@ export class PostPurchase extends CustomCallback<T> {
51
70
  );
52
71
  };
53
72
 
73
+ // ModCallback.POST_USE_ITEM (3)
74
+ private postUseItem = (
75
+ _collectibleType: CollectibleType,
76
+ _rng: RNG,
77
+ player: EntityPlayer,
78
+ ): boolean | undefined => {
79
+ markUsedItemOnThisFrame(player);
80
+ return undefined;
81
+ };
82
+
83
+ // ModCallback.POST_USE_CARD (5)
84
+ private postUseCard = (_cardType: CardType, player: EntityPlayer) => {
85
+ markUsedItemOnThisFrame(player);
86
+ return undefined;
87
+ };
88
+
89
+ // ModCallback.POST_USE_PILL (10)
90
+ private postUsePill = (_pillEffect: PillEffect, player: EntityPlayer) => {
91
+ markUsedItemOnThisFrame(player);
92
+ return undefined;
93
+ };
94
+
54
95
  // ModCallbackCustom.POST_PEFFECT_UPDATE_REORDERED
55
96
  private postPEffectUpdateReordered = (player: EntityPlayer) => {
56
97
  const isHoldingItem = player.IsHoldingItem();
@@ -64,11 +105,29 @@ export class PostPurchase extends CustomCallback<T> {
64
105
  isHoldingItem,
65
106
  );
66
107
 
67
- if (!wasHoldingItemOnLastFrame && isHoldingItem) {
108
+ // Assume that if the player did not use an active item, card, or pill recently, then they
109
+ // purchased an item.
110
+ if (
111
+ !wasHoldingItemOnLastFrame &&
112
+ isHoldingItem &&
113
+ !this.playerUsedItemRecently(player)
114
+ ) {
68
115
  this.playerPickedUpNewItem(player);
69
116
  }
70
117
  };
71
118
 
119
+ private playerUsedItemRecently(player: EntityPlayer): boolean {
120
+ const gameFrameCount = game.GetFrameCount();
121
+ const usedCollectibleOnFrame = defaultMapGetPlayer(
122
+ v.room.playersUsedItemOnFrame,
123
+ player,
124
+ );
125
+ return (
126
+ gameFrameCount === usedCollectibleOnFrame ||
127
+ gameFrameCount === usedCollectibleOnFrame + 1
128
+ );
129
+ }
130
+
72
131
  private playerPickedUpNewItem(player: EntityPlayer) {
73
132
  const pickups = getPickups();
74
133
  const disappearingPickup = pickups.find(
@@ -79,3 +138,8 @@ export class PostPurchase extends CustomCallback<T> {
79
138
  }
80
139
  }
81
140
  }
141
+
142
+ function markUsedItemOnThisFrame(player: EntityPlayer) {
143
+ const gameFrameCount = game.GetFrameCount();
144
+ mapSetPlayer(v.room.playersUsedItemOnFrame, player, gameFrameCount);
145
+ }
@@ -64,16 +64,39 @@ export function addTrinketCostume(
64
64
  player.AddCostume(itemConfigTrinket, false);
65
65
  }
66
66
 
67
+ /**
68
+ * Helper function to check to see if any player has a particular collectible.
69
+ *
70
+ * @param collectibleType The collectible type to check for.
71
+ * @param ignoreModifiers If set to true, only counts collectibles the player actually owns and
72
+ * ignores effects granted by items like Zodiac, 3 Dollar Bill and Lemegeton.
73
+ * Default is false.
74
+ */
67
75
  export function anyPlayerHasCollectible(
68
76
  collectibleType: CollectibleType,
77
+ ignoreModifiers?: boolean,
69
78
  ): boolean {
70
79
  const players = getAllPlayers();
71
- return players.some((player) => player.HasCollectible(collectibleType));
80
+ return players.some((player) =>
81
+ player.HasCollectible(collectibleType, ignoreModifiers),
82
+ );
72
83
  }
73
84
 
74
- export function anyPlayerHasTrinket(trinketType: TrinketType): boolean {
85
+ /**
86
+ * Helper function to check to see if any player has a particular trinket.
87
+ *
88
+ * @param trinketType The trinket type to check for.
89
+ * @param ignoreModifiers If set to true, only counts trinkets the player actually holds and ignores
90
+ * effects granted by other items. Default is false.
91
+ */
92
+ export function anyPlayerHasTrinket(
93
+ trinketType: TrinketType,
94
+ ignoreModifiers?: boolean,
95
+ ): boolean {
75
96
  const players = getAllPlayers();
76
- return players.some((player) => player.HasTrinket(trinketType));
97
+ return players.some((player) =>
98
+ player.HasTrinket(trinketType, ignoreModifiers),
99
+ );
77
100
  }
78
101
 
79
102
  /**