Jump to content

Help me with WX-like upgrade but with nightmare fuel


Recommended Posts

Hi there! So i wanted to make a character that can gain stats like WX-78 but instead of eating gears, they eat nightmare fuel. So i tried using WX's code but instead of

local function oneat(inst, food)
    if food and food.components.edible and food.components.edible.foodtype == FOODTYPE.GEARS then

        inst.level = inst.level + 1
        applyupgrades(inst) 
        inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")

i put

local function oneat(inst, food)
    if food and food.components.edible and food.components.edible.foodtype == FOODTYPE.NIGHTMAREFUEL then

        inst.level = inst.level + 1
        applyupgrades(inst) 
        inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")

I opened the game up and i didn't get a crash but it just didn't let me eat nightmare fuel or gears.

I also put in the tuning stats code from WX's files

local function applyupgrades(inst)
    local max_upgrades = 15
    inst.level = math.min(inst.level, max_upgrades)

    local hunger_percent = inst.components.hunger:GetPercent()
    local health_percent = inst.components.health:GetPercent()
    local sanity_percent = inst.components.sanity:GetPercent()

    inst.components.hunger.max = math.ceil(TUNING.WX78_MIN_HUNGER + inst.level * (TUNING.WX78_MAX_HUNGER - TUNING.WX78_MIN_HUNGER) / max_upgrades)
    inst.components.health.maxhealth = math.ceil(TUNING.WX78_MIN_HEALTH + inst.level * (TUNING.WX78_MAX_HEALTH - TUNING.WX78_MIN_HEALTH) / max_upgrades)
    inst.components.sanity.max = math.ceil(TUNING.WX78_MIN_SANITY + inst.level * (TUNING.WX78_MAX_SANITY - TUNING.WX78_MIN_SANITY) / max_upgrades)

    inst.components.hunger:SetPercent(hunger_percent)
    inst.components.health:SetPercent(health_percent)

    local ignoresanity = inst.components.sanity.ignore
    inst.components.sanity.ignore = false
    inst.components.sanity:SetPercent(sanity_percent)
    inst.components.sanity.ignore = ignoresanity
end

I am a novice mod maker so I knew it wouldn't work. 

Can you guys help me?

 

Link to comment
Share on other sites

Well of course you need to add an edible component to the nightmarefuel prefab


 

Quote

inst:AddComponent("edible")
    inst.components.edible.foodtype = FOODTYPE.GEARS --Change this into FOODTYPE.NIGHTMAREFUEL
    inst.components.edible.healthvalue = TUNING.HEALING_HUGE -- Do whatever you wish with these 3
    inst.components.edible.hungervalue = TUNING.CALORIES_HUGE
    inst.components.edible.sanityvalue = TUNING.SANITY_HUGE

 

Link to comment
Share on other sites

Quote

AddPrefabPostInit("nightmarefuel", function(inst)
   inst:AddComponent("edible")
    inst.components.edible.foodtype = FOODTYPE.GEARS --Change this into FOODTYPE.NIGHTMAREFUEL
    inst.components.edible.healthvalue = TUNING.HEALING_HUGE -- Do whatever you wish with these 3
    inst.components.edible.hungervalue = TUNING.CALORIES_HUGE
    inst.components.edible.sanityvalue = TUNING.SANITY_HUGE
end)

Something like that.

Link to comment
Share on other sites

On 4/18/2019 at 6:37 PM, Hell-met said:

How would this be doable for an item that already has an edible component?

Say, eating a moonrock. It's already "edible" for rock lobsters but obviously not for players.

Change the characters diet to include rocks... not sure what diet that would be but rocklobstars or moleworms probably have it.

Link to comment
Share on other sites

7 minutes ago, MidrealmDM said:

Change the characters diet to include rocks... not sure what diet that would be but rocklobstars or moleworms probably have it.

thanks but I've figured it out. It's been more than a month after all.

Link to comment
Share on other sites

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
 Share

×
  • Create New...