isaacscript-common 6.16.2 → 6.18.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.
- package/dist/enums/ModCallbackCustom.d.ts +1 -1
- package/dist/features/customGridEntity.d.ts +3 -3
- package/dist/features/customGridEntity.d.ts.map +1 -1
- package/dist/features/customGridEntity.lua +18 -11
- package/dist/features/extraConsoleCommands/listCommands.lua +2 -2
- package/dist/features/persistentEntities.d.ts.map +1 -1
- package/dist/features/persistentEntities.lua +15 -5
- package/dist/features/pickupIndex.d.ts.map +1 -1
- package/dist/features/pickupIndex.lua +5 -6
- package/dist/features/roomHistory.d.ts +11 -4
- package/dist/features/roomHistory.d.ts.map +1 -1
- package/dist/features/roomHistory.lua +18 -5
- package/dist/functions/log.d.ts +1 -1
- package/dist/functions/log.d.ts.map +1 -1
- package/dist/functions/log.lua +33 -28
- package/dist/functions/npcs.d.ts +9 -0
- package/dist/functions/npcs.d.ts.map +1 -1
- package/dist/functions/npcs.lua +16 -3
- package/dist/functions/playerHealth.d.ts.map +1 -1
- package/dist/functions/playerHealth.lua +29 -12
- package/dist/functions/rockAlt.d.ts +4 -4
- package/dist/functions/rockAlt.d.ts.map +1 -1
- package/dist/functions/rockAlt.lua +38 -87
- package/dist/functions/saveFile.d.ts +5 -0
- package/dist/functions/saveFile.d.ts.map +1 -1
- package/dist/functions/saveFile.lua +112 -3
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.lua +1 -9
- package/dist/interfaces/{CustomGridEntityData.d.ts → GridEntityCustomData.d.ts} +2 -2
- package/dist/interfaces/{CustomGridEntityData.d.ts.map → GridEntityCustomData.d.ts.map} +1 -1
- package/dist/interfaces/{CustomGridEntityData.lua → GridEntityCustomData.lua} +0 -0
- package/dist/interfaces/PlayerHealth.d.ts +4 -1
- package/dist/interfaces/PlayerHealth.d.ts.map +1 -1
- package/dist/interfaces/RoomDescription.d.ts +1 -0
- package/dist/interfaces/RoomDescription.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/enums/ModCallbackCustom.ts +1 -1
- package/src/features/customGridEntity.ts +30 -17
- package/src/features/extraConsoleCommands/listCommands.ts +2 -2
- package/src/features/persistentEntities.ts +19 -5
- package/src/features/pickupIndex.ts +9 -15
- package/src/features/roomHistory.ts +24 -4
- package/src/functions/log.ts +35 -30
- package/src/functions/npcs.ts +27 -2
- package/src/functions/playerHealth.ts +25 -12
- package/src/functions/rockAlt.ts +50 -132
- package/src/functions/saveFile.ts +146 -4
- package/src/index.ts +1 -2
- package/src/interfaces/{CustomGridEntityData.ts → GridEntityCustomData.ts} +1 -1
- package/src/interfaces/PlayerHealth.ts +12 -1
- package/src/interfaces/RoomDescription.ts +1 -0
- package/dist/functions/itemPool.d.ts +0 -10
- package/dist/functions/itemPool.d.ts.map +0 -1
- package/dist/functions/itemPool.lua +0 -116
- package/src/functions/itemPool.ts +0 -153
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CollectibleType,
|
|
3
|
-
ItemConfigTag,
|
|
4
|
-
ItemPoolType,
|
|
5
|
-
PlayerType,
|
|
6
|
-
TrinketType,
|
|
7
|
-
} from "isaac-typescript-definitions";
|
|
8
|
-
import { game } from "../cachedClasses";
|
|
9
|
-
import { PlayerIndex } from "../types/PlayerIndex";
|
|
10
|
-
import { getCollectibleSet } from "./collectibleSet";
|
|
11
|
-
import { collectibleHasTag } from "./collectibleTag";
|
|
12
|
-
import { mapGetPlayer, mapSetPlayer } from "./playerDataStructures";
|
|
13
|
-
import { getPlayers } from "./playerIndex";
|
|
14
|
-
import { getPlayersOfType } from "./players";
|
|
15
|
-
import { repeat } from "./utils";
|
|
16
|
-
|
|
17
|
-
const COLLECTIBLES_THAT_AFFECT_ITEM_POOLS: readonly CollectibleType[] = [
|
|
18
|
-
CollectibleType.CHAOS, // 402
|
|
19
|
-
CollectibleType.SACRED_ORB, // 691
|
|
20
|
-
CollectibleType.TMTRAINER, // 721
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
const TRINKETS_THAT_AFFECT_ITEM_POOLS: readonly TrinketType[] = [
|
|
24
|
-
TrinketType.NO,
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Helper function to see if the given collectible is still present in the given item pool.
|
|
29
|
-
*
|
|
30
|
-
* If the collectible is non-offensive, any Tainted Losts will be temporarily changed to Isaac and
|
|
31
|
-
* then changed back. (This is because Tainted Lost is not able to retrieve non-offensive
|
|
32
|
-
* collectibles from item pools).
|
|
33
|
-
*/
|
|
34
|
-
export function isCollectibleInItemPool(
|
|
35
|
-
collectibleType: CollectibleType,
|
|
36
|
-
itemPoolType: ItemPoolType,
|
|
37
|
-
): boolean {
|
|
38
|
-
// On Tainted Lost, it is impossible to retrieve non-offensive collectibles from pools, so we
|
|
39
|
-
// temporarily change the character to Isaac.
|
|
40
|
-
const taintedLosts = getPlayersOfType(PlayerType.THE_LOST_B);
|
|
41
|
-
const isOffensive = collectibleHasTag(
|
|
42
|
-
collectibleType,
|
|
43
|
-
ItemConfigTag.OFFENSIVE,
|
|
44
|
-
);
|
|
45
|
-
let changedPlayerTypes = false;
|
|
46
|
-
if (!isOffensive) {
|
|
47
|
-
changedPlayerTypes = true;
|
|
48
|
-
for (const player of taintedLosts) {
|
|
49
|
-
player.ChangePlayerType(PlayerType.ISAAC);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const [removedItemsMap, removedTrinketsMap] =
|
|
54
|
-
removeItemsAndTrinketsThatAffectItemPools();
|
|
55
|
-
|
|
56
|
-
// Blacklist every collectible in the game except for the provided collectible.
|
|
57
|
-
const itemPool = game.GetItemPool();
|
|
58
|
-
const collectibleSet = getCollectibleSet();
|
|
59
|
-
for (const collectibleTypeInSet of collectibleSet.values()) {
|
|
60
|
-
if (collectibleTypeInSet !== collectibleType) {
|
|
61
|
-
itemPool.AddRoomBlacklist(collectibleTypeInSet);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Get a collectible from the pool and see if it is the intended collectible. (We can use any
|
|
66
|
-
// arbitrary value as the seed since it should not influence the result.)
|
|
67
|
-
const retrievedCollectibleType = itemPool.GetCollectible(
|
|
68
|
-
itemPoolType,
|
|
69
|
-
false,
|
|
70
|
-
1 as Seed,
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
const collectibleUnlocked = retrievedCollectibleType === collectibleType;
|
|
74
|
-
|
|
75
|
-
// Reset the blacklist
|
|
76
|
-
itemPool.ResetRoomBlacklist();
|
|
77
|
-
|
|
78
|
-
restoreItemsAndTrinketsThatAffectItemPools(
|
|
79
|
-
removedItemsMap,
|
|
80
|
-
removedTrinketsMap,
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
// Change any players back to Tainted Lost, if necessary.
|
|
84
|
-
if (changedPlayerTypes) {
|
|
85
|
-
for (const player of taintedLosts) {
|
|
86
|
-
player.ChangePlayerType(PlayerType.THE_LOST_B);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return collectibleUnlocked;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Before checking the item pools, remove any collectibles or trinkets that would affect the
|
|
95
|
-
* retrieved collectible types.
|
|
96
|
-
*/
|
|
97
|
-
function removeItemsAndTrinketsThatAffectItemPools(): [
|
|
98
|
-
removedItemsMap: Map<PlayerIndex, CollectibleType[]>,
|
|
99
|
-
removedTrinketsMap: Map<PlayerIndex, TrinketType[]>,
|
|
100
|
-
] {
|
|
101
|
-
const removedItemsMap = new Map<PlayerIndex, CollectibleType[]>();
|
|
102
|
-
const removedTrinketsMap = new Map<PlayerIndex, TrinketType[]>();
|
|
103
|
-
for (const player of getPlayers()) {
|
|
104
|
-
const removedItems: CollectibleType[] = [];
|
|
105
|
-
for (const itemToRemove of COLLECTIBLES_THAT_AFFECT_ITEM_POOLS) {
|
|
106
|
-
if (player.HasCollectible(itemToRemove)) {
|
|
107
|
-
const numCollectibles = player.GetCollectibleNum(itemToRemove);
|
|
108
|
-
repeat(numCollectibles, () => {
|
|
109
|
-
player.RemoveCollectible(itemToRemove);
|
|
110
|
-
removedItems.push(itemToRemove);
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
mapSetPlayer(removedItemsMap, player, removedItems);
|
|
116
|
-
|
|
117
|
-
const removedTrinkets: TrinketType[] = [];
|
|
118
|
-
for (const trinketToRemove of TRINKETS_THAT_AFFECT_ITEM_POOLS) {
|
|
119
|
-
if (player.HasTrinket(trinketToRemove)) {
|
|
120
|
-
const numTrinkets = player.GetTrinketMultiplier(trinketToRemove);
|
|
121
|
-
repeat(numTrinkets, () => {
|
|
122
|
-
player.TryRemoveTrinket(trinketToRemove);
|
|
123
|
-
removedTrinkets.push(trinketToRemove);
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
mapSetPlayer(removedTrinketsMap, player, removedTrinkets);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return [removedItemsMap, removedTrinketsMap];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function restoreItemsAndTrinketsThatAffectItemPools(
|
|
135
|
-
removedItemsMap: Map<PlayerIndex, CollectibleType[]>,
|
|
136
|
-
removedTrinketsMap: Map<PlayerIndex, TrinketType[]>,
|
|
137
|
-
) {
|
|
138
|
-
for (const player of getPlayers()) {
|
|
139
|
-
const removedItems = mapGetPlayer(removedItemsMap, player);
|
|
140
|
-
if (removedItems !== undefined) {
|
|
141
|
-
for (const collectibleType of removedItems) {
|
|
142
|
-
player.AddCollectible(collectibleType, 0, false); // Prevent Chaos from spawning pickups
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const removedTrinkets = mapGetPlayer(removedTrinketsMap, player);
|
|
147
|
-
if (removedTrinkets !== undefined) {
|
|
148
|
-
for (const trinketType of removedTrinkets) {
|
|
149
|
-
player.AddTrinket(trinketType, false);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|