Peovonerb Posted November 26, 2017 Share Posted November 26, 2017 hello klei Users I have a favor to ask, I want to create my own mods but I first want to know how to modify files like the crowns here is a example: (first of all! I am not going to steal the mods and I am not taking credit of the same mods all credits are for the ones who made them I am just using them as a example) the obsidian crown from Obsidian Tools PLUS first of all I want to know how to change the durability of the crown Here is the Prefab Scripts (please tell me if this is the wrong file): ------------------------------------------------------------------------------------------ local assets= { Asset("ANIM", "anim/obsidiancrown.zip"), Asset("ANIM", "anim/obsidiancrown.zip"), Asset("ATLAS", "images/inventoryimages/obsidiancrown.xml"), Asset("IMAGE", "images/inventoryimages/obsidiancrown.tex"), } local prefabs = { "forcefieldfx", } local function fn() local function ruinshat_proc(inst, owner) inst:AddTag("forcefield") inst.components.armor:SetAbsorption(TUNING.FULL_ABSORPTION) local fx = SpawnPrefab("forcefieldfx") fx.entity:SetParent(owner.entity) fx.Transform:SetPosition(0, 0.2, 0) local fx_hitanim = function() fx.AnimState:PlayAnimation("hit") fx.AnimState:PushAnimation("idle_loop") end fx:ListenForEvent("blocked", fx_hitanim, owner) inst.components.armor.ontakedamage = function(inst, damage_amount) if owner then local sanity = owner.components.sanity if sanity then local unsaneness = damage_amount * TUNING.ARMOR_RUINSHAT_DMG_AS_SANITY sanity:DoDelta(-unsaneness, false) end end end inst.active = true owner:DoTaskInTime(--[[Duration]] TUNING.ARMOR_RUINSHAT_DURATION, function() fx:RemoveEventCallback("blocked", fx_hitanim, owner) fx.kill_fx(fx) if inst:IsValid() then inst:RemoveTag("forcefield") inst.components.armor.ontakedamage = nil inst.components.armor:SetAbsorption(TUNING.ARMOR_RUINSHAT_ABSORPTION) owner:DoTaskInTime(--[[Cooldown]] TUNING.ARMOR_RUINSHAT_COOLDOWN, function() inst.active = false end) end end) end local function tryproc(inst, owner) if not inst.active and math.random() < --[[ Chance to proc ]] TUNING.ARMOR_RUINSHAT_PROC_CHANCE then ruinshat_proc(inst, owner) end end local function OnBlocked(owner, data) owner.SoundEmitter:PlaySound("dontstarve_DLC002/common/armour/obsidian") if (data.weapon == nil or (not data.weapon:HasTag("projectile") and data.weapon.projectile == nil)) and data.attacker and data.attacker.components.burnable and (data.attacker.components.combat == nil or (data.attacker.components.combat.defaultdamage > 0)) then data.attacker.components.burnable:Ignite() end end local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("swap_hat", "obsidiancrown", "swap_hat") owner.AnimState:Show("HAT") owner.AnimState:Hide("HAT_HAIR") owner.AnimState:Show("HAIR_NOHAT") owner.AnimState:Show("HAIR") owner.AnimState:Show("HEAD") owner.AnimState:Hide("HEAD_HAIR") inst:ListenForEvent("attacked", OnBlocked, owner) if owner.components.health then owner.components.health.fire_damage_scale = owner.components.health.fire_damage_scale - TUNING.ARMORDRAGONFLY_FIRE_RESIST end inst.procfn = function() tryproc(inst, owner) end owner:ListenForEvent("attacked", inst.procfn) end local function OnUnequip(inst, owner) owner.AnimState:Hide("HAT") owner.AnimState:Hide("HAT_HAIR") owner.AnimState:Show("HAIR_NOHAT") owner.AnimState:Show("HAIR") if owner:HasTag("player") then owner.AnimState:Show("HEAD") owner.AnimState:Hide("HEAD_HAIR") end inst:RemoveEventCallback("attacked", OnBlocked, owner) if owner.components.health then owner.components.health.fire_damage_scale = owner.components.health.fire_damage_scale + TUNING.ARMORDRAGONFLY_FIRE_RESIST end owner:RemoveEventCallback("attacked", inst.procfn) end local inst = CreateEntity() local trans = inst.entity:AddTransform() local anim = inst.entity:AddAnimState() MakeInventoryPhysics(inst) anim:SetBank("hat_bee_bw") anim:SetBuild("obsidiancrown") MakeInventoryFloatable(inst, "idle", "idle") inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "obsidiancrown" inst.components.inventoryitem.atlasname = "images/inventoryimages/obsidiancrown.xml" inst.components.inventoryitem.foleysound = "dontstarve_DLC002/common/foley/obsidian_armour" inst:AddComponent("waterproofer") inst.components.waterproofer:SetEffectiveness(0) inst.no_wet_prefix = true inst:AddComponent("equippable") inst.components.equippable.equipslot = EQUIPSLOTS.HEAD inst.components.equippable:SetOnEquip(OnEquip) inst.components.equippable:SetOnUnequip(OnUnequip) return inst end return Prefab("common/inventory/obsidiancrown", fn, assets, prefabs) ---------------------------------------------------------------------------------------------- I want to first know how to change the durability, time of the barrier and also change the sanity drain of it Link to comment Share on other sites More sharing options...
K1NGT1GER609 Posted December 3, 2017 Share Posted December 3, 2017 Hmm strange I don't see something like: inst.components.armor:InitCondition(TUNING.ARMOR_OBSIDIANCROWN, TUNING.ARMOR_OBSIDIANCROWN_ABSORPTION) --how many hitpoints it can protect before breaking, percentage the armour protects near equippable where its usually at. Change the arguments as you wish and read the note I put explaining the arguments respectively. As for sanity drain its under: inst.components.armor.ontakedamage = function(inst, damage_amount) if owner then local sanity = owner.components.sanity if sanity then local unsaneness = damage_amount * TUNING.ARMOR_RUINSHAT_DMG_AS_SANITY --math for the first argument sanity:DoDelta(-unsaneness, false) --dodelta subtracts the value in the first argument and second is overtime(bleed?) what ever that means end end end Change the dodelta argument and/or unsaneness equation. For the duration of the shield length: owner:DoTaskInTime(--[[Duration]] TUNING.ARMOR_RUINSHAT_DURATION, function() fx:RemoveEventCallback("blocked", fx_hitanim, owner) fx.kill_fx(fx) if inst:IsValid() then inst:RemoveTag("forcefield") inst.components.armor.ontakedamage = nil inst.components.armor:SetAbsorption(TUNING.ARMOR_RUINSHAT_ABSORPTION) owner:DoTaskInTime(--[[Cooldown]] TUNING.ARMOR_RUINSHAT_COOLDOWN, function() inst.active = false end) --Cooldown is a timer end end) end change the tuning.armor_ruinshat_cooldown to the amount of time you want. And I guess that should cover everything asked. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.