Script autodestructs on PositionCell?

Post » Sat May 28, 2011 2:04 am

I've got a strange situation that I don't know what to think about. In my mod, I don't place custom NPCs into the world in CS but gather them in a "waiting room" cell and then PositionCell them into destination when the quest stage is appropriate. I know for sure that this method works, for I already have several NPCs like that whose quests are completely debugged and they didn't show any problems with this way of introducing. But now I added one more NPC that somehow doesn't work as planned. The PositionCell command places him where needed, but he doesn't move at all. When calling for the console and issuing an "sv" on him, it shows the list of globals instead of locals in his script. If I try to talk to him, the game CTDs. If, on the other hand, I COC into the waiting room where he's originally placed by CS, everything runs fine - he has locals in his script and does it as intended. If I COC into the cell, then teleport back and then do the planned procedure to summon him into position, he's also safe.

Now, I already had a similar situation before, but that time it seemed to be a matter of an unclean save - I created an NPC first and assigned script to him later, while a save with a previous version already existed. That time I cleaned the save and everything went OK since then. But this time it was not so - the save was made before the problem NPC was brought into the mod. More than that, I started a clean new game with no other mods loaded and yet the teleported NPC lacked his script.

What else could be a reason for this strange behavior?

Thanks.
User avatar
Katie Louise Ingram
 
Posts: 3437
Joined: Sat Nov 18, 2006 2:10 am

Post » Sat May 28, 2011 5:26 am

Your NPC does not exist in the game data until the cell he is placed in is loaded in the game. PositionCell can't move the NPC because it doesn't exist and therefore creates an new reference object. This new reference has no scripts. To solve this problem you'll need to place your NPC in the cell where he needs to load and have his script immediately move him to the holding cell when your conditions for his first appearence are still false. Although the NPC may flash on the screen for one frame it is unlikely that the player will see it. You could position the NPC inside of an object or under the ground so there is no change of him being seen during the frame when the game engine moves him to the holding cell the first time the player visits the cell where he will appear.

if ( getCurrentCell == [name of cell where NPC will be])   if ( getJouralIndex [journalName] < [value where NPC will be moved to correct cell] )      possitionCell [name of holding cell] 0 0 0   endIfendIf

User avatar
Kathryn Medows
 
Posts: 3547
Joined: Sun Nov 19, 2006 12:10 pm

Post » Sat May 28, 2011 12:42 am

Your NPC does not exist in the game data until the cell he is placed in is loaded in the game. PositionCell can't move the NPC because it doesn't exist and therefore creates an new reference object. This new reference has no scripts.
I would believe that if not for a fact that, as I said, I had more than one NPC treated exactly the same way. They were placed in a waiting cell, they had their script attached, and they caught up flawlessly when summoned. Also: when I teleport to the waiting room *after* summoning the NPC to the world, he's not there anymore, so you can't say that "PositionCell... creates an new reference object".
User avatar
Thema
 
Posts: 3461
Joined: Thu Sep 21, 2006 2:36 am

Post » Fri May 27, 2011 11:50 pm

The scripts won't always load correcly nor will postionCell work reliable if not done that way. Occasionaly it may work as often as not it won't work. Doing it as I suggest it will always work.
User avatar
Maria Garcia
 
Posts: 3358
Joined: Sat Jul 01, 2006 6:59 am

Post » Sat May 28, 2011 6:29 am

I understand that you have in your mind a way of solving the problem that you consider a better one (then again, it essentially is not different from simply placing NPC into the world and disabling him until the time), but what I would like to know is what is wrong with the method I use. If the PositionCell worked the way you described... why the method *does* work at all? For I just restarted the clean new game and checked all implemented characters once again, making sure not to visit the "waiting cell" with them - those that did work previously, worked now as well; the one that didn't, didn't. It means that working or not working of PositionCell isn't a matter of random numbers, but that there is a *factor* that makes it work for a certain kind of never-seen objects and fail for another - but still a certain - kind. And I'm interested to know what that factor might be.
User avatar
Naughty not Nice
 
Posts: 3527
Joined: Sat Nov 04, 2006 6:14 am

Post » Fri May 27, 2011 11:19 pm

I understand that you have in your mind a way of solving the problem that you consider a better one (then again, it essentially is not different from simply placing NPC into the world and disabling him until the time), but what I would like to know is what is wrong with the method I use. If the PositionCell worked the way you described... why the method *does* work at all? For I just restarted the clean new game and checked all implemented characters once again, making sure not to visit the "waiting cell" with them - those that did work previously, worked now as well; the one that didn't, didn't. It means that working or not working of PositionCell isn't a matter of random numbers, but that there is a *factor* that makes it work for a certain kind of never-seen objects and fail for another - but still a certain - kind. And I'm interested to know what that factor might be.
Morrowind, a never ending source of quirks :)
what factor to compare first?
Essential/Corpses Persist/Respawn?
NPC class/six? :D

This is indeed interesting, please keep us informed if you find the factor.
User avatar
Jordan Fletcher
 
Posts: 3355
Joined: Tue Oct 16, 2007 5:27 am

Post » Fri May 27, 2011 10:37 pm

The specifics of why this works for one character, and not the other, probably relates to some unknown detail which nobody has figured out yet.

If you feel like experimenting further, maybe try mixing up the NPCs. Try swapping the "broken" NPC into a working script, and vice versa, to see what crashes when you switch things around. That may narrow down whether the issue is in the NPC, or the circumstances in which the NPC is being teleported.
User avatar
Queen Bitch
 
Posts: 3312
Joined: Fri Dec 15, 2006 2:43 pm

Post » Fri May 27, 2011 11:42 pm

I did that, and discovered that NPCs' behavior indeed switched - the one inserted into the debugged quest got the script; the one inserted into the current quest lost it. I might suggest that the reason is that I used PositionCell to place a NPC into an exterior cell rather than interior, if I didn't experiment earlier with following results:

I made a script that sends *all* vanilla NPCs (and then all mod NPCs) into a single place to check their scripts - I thought that by comparing those that lose scripts and those that don't I might get the correlation. Instead I figured that *all* NPCs lose the script when I teleport them into the place where PC already is, and retain it when I teleport them first and visit the cell later. That, I believe, can be considered a hard fact, but it still doesn't explain the weirdness above. Since the place I experimented was Vivec Temple's platform cleaned of all possible obstacles (as it turned out, I wanted to check no less than 800 NPCs! :D) - clearly an exterior cell, and I also used PositionCell and not Position.

Now, what my current quest details were. The idea is that PC gets quest-moving information from a certain NPC in Balmora Hlaalu Council, and when he leaves the building, he meets a "messenger" - my NPC. By results of a previous paragraph, such transition should have been safe, but it's not. What is interesting, when I talk to Hlaalu NPC whose dialog teleports the messenger to the outside, then teleport myself into a different interior cell (Fighters Guild) and then walk outside, the messenger has his script intact. Then I implanted the summoning command to dialogue lines of other NPCs and experimented some more. It turned out that when I summon the messenger, then walk outside, he loses the script. When I summon him, then teleport to another exterior cell (Moonmoth fort for example), then walk back on foot, he loses the script. When I either teleport to another interior cell before leaving or summon the messenger from a cell that doesn't have direct doors to exterior but has an intermediate cell (had to employ Moonmoth fort again - there's no multiple cell houses in Balmora), he retains the script. Now that could be considered a trend... if not for results of my "totality experiment" above. For then I coc'ed to Vivec Temple straight from the starting prison ship after summoning everybody there, and they still had their scripts.

*sigh* I don't know what to make of the last bit of info, I'm tired and have a headache approaching. Off to bed for today.
User avatar
Adam
 
Posts: 3446
Joined: Sat Jun 02, 2007 2:56 pm

Post » Sat May 28, 2011 6:13 am

how about having the dialog place an invisible activator outside with a do once, check distance script that spawns the NPC around the corner with orders to aitravel to and forcegreet the PC?
User avatar
JD FROM HELL
 
Posts: 3473
Joined: Thu Aug 24, 2006 1:54 am

Post » Fri May 27, 2011 8:50 pm

As for the mod itself, since I know now that I should aim for a longer chain of transitions between cells, I can do a workaround. But it's frustrating that the information I base my programming on is *still* not reliable.
User avatar
Wanda Maximoff
 
Posts: 3493
Joined: Mon Jun 12, 2006 7:05 am

Post » Sat May 28, 2011 8:30 am

I have been straining to remember the details of a similar problem I was testing. It was not until you wrote that this change is occurring when the NPC is moved to an exterior cell that my memory was jarred.

I believe that the NPC is not being 'updated' because the cell is not reloading after the NPC has been moved to it. This is not an issue if a reference of the NPC has already been created in the existing game - the sort of thing that happens the first time the NPC is met. That is why PositionCell works after the player has already met the NPC. However if the reference does not exist it is created once the NPC enters the cell where the NPC has been moved. If the cell is not 'refreshed' or 'updated' the moved NPC is merely a 'ghost' reference that causes the game to crash when the NPC is activated. This probably accounts for your script no longer being 'attached' to the NPC. There is no reference for the console to grasp so no script appears.

This is all conjecture on my part since I do not pretend to understand how the Morrowind engine (or that of any game for that matter) works. However, I performed a number of tests in http://www.gamesas.com/index.php?/topic/1080130-script-optimization/page__view__findpost__p__16280675 and have performed a few more in light of your information.

I have used Ajira as I did in my previous investigation. If I have already visited her cell, I can move her to Arrille's Tradehouse and to the Seyda Neen exterior using PositionCell successfully. If I have not previously visited Ajira (created a reference in my game), moving her to the player's cell renders Ajira's model, but as far as the game engine is concerned she does not exist in the player's cell. Activating the model creates a paradox that crashes the game. I believe your 'move to Moonmoth' test is an exterior cell adjacent to Balmora. Although CellChange may register true, the adjacent cell was already rendered and is not refreshed (or updated) when the player crosses from Fort Moonmoth to Balmora.

My original tests have the same results as before, but my conclusion was not complete. I reported that no circumstances when I had not previously visited the NPC (Ajira) in her starting (editor) cell. As it turns out, I can move Ajira to Arrille's Tradehouse before I enter it for the first time and it works, However if I have previously visited Arrille's Tradehouse, no number of cell updates (leaving and entering) seem to make Ajira's model recognizable when it is activated - the game crashes. This is also the case when I move her to the exterior cell Seyda Neen (since my test player 'lives' there).

Since the reference appears to be established the first time the cell is entered I tested by moving Ajira to an exterior cell of Balmora. Then I 'coc'ed to Balmora, Guild of Fighters, and stepped outside to greet Ajira successfully. However when I previously visit that exterior cell activation of Ajira causes the game to crash.

I do not have time this morning to test this exhaustively, and I cannot tell if your situation contradicts my conclusions. I might imagine that your test player had previously visited the exterior cell where the messenger NPC is re-positioned. If that were the case, then I would expect the result you have seen. In those tests where you moved to a different interior cell first and had a successful encounter with the messenger I wonder if in your haste to test you 'coc'ed into the interior cell pass Balmora's exterior thereby not creating a reference of it in your game until you met the messenger NPC later. In those other instances where you have re-positioned NPCs from a holding cell into another cell to encounter the player, were those cells previously visited by the player?

As abot points out, the Morrowind engine has plenty of inconsistencies to keep us guessing, but perhaps there is some regularity here:

1. You can always move an NPC if a reference of that NPC already exists in the player's game.
2. You can move an NPC to a cell that has not already been referenced in the player's game.

I look forward to your conclusions based on your experiences in light of my observations.
User avatar
teeny
 
Posts: 3423
Joined: Sun Feb 25, 2007 1:51 am

Post » Sat May 28, 2011 3:12 am

Blast. I checked what you say and you're right - the solution I concocted and that just seemed to work failed if I visit the place before issuing PositionCell, just as much as with quests I already considered debugged. Although it's possible that the condition might be cleared by 72-hour effect, for it's hard to imagine I never visited target cells prior to debugging respective quests, and I remember at least one of those quests teleporting an NPC into a cell I had visited with 100% certainty. Oh well, it seems that I'll have to rework my old scripts. [philosophically] Better now than after release, I guess.
User avatar
Alycia Leann grace
 
Posts: 3539
Joined: Tue Jun 26, 2007 10:07 pm


Return to III - Morrowind