Hi, i am currently making a moveset system for npcs and bosses, currently is for bosses right now, and i was wondering if i am doing it correctly, for example, all the moves are managed in 1 script, but, i should instead make their respective oop module?, because what if i want the boss change movesets at certain health?, and more?, what should i stick to?
task.wait(.1)
local replicatedStorage = game:GetService("ReplicatedStorage")
local modulesfolder = replicatedStorage:WaitForChild("Modules")
local requireQueueModule = require(modulesfolder:WaitForChild("Queue"))
local key_ = "MovesetSystem"
local bossesfolder = workspace:WaitForChild("bosses")
local debris = game:GetService("Debris")
local movesetFolders = replicatedStorage:WaitForChild("movesets")
local works = workspace
local CurrentQueue = requireQueueModule.Fetch(key_) or requireQueueModule.New(key_)
print("initializing")
function SetupMovesets(model)
if model then
if model:FindFirstChild("Humanoid") or model:FindFirstChildWhichIsA("Humanoid") then
local humano = model:WaitForChild("Humanoid") or model:FindFirstChildWhichIsA("Humanoid")
if humano then
task.wait()
if model:HasTag("Boss") then
if movesetFolders:FindFirstChild(tostring(model.Name)) then
local MovesetFound = movesetFolders:WaitForChild(tostring(model.Name)) :: ModuleScript
if MovesetFound then
local require_moveset = require(MovesetFound)
local key_new = model or model.Name
local bossQueue_ = requireQueueModule.New(key_new) or requireQueueModule.Fetch(key_new)
coroutine.wrap(function()
while true do
task.wait(.1)
for _, moves in pairs(require_moveset["SkillLibrary"]["skills"]) do
if type(moves) == "function" then
bossQueue_:Add(function()
moves()
end, true, true)
end
end
end
end)()
end
end
end
end
end
else
warn("Doesn't exists")
end
end
task.delay(0.1, function()
for _, bosses in pairs(works:GetDescendants()) do
if bosses then
if bosses:HasTag("Boss") then
print("setting".. bosses:GetFullName())
SetupMovesets(bosses)
end
end
end
end)
works.DescendantAdded:Connect(SetupMovesets)
Moveset for the npc :
local moveset = {}
moveset.Cache = {}
moveset.__index = moveset
moveset.SkillLibrary = {
skills = {
[1] = function()
print("works?")
task.wait(2)
end,
[2] = function()
print("works 2 ?")
task.wait(2)
end,
}
}
function moveset.New(model)
assert(typeof(model) ~= nil, "Argument #1 of moveset.New cannot be nil.")
local self = {
model = model,
}
local Metatable = setmetatable(self, moveset)
moveset.Cache[model] = Metatable
return Metatable
end
type Function = (...any) -> any
return moveset