Myst42 Posted September 10, 2021 Share Posted September 10, 2021 I'm wondering if anybody knows anything about missing functions. I have an LE mod that uses 2 functions actually:One is Cell.GetNumRefs()The other is Cell.GetNthRef() They worked perfectly on LE as I was using them to index actors in a cell, but on Special Edition, the function seems to be doing nothing.I ran debugging lines and now those functions return 0/None But I just checked some SKSE64 source scripts and form types are still inside a script.So anybody knows what happened? Can I still use these on another way or are they just gone and I need to rewrite the whole thing? A fragment of the script goes like this. I've highlighted the parts that mattter cause they work on LE but return 0 on SEEvent OnUpdate() PlayerCell = PlayerRef.GetParentCell() ActiveActors = PlayerCell.GetNumRefs(62) ; 62 -> Type of Ref: Character LogTrace("ActiveActors = "+ActiveActors) ActorCount = 0 If DebugMode && NewCell Timer = Utility.GetCurrentRealTime() LogTrace("New Cell Scan Initialized " + Timer) Else LogTrace("Old cell (No effects regenerate call)") EndIf While ActorCount <= ActiveActors && PlayerCell == PlayerRef.GetParentCell() Actor Subject = PlayerCell.GetNthRef(ActorCount, 62) as Actor If Subject != None LogTrace("New Actor = "+Subject) If Subject.Is3DLoaded() Subject.AddSpell(ElementalVulnerability, False) ; Base Effect If NewCell RegenerateEffects(Subject) EndIf EndIf Else LogTrace("Failed to retrieve an actor (Subject = None) at count = "+ActorCount) EndIf ActorCount += 1 EndWhile Link to comment Share on other sites More sharing options...
ReDragon2013 Posted September 10, 2021 Share Posted September 10, 2021 (edited) Myst42 wrote: "They worked perfectly on LE as I was using them to index actors in a cell, but on Special Edition, the function seems to be doing nothing.""If the cell that references are called from is not loaded, non-persistent references will not be called." https://www.creationkit.com/index.php?title=GetNumRefs_-_Cell I assume you run a script of type ReferenceAlias, which refers to the player. Sometimes it is a good idea to make things a bit easier to understand.Maybe next code is helpful. By the way it is using the same two SKSE functions. And I am not sure, if function GetNthRef() starts with n=0 or n=1. Cell LastPlayerCell ; place holder Bool bNewCell ; ??? EVENT OnPlayerLoadGame() LastPlayerCell = None ; reset variable on every game load ENDEVENT EVENT OnLocationChange(Location akOldLoc, Location akNewLoc) gotoState("Busy") ; ### STATE ### prevent multiple calls at the same time cell c = Game.GetPlayer().GetParentCell() ; get players cell IF (LastPlayerCell) && (LastPlayerCell == c) ; last cell exists, but is the same as before ELSE LastPlayerCell = c ; set variable, every time on players cell change IF (Weather.GetSkyMode() == 1) ; interior location, and the cell as same ELSE myF_FindActors(c) ENDIF ENDIF gotoState("") ; ### STATE ### ENDEVENT ; -- FUNCTIONs -- ;------------------------------ FUNCTION myF_FindActors(Cell c) ;------------------------------ ;; see cell.psc, SKSE 64 additions built 2020-07-29 17:24:48.495000 UTC ;; Returns the number of refs in the cell ; int Function GetNumRefs(int formTypeFilter = 0) native ; ;; returns the ref at the specified index ; ObjectReference Function GetNthRef(int n, int formTypeFilter = 0) native ;; ---------------------------------------------------------------------- ; https://www.creationkit.com/index.php?title=GetType_-_Form IF (SKSE.GetVersion() > 0) ELSE RETURN ; - STOP - SKSE is missing! ENDIF ;--------------------- int i = c.GetNumRefs(62) ; 62 -> kCharacter WHILE (i) ; (i != 0) --- TopDown loop -- ;;; i = i - 1 objectReference oRef = c.GetNthRef(i, 62) IF (oRef as Actor) myF_Action(oRef) ELSE Debug.Trace(SKSE.GetVersion() + " GetNthRef(" +i+ ") - failed to retrieve an actor.. " +oRef) ENDIF i = i - 1 ENDWHILE ENDFUNCTION ;---------------------------------------- FUNCTION myF_Action(ObjectReference oRef) ;---------------------------------------- IF oRef.Is3DLoaded() (oRef as Actor).AddSpell(ElementalVulnerability, False) ; Base Effect IF ( bNewCell ) RegenerateEffects(oRef as Actor) ENDIF ENDIF ENDFUNCTION ;------------------------------------- FUNCTION RegenerateEffects(Actor aRef) ;------------------------------------- ; .. ENDFUNCTION Edited September 10, 2021 by ReDragon2013 Link to comment Share on other sites More sharing options...
Myst42 Posted September 11, 2021 Author Share Posted September 11, 2021 Unloaded Cell: Somehow I can't see why would that be an issue since it's calling the cell the player is currently in. Also it's called from a repeating script, so if the player cell is not considered "loaded" after 2 minutes of standing still in it, I dont know what does load it. Reference Alias: actually no. That one is on a player permanent ability, but the way it works is more or less the same. for what it does. As for the script, sadly I wont get a chance to test it properly until a couple more days. I can say though, that I dont think a rewritten version can fix it. I should still test to see if anything changes.But just in case, I gotta sat this wasn't a post about code not working because I have an unfinished mod and I got confused on how to do something, this is about functions not working.I'm 100% sure that the original code works. The LE mod is completely functional and I've used it for a couple of years by now with no issues at all. Tried to port it to SE and this happens. I found an alternate way earlier to day to handle the abilty assignment and another thing I did that scans shaders and re-applies them to NPCs in case they disappeared on a cell change. But it's probably not as good as the original system. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 11, 2021 Share Posted September 11, 2021 According to the type list on the GetType page, type 62 is kCharacter which, as I understand it, would be the player. If you are wanting other actors then use 43 which is kNPC. Link to comment Share on other sites More sharing options...
Recommended Posts