Problem With Fose's Getnextref

Post » Mon Sep 20, 2010 3:18 am

I have this bit of a script that performs a ref walk:


		Set rCurRef to Apple		set rCurRef to GetFirstRef 200 1 0			;All actors		Label 10		if rCurRef			printc "A Found Ref: %n" rCurRef					If rCurRef.GetDisabled == 0				printc "B Found Ref: %n" rCurRef				If Player.GetLos rCurRef				printc "C Found Ref: %n" rCurRef							Set Found to -1				Set Count to (ListGetCount UCFXListNew -2)				Label 15				If Count > -1					Set rOldRef to ListGetNthForm UCFXListNew Count					If rCurRef == rOldRef						Set Found to Count					EndIf					Set Count to Count - 1					Goto 15				EndIf ;Count				If Found == -1					rCurRef.ListAddReference UCFXListNew 0					rCurRef.PMS UCBlueFlames01					printc "New Ref added %n  %i" rCurRef rCurRef							Endif ;Found				Set rCurRef to apple				set rCurRef to GetNextRef				Goto 10								EndIf ;LOS			Endif ;Disabled		EndIf ;CurRef


Here is a picture of the http://s779.photobucket.com/albums/yy80/HupOranje/Output.jpg in the game near springvale.

A = A ref has been found
B = That Ref is not disabled
C = That Ref is within the LOS of the Player

As you can see from the picture, The NPC Gonzalo Ruiz has not been found by the Ref Walk at all. Any Ref found with this script will have a blue flame shader effect on them. Not only does Ruiz not have the effect, but he is absent from the Ref Walk output.

For testing, the Script runs in a quest with a 1 second processing delay.
I only seem to experience this issue with exterior cells.

Can anyone shed some light on this for me?

Also, I undertstand Cell depth, but I don't know what 'Taken Refs" means or is used for.
User avatar
Kathryn Medows
 
Posts: 3547
Joined: Sun Nov 19, 2006 12:10 pm

Post » Mon Sep 20, 2010 12:48 pm

My first guess: the problem is the -2 (unless you deliberatly want to truncate the last element)

Edit: Ok first guesses are not always good :)
But are you sure that the ref walk indeed never processes him (for depth = 1 there's a lot of console output, not everything will fit on the screen)
User avatar
Assumptah George
 
Posts: 3373
Joined: Wed Sep 13, 2006 9:43 am

Post » Mon Sep 20, 2010 3:05 am

Hey buddy,

Try your GetFirstRef with a 43 instead of a 200. 43 looks Just for NPC's, and I found great success with it in making my custom respawn system for NPCs. So this starter:

set rCurrentRef to GetFirstRef 43 0 0 ; NPCs


Might do the trick.

Luck!

Miax
User avatar
Sammie LM
 
Posts: 3424
Joined: Thu Nov 30, 2006 1:59 pm

Post » Mon Sep 20, 2010 9:04 am

But are you sure that the ref walk indeed never processes him (for depth = 1 there's a lot of console output, not everything will fit on the screen)


The output actually shows 3 iterations. I put the fire ant there as a 'flag' as you would not normally see fire ants in springvale. You can see that besides the ant, the only other ref found was an eyebot which is off screen and fails the "C" test. Having an "A" next to the ref means that the ref walk found a ref and that ref is not empty [the If (rCurRef) line]. So Ruiz is failing the most basic part of the ref walk. Its as if he does not qualify for the '200' value passed to the GetFirstRef command. If I go into Megaton, most of the NPCs will not show up either, but one or two do. Its very puzzling to me. I also used a depth of 0 initially and hoped that increasing it would help the command find Ruiz. I have to say that if I walk around some, eventually he does show up. Also, the script only runs once a second so that's why there is not so much output listed on the screenshot.


Hey buddy,

Try your GetFirstRef with a 43 instead of a 200. 43 looks Just for NPC's, and I found great success with it in making my custom respawn system for NPCs. So this starter:

set rCurrentRef to GetFirstRef 43 0 0 ; NPCs



I used to use 43 originally. But TheTalkieToaster suggested I use 200 to get 'All Actors' which is what I am after. I use the same format to move custom followers (NPCs and Creatures) in three different scripts in UC which have worked flawlessly (so far, knock on wood). I can try to use 43, but then I would need a second ref walk for the creatures. I'll test it out to see how it performs, though. Again, I only seem to have this issue in exterior cells. The same script catches all NPCs and creatures in interior cells.


Thanks to both of you for responding.

EDIT: I tried with both 42 and 43 with the same results. Most refs were skipped, but a few were not. For example, when I go into megaton, only Nathan, Manya and Confessor Cromwell are found, the rest are not. Weird!
User avatar
Ricky Meehan
 
Posts: 3364
Joined: Wed Jun 27, 2007 5:42 pm

Post » Mon Sep 20, 2010 7:21 am

I replaced my script with one that only performs a ref walk and displays whatever refs were found. This showed me that the ref walk is skipping refs. Its just not returning all ref in an exterior cell.

Here is that script:

scn UCRefTestScript   ;Quest script with 1 second prcessing delayRef rCurRefBegin GameMode	Set rCurRef to Apple	set rCurRef to GetFirstRef 200 1 0		;also tried 42 & 43 in exterior cells	Label 10	printc "Found Ref: %n" rCurRef	if (rCurRef)		Set rCurRef to Apple		set rCurRef to GetNextRef		Goto 10	EndIf ;CurRefEnd

User avatar
Kaley X
 
Posts: 3372
Joined: Wed Jul 05, 2006 5:46 pm

Post » Sun Sep 19, 2010 11:29 pm

Interesting...

My version didn't miss any NPC, though I had challenges with GetDead, my code looks amazingly similar to yours:

		set RunScan to 0		set NPCcount to 0		set rCurrentRef to GetFirstRef 43 0 0 ; NPCs		Label 100		if rCurrentRef			if rCurrentRef.GetPlayerTeammate == 0				if rCurrentRef.GetDead == 0					if rCurrentRef == player						if( Logging == 1 )							printc "Found Player"						endif						set rCurrentRef to GetNextRef						Goto 100					else						if( Logging == 1 )							printc "Found NPC %n" rCurrentRef						endif						set NPCcount to NPCcount + 1						set rCurrentRef to GetNextRef						Goto 100					endif				endif			endif		endif


Do you have a handle on the kinds of references that are getting skipped? Is it the same kind of creature all the time, or a random creature? What % would you say is getting skipped?

There will definitely be a reason OR something the FOSE team will want to know about!

Cheers

Miax
User avatar
The Time Car
 
Posts: 3435
Joined: Sat Oct 27, 2007 7:13 pm

Post » Mon Sep 20, 2010 12:02 pm

I actually have to modify what I said before. I was a bit premature. The above code actually works. But the version I ran had one more check, like this:

scn UCRefTestScriptShort IsOnShort CountShort Count2Short FoundShort NumRef rCurRefRef rOldRefBegin GameMode	If IsOn		Set rCurRef to Apple		set rCurRef to GetFirstRef 200 1 0	;also tried 42 & 43 in exterior cells		Label 10		printc "Found Ref: %n" rCurRef		if (rCurRef)			If Player.GetLOS rCurRef	;### also tried this line with 'If rCurRef.GetDisabled'[/color]				Set rCurRef to Apple				set rCurRef to GetNextRef				Goto 10			EndIf; Not Disabled		EndIf ;CurRef	EndifEnd


### If I performed a test on the returned rCurRef with either:

If rCurRef.GetDisabled == 0  (OR)If Player.GetLOS rCurRef


Then the Ref Walk started to miss references. I saw there was a warning that GetLOS was slow if called by the player on an object, but this isn't the case. And why the misses occur with GetDisabled is just a plain mystery. I'm not sure if a Ref Walk will return a disabled reference or not, but since calling GetLOS on a disabled ref will insta-crash, I thought it would be good to leave it in. In either case, what I want to accomplish just doesn't seem possible any more. Removing the LOS portion means that there will be way too many refs that will get an effect that the player won't even be able to see and, from my earlier testing in an interior cell (where the missing refs don't seem to happen when using those two commands), having too many refs with my 'effect' caused a performance hit.

Back to the drawing board I guess...
User avatar
BaNK.RoLL
 
Posts: 3451
Joined: Sun Nov 18, 2007 3:55 pm

Post » Mon Sep 20, 2010 1:09 pm

Maybe the performance hit was caused by something else? I didn't have problems so far when attaching effects to all actors, though I don't know what exact effect you're using. And maybe my pc is just too fast :D
User avatar
Kaylee Campbell
 
Posts: 3463
Joined: Mon Mar 05, 2007 11:17 am

Post » Mon Sep 20, 2010 12:54 pm

I would pose that specific question about disabled references and GetLOS to the FOSE thread in the Mod forum, and see what IanPatt has to say about it.

It also says in the Wiki that performing the check on a non-actor is what causes the performance problem - another reason to avoid using 200 in with the GetNextRef - I would find the specific code for targetting only actors with GetLOS (even if you don't perceive a hit yourself, it may still be there).

The disabled actor crashing is interesting, and likely caused by the GetLOS function not finding certain data from the actor while in a disabled state - resulting in a null-pointer reference, which leads to insta-crash. In either case, you can buffer this with a GetDisabled check before doing GetLOS and avoid the issue.

Good luck with this one, its good that your exercizing GetLOS too - as there are no Wiki updates for it and few who have toyed with it yet thus far. :)
User avatar
CHANONE
 
Posts: 3377
Joined: Fri Mar 30, 2007 10:04 am

Post » Mon Sep 20, 2010 12:43 pm

I want to thank everybody that has put up with me today and apologize too. It seems my problems have been nothing more than misplaced code. I had the GetNextRef & Goto statements in the wrong place. Once I moved them to their proper location, everything started to work fine. I can't begin to tell how embarrassed I feel right now. I should use some strong self-deprecating language right about now, but I shall leave it with this:

Sorry :embarrass:
User avatar
Sammie LM
 
Posts: 3424
Joined: Thu Nov 30, 2006 1:59 pm

Post » Mon Sep 20, 2010 5:50 am

Gah, no apologies are required - none of us caught it either eh? :) We posted a ton of code, and I even looked at your code but I didn't see a problem.

Anyway thats what the forums are for! You help out 40791873409847 people here, you got some love due back.

M
User avatar
Camden Unglesbee
 
Posts: 3467
Joined: Wed Aug 15, 2007 8:30 am

Post » Mon Sep 20, 2010 10:31 am

I seem to still be having issues with a refwalk using GetFirstRef and GetNextRef missing some refs. I have output all refs found by the ref-walk to a file and clearly the list is still missing some on occasion. It is not a persistent thing. Moving closer to them seems to get them noticed by the ref walk. Other refs in the vicinity both closer and farther away get noticed, but for some reason a few still get skipped on occasion.

Can some one explain to me what the last parameter for GetFirstRef is? The one called "Include Taken Refs"
User avatar
c.o.s.m.o
 
Posts: 3419
Joined: Sat Aug 12, 2006 9:21 am


Return to Fallout 3