kxdace Posted October 10, 2020 Posted October 10, 2020 Hello! I am testing a spell that when it executes it gets all the Actors in a cell then sorts then based on different criteria. I start a new game using alternate start and while in the Sleeping Giant Inn I run the spell and it gets all three actors Tester(The PC), Orgnar and Delfine. I go outside and it gets 7 people to include the dog, chickens and surprisingly a white run guard?! I dont see no guard so I assume it must be a disabled actor that activates when you complete that quest where you talk to the Yarl at Whiterun. How do I check to see of a Actor is disabled or enabled. I've been able to filter by things like gender, race and formlist but I cant get the disable \ enabled code to function properly I've included the entire code below but this is the specific section I m having trouble with: Please help ===Section=== actorRandomWL = playerCell.GetNthRef(npcCountInitial, 43) AS Actor ObjectReference npcEnabledStatus = actorRandomWL AS ObjectReference if(npcEnabledStatus.getLinkedRef().isDisabled()) debug.MessageBox("The actor " + actorRandomWL.getleveledActorBase().getName() + " is disabled") endIf ===Entire Code=== Scriptname wrScript_MISC_GetNPC_A_V2 extends activemagiceffect Actor property actorRandom Auto Actor property actorRandomWL Auto String property stringFinalText Auto Event onEffectStart(Actor akTarget, Actor akCaster) Cell playerCell = Game.GetPlayer().GetParentCell() int npcCountInitial = playerCell.GetNumRefs(43) debug.MessageBox("There are currently: " + npcCountInitial + " actors in this cell") int randomNPCnumber = Utility.RandomInt (0, npcCountInitial) ObjectReference[] objectRefListA = new ObjectReference[20] while(npcCountInitial) npcCountInitial -= 1 actorRandomWL = playerCell.GetNthRef(npcCountInitial, 43) AS Actor ;debug.MessageBox("The actor in this cell list at postion " + npcCountInitial + " is " + actorRandomWL.getleveledActorBase().getName()) int npcSexInt = actorRandomWL.GetActorBase().getSex(); 0 is male 1 is female race npcRace = actorRandomWL.GetActorBase().getRace() ObjectReference npcEnabledStatus = actorRandomWL AS ObjectReference if(npcEnabledStatus.getLinkedRef().isDisabled()) debug.MessageBox("The actor " + actorRandomWL.getleveledActorBase().getName() + " is disabled") endIf if (npcSexInt == 1) debug.MessageBox("The actor " + actorRandomWL.getleveledActorBase().getName() + " is a " + npcRace +" female") ;if (npcRace == NordRace) ;debug.MessageBox("The actor " + actorRandomWL.getleveledActorBase().getName() + " is a Nord") ;Tested and works but probably better to use formlist ;endIf int formSizeInt = RacesHuman.getSize() debug.MessageBox("Form size is " + z) while formSizeInt >= 0 formSizeInt -= 1 race tempRace = RacesHuman.GetAt(z) AS RACE ;debug.MessageBox("Compare: " + tempRace) if (npcRace == tempRace) debug.MessageBox("The actor " + actorRandomWL.getleveledActorBase().getName() + " is a valid target") endIf endWhile endIf objectRefListA[npcCountInitial] = playerCell.GetNthRef(npcCountInitial, 43) utility.wait(1) ;If I dont put wait the code executes List Item 2 Tester, List Item 0 Delphine, List Item 1 Orgnar for some strange reason ;This test was done with three people in the sleeping giant inn those three listed above ;stringFinalText += " Array Slot: " + npcCountInitial +" "+ actorRandomWL.getleveledActorBase().getName() endWhile actorRandom = objectRefListA[randomNPCnumber] AS Actor debug.MessageBox("The chosen NPC is " + actorRandom.getleveledActorBase().getName()) ;debug.MessageBox("The actors are as follows: " + stringFinalText) EndEvent
Seijin8 Posted October 10, 2020 Posted October 10, 2020 4 minutes ago, kxdace said: How do I check to see of a Actor is disabled or enabled. https://www.creationkit.com/index.php?title=IsDisabled_-_ObjectReference
dnoah Posted October 10, 2020 Posted October 10, 2020 57 minutes ago, kxdace said: if(npcEnabledStatus.getLinkedRef().isDisabled()) Well I can see how this wouldn't work in case of a non-unique actor, as their ActorBase can have a lot of linked references, both disabled and enabled. I think I heard people using cloak spell effects for stuff like that and that that was bad for performance. And that's about all I have on the matter.
kxdace Posted October 10, 2020 Author Posted October 10, 2020 So it looks like the following change did the trick: if(npcEnabledStatus.getLinkedRef().isDisabled()) Changed to if(npcEnabledStatus..isDisabled()) Thanks for the advice!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.