Jump to content

How to create traits similar to existing ones?

Recommended Posts

After a long time away from PZ, I've returned to the game and am loving all the new improvements since I last played! I've of course been equally excited to get back into modding again. :)


I have been re-creating my old outdated mods such as my new professions, but I've hit upon something I never could figure out last and wanted to finally ask:


If I want to assign an existing trait (e.g. Graceful) to be given 'free' by a profession, this works fine except that the player can 'remove' that trait if they want to. This is to be expected; these traits weren't designed to be exclusive to a profession. Of course, this is visually ugly (duplicate traits in trait list) and not really the designed functionality.


The answer, I would have thought, would be to create a 'duplicate' of the desired existing trait (e.g. "Poised" for "Graceful") and set as an exclusive profession-only trait with a 0 point cost. Makes sense to me!


Except... how *do* I duplicate the functionality of an existing trait, such as Graceful or Light Eater or Brave? Unlike the simple traits that increase skill points, I can't find the "mechanics" of these traits anywhere in the game's files (lua or otherwise). In other words, if I make my own "Eats Less" trait, how do I make sure it has the same game effect as selecting "Light Eater"?


Presumably, there's some code somewhere that does some sort of "if has this trait, do X" but the place to find this is a total mystery to me, hence I have no idea how to code my own such traits!


If any experts here could even just point me in the right direction, I'd really appreciate it!

Share this post

Link to post
Share on other sites

you cant do this i think. i remember seeing the lua codes sometimes references directly to these traits so like if herbalist then can do this or if handy than +100 etc. the only way to do this is if you make a new trait and track down all the associated lua codes and add your trait in it.

function ISBuildAction:new(character, item, x, y, z, north, spriteName, time)    local o = {}    setmetatable(o, self)    self.__index = self    o.character = character;    o.item = item;    o.x = x;    o.y = y;    o.z = z;    o.north = north;    o.spriteName = spriteName;    o.stopOnWalk = true;    o.stopOnRun = true;    o.maxTime = time;    if character:HasTrait("Handy") then        o.maxTime = time - 50;    end--    o.maxTime = 500;    o.square = getCell():getGridSquare(x,y,z);    o.doSaw = true;    return o;end

This is 1 of the example with handy trait.


If you still desire to do this you can do so using editors such as notepad++ to find all the trait names in all files and replace them 1 by 1 good luck !

Share this post

Link to post
Share on other sites

Thanks for the reply, ShuiYin. I thought that might be the case (I saw several places in the code that specifically refereced traits as in "if has trait x"), so that makes sense. It's a shame the devs don't make the game a bit more moddable (since it already is very) by making these values rather than specific trait references (e.g. a buildTimeReduction type value set to -50 by taking the Handy trait).


As it stands, I'm happy to do the work to add references to my own custom (duplicated original) traits, but how would I do it for traits that don't seem to be referenced in the code anywhere human-readable? For example, if I want to make my own 'Graceful', where is the original trait used? With Handy, you can find that reference to it in the lua for building. For Graceful, I can't find it anywhere except the character creation screen lua!


Alternately, the other way to resolve this issue would be to ask the devs if there was a way to make *any* trait added by a profession (whether it is a profession-only trait or not) 'unremovable'. Would this be possible or too complex?

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...