Forum Announcement, Click Here to Read More From EA_Cade.

Issue with old saves and mods that involve interactions or edited needs?

TriplisTriplis Posts: 3,048 Member
edited March 5 in Nominated Threads
My knowledge of the python scripts for this game is really limited and I've got no idea where this issue might be coming from, so I figured I'd ask some of you who I know are more familiar with python (or just know the game in general... SimGuruModSquad :P) and see if you have any thoughts on it, or if you're into technical things, you might find it an interesting problem.

@Neia
@TURBODRIVER
@SimGuruModSquad

The long and short of it is, with the new patch, old saves that had Sorcerers in them from my mod are getting a lastexception error like this:
<?xml version="1.0" ?><root>
<report><version>2</version><sessionid>84459c6f8b8b092559273885</sessionid><type>desync</type><sku>ea.maxis.sims4_64.15.pc</sku><createtime>2017-05-25 16:14:06</createtime><buildsignature>Local.Unknown.Unknown.1.30.103.1010-1.300.000.96.Release</buildsignature><categoryid>state.py:1661</categoryid><desyncid>84459c6f8b8b092559273885</desyncid><systemconfig/><screenshot/><desyncdata>Exception while creating sims, sim_id=493994472144306196; failed (AttributeError: 'NoneType' object has no attribute 'use_stat_value_on_initialization')&#13;&#10;Traceback (most recent call last):&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Server\areaserver.py", line 111, in wrapped&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Server\areaserver.py", line 107, in finally_wrap&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Core\sims4\utils.py", line 173, in wrapper&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Core\sims4\utils.py", line 191, in wrapper&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Server\areaserver.py", line 356, in c_api_client_connect&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Server\zone.py", line 483, in do_zone_spin_up&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Server\zone_spin_up_service.py", line 1138, in update&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Server\zone_spin_up_service.py", line 537, in on_enter&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Server\sims\sim_spawner_service.py", line 584, in batch_spawn_during_zone_spin_up&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Server\sims\sim_spawner_service.py", line 755, in _spawn_next_sim&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Server\sims\sim_spawner_service.py", line 787, in _spawn_requested_sim&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Server\sims\sim_spawner.py", line 313, in spawn_sim&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Server\sims\sim_info.py", line 1668, in create_sim_instance&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Server\objects\system.py", line 178, in create_object&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Server\objects\object_manager.py", line 494, in add&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Server\indexed_manager.py", line 152, in add&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Server\indexed_manager.py", line 268, in call_pre_add&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Server\sims\sim.py", line 2262, in pre_add&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Server\objects\components\__init__.py", line 92, in wrapped_method&#13;&#10;  File "T:\InGame\Gameplay\Scripts\Server\objects\components\state.py", line 1661, in pre_add&#13;&#10;AttributeError: 'NoneType' object has no attribute 'use_stat_value_on_initialization'&#13;&#10;</desyncdata></report>
</root>

The most important part seems to be the:
"T:\InGame\Gameplay\Scripts\Server\objects\components\state.py", line 1661, in pre_add&#13;&#10;AttributeError: 'NoneType' object has no attribute 'use_stat_value_on_initialization'&#13;&#10;

At first, I thought it was an issue with the scripts themselves. They use an injector to add new interactions and code like this:
import services
import Triplis_SorcererTrait_Injector
import sims.sim
import sims4.resources
from sims4.tuning.instance_manager import InstanceManager
from sims4.resources import Types
import objects.game_object

#SuperAffordances to Objects code structure originally by TheFoodGroup of MTS
#Adapted/used for objects and for Mixers to Snippets by Triplis

Triplis_SorcererTrait_Interactions_sa_to_objects = [
    {
        "name": "Triplis_SorcererTrait_TerrainObjectInteractions",
        "sa_instance_ids": (16003312313934637199, 16829542811876238927, 16128068953812816441, 14873449219798807781, 11269757060309766408, 17205622711440938437),
        "object_tuning_ids": (14982, )
    },
    {
        "name": "Triplis_SorcererTrait_FireObjectInteractions",
        "sa_instance_ids": (14946596997462317149, ),
        "object_tuning_ids": (38909, )
    },
    {
        "name": "Triplis_SorcererTrait_PuddleSmallObjectInteractions",
        "sa_instance_ids": (16163700323824113830, ),
        "object_tuning_ids": (15017, )
    },	
    {
        "name": "Triplis_SorcererTrait_PuddleMediumObjectInteractions",
        "sa_instance_ids": (16163700323824113830, ),
        "object_tuning_ids": (15016, )
    },	
    {
        "name": "Triplis_SorcererTrait_PuddleLargeObjectInteractions",
        "sa_instance_ids": (16163700323824113830, ),
        "object_tuning_ids": (15015, )
    },
    {
        "name": "Triplis_SorcererTrait_ClayBlobObjectInteractions",
        "sa_instance_ids": (12725877393003148451, ),
        "object_tuning_ids": (14843, )
    }		
]

Triplis_SorcererTrait_Interactions_mixer_to_snippets = [
    {
        "name": "Triplis_SorcererTrait_MixerInteractions_FriendlyNonTouching_Snippet",
        "mixer_instance_ids": (13250433561655961719, 10814470620858752309),
        "snippet_tuning_ids": (24508, )
    },	
    {
        "name": "Triplis_SorcererTrait_DeathInteractions_DeathAll_Snippet",
        "mixer_instance_ids": (17537670152126568118, ),
        "snippet_tuning_ids": (16338, )
    },	
]

Triplis_SorcererTrait_Interactions_sa_instance_ids = (15637114959971654166, 17956754764064186480, 18223974517353246826, 10257892382521782328, 13207307475727282152, 15775708450489890343, 10548302199666969406, 11787609329977441829, 17565522103389469685, 13534504451029703004, 15262449686936737821, 18218869284778878145, 13231897427706895428, 17860231607360189656, 16639758558078259438, 11094863792259477513, 13250546842406808257, 12025535218494338879, 15727144965150744557, 12638526487282842888, 15198688674050695837, 12395990693228806593, 13239673440695320889, 13660689571040598607, 10279806041534929123, 14333155500551188841, 11200444586579120597, 10458676601500530505, 10228118086517851733, 13703229026582681329, 14949459108761024598, 17385586641172972108, 16585455976159330857, 16746233815942520933, 15702232757022073517, 13425038154883720197, 17537670152126568118, 16840735687703362752, 13144850200480067617, 18003109359191902093, 17403496901651142481, 13684313206131528096, 10271962828287349957, 15168663946995751965)


@Triplis_SorcererTrait_Injector.inject_to(InstanceManager, 'load_data_into_class_instances')
def Triplis_Sorcerer_add_super_affordances_to_objects(original, self):
    original(self)

    if self.TYPE == Types.OBJECT:
        # For each set of interaction ids and object ids...
        for obj_tun_hash in Triplis_SorcererTrait_Interactions_sa_to_objects:

            # First, get a tuple containing the tunings for all the super affordances...
            affordance_manager = services.affordance_manager()
            sa_list = []
            for sa_id in obj_tun_hash['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)

            # Now update the tunings for all the objects in our object list
            for obj_id in obj_tun_hash['object_tuning_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
				
				
@Triplis_SorcererTrait_Injector.inject_to(InstanceManager, 'load_data_into_class_instances')
def Triplis_Sorcerer_add_mixers_to_snippets(original, self):
    original(self)

    if self.TYPE == Types.SNIPPET:
        # For each set of interaction ids and object ids...
        for snippet_tun_hash in Triplis_SorcererTrait_Interactions_mixer_to_snippets:

            # First, get a tuple containing the tunings for all the social mixers...
            affordance_manager = services.affordance_manager()
            mixer_list = []
            for mixer_id in snippet_tun_hash['mixer_instance_ids']:
                key = sims4.resources.get_resource_key(mixer_id, Types.INTERACTION)
                mixer_tuning = affordance_manager.get(key)
                if not mixer_tuning is None:
                    mixer_list.append(mixer_tuning)
            mixer_tuple = tuple(mixer_list)

            # Now update the tunings for all the snippets in our snippet list
            for snippet_id in snippet_tun_hash['snippet_tuning_ids']:
                key = sims4.resources.get_resource_key(snippet_id, Types.SNIPPET)
                snippet_tuning = self._tuned_classes.get(key)
                if not snippet_tuning is None:
                    snippet_tuning.value = snippet_tuning.value + mixer_tuple


@Triplis_SorcererTrait_Injector.inject_to(sims.sim.Sim, 'on_add')
def Triplis_SorcerTrait_Interactions_add_super_affordances(original, self):
    original(self)
    sa_list = []
    affordance_manager = services.affordance_manager()
    for sa_id in Triplis_SorcererTrait_Interactions_sa_instance_ids:
        tuning_class = affordance_manager.get(sa_id)
        if not tuning_class is None:
            sa_list.append(tuning_class)
    self._super_affordances = self._super_affordances + tuple(sa_list)

Never had issues with it prior to the patch, but I thought maybe it was something related to it. Weird thing is, if I make a NEW save (post-patch) and make my sim into a Sorcerer, per the mod's parameters, that save doesn't seem to have any issues. I can save it and load it as if this issue never existed. It only seems to be pre-patch saves that are affected.

For now, I came up with a workaround, which is essentially to remove the mod and then save a copy of the now Sorcerer-free save, so that it can be loaded cleanly with the Sorcerer mod installed, without losing what else it has and then Sorcerer stuff can be re-added in that same save.

But I don't know if that's a workaround that will last and if for no other reason than the sheer knowing of it, I want to understand why something like this happened.

I mean, the old saves load fine if the mod is not installed, new saves load fine with it installed. So it seems like it's gotta be something in the save information itself that conflicts with a way in which the game was changed. But why would my mod specifically have some kind of information saved that conflicts? Information that only causes a problem when the mod is installed and only on saves prior to the patch?

I just spent hours trying to narrow down where the load issue is, so my brain is a bit fried. Could be I'm overthinking this. Doesn't make a lot of sense atm though.
Mods moved from MTS, now hosted at: https://triplis.github.io
Post edited by EA_Cade on

Comments

  • Options
    TriplisTriplis Posts: 3,048 Member
    edited May 2017
    Well, well... getting more specific on what the issue is (though still not sure about the root cause): I noticed that in some saves with Sorcerers, the issue didn't occur at all. At first, I thought maybe it starts occurring when the sims have custom needs. But nope, one of the saves, they had the custom Sorcerer needs and no issue.

    Then I noticed where it started happening was a save where I had taken Sorcerers with custom needs into CAS with testingcheats on and cas.fulleditmode to add another sim.

    So in one of my "fixed" saves (where the issue shouldn't be happening anymore), I tried making a couple Sorcerers again, making sure they had custom needs, and then taking them into CAS and adding a new sim to the household. I tried to "save" out of CAS and it hit me with the infinite loading screen and lastexception error.

    Which means it's at least narrowed to having something to do with CAS, presumably, and possibly something to do with editing in CAS via cas.fulleditmode. Which could be related to the "fix" for not being able to edit townies in some ancillary way, though I'm not sure how. I'm guessing it also has something to do with editing in CAS specifically tied to custom needs, though I haven't fully tested to confirm that possibility.

    Edit: This feels very Sisyphean, tracking down.

    I've now found that new saves, seems no problem.

    But whatever issue with old saves, does cling in some way. With the main Sorc family I was using for testing (I'll call them "The Bobsons" for simplicity) their save files start having the issue with when: Some of them had custom needs and I'd taken them into CAS with testingcheats on / cas.fulleditmode and added another sim to the family, saving it that way. (The issue did not appear until post-patch.)

    I "cleaned" one of their bugged saves today by removing the mod and then making a copy of the save where they aren't Sorcerers. Upon doing some more testing just now, the infinite loading screen issue returned when I made them Sorcerers again to the point of them having custom needs and saved another copy, with them as Sorcerers (in that copy, the issue returned). When I did this with only making them Sorcerers, but NOT giving them the custom needs... the issue hasn't returned yet.

    So whatever "corruption" happened connected to the CAS thing is clinging to the save and custom needs definitely appear to be tied to it in some way. This would explain why it seems to be a bizarrely fringe issue, since very few mods change the needs in any way.
    Post edited by Triplis on
    Mods moved from MTS, now hosted at: https://triplis.github.io
  • Options
    TURBODRIVERTURBODRIVER Posts: 68 Member
    Hey!

    I can only tell you about the exception file you provided.

    The error happens in the State Component which is assigned to every script object in the game (anything you can click on - chair, Sim, table, etc.). In your case, it's about adding a Sim (ID: 493994472144306196) object to the world and failing to define an initial value of a state base on a statistic of that Sim.

    The state that is being set it based on a statistic of that Sim. The related statistic is missing from that Sim statistics tracker. Now, I don't know how your mod works, but it could be that you're referring to a statistic somewhere that does not exist anymore.

    It's hard to tell much about it but it could be that the state stops working once it knows that the statistic doesn't exist anymore after loading the game so any future or new saves don't have that problem.

    Look through your tuning files, search for 'linked_stat' value, it might be set wrong.
  • Options
    TriplisTriplis Posts: 3,048 Member
    @TURBODRIVER

    Hmm. Thanks for explaining that. So I've been scouring the files for something that could be related to what you're saying. So far, not really having any luck.

    If it helps explain what I'm working with, the custom needs that I talked about are two needs "Magical Connection" and "Alignment" that are added via a trait and work like the special Vampire or PlantSim needs, where they overwrite some of the default needs. Those are the only reference to a statistic I can find in my files, or think of, that would be having an issue. Bizarrely though, in most ways, they are exactly like the Vampire or PlantSim needs, so it's not as though there's a huge difference.

    The only reference to statistics or states I've been able to find that has anything to do with my mod (apart from the two needs I just mentioned) is abilities to do with starting a fire or putting out a fire, and the fact that I added an interaction to the blob of clay (which has some states). But I checked those files carefully and am seeing no changes between how they work on Maxis's end pre-patch and how they work now, so I can't see any reason they'd be related.

    In my testing, the center of the issue seems to come back to the custom needs.

    Here's another trip into bizarre land: I have a "corrupted" save that I've been using to test things, to see if I can "uncorrupt" it reliably. So far, the only way to make it loadable is to not have any Sorcerers in it with the custom needs. In this special save...

    If I contrive a situation where there's a Sorcerer with only one of the custom needs (doesn't matter which one, I tested both) no error. If I give them both custom needs at the same time, the error returns.

    The only way I'm seeing at the moment that this can make any sense at all is if it's tied to the fact that casting a spell usually affects both needs at the same time. Say I cast a "Dark" spell called Bizarro Land (not a real spell, just go with it :P), it does -5 Magical Connection and -10 Alignment. Or if it's Light, it'd do -5 Magical Connection and +10 Alignment. I can't imagine why corruption would occur in that, but it's the only thing I can think of at the moment where the game could theoretically get caught on trying to modify both values at the same time and the data gets corrupted somehow? Then it gets saved that way, which could maybe explain why the save is only "uncorrupted" if it doesn't contain a sim that has both of those custom needs.

    But I mean, I think that's like need-to-go-to-the-chiropractor levels of reaching for an explanation. And it'd have to be some kind of corruption across the whole save, not just tied to a specific sim, cause with the testing I've done, it's if any sim in the corrupted save is given both custom needs at the same time that the issue returns, not only the ones who had the custom needs previously.
    Mods moved from MTS, now hosted at: https://triplis.github.io
  • Options
    TriplisTriplis Posts: 3,048 Member
    edited May 2017
    Hmm. Interesting turn of events. So I tried another idea for trying to narrow down the problem. Reasoned that if it only comes up when the two custom needs are added, maybe it's actually something to do with the interactions (because some of them have global tests pertaining to the needs being at certain values, that sort of thing).

    I tried just removing the scripts that inject the interactions. In theory, this shouldn't cause any problems... the interactions just won't show up anywhere. Instead, it did something a little different on a corrupted save. Instead of only giving the error message for the usual one sim ID, it gave it for 3 different sim IDs (there's a total of five sims in this corrupted save, three of which, if I recall correctly, have the base Sorcerer Trait related to the mod, though only two are adults with the two custom needs... one is a child).

    I would bet that the 3 sims it's referencing are the Sorcerers. Still doesn't pinpoint the issue, but it does play into the theory that it's something tied to the scripts and interactions.

    EDIT: Lol. So I interpreted this partly right. The number of sim ID errors is probably corresponding to the number of sims with the base Sorcerer Trait from the mod, in the save file. But it was giving 3 sim ID errors on this particular file, regardless of whether the scripts are installed. I got confused because I'd been testing on a file with only one Sorcerer in it and got used to seeing the one error message in a lastexception file.
    Post edited by Triplis on
    Mods moved from MTS, now hosted at: https://triplis.github.io
  • Options
    TriplisTriplis Posts: 3,048 Member
    Another step toward hunting down this issue... assuming I have not simply fallen asleep and dreamt it, I accidentally caused the issue to happen on an uncorrupted save, which gives me a much clearer idea of what can cause it.

    To explain: On a save I'd "cleaned" of Sorcerer, I was using an edited version of the base Sorcerer Trait and having it give the custom needs, so that I could more quickly test trying to "repair" that save. In other words, I had a trait called Bob that is just the base trait for the mod. Then there are 3 optional traits called Bobbo, Bobby, and Bobberino. Each of the 3 optional traits adds the two custom needs, but you're only supposed to use one or things would get weird.

    I had Bob edited so that it was giving custom needs, so that I could test more quickly.

    With this edited Bob installed, I tried to load a new save that works fine, where a sim in it has the two custom needs from one of the 3 optional traits. The same error message appeared!

    So what this implies is, if one trait tries to blacklist a need and another trait tries to set it as an initial_commodity or reference it in ui_commodity_sort_override, the error will occur; the edits in Bob were blacklisting Energy and the sim in the formerly new and working save had an optional of the 3 that referenced Energy in ui_commodity_sort_override.

    Here's what's weird though... someone pointed out to me that one of Bobbo, Bobby, and Bobberino (we'll say "Bobberino") was causing problems. With Bobberino gone, the issue disappears.

    So far, appears to be true. Only I can't find anything significant about Bobberino, apart from which needs it blacklists. It blacklists Energy and Hygiene. I'm figuring maybe Energy or Hygiene, one or both, have issues with being blacklisted related to the patch. Logically, it wouldn't make sense for it to be Energy, since Vampire trait blacklists that and no one seems to be reporting issues with them. That leaves Hygiene.

    Now I need to isolate and see if that holds true... making an alternative version of Bobberino that only blacklists Hygiene or only blacklists Energy.

    ...

    Ok, did that. Turns out Energy blacklists fine. Hygiene causes an error.

    All those hours in front of a computer, in need of a shower, and it was Hygiene all along.

    It feels like the universe is playing a trick on me right now.

    In all seriousness though, Hygiene seems almost undeniably the culprit at this point, but there's still one piece missing: Why? Why would you do this to me Hygiene? What did I ever do to you?

    No, but seriously, why, out of all the needs, would Hygiene have issues with being blacklisted? Makes no sense. I'm not finding anything in the code indicating a change to Hygiene. Also, I'm now seeing it's an issue with Hygiene being blacklisted, whether it's a new save or not.
    Mods moved from MTS, now hosted at: https://triplis.github.io
  • Options
    TURBODRIVERTURBODRIVER Posts: 68 Member
    Well, you said a lot so please don't except me to understand everything but I can add one thing.

    I mentioned the state of an object before. The state of an object generally changes how that object looks. Hygiene is one of the needs that does that. If a Sim has a really low hygiene level the state of that Sim will change to make that Sim look dirty. That's the state that was checking for a statistic which I guess you caused to be missing.

    Good work figuring that out!
  • Options
    TriplisTriplis Posts: 3,048 Member
    @TURBODRIVER Heh, don't worry, I just started writing everything out, in part to keep track and in part so that anyone who might be following along would know where I was with the problem (also, in case anyone who was just curious about the issue might find the thought process interesting). I don't expect anything from you about it. :)

    But thank you for your kind words and thanks for your input as well. I think what you said just now is the final piece of the puzzle I needed.

    I was totally blanking on the fact that Hygiene is tied to that process. Which makes me think that attempting to blacklist Hygiene is a really bad idea, due to those kind of processes that are related to it. I only wonder now why it didn't throw a fit before the patch. But anyway, taking this into account, I've changed the behavior of the trait, so that instead of blacklisting, Hygiene just ends up buried in the ui_sorting (aka: for all intents and purposes, not visible) and has a super low decay rate tied to the trait. So mostly the same mechanics as before, but without the bugs.

    Now I need to sleep. :)
    Mods moved from MTS, now hosted at: https://triplis.github.io

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file
Return to top