Jump to content

Need help with scripting (Character,Items and UI)


Recommended Posts

EDIT:  All problems solved! Now on to balancing. :D

 

 

Hey all. I started making a character mod some months ago and had to put the breaks on it just as I was getting close to completing things. I've forgotten a lot of what I learned while making it and I'm going to need some serous help to hammer out the last few things I want to complete. I'm good on the art side of these tasks but I need some clever coders to save me from myself.

Task list

  • One of the updates that dropped while I was away seems to have broken crafting for my character using their custom "Dream" ingredient. Not sure what is broken.
  • I want to make a new tab on the crafting bar to put my characters item recipes under. Like WickerBottoms book crafting tab.

craftingtab_zpsmwukqcno.png

  • Not sure if It is possible but I want to make a bag that has two different sections. One that can act like a cooler to keep food fresh and another that is normal storage. I already made an item and UI asset for this but have no idea how to make it a reality script wise.

Dualbackpack_zpsmebp3nqg.png

  • Lastly I want to see if I can rework the way my characters items use Dream power. Currently his custom items have durability and wear down as normal, with the ability to consume dream power to repair them. However what I originally envisioned is that weapons and tools would directly siphon energy from the Dream Power meter instead of having durability. For example, say his axe costs 5 Dream to swing/chop/mine. Each time he preforms one of those actions the 5 dream would be depleted from the Dream meter. If the item is used with less than 5 Dream available it will break. The amount of Dream would be different for each item for balance reasons.

Any help would be very much appreciated. I can provide script files as needed

Edited by RetroMike
Link to comment
Share on other sites

Hi Mike. I have exactly opposite situation: I'm good at programing but have no artist to help me with drawing character. It would be nice to collaborate with you if you will agree. I prepared some code which should turn first 2 slots of regular backpack into ultimate freezer(but Termal Stone won't be any cooler). Also I can try to detach first 2 slots from others but I need your UI file in PNG format. Other task also looks interesting to me.

local require = GLOBAL.require

local TUNING = GLOBAL.TUNING
local FRAMES = GLOBAL.FRAMES

local function customUpdate(inst, dt)
    local TheWorld = GLOBAL.TheWorld
    if inst.components.perishable then

        local modifier = 1
        local owner = inst.components.inventoryitem and inst.components.inventoryitem.owner or nil
        if not owner and inst.components.occupier then
            owner = inst.components.occupier:GetOwner()
        end

        if owner then
            if owner:HasTag("2slotsNotPerish") and owner.components.container then
                if inst==owner.components.container:GetItemInSlot(1) or inst==owner.components.container:GetItemInSlot(2) then
                    return
                end
            end
            if owner:HasTag("fridge") then
                if inst:HasTag("frozen") and not owner:HasTag("nocool") and not owner:HasTag("lowcool") then
                    modifier = TUNING.PERISH_COLD_FROZEN_MULT
                else
                    modifier = TUNING.PERISH_FRIDGE_MULT
                end
            elseif owner:HasTag("spoiler") then
                modifier = TUNING.PERISH_GROUND_MULT
            elseif owner:HasTag("cage") and inst:HasTag("small_livestock") then
                modifier = TUNING.PERISH_CAGE_MULT
            end
        else
            modifier = TUNING.PERISH_GROUND_MULT
        end

        if inst:GetIsWet() then
            modifier = modifier * TUNING.PERISH_WET_MULT
        end

        
        if TheWorld.state.temperature < 0 then
            if inst:HasTag("frozen") and not inst.components.perishable.frozenfiremult then
                modifier = TUNING.PERISH_COLD_FROZEN_MULT
            else
                modifier = modifier * TUNING.PERISH_WINTER_MULT
            end
        end

        if inst.components.perishable.frozenfiremult then
            modifier = modifier * TUNING.PERISH_FROZEN_FIRE_MULT
        end

        if TheWorld.state.temperature > TUNING.OVERHEAT_TEMP then
            modifier = modifier * TUNING.PERISH_SUMMER_MULT
        end

        modifier = modifier * inst.components.perishable.localPerishMultiplyer

        modifier = modifier * TUNING.PERISH_GLOBAL_MULT
        
        local old_val = inst.components.perishable.perishremainingtime
        local delta = dt or (10 + math.random()*FRAMES*8)
        if inst.components.perishable.perishremainingtime then
            inst.components.perishable.perishremainingtime = inst.components.perishable.perishremainingtime - delta*modifier
            if math.floor(old_val*100) ~= math.floor(inst.components.perishable.perishremainingtime*100) then
                inst:PushEvent("perishchange", {percent = inst.components.perishable:GetPercent()})
            end
        end

        -- Cool off hot foods over time (faster if in a fridge)
        if inst.components.edible and inst.components.edible.temperaturedelta and inst.components.edible.temperaturedelta > 0 then
            if owner and owner:HasTag("fridge") then
                if not owner:HasTag("nocool") then
                    inst.components.edible.temperatureduration = inst.components.edible.temperatureduration - 1
                end
            elseif TheWorld.state.temperature < TUNING.OVERHEAT_TEMP - 5 then
                inst.components.edible.temperatureduration = inst.components.edible.temperatureduration - .25
            end
            if inst.components.edible.temperatureduration < 0 then inst.components.edible.temperatureduration = 0 end
        end
        
        --trigger the next callback
        if inst.components.perishable.perishremainingtime and inst.components.perishable.perishremainingtime <= 0 then
            inst.components.perishable:Perish()
        end
    end
end

 

local function perish_postinit(self)
    function self:StartPerishing()
        if self.updatetask ~= nil then
            self.updatetask:Cancel()
            self.updatetask = nil
        end

        local dt = 10 + math.random()*FRAMES*8
        self.updatetask = self.inst:DoPeriodicTask(dt, customUpdate, math.random()*2, dt)
    end

    function self:LongUpdate(dt)
        if self.updatetask ~= nil then
            customUpdate(self.inst, dt or 0)
        end
    end
end

AddComponentPostInit("perishable",perish_postinit)

local function backpack_postinit(inst)
    inst:AddTag("2slotsNotPerish")
end
AddPrefabPostInit("backpack", backpack_postinit)

dU7kgnD.jpg

Link to comment
Share on other sites

Dude that's awesome. I'm always up for a little cross skill collaboration, I've done a lot of that in the past on this character mod actually. I'm not at my computer at the moment but once I get a chance I can upload a png of the backpack UI. What exactly are you looking to make with your character?

Link to comment
Share on other sites

On 03.12.2016 at 5:12 AM, RetroMike said:

 

  • I want to make a new tab on the crafting bar to put my characters item recipes under. Like WickerBottoms book crafting tab.

 

craftingtab_zpsmwukqcno.png

FTEszZ2.jpg

--adding tab

local recipe_tab = AddRecipeTab(                                
"Dreams", -- Name of the tab to show the player.                                
902, -- Sort Order #, 999 will place it at the bottom of the list.                                
"images/imagas/tab_icon.xml",
"tab_icon.tex",                              
"dreamer" -- Builder Tag if one is needed, character must have this tag in order to see tab.                                
)

--adding recipe to the tab

AddRecipe("mstick", { Ingredient("rabbit", 4), Ingredient("livinglog", 1)}, recipe_tab, TECH.NONE, nil, nil, nil, nil, nil, "images/inventoryimages/mstick.xml", "mstick.tex")

Don't forget to add "dreamer" tag to your character and assert icon files.

 

tab_icon.rar

Link to comment
Share on other sites

Thanks again. :D Sending a steam message with some files for you to dig into. I'm sure you will see that before this reply. I think working with the character would be helpful since it will give you a good idea of how it has been built and what names the functions currently operate on. 

Having the character and its items will also give you an idea of my art quality. I should be free to start helping on art assets tomorrow. So once you know what you need done just let me know. 

 

EDIT: The Pokemon trainer character is almost done. I just have to finish a few more faces, a portrait and some small icons. 

Edited by RetroMike
Link to comment
Share on other sites

7 hours ago, popitup said:

Just saw it on Steam. I had a lot of fun working on this project with you. I'm gonna give the mod a try later and see how the pokeball works. :D

I just now noticed I forgot the paper cut out look for the main portrait. I can update that so it matches the other portraits if you like.

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...