helo guys! out of love for the game and a stagnation of development for my extraction shooter, i decided to spend the last day of my weekend trying to recreate the Stratagem input system from Helldivers 2.
an example of how it looks in HD2 is shown below
basically, i have a module script that holds all the directions a player must input for a specific stratagem. i want it so that it replicates the ingame stratagem selector system, so when you input any key it will color it in with the active input color as long as it is in the same position relative to the input_mapâs lenght as it is to the next step index (if the next input index = 1 and the first key in the stratagem UI has the same index and the same direction, then it would be colored in). i also want it to return any inputs back to white if the inputs the player puts in strays away from what the input_map requires for the stratagem to be called (if i go left and a stratagem starts with left, but i go down and it requires right for the second input, then it returns that stratagemâs input colors back to white).
sorry if this is a bit confusing but im running on insomnia induced fumes and fried brains because ive been trying to fix this for half the day
.
it basically doesnt work but im trying to replicated and need any help, so if u can help me either design the structure of the code itself or how to properly index and check stuff, i would really appreciate it, thanks
i want the system to be dynamic so i can easily create new stratagem input maps and stuff, but i cant even really grasp how to make it in the first place, even though i had a vague thought/idea in my head of how i would structure it (this is the second idea i tried after an hour long break after a few hours of trying to debug and make stuff work)
input maps module script
local stratagem_blueprints = {}
stratagem_blueprints.fivehundredkilo_bomb = {"up","right","down","down","down"}
stratagem_blueprints.hellbomb = {"down","up","left","down","up","right","down","up"}
return stratagem_blueprints
hierarchy of the GUI you use:
gui
stratagem input script
-- player
local plr = game.Players.LocalPlayer
-- input colors
local idle_input_col = Color3.fromRGB(255, 255, 255)
local activated_input_col = Color3.fromRGB(255, 200, 0)
--
local up_input_id = "rbxassetid://90729986968561"
local right_input_id = "rbxassetid://90271689553778"
local down_input_id = "rbxassetid://136041977216996"
local left_input_id = "rbxassetid://134806224313272"
-- ui
local requesting_stratagem = true
local next_input_step = 1
local stratagem_ui = plr.PlayerGui.stratagems_gui
local stratagem_list = stratagem_ui:WaitForChild("stratagems")
local sounds = stratagem_ui:WaitForChild("sounds")
local input_sounds = sounds:WaitForChild("input_sounds")
-- services
local uis = game:GetService("UserInputService")
local repstorage = game:GetService("ReplicatedStorage")
-- events
local call_in_stratagem = repstorage:WaitForChild("call_in_stratagem")
local stratagem_input_success = repstorage:WaitForChild("stratagem_input_success")
-- modules
local input_maps = require(script.stratagem_input_maps)
function fail_input(inputs_list)
for _,input in ipairs(inputs_list:GetChildren()) do
input.ImageColor3 = idle_input_col
end
end
function reset_all()
for _,stratagem in ipairs(stratagem_list:GetChildren()) do
fail_input(stratagem:WaitForChild("inputs_list"))
end
next_input_step = 1
end
function finish_check(stratagem_input_map)
if next_input_step == #stratagem_input_map then
print("FINISHED A STRATAGEM")
else
next_input_step += 1
end
end
function inputs_scan(dir, input_id)
for _,stratagem_blueprint in pairs(input_maps) do
if stratagem_blueprint[next_input_step] == dir then
print("next thingy equals next input and direction")
for _,stratagem in ipairs(stratagem_list:GetChildren()) do
local previ = stratagem:FindFirstChild("inputs_list"):FindFirstChild("input_"..tostring(next_input_step - 1))
if previ then
print(previ.Name)
if previ.ImageColor3 ~= activated_input_col then
print("FAIL FROM COLOR THING")
end
end
if stratagem:FindFirstChild("inputs_list"):WaitForChild("input_"..tostring(next_input_step)).Image == input_id then
stratagem:FindFirstChild("inputs_list"):FindFirstChild("input_"..tostring(next_input_step)).ImageColor3 = activated_input_col
finish_check(stratagem_blueprint)
else
print("failed!!!!")
fail_input(stratagem:FindFirstChild("inputs_list"))
end
end
else
reset_all()
end
end
end
-- uis
uis.InputBegan:Connect(function(key, gp)
if gp then return end
if key.KeyCode == Enum.KeyCode.W and requesting_stratagem then
inputs_scan("up", up_input_id)
return
end
if key.KeyCode == Enum.KeyCode.A and requesting_stratagem then
inputs_scan("left", left_input_id)
return
end
if key.KeyCode == Enum.KeyCode.S and requesting_stratagem then
inputs_scan("down", down_input_id)
return
end
if key.KeyCode == Enum.KeyCode.D and requesting_stratagem then
inputs_scan("right", right_input_id)
return
end
if key.KeyCode == Enum.KeyCode.LeftControl then
local toggle_ui_sound = sounds:WaitForChild("toggle_ui")
stratagem_ui.Enabled = not stratagem_ui.Enabled
requesting_stratagem = not requesting_stratagem
next_input_step = 1
toggle_ui_sound:Play()
end
end)

