Jump to content

Recommended Posts

I've been trying to mod a character with a signature Weapon that has fuel like the mining hat or a Lamp, but the more the fuel decreases, the more the power decreases. Unfortunately I have no substantial experience with modding, and I've not gotten much farther than a basic weapon with infinite durability.

Hi, you should be able to do this following how the Hambat weapon component is done, which has a custom function run when you'll be dealing damage which update them, they're just calculated it out of the freshness and what you'll need to do is instead apply it from the fuel left on it, as for the fuel part, you can look into how other refuelable are done and basically make it out of the two things together if you have easy understanding of the code, but in case here's how you could be doing :

-- add this local function up in your weapon file 
local function UpdateDamage(inst)
    if inst.components.fueled and inst.components.weapon then
        local dmg = TUNING.HAMBAT_DAMAGE * inst.components.fueled:GetPercent()
    	-- same as the hambat right now, but if you want it differently done then you can always replace the calculation method and numbers :)
        dmg = Remap(dmg, 0, TUNING.HAMBAT_DAMAGE, TUNING.HAMBAT_MIN_DAMAGE_MODIFIER*TUNING.HAMBAT_DAMAGE, TUNING.HAMBAT_DAMAGE)
        inst.components.weapon:SetDamage(dmg)
    end
end

-------------------

-- add this to your item main function (fn) after the weapon component :
inst.components.weapon:SetOnAttack(UpdateDamage)

-- still in the fn, you should configure the "fueled" component, look up mininglantern.lua or such but as long as you have the component set up then it will be alright,
inst:AddComponent("fueled")
inst.components.fueled.fueltype = FUELTYPE.CAVE
inst.components.fueled:InitializeFuelLevel(TUNING.LANTERN_LIGHTTIME)
-- many other things can be changed as for when to consume fuel (probably on equipped so check the onequip / unequip functions of your script vs lantern one or such

-- you can configure the tuning values with your owns (just replace with numbers directly) to anything you prefer and even the fueltype or create your own

If you have any other question just DM me and we can set it up together with more customisation for your preferences, also since you'll be told soon or ever, remember to post those modding related topics here which is more fit on the forums :encouragement:

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...