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).
Comments
1) You shouldn't need or want to edit object_terrain in any way, unless it's to force a new interaction on it using an override (and if that's your goal, you can use scripts, which'll have better forward compatibility, since they can inject the interaction to object_terrain). I can share an example of such a script if need be. As far as terrain being recognized as a toilet, that's probably going to be an involved process and may not work for generic terrain itself; I mean, if you're wanting some kind of remnant of it happening on the terrain, I can see why you'd go in that direction, but you could probably create a puddle at the end of the interaction, which more or less simulates a result of the terrain being peed on. If all you want is for the sim to autonomously consider terrain as a possible option for peeing, you should be able to pull that off in your custom pee-while-standing interaction itself, by implementing some autonomy pull for bladder.
2) It sounds like you're on the right track with creating an interaction based on the pee while standing interaction. The route failure part probably has something to do with the animation and/or the constraints of the interaction. You could try experimenting with the removal of constraints, changing of animation, etc., to try to nail down where the problem area is.
2) I've made some progress, I removed one of the constraints and also created an Animation Tuning and Animation State Machine based on the original one with some changes. It doesn't cause a route failure anymore, but the sim will just walk to the spot where I clicked and generate a puddle underneath (I've set it in the Interaction Tuning to always generate a puddle because it's more realistic). However, for some reason, the peeing animation does not play and also the bladder motive does not go up.
This time I pasted the code in a website so it's easier to see it:
Object Tuning (Terrain): Link
Interaction Tuning: Link
Animation Tuning: Link
Animation State Machine: Link
The "toilet_sit" in the ASM is just because Sims4Studio wouldn't let me remove one of the choice values, it would always reset to two, so I just duplicated "toilet_stand" and renamed it as "toilet_sit", but they are the same.
https://www.youtube.com/watch?v=_tXsHw5TYHU&feature=youtu.be
I don't remember for sure what constraints you still had in there, if any. But I think the posture_manifest_tuning part may be vital to put the sim in the peeing stance. The body_target_tuning part can probably be deleted; I'd have to review the tdesc on that to be certain. But now that I'm thinking about how the toilet animation looks normally from my recollection, I think it's mostly just a static posture.
So you could try the following for constraints (if you haven't already) and see what happens:
The interaction tuning (before I added the posture_manifest_tuning) is the following:
Then try with or without the posture constraint again. You might also try removing _provided_posture_type, but with the constraint. I've read the tdesc before, but I'm not totally sure how _provided_posture_type functions in practice.
Edit: Also, unless you're wanting a flush animation to happen in some way, you should be able to safely get rid of the pre-add and post-run commodities. All they do is push the sim to move into a flush interaction after peeing, but since it's not an actual toilet, you shouldn't need that.
Also also, if you get stumped, my recommendation would be to look for a Maxis-made interaction that is as similar as possible to what you're attempting to do and just use that as a base, with the peeing animation and posture inserted into it... see if it makes any difference. I don't know how helpful that is, but it's what I usually do if I'm struggling. Off-hand, I'm not sure what all there is in the way of interactions that are ground-targeted that aren't just a movement-based thing. But I guess there's the list of super_affordances in terrain object, so you could look there for examples.
I also tried to create a new Posture Tuning and ASM for this Posture Tuning based on the ones from other terrain interactions, but it didn't make any difference. I had already tried to look at other terrain interactions too such as Do Push-Ups and replace the animations and postures by the peeing ones but then the interaction didn't even appear in the queue, it was simply ignored every time I clicked it.
I mean, you could maybe try extracting the peeing animation and just try to have it play without the posture or something. But then it probably wouldn't have the peeing stream effect (which may not reach the ground even if your attempts were working).
I'm not sure I can be of much more help. I hope you can figure it out though.
Edit: On giving it more thought, this may not be as much of a clincher as I thought. The reason it seems important is because I ran into a situation in experimenting with SitOnGround and attempting to allow ages other than toddler to do it, just to see if I could get past the contraint, for one thing. In the end, what clinched that was editing the age in both the SitOnGround interaction and the "generic" SitOnGround (there are a lot of "generic" named files like these, which are apparently important in interactions that involve special posture).
Posture Tuning:
Animation State Machine (for the posture):
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.
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?
As far as where the puddle spawns, I did a quick search and found this (this is from a LootActions file):
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 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:
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.
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!
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!