RequiredTrait not working with spectrum traits

Started by twoski, August 13, 2016, 03:02:43 PM

Previous topic - Next topic

twoski

So if i want to add a mental break that only applies to Neurotic or Nervous or Teetotaler, i cannot do that since these traits are defined a bit differently than normal traits.

What would be nice is if the RequiredTrait tag for mental breaks searched by name or something rather than using TraitDefOf.

1000101

What do you mean?  The def is the only real mechanism to look at it by.  Trying to do a string search through a database is going to be slow.  It's a balance between optimization and usage.  Since the usage fits the core mechanics then the optimization is valid.
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

cuproPanda

Wouldn't you just have to specify the degree? For example:


<label>teetotaler</label>
<description>NAME abhors the idea of gaining pleasure from chemicals, and avoids alcohol and drugs.</description>
<degree>-1</degree>


has a -1 for the degree, where singular traits have a 0 for the degree, signifying they are the only one in the spectrum (thus being singular).
cuproPanda's Mods: Survivalist's Additions, Additional Joy Objects, Cupro's Drinks, Quarry, Cupro's Stones, Zen Garden, Cupro's Alloys, Preset Filtered Zones, & more!

twoski

Quote from: cuproPanda on August 13, 2016, 08:00:54 PM
Wouldn't you just have to specify the degree? For example:


<label>teetotaler</label>
<description>NAME abhors the idea of gaining pleasure from chemicals, and avoids alcohol and drugs.</description>
<degree>-1</degree>


has a -1 for the degree, where singular traits have a 0 for the degree, signifying they are the only one in the spectrum (thus being singular).

Not sure i follow.

Here is an example:


<MentalBreakDef>
    <defName>Berserk</defName>
    <mentalState>Berserk</mentalState>
    <commonality>0.25</commonality>
    <intensity>Extreme</intensity>
   <requiredTrait>Brawler</requiredTrait>
  </MentalBreakDef>
 
  <MentalStateDef ParentName="BaseMentalState">
    <defName>Berserk</defName>
    <stateClass>MentalState_Berserk</stateClass>
    <label>berserk</label>
    <category>Aggro</category>
    <blockNormalThoughts>true</blockNormalThoughts>
    <nameColor>(0.9,0.2,0.5)</nameColor>
    <beginLetterLabel>berserk</beginLetterLabel>
    <beginLetter>{0} has gone berserk!</beginLetter>
    <beginLetterType>BadUrgent</beginLetterType>
    <recoveryMessage>{0}'s berserk rage has come to an end.</recoveryMessage>
    <inspectLine>Mental state: Berserk</inspectLine>
    <stateEffecter>Berserk</stateEffecter>
    <tale>MentalStateBerserk</tale>
    <recoverFromSleep>true</recoverFromSleep>
    <recoverFromDowned>true</recoverFromDowned>
  </MentalStateDef>


Okay so what we did here is make Berserk only apply to pawns with the Brawler trait.

Now what if we wanted to make this mental break only apply to pawns with the Teetotaler trait? Let's look at the Teetotaler TraitDef:

<TraitDef>
    <defName>DrugDesire</defName>
    <commonality>1</commonality>
    <degreeDatas>
      <li>
        <label>chemical fascination</label>
        <description>NAME has an intense fascination with chemical sources of enjoyment. HECAP will consume much more of them, and is more likely to go on binges.</description>
        <degree>2</degree>
        <randomMentalState>BingingAlcohol</randomMentalState>
        <randomMentalStateMtbDaysMoodCurve>
          <points>
            <li>(0, 7.5)</li>
            <li>(50, 25)</li>
            <li>(100, 50)</li>
          </points>
        </randomMentalStateMtbDaysMoodCurve>
      </li>   
      <li>
        <label>chemical interest</label>
        <description>NAME has an unusual interest in chemical sources of enjoyment. HECAP will consume more of them, and is more likely to go on binges.</description>
        <degree>1</degree>
        <randomMentalState>BingingAlcohol</randomMentalState>
        <randomMentalStateMtbDaysMoodCurve>
          <points>
            <li>(0, 15)</li>
            <li>(50, 50)</li>
            <li>(100, 100)</li>
          </points>
        </randomMentalStateMtbDaysMoodCurve>
      </li>
      <li>
        <label>teetotaler</label>
        <description>NAME abhors the idea of gaining pleasure from chemicals, and avoids alcohol and drugs.</description>
        <degree>-1</degree>
        <disallowedMentalStates>
          <li>BingingAlcohol</li>
        </disallowedMentalStates>
      </li>
    </degreeDatas>
  </TraitDef>


Doesn't look like we can reference it by DefName.