Jump to content

loops inside loops is it possible ?


romeck

Recommended Posts

huh thats true, i tried to fool it but i cant, it always CTD or just hang the game :( is it possible to add static reference i mean there is NPC Boon and i want to use his reference but dont know how. there is form list npc which has number 42 but again refwalking . is it posible in script sth like that

 

ref killer

set killer to "Boone"

Link to comment
Share on other sites

You could cache the inner loop refs to a formlist.

I'm not sure exactly what refs you are trying to scan over. But looking at your recent questions you are scanning teammates and dead actors?

The scan for the inner loop teammates could also use the static refs of the standard companions (you mean the ones in NPCFollowersLIST?)

As you are using nested loops, then for efficiency do all the processing of the potential 'killers' once outside of the main loops and sotre the valid refs to MyTmpFormList.

 

Something like the code below could be used...

 

 

 

;Ensure your temp formlist is empty
Label 1
if ListGetCount MyTmpFormList
 ListRemoveNth MyTmpFormList 0
 Goto 1
endif

;Fill Inner loop Temp formlist with your teammate refs
set rActorRef to GetFirstRef 200 1 0
Label 1
if rActorRef
 if (rActorRef.GetPlayerTeamMate == 1)
   rActorRef.ListAddRef MyTmpFormList
 endif
 set rActorRef to Pencil01
 set rActorRef to GetNextRef
 goto 1
endif

if ListGetCount MyTmpFormList
 set rActorRef to GetFirstRef 200 1 0
 Label 1;OUTER LOOP
 if rActorRef
   if (rActorRef.GetPlayerTeamMate == 0)
     ;Do more tests on rActorRef - like is it dead???
     set iIdx to ListGetCount MyTmpFormList
     Label 2;INNER LOOP
     if iIdx
       set iIdx to iIdx - 1
       set rTgt to ListGetNthForm MyTmpFormList iIdx
       ;Now you have a teammate in rTgt, and a (dead?) non-teammate actor in rActorRef
       ;Do stuff
       Goto 2
     endif
   endif
   set rActorRef to Pencil01
   set rActorRef to GetNextRef
   goto 1
 endif
endif

 

 

Link to comment
Share on other sites

but how can i use static refs ? thats what i want now but i do not know how, like i write :

 

ref killer and how to set the killer to be "Boone" or other companions.

 

 

 

and thanks for sample. that should solve my problem , since i do not know that i can use elements of the list without refwalking. that will save me a lot of work :)

Edited by romeck
Link to comment
Share on other sites

You use ref variables just the same as you'd use the static ref.

 

ref rTgt

set rTgt to CraigBooneREF

 

So now you can use rActorREF.IsKiller rTgt

 

Changing the previous code a little, MyTmpFormList can store companion and teammate refs

 

 

 

if ListGetCount MyTmpFormList 
 set rActorRef to GetFirstRef 200 1 0 
 Label 1;OUTER LOOP 
 if rActorRef 
   if (rActorRef.GetPlayerTeamMate == 0) 
     ;Do more tests on rActorRef - like is it dead??? 
     if rActorRef.GetDead
       set iIdx to ListGetCount MyTmpFormList 
       Label 2;INNER LOOP 
       if iIdx 
         set iIdx to iIdx - 1 
         set rTgt to ListGetNthForm MyTmpFormList iIdx 
         ;Now you have a teammate in rTgt, and a (dead?) non-teammate actor in rActorRef 
         if rActorRef.IsKiller rTgt
           ;Do stuff
         endif
         Goto 2 
       endif 
     endif 
   endif 
   set rActorRef to Pencil01 
   set rActorRef to GetNextRef 
   goto 1 
 endif 
endif

 

 

 

Just a note about a possible cause of CTD's. When using 2 lists like this you may need to ensure that rActorRef != rTgt.

(I had a script of mine hang before when using a container function where the source was the target.)

Can easily be avoided above as could add a GetDead == 0 condition to the part populating MyTmpFormList.

 

Of course in the ';Do stuff' part you may also need to make sure you don't 'do stuff' repeatedly :/

 

The good thing about caching the 'teammates' into a temp fomlist is that it only needs to be updated infrequently. You could also have it completely empty when not in combat... just thinking out loud here really :)

 

FWIW, I've not looked closely at the companion and teammate code but I don't *think* they are related.

teammates are the temporary followers? Like the injured NPC you find in the caves in a big mountain.

The vanilla followers all seem to be refered to individually and there are 2 flags you need to check to see if they are curently with the player.

(something like isHired && !Resting)

I've no idea how to identify the companions from new-follower mods if you want to make yours compatible with those.

 

EDIT: Sorry, I didn't explain how to find the ref name's like CraigBooneREF

 

Finding the refs of NPC's (and general GECK searching)

 

The vanilla follower baseforms are listed in NPCFollowersLIST

If you type one of those (eg CraigBoone) in the 'filter' box and select to show all forms you'll see it.

Right click the baseform and choose 'use info'.

In the bottom pane you'll see that there is a reference in some interior cell, just double-click that to open the cell and have the reference highlighted.

 

You could do that for each NPC in the list, but there are lots of ingame scripts that already use the vanilla refnames. To find them, Choose 'Edit->Find Text' from the main menu, and search for CraigBooneREF

Under the scripts tab, you'll see many scripts. VUltraLuxeInteriorDoorSCRIPT is one that lists them all.

Edited by tunaisafish
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...