isaacscript-common 1.2.38 → 1.2.39
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/functions/familiars.d.ts +17 -0
- package/dist/functions/familiars.lua +53 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.lua +0 -8
- package/dist/upgradeMod.lua +0 -3
- package/package.json +1 -1
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to add and remove familiars based on the amount of associated collectibles that a
|
|
4
|
+
* player has. Use this instead of the `EntityPlayer.CheckFamiliar` method so that the InitSeed of
|
|
5
|
+
* the spawned familiar will be set properly and Box of Friends functions correctly.
|
|
6
|
+
*
|
|
7
|
+
* This function is meant to be called in the EvaluateCache callback (when the cache flag is equal
|
|
8
|
+
* to `CacheFlag.CACHE_FAMILIARS`).
|
|
9
|
+
*
|
|
10
|
+
* @param player The player that has the collectibles for this familiar.
|
|
11
|
+
* @param collectibleType The collectible type of the collectible associated with this familiar.
|
|
12
|
+
* @param familiarVariant The variant of the familiar to spawn or remove.
|
|
13
|
+
* @param familiarSubType Optional. The sub-type of the familiar to spawn or remove. 0 by default.
|
|
14
|
+
* @returns The amount of familiars that were added or removed. For example, the player has 0
|
|
15
|
+
* collectibles and there were 2 familiars, this function would remove the 2 familiars and return
|
|
16
|
+
* -2.
|
|
17
|
+
*/
|
|
18
|
+
export declare function checkFamiliar(player: EntityPlayer, collectibleType: int, familiarVariant: int, familiarSubType?: int): int;
|
|
2
19
|
/**
|
|
3
20
|
* Helper function to get all of the familiars in the room.
|
|
4
21
|
*
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____lualib = require("lualib_bundle")
|
|
3
3
|
local Set = ____lualib.Set
|
|
4
|
+
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
4
5
|
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
5
6
|
local ____exports = {}
|
|
6
7
|
local ____constants = require("constants")
|
|
@@ -25,6 +26,58 @@ function ____exports.getFamiliars(self, matchingVariant, matchingSubType)
|
|
|
25
26
|
end
|
|
26
27
|
return familiars
|
|
27
28
|
end
|
|
29
|
+
function ____exports.checkFamiliar(self, player, collectibleType, familiarVariant, familiarSubType)
|
|
30
|
+
local game = Game()
|
|
31
|
+
local familiarSubTypeToSearchFor = familiarSubType == nil and -1 or familiarSubType
|
|
32
|
+
local playerPtrHash = GetPtrHash(player)
|
|
33
|
+
local familiars = ____exports.getFamiliars(nil, familiarVariant, familiarSubTypeToSearchFor)
|
|
34
|
+
local familiarsForThisPlayer = __TS__ArrayFilter(
|
|
35
|
+
familiars,
|
|
36
|
+
function(____, familiar) return GetPtrHash(familiar.Player) == playerPtrHash end
|
|
37
|
+
)
|
|
38
|
+
local numCollectibles = player:GetCollectibleNum(collectibleType)
|
|
39
|
+
local effects = player:GetEffects()
|
|
40
|
+
local numBoxOfFriendsUses = effects:GetCollectibleEffectNum(CollectibleType.COLLECTIBLE_BOX_OF_FRIENDS)
|
|
41
|
+
local numFamiliarsThatShouldExist = numCollectibles * (numBoxOfFriendsUses + 1)
|
|
42
|
+
if #familiarsForThisPlayer == numFamiliarsThatShouldExist then
|
|
43
|
+
return 0
|
|
44
|
+
end
|
|
45
|
+
if #familiarsForThisPlayer > numFamiliarsThatShouldExist then
|
|
46
|
+
local numFamiliarsToRemove = #familiarsForThisPlayer - numFamiliarsThatShouldExist
|
|
47
|
+
do
|
|
48
|
+
local i = 0
|
|
49
|
+
while i < numFamiliarsToRemove do
|
|
50
|
+
local familiar = familiarsForThisPlayer[i + 1]
|
|
51
|
+
familiar:Remove()
|
|
52
|
+
i = i + 1
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
return numFamiliarsToRemove * -1
|
|
56
|
+
end
|
|
57
|
+
local numFamiliarsToSpawn = numFamiliarsThatShouldExist - #familiarsForThisPlayer
|
|
58
|
+
local collectibleRNG = player:GetCollectibleRNG(collectibleType)
|
|
59
|
+
local familiarSubTypeToUse = familiarSubType == nil and 0 or familiarSubType
|
|
60
|
+
do
|
|
61
|
+
local i = 0
|
|
62
|
+
while i < numFamiliarsToSpawn do
|
|
63
|
+
collectibleRNG:Next()
|
|
64
|
+
local familiar = game:Spawn(
|
|
65
|
+
EntityType.ENTITY_FAMILIAR,
|
|
66
|
+
familiarVariant,
|
|
67
|
+
player.Position,
|
|
68
|
+
Vector.Zero,
|
|
69
|
+
player,
|
|
70
|
+
familiarSubTypeToUse,
|
|
71
|
+
collectibleRNG:GetSeed()
|
|
72
|
+
):ToFamiliar()
|
|
73
|
+
if familiar ~= nil then
|
|
74
|
+
familiar.Player = player
|
|
75
|
+
end
|
|
76
|
+
i = i + 1
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
return numFamiliarsToSpawn
|
|
80
|
+
end
|
|
28
81
|
function ____exports.isFamiliarThatShootsPlayerTears(self, familiar)
|
|
29
82
|
return FAMILIARS_THAT_SHOOT_PLAYER_TEARS:has(familiar.Type)
|
|
30
83
|
end
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { forceNewLevelCallback, forceNewRoomCallback, } from "./callbacks/reorderedCallbacks";
|
|
2
2
|
export * from "./constants";
|
|
3
|
-
export * from "./features/checkFamiliar";
|
|
4
3
|
export { deployJSONRoom, deployRandomJSONRoom, emptyRoom, } from "./features/deployJSONRoom";
|
|
5
4
|
export { disableAllInputs, disableAllInputsExceptFor, disableMovementInputs, disableShootingInputs, enableAllInputs, enableAllInputsExceptFor, } from "./features/disableInputs";
|
|
6
5
|
export { forgottenSwitch } from "./features/forgottenSwitch";
|
package/dist/index.lua
CHANGED
|
@@ -15,14 +15,6 @@ do
|
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
|
-
do
|
|
19
|
-
local ____export = require("features.checkFamiliar")
|
|
20
|
-
for ____exportKey, ____exportValue in pairs(____export) do
|
|
21
|
-
if ____exportKey ~= "default" then
|
|
22
|
-
____exports[____exportKey] = ____exportValue
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
18
|
do
|
|
27
19
|
local ____deployJSONRoom = require("features.deployJSONRoom")
|
|
28
20
|
local deployJSONRoom = ____deployJSONRoom.deployJSONRoom
|
package/dist/upgradeMod.lua
CHANGED
|
@@ -69,8 +69,6 @@ local ____preNewLevel = require("callbacks.preNewLevel")
|
|
|
69
69
|
local preNewLevelCallbackInit = ____preNewLevel.preNewLevelCallbackInit
|
|
70
70
|
local ____reorderedCallbacks = require("callbacks.reorderedCallbacks")
|
|
71
71
|
local reorderedCallbacksInit = ____reorderedCallbacks.reorderedCallbacksInit
|
|
72
|
-
local ____checkFamiliar = require("features.checkFamiliar")
|
|
73
|
-
local checkFamiliarInit = ____checkFamiliar.checkFamiliarInit
|
|
74
72
|
local ____deployJSONRoom = require("features.deployJSONRoom")
|
|
75
73
|
local deployJSONRoomInit = ____deployJSONRoom.deployJSONRoomInit
|
|
76
74
|
local ____disableInputs = require("features.disableInputs")
|
|
@@ -129,7 +127,6 @@ function initCustomCallbacks(self, mod)
|
|
|
129
127
|
postGridEntityCollisionInit(nil, mod)
|
|
130
128
|
end
|
|
131
129
|
function initFeatures(self, mod)
|
|
132
|
-
checkFamiliarInit(nil, mod)
|
|
133
130
|
deployJSONRoomInit(nil, mod)
|
|
134
131
|
disableInputsInit(nil, mod)
|
|
135
132
|
forgottenSwitchInit(nil, mod)
|