Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Field Researcher
Original Poster
#1 Old 13th Aug 2018 at 2:53 PM
Default Adding Interactions to Sims
I’ve been using this tutorial here to create my own interactions and add them to objects which has been super helpful, but I was wondering if anyone knows how to add interactions directly to sims, so they show up in the pie menu when you click on the Sim, and not an object?

I’m trying to create custom interactions that are associated with certain sims traits, for example Erratic/Insane Sims have the option to “Talk To Self” on the pie menu, and I wanted to create something like this. If anyone has any tips it would be really appreciated!

Twilightsims
Advertisement
Lab Assistant
#2 Old 15th Aug 2018 at 2:29 AM
There are several available pie menus directly to sims that exist on the game that we can use actually, find the one that suits you or simply add Actor under token participant and specify the target under who in sim_info(TargetType).

Code:
<U n="display_name_text_tokens">
 <L n="tokens">
  <V t="participant_type">
   <U n="participant_type">
    <V t="from_participant" n="objects">
     <U n="from_participant">
      <E n="participant">Actor</E>
     </U>
   </V>
  </U>
 </V>
<U n="progress_bar_enabled">
 <T n="bar_enabled">False</T>
</U>
<E n="target_type">OBJECT</E>
 <L n="test_globals">
  <V t="sim_info">
   <U n="sim_info">
    <V n="ages" t="specified">
     <L n="specified">
      <E>CHILD</E>
      <E>TEEN</E>
      <E>YOUNGADULT</E>
      <E>ADULT</E>
      <E>ELDER</E>
     </L>
    </V>
    <E n="who">TargetSim</E>
   </U>
  </V>
 </L>
</I>


Sorry for the long code, I don't why it looks like this here.

AshenSS
Lab Assistant
#3 Old 15th Aug 2018 at 10:54 AM
Well the good news is, if you just want to add interactions through a trait, you don't need to fiddle with python scripts at all. Here's an example from one of my Child Traits:

This is the trait itself. Note the "buffs"/"buff_type" part. That's important, as it applies the hidden buff that has some of the trait's important operations, like interactions. (You can ignore the buff_replacements section for the purpose of this example. It has nothing to do with the interactions.)
Code:
<?xml version="1.0" encoding="utf-8"?>
<I c="Trait" i="trait" m="traits.traits" n="Triplis_ChildTrait_Rocket_Trait" s="16492474827361129913">
  <L n="ages">
    <E>CHILD</E>
  </L>
  <L n="buff_replacements">
    <U>
      <T n="key">12816<!--Buff: Buff_Motives_Energy_Tired--></T>
      <U n="value">
        <V t="enabled" n="buff_reason">
          <T n="enabled">0x1B2DE657<!--String: "(From Low Energy)"--></T>
        </V>
        <T n="buff_type">14951170304358475830<!--Buff: Triplis_ChildTrait_Rocket_ReplaceEnergyLowBuff--></T>
      </U>
    </U>
    <U>
      <T n="key">12818<!--Buff: Buff_Motives_Energy_Exhausted--></T>
      <U n="value">
        <V t="enabled" n="buff_reason">
          <T n="enabled">0x46701DA0<!--String: "(From Critically Low Energy)"--></T>
        </V>
        <T n="buff_type">17950906076574786090<!--Buff: Triplis_ChildTrait_Rocket_ReplaceEnergyVeryLowBuff--></T>
      </U>
    </U>
    <U>
      <T n="key">27113<!--Buff: Buff_Motives_Fun_NeedsAmusement--></T>
      <U n="value">
        <V t="enabled" n="buff_reason">
          <T n="enabled">0xED5C85CF<!--String: "(From Low Fun)"--></T>
        </V>
        <T n="buff_type">13599632494283167037<!--Buff: Triplis_ChildTrait_Rocket_ReplaceFunLowBuff--></T>
      </U>
    </U>
    <U>
      <T n="key">12819<!--Buff: Buff_Motives_Fun_DesperateForFun--></T>
      <U n="value">
        <V t="enabled" n="buff_reason">
          <T n="enabled">0xED5C85CF<!--String: "(From Low Fun)"--></T>
        </V>
        <T n="buff_type">10773929570161709249<!--Buff: Triplis_ChildTrait_Rocket_ReplaceFunVeryLowBuff--></T>
      </U>
    </U>
    <U>
      <T n="key">27457<!--Buff: Buff_Trait_Active_Antsy--></T>
      <U n="value">
        <V t="enabled" n="buff_reason">
          <T n="enabled">0xC0B9122D<!--String: "(From Rocket Trait)"--></T>
        </V>
        <T n="buff_type">18259048947900422325<!--Buff: Triplis_ChildTrait_Rocket_ReplaceActiveAntsyBuff--></T>
      </U>
    </U>
  </L>
  <L n="buffs">
    <U>
      <T n="buff_type">16040056250146008020<!--Buff: Triplis_ChildTrait_Rocket_TraitBuff--></T>
    </U>
  </L>
  <T n="cas_trait_asm_param">Active</T>
  <T n="display_name">0xB4A897CC<!--String: "Rocket"--></T>
  <T n="display_name_gender_neutral">0xB4A897CC<!--String: "Rocket"--></T>
  <T n="icon">2f7d0004:00000000:95C0F71128EBED33</T>
  <V n="loot_on_trait_add" t="enabled">
    <L n="enabled">
      <T>168041<!--LootActions: loot_Statistic_LifeSkill_Responsibility_Trait_LossSmall--></T>
    </L>
  </V>
  <E n="min_lod_value">MINIMUM</E>
  <L n="species">
    <E />
  </L>
  <L n="tags">
    <E>TraitPersonality</E>
    <E>TraitGroup_Lifestyle</E>
  </L>
  <U n="trait_asm_overrides">
    <V t="enum" n="param_type">
      <T n="enum">triplis_trait_child</T>
    </V>
    <T n="trait_asm_param">rocket</T>
  </U>
  <T n="trait_description">0x57F365E9<!--String: "The energy of these children seems to have no end. They love to Run Around, Get Hyped, fight themselves, and carry around a secret Sugar Stash."--></T>
  <E n="trait_type">PERSONALITY</E>
  <V t="ui_trait_category_tag" n="ui_category" />
</I>


Then here's the buff that is applied through the trait:
Code:
<?xml version="1.0" encoding="utf-8"?>
<I c="Buff" i="buff" m="buffs.buff" n="Triplis_ChildTrait_Rocket_TraitBuff" s="16040056250146008020">
  <L n="actor_mixers">
    <U>
      <T n="key">13998<!--SocialSuperInteraction: sim_Chat--></T>
      <L n="value">
        <T>12893269688495678033<!--SocialMixerInteraction: Triplis_ChildTrait_Rocket_ShareSugarStash--></T>
      </L>
    </U>
  </L>
  <T p="InGame\Audio\Stings\sting_buff_gain.propx" n="audio_sting_on_add">39b2aa4a:00000000:8af8b916cf64c646</T>
  <T p="InGame\Audio\Stings\sting_buff_loss.propx" n="audio_sting_on_remove">39b2aa4a:00000000:3bf33216a25546ea</T>
  <U n="game_effect_modifier">
    <L n="_game_effect_modifiers">
      <V t="autonomy_modifier">
        <U n="autonomy_modifier">
          <L n="commodities_to_add">
            <T>29105<!--Commodity: commodity_Trait_Autonomy_Active--></T>
            <T>27458<!--Commodity: commodity_Trait_Active_Activity--></T>
            <T>14695317521761772662<!--Commodity: Triplis_ChildTrait_Rocket_Commodity_RandomlyEnergized--></T>
          </L>
          <L n="decay_modifiers">
            <U>
              <T n="key">16654<!--Commodity: motive_Energy--></T>
              <T n="value">0.75</T>
            </U>
          </L>
        </U>
      </V>
    </L>
  </U>
  <T p="InGame\UI\Icons\Debug\missing_image.png" n="icon">2f7d0004:00000000:30f0846c783606f9</T>
  <V n="interactions" t="enabled">
    <U n="enabled">
      <L n="interaction_items">
        <T>14960855851331812111<!--MixerInteraction: Triplis_ChildTrait_Idles_Mixer--></T>
      </L>
      <T n="weight">100</T>
    </U>
  </V>
  <L n="super_affordances">
    <T>18391842166729904973<!--SuperInteraction: Triplis_Child_RunAround--></T>
    <T>12749438425912480227<!--SuperInteraction: Triplis_ChildTrait_Rocket_DrinkSugarStash--></T>
    <T>17908143711610097781<!--SuperInteraction: Triplis_ChildTrait_Rocket_FightWithSelf--></T>
    <T>11200552380196982311<!--SuperInteraction: Triplis_ChildTrait_Rocket_GetHyped--></T>
  </L>
  <T n="visible">False</T>
  <V n="walkstyle" t="enabled">
    <U n="enabled">
      <E n="priority">MOTIVE_CRITICAL</E>
      <T p="InGame\Locomotion\Run.walkstyle" n="walkstyle">27c01d95:00000000:000000002a72b9a8</T>
    </U>
  </V>
  <V n="walkstyle_behavior_override" t="enabled">
    <U n="enabled">
      <L n="removed_run_flags">
        <E />
        <E>RUN_ALLOWED_OUTDOORS</E>
      </L>
      <E n="walkstyle_behavior_priority">DEFAULT</E>
    </U>
  </V>
</I>

Note the part under super_affordances.

Here's a detailed breakdown on it I wrote a while back:

https://forums.thesims.com/en_US/di...omment_16017942

♫ Improvising into a corner ♫
♫ No rhyme or rhythm in this verse cause I'm in a corner ♫
Deceased
#4 Old 15th Aug 2018 at 10:45 PM
The post Triplis made above sounds like the best method for the purpose you stated; however, if you are working with an existing trait that you don't want to code an override for, you can inject an interaction into the super affordances for a Sim easily. This is one example, a method I preferr over some other scripts that have been written in the past (including my own) since this will only run once as the game loads instead of each time a Sim is added to a lot. I believe this or something like it is in that thread but it can be kind of hard to find.

This works to add interactions for any object tuning that has a super affordance list available for it, in this case we're just using 14965 which is the ID for the object_sim tuning. The two interaction IDs in that list are dummy values that will not work, use your own of course.
Code:
import sims4.resources
import services
from sims4.tuning.instance_manager import InstanceManager
from sims4.resources import Types

from injector import inject_to

def add_super_affordances_to_objects(self, sa_ids, object_ids):
    affordance_manager = services.affordance_manager()
    sa_list = []
    for sa_id in sa_ids:
        key = sims4.resources.get_resource_key(sa_id, Types.INTERACTION)
        sa_tuning = affordance_manager.get(key)
        if sa_tuning:
            sa_list.append(sa_tuning)
    if len(sa_list) > 0:
        sa_tuple = tuple(sa_list)
        for obj_id in object_ids:
            key = sims4.resources.get_resource_key(obj_id, Types.OBJECT)
            obj_tuning = self._tuned_classes.get(key)
            if obj_tuning:
                obj_tuning._super_affordances = obj_tuning._super_affordances + sa_tuple

@inject_to(InstanceManager, 'load_data_into_class_instances')
def SimLotto_load_data_into_class_instances(original, self):
    original(self)
    if self.TYPE == Types.OBJECT:
        list_of_sa_ids = [8675309, 5882300]
        list_of_object_tuning_ids = [14965]
        add_super_affordances_to_objects(self, list_of_sa_ids, list_of_object_tuning_ids)
Lab Assistant
#5 Old 20th Aug 2018 at 3:40 AM
Quote: Originally posted by scumbumbo
The post Triplis made above sounds like the best method for the purpose you stated; however, if you are working with an existing trait that you don't want to code an override for, you can inject an interaction into the super affordances for a Sim easily. This is one example, a method I preferr over some other scripts that have been written in the past (including my own) since this will only run once as the game loads instead of each time a Sim is added to a lot. I believe this or something like it is in that thread but it can be kind of hard to find.

This works to add interactions for any object tuning that has a super affordance list available for it, in this case we're just using 14965 which is the ID for the object_sim tuning. The two interaction IDs in that list are dummy values that will not work, use your own of course.
Code:
import sims4.resources
import services
from sims4.tuning.instance_manager import InstanceManager
from sims4.resources import Types

from injector import inject_to

def add_super_affordances_to_objects(self, sa_ids, object_ids):
    affordance_manager = services.affordance_manager()
    sa_list = []
    for sa_id in sa_ids:
        key = sims4.resources.get_resource_key(sa_id, Types.INTERACTION)
        sa_tuning = affordance_manager.get(key)
        if sa_tuning:
            sa_list.append(sa_tuning)
    if len(sa_list) > 0:
        sa_tuple = tuple(sa_list)
        for obj_id in object_ids:
            key = sims4.resources.get_resource_key(obj_id, Types.OBJECT)
            obj_tuning = self._tuned_classes.get(key)
            if obj_tuning:
                obj_tuning._super_affordances = obj_tuning._super_affordances + sa_tuple

@inject_to(InstanceManager, 'load_data_into_class_instances')
def SimLotto_load_data_into_class_instances(original, self):
    original(self)
    if self.TYPE == Types.OBJECT:
        list_of_sa_ids = [8675309, 5882300]
        list_of_object_tuning_ids = [14965]
        add_super_affordances_to_objects(self, list_of_sa_ids, list_of_object_tuning_ids)

Yeah, this is good stuff. ^^

I remember it being difficult to track down in the past. Thanks for sharing a solid, up-to-date example.

♫ Improvising into a corner ♫
♫ No rhyme or rhythm in this verse cause I'm in a corner ♫
Back to top