gpt4 book ai didi

Can't figure out how to make a combat system on Lua in Roblox Studio(我不知道如何在Roblox工作室的Lua上制作战斗系统)

转载 作者:bug小助手 更新时间:2023-10-24 23:47:57 25 4
gpt4 key购买 nike



I am a new programmer and have been working with some of my friends on Roblox. We have been trying to make a game with a fun combat system, but have failed in every attempt, although we're not ready to give up.

我是一名新的程序员,一直在和我的一些朋友一起开发Roblox。我们一直试图制作一款带有有趣战斗系统的游戏,但每一次尝试都失败了,尽管我们还没有准备好放弃。


We've tried googling things, searching tutorials on YouTube and have been trying for about a week to get this to work. We can barely get a punch animation to play when our goal is to make a combat system with a normal attack that combos up to 5, a skill that can be used every 15 seconds, and an ultimate ability that charges whenever you hit an enemy.
Thank you to anyone that can help, I feel as if I'm in way over my head and I don't really know where to start.

我们试着在谷歌上搜索东西,在YouTube上搜索教程,并已经尝试了大约一周的时间来实现这一点。当我们的目标是制造一个战斗系统时,我们几乎不能播放拳击动画,因为我们的战斗系统具有最多5次的普通攻击,一种可以每15秒使用一次的技能,以及一种无论你何时击中敌人都可以冲锋的终极能力。感谢所有能帮上忙的人,我觉得自己有些力不从心,我真的不知道从何说起。


更多回答

Welcome to StackOverflow! I'm sorry, but such vague, open questions or questions along the lines of "please implement this for us" aren't fit for StackOverflow - take the tour or visit the help center to see which questions are suitable for StackOverflow. What exactly have you tried, where have you failed?

欢迎来到StackOverflow!很抱歉,这种含糊的、公开的问题或类似“请为我们实现这一点”之类的问题不适合StackOverflow-请浏览或访问帮助中心,以了解哪些问题适合StackOverflow。你到底尝试了什么,在哪里失败了?

Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.

请澄清您的具体问题或提供更多详细信息,以突出您的确切需求。按照目前的写法,很难准确地说出你在问什么。

优秀答案推荐

You can use my code if u can read it :P

你可以使用我的代码,如果你能读懂的话:p




--Server Script

local re=Instance.new("RemoteEvent",game.ReplicatedStorage)
-- all abilities(except the ultimate)are not on cooldown at start of the game
local ability_cds={
["basicAttack"]=1,
["r"]=15, -- Skill1 (binded to button r with 15s cooldown)
["t"]=60 -- Ultimate ability
}
local ultcd=60 -- ultimate ability default cooldown
local function ultcd_update(player,cd)
re:FireClient(player,"t",5)
end
local ability={
["basicAttack"]=function(player,combo)
local hint=workspace:FindFirstChild"Message"or Instance.new("Hint",workspace)
hint.Text="basicAttack x"..combo
end,
["r"]=function(player,combo) -- Skill1 (binded to button r with 15s cooldown)
end,
["t"]=function(player) --[[Ultimate ability(charging cd by kill not implemented)

ultcd_update(player,5) -- use to decrease ultimate cooldown by 5seconds(example)

]]
end


}
local maxcombo=5
local function useAbility(ability_name,player,combo)
ability[ability_name](player,combo)
end
local ability_combo,ability_cds2={},{}
re.OnServerEvent:Connect(function(player,ability)
if not ability or type(ability)~="string"then player:Kick()end
local cd=ability_cds[ability]
if not cd then player:Kick()end
ability_cds2[player.Name]=ability_cds2[player.Name]or table.clone(ability_cds)
local ability_cds=ability_cds2[player.Name]
cd=ability_cds[ability]
-- ultimate charging mechanism override:
--(ult. cooldown will not decrease every second)
if ability=="t"and cd==0 then
ability_cds[ability]=ultcd
useAbility("t",player,0)
end
--
if cd==0 then return end
ability_cds[ability]=0
ability_combo[player.Name]=ability_combo[player.Name]or {}
ability_combo[player.Name][ability]=ability_combo[player.Name][ability]or 0
if not(ability_combo[player.Name][ability]+1>maxcombo) then
ability_combo[player.Name][ability]+=1
else
ability_combo[player.Name][ability]=1
end
delay(cd,function()
ability_cds[ability]=cd
local combo=ability_combo[player.Name][ability]
delay(cd,function()
if combo==ability_combo[player.Name][ability]then
ability_combo[player.Name][ability]=0
end

end)
end)
spawn(function()
useAbility(ability,player,ability_combo[player.Name][ability])
end)
end)
-------------------------------------------------------------------






--LocalScript



local player=game.Players.LocalPlayer

--local gui=script.Parent

local char=player.Character
local hum=char:WaitForChild"Humanoid"

local mouse=player:GetMouse()
local re=game.ReplicatedStorage:WaitForChild"RemoteEvent"
local ability_cds={
["basicAttack"]=1,
["r"]=15, -- Skill1 (binded to button r with 15s cooldown)
["t"]=60 -- Ultimate ability
}
re.OnClientEvent:Connect(function(ability,cd)
local newcd=ability_cds[ability]-cd
newcd=newcd<0 and 0 or newcd
ability_cds[ability]=cd
end)
local ultcd=60
local function useAbility(ability)
local cd=ability_cds[ability]
-- ultimate ability special charging mechanism
if ability=="t"then
if cd==0 then
ability_cds[ability]=ultcd
re:FireServer(ability)
end
return
end
--
if not cd or cd==0 then return end
ability_cds[ability]=0
delay(cd,function()
ability_cds[ability]=cd
end)
re:FireServer(ability)
end
mouse.KeyDown:Connect(function(key)
useAbility(key:lower())
end)
mouse.Button1Down:Connect(function(key)
useAbility("basicAttack")
end)




更多回答

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com