GLOBAL.setmetatable(GLOBAL.getfenv(1), {__index = function(self, index) return GLOBAL.rawget(GLOBAL, index) end}) local GLOBAL = GLOBAL local TheNet = GLOBAL.TheNet local EntityScript = GLOBAL.EntityScript local EQUIPSLOTS = GLOBAL.EQUIPSLOTS local function IsMasterSim() return GLOBAL.TheWorld ~= nil and GLOBAL.TheWorld.ismastersim end Assets = { Asset("ANIM", "anim/inventory_fx_shadow.zip"), } local function IsWearingDreadstoneArmor(inst) if inst == nil or not inst:IsValid() then return false end local inventory = inst.components and inst.components.inventory if inventory == nil then return false end local body_item = inventory:GetEquippedItem(EQUIPSLOTS.BODY) if body_item ~= nil and body_item.prefab == "armordreadstone" then return true end if inventory.equipslots ~= nil then for _, item in pairs(inventory.equipslots) do if item ~= nil and item.prefab == "armordreadstone" then return true end end end return false end local function HookAttackedHandler(sg) if sg == nil or sg.events == nil or sg.events.attacked == nil then return end if sg.events.attacked._dreadstone_attacked_wrapped then return end sg.events.attacked._dreadstone_attacked_wrapped = true local original_fn = sg.events.attacked.fn sg.events.attacked.fn = function(inst, data) if IsWearingDreadstoneArmor(inst) then local health = inst.components and inst.components.health local dead = health and health:IsDead() local locked = inst.sg and inst.sg:HasAnyStateTag("drowning", "falling") if inst.sg and inst.sg:HasStateTag("sleeping") then return original_fn(inst, data) end if inst.sg and inst.sg:HasStateTag("parrying") and data and data.redirected then return original_fn(inst, data) end if not dead and not locked and inst.SoundEmitter then inst.SoundEmitter:PlaySound("dontstarve/wilson/hit") end return end return original_fn(inst, data) end end AddStategraphPostInit("wilson", HookAttackedHandler) if not EntityScript._dreadstone_knockback_blocker_installed then EntityScript._dreadstone_knockback_blocker_installed = true local _PushEvent = EntityScript.PushEvent function EntityScript:PushEvent(event, data, ...) if event == "knockback" then if self:HasTag("player") and IsWearingDreadstoneArmor(self) then return end end return _PushEvent(self, event, data, ...) end end local function HookKnockbackHandler(sg) if sg == nil or sg.events == nil or sg.events.knockback == nil then return end if sg.events.knockback._dreadstone_knockback_wrapped then return end sg.events.knockback._dreadstone_knockback_wrapped = true local original_fn = sg.events.knockback.fn sg.events.knockback.fn = function(inst, data) if IsWearingDreadstoneArmor(inst) then return end return original_fn(inst, data) end end AddStategraphPostInit("wilson", HookKnockbackHandler) -- ============================================================ -- 拦截“打落武器”行为 -- ============================================================ local function InstallWeaponDropBlock(inst) if not IsMasterSim() then return end if inst._dreadstone_weapon_block_installed then return end inst._dreadstone_weapon_block_installed = true inst:DoTaskInTime(0, function() if not inst:IsValid() then return end local inventory = inst.components and inst.components.inventory if inventory == nil then return end local old_DropItem = inventory.DropItem if old_DropItem == nil then return end inventory.DropItem = function(self, item, ...) if IsWearingDreadstoneArmor(inst) then if item ~= nil and item.components and item.components.equippable then if item.components.equippable.equipslot == EQUIPSLOTS.HANDS then return end end end return old_DropItem(self, item, ...) end end) end AddPlayerPostInit(function(inst) if inst.prefab == "wathgrithr" then InstallWeaponDropBlock(inst) end end) -- ============================================================ -- 绝望石盔甲移速加成 + 耐久回复速度提升至三倍 -- ============================================================ AddPrefabPostInit("armordreadstone", function(inst) if not IsMasterSim() then return end if inst.components.equippable ~= nil then inst.components.equippable.walkspeedmult = 1.10 end -- 提升自动回复耐久速度至原来的三倍 if inst.components.finiteuses ~= nil then local old_update = inst.components.finiteuses.Update if old_update ~= nil then inst.components.finiteuses.Update = function(self, dt, ...) -- 把每一帧的时间乘以 3,让回复速度变成三倍 return old_update(self, dt * 3, ...) end end end end) -- ============================================================ -- 充能奔雷矛攻击特效与音效 -- ============================================================ local function ChargedSpearOnAttack(inst, attacker, target) if target == nil or not target:IsValid() then return end if attacker == nil or not attacker:IsValid() then return end local spark = SpawnPrefab("electrichitsparks") if spark ~= nil then spark:AlignToTarget(target, attacker, true) end local fx = SpawnPrefab("wanda_attack_pocketwatch_old_fx") if fx ~= nil and fx.Transform ~= nil then local x, y, z = target:GetPosition():Get() fx.Transform:SetPosition(x, y + 1, z) end end AddPrefabPostInit("spear_wathgrithr_lightning_charged", function(inst) if not IsMasterSim() then return inst end if inst.components.weapon == nil then return inst end local old_onattack = inst.components.weapon.onattack inst.components.weapon:SetOnAttack(function(inst, attacker, target) if old_onattack then old_onattack(inst, attacker, target) end if attacker ~= nil and attacker.prefab == "wathgrithr" then ChargedSpearOnAttack(inst, attacker, target) end end) return inst end) -- ============================================================ -- 物品栏暗影特效 -- ============================================================ local UIAnim = GLOBAL.require("widgets/uianim") local function ShouldShowDreadstoneShadowFX(item) if item == nil then return false end local prefab = item.prefab if prefab == "armordreadstone" or prefab == "dreadstonehat" then return true end if item.HasTag and (item:HasTag("dreadstone_icon_shadow_fx") or item:HasTag("dreadstone")) then return true end return false end local function ApplyShadowFX(itemtile) if itemtile == nil or itemtile.image == nil then return end if itemtile.shadowfx == nil then local fx = itemtile.image:AddChild(UIAnim()) fx:GetAnimState():SetBank("inventory_fx_shadow") fx:GetAnimState():SetBuild("inventory_fx_shadow") fx:GetAnimState():PlayAnimation("idle", true) if fx:GetAnimState().GetCurrentAnimationTime then local total = fx:GetAnimState():GetCurrentAnimationTime() if total and total > 0 then fx:GetAnimState():SetTime(math.random() * total) end end fx:SetScale(0.25) fx:GetAnimState():AnimateWhilePaused(false) fx:SetClickable(false) itemtile.shadowfx = fx end if itemtile.StopUpdatingShadowFuel ~= nil then itemtile:StopUpdatingShadowFuel() end end local ItemTile = GLOBAL.require("widgets/itemtile") if ItemTile and not ItemTile._dreadstone_patched then ItemTile._dreadstone_patched = true local old_ToggleShadowFX = ItemTile.ToggleShadowFX ItemTile.ToggleShadowFX = function(self) if ShouldShowDreadstoneShadowFX(self.item) then ApplyShadowFX(self) return end return old_ToggleShadowFX(self) end end AddClassPostConstruct("widgets/itemtile", function(self) if ShouldShowDreadstoneShadowFX(self.item) then ApplyShadowFX(self) end end)