Jump to content

Survival Tailor MOD


Spar10

Recommended Posts

This mod expands on the Tailoring skill adding some new items to craft and material recipes.  Some of these items/recipes were already in some tailoring mods, but I felt the current ones were unbalanced or didn't factor in player skill.

 

This is my first PZ mod.  I have figured out a good bit of what I need to get things functional, but still learning.  I don't have a public release yet but it seems to be working well in my test games. I'll probably add it to the Steam Workshop this weekend, but wanted some feed back from community.

 

Current build includes some basic recipes, but will be expanded to use Tailoring skill for crafted results.

 

Craftable items:
   + Crude Backpack - Craftable early with just ripped sheets and a paperclip, low stats
   + Utility Pack Small - uses Fanny Pack slots (req Tailoring 1)
   + Utility Pack Large - uses Fanny Pack slots (req Tailoring 2)
   + Denim Backpack - Better 'school bag' (req Tailoring 3)
   + Utility Satchel - can be equipped with backpack  (req Tailoring 4)

Material recipes:
   + Salvage Ripped Sheets (for Thread)
       -Takes 5 Ripped Sheets, requires one tool: Paperclip/Tweezers/Needle/Suture Needle
       -Creates between 0 -10 units of thread based on Tailoring skill and some chance
       -Still working on craft balance, but I feel the current functionality is good.
   + Salvage Denin Strips (for Thread)
       -Similar to Salvage Ripped Sheets, but takes Denim Strips
   + Twist Thread into Twine
   + Unravel Twine
   + Twist Twine into Rope
   + Unravel Rope
   + Craft Sheet Rope
   + Craft Sheet Rope
   + Unravel Sheet Rope
   + Craft Sheet
   + Salvage Sheet (for Ripped Sheets)
   + Craft Tarp

Planned recipes (but not implemented)
   + Merge Thread/Twine (kind of working, but somewhat basic)
   + Craft Pillow
   + Salvage Pillow

 

 

I have some general questions about mechanics I haven't figured out yet.  Currently I'm trying to figure out how the AddXP function works and if it factors in Perks and Bonuses.  My current thought is that it doesn't, but need to do some more testing to be sure.

 

Another question I have is if ZombRand factors in Lucky and Unlucky traits?  I don't think it does. In my OnCreate recipe function I'm adding some custom code to give some change in chance if those attributes exist.  Below is my 'Salvage for Thread' code.  The recipe item destroys the original result thread item so it is created in the OnCreate function.

function stSalvageThread(items, result, player, selectedItem)
    local countFail = 0;
    -- Create base thread item to give to player (current gmame stats 1 thread = 10 thread units)
    local objThread = InventoryItemFactory.CreateItem("Base.Thread");
    -- Base chance with no skill is 15% with master skill at 95%
    local skillChance = 15 + (player:getPerkLevel(Perks.Tailoring)*8);

    --[[
    --This code is breaking the function
    if player:HasTrait("Lucky") then
        successChance = successChance + 100;
    elseif player:HasTrait("Unlucky") then
        successChance = successChance - 10;
    end
    --]]

    -- Calculate thread amount depending on tailoring skill and some chance
    for i=1,10 do
        successChance = ZombRand(-10,10) + skillChance
        if ZombRand(0,100) < successChance then
            -- Sucess, keep thread unit and gain some XP
            player:getXp():AddXP(Perks.Tailoring, 1);
        else
            -- Failed to get thread unit so take some from thread
            countFail = countFail + 1;
            objThread:Use();
        end
    end
    -- Give player final thread item
    if countFail < 10 then
        -- Only give thread if player didn't fail 10 times.
        player:getInventory():AddItem(objThread);
    end
end

 

I found the original code that had a chance to give thread in the 'Rip Sheets' function in the base game.  Is there a better way or function to change the thread units in a thread item?  I feel this method is 'less than perfect' to generate thread units, but it works.  Any feedback is welcome and I'm looking forward to learn more of the functions available and how to use them.

 

 

 

 

stSurvivalTailor.txt

Edited by Spar10
Updated lua function code
Link to comment
Share on other sites

Quote

Currently I'm trying to figure out how the AddXP function works

AddXP functions are called automatically when they are part of a recipe. You can set this in recipe definition.

AddXP functions can be added anywhere you like.

For Active xp a good time would be at perform() time of Timed Actions.

For Passive xp, follow your imagination.

 

Quote

and if it factors in Perks and Bonuses.

yes it does.

 

Quote

ZombRand factors in Lucky and Unlucky traits?

No id does not.

Vanilla lucky/unlucky is about loots so far.

 

have fun

Link to comment
Share on other sites

Tchernobill,  Thanks for the response.  So in my current code snip I have where I'm adding 1 xp if the rand chance is a success.  I'm actually testing it in game now and the XP gains are working.  Glad to know it does take into account perks and bonuses.  I was about to try and code that into my OnCreate functions. :)  What do you think about how I added Lucky and Unlucky chance modifiers to my stSalvageThread OnCreate function posted above?

 

Right now I'm messing with a TimedAction function to make a better merge thread and twine.  I don't enjoy clicking "Add To" on all my scraps separately.  I'm thinking about grabbing a total thread unit count from inventory and remove all the scraps and return a total of full Thread items plus one with the left over units. I found some useful function in the RapairAllClothing function that might do the trick. I'm just not sure how to remove the 'old thread units'.

 

    local threadArray = player:getInventory():getItemsFromType(thread:getType(), true);
    local threadCount = player:getInventory():getItemCount(thread:getType(), true);

Still learning lua, but I figure I can remove the found items in the array and then re-add thread based on total count.  In my timed action I can have the maxTime based on the total thread that has to be merged. 

 

 

 

 

 

 

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
×
×
  • Create New...