Forum Discussion

lexuus20's avatar
8 years ago

Trying to add an interaction to terrain but it's causing a route failure

I'm trying to make a "Pee Here" mod, so I created a new interaction based on the pee while standing interaction and added it to object_terrain. I also copied most of a toilet's tuning to terrain as well so it would be recognized as a toilet (or at least I thought it would). The interaction does show up in the game, but the problem is that it doesn't work, it always ends up in a route failure. I have no idea what's causing the route failure or how can I get the mod to work, can someone help me?

I tried to paste the XML code for the Object Tuning and Interaction Tuning here, but it was too long so I couldn't, so I uploaded the package file instead (link here).

20 Replies

Replies have been turned off for this discussion
  • I found out that the problem is the posture. I removed the posture constraint and replaced the animation by the push-up animation just to test if it would work and it did. Then, I copied the push-up ASM and replaced the animation by the peeing animation and it worked as well, but with no censor grid, no sound, no pee stream, and the animation also ends abruptly not smoothly. The animation is divided into start, loop, and stop, but I think it is going straight to the loop and skipping both the start (which creates the censor grid, sound and pee stream effect) and stop, probably because I used posture_Stand instead of posture_ToiletStand. So I tried to create a new ToiletStand posture by removing the object requirements from the original but it didn't work either. I don't know what could be causing the problem with the new posture.

    Posture Tuning:
    Spoiler






    HUMAN

    02d5df13:00000000:00aa8c29b1c913f7
    useStanding_start

    6359664752630901125

    Toilet_Stand_Posture






    15537


    20


    0
    0
    0.15



    -0.5
    0
    0


    0.5
    0
    0


    1
    0
    1


    -1
    0
    1





    SURFACETYPE_OBJECT




    Animation State Machine (for the posture):
    Spoiler

















































  • Well, from the stuff I've dealt in recently, special situations with posture will have a generic_ interaction as one of the affordances on the object that looks something like this:







    Object



    15540

    False
    False
    0.5




    Actor




    Object




    False

    Interaction_Super
    Interaction_All

    NORMAL
    1
    OBJECT




    26171







    CHILD
    TEEN
    YOUNGADULT
    ADULT
    ELDER







    Actor



    30
    False



    So if you're making a new/modified posture, you might try creating a custom version of this interaction and add it to object_terrain super_affordances, with the _provided_posture_type being your toilet stand posture, instead of Maxis's. (Not sure terrain is treated in the same way as most objects though.)

    Or maybe try adding it to postures.posture_graph in the POSTURE_PROVIDING_AFFORDANCES section.
  • Good news (almost)! The animation finally played (with sound, effects, everything), I guess the problem was that I needed to add the generic interaction to postures.posture_graph, the route fail was happening probably because of this. The problem now is that the sim is not walking to the spot where I clicked anymore, he pees right where he is, although the puddle spawns where I clicked, not where he peed.
  • Awesome! Does it still have the circle constraint at all? You could try adding that back in, if not, and see if it still works.

    If that fails, maybe try structuring it as two interactions, the way stuff like pushups does it? Where the first interaction is a GoHere with a circle constraint and then it does a continuation into the main peeing interaction?
  • Thank you so much for the help! I used two interactions and it's now fully working! I had actually tried using two interactions but I had forgot to change object_terrain to the first interaction rather than the second. Just one thing, do you know how could I change the position where the puddle spawns? It's spawning right under the sim rather than in his front where he peed. This is a minor thing, though, I'm very happy that the mod is working! Next I will try to use a script instead of replacing object_terrain. Do I need to make a script too for postures.posture_graph?
  • Awesome! Glad I could be of help. :smile:

    As far as where the puddle spawns, I did a quick search and found this (this is from a LootActions file):

        



    0
    WATER
    1
    0
    4

    2.5
    Actor
    Object




    So it looks like choosing where the puddle spawns is definitely possible to some extent. Your target_participant_type would probably want to be set to Object as it is in the example above, since your target participant is terrain (a type of object). max_distance might help with tweaking where it lands?

    I would recommend looking at the TDESCs under Actions > Descriptions > LootActions.tdesc and see what all possible commands can be used in determining where a puddle spawns.

    Altho, just having it be set to spawn on target_participant_type as Object might do it.

    I'm not really sure. Haven't messed with puddle spawning a lot.


    W/ regards to scripts: @TURBODRIVER might know if there's a way to inject to postures.posture_graph, as opposed to using an override. I've never attempted it myself. If anyone knows, he probably would.

    For injecting to object_terrain, I know that can be done and is pretty straightforward. If you need or want code samples for injecting to object_terrain, feel free to ask. I'm sure I have an example laying around somewhere in stuff I've done.
  • I couldn't change the puddle spawning but I think it's okay the way it is, it doesn't bother me that much.

    I tried to make a script based off the one from this thread by replacing the names and interaction hash ids to inject the interactions to object_terrain but how should I add it to the package? Do I save it as .py and put it in the Mods folder or do I need a .pyo file too? If a .pyo is needed, how does that file need to be? This is my first time scripting so I'm not really sure.

    Script:

    import services
    import injector
    import sims4.resources
    from sims4.tuning.instance_manager import InstanceManager
    from sims4.resources import Types

    TS40_PeeHere_Interactions_ObjectTerrain_sa_instance_ids = (15295192161465113131, 6192637829597138744,)
    TS40_PeeHere_Interactions_ObjectTerrain_object_ids = (14982,)

    @injector.inject_to(InstanceManager, 'load_data_into_class_instances')
    def add_superaffordances(original, self):
    original(self)

    if self.TYPE == Types.OBJECT:
    affordance_manager = services.affordance_manager()
    sa_list = []
    for sa_id in TS40_PeeHere_Interactions_ObjectTerrain_sa_instance_ids:
    key = sims4.resources.get_resource_key(sa_id, Types.INTERACTION)
    sa_tuning = affordance_manager.get(key)
    if not sa_tuning is None:
    sa_list.append(sa_tuning)
    sa_tuple = tuple(sa_list)

    for obj_id in TS40_PeeHere_Interactions_ObjectTerrain_object_ids:
    key = sims4.resources.get_resource_key(obj_id, Types.OBJECT)
    obj_tuning = self._tuned_classes.get(key)
    if not obj_tuning is None:
    obj_tuning._super_affordances = obj_tuning._super_affordances + sa_tuple
  • For testing purposes (e.g. to try out the script before compiling), you go to your Mods folder and created a folder inside of it called Testing. Then a folder inside of Testing called Scripts. And then put any .py files in the Scripts folder. So it'll look like Mods > Testing > Scripts

    For sharing the final product with others, you'll want to compile, to make it into a .pyo file, which can be read by the game without being in the special testing/scripts folder.

    To compile, you first want to download Python 3.3. For me, after downloading, it's located in C:\Python33

    Put a copy of your scripts in the Python33 folder.

    Then I pull up the start menu and in the search box, put in the file path for Python 33, python.exe, and then append -O at the end. So something like this: C:\Python33\python.exe -O

    If the path is right, this should bring up an option to open up a python.exe command prompt.

    When you've opened the command prompt that comes up, type in;

    import myScriptName

    Where myScriptName is the name of your script, obviously. :tongue:

    And just do that for every script you put in the Python33 folder.

    When you're finished, go into __pycache__ folder within Python33 and there should be a .pyo file for each script you compiled. Its name will have some extra stuff in it (I forget the syntax). Just change its name back to what it was originally (with the exception of the file extension, of course).

    Now that you have your compiled scripts together, you can put them in a zip file and then change the file extension from .zip to .ts4script (this is just so that it's more clear to people using your mod that the script part is not something they're meant to unzip). Then put it in your Mods folder (*not* within the testing folder this time, since it's compiled and zipped now). I suggest testing it in its compiled form, to be sure compiling went as expected.

    Then you're good to go!
  • Hi there! Sorry to piggyback on this thread but I am having animation issue and this is the closest thread to my issue that I've seen.

    I have been trying to just simply override the animations for the Yoga skill-- exporting the corresponding animation pose as a base, creating my own animation and importing the animation to the mod override file. However, every time I try to replace the pose "a2o_yoga_posture_getIn_x" and playtest it, my sim gets a routing failure. Other poses seem to work fine when being overwritten.

    Could this be a tuning issue? I do not have coding experience and most tuning troubleshooting goes way over my head. I guess I am looking for guidance as to if this could be a very simple fix or if I'm treading into deep waters. Thank you!

About The Sims 4 Mods & Custom Content

Find expert tips, troubleshooting help, tutorials for mods and custom content, and The Sims 4 patch files in our forum.15,849 PostsLatest Activity: 58 minutes ago