PDA

View Full Version : Custom Harvestables: An overview


plasticbox
24th Jan 2016, 4:56 PM
Custom harvestables are actually not very complex (unless you make them complex =P); here's an overview of what you need to have a custom harvestable in game:


1. Harvestable object:

1.1 Object mesh for the harvestable: The Maxian harvestables I've seen so far have two geometry states, one for the seed and one for the fruit -- I haven't seen the seed being used anywhere though (when sims plant stuff in TS4, the actual fruit mesh is being used, not the seed mesh). So if you clone a harvestable to make a new one, you actually only need to make a fruit mesh and assign that to both states. See the Custom Foods thread in this forum for more info on how to deal with states.

1.2 Object texture for the harvestable: The Maxis fruits and flowers all use the same texture, which contains all the fruits/veggies/flowers in game. Whatever you do, do not override this, since it's being updated with nearly every patch. Just give your harvestable a small individual texture (64x64 should be plenty).

Harvestables need to have a 32bit ID, I'm not sure about the group atm.


2. Harvestable plant:

2.1 (somewhat optional) Plant mesh: The plants usually consist of several different objects; one or two for the sprout state (those are mostly generic, i.e. a bunch of plants is using the same sprout object), plus the actual grown-up plant which (as far as I've seen) has two states, "healthy" 0xAB5783E0 and "unhealthy" 0x21519F0F. These are pretty simple to make, since the unhealthy one is basically the same minus a few leaves / twigs / whatever appendixes your plant has (i.e. when assinging the state, select all and then remove parts by shiftclicking with the clicky tool).

The sprout objects / states / are linked in the object tuning of the plant (see below). The ones I've seen only had one state, "soil" 0x28F896A4 which included the plant too though.

Before you set out to make a new mesh and all, check if you can't simply re-use an existing one -- they can look quite different with different textures.

2.2 Plant textures: this is a bit fiddly since the plants have an Instanced shader, I believe that is why TSRW does not recognise / load the textures for those parts so you could simply replace them there. All references are preserved though when you export to package, so what I do is just clone the thing and link the textures in s4pe.


Background info on material states:

Plants have internal state values that define how wet/dry they are:

\object_state\S4_5B02819E_00000000_0000000000003B94_Moisture.xml:

<L n="_values">
<T>15253<!--CommodityBasedObjectStateValue: Moisture_0_VeryDryRed--></T>
<T>15254<!--CommodityBasedObjectStateValue: Moisture_1_DryYellow--></T>
<T>15255<!--CommodityBasedObjectStateValue: Moisture_2_Waterable--></T>
<T>15256<!--CommodityBasedObjectStateValue: Moisture_3_FullyWatered--></T>
<T>15257<!--CommodityBasedObjectStateValue: Moisture_4_FullyWateredDripping--></T>
</L>
<T n="linked_stat">16602<!--Commodity: commodity_Gardening_Moisture--></T>


These values are linked to specific material states in the plant object tuning; for example:


<T n="key">15256<!--CommodityBasedObjectStateValue: Moisture_3_FullyWatered--></T>
<U n="value">
<V t="apply_new_value" n="material_state">
<U n="apply_new_value">
<V n="state_name" t="set_to_custom_value">
<T n="set_to_custom_value">wet</T>
</V>
<T n="transition">3</T>
</U>
</V>
</U>


They do not necessarily have distinct material states for each of those; the last plant I looked at had these three (but you can also invent your own and use them):

dry = 0x25954450
normal = 0x4527C498
wet = 0x46661993


You can see the states that an object is using in s4pe, look in MODL for the "Type300EntryList". The plant I quoted above lists these:

ChunkEntries[08]
0x02019972-0x00D9F431-0xFC2DE2DB88FC3047 - MTST
Version: 0x00000300
NameHash: 0x1D5D5C69
Index: (unset)
Type300EntryList: Type300Entries (0x4)
[0]: Index: 0x0000000F (0x01 (Private)); MaterialState: 0x00000000 (0); MaterialVariant: 0x00000000
[1]: Index: 0x00000010 (0x01 (Private)); MaterialState: 0x25954450 (630539344); MaterialVariant: 0x00000000
[2]: Index: 0x00000011 (0x01 (Private)); MaterialState: 0x4527C498 (1160234136); MaterialVariant: 0x00000000
[3]: Index: 0x00000012 (0x01 (Private)); MaterialState: 0x46661993 (1181096339); MaterialVariant: 0x00000000


The first state (0x00000000) is the fallback, i.e. the default that the game is using when it's asked to set a state that does not exist.


You don't really need to know all that in detail to replace the textures -- you can just C+P the IDs of the diffuse maps in your clone and find them in Fullbuild0, so that you can see which texture is wet/normal and which one is dry, then replace the IDs accordingly. From what I've seen so far, the "wet" texture in Maxis plants is identical with the "normal" one, only with a more glossy specular, so the textures you need to make in order to match that setup are:



one diffuse for the regular and wet states
one diffuse for the dry state
one specular for the regular and dry state
one specular for the wet state
one bump map


To edit texture references in s4pe, select MODL (low poly LOD) in the left-hand list, click "Grid", then click the three dots next to "ChunkEntries", select one from the list on the left, cick "Expand All", scroll to e.g. "0x6CC0FD85 (DiffuseMap)" -- this is the resource key for the diffuse map. The last four definitions are (often? always? usually?) the soil texture; you don't need to do anything with that. Repeat for MLOD group 0x00000000 (high poly LOD) and 0x00000001 (mid poly LOD).


3. Tuning:

Two object tuning files come into play here, one for the harvestable and one for the plant (if you make custom sprout objects, they do not need any tuning). The harvestable tuning has the info which plant should grow from this fruit; the plant object tuning tells the game which sprout models to use and links to the material states/effects/etc of the grown-up plant. The latter may not need to be customised.

3.1. Harvestable tuning:

Right at the top is a list of animation overrides; this defines how sims should hold/carry the object -- might be important if you changed the shape of your harvestable very much:


<V t="enabled" n="_anim_overrides">
<U n="enabled">
<L n="params">
<U>
<T n="name">carryObject</T>
<V n="value" t="string">
<T n="string">harvestableStemmed</T>
</V>
</U>
<U>
<T n="name">WhereToPlantSeed</T>
<V t="string" n="value">
<T n="string">PlantEdge</T>
</V>
</U>
<U>
<T n="name">plantType</T>
<V n="value" t="string">
<T n="string">stemmed</T>
</V>
</U>
</L>
</U>
</V>



The one part that you will want to change is in fruit_component, near the top: the name hash (what the object is going to be called in game), and which plant to grow from it.


<V n="gardening_component" t="fruit_component">
<U n="fruit_component">
<V t="fruit_does_not_fall" n="fruit_fall_behavior" />
<T n="fruit_name">0x9B0AFA2C<!--pbox_object_GardeningFlower_Lettuce_name--></T>
<T n="plant">2732072927<!--pbox_object_GardeningPlant_Bush_lettuce--></T>
..


2732072927 is the OBJD/COBJ ID of the custom object to use. The rest of it you can probably just ignore unless you want to do something really specific.


3.2. Plant tuning:

You don't necessarily need to edit this or have custom plant tuning at all -- if you don't do anything special with your plant, use Maxis tuning instead (has the advantage that they will update it for you =P).


Shoots are defined in plant_component > shoot_definition:


<V t="plant_component" n="gardening_component">
<U n="plant_component">
<T n="shoot_definition">22469<!--gardenShootGEN_01 / object_GardeningShoot_Generic--></T>
<L n="states_that_support_fruit">
<T>77615<!--CommodityBasedObjectStateValue: PlantGrowth_3_Blossoming--></T>
<T>15295<!--CommodityBasedObjectStateValue: PlantGrowth_2_Mature--></T>
</L>
</U>
</V>


This number is the ID of the OBJD/COBJ of the shoot model, expressed as decimal value. This is not the sprout! It is the object that sims get when they do the "Take Cutting" thing.


Sprouts are defined in the "PlantGrowth" state list, similar to the abovementioned textures. If the Maxis generic sprouts work OK for your plant, you don't need to edit them.


<U>
<T n="key">15293<!--CommodityBasedObjectStateValue: PlantGrowth_0_Planted--></T>
<U n="value">
<V t="apply_new_value" n="geometry_state">
<V n="apply_new_value" t="set_to_custom_value">
<T n="set_to_custom_value">soil</T>
</V>
</V>
<V t="apply_new_value" n="model">
<V n="apply_new_value" t="set_to_custom_model">
<U n="set_to_custom_model">
<V n="model" t="from_definition">
<U n="from_definition">
<T n="definition">22042</T>
</U>
</V>
</U>
</V>
</V>
</U>
</U>


22042 is the COBJ/OBJD ID of "gardenPlantSproutGEN_01" (0x561A).



At the very bottom of the tuning is also the interactions list, should you want to give your plant custom interactions or disable some.

icemunmun
30th Jan 2016, 10:23 PM
How do we tag a harvestable as a fruit or veggie?

plasticbox
30th Jan 2016, 11:20 PM
That is in the tags in COBJ. See sticky in Object Creation (the one on COBJ/OBJD) if you're unsure how to edit them!

icemunmun
30th Jan 2016, 11:45 PM
That is in the tags in COBJ. See sticky in Object Creation (the one on COBJ/OBJD) if you're unsure how to edit them!

I somewhat know how to edit the COBJ and have some idea about the catalogue tags but I cannot figure out which specific tag to change if I want to tag a harvestable(Garlic) as a veggie.Thank you so much for the pointers and the tutorial!

plasticbox
31st Jan 2016, 12:25 AM
Off the top of my head the tag is Func_Veggie. If you use s4pe, that has autocomplete for the tags (select the Func category in the first box, then in the tag box type "veg" or something).

E: you can also look up tags in S4_03B33DDF_00000000_D89CB9186B79ACB7_tag.xml.

icemunmun
31st Jan 2016, 12:43 AM
Off the top of my head the tag is Func_Veggie. If you use s4pe, that has autocomplete for the tags (select the Func category in the first box, then in the tag box type "veg" or something).

E: you can also look up tags in S4_03B33DDF_00000000_D89CB9186B79ACB7_tag.xml.

Thank you so much! It is so much easier to tag things in s4pe :lovestruc . Earlier I was using S4S to manually edit the category flags and i only knew the value for fruit(0x031B).I did not know about this function of s4pe!

plasticbox
31st Jan 2016, 12:56 AM
You're welcome. Yes, there is not a lot of documentation for s4pe, unfortunately.