Jump to content

FormList strange "anomaly"...


LukeH

Recommended Posts

Hi,

 

I was working on my mod and during some tests I encountered something strange. I use a FormList in which I add Actors as I killed them. For testing I used Reachcliff Cave (the one with the cannibal feast) killing the cannibal gang there and my follower which happened to be Vorstag (mercenary from Markarth) which I also kill inside. On a onCellLoad() event on player I iterate trough my FormList. When I exit the cave and receive that event the strange thing is that Vorstag is not found on my list by the script neither Hogni Red-Arm from the cannibal gang (hope I not mistake which was that). The list contains None elements instead of those, those two are not properly removed the list keeps original size preserving all items positions. If I enter back the cave the two Actors are found again in the list everything looking ok. This reproduced every time with a clean load from before entering the cave and killing those, each time the same actors Vorstag and Hogni had the issue.

Anyone has any idea why this may happen to my list?

 

PS: also on a test I did at 2AM before giving up it seemed to me that FormList is in fact a LinkedSet (you can't have the same object instance twice in it), now I'm at work... Anyone can confirm this?

 

Thanks

Link to comment
Share on other sites

I understood half the thing that you said (formlists of actors you killed or something like that? ) but anyway, some NPCs may be possibly named via aliases rather than being some specific NPCs. So maybe you're finding some common bandit instead of the two named NPCs.

 

This part is what confuses me "The list contains None elements instead of those, those two are not properly removed the list keeps original size preserving all items positions. If I enter back the cave the two Actors are found again in the list everything looking ok." you say first that the list gets filled when you kill actors, then you say that the the list is empty, then than those two actors are not properly removed (i though you said you were adding stuff not removing it? ) then you say that if you enter back in the cave the two actors are found in the list, as in the list appears to be filled suddenly for some reason?

Link to comment
Share on other sites

Sorry if I can't make myself completely understood, I'm not a native English speaker.

That NPC are named via aliases should not be a problem as I put the Actor instance in the FormList...well I'm interested in their names actually but first I have the problem of them being returned as None (equivalent of null from java) from the list. Yours was a good point that may rise problems for me later...

By "not properly removed" I meant that if you use "Function RemoveAddedForm(Form apForm)" then the size of the list (int Function GetSize()) is decreased, but in my case when I exit the Cave my list still has the right number of elements but using "Form Function GetAt(int aiIndex)" returns None for two indexes (which I'd expect to be Vorstag and Hogni and those are not the last two items of the list). If I return back in the Cave (walk in again after I exited, not load a save game or something) the same script that iterates trough the same list returns all the Actors OK...which is the most strange thing in this whole story imo. The list is passed as an auto property to the script and shouldn't change except when I explicitly add elements.

Link to comment
Share on other sites

Interesting.

 

I thought FormLists were only to store Base Forms, not references - but you've done this and it works. Cool.

(In FNV that's how they worked and it took NVSE to add the ability for us to store Refs)

But Refs can go out of scope, something we had to check for when we put refs in FL's before using them.

 

With Skyrim, if you have a variable pointing to a Ref then it causes that ref to become persistent for the duration.

(so don't hang on to refVars longer than you need them)

 

It sounds like the FormList contents don't cause the persistence. Maybe as they were not intended to hold Refs.

 

Any chance of posting the relevant code?

 

Edit: You could probably solve your problem by using Arrays instead.

Edited by tunaisafish
Link to comment
Share on other sites

The FormList accepted instances with no problem, I didn't even think I couldn't do that, I just created a Form List in CK leaving it empty, assigned it in a property (auto) in my quest and started to add new forms to it from the script.

As you may know from my other posts and from my submitted mod, which is right now disabled due to the issues I encountered, I work on a Named Souls in Gems mod.

I'm under the impression that adding items to a FormList doesn't make them persistent...doesn't count as a reference for the persistence rule, I have a list or soul gems and just that didn't made onItemAdded populate the reference. If also registered for onUpdate event it did made them persistent and onItemAdded passed me their reference...I have to try that for Actors too maybe it will solve this problem...

I don't have the code cause I usually work on the mod late night from home and I visit forums and such at work, I have really limited free time those days. But there was nothing fancy, I added Actors and gems ObjectReference to my lists as I sayed and just iterated my lists on a onCellLoaded event on a alias of for Game.GetPlayer(), a simple while then a check for None on the list.GetAt(index)

BTW: there's no such thing as a NullPointerException (I work as a Java programmer) in papyrus when i did Actor act = list.GetAt(index) and it was None I still could call getActorBase, getRace, etc on it, all of those fuctions returning None, I didn't try a setter just getters.

I realy hate arrays in papyrus as you have to declare fixed size...you can't do something like new Actor[previousSize+1], it has to be a number in the [] it doesn't accept an expression.

Also regarding my initial PS: i double checked last night and indeed it seems you can't add one form twice to a form list neither by drag'n'drop in CK neither form papyrus.

Link to comment
Share on other sites

Thanks, and yes I do remember the mod you're working on :)

 

I tried throwing all sorts of types at AddForm(). Virtually everything will compile.

In fact the compiler isn't really fussy about what you pass to a function with a Form parameter.

So I can see there's no magic involved in storing the ref to the formlist, it was just knowing how FNV handled them that made me assume it would be the same here. I'm glad you posted as I can see uses for this :)

On the no-dupes issue, they worked the same in FNV too. With NVSE you could add dupes if needed, and as there were no arrays at all this came in handy at times. However, when the savegame loaded, the dupes were trimmed again. If you try to imagine what sort of tricks you'd have to invent to get around these issues you'd probably think the 128 fixed sized arrays were a godsend now.

 

You say you are getting None returned when looking at the list, but on returning to where the Actors are loaded it works again. So obviously the 'None' is a Papyrus lie. It's still stored. How are you testing for None?

I'm just wondering if Form.GetFormID will actually allow you to see the raw integer value.

 

And yes Papyrus is a forgiving engine w.r.t. using Null's. You'll may find corresponding lines in the debug log for calls on null objects though.

Link to comment
Share on other sites

You say you are getting None returned when looking at the list, but on returning to where the Actors are loaded it works again. So obviously the 'None' is a Papyrus lie. It's still stored. How are you testing for None?

I'm just wondering if Form.GetFormID will actually allow you to see the raw integer value.

 

And yes Papyrus is a forgiving engine w.r.t. using Null's. You'll may find corresponding lines in the debug log for calls on null objects though.

 

That's exactly what I'm saying, on exiting the cave where I killed them I find None items in the list, upon returning back in they are in the list where they should be. I also thought the None is a lie, I simply test for it with actorFromList==None and GetFormId() on it returns "0" at last it shows that when printed with Debug.Notification(actorFromList.GetFormId()). I thought that only the id gets messed up inside the form which also makes it retrun true when compared with None (though maybe is implemented as a Form with id=0 and the ids get compared) but every other calls on it (like getRace) returns None and also my name replacement doesn't work. If you wonder why I need this check http://forums.nexusmods.com/index.php?/topic/624277-text-replacement-problems-after-saveload/ if I solve that one I may not need all this s*** but it was learning papyrus the trial and error way, if you have any insight on that please let me know.

I didn't looked at the debug log, maybe is time to relay on that.

I also thought to solve this, if I can't find the actual problem, by storing ActorBase but that way I'll run into the duplicates in list problem which I may solve by storing some clutter references with the owner set to the ActorBase I need, but I'll need to placeActorAtMe when doing text replacement. May also ran into the issue noted by eltucu in the first replay when actors were named via aliases too.

Link to comment
Share on other sites

So the FormList only is persistent on the cell it was created?

 

Did you tried killing the actors inside a cell, then getting outside, kill something there, check the list outside, then enter into the cell again to check the list there?

 

It looks like the engine looses track of what the list is pointing at once you get out of the cell where the list was filled.

Edited by eltucu
Link to comment
Share on other sites

So the FormList only is persistent on the cell it was created?

 

Did you tried killing the actors inside a cell, then getting outside, kill something there, check the list outside, then enter into the cell again to check the list there?

 

It looks like the engine looses track of what the list is pointing at once you get out of the cell where the list was filled.

 

Not quite, from my list of ~7 only 2 had the problem, my follower and only one from the canibal gang from the cave, the rest seems ok. And only the list of actors, the list of gems is completely fine. I start thinking that is not the FormList with the problems but the actor reference itself somehow. But this cave is only my test ground, I can't say anything about the rest of the NPCs and places...yet I expect such problems in other places too.

Link to comment
Share on other sites

Well guys I just made a few tests and found the following:

- I created an Actor local variable in my script and after a kill if it was none I asigned it to the actor I just killed. Then I went in game and killed Vorstag which was one of the item in my list that had problems and killed him first so it's reference was assigned to my new local variable. Guess what...the list had no more problems with Vorstag upon exiting the cave

- in the following test I just did myActor.RegisterForUpdate(1800) for all actors I add to my list. Gues again...no more problems with the list upon exiting the cave

 

Conclusion: In those tests I made the actors persistent as in http://www.creationkit.com/Persistence_(Papyrus) which made the list not loosing them. I suspected it has something to do with persitence but expected that keeping a reference in a FormList will also make that reference persistent...it looks like it doesn't. All the other actors in the cave must have been persistent for other reasons from vanilla except Vorstag and Hogni. After finding those I still say that there's an "anomaly" with the FormList because it has something on those positions which changes to None and most curious back to the right value after I reenter the cave in my case...I go wtf thinking how could they have implemented this internaly to end up with such behaviour :)

 

PS: right now I'm closer to release my mod with a workaround for the issue described here: http://forums.nexusmods.com/index.php?/topic/624277-text-replacement-problems-after-saveload/ but would better find a way to fix that...any help there will be highly apreciated.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...