This is probally one of the biggest updates im ever going to make and its going to kill me. So lets all sit back and explain how we got here.
First off if you don’t know soyjak tycoon originally was going to have AI units that you could spawn in. There in the game and work perfectly however I felt like they could be used for more. Thats where the idea of making a open world map where they can be properly used set in.
Here was the AI before I came up with the idea.
I have more but pretty much thats the general gist of it.
Ok so how is this going to work. Well with any idea I need a plan and I came up with a pretty good one.
Each part of the open world map is set into sections and then we just load in the ai units when a player gets put into that section. This means however we have to track when the player leaves the game, dies, moves etc.
--Store the value of every players position
players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
local currentplayerpos = Instance.new("StringValue", player)
currentplayerpos.Name = "placeonmap"
--we want to reset the value when the Character is added rather than the player so the ai does not instantly stop when they die and it looks jarring
player.CharacterAdded:Connect(function()
currentplayerpos.Value = "main-island"
game.ServerScriptService.OpenWorldManager:FindFirstChild(currentplayerpos.Value).Value += 1
player.Character:WaitForChild("Humanoid").Died:Connect(function()
if(game.ServerScriptService.OpenWorldManager:FindFirstChild(currentplayerpos.Value).Value > 0 ) then
game.ServerScriptService.OpenWorldManager:FindFirstChild(currentplayerpos.Value).Value -= 1
end
currentplayerpos.Value = "none"
end)
end)
end)
--move ai to serverstorage. Its the servers job now to do this.
game.Workspace.Openworldaispawn.j1praying.Parent = game.ServerStorage.Openworldaiholder
game.Workspace.Openworldaispawn.j1walkpath.Parent = game.ServerStorage.Openworldaiholder
game.Workspace.Openworldaispawn.Jannynormalunit.Parent = game.ServerStorage.Openworldaiholder
game.Workspace.Openworldaispawn.scriptedferalfight.Parent = game.ServerStorage.Openworldaiholder
game.Workspace.Openworldaispawn.Feralherounitsm1.Parent = game.ServerStorage.Openworldaiholder
--Main ai handler for one-oneOW
game.ServerScriptService.OpenWorldManager["one-oneOW"].Changed:Connect(function()
if game.ServerScriptService.OpenWorldManager["one-oneOW"].Value == 1 then
game.ServerScriptService.gameai.Openworldai.JannyAIpray.Enabled = true
game.ServerScriptService.gameai.Openworldai.JannyAiPatrol.Enabled = true
task.wait(0.3) --just in case the scripts dont catch the childadded because its to fast
game.ServerStorage.Openworldaiholder.j1praying:Clone().Parent = game.Workspace
game.ServerStorage.Openworldaiholder.j1walkpath:Clone().Parent = game.Workspace
game.Workspace.Openworldaispawn.j1praying:FindFirstChild("0").HumanoidRootPart.Anchored = true
task.wait(0.2)
game.Workspace.Openworldaispawn.j1praying:FindFirstChild("0").HumanoidRootPart.Anchored = false
else if game.ServerScriptService.OpenWorldManager["one-oneOW"].Value == 0 then
game.Workspace.j1praying:Destroy()
game.Workspace.j1walkpath:Destroy()
end
game.ServerScriptService.gameai.Openworldai.JannyAIpray.Enabled = false
game.ServerScriptService.gameai.Openworldai.JannyAiPatrol.Enabled = false
end
end)
game.ServerScriptService.OpenWorldManager["one-twoOW"].Changed:Connect(function()
if game.ServerScriptService.OpenWorldManager["one-twoOW"].Value == 1 then
game.ServerScriptService.gameai.Openworldai["JannyAi-General"].Enabled = true
game.ServerScriptService.gameai.Openworldai["Feralai"].Enabled = true
task.wait(0.6) --just in case the scripts dont catch the childadded because its to fast
Instance.new("Model", game.Workspace).Name = "Jannynormalunit"
task.wait(0.3)
game.ServerStorage.Openworldaiholder.Jannynormalunit:FindFirstChild("0").Parent = game.Workspace.Jannynormalunit
game.ServerStorage.Openworldaiholder.scriptedferalfight:Clone().Parent = game.workspace
game.ServerStorage.Openworldaiholder.Feralherounitsm1:Clone().Parent = game.Workspace
else if game.ServerScriptService.OpenWorldManager["one-twoOW"].Value == 0 then
else if game.ServerScriptService.OpenWorldManager["one-oneOW"].Value >= 1 then
return
end
end
game.Workspace.scriptedferalfight:Destroy()
game.Workspace.Feralherounitsm1:Destroy()
Instance.new("Model", game.Workspace).Name = "scriptedferalfight"
game.Workspace.Jannynormalunit:Destroy()
Instance.new("Model", game.Workspace).Name = "Jannynormalunit"
end
end)
I made a basic prototype of it. Pretty much every single ai unit gets moved to serverstorage and then when its time cloned into workspace at there position to simulate a open world environment like there all there.
Im still semi working on the third part of the map for the first mission for but it will act as the first base.
I scribbled a Entrance to the open world base using gimp and figuring out the US highway font to make these models to make cool warning signs.
Anyways lets talk about AI design now.
The last ai was purely combat, when it came to after the battle or before the battle they were kind of wandering idiots. In a open world you typically see enemys doing stuff so I wanted to replicate that.
I made the AI be able to interact and be in unique states
Some when spawned in will patrol a area.
and we also have general units which just fight normally. Sometimes you might stumble across 2 ai factions fighting each other.
And I updated the quest system to deal with this so we can have sort of mini quests. I think the director of halo combat eveolved said something very true that video games are 30 seconds of fun repeated over and over and over and over again. and hes 100% right.
For example after a firefight and saving some ai units more will pop out of this base(Yes Im still working on it its a prototype) and come to offer you a sidequest.










