@rbxts/humanoid-stat-manager 1.0.0 → 1.0.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/out/index.d.ts +1 -0
- package/out/init.luau +57 -48
- package/package.json +1 -1
- package/out/loaders/client.meta.json +0 -5
- package/out/loaders/client.server.d.ts +0 -1
- package/out/loaders/client.server.luau +0 -10
- package/out/loaders/server.meta.json +0 -5
- package/out/loaders/server.server.d.ts +0 -1
- package/out/loaders/server.server.luau +0 -10
package/out/index.d.ts
CHANGED
package/out/init.luau
CHANGED
|
@@ -15,58 +15,65 @@ local serverNpcModifiers = {}
|
|
|
15
15
|
local clientModifiers = {}
|
|
16
16
|
local clientHumanoid
|
|
17
17
|
local remote
|
|
18
|
+
local initialized = false
|
|
18
19
|
local clientAddInternal, clientRemoveInternal
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
local function init()
|
|
21
|
+
if initialized then
|
|
22
|
+
return nil
|
|
23
|
+
end
|
|
24
|
+
initialized = true
|
|
25
|
+
if IS_SERVER then
|
|
26
|
+
remote = Instance.new("RemoteEvent")
|
|
27
|
+
remote.Name = REMOTE_NAME
|
|
28
|
+
remote.Parent = script
|
|
29
|
+
RunService.Heartbeat:Connect(function()
|
|
30
|
+
for char, modifiers in serverNpcModifiers do
|
|
31
|
+
if not char.Parent then
|
|
32
|
+
serverNpcModifiers[char] = nil
|
|
33
|
+
continue
|
|
34
|
+
end
|
|
35
|
+
pruneExpiredModifiers(modifiers)
|
|
36
|
+
if #modifiers == 0 then
|
|
37
|
+
serverNpcModifiers[char] = nil
|
|
38
|
+
end
|
|
39
|
+
local humanoid = char:FindFirstChildOfClass("Humanoid")
|
|
40
|
+
if humanoid then
|
|
41
|
+
humanoid.WalkSpeed = calculateStat("WalkSpeed", modifiers)
|
|
42
|
+
humanoid.JumpHeight = calculateStat("JumpHeight", modifiers)
|
|
43
|
+
end
|
|
28
44
|
end
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
45
|
+
end)
|
|
46
|
+
else
|
|
47
|
+
remote = script:WaitForChild(REMOTE_NAME)
|
|
48
|
+
RunService.Heartbeat:Connect(function()
|
|
49
|
+
pruneExpiredModifiers(clientModifiers)
|
|
50
|
+
if not clientHumanoid then
|
|
51
|
+
return nil
|
|
32
52
|
end
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
53
|
+
clientHumanoid.WalkSpeed = calculateStat("WalkSpeed", clientModifiers)
|
|
54
|
+
clientHumanoid.JumpHeight = calculateStat("JumpHeight", clientModifiers)
|
|
55
|
+
end)
|
|
56
|
+
remote.OnClientEvent:Connect(function(action, ...)
|
|
57
|
+
local args = { ... }
|
|
58
|
+
if action == "Add" then
|
|
59
|
+
local modifier = args[1]
|
|
60
|
+
clientAddInternal(modifier)
|
|
61
|
+
elseif action == "Remove" then
|
|
62
|
+
local id = args[1]
|
|
63
|
+
clientRemoveInternal(id)
|
|
37
64
|
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
end
|
|
50
|
-
remote.OnClientEvent:Connect(function(action, ...)
|
|
51
|
-
local args = { ... }
|
|
52
|
-
if action == "Add" then
|
|
53
|
-
local modifier = args[1]
|
|
54
|
-
clientAddInternal(modifier)
|
|
55
|
-
elseif action == "Remove" then
|
|
56
|
-
local id = args[1]
|
|
57
|
-
clientRemoveInternal(id)
|
|
58
|
-
end
|
|
59
|
-
end)
|
|
60
|
-
observeCharacters(function(char, player)
|
|
61
|
-
if player ~= Players.LocalPlayer then
|
|
62
|
-
return nil
|
|
63
|
-
end
|
|
64
|
-
table.clear(clientModifiers)
|
|
65
|
-
clientHumanoid = char:WaitForChild("Humanoid")
|
|
66
|
-
return function()
|
|
67
|
-
clientHumanoid = nil
|
|
68
|
-
end
|
|
69
|
-
end)
|
|
65
|
+
end)
|
|
66
|
+
observeCharacters(function(char, player)
|
|
67
|
+
if player ~= Players.LocalPlayer then
|
|
68
|
+
return nil
|
|
69
|
+
end
|
|
70
|
+
table.clear(clientModifiers)
|
|
71
|
+
clientHumanoid = char:WaitForChild("Humanoid")
|
|
72
|
+
return function()
|
|
73
|
+
clientHumanoid = nil
|
|
74
|
+
end
|
|
75
|
+
end)
|
|
76
|
+
end
|
|
70
77
|
end
|
|
71
78
|
function clientAddInternal(modifier)
|
|
72
79
|
local _modifier = modifier
|
|
@@ -95,6 +102,7 @@ local HumanoidStatManager = {}
|
|
|
95
102
|
do
|
|
96
103
|
local _container = HumanoidStatManager
|
|
97
104
|
local function addModifier(char, modifier)
|
|
105
|
+
init()
|
|
98
106
|
if IS_SERVER then
|
|
99
107
|
return addModifierServer(char, modifier)
|
|
100
108
|
end
|
|
@@ -164,5 +172,6 @@ function addModifierClient(char, modifier)
|
|
|
164
172
|
end
|
|
165
173
|
end
|
|
166
174
|
return {
|
|
175
|
+
init = init,
|
|
167
176
|
HumanoidStatManager = HumanoidStatManager,
|
|
168
177
|
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
-- Compiled with roblox-ts v3.0.0
|
|
2
|
-
local _module = script.Parent
|
|
3
|
-
if _module ~= nil then
|
|
4
|
-
_module = _module.Parent
|
|
5
|
-
end
|
|
6
|
-
local module = _module
|
|
7
|
-
local _arg0 = module and module:IsA("ModuleScript")
|
|
8
|
-
local _arg1 = `Module not found`
|
|
9
|
-
assert(_arg0, _arg1)
|
|
10
|
-
require(module)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
-- Compiled with roblox-ts v3.0.0
|
|
2
|
-
local _module = script.Parent
|
|
3
|
-
if _module ~= nil then
|
|
4
|
-
_module = _module.Parent
|
|
5
|
-
end
|
|
6
|
-
local module = _module
|
|
7
|
-
local _arg0 = module and module:IsA("ModuleScript")
|
|
8
|
-
local _arg1 = `Module not found`
|
|
9
|
-
assert(_arg0, _arg1)
|
|
10
|
-
require(module)
|