isaacscript-common 1.2.189 → 1.2.192
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/features/characterStats.d.ts +19 -0
- package/dist/features/characterStats.lua +77 -0
- package/dist/functions/cacheFlag.d.ts +4 -3
- package/dist/functions/cacheFlag.lua +1 -2
- package/dist/functions/utils.d.ts +15 -0
- package/dist/functions/utils.lua +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.lua +8 -0
- package/dist/maps/defaultPlayerStatMap.d.ts +2 -1
- package/dist/maps/defaultPlayerStatMap.lua +17 -9
- package/dist/upgradeMod.lua +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to manage the stats for a vanilla or custom character. Call this function once at
|
|
4
|
+
* the beginning of your mod to declare the starting stats.
|
|
5
|
+
*
|
|
6
|
+
* You must provide this function with a map of CacheFlag to the default stat amount. For example,
|
|
7
|
+
* the default amount of damage is 3.5. To make a custom character start with 4.5 damage:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* const fooDefaultStats = new Map<CacheFlag, number>([
|
|
11
|
+
* [CacheFlag.CACHE_DAMAGE, 4.5],
|
|
12
|
+
* ])
|
|
13
|
+
* registerCharacterStats(PlayerTypeCustom.FOO, fooDefaultStats);
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* Note that the format for the `CacheFlag.CACHE_FIREDELAY` value should be in the tears stat
|
|
17
|
+
* format, not the `MaxFireDelay` format.
|
|
18
|
+
*/
|
|
19
|
+
export declare function registerCharacterStats(playerType: PlayerType | int, statMap: Map<CacheFlag, number>): void;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local Map = ____lualib.Map
|
|
3
|
+
local __TS__New = ____lualib.__TS__New
|
|
4
|
+
local ____exports = {}
|
|
5
|
+
local evaluateCache, charactersStatMap
|
|
6
|
+
local ____featuresInitialized = require("featuresInitialized")
|
|
7
|
+
local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
|
|
8
|
+
local ____cacheFlag = require("functions.cacheFlag")
|
|
9
|
+
local getDefaultPlayerStat = ____cacheFlag.getDefaultPlayerStat
|
|
10
|
+
local ____tears = require("functions.tears")
|
|
11
|
+
local addTearsStat = ____tears.addTearsStat
|
|
12
|
+
function evaluateCache(self, player, cacheFlag)
|
|
13
|
+
local character = player:GetPlayerType()
|
|
14
|
+
local statMap = charactersStatMap:get(character)
|
|
15
|
+
if statMap == nil then
|
|
16
|
+
return
|
|
17
|
+
end
|
|
18
|
+
local stat = statMap:get(cacheFlag)
|
|
19
|
+
local defaultStat = getDefaultPlayerStat(nil, cacheFlag)
|
|
20
|
+
if stat == nil or defaultStat == nil then
|
|
21
|
+
return
|
|
22
|
+
end
|
|
23
|
+
local delta = stat - defaultStat
|
|
24
|
+
repeat
|
|
25
|
+
local ____switch6 = cacheFlag
|
|
26
|
+
local ____cond6 = ____switch6 == CacheFlag.CACHE_DAMAGE
|
|
27
|
+
if ____cond6 then
|
|
28
|
+
do
|
|
29
|
+
player.Damage = player.Damage + delta
|
|
30
|
+
return
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
____cond6 = ____cond6 or ____switch6 == CacheFlag.CACHE_FIREDELAY
|
|
34
|
+
if ____cond6 then
|
|
35
|
+
do
|
|
36
|
+
addTearsStat(nil, player, delta)
|
|
37
|
+
return
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
____cond6 = ____cond6 or ____switch6 == CacheFlag.CACHE_SHOTSPEED
|
|
41
|
+
if ____cond6 then
|
|
42
|
+
do
|
|
43
|
+
player.ShotSpeed = player.ShotSpeed + delta
|
|
44
|
+
break
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
____cond6 = ____cond6 or ____switch6 == CacheFlag.CACHE_RANGE
|
|
48
|
+
if ____cond6 then
|
|
49
|
+
do
|
|
50
|
+
player.TearHeight = player.TearHeight + delta
|
|
51
|
+
break
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
____cond6 = ____cond6 or ____switch6 == CacheFlag.CACHE_SPEED
|
|
55
|
+
if ____cond6 then
|
|
56
|
+
do
|
|
57
|
+
player.MoveSpeed = player.MoveSpeed + delta
|
|
58
|
+
break
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
do
|
|
62
|
+
do
|
|
63
|
+
break
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
until true
|
|
67
|
+
end
|
|
68
|
+
local FEATURE_NAME = "character stat manager"
|
|
69
|
+
charactersStatMap = __TS__New(Map)
|
|
70
|
+
function ____exports.characterStatsInit(self, mod)
|
|
71
|
+
mod:AddCallback(ModCallbacks.MC_EVALUATE_CACHE, evaluateCache)
|
|
72
|
+
end
|
|
73
|
+
function ____exports.registerCharacterStats(self, playerType, statMap)
|
|
74
|
+
errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
|
|
75
|
+
charactersStatMap:set(playerType, statMap)
|
|
76
|
+
end
|
|
77
|
+
return ____exports
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
2
|
/**
|
|
3
|
-
* Returns the starting stat that Isaac (the default character) starts with.
|
|
3
|
+
* Returns the starting stat that Isaac (the default character) starts with. For example, if you
|
|
4
|
+
* pass this function `CacheFlag.CACHE_DAMAGE`, it will return 3.5.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
+
* Note that the default fire delay is represented in the tear stat, not the `MaxFireDelay` value.
|
|
6
7
|
*/
|
|
7
|
-
export declare function getDefaultPlayerStat(cacheFlag: CacheFlag):
|
|
8
|
+
export declare function getDefaultPlayerStat(cacheFlag: CacheFlag): number | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
local Map = ____lualib.Map
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
3
2
|
local ____exports = {}
|
|
4
3
|
local ____defaultPlayerStatMap = require("maps.defaultPlayerStatMap")
|
|
5
4
|
local DEFAULT_PLAYER_STAT_MAP = ____defaultPlayerStatMap.DEFAULT_PLAYER_STAT_MAP
|
|
@@ -36,6 +36,21 @@
|
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
38
|
export declare const ensureAllCases: (obj: never) => never;
|
|
39
|
+
/**
|
|
40
|
+
* TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
|
|
41
|
+
* when you iterate over them, you will get both the names of the enums and the values of the enums,
|
|
42
|
+
* in a random order. If all you need are the keys of an enum, use this helper function.
|
|
43
|
+
*
|
|
44
|
+
* This function will return the enum keys in a sorted order, which may not necessarily be the same
|
|
45
|
+
* order as which they were declared in.
|
|
46
|
+
*
|
|
47
|
+
* This function will work properly for both number enums and string enums. (Reverse mappings are
|
|
48
|
+
* not created for string enums.)
|
|
49
|
+
*
|
|
50
|
+
* For a more in depth explanation, see:
|
|
51
|
+
* https://isaacscript.github.io/docs/gotchas#iterating-over-enums
|
|
52
|
+
*/
|
|
53
|
+
export declare function getEnumKeys<T>(transpiledEnum: T): string[];
|
|
39
54
|
/**
|
|
40
55
|
* TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
|
|
41
56
|
* when you iterate over them, you will get both the names of the enums and the values of the enums,
|
package/dist/functions/utils.lua
CHANGED
|
@@ -6,6 +6,16 @@ local __TS__StringSubstr = ____lualib.__TS__StringSubstr
|
|
|
6
6
|
local ____exports = {}
|
|
7
7
|
local HEX_STRING_LENGTH = 6
|
|
8
8
|
____exports.ensureAllCases = function(____, obj) return obj end
|
|
9
|
+
function ____exports.getEnumKeys(self, transpiledEnum)
|
|
10
|
+
local enumKeys = {}
|
|
11
|
+
for key in pairs(transpiledEnum) do
|
|
12
|
+
if type(key) == "string" then
|
|
13
|
+
__TS__ArrayPush(enumKeys, key)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
__TS__ArraySort(enumKeys)
|
|
17
|
+
return enumKeys
|
|
18
|
+
end
|
|
9
19
|
function ____exports.getEnumValues(self, transpiledEnum)
|
|
10
20
|
local enumValues = {}
|
|
11
21
|
for key, value in pairs(transpiledEnum) do
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from "./enums/PillEffectClass";
|
|
|
12
12
|
export * from "./enums/PillEffectType";
|
|
13
13
|
export * from "./enums/PocketItemType";
|
|
14
14
|
export * from "./enums/SerializationType";
|
|
15
|
+
export * from "./features/characterStats";
|
|
15
16
|
export { deployJSONRoom, deployRandomJSONRoom, emptyRoom, } from "./features/deployJSONRoom";
|
|
16
17
|
export { disableAllInputs, disableAllInputsExceptFor, disableMovementInputs, disableShootingInputs, enableAllInputs, enableAllInputsExceptFor, } from "./features/disableInputs";
|
|
17
18
|
export { disableAllSound, enableAllSound } from "./features/disableSound";
|
package/dist/index.lua
CHANGED
|
@@ -110,6 +110,14 @@ do
|
|
|
110
110
|
end
|
|
111
111
|
end
|
|
112
112
|
end
|
|
113
|
+
do
|
|
114
|
+
local ____export = require("features.characterStats")
|
|
115
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
116
|
+
if ____exportKey ~= "default" then
|
|
117
|
+
____exports[____exportKey] = ____exportValue
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
113
121
|
do
|
|
114
122
|
local ____deployJSONRoom = require("features.deployJSONRoom")
|
|
115
123
|
local deployJSONRoom = ____deployJSONRoom.deployJSONRoom
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
-
|
|
2
|
+
/** The default fire delay is represented in the tear stat, not the `MaxFireDelay` value. */
|
|
3
|
+
export declare const DEFAULT_PLAYER_STAT_MAP: ReadonlyMap<CacheFlag, number>;
|
|
@@ -2,13 +2,21 @@ local ____lualib = require("lualib_bundle")
|
|
|
2
2
|
local Map = ____lualib.Map
|
|
3
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
4
|
local ____exports = {}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
local ____tears = require("functions.tears")
|
|
6
|
+
local getTearsStat = ____tears.getTearsStat
|
|
7
|
+
local DEFAULT_MAX_FIRE_DELAY = 10
|
|
8
|
+
____exports.DEFAULT_PLAYER_STAT_MAP = __TS__New(
|
|
9
|
+
Map,
|
|
10
|
+
{
|
|
11
|
+
{CacheFlag.CACHE_DAMAGE, 3.5},
|
|
12
|
+
{
|
|
13
|
+
CacheFlag.CACHE_FIREDELAY,
|
|
14
|
+
getTearsStat(nil, DEFAULT_MAX_FIRE_DELAY)
|
|
15
|
+
},
|
|
16
|
+
{CacheFlag.CACHE_SHOTSPEED, 1},
|
|
17
|
+
{CacheFlag.CACHE_RANGE, 6.5},
|
|
18
|
+
{CacheFlag.CACHE_SPEED, 1},
|
|
19
|
+
{CacheFlag.CACHE_LUCK, 0}
|
|
20
|
+
}
|
|
21
|
+
)
|
|
14
22
|
return ____exports
|
package/dist/upgradeMod.lua
CHANGED
|
@@ -78,6 +78,8 @@ local ____roomClearChange = require("callbacks.roomClearChange")
|
|
|
78
78
|
local roomClearChangeCallbackInit = ____roomClearChange.roomClearChangeCallbackInit
|
|
79
79
|
local ____ModUpgraded = require("classes.ModUpgraded")
|
|
80
80
|
local ModUpgraded = ____ModUpgraded.ModUpgraded
|
|
81
|
+
local ____characterStats = require("features.characterStats")
|
|
82
|
+
local characterStatsInit = ____characterStats.characterStatsInit
|
|
81
83
|
local ____deployJSONRoom = require("features.deployJSONRoom")
|
|
82
84
|
local deployJSONRoomInit = ____deployJSONRoom.deployJSONRoomInit
|
|
83
85
|
local ____disableInputs = require("features.disableInputs")
|
|
@@ -163,6 +165,7 @@ function initFeatures(self, mod)
|
|
|
163
165
|
taintedLazarusPlayersInit(nil, mod)
|
|
164
166
|
fastResetInit(nil, mod)
|
|
165
167
|
fadeInRemoverInit(nil, mod)
|
|
168
|
+
characterStatsInit(nil, mod)
|
|
166
169
|
end
|
|
167
170
|
function ____exports.upgradeMod(self, modVanilla, verbose)
|
|
168
171
|
if verbose == nil then
|