isaacscript-common 9.0.0 → 9.1.1
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/postPlayerCollectible.d.ts.map +1 -1
- package/dist/callbacks/postPlayerCollectible.lua +101 -27
- package/dist/enums/ModCallbackCustom.d.ts +4 -2
- package/dist/enums/ModCallbackCustom.d.ts.map +1 -1
- package/dist/features/playerInventory.d.ts.map +1 -1
- package/dist/features/playerInventory.lua +4 -50
- package/dist/functions/cards.d.ts.map +1 -1
- package/dist/functions/collectibleCacheFlag.d.ts +4 -1
- package/dist/functions/collectibleCacheFlag.d.ts.map +1 -1
- package/dist/functions/collectibleCacheFlag.lua +5 -2
- package/dist/functions/debug.d.ts +25 -0
- package/dist/functions/debug.d.ts.map +1 -1
- package/dist/functions/debug.lua +50 -0
- package/dist/functions/familiars.d.ts.map +1 -1
- package/dist/functions/itemPool.lua +9 -11
- package/dist/functions/log.d.ts +2 -7
- package/dist/functions/log.d.ts.map +1 -1
- package/dist/functions/log.lua +9 -31
- package/dist/functions/players.d.ts +6 -0
- package/dist/functions/players.d.ts.map +1 -1
- package/dist/functions/players.lua +7 -1
- package/dist/index.d.ts +16 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.lua +0 -8
- package/package.json +1 -1
- package/src/callbacks/postPlayerCollectible.ts +174 -38
- package/src/enums/ModCallbackCustom.ts +4 -2
- package/src/features/playerInventory.ts +5 -65
- package/src/functions/cards.ts +4 -2
- package/src/functions/collectibleCacheFlag.ts +6 -2
- package/src/functions/debug.ts +49 -0
- package/src/functions/familiars.ts +1 -0
- package/src/functions/itemPool.ts +6 -7
- package/src/functions/log.ts +15 -35
- package/src/functions/players.ts +14 -1
- package/src/index.ts +0 -1
- package/dist/functions/dev.d.ts +0 -20
- package/dist/functions/dev.d.ts.map +0 -1
- package/dist/functions/dev.lua +0 -34
- package/src/functions/dev.ts +0 -31
|
@@ -1 +1 @@
|
|
|
1
|
-
{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H,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAalE;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,IAAI,CAON;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,EAAE,UAAU,EACtB,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"}
|
|
@@ -219,6 +219,8 @@ end
|
|
|
219
219
|
-- collectible type(s) provided.
|
|
220
220
|
--
|
|
221
221
|
-- This function is variadic, meaning that you can specify N collectible types.
|
|
222
|
+
--
|
|
223
|
+
-- Note that this will filter out non-real collectibles like Lilith's Incubus.
|
|
222
224
|
function ____exports.getPlayerCollectibleCount(self, player, ...)
|
|
223
225
|
local collectibleTypes = {...}
|
|
224
226
|
local numCollectibles = 0
|
|
@@ -229,6 +231,8 @@ function ____exports.getPlayerCollectibleCount(self, player, ...)
|
|
|
229
231
|
end
|
|
230
232
|
--- Iterates over every item in the game and returns a map containing the number of each item that
|
|
231
233
|
-- the player has.
|
|
234
|
+
--
|
|
235
|
+
-- Note that this will filter out non-real collectibles like Lilith's Incubus.
|
|
232
236
|
function ____exports.getPlayerCollectibleMap(self, player)
|
|
233
237
|
local collectibleArray = getCollectibleArray(nil)
|
|
234
238
|
local collectibleMap = __TS__New(Map)
|
|
@@ -334,11 +338,13 @@ function ____exports.getPlayersWithTrinket(self, ...)
|
|
|
334
338
|
end
|
|
335
339
|
--- Returns the total number of collectibles amongst all players. For example, if player 1 has 1 Sad
|
|
336
340
|
-- Onion and player 2 has 2 Sad Onions, then this function would return 3.
|
|
341
|
+
--
|
|
342
|
+
-- Note that this will filter out non-real collectibles like Lilith's Incubus.
|
|
337
343
|
function ____exports.getTotalPlayerCollectibles(self, collectibleType)
|
|
338
344
|
local players = getPlayers(nil)
|
|
339
345
|
local numCollectiblesArray = __TS__ArrayMap(
|
|
340
346
|
players,
|
|
341
|
-
function(____, player) return player:GetCollectibleNum(collectibleType) end
|
|
347
|
+
function(____, player) return player:GetCollectibleNum(collectibleType, true) end
|
|
342
348
|
)
|
|
343
349
|
return sumArray(nil, numCollectiblesArray)
|
|
344
350
|
end
|
package/dist/index.d.ts
CHANGED
|
@@ -3926,18 +3926,22 @@ export declare function getPlayerCloserThan(position: Vector, distance: float):
|
|
|
3926
3926
|
* collectible type(s) provided.
|
|
3927
3927
|
*
|
|
3928
3928
|
* This function is variadic, meaning that you can specify N collectible types.
|
|
3929
|
+
*
|
|
3930
|
+
* Note that this will filter out non-real collectibles like Lilith's Incubus.
|
|
3929
3931
|
*/
|
|
3930
3932
|
export declare function getPlayerCollectibleCount(player: EntityPlayer, ...collectibleTypes: CollectibleType[]): int;
|
|
3931
3933
|
|
|
3932
3934
|
/**
|
|
3933
3935
|
* Iterates over every item in the game and returns a map containing the number of each item that
|
|
3934
3936
|
* the player has.
|
|
3937
|
+
*
|
|
3938
|
+
* Note that this will filter out non-real collectibles like Lilith's Incubus.
|
|
3935
3939
|
*/
|
|
3936
3940
|
export declare function getPlayerCollectibleMap(player: EntityPlayer): Map<CollectibleType, int>;
|
|
3937
3941
|
|
|
3938
3942
|
/**
|
|
3939
3943
|
* Returns an array containing every collectible type that the player has that matches the provided
|
|
3940
|
-
* CacheFlag
|
|
3944
|
+
* `CacheFlag`.
|
|
3941
3945
|
*
|
|
3942
3946
|
* For example, if the cache flag is `CacheFlag.FLYING`, and the player has one Lord of the Pit and
|
|
3943
3947
|
* two Dead Doves, then this function would return:
|
|
@@ -3950,6 +3954,9 @@ export declare function getPlayerCollectibleMap(player: EntityPlayer): Map<Colle
|
|
|
3950
3954
|
* ]
|
|
3951
3955
|
* ```
|
|
3952
3956
|
*
|
|
3957
|
+
* Note that this array will not include collectibles that the player does not really have, like
|
|
3958
|
+
* Lilith's Incubus.
|
|
3959
|
+
*
|
|
3953
3960
|
* This function can only be called if at least one callback has been executed. This is because not
|
|
3954
3961
|
* all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
3955
3962
|
*/
|
|
@@ -4983,6 +4990,8 @@ export declare function getTotalCharge(player: EntityPlayer, activeSlot: ActiveS
|
|
|
4983
4990
|
/**
|
|
4984
4991
|
* Returns the total number of collectibles amongst all players. For example, if player 1 has 1 Sad
|
|
4985
4992
|
* Onion and player 2 has 2 Sad Onions, then this function would return 3.
|
|
4993
|
+
*
|
|
4994
|
+
* Note that this will filter out non-real collectibles like Lilith's Incubus.
|
|
4986
4995
|
*/
|
|
4987
4996
|
export declare function getTotalPlayerCollectibles(collectibleType: CollectibleType): int;
|
|
4988
4997
|
|
|
@@ -6480,6 +6489,8 @@ export declare function logAllGridEntities(this: void, includeWalls: boolean, gr
|
|
|
6480
6489
|
|
|
6481
6490
|
export declare function logArray<T>(this: void, array: T[] | readonly T[]): void;
|
|
6482
6491
|
|
|
6492
|
+
export declare function logCollectibleTypes(this: void, collectibleTypes: CollectibleType[]): void;
|
|
6493
|
+
|
|
6483
6494
|
export declare function logColor(this: void, color: Color): void;
|
|
6484
6495
|
|
|
6485
6496
|
/** Helper function for printing out every damage flag that is turned on. Useful when debugging. */
|
|
@@ -7572,7 +7583,8 @@ export declare enum ModCallbackCustom {
|
|
|
7572
7583
|
POST_PLAYER_CHANGE_TYPE = 57,
|
|
7573
7584
|
/**
|
|
7574
7585
|
* Fires from the `POST_PEFFECT_UPDATE` callback when a player's collectible count is higher than
|
|
7575
|
-
* what it was on the previous frame or when
|
|
7586
|
+
* what it was on the previous frame, or when the active items change, or when the build is
|
|
7587
|
+
* rerolled.
|
|
7576
7588
|
*
|
|
7577
7589
|
* When registering the callback, takes an optional second argument that will make the callback
|
|
7578
7590
|
* only fire if the collectible matches the `CollectibleType` provided.
|
|
@@ -7587,7 +7599,8 @@ export declare enum ModCallbackCustom {
|
|
|
7587
7599
|
POST_PLAYER_COLLECTIBLE_ADDED = 58,
|
|
7588
7600
|
/**
|
|
7589
7601
|
* Fires from the `POST_PEFFECT_UPDATE` callback when a player's collectible count is lower than
|
|
7590
|
-
* what it was on the previous frame or when
|
|
7602
|
+
* what it was on the previous frame, or when the active items change, or when the build is
|
|
7603
|
+
* rerolled.
|
|
7591
7604
|
*
|
|
7592
7605
|
* When registering the callback, takes an optional second argument that will make the callback
|
|
7593
7606
|
* only fire if the collectible matches the `CollectibleType` provided.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,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AAChD,cAAc,mBAAmB,CAAC"}
|
package/dist/index.lua
CHANGED
|
@@ -551,14 +551,6 @@ do
|
|
|
551
551
|
end
|
|
552
552
|
end
|
|
553
553
|
end
|
|
554
|
-
do
|
|
555
|
-
local ____export = require("functions.dev")
|
|
556
|
-
for ____exportKey, ____exportValue in pairs(____export) do
|
|
557
|
-
if ____exportKey ~= "default" then
|
|
558
|
-
____exports[____exportKey] = ____exportValue
|
|
559
|
-
end
|
|
560
|
-
end
|
|
561
|
-
end
|
|
562
554
|
do
|
|
563
555
|
local ____export = require("functions.dimensions")
|
|
564
556
|
for ____exportKey, ____exportValue in pairs(____export) do
|
package/package.json
CHANGED
|
@@ -2,12 +2,22 @@
|
|
|
2
2
|
// - `POST_PLAYER_COLLECTIBLE_ADDED`
|
|
3
3
|
// - `POST_PLAYER_COLLECTIBLE_REMOVED`
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ActiveSlot,
|
|
7
|
+
CollectibleType,
|
|
8
|
+
DamageFlag,
|
|
9
|
+
EntityType,
|
|
10
|
+
ModCallback,
|
|
11
|
+
PlayerType,
|
|
12
|
+
} from "isaac-typescript-definitions";
|
|
6
13
|
import { DefaultMap } from "../classes/DefaultMap";
|
|
14
|
+
import { runNextGameFrame } from "../features/runInNFrames";
|
|
7
15
|
import { saveDataManager } from "../features/saveDataManager/exports";
|
|
16
|
+
import { arrayEquals } from "../functions/array";
|
|
17
|
+
import { getEnumValues } from "../functions/enums";
|
|
18
|
+
import { hasFlag } from "../functions/flag";
|
|
8
19
|
import {
|
|
9
20
|
defaultMapGetPlayer,
|
|
10
|
-
mapGetPlayer,
|
|
11
21
|
mapSetPlayer,
|
|
12
22
|
} from "../functions/playerDataStructures";
|
|
13
23
|
import { getPlayerCollectibleMap } from "../functions/players";
|
|
@@ -24,18 +34,28 @@ import {
|
|
|
24
34
|
|
|
25
35
|
const v = {
|
|
26
36
|
run: {
|
|
27
|
-
playersCollectibleCount: new
|
|
37
|
+
playersCollectibleCount: new DefaultMap<PlayerIndex, int>(0),
|
|
28
38
|
playersCollectibleMap: new DefaultMap<
|
|
29
39
|
PlayerIndex,
|
|
30
40
|
Map<CollectibleType, int>
|
|
31
41
|
>(() => new Map()),
|
|
42
|
+
playersActiveItemMap: new DefaultMap<
|
|
43
|
+
PlayerIndex,
|
|
44
|
+
Map<ActiveSlot, CollectibleType>
|
|
45
|
+
>(() => new Map()),
|
|
32
46
|
},
|
|
33
47
|
};
|
|
34
48
|
|
|
35
49
|
export function postPlayerCollectibleCallbacksInit(mod: Mod): void {
|
|
36
50
|
saveDataManager("postPlayerCollectible", v, hasSubscriptions);
|
|
37
51
|
|
|
52
|
+
mod.AddCallback(ModCallback.POST_USE_ITEM, useItemD4, CollectibleType.D4); // 3
|
|
38
53
|
mod.AddCallback(ModCallback.POST_PEFFECT_UPDATE, postPEffectUpdate); // 4
|
|
54
|
+
mod.AddCallback(
|
|
55
|
+
ModCallback.ENTITY_TAKE_DMG,
|
|
56
|
+
entityTakeDmgPlayer,
|
|
57
|
+
EntityType.PLAYER,
|
|
58
|
+
); // 11
|
|
39
59
|
}
|
|
40
60
|
|
|
41
61
|
function hasSubscriptions() {
|
|
@@ -45,36 +65,20 @@ function hasSubscriptions() {
|
|
|
45
65
|
);
|
|
46
66
|
}
|
|
47
67
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (oldCollectibleCount === undefined) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const difference = newCollectibleCount - oldCollectibleCount;
|
|
66
|
-
|
|
67
|
-
if (difference > 0) {
|
|
68
|
-
collectibleCountChanged(player, difference, true);
|
|
69
|
-
} else if (difference < 0) {
|
|
70
|
-
collectibleCountChanged(player, difference * -1, false);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function collectibleCountChanged(
|
|
68
|
+
/**
|
|
69
|
+
* This is called when the collectible count changes and in situations where the entire build is
|
|
70
|
+
* rerolled.
|
|
71
|
+
*
|
|
72
|
+
* Since getting a new player collectible map is expensive, we want to only run this function when
|
|
73
|
+
* necessary, and not on e.g. every frame. Unfortunately, this has the side effect of missing out on
|
|
74
|
+
* collectible changes from mods that add and remove a collectible on the same frame.
|
|
75
|
+
*
|
|
76
|
+
* @param player The player to update.
|
|
77
|
+
* @param numCollectiblesChanged Pass undefined for situations where the entire build was rerolled.
|
|
78
|
+
*/
|
|
79
|
+
function updateCollectibleMapAndFire(
|
|
75
80
|
player: EntityPlayer,
|
|
76
|
-
numCollectiblesChanged: int,
|
|
77
|
-
increased: boolean,
|
|
81
|
+
numCollectiblesChanged: int | undefined,
|
|
78
82
|
) {
|
|
79
83
|
const oldCollectibleMap = defaultMapGetPlayer(
|
|
80
84
|
v.run.playersCollectibleMap,
|
|
@@ -83,19 +87,20 @@ function collectibleCountChanged(
|
|
|
83
87
|
const newCollectibleMap = getPlayerCollectibleMap(player);
|
|
84
88
|
mapSetPlayer(v.run.playersCollectibleMap, player, newCollectibleMap);
|
|
85
89
|
|
|
86
|
-
const
|
|
90
|
+
const collectibleTypesSet = new Set<CollectibleType>([
|
|
87
91
|
...oldCollectibleMap.keys(),
|
|
88
92
|
...newCollectibleMap.keys(),
|
|
89
|
-
];
|
|
90
|
-
collectibleTypes.sort();
|
|
93
|
+
]);
|
|
91
94
|
|
|
92
95
|
let numFired = 0;
|
|
93
|
-
for (const collectibleType of
|
|
96
|
+
for (const collectibleType of collectibleTypesSet.values()) {
|
|
94
97
|
const oldNum = oldCollectibleMap.get(collectibleType) ?? 0;
|
|
95
98
|
const newNum = newCollectibleMap.get(collectibleType) ?? 0;
|
|
96
|
-
const difference =
|
|
99
|
+
const difference = newNum - oldNum;
|
|
100
|
+
const increased = difference > 0;
|
|
101
|
+
const absoluteDifference = Math.abs(difference);
|
|
97
102
|
|
|
98
|
-
repeat(
|
|
103
|
+
repeat(absoluteDifference, () => {
|
|
99
104
|
if (increased) {
|
|
100
105
|
postPlayerCollectibleAddedFire(player, collectibleType);
|
|
101
106
|
} else {
|
|
@@ -109,3 +114,134 @@ function collectibleCountChanged(
|
|
|
109
114
|
}
|
|
110
115
|
}
|
|
111
116
|
}
|
|
117
|
+
|
|
118
|
+
// ModCallback.POST_USE_ITEM (3)
|
|
119
|
+
// CollectibleType.D4 (284)
|
|
120
|
+
function useItemD4(
|
|
121
|
+
_collectibleType: CollectibleType,
|
|
122
|
+
_rng: RNG,
|
|
123
|
+
player: EntityPlayer,
|
|
124
|
+
): boolean | undefined {
|
|
125
|
+
// This function is also triggered for:
|
|
126
|
+
// - D100
|
|
127
|
+
// - D Infinity copying D4 or D100
|
|
128
|
+
// - 1-pip dice room
|
|
129
|
+
// - 6-pip dice room
|
|
130
|
+
// - Reverse Wheel of Fortune copying 1-pip or 6-pip dice room
|
|
131
|
+
// - First getting Missing No.
|
|
132
|
+
// - Arriving on a new floor with Missing No.
|
|
133
|
+
|
|
134
|
+
// This function is not triggered for:
|
|
135
|
+
// - Tainted Eden getting hit (this is explicitly handled elsewhere)
|
|
136
|
+
// - Genesis (which is automatically handled by the collectibles being removed in the normal
|
|
137
|
+
// `POST_PLAYER_COLLECTIBLE_REMOVED` callback)
|
|
138
|
+
updateCollectibleMapAndFire(player, undefined);
|
|
139
|
+
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// ModCallback.POST_PEFFECT_UPDATE (4)
|
|
144
|
+
function postPEffectUpdate(player: EntityPlayer) {
|
|
145
|
+
if (!hasSubscriptions()) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const oldCollectibleCount = defaultMapGetPlayer(
|
|
150
|
+
v.run.playersCollectibleCount,
|
|
151
|
+
player,
|
|
152
|
+
);
|
|
153
|
+
const newCollectibleCount = player.GetCollectibleCount();
|
|
154
|
+
mapSetPlayer(v.run.playersCollectibleCount, player, newCollectibleCount);
|
|
155
|
+
|
|
156
|
+
const difference = newCollectibleCount - oldCollectibleCount;
|
|
157
|
+
|
|
158
|
+
if (difference > 0) {
|
|
159
|
+
updateCollectibleMapAndFire(player, difference);
|
|
160
|
+
} else if (difference < 0) {
|
|
161
|
+
updateCollectibleMapAndFire(player, difference * -1);
|
|
162
|
+
} else if (difference === 0) {
|
|
163
|
+
checkActiveItemsChanged(player);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Checking for collectible count will work to detect when a player swaps their active item for
|
|
169
|
+
* another active item. This is because the collectible count will decrement by 1 when the item is
|
|
170
|
+
* swapped onto the pedestal and the hold animation begins, and increment by 1 when the item is
|
|
171
|
+
* dequeued and the hold animation ends.
|
|
172
|
+
*
|
|
173
|
+
* However, we also want to explicitly check for the case where a mod swaps in a custom active
|
|
174
|
+
* collectible on the same frame, since doing so is cheap.
|
|
175
|
+
*/
|
|
176
|
+
function checkActiveItemsChanged(player: EntityPlayer) {
|
|
177
|
+
const activeItemMap = defaultMapGetPlayer(v.run.playersActiveItemMap, player);
|
|
178
|
+
|
|
179
|
+
const oldCollectibleTypes: CollectibleType[] = [];
|
|
180
|
+
const newCollectibleTypes: CollectibleType[] = [];
|
|
181
|
+
|
|
182
|
+
for (const activeSlot of getEnumValues(ActiveSlot)) {
|
|
183
|
+
const oldCollectibleType =
|
|
184
|
+
activeItemMap.get(activeSlot) ?? CollectibleType.NULL;
|
|
185
|
+
const newCollectibleType = player.GetActiveItem(activeSlot);
|
|
186
|
+
activeItemMap.set(activeSlot, newCollectibleType);
|
|
187
|
+
|
|
188
|
+
oldCollectibleTypes.push(oldCollectibleType);
|
|
189
|
+
newCollectibleTypes.push(newCollectibleType);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// For example, it is possible for the player to switch Schoolbag items, which will cause the
|
|
193
|
+
// collectibles in the array to be the same, but in a different order. Thus, we sort both arrays
|
|
194
|
+
// before comparing them.
|
|
195
|
+
oldCollectibleTypes.sort();
|
|
196
|
+
newCollectibleTypes.sort();
|
|
197
|
+
|
|
198
|
+
if (!arrayEquals(oldCollectibleTypes, newCollectibleTypes)) {
|
|
199
|
+
// One or more active items have changed (with the player's total collectible count remaining
|
|
200
|
+
// the same).
|
|
201
|
+
updateCollectibleMapAndFire(player, undefined);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// ModCallback.ENTITY_TAKE_DMG (11)
|
|
206
|
+
// EntityType.PLAYER (1)
|
|
207
|
+
// We need to handle the case of Tainted Eden taking damage.
|
|
208
|
+
function entityTakeDmgPlayer(
|
|
209
|
+
entity: Entity,
|
|
210
|
+
_amount: float,
|
|
211
|
+
damageFlags: BitFlags<DamageFlag>,
|
|
212
|
+
_source: EntityRef,
|
|
213
|
+
_countdownFrames: int,
|
|
214
|
+
): boolean | undefined {
|
|
215
|
+
// Tainted Eden's mechanic does not apply if she e.g. uses Dull Razor.
|
|
216
|
+
if (hasFlag(damageFlags, DamageFlag.FAKE)) {
|
|
217
|
+
return undefined;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const player = entity.ToPlayer();
|
|
221
|
+
if (player === undefined) {
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const character = player.GetPlayerType();
|
|
226
|
+
if (character !== PlayerType.EDEN_B) {
|
|
227
|
+
return undefined;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// The items will only be rerolled after the damage is successfully applied.
|
|
231
|
+
const ptr = EntityPtr(player);
|
|
232
|
+
runNextGameFrame(() => {
|
|
233
|
+
const futureEntity = ptr.Ref;
|
|
234
|
+
if (futureEntity === undefined) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const futurePlayer = futureEntity.ToPlayer();
|
|
239
|
+
if (futurePlayer === undefined) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
updateCollectibleMapAndFire(player, undefined);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
return undefined;
|
|
247
|
+
}
|
|
@@ -959,7 +959,8 @@ export enum ModCallbackCustom {
|
|
|
959
959
|
|
|
960
960
|
/**
|
|
961
961
|
* Fires from the `POST_PEFFECT_UPDATE` callback when a player's collectible count is higher than
|
|
962
|
-
* what it was on the previous frame or when
|
|
962
|
+
* what it was on the previous frame, or when the active items change, or when the build is
|
|
963
|
+
* rerolled.
|
|
963
964
|
*
|
|
964
965
|
* When registering the callback, takes an optional second argument that will make the callback
|
|
965
966
|
* only fire if the collectible matches the `CollectibleType` provided.
|
|
@@ -975,7 +976,8 @@ export enum ModCallbackCustom {
|
|
|
975
976
|
|
|
976
977
|
/**
|
|
977
978
|
* Fires from the `POST_PEFFECT_UPDATE` callback when a player's collectible count is lower than
|
|
978
|
-
* what it was on the previous frame or when
|
|
979
|
+
* what it was on the previous frame, or when the active items change, or when the build is
|
|
980
|
+
* rerolled.
|
|
979
981
|
*
|
|
980
982
|
* When registering the callback, takes an optional second argument that will make the callback
|
|
981
983
|
* only fire if the collectible matches the `CollectibleType` provided.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CollectibleType
|
|
1
|
+
import { CollectibleType } from "isaac-typescript-definitions";
|
|
2
2
|
import { DefaultMap } from "../classes/DefaultMap";
|
|
3
3
|
import { ModUpgraded } from "../classes/ModUpgraded";
|
|
4
4
|
import { ModCallbackCustom } from "../enums/ModCallbackCustom";
|
|
@@ -9,13 +9,7 @@ import {
|
|
|
9
9
|
getLastElement,
|
|
10
10
|
} from "../functions/array";
|
|
11
11
|
import { isActiveCollectible } from "../functions/collectibles";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
defaultMapGetPlayer,
|
|
15
|
-
mapSetPlayer,
|
|
16
|
-
} from "../functions/playerDataStructures";
|
|
17
|
-
import { getAllPlayers, getPlayerIndex } from "../functions/playerIndex";
|
|
18
|
-
import { repeat } from "../functions/utils";
|
|
12
|
+
import { defaultMapGetPlayer } from "../functions/playerDataStructures";
|
|
19
13
|
import { PlayerIndex } from "../types/PlayerIndex";
|
|
20
14
|
import { saveDataManager } from "./saveDataManager/exports";
|
|
21
15
|
|
|
@@ -27,40 +21,14 @@ const v = {
|
|
|
27
21
|
PlayerIndex,
|
|
28
22
|
CollectibleType[],
|
|
29
23
|
[player: EntityPlayer]
|
|
30
|
-
>((
|
|
24
|
+
>(() => []),
|
|
31
25
|
},
|
|
32
26
|
};
|
|
33
27
|
|
|
34
|
-
function newPlayerInventory(player: EntityPlayer) {
|
|
35
|
-
const inventory: CollectibleType[] = [];
|
|
36
|
-
|
|
37
|
-
for (const collectibleType of getCollectibleArray()) {
|
|
38
|
-
// We have to use the `EntityPlayer.HasCollectible` method in addition to the
|
|
39
|
-
// `EntityPlayer.GetCollectibleNum` method in order to mitigate situations like Lilith's Incubus
|
|
40
|
-
// counting as a collectible. (The former method will return false for her innate Incubus, but
|
|
41
|
-
// the latter method will return 1.)
|
|
42
|
-
if (player.HasCollectible(collectibleType)) {
|
|
43
|
-
const numCollectibles = player.GetCollectibleNum(collectibleType, true);
|
|
44
|
-
repeat(numCollectibles, () => {
|
|
45
|
-
inventory.push(collectibleType);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return inventory;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function resetInventory(player: EntityPlayer) {
|
|
54
|
-
const inventory = newPlayerInventory(player);
|
|
55
|
-
mapSetPlayer(v.run.playersInventory, player, inventory);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
28
|
/** @internal */
|
|
59
29
|
export function playerInventoryInit(mod: ModUpgraded): void {
|
|
60
30
|
saveDataManager(FEATURE_NAME, v);
|
|
61
31
|
|
|
62
|
-
mod.AddCallback(ModCallback.POST_USE_ITEM, useItemD4, CollectibleType.D4); // 3
|
|
63
|
-
mod.AddCallback(ModCallback.POST_GAME_STARTED, postGameStarted); // 15
|
|
64
32
|
mod.AddCallbackCustom(
|
|
65
33
|
ModCallbackCustom.POST_PLAYER_COLLECTIBLE_ADDED,
|
|
66
34
|
postCollectibleAdded,
|
|
@@ -71,33 +39,6 @@ export function playerInventoryInit(mod: ModUpgraded): void {
|
|
|
71
39
|
);
|
|
72
40
|
}
|
|
73
41
|
|
|
74
|
-
// ModCallback.POST_USE_ITEM (3)
|
|
75
|
-
// CollectibleType.D4 (284)
|
|
76
|
-
function useItemD4(
|
|
77
|
-
_collectibleType: CollectibleType,
|
|
78
|
-
_rng: RNG,
|
|
79
|
-
player: EntityPlayer,
|
|
80
|
-
): boolean | undefined {
|
|
81
|
-
// This function is also triggered when the player uses D100, D Infinity, a 1-pip dice room, or a
|
|
82
|
-
// 6-pip dice room. (Genesis should be automatically handled by the
|
|
83
|
-
// `POST_PLAYER_COLLECTIBLE_REMOVED` callback.)
|
|
84
|
-
resetInventory(player);
|
|
85
|
-
|
|
86
|
-
return undefined;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// ModCallback.POST_GAME_STARTED (15)
|
|
90
|
-
function postGameStarted() {
|
|
91
|
-
// We don't use the `POST_PLAYER_INIT` callback because some items are not given to the player at
|
|
92
|
-
// that point.
|
|
93
|
-
for (const player of getAllPlayers()) {
|
|
94
|
-
const playerIndex = getPlayerIndex(player);
|
|
95
|
-
if (!v.run.playersInventory.has(playerIndex)) {
|
|
96
|
-
resetInventory(player);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
42
|
// ModCallbackCustom.POST_PLAYER_COLLECTIBLE_ADDED
|
|
102
43
|
function postCollectibleAdded(
|
|
103
44
|
player: EntityPlayer,
|
|
@@ -144,12 +85,11 @@ export function getPlayerInventory(
|
|
|
144
85
|
|
|
145
86
|
const inventory = defaultMapGetPlayer(v.run.playersInventory, player, player);
|
|
146
87
|
|
|
147
|
-
const copiedInventory = copyArray(inventory);
|
|
148
88
|
if (includeActiveCollectibles) {
|
|
149
|
-
return
|
|
89
|
+
return copyArray(inventory);
|
|
150
90
|
}
|
|
151
91
|
|
|
152
|
-
return
|
|
92
|
+
return inventory.filter(
|
|
153
93
|
(collectibleType) => !isActiveCollectible(collectibleType),
|
|
154
94
|
);
|
|
155
95
|
}
|
package/src/functions/cards.ts
CHANGED
|
@@ -73,7 +73,8 @@ export function getCardDescription(cardType: CardType): string {
|
|
|
73
73
|
// "ItemConfigCard.Description" is bugged with vanilla cards on patch v1.7.6, so we use a
|
|
74
74
|
// hard-coded map as a workaround.
|
|
75
75
|
const cardDescription = CARD_DESCRIPTIONS[cardType];
|
|
76
|
-
|
|
76
|
+
// Handle modded cards.
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
77
78
|
if (cardDescription !== undefined) {
|
|
78
79
|
return cardDescription;
|
|
79
80
|
}
|
|
@@ -95,7 +96,8 @@ export function getCardName(cardType: CardType): string {
|
|
|
95
96
|
// "ItemConfigCard.Name" is bugged with vanilla cards on patch v1.7.6, so we use a hard-coded map
|
|
96
97
|
// as a workaround.
|
|
97
98
|
const cardName = CARD_NAMES[cardType];
|
|
98
|
-
|
|
99
|
+
// Handle modded cards.
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
99
101
|
if (cardName !== undefined) {
|
|
100
102
|
return cardName;
|
|
101
103
|
}
|
|
@@ -64,7 +64,7 @@ export function getCollectiblesForCacheFlag(
|
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Returns an array containing every collectible type that the player has that matches the provided
|
|
67
|
-
* CacheFlag
|
|
67
|
+
* `CacheFlag`.
|
|
68
68
|
*
|
|
69
69
|
* For example, if the cache flag is `CacheFlag.FLYING`, and the player has one Lord of the Pit and
|
|
70
70
|
* two Dead Doves, then this function would return:
|
|
@@ -77,6 +77,9 @@ export function getCollectiblesForCacheFlag(
|
|
|
77
77
|
* ]
|
|
78
78
|
* ```
|
|
79
79
|
*
|
|
80
|
+
* Note that this array will not include collectibles that the player does not really have, like
|
|
81
|
+
* Lilith's Incubus.
|
|
82
|
+
*
|
|
80
83
|
* This function can only be called if at least one callback has been executed. This is because not
|
|
81
84
|
* all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
82
85
|
*/
|
|
@@ -88,7 +91,8 @@ export function getPlayerCollectiblesForCacheFlag(
|
|
|
88
91
|
|
|
89
92
|
const playerCollectibles: CollectibleType[] = [];
|
|
90
93
|
for (const collectibleType of getSortedSetValues(collectiblesForCacheFlag)) {
|
|
91
|
-
|
|
94
|
+
// We specify "true" as the second argument to filter out things like Lilith's Incubus.
|
|
95
|
+
const numCollectibles = player.GetCollectibleNum(collectibleType, true);
|
|
92
96
|
repeat(numCollectibles, () => {
|
|
93
97
|
playerCollectibles.push(collectibleType);
|
|
94
98
|
});
|