mirror of
https://github.com/TemujinCalidius/SurvivorCore.git
synced 2026-08-14 00:58:01 +00:00
Merge pull request #63 from TemujinCalidius/fix/ghost-tools-spawn-safety
fix: ghost tools from unowned hotbar pins + demo spawn safety
This commit is contained in:
@@ -5,6 +5,17 @@ All notable changes to SurvivorCore are recorded here. The format follows
|
||||
[Semantic Versioning](https://semver.org/spec/v2.0.0.html). At release time, `## Unreleased`
|
||||
is promoted to the new version and `main` is tagged `vX.Y.Z`.
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Fixed
|
||||
- **Ghost tools** — the hotbar→Tool bridge now verifies the player actually CARRIES a pinned item
|
||||
before equipping it: a pin is only a pointer, and a stale/seeded pin without a backing stack
|
||||
could previously conjure a usable Tool out of thin air.
|
||||
- The hotbar now **dims** a pinned item's icon (same 0.45 convention as the Crafting tab) when the
|
||||
player has none of it, so an inert pin reads as inert.
|
||||
- Demo: the husks spawn farther out — new players are no longer farmed at the spawn point before
|
||||
they've picked up a weapon.
|
||||
|
||||
## 0.7.0 — 2026-07-06
|
||||
|
||||
### Added
|
||||
|
||||
@@ -580,8 +580,10 @@ local function buildWeaponTemplates()
|
||||
end
|
||||
buildWeaponTemplates()
|
||||
|
||||
SurvivorCore.Mobs.spawn("husk", CFrame.new(40, 5, 20), { respawn = true })
|
||||
SurvivorCore.Mobs.spawn("husk", CFrame.new(48, 5, 32), { respawn = true })
|
||||
-- Husks live out past their aggro+wander reach of spawn — new players shouldn't get farmed at
|
||||
-- the spawn point before they've picked up a weapon (they'll still hunt you in their territory).
|
||||
SurvivorCore.Mobs.spawn("husk", CFrame.new(70, 5, 45), { respawn = true })
|
||||
SurvivorCore.Mobs.spawn("husk", CFrame.new(82, 5, 58), { respawn = true })
|
||||
SurvivorCore.Mobs.spawn("boar", CFrame.new(-30, 5, 18))
|
||||
|
||||
-- The quest-giver post: offers `slay_husk` (hold E to accept; return to turn in). Any mesh works —
|
||||
|
||||
@@ -87,14 +87,17 @@ local function bindHotbar(root: Instance)
|
||||
local active = math.floor(tonumber(localPlayer:GetAttribute(InventoryTypes.HOTBAR_EQUIPPED_ATTR)) or 0)
|
||||
|
||||
local icon = slot:FindFirstChild("Icon")
|
||||
local qty = totalQty(itemId)
|
||||
if icon and (icon:IsA("ImageLabel") or icon:IsA("ImageButton")) then
|
||||
local id = if itemId ~= "" then SlotGrid.resolveItemIcon(itemId) else ""
|
||||
icon.Image = id
|
||||
icon.Visible = id ~= ""
|
||||
-- A pin without a backing stack is inert (the server refuses to use/equip it) — show it
|
||||
-- dimmed, the same 0.45 "can't afford" convention the Crafting tab uses.
|
||||
icon.ImageTransparency = if itemId ~= "" and qty <= 0 then 0.45 else 0
|
||||
end
|
||||
local count = slot:FindFirstChild("Count")
|
||||
if count and count:IsA("TextLabel") then
|
||||
local qty = totalQty(itemId)
|
||||
count.Text = if qty > 1 then tostring(qty) else ""
|
||||
count.Visible = qty > 1
|
||||
end
|
||||
|
||||
@@ -20,6 +20,7 @@ local RunService = game:GetService("RunService")
|
||||
assert(RunService:IsServer(), "SurvivorCore.ToolEquip is server-only — require it via SurvivorCore.start()")
|
||||
|
||||
local Registries = require(script.Parent.Parent.registries)
|
||||
local Inventory = require(script.Parent.Inventory)
|
||||
local InventoryTypes = require(script.Parent.Parent.shared.InventoryTypes)
|
||||
|
||||
local ToolEquip = {}
|
||||
@@ -119,6 +120,12 @@ local function refresh(player: Player)
|
||||
local def = itemId ~= "" and Registries.Items.get(itemId) or nil
|
||||
local toolType = def and def.toolType
|
||||
|
||||
-- Possession gate: a pin is only a POINTER — never equip an item the player doesn't actually
|
||||
-- carry (a stale/seeded pin without a backing stack would otherwise conjure a ghost tool).
|
||||
if toolType and Inventory.getQty(player, itemId) <= 0 then
|
||||
toolType = nil
|
||||
end
|
||||
|
||||
-- Already holding the right tool? Leave it (avoids re-equip flicker on a re-press).
|
||||
local held = currentEngineTool(player)
|
||||
if toolType and held and held:GetAttribute("_ItemId") == itemId then
|
||||
|
||||
Reference in New Issue
Block a user