Jump to content

Making existing current item cheaper but only for this specific character


Recommended Posts

I honestly don't know how to approach this. Browsing through past topics i found one way was to make an exact same prefab with a different name that can be crafted. While this method does work it completely ignores skins which I definitely want. 

Another method was trying to mimic the green amulet but unfortunately ive only found ways to reducing an entire tab's worth of items rather than a specific item itself. 

And lastly changing the recipe directly. Obviously this works but if i remember correctly, if i made it character specific then the original recipe of the item becomes unavailable and uncraftable. 

To be frank, I just want log armor to be cheaper for this character alone. Any ideas?

Edited by rons0n
Link to comment
Share on other sites

Maybe you add a new crafting recipe for log armor while keeping the prefab the same which cost less/different resources, but that mean you'd have 2 recipes & I don't know if it'd work with skins or not, or it could not work at all & I'm being dumb lol!

Link to comment
Share on other sites

Yeah I did that and it works for my character but if you play any other character the item will disappear for everyone else. Rather unfortunate, Guess i'll just have to live with a none skinned version. The enternal sadness :wilson_cry:

Thanks anyway!

Link to comment
Share on other sites

Well, it depends how much you want it.

First of all you'll probably need to work with the builder component(and/or builder_replica, as I don't really understand how the replicas work), and you'll want to see how the green amulet code works, so you'll be looking for ingredientmod in those files, for example this function:

function Builder:CanBuild(recname)
    local recipe = GetValidRecipe(recname)
    if recipe == nil then
        return false
    elseif not self.freebuildmode then
        for i, v in ipairs(recipe.ingredients) do
            if not self.inst.components.inventory:Has(v.type, math.max(1, RoundBiasedUp(v.amount * self.ingredientmod))) then
                return false
            end
        end
    end
    for i, v in ipairs(recipe.character_ingredients) do
        if not self:HasCharacterIngredient(v) then
            return false
        end
    end
    for i, v in ipairs(recipe.tech_ingredients) do
        if not self:HasTechIngredient(v) then
            return false
        end
    end
    return true
end

You'll likely want to change that to something of the sort:

function Builder:CanBuild(recname)
    local recipe = GetValidRecipe(recname)
    if recipe == nil then
        return false
    elseif not self.freebuildmode then
        for i, v in ipairs(recipe.ingredients) do

           if self.inst.prefab=="insert charprefab here" and recipe=="the reciepe I want to discount" then
             if not self.inst.components.inventory:Has(v.type, math.max(1, RoundBiasedUp("the discounts multiplier" * v.amount * self.ingredientmod))) then
                return false
            end
           else
            if not self.inst.components.inventory:Has(v.type, math.max(1, RoundBiasedUp(v.amount * self.ingredientmod))) then
                return false
            end
            end

        end
    end
    for i, v in ipairs(recipe.character_ingredients) do
        if not self:HasCharacterIngredient(v) then
            return false
        end
    end
    for i, v in ipairs(recipe.tech_ingredients) do
        if not self:HasTechIngredient(v) then
            return false
        end
    end
    return true
end

 

Edited by spideswine
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...