gsmanners Posted June 24, 2009 Share Posted June 24, 2009 I really don't know. At the moment, I guess it would just be best to try different things, but those NPCs that have parentrefs would be tough to handle. I would probably avoid those if possible. With FOSE you can do stuff like that, but I don't think it's quite what you're looking for: set target to player.GetFirstRef 200 1 0 Label 10 if target if target != player && target.GetIsCreature == 0 && target.GetInSameCell player if player.GetFactionRelation target == 1 ; NPC is enemy, do stuff here endif endif set target to target.GetNextRef Goto 10 endif Link to comment Share on other sites More sharing options...
ZephyrX Posted June 24, 2009 Author Share Posted June 24, 2009 I'm not that great at scripting :smile: , but I think I sort of understand your script. Basically, it targets any NPC in the cell, right? I'm pretty sure that would work when attached to the door. About the getfirstref command, I'm not really sure how that works, but would getnextref be more applicable. Admittedly, I don't know much about either command, only what I could glean from the Construction Set wiki (there wasn't anything in the GECK wiki, maybe since it doesn't include FOSE commands). What do you think about the edit in my last post about disabling the cell? I feel that might be a very simple way to fix this problem if it would work. Also, I was curious on what a parentref is; I feel kind of dumb for asking seeing that you've mentioned it several times already but I tried looking it up but didn't find anything :biggrin: . Link to comment Share on other sites More sharing options...
gsmanners Posted June 24, 2009 Share Posted June 24, 2009 My script targets any NPC in the player's cell, and it then checks if they're an enemy. It's a standard loop structure for FOSE. The GetFirstRef tells FOSE what you want to find, and the respective GetNextRef continues its context. It's all nicely spelled out in the document that comes with FOSE. It would be nice if you could disable a cell, but something tells me (even if that syntax is permitted) that they haven't implemented that capability. You could always try it in console mode and see if it works. :) The parentref for an object allows you to give it special disabling. That is to say, it won't disable by itself. Objects that have a parentref other than 0 can only be disabled by disabling their parentref. http://geck.bethsoft.com/index.php/Disablehttp://cs.elderscrolls.com/constwiki/index.php/GetParentRef I mention this because a number of NPCs (Talon Mercs and some Super Mutants especially) tend to be chained together like this. If you were planning on having something that disables their AI via the disable command, you may be forced to disable whole groups of them somehow. Link to comment Share on other sites More sharing options...
ZephyrX Posted June 24, 2009 Author Share Posted June 24, 2009 I did some experimenting in the GECK and found that you were right about disabling a cell; it's not possible. After that, I tried to implement your script in a way that would disable the captured NPCs when the player leaves the vault and reenable them when the player reenters. I think I must have done something wrong because Fallout 3 crashes whenever I load my game. Here's the portion of my script: scn VaultInitQuestScript ref prisoner begin gamemode if player.getincell vault == 0 set prisoner to getfirstrefincell vault 200 1 label 10 if prisoner.getinfaction vaultprisonerfaction == 1 prisoner.disable endif set prisoner to prisoner.getnextref goto 10 else set prisoner to getfirstrefincell vault 200 1 label 20 if prisoner.getinfaction vaultprisonerfaction == 1 prisoner.enable endif set prisoner to prisoner.getnextref goto 20 endif end It's running as a quest script that updates practically every frame (I think). Can you help me figure out what's making it crash? Also, I was thinking about when the NPCs evaluate their packages and I wasn't sure if this would work as it's implemented in my mod. Since they seem to change their packages whenever there is some change to the cell (either the player enters or another NPC is sent to the cell) the NPCs can only be reenabled AFTER the change occurs. Perhaps the check that the player is in the cell before the enable function will account for that, but I'm not sure as of now. Link to comment Share on other sites More sharing options...
gsmanners Posted June 25, 2009 Share Posted June 25, 2009 I think you missed a line or two: if player.getincell vault == 0 set prisoner to getfirstrefincell vault 200 1 label 10 ; check the ref, or else this will loop forever if prisoner if prisoner.getinfaction vaultprisonerfaction == 1 prisoner.disable endif set prisoner to prisoner.getnextref goto 10 endif else set prisoner to getfirstrefincell vault 200 1 label 20 if prisoner if prisoner.getinfaction vaultprisonerfaction == 1 prisoner.enable endif set prisoner to prisoner.getnextref goto 20 endif endif AI can get pretty tricky, especially when you're tweaking it on the fly. Link to comment Share on other sites More sharing options...
ZephyrX Posted June 25, 2009 Author Share Posted June 25, 2009 Thanks, adding those lines stopped the crashing! I tested it out and found that the disabling part works well (I tested it with the console when out of the cell), but the enabling part doesn't seem to initialize. When I reenter the cell, the NPCs are still disabled. I double checked that I made the right additions, but I'm not sure why that part doesn't work. By the way, I was curious about what the lines you added actually do. I never came across that before when reading the GECK pages on scripting, but I guess it works :biggrin: . Link to comment Share on other sites More sharing options...
gsmanners Posted June 25, 2009 Share Posted June 25, 2009 The way GetFirstRef/GetNextRef works is that it returns a 0 terminator. The practical upshot is that you need to check that variable, and do the respective Goto within that check. Maybe you should try GetDisabled rather than checking the faction on the enable loop (not sure that works on NPCs that are disabled). http://cs.elderscrolls.com/constwiki/index.php/GetDisabled Link to comment Share on other sites More sharing options...
ZephyrX Posted June 25, 2009 Author Share Posted June 25, 2009 Hmm, I tried switching the getinfaction command with getdisabled, but the NPCs still aren't being enabled. Maybe both functions don't work on disabled refs. The good thing is that the NPCs aren't evaluating their script packages because of the disabling, but it seems that either those functions can't be used for this. That's strange though because getdisabled can be used in the console on disabled NPCs, which is how I realized that the NPCs were still disabled. It could still be something wrong with the script then since the function should work. Link to comment Share on other sites More sharing options...
gsmanners Posted June 25, 2009 Share Posted June 25, 2009 Maybe you need to do AddScriptPackage, then Enable. Or maybe you need to do a MoveTo, AddScriptPackage, then Enable. Link to comment Share on other sites More sharing options...
ZephyrX Posted June 25, 2009 Author Share Posted June 25, 2009 I'm kind of confused on what you mean by using moveto, addscriptpackage and enable. Would that go in the same place that enable is now? Also, I think the problem must be that getfirstref isn't targeting disabled refs, maybe changing the last ignore parameter might fix that? EDIT: Adding a 1 for the ignore parameter didn't change anything so it must be something else. Link to comment Share on other sites More sharing options...
Recommended Posts