One of our long standing bugs on the USKP tracker is for civil war camps that spawn wounded soldiers long after everyone else in the camp is dead, though the camp itself is still there. Rather than edit the properties on 54 individual references, I tried a slightly fancier approach. This altered script is the result:
Scriptname CWFortSoldierWoundedScript extends Actor int Property PercentChanceToAppear = 75 Auto{Default: 75; What percentage of the time should this actor be loaded?}ObjectReference Property CampEnableMarker Auto{MANDATORY!!! Pointer to the camp's enable marker}FormList Property USKPCampCOList Auto{Added by USKP 1.3.3 - If the camp's Legate is dead, stop spawning wounded soldiers}Event OnCellLoad() disable() ObjectReference LegateRef = Game.FindClosestReferenceOfAnyTypeInListFromRef(USKPCampCOList, CampEnableMarker, 8000.0) if( LegateRef == None ) debug.messagebox( "I didn't find anything here" ) Return EndIf Actor Legate = LegateRef as Actor if( CampEnableMarker.IsEnabled() && Utility.RandomInt(1, 100) <= PercentChanceToAppear ) if( !Legate.IsDead() ) Enable() SetRestrained() EndIf EndIfEndEvent
However, it does not work. The debug messagebox pops up all the time even when the Legate at the camp is still alive and well within the 8000 unit radius.
The formlists have been populated correctly with the base NPC records of each Legate and/or Stormcloak. The wounded soldier base records have the proper settings, and I've confirmed they're propagating down to the individual references. Approaching a camp nets me 3 debug message boxes, which is what I'd expect from a camp with a dead leader.
Does FindClosestReferenceOfAnyTypeInListFromRef() simply not work or am I doing this wrong?