mirror of
https://github.com/HaodongMo/ARC-9.git
synced 2025-03-04 03:02:58 -05:00
press r on slot or folder to randomzie it but when you try randmize 3dslot while some att extended it wont work
This commit is contained in:
parent
efe396f087
commit
a686d2b514
@ -1,5 +1,7 @@
|
||||
ARC9.KeyPressed_Menu = false
|
||||
|
||||
local randsound = "arc9/newui/ui_part_randomize.ogg"
|
||||
|
||||
hook.Add("PlayerBindPress", "ARC9_Binds", function(ply, bind, pressed, code)
|
||||
local wpn = ply:GetActiveWeapon()
|
||||
|
||||
@ -56,6 +58,61 @@ hook.Add("PlayerBindPress", "ARC9_Binds", function(ply, bind, pressed, code)
|
||||
return true
|
||||
end
|
||||
|
||||
if bind == "+reload" and wpn:GetCustomize() then
|
||||
local attpnl = wpn.CustomizeLastHovered
|
||||
local foldpnl = wpn.CustomizeLastHoveredFolder
|
||||
local slotpnl = wpn.CustomizeLastHoveredSlot
|
||||
|
||||
if attpnl and attpnl:IsHovered() then
|
||||
-- print("att", attpnl.att)
|
||||
end
|
||||
|
||||
if foldpnl and foldpnl:IsHovered() then
|
||||
-- print("folder", foldpnl)
|
||||
|
||||
local randompool = {}
|
||||
|
||||
for _, v in ipairs(wpn.BottomBarAtts) do
|
||||
local atbl = ARC9.GetAttTable(v.att)
|
||||
|
||||
local checkfolder = foldpnl.folder
|
||||
|
||||
local pathprefix = string.Implode("/", wpn.BottomBarPath)
|
||||
if pathprefix != "" then checkfolder = pathprefix .. "/" .. foldpnl.folder end
|
||||
|
||||
if atbl.Folder == checkfolder or (foldpnl.folder == "!favorites" and ARC9.Favorites[v.att]) then
|
||||
table.insert(randompool, atbl)
|
||||
randompool[#randompool].fuckthis = v.slot
|
||||
end
|
||||
end
|
||||
|
||||
local thatatt = randompool[math.random(0, #randompool)]
|
||||
if thatatt then
|
||||
wpn:Attach(thatatt.fuckthis, thatatt.ShortName, true)
|
||||
end
|
||||
|
||||
surface.PlaySound(randsound)
|
||||
end
|
||||
|
||||
if slotpnl and (slotpnl:IsHovered() or slotpnl.validforrand) then
|
||||
if !wpn:GetSlotBlocked(slotpnl.slot) then
|
||||
-- print("slot", slotpnl)
|
||||
|
||||
wpn:RollRandomAtts({[1] = wpn:LocateSlotFromAddress(slotpnl.slot.Address)}, true)
|
||||
|
||||
wpn:PruneAttachments()
|
||||
wpn:PostModify()
|
||||
wpn:SendWeapon()
|
||||
|
||||
timer.Simple(0, function() wpn:CreateHUD_Bottom() end)
|
||||
|
||||
surface.PlaySound(randsound)
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if wpn:GetInSights() then
|
||||
if bind == "invnext" then
|
||||
wpn:Scroll(1)
|
||||
|
@ -740,4 +740,4 @@ L["settings.developer.reload"] = "Reload"
|
||||
|
||||
-- october 8
|
||||
|
||||
L["customize.hint.randomize"] = "Random folder attachment"
|
||||
L["customize.hint.randomize"] = "Attach random"
|
@ -808,6 +808,7 @@ function SWEP:CreateCustomizeHUD()
|
||||
|
||||
if hoveredslot then
|
||||
self.CustomizeHints["customize.hint.select"] = "customize.hint.expand"
|
||||
self.CustomizeHints["customize.hint.random"] = "customize.hint.randomize"
|
||||
if slot.Installed then
|
||||
self.CustomizeHints["customize.hint.deselect"] = "customize.hint.unattach"
|
||||
end
|
||||
@ -981,7 +982,7 @@ function SWEP:CreateCustomizeHUD()
|
||||
self.CustomizeYaw = self.CustomizeYaw + (dy / ARC9ScreenScale(8)) * 3
|
||||
|
||||
end
|
||||
elseif self:GetOwner():KeyDown(IN_RELOAD) then
|
||||
elseif self:GetOwner():KeyDown(IN_RELOAD) and self2:IsHovered() then
|
||||
self.CustomizePanX = Lerp(0.25, self.CustomizePanX, 0)
|
||||
self.CustomizePanY = Lerp(0.25, self.CustomizePanY, 0)
|
||||
self.CustomizePitch = Lerp(0.25, self.CustomizePitch, 0)
|
||||
@ -1099,6 +1100,11 @@ function SWEP:CreateCustomizeHUD()
|
||||
glyph = ARC9.GetBindKey("impulse 100"),
|
||||
hidden = true,
|
||||
},
|
||||
{
|
||||
action = "customize.hint.random",
|
||||
glyph = ARC9.GetBindKey("+reload"),
|
||||
hidden = true,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -192,36 +192,38 @@ local function enterfolder(self, scroll, slottbl, fname)
|
||||
enterfolder(self, scroll, slottbl, self2.folder)
|
||||
surface.PlaySound(foldersound)
|
||||
end
|
||||
if kc == MOUSE_RIGHT then -- randomizing attachments from folder!
|
||||
local randompool = {}
|
||||
-- if kc == MOUSE_RIGHT then -- randomizing attachments from folder! -- Moved to cl_bind reload
|
||||
-- local randompool = {}
|
||||
|
||||
for _, v in ipairs(self.BottomBarAtts) do
|
||||
local atbl = ARC9.GetAttTable(v.att)
|
||||
-- for _, v in ipairs(self.BottomBarAtts) do
|
||||
-- local atbl = ARC9.GetAttTable(v.att)
|
||||
|
||||
local checkfolder = self2.folder
|
||||
-- local checkfolder = self2.folder
|
||||
|
||||
local pathprefix = string.Implode("/", self.BottomBarPath)
|
||||
if pathprefix != "" then checkfolder = pathprefix .. "/" .. self2.folder end
|
||||
-- local pathprefix = string.Implode("/", self.BottomBarPath)
|
||||
-- if pathprefix != "" then checkfolder = pathprefix .. "/" .. self2.folder end
|
||||
|
||||
if atbl.Folder == checkfolder or (self2.folder == "!favorites" and ARC9.Favorites[v.att]) then
|
||||
table.insert(randompool, atbl)
|
||||
randompool[#randompool].fuckthis = v.slot
|
||||
end
|
||||
end
|
||||
-- if atbl.Folder == checkfolder or (self2.folder == "!favorites" and ARC9.Favorites[v.att]) then
|
||||
-- table.insert(randompool, atbl)
|
||||
-- randompool[#randompool].fuckthis = v.slot
|
||||
-- end
|
||||
-- end
|
||||
|
||||
local thatatt = randompool[math.random(0, #randompool)]
|
||||
if thatatt then
|
||||
self:Attach(thatatt.fuckthis, thatatt.ShortName, true)
|
||||
end
|
||||
surface.PlaySound(tabsound)
|
||||
end
|
||||
-- local thatatt = randompool[math.random(0, #randompool)]
|
||||
-- if thatatt then
|
||||
-- self:Attach(thatatt.fuckthis, thatatt.ShortName, true)
|
||||
-- end
|
||||
|
||||
-- surface.PlaySound(tabsound)
|
||||
-- end
|
||||
end
|
||||
|
||||
folderbtn.Think = function(self2)
|
||||
if !IsValid(self) then return end
|
||||
if self2:IsHovered() then
|
||||
self.CustomizeHints["customize.hint.select"] = "customize.hint.select"
|
||||
self.CustomizeHints["customize.hint.deselect"] = "customize.hint.randomize"
|
||||
self.CustomizeHints["customize.hint.random"] = "customize.hint.randomize"
|
||||
self.CustomizeLastHoveredFolder = self2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -123,16 +123,23 @@ function SWEP:CreateHUD_Slots(scroll)
|
||||
|
||||
slotbtn.Think = function(self2)
|
||||
if !IsValid(self) then return end
|
||||
|
||||
if self2.slot.lowerbutton.OverrideHovered then
|
||||
self.CustomizeLastHoveredSlot = self2
|
||||
self.CustomizeLastHoveredSlot.validforrand = true
|
||||
end
|
||||
|
||||
if self2:IsHovered() then
|
||||
self.CustomizeHints["customize.hint.select"] = "customize.hint.expand"
|
||||
self.CustomizeHints["customize.hint.random"] = "customize.hint.randomize"
|
||||
if self2.slot.Installed then
|
||||
self.CustomizeHints["customize.hint.deselect"] = "customize.hint.unattach"
|
||||
end
|
||||
self2.slot.hovered = true
|
||||
self.CustomizeLastHoveredSlot = self2
|
||||
else
|
||||
self2.slot.hovered = false
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -119,8 +119,9 @@ function SWEP:QueueForRandomize()
|
||||
table.insert(ARC9.RandomizeQueue, self)
|
||||
end
|
||||
|
||||
function SWEP:RollRandomAtts(tree)
|
||||
function SWEP:RollRandomAtts(tree, nofuther)
|
||||
local attchance = 66
|
||||
if nofuther then attchance = 999 end
|
||||
|
||||
for i, slottbl in pairs(tree) do
|
||||
if slottbl.MergeSlots then
|
||||
@ -144,7 +145,7 @@ function SWEP:RollRandomAtts(tree)
|
||||
|
||||
slottbl.Installed = att
|
||||
|
||||
if atttbl.Attachments then
|
||||
if !nofuther and atttbl.Attachments then
|
||||
slottbl.SubAttachments = table.Copy(atttbl.Attachments)
|
||||
self:RollRandomAtts(slottbl.SubAttachments)
|
||||
end
|
||||
|
BIN
sound/arc9/newui/ui_part_randomize.ogg
Normal file
BIN
sound/arc9/newui/ui_part_randomize.ogg
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user