Skip to content

Instantly share code, notes, and snippets.

@Aerodos12
Created January 25, 2018 17:45
Show Gist options
  • Save Aerodos12/ca3f5c18f2cc4f254f0fdfe8ddc6a9c8 to your computer and use it in GitHub Desktop.
Save Aerodos12/ca3f5c18f2cc4f254f0fdfe8ddc6a9c8 to your computer and use it in GitHub Desktop.
MobManager
local LootService = require(game.ReplicatedStorage.LootService)
local Bot = {
Mana = 100,
Lvl = 1,
CooldownMagnitude = 50,
MinDmg = 5,
MaxDmg = 10,
Gold = 20,
XP = 10,
CritMagnitude = 200,
ChaseRange = 1000,
ChaseDistance = 25,
WanderRadius = 8,
MobName = "Stormtrooper",
ShootRange = 50,
Allegiance = "Evil",
CritChance = 2.5,
Role = "Standard";
HitChance = 20,
BlasterCarrier = {
BlasterName = "E-11"
},
PutOnClothes = {
Armor = "Stormtrooper"
};
Attributes = {
Dexterity = 5,
};
Loot = LootService.LootSet.new(
game.ReplicatedStorage.ITEMS.Blasters["E-11"],
game.ReplicatedStorage.ITEMS.Blasters["SE-14c"],
game.ReplicatedStorage.ITEMS.Medpacs.Medpac,
game.ReplicatedStorage.ITEMS.Medpacs.Traumakit,
"Drop"
);
}
return Bot
local MobService = {};
local BindingService = require(game.ReplicatedStorage.BindingService)()
local RemoteService = require(game.ReplicatedStorage.RemoteService)
local ProgressionService =require(game.ReplicatedStorage.ProgressionService)
MobService.PFS = game:GetService("PathfindingService");
MobService.Pathfinder = require(script.Pathfinder)
MobService.Region = require(script.Region)
MobService.RemoteService = require(game.ReplicatedStorage.RemoteService)
MobService.RPGM = require(game.ReplicatedStorage.RPGMathProvider)
MobService.Starting = require(game.Workspace.Settings.Starting)
MobService.OrderThread = require(script.OrderThread)
MobService.BT = require(script.BehaviorTree)
local MarketService = require(game.ReplicatedStorage:FindFirstChild("MarketService"))
MobService.Actions = {}
for _, actionScript in pairs(script.MobActions:GetChildren()) do
MobService.Actions[actionScript.Name] = require(actionScript)
end
function MobService:WalkToPlayer(Mob, Player)
if Mob:FindFirstChild("Torso") ~= nil and Mob:FindFirstChild("Human") ~= nil then
Mob:FindFirstChild("Human"):WalkToPart(Player.Character:FindFirstChild("Torso"))
end
end
function MobService:AwardPlayerPoints(points,player)
pcall(function() game.PointsService:AwardPoints(player.userId,points) end)
end
function MobService:MarkAsKill(plr)
plr.MissionStats.Kills.Value = plr.MissionStats.Kills.Value + 1
plr.MissionStats.TotalKills.Value = plr.MissionStats.TotalKills.Value + 1
end
function MobService:MarkAsAssist(plr)
plr.MissionStats.Assists.Value = plr.MissionStats.Assist.Value + 1
end
function MobService:AddGenericKill(mob, plr, xpGain, weapon)
if plr:IsA("Player") then
BindingService.send("AddKill",mob, plr, xpGain)
end
RemoteService.bounce("Client","AddToKillFeed",plr,weapon,mob)
end
--function MobService:Wander(OrigPos,Mob,Bot)
-- local path = MobService.PFS:ComputeRawPathAsync(OrigPos,Vector3.new(OrigPos.X + math.random(-Bot.WanderRadius, Bot.WanderRadius), OrigPos.Y, OrigPos.Z + math.random(-Bot.WanderRadius, Bot.WanderRadius)),50)
-- for _,v in pairs(path:GetPointCoordinates()) do
-- Mob.Human:MoveTo(v)
-- end
--end
function MobService:Pursue(target,Mob)
local pathc = MobService.PFS:ComputeRawPathAsync(Mob.Torso.Position,target.Position,200)
for _, v in pairs(pathc:GetPointCoordinates()) do
Mob.Human:MoveTo(v)
end
end
function MobService:MoveTo(Mob,TargetPos)
local path = MobService.PFS:ComputeSmoothPathAsync(Mob.PrimaryPart.Position,TargetPos,300)
for _, v in pairs(path:GetPointCoordinates()) do
Mob.Human:MoveTo(v)
wait(0.2)
end
end
function MobService:GetToPoint(Mob,Point,EC)
local finder = MobService.Pathfinder.new(Mob.HumanoidRootPart, Mob.Human, Mob)
finder.Target = Point
finder.EmptyCutoff = EC
finder:ComputePath()
finder:Start(1,function()
end)
finder.Stopped:wait()
end
local function tagHumanoid(humanoid, character)
local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = character
creator_tag.Name = "creator"
creator_tag.Parent = humanoid
end
function MobService.AttackPlayer(Mob, Humanoid, LowDmg, HighDmg, HitChance, CritChance, CritMagnitude, showGUI)
if Humanoid ~= nil and Mob:FindFirstChild("Human").Health > 0 then
-- if game.Players:GetPlayerFromCharacter(Humanoid.Parent) then
--if Debounce == false then
-- Debounce = true
local damage = MobService.RPGM.MobCombatMath["Random"]["DamageRoll"](LowDmg, HighDmg)
local hitroll = MobService.RPGM:GetRoll(1, 100)
local critroll = MobService.RPGM:GetRoll(1, 100)
--Modify damage based on defense.
damage = MobService.RPGM.MobCombatMath["Regular"][MobService.Starting.DefenseMode](damage,Humanoid)
damage = (hitroll > HitChance and 0 or damage)
damage = (damage > 9999 and 9999 or damage)
damage =(damage < 1 and 0 or damage)
damage = (critroll <= CritChance and MobService.RPGM.MobCombatMath["Crit"](damage,CritMagnitude) or damage)
Mob:WaitForChild("Head")
Mob.Head:WaitForChild("DamageGUI")
if showGUI then
--Decides text. Should it show miss or number? It's all dependent on hit and critical chances.
local NumberText = Instance.new("TextLabel")
NumberText.FontSize = Enum.FontSize.Size24
NumberText.Font = Enum.Font.SciFi
NumberText.Size = UDim2.new(1,0,1,0)
NumberText.Position = UDim2.new(0,0,0,0)
NumberText.BackgroundTransparency = 1
NumberText.TextStrokeTransparency = 0
NumberText.TextColor3 = (damage == 0 and Color3.new(0,0.5,1) or (critroll <= CritChance and Color3.new(1,0.5,0) or Color3.new(1,0,0) ))
NumberText.Text = (damage == 0 and "MISS" or (critroll <= CritChance and ""..damage.."!" or ""..damage..""))
NumberText.FontSize =(damage == 0 and Enum.FontSize.Size24 or (critroll <= CritChance and Enum.FontSize.Size36 or Enum.FontSize.Size24))
NumberText.Parent = Mob.Head.DamageGUI
spawn(function()
NumberText:TweenPosition(UDim2.new(0,0,0,-98))
wait(1)
for i = 1, 20 do
NumberText.TextTransparency = NumberText.TextTransparency + 0.05
wait(0.025)
end
end)
end
tagHumanoid(Humanoid, Mob)
Humanoid:TakeDamage(damage) --Deducts humanoid health.
-- wait(script.Parent.SETTINGS.CooldownMagnitude.Value/100)
-- Debounce = false
--else print("Debouncing")
--end
end
--else
--return false
-- end
end
function MobService.AddStats(Leaderstats, XPAward, CreditsAward, killType)
ProgressionService:AddXP(Leaderstats.Parent,XPAward,killType)
if (Leaderstats.Credits.Value + CreditsAward) <= 2147483647 then
MarketService:DepositWithEnemySource(Leaderstats.Parent.UserId,(ProgressionService:PlayerHasPowerUp(Leaderstats.Parent,"Double Credits") and (CreditsAward * 2) or CreditsAward),"EnemyKill")
end
MobService.RemoteService.send("Client",Leaderstats.Parent,"DisplayReward",(ProgressionService:PlayerHasPowerUp(Leaderstats.Parent,"Double XP") and (XPAward * 2) or XPAward),"XP")
MobService.RemoteService.send("Client",Leaderstats.Parent,"DisplayReward",(ProgressionService:PlayerHasPowerUp(Leaderstats.Parent,"Double Credits") and (CreditsAward * 2) or CreditsAward),"Credits")
end
return MobService
local Mob = script.Parent
local RemoteService = require(game.ReplicatedStorage.RemoteService)
local RS = game:GetService("RunService")
local Torso = Mob:WaitForChild("Torso",200)
local RightShoulder = Torso:WaitForChild("Right Shoulder",200)
local LeftShoulder = Torso:WaitForChild("Left Shoulder",200)
local RightHip = Torso:WaitForChild("Right Hip",200)
local LeftHip = Torso:WaitForChild("Left Hip",200)
local Neck = Torso:WaitForChild("Neck",200)
local Humanoid = Mob:WaitForChild('Human',200)
local CEIL = math.ceil
local RANDOM = math.random
local SIN = math.sin
local Hats = {}
local V3 = Vector3.new
local DS = game:GetService("Debris")
spawn(function()
for _, hat in pairs(script.Parent:GetChildren()) do
if hat:IsA("Accessory") then
Hats[#Hats + 1] = hat:Clone()
end
end
end)
local pose = "Standing"
local currentAnim = ""
local currentAnimTrack = nil
local currentAnimKeyframeHandler = nil
local oldAnimTrack = nil
local animTable = {}
local animNames = {
idle = {
{ id = "http://www.roblox.com/asset/?id=125750544", weight = 9 },
{ id = "http://www.roblox.com/asset/?id=125750618", weight = 1 }
},
walk = {
{ id = "http://www.roblox.com/asset/?id=125749145", weight = 10 }
},
run = {
{ id = "rbxassetid://1207121902", weight = 10 }
},
jump = {
{ id = "http://www.roblox.com/asset/?id=125750702", weight = 10 }
},
fall = {
{ id = "http://www.roblox.com/asset/?id=125750759", weight = 10 }
},
climb = {
{ id = "http://www.roblox.com/asset/?id=125750800", weight = 10 }
},
toolnone = {
{ id = "http://www.roblox.com/asset/?id=125750867", weight = 10 }
},
toolslash = {
{ id = "http://www.roblox.com/asset/?id=129967390", weight = 10 }
-- { id = "slash.xml", weight = 10 }
},
toollunge = {
{ id = "http://www.roblox.com/asset/?id=129967478", weight = 10 }
},
point = {
{ id = "http://www.roblox.com/asset/?id=128853357", weight = 10 }
},
}
-- Add custom animations to the list.
spawn(function()
if script:FindFirstChild('Animations') then
for _, anim in ipairs(script.Animations:GetChildren()) do
animNames[anim.Name:lower()] = {
{ id = anim.AnimationId, weight = 10 }
}
end
end
end)
-- Setup animation objects
for name, fileList in pairs(animNames) do
animTable[name] = {}
animTable[name].count = 0
animTable[name].totalWeight = 0
-- check for config values
local config = script:FindFirstChild(name)
if config then
local idx = 1
for _, childPart in pairs(config:GetChildren()) do
animTable[name][idx] = {}
animTable[name][idx].anim = childPart
local weightObject = childPart:FindFirstChild("Weight")
if (weightObject == nil) then
animTable[name][idx].weight = 1
else
animTable[name][idx].weight = weightObject.Value
end
animTable[name].count = animTable[name].count + 1
animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
idx = idx + 1
end
end
-- fallback to defaults
if animTable[name].count <= 0 then
for idx, anim in pairs(fileList) do
animTable[name][idx] = {}
animTable[name][idx].anim = Instance.new("Animation")
animTable[name][idx].anim.Name = name
animTable[name][idx].anim.AnimationId = anim.id
animTable[name][idx].weight = anim.weight
animTable[name].count = animTable[name].count + 1
animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
end
end
end
-- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
-- ANIMATION
-- declarations
local toolAnim = "None"
local toolAnimTime = 0
local jumpAnimTime = 0
local jumpAnimDuration = 0.175
local toolTransitionTime = 0.1
local fallTransitionTime = 0.2
local jumpMaxLimbVelocity = 0.75
-- functions
function stopAllAnimations()
local oldAnim = currentAnim
currentAnim = ""
if (currentAnimKeyframeHandler ~= nil) then
currentAnimKeyframeHandler:disconnect()
end
if (oldAnimTrack ~= nil) then
oldAnimTrack:Stop()
oldAnimTrack:Destroy()
oldAnimTrack = nil
end
if (currentAnimTrack ~= nil) then
currentAnimTrack:Stop()
currentAnimTrack:Destroy()
currentAnimTrack = nil
end
return oldAnim
end
function keyFrameReachedFunc(frameName)
if (frameName == "End") then
-- print("Keyframe : ".. frameName)
local repeatAnim = stopAllAnimations()
playAnimation(repeatAnim, 0.0, Humanoid)
end
end
-- Preload animations
function playAnimation(animName, transitionTime, humanoid)
if (animName ~= currentAnim) then
if (oldAnimTrack ~= nil) then
oldAnimTrack:Stop()
oldAnimTrack:Destroy()
end
local roll = RANDOM(1, animTable[animName].totalWeight)
local origRoll = roll
local idx = 1
while (roll > animTable[animName][idx].weight) do
roll = roll - animTable[animName][idx].weight
idx = idx + 1
end
-- print(animName .. " " .. idx .. " [" .. origRoll .. "]")
local anim = animTable[animName][idx].anim
-- load it to the humanoid; get AnimationTrack
oldAnimTrack = currentAnimTrack
currentAnimTrack = humanoid:LoadAnimation(anim)
currentAnimTrack:Play(transitionTime)
-- play the animation
currentAnim = animName
-- set up keyframe name triggers
if (currentAnimKeyframeHandler ~= nil) then
currentAnimKeyframeHandler:disconnect()
end
currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
end
end
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
function onRunning(speed)
if speed>0 then
playAnimation("walk", 0.1, Humanoid)
pose = "Running"
else
playAnimation("idle", 0.1, Humanoid)
pose = "Standing"
end
end
function onJumping()
playAnimation("jump", 0.1, Humanoid)
jumpAnimTime = jumpAnimDuration
pose = "Jumping"
end
function onClimbing()
playAnimation("climb", 0.1, Humanoid)
pose = "Climbing"
end
function onGettingUp()
pose = "GettingUp"
end
function onFreeFall()
if (jumpAnimTime <= 0) then
playAnimation("fall", fallTransitionTime, Humanoid)
end
pose = "FreeFall"
end
function onFallingDown()
pose = "FallingDown"
end
function onSeated()
pose = "Seated"
end
function onPlatformStanding()
pose = "PlatformStanding"
end
function onSwimming(speed)
if speed>0 then
pose = "Running"
else
pose = "Standing"
end
end
function getTool()
for _, kid in ipairs(Mob:GetChildren()) do
if kid.className == "Tool" then return kid end
end
return nil
end
function getToolAnim(tool)
for _, c in ipairs(tool:GetChildren()) do
if c.Name == "toolanim" and c.className == "StringValue" then
return c
end
end
return nil
end
function moveSit()
RightShoulder.MaxVelocity = 0.15
LeftShoulder.MaxVelocity = 0.15
if RightShoulder.Part1 then
RightShoulder:SetDesiredAngle(3.14 * 0.5)
end
if LeftShoulder.Part1 then
LeftShoulder:SetDesiredAngle(-3.14 * 0.5)
end
RightHip:SetDesiredAngle(3.14 * 0.5)
LeftHip:SetDesiredAngle(-3.14 * 0.5)
end
local lastTick = 0
local function move(time)
local amplitude = 1
local frequency = 1
local deltaTime = time - lastTick
lastTick = time
local climbFudge = 0
local setAngles = false
if (jumpAnimTime > 0) then
jumpAnimTime = jumpAnimTime - deltaTime
end
if (pose == "FreeFall" and jumpAnimTime <= 0) then
playAnimation("fall", fallTransitionTime, Humanoid)
elseif (pose == "Seated") then
stopAllAnimations()
moveSit()
return
elseif (pose == "Running") then
playAnimation("walk", 0.1, Humanoid)
elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
-- print("Wha " .. pose)
amplitude = 0.1
frequency = 1
setAngles = true
end
if (setAngles) then
local desiredAngle = amplitude * SIN(time * frequency)
RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
RightHip:SetDesiredAngle(-desiredAngle)
LeftHip:SetDesiredAngle(-desiredAngle)
end
end
-- connect events
Humanoid.Running:connect(onRunning)
Humanoid.Jumping:connect(onJumping)
Humanoid.Climbing:connect(onClimbing)
Humanoid.GettingUp:connect(onGettingUp)
Humanoid.FreeFalling:connect(onFreeFall)
Humanoid.FallingDown:connect(onFallingDown)
Humanoid.Seated:connect(onSeated)
Humanoid.PlatformStanding:connect(onPlatformStanding)
Humanoid.Swimming:connect(onSwimming)
-- main program
-- initialize to idle
spawn(function()
playAnimation("idle", 0.1, Humanoid)
pose = "Standing"
end)
local Module = require(game.ServerScriptService.MobFunctions)
local TSS = require(game.ServerScriptService.ToolStoreService)
local ProgService = require(game.ReplicatedStorage.ProgressionService)
local Bot = require(Mob.BOT)
local larm = Mob:FindFirstChild("Left Arm")
local rarm = Mob:FindFirstChild("Right Arm")
local Debounce = false
local Others = require(game.Workspace.Settings.Others)
Humanoid.Mana.Value = Bot.Mana
local DamageTag = require(game.ReplicatedStorage.DamageTag)
game.CollectionService:AddTag(Mob,game.HttpService:GenerateGUID(false))
local ToolName = Bot.BlasterCarrier.BlasterName
local weaponToClone = game.ReplicatedStorage.MobItems[ToolName]
local weapon = weaponToClone:Clone()
if Mob:FindFirstChild(ToolName) == nil then
weapon.Parent = Mob
weapon.Equip:Fire()
weapon:FindFirstChild("HoleStorage").Value = workspace.HoleStorage
Mob.CurrentItem.Value = weapon
end
local ArmorService = require(game.ReplicatedStorage.ArmorModule)
ArmorService:EquipArmorByName(Mob, Bot.PutOnClothes.Armor)
local settings = require(weapon.SETTINGS)
Mob.SetAimed.Event:connect(function(aimed)
weapon.SetAimed:Fire(aimed)
Mob.Head.Face.Texture = (aimed and "rbxassetid://216769025" or "rbxassetid://125042132")
end)
Mob.Shooting.Changed:connect(function(shooting)
if shooting then
while Mob.Shooting.Value and Humanoid.Health > 0 and Mob.GetTarget:Invoke() do
weapon.Activate:Fire()
wait(60 / settings.roundsPerMin)
end
end
end)
Mob.Name = Bot.MobName
Humanoid.Health = Humanoid.MaxHealth
function isInPeople(first, second)
for _,v in pairs(first) do
if second == v then
return true
end
end
return false
end
function getIndexOfValue(array, val)
for i = 0, #array do
if tostring(val) == tostring(array[i]) then
return i
end
end
return nil
end
local hurtConn
local CurrentHealth = Humanoid.Health
hurtConn = Humanoid.HealthChanged:connect(function(health)
if CurrentHealth > health and health ~= 0 then
if weapon then
Mob.SightedEnemy.Value = true
local tags = game.CollectionService:GetTags(Humanoid)
for _, tagStr in pairs(tags) do
local tag = DamageTag.ParseTag(tagStr)
if tag then
if tag:GetKiller() then
if tag:GetKiller():FindFirstChildOfClass("Humanoid") then
Mob.SetTarget:Fire(tag:GetKiller():FindFirstChildOfClass("Humanoid"))
elseif tag:GetKiller():IsA("Player") then
Mob.SetTarget:Fire(tag:GetKiller().Character:FindFirstChildOfClass("Humanoid"))
end
Mob.SetState:Fire("Defense")
end
end
end
wait(2.5)
if Humanoid.Health > 0 then
Mob.SightedEnemy.Value = false
end
end
elseif health <= 0 then
hurtConn:Disconnect()
end
CurrentHealth = health
end)
local fightRoutine = coroutine.create(require(Mob.Duty))
function Died()
coroutine.yield(fightRoutine)
pose = "Dead"
local gold = Bot.Gold
local xp = Bot.XP
local people = {}
local damages = {}
local weapons = {}
local headshots = {}
Mob.CurrentItem.Value.Unequip:Fire(true,true)
hurtConn:Disconnect()
for _, tagStr in pairs(game:GetService("CollectionService"):GetTags(Humanoid)) do
local tag = DamageTag.ParseTag(tagStr)
if tag then
local Killer = tag:GetKiller()
local usedWeapon = tag:GetWeaponName()
if Killer then
if not isInPeople(people, Killer) then
people[#people+1] = Killer
weapons[#weapons+1] = usedWeapon
damages[#damages+1] = tag.dmg
headshots[#headshots+1] = tag.Headshot
else
if string.lower(Others.XPShareMode) ~= "classic" then
local y = getIndexOfValue(people, Killer)
damages[y] = damages[y] + CEIL(tag.dmg)
weapons[y] = tag:GetWeaponName()
end
end
end
end
RS.Heartbeat:wait()
end
local health = 0
for i,v in pairs(damages) do
health = health + v
end
table.sort(people,function(a,b)
local damagea, damageb
local indexA, indexB = getIndexOfValue(people,a), getIndexOfValue(people,b)
damagea = damages[indexA]
damageb = damages[indexB]
return damagea > damageb
end)
table.sort(damages,function(a,b)
return a > b
end)
table.sort(weapons,function(a,b)
local damagea, damageb
local indexA, indexB = getIndexOfValue(weapons,a), getIndexOfValue(weapons,b)
damagea = damages[indexA]
damageb = damages[indexB]
return damagea > damageb
end)
Module:AddGenericKill(Mob, people[1] , CEIL((damages[1]/health)*xp), weapons[1])
spawn(function()
local prevV = nil
for d, v in pairs(people) do
print("Giving stats to ", v.Name, " | ", d)
if v ~= nil then
if prevV ~= v then
prevV = v
if v:IsA("Player") then
local ls = v:FindFirstChild("leaderstats")
if ls then
if xp and gold then
if d == 1 then
Module.AddStats(ls, CEIL((damages[d]/health)*xp), CEIL((damages[d]/health)*gold),"kill")
if headshots[d] then
ProgService:AddXP(v,math.floor(xp/4),"head")
end
elseif d > 1 and d <= 3 then
Module.AddStats(ls, CEIL((damages[d]/health)*xp), CEIL((damages[d]/health)*gold),"assistkill")
else
Module.AddStats(ls, CEIL((damages[d]/health)*xp), CEIL((damages[d]/health)*gold),"assist")
end
Module:AwardPlayerPoints(CEIL((damages[d]/health)*xp), v)
end
end
end
end
end
RS.Heartbeat:wait()
end
end)
Bot.Loot:Calculate()
Bot.Loot:Distribute(Mob)
local Hum = Humanoid:Clone()
Hum.Health = 0
Hum.MaxHealth = 0
Humanoid.Parent = nil
if Torso then
local Head = Mob:FindFirstChild("Head")
if Head then
local Neck = Instance.new("Motor6D")
Neck.Name = "Neck"
Neck.Part0 = Torso
Neck.Part1 = Head
Neck.C0 = CFrame.new(0, 1.5, 0)
Neck.C1 = CFrame.new()
Neck.Parent = Torso
end
local Limb = Mob:FindFirstChild("Right Arm")
if Limb then
Limb.CFrame = Torso.CFrame * CFrame.new(1.5, 0, 0)
local Joint = Instance.new("Rotate")
Joint.Name = "RightShoulder"
Joint.Part0 = Torso
Joint.Part1 = Limb
Joint.C0 = CFrame.new(1.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
Joint.C1 = CFrame.new(-0, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
Joint.Parent = Torso
local B = Instance.new("Part")
B.TopSurface = 0
B.BottomSurface = 0
B.formFactor = "Symmetric"
B.Size = Vector3.new(1, 1, 1)
B.Transparency = 1
B.CFrame = Limb.CFrame * CFrame.new(0, -0.5, 0)
B.Parent = Mob
local W = Instance.new("Weld")
W.Part0 = Limb
W.Part1 = B
W.C0 = CFrame.new(0, -0.5, 0)
W.Parent = Limb
end
local Limb = Mob:FindFirstChild("Left Arm")
if Limb then
Limb.CFrame = Torso.CFrame * CFrame.new(-1.5, 0, 0)
local Joint = Instance.new("Rotate")
Joint.Name = "LeftShoulder"
Joint.Part0 = Torso
Joint.Part1 = Limb
Joint.C0 = CFrame.new(-1.5, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
Joint.C1 = CFrame.new(0, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
Joint.Parent = Torso
local B = Instance.new("Part")
B.TopSurface = 0
B.BottomSurface = 0
B.Size = Vector3.new(1, 1, 1)
B.Transparency = 1
B.CFrame = Limb.CFrame * CFrame.new(0, -0.5, 0)
B.Parent = Mob
local W = Instance.new("Weld")
W.Part0 = Limb
W.Part1 = B
W.C0 = CFrame.new(0, -0.5, 0)
W.Parent = Limb
end
local Limb = Mob:FindFirstChild("Right Leg")
if Limb then
Limb.CFrame = Torso.CFrame * CFrame.new(0.5, -2, 0)
local Joint = Instance.new("Rotate")
Joint.Name = "RightHip"
Joint.Part0 = Torso
Joint.Part1 = Limb
Joint.C0 = CFrame.new(0.5, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
Joint.C1 = CFrame.new(0, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
Joint.Parent = Torso
local B = Instance.new("Part")
B.TopSurface = 0
B.BottomSurface = 0
B.Size = V3(1, 1, 1)
B.Transparency = 1
B.CFrame = Limb.CFrame * CFrame.new(0, -0.5, 0)
B.Parent = Mob
local W = Instance.new("Weld")
W.Part0 = Limb
W.Part1 = B
W.C0 = CFrame.new(0, -0.5, 0)
W.Parent = Limb
end
local Limb = Mob:FindFirstChild("Left Leg")
if Limb then
Limb.CFrame = Torso.CFrame * CFrame.new(-0.5, -2, 0)
local Joint = Instance.new("Rotate")
Joint.Name = "LeftHip"
Joint.Part0 = Torso
Joint.Part1 = Limb
Joint.C0 = CFrame.new(-0.5, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
Joint.C1 = CFrame.new(-0, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
Joint.Parent = Torso
local B = Instance.new("Part")
B.TopSurface = 0
B.BottomSurface = 0
B.formFactor = "Symmetric"
B.Size = Vector3.new(1, 1, 1)
B.Transparency = 1
B.CFrame = Limb.CFrame * CFrame.new(0, -0.5, 0)
B.Parent = Mob
local W = Instance.new("Weld")
W.Part0 = Limb
W.Part1 = B
W.C0 = CFrame.new(0, -0.5, 0)
W.Parent = Limb
end
--[
local Bar = Instance.new("Part")
Bar.TopSurface = 0
Bar.BottomSurface = 0
Bar.formFactor = "Symmetric"
Bar.Size = Vector3.new(1, 1, 1)
Bar.Transparency = 1
Bar.CFrame = Torso.CFrame * CFrame.new(0, 0.5, 0)
Bar.Parent = Mob
local Weld = Instance.new("Weld")
Weld.Part0 = Torso
Weld.Part1 = Bar
Weld.C0 = CFrame.new(0, 0.5, 0)
Weld.Parent = Torso
--]]
for _, hat in pairs(Hats) do
hat.Parent = Hum.Parent
end
Hum.Parent = Mob
Mob.Parent = workspace.CorpseIgnore
Torso.Velocity=V3(RANDOM(-30,30),0,RANDOM(-30,30))
Hum.Name = "Human"
Hum:SetStateEnabled(Enum.HumanoidStateType.Physics,false)
Hum:SetStateEnabled(Enum.HumanoidStateType.GettingUp,false)
Hum:SetStateEnabled(Enum.HumanoidStateType.RunningNoPhysics,false)
Hum:SetStateEnabled(Enum.HumanoidStateType.Running,false)
wait(10)
Mob:Destroy()
end
end
Humanoid.Died:connect(Died)
local PFinding = game:GetService("PathfindingService")
local ITT = Mob.Transport.Value
if ITT then
function getSeat()
local seats = {}
for _, item in pairs(ITT:GetChildren()) do
if item.Name == "SeatPlacement" then
seats[#seats+1] = item
end
end
return seats[Mob.ID.Value]
end
local Path = PFinding:FindPathAsync(Mob.Torso.CFrame.p,ITT.EntryPart.CFrame.p)
if Path.Status == Enum.PathStatus.Success then
local points = Path:GetWaypoints()
for _, point in pairs(points) do
if point.Action == Enum.PathWaypointAction.Jump then
Humanoid.Jump = true
end
Humanoid:MoveTo(point.Position)
Humanoid.MoveToFinished:wait()
end
end
local Path = PFinding:FindPathAsync(Mob.Torso.CFrame.p,ITT.EntryPart2.CFrame.p)
if Path.Status == Enum.PathStatus.Success then
local points = Path:GetWaypoints()
for _, point in pairs(points) do
if point.Action == Enum.PathWaypointAction.Jump then
Humanoid.Jump = true
end
Humanoid:MoveTo(point.Position)
Humanoid.MoveToFinished:wait()
end
end
if (getSeat().CFrame.p - Mob.Torso.CFrame.p).magnitude> 5 then
local Path = PFinding:FindPathAsync(Mob.Torso.CFrame.p,ITT.EntryPart3.CFrame.p)
if Path.Status == Enum.PathStatus.Success then
local points = Path:GetWaypoints()
for _, point in pairs(points) do
if point.Action == Enum.PathWaypointAction.Jump then
Humanoid.Jump = true
end
Humanoid:MoveTo(point.Position)
Humanoid.MoveToFinished:wait()
end
end
end
if (getSeat().CFrame.p - Mob.Torso.CFrame.p).magnitude > 5 then
local Path = PFinding:FindPathAsync(Mob.Torso.CFrame.p,ITT.EntryPart4.CFrame.p)
if Path.Status == Enum.PathStatus.Success then
local points = Path:GetWaypoints()
for _, point in pairs(points) do
if point.Action == Enum.PathWaypointAction.Jump then
Humanoid.Jump = true
end
Humanoid:MoveTo(point.Position)
Humanoid.MoveToFinished:wait()
end
end
end
local Path = PFinding:FindPathAsync(Mob.Torso.CFrame.p,getSeat().CFrame.p)
if Path.Status == Enum.PathStatus.Success then
local points = Path:GetWaypoints()
for _, point in pairs(points) do
if point.Action == Enum.PathWaypointAction.Jump then
Humanoid.Jump = true
end
Humanoid:MoveTo(point.Position)
Humanoid.MoveToFinished:wait()
end
end
end
coroutine.resume(fightRoutine)
--Follow
local OrderList = script.Parent.OrderQueue
local OrderExecutables = require(script.Parent.OrdersExec)
local MobService = require(game.ServerScriptService.MobFunctions)
local Mob = script.Parent
local Bot = require(script.Parent.BOT)
local AvailableOrders = {}
local CurrentOrder = nil
local bindableService = require(game.ReplicatedStorage.BindingService)()
local function insertOrder(order)
if order:IsA("Folder") then
AvailableOrders[#AvailableOrders+1] = MobService.OrderThread.new(order.Name,OrderExecutables[order:WaitForChild("Command",200).Value],order,script.Parent)
script.Parent.Parent.MobSpeaker.Speak:Fire(script.Parent.UnitName.Value,"Aye sir, order acknowledged")
end
end
local function getOrderByName(name)
for i, order in pairs(AvailableOrders) do
if order.OrderName == name then
return i, order
end
end
return nil
end
local function removeOrder(order)
local orderIndex, orderThread = getOrderByName(order.Name)
orderThread:Terminate()
table.remove(AvailableOrders,orderIndex)
end
for _, order in pairs(OrderList:GetChildren()) do
insertOrder(order)
end
OrderList.ChildAdded:connect(insertOrder)
OrderList.ChildRemoved:connect(removeOrder)
Mob.CancelCurrentOrder.Event:connect(function()
if CurrentOrder ~= nil then
CurrentOrder:Terminate()
end
end)
function getEnemiesInRange()
local result = {}
for _, enemy in pairs(workspace.Mobs:GetChildren()) do
if enemy then
if enemy:FindFirstChildOfClass("Humanoid") then
if require(enemy.BOT).Allegiance ~= Bot.Allegiance and enemy.PrimaryPart then
local distance = (enemy.PrimaryPart.CFrame.p - Mob.PrimaryPart.CFrame.p).magnitude
if distance < Bot.ChaseRange then
result[#result+1] = enemy
end
end
end
end
end
for _, enemy in pairs(bindableService.fetch("PlayerList")) do
if enemy then
if enemy.Character then
if enemy.Character:FindFirstChildOfClass("Humanoid") then
if enemy.Allegiance.Value ~= Bot.Allegiance then
local distance = (enemy.Character.PrimaryPart.CFrame.p - Mob.PrimaryPart.CFrame.p).magnitude
if distance < Bot.ChaseRange then
result[#result+1] = enemy.Character
for _, secondEnemy in pairs(enemy.playerArmy.Value:GetChildren()) do
if secondEnemy:FindFirstChildOfClass("Humanoid") and secondEnemy.PrimaryPart then
local distance = (secondEnemy.PrimaryPart.CFrame.p - Mob.PrimaryPart.CFrame.p).magnitude
if distance < Bot.ChaseRange then
result[#result+1] = secondEnemy
end
end
end
end
end
end
end
end
end
return result
end
while script.Parent.Human.Health > 0 do
if #AvailableOrders > 0 then
for i = 1,#AvailableOrders do
local Order = AvailableOrders[i]
script.Parent.CurrentOrder.Value = Order.OrderData
CurrentOrder = Order
CurrentOrder()
repeat wait() until coroutine.status(CurrentOrder.OrderTask) == "dead"
end
end
wait()
end
local ProgressionService = {}
local GamepassService = game:GetService("GamePassService")
local RemoteService = require(game.ReplicatedStorage.RemoteService)
function ProgressionService:PlayerHasPowerUp(plr,powerUp)
if powerUp == "Double XP" then
return GamepassService:PlayerHasPass(plr,450520088)
elseif powerUp == "Double Credits" then
return GamepassService:PlayerHasPass(plr,565148813)
end
end
function ProgressionService:AddXP(plr,amount,reason)
local total = ((ProgressionService:PlayerHasPowerUp(plr,"Double XP")) and (amount * 2) or amount)
if total ~= total then warn("NaN problem with XP gain") return end
if total < 0 then return end
plr.leaderstats.XP.Value = plr.leaderstats.XP.Value + total
if reason then
RemoteService.send("Client",plr,"DisplayAward",amount,reason)
end
end
return ProgressionService
local UI = script.Parent
local UnitManagerUI = UI.UnitManager
local ToolsFrame = UnitManagerUI.Tools
local ToolsChooser = ToolsFrame.Choices
local Player = game.Players.LocalPlayer
Player:WaitForChild("playerArmy",200)
local playerArmy = Player.playerArmy.Value
local Services = {};
Services.TweenService = game.TweenService
local Settings = require(game.Workspace.Settings.UnitManagement)
local OrderList = require(game.Workspace.Settings.UnitManagement.OrderCommands)
local ToolsList = Settings.Tools
local ToolConnections = {}
local UnitConnections = {}
local OrderConnections = {}
local Stacks = {Notifs = {},Frames = {}}
local RemS = require(game.ReplicatedStorage.RemoteService)
local RemoteService = require(game.ReplicatedStorage.RemoteService.Plugin_Army)(Player,Player.Name.."_Army",true,playerArmy)
local function INSERT(tableObj,item)
tableObj[#tableObj+1] = item
end
local function createTool(toolButtonName,tool)
local ToolButton = game.ReplicatedStorage.UMSTemplates.ToolTemplate:Clone()
ToolButton.Name = toolButtonName
ToolButton.Text = tool.Title:upper()
ToolButton.Parent = ToolsChooser
INSERT(ToolConnections,ToolButton.MouseButton1Click:connect(function()
for _, toolFrame in pairs(UnitManagerUI.ToolUIs:GetChildren()) do
if toolFrame:IsA("Frame") then
toolFrame.Visible = false
end
end
UnitManagerUI.ToolUIs:FindFirstChild(tool.ToolUIName).Visible = true
end))
return ToolButton
end
local function orderConfirmation(Order,Unit,Data)
local toReturn
local confirmationTemplate = game.ReplicatedStorage.UMSTemplates.ConfirmationalTemplates.OrderConfirmation
local confirmationClone = confirmationTemplate:Clone()
confirmationClone.Parent = UI
confirmationClone.Position = UDim2.new(0.5,-210,0,-confirmationClone.Size.Y.Offset)
confirmationClone.Visible = true
local Body = confirmationClone:WaitForChild('Body')
local Options = Body:WaitForChild('Options')
local Confirm,Cancel = Options:WaitForChild('Confirm'),Options:WaitForChild('Cancel')
local commandText = Body:WaitForChild('Order')
commandText.Text = '"'..Order..' '..Data..'"'
Body.Ques.Text = [[
ARE YOU SURE YOU WANT TO GIVE ]].. Unit:upper() ..[[ THE FOLLOWING ORDER? THIS COULD RESULT IN DEATH OR OTHER UNEXPECTED RESULTS.
]]
confirmationClone:TweenPosition(UDim2.new(0.5,-210,0.5,-70),"Out",'Quint',0.3,true)
Confirming = Confirm.MouseButton1Click:connect(function()
Confirming:Disconnect()
confirmationClone:TweenPosition(UDim2.new(0.5,-210,1,0),"Out",'Quint',0.3,true,function(Stat)
if Stat == Enum.TweenStatus.Completed then
confirmationClone:Destroy()
end
end)
toReturn = true
end)
Cancelling = Cancel.MouseButton1Click:connect(function()
Cancelling:Disconnect()
confirmationClone:TweenPosition(UDim2.new(0.5,-210,1,0),"Out",'Quint',0.3,true,function(Stat)
if Stat == Enum.TweenStatus.Completed then
confirmationClone:Destroy()
end
end)
toReturn = false
end)
repeat
wait()
until toReturn ~= nil
return toReturn
end
local function createTools()
for toolName, tool in pairs(ToolsList) do
local ToolButton = createTool(toolName,tool)
end
end
local function RefreshUnits()
for _, unitTag in pairs(UI.UnitMenu.UnitList:GetChildren()) do
if unitTag:IsA("TextButton") then
unitTag:Destroy()
end
end
for _, soldier in pairs(playerArmy:GetChildren()) do
if soldier:IsA("Model") and soldier:FindFirstChildOfClass("Humanoid") then
local UnitTag = game.ReplicatedStorage.UMSTemplates.UnitTemplate:Clone()
UnitTag.Name = soldier.UnitName.Value
UnitTag.Text = UnitTag.Name:upper()
UnitTag.Parent = UI.UnitMenu.UnitList
UnitTag.Unit.Value = soldier
INSERT(UnitConnections,UnitTag.MouseButton1Click:connect(function()
UnitManagerUI.Visible = true
UI.Mind.CurrentSoldier.Value = UnitTag.Unit.Value
end))
end
end
end
local function queryTable(Table,Data)
local tempTable = {}
for _,v in pairs(Table) do
if v:FindFirstChildOfClass("Humanoid") then
if string.lower(v.UnitName.Value):match(string.lower(Data)) then
table.insert(tempTable,v)
end
end
end
return tempTable
end
local function RefreshUnitsWithQuery(queryData)
for _, unitTag in pairs(UI.UnitMenu.UnitList:GetChildren()) do
if unitTag:IsA("TextButton") then
unitTag:Destroy()
end
end
for _, soldier in pairs(queryTable(playerArmy:GetChildren(),queryData)) do
if soldier:IsA("Model") and soldier:FindFirstChildOfClass("Humanoid") then
local UnitTag = game.ReplicatedStorage.UMSTemplates.UnitTemplate:Clone()
UnitTag.Name = soldier.UnitName.Value
UnitTag.Text = UnitTag.Name:upper()
UnitTag.Parent = UI.UnitMenu.UnitList
UnitTag.Unit.Value = soldier
INSERT(UnitConnections,UnitTag.MouseButton1Click:connect(function()
UnitManagerUI.Visible = true
UI.Mind.CurrentSoldier.Value = UnitTag.Unit.Value
end))
end
end
end
RefreshUnits()
UI.UnitMenu.Controls.Refresh.MouseButton1Click:connect(RefreshUnits)
UI.UnitMenu.Controls.Search.MouseButton1Click:connect(function()
if UI.UnitMenu.Controls.Decoration.Title.Visible then
UI.UnitMenu.Controls.Decoration.Title.Visible = false
-- searchBar.Position = UDim2.new(0,0,-1,0)
UI.UnitMenu.Controls.Decoration.Search.Visible = true
-- searchBar:TweenPosition(UDim2.new(0,0,0,0),'Out','Quint',0.3,true)
else
UI.UnitMenu.Controls.Decoration.Title.Visible = true
-- searchBar:TweenPosition(UDim2.new(0,0,1,0),'Out','Quint',0.3,true)
UI.UnitMenu.Controls.Decoration.Search.Visible = false
UI.UnitMenu.Controls.Decoration.Title.Visible = true
end
UI.UnitMenu.Controls.Decoration.Search.TextBox.Text = "Search.."
end)
UI.UnitMenu.Controls.Decoration.Search.TextBox.FocusLost:connect(function(enter)
if UI.UnitMenu.Controls.Decoration.Search.TextBox.Text ~= '' and UI.UnitMenu.Controls.Decoration.Search.TextBox.Text ~= "Search.." then
RefreshUnitsWithQuery(UI.UnitMenu.Controls.Decoration.Search.TextBox.Text)
end
end)
UI.Mind.CurrentSoldier.Changed:connect(function(soldier)
if soldier then
UnitManagerUI.Controls.Decoration.Title.Text = soldier.UnitName.Value:upper() .. " - Unit Manager"
else
UnitManagerUI.Controls.Decoration.Title.Text = "UNIT ALPHA - Unit Manager"
end
end)
local runAsBackgroundTask = function(task)
local bGround = UI.Background
local bGroundState = {
Completed = false;
Cancelled = false;
}
local tweens = {
In = TweenInfo.new(
0.5,
Enum.EasingStyle.Quad,
Enum.EasingDirection.In,
0,
false,
0
);
Out = TweenInfo.new(
0.5,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
0,
false,
0
);
}
local tweenGoals = {
In = {
Transparency = 0.5;
};
Out = {
Transparency = 1;
};
}
local BackgroundAnimations = {
In = Services.TweenService:Create(bGround,tweens.In,tweenGoals.In);
Out = Services.TweenService:Create(bGround,tweens.Out,tweenGoals.Out);
};
BackgroundAnimations.In.Completed:connect(function(playBackState)
if playBackState == Enum.PlaybackState.Completed then
task(bGroundState)
repeat wait() until bGroundState.Completed
BackgroundAnimations.Out:Play()
end
end)
BackgroundAnimations.In:Play()
end
for orderName, order in pairs(OrderList) do
local OrderTag = game.ReplicatedStorage.UMSTemplates.OrderTemplate:Clone()
OrderTag.Name = orderName
OrderTag.Text = order.HumanName
OrderTag.Parent = UnitManagerUI.ToolUIs.OrderGiver.Choices
OrderTag.Command.Value = orderName:upper()
local orderVars = {
getOrderUI = function(orderName)
local order = OrderList[orderName]
if order then
local orderOption = order.OptionsName
return UI.OrderGUIs:FindFirstChild(orderOption)
end
return nil
end;
runAsBackground = runAsBackgroundTask;
hideUIManager = function()
UnitManagerUI.Visible = false;
end;
UI = UI;
Player = Player;
};
INSERT(OrderConnections, OrderTag.MouseButton1Click:connect(function()
local authorized2 = nil
if Player.PlayerScripts.CustomUIOrderActions:FindFirstChild(orderName) then
local action = require(Player.PlayerScripts.CustomUIOrderActions:FindFirstChild(orderName))
authorized2 = action(orderVars)
end
local authorized
if order.OptionsName ~= "None" then
authorized = (orderConfirmation(OrderTag.Command.Value:upper(),UI.Mind.CurrentSoldier.Value.UnitName.Value,tostring(UI.OrderGUIs:FindFirstChild(order.OptionsName).OptionData:FindFirstChild(order.AuthorizationOption).Value)) and (authorized2 ~= nil and authorized2 or nil))
end
if authorized then
local OrderObj = {
Command = OrderTag.Command.Value;
};
local CommandOptions = UI.OrderGUIs:FindFirstChild(order.OptionsName).OptionData
for _, data in pairs(CommandOptions:GetChildren()) do
OrderObj[data.Name] = data.Value
end
RemoteService.send("Server","RecieveOrder",UI.Mind.CurrentSoldier.Value,OrderObj)
CommandOptions:ClearAllChildren()
elseif order.OptionsName == "None" then
local OrderObj = {
Command = OrderTag.Command.Value;
};
RemoteService.send("Server","RecieveOrder",UI.Mind.CurrentSoldier.Value,OrderObj)
end
end))
end
UnitManagerUI.Controls.Exit.MouseButton1Click:connect(function()
UnitManagerUI.Visible = false
UI.Mind.CurrentSoldier.Value = nil
end)
local function pendNotif(Title,Desc,Data)
spawn(function()
local Notification = game.ReplicatedStorage.UMSTemplates.Notification
local notifClone = Notification:Clone()
local notifTitle = notifClone.Frame:WaitForChild('Title')
local notifExit = notifClone.Frame:WaitForChild('Close')
local notifDesc = notifClone.Frame:WaitForChild('Main')
notifClone.Name = 'Notification'
notifClone.Visible = true
notifClone.Parent = Notification:Clone()
notifTitle.Text = Title
notifDesc.Text = Desc
local S = Instance.new('Sound',Services.Workspace.CurrentCamera)
S.Name = 'Notification'
S.SoundId = 'rbxassetid://255881176'
S.Volume = 1
S.Pitch = 1
S.PlayOnRemove = true
S:Destroy()
notifExit.MouseButton1Click:connect(function()
for a,b in pairs(Stacks.Notifs) do
if b == notifClone then
table.remove(Stacks.Notifs,a)
end
end
notifClone:Destroy()
figureNotifs(Stacks.Notifs,Notification)
end)
notifDesc.MouseButton1Click:connect(function()
for a,b in pairs(Stacks.Notifs) do
if b == notifClone then
table.remove(Stacks.Notifs,a)
end
end
notifClone:Destroy()
figureNotifs(Stacks.Notifs,Notification)
end)
table.insert(Stacks.Notifs,notifClone)
figureNotifs(Stacks.Notifs,Notification)
end)
end
function figureNotifs(Stack,Container)
local stacksize = 0
local i = #Stack
while i > 0 do
local gui = Stack[i]
if gui then
stacksize = stacksize+gui.AbsoluteSize.Y+5
local desiredpos = UDim2.new(0,0,1,-stacksize)
if gui.Position ~= desiredpos then
if stacksize == 65 then
gui.Position = UDim2.new(0,0,1,0)
end
gui:TweenPosition(desiredpos,"Out","Quint",0.3,true)
if desiredpos.Y.Offset<-Container.AbsoluteSize.Y and gui.Name ~= "RemovingThis" then
gui.Name="RemovingThis"
table.remove(Stack,i)
gui:Destroy()
end
end
end
i = i-1
end
end
RemS.listen("Client","Fetch","GetOrderOptions",function(command)
local orderVars = {
getOrderUI = function(orderName)
local order = OrderList[orderName]
if order then
local orderOption = order.OptionsName
return UI.OrderGUIs:FindFirstChild(orderOption)
end
return nil
end;
runAsBackground = runAsBackgroundTask;
hideUIManager = function()
UnitManagerUI.Visible = false;
end;
UI = UI;
Player = Player;
};
local authorization = nil
orderVars.runAsBackground(function(bGroundState)
orderVars.getOrderUI(command).Visible = true
orderVars.hideUIManager()
authorization = orderVars.getOrderUI(command).GetOptions:Invoke()
bGroundState.Completed = true
end)
repeat wait() until authorization ~= nil
if authorization then
local OrderOptions = {}
for _,orderOption in pairs(orderVars.getOrderUI(command).OptionData:GetChildren()) do
OrderOptions[orderOption.Name] = orderOption.Value
end
return OrderOptions
else
return {}
end
end)
function createOrder(order)
local orderUI = game.ReplicatedStorage.UMSTemplates.Order:Clone()
orderUI.Name = order.Name
orderUI.OrderName.Text = order.Command.Value:upper() .. " - " .. order.Name:sub(7)
orderUI.Status.Text = order.Status.Value:upper()
order.Status.Changed:connect(function(status)
if status:upper() ~= "COMPLETED" and status:upper() ~= "CANCELLED" then
orderUI.Status.Text = status:upper()
else
orderUI:Destroy()
pendNotif("DONE!","Mission Accomplished",nil)
end
end)
orderUI.FurtherAction.MouseButton1Click:connect(function()
runAsBackgroundTask(function(bgs)
local doAction, Action = nil
UnitManagerUI.ToolUIs.CurrentOrders.OrderActionMenu.Visible = true
UnitManagerUI.ToolUIs.CurrentOrders.OrderActionMenu.Actions.Cancel.MouseButton1Click:connect(function()
UnitManagerUI.ToolUIs.CurrentOrders.OrderActionMenu.Visible = false
doAction = false
end)
repeat wait() until doAction ~= nil
end)
end)
orderUI.Parent = UnitManagerUI.ToolUIs.CurrentOrders.Orders
end
RemoteService.listen("Client","Send","AddOrder",function(order)
if order ~= nil and order.Parent == UI.Mind.CurrentSoldier.Value.OrderQueue then
createOrder(order)
end
end)
UI.Mind.CurrentSoldier.Changed:connect(function(soldier)
for _, orderUI in pairs(UnitManagerUI.ToolUIs.CurrentOrders.Orders:GetChildren()) do
if orderUI:IsA("Frame") then
orderUI:Destroy()
end
end
if soldier then
for _, order in pairs(soldier.OrderQueue:GetChildren()) do
createOrder(order)
end
end
end)
createTools()
RemoteService.startClient()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment