Morrowind Mod:XFirstNPC

The UESPWiki – Your source for The Elder Scrolls since 1995
Jump to: navigation, search

A function added by MWSE.

xFirstNPC returns a reference to one of the NPCs or Creatures in the players cell or 0 if there are none. The reference is simply the one on the top of a list of all NPCs and Creatures in the cell and you can use the xNextRef function to find the rest.

In v0.9.4a this function is bugged: it may not return all references in exterior cells, and it returns deleted references. These bugs are fixed in the MWSE update released by Merzasphor.

Syntax[edit]

reference (long): xFirstNPC

Example[edit]

long NPCref 
short findNPC 
            
        if ( CellChanged == 1 )
                set findNPC to 1                
        endif

        ifx ( findNPC )
                ifx ( npcref )
                        setx npcref to xNextRef npcref
                else
                        setx npcref to xFirstNPC
                endif
                if ( npcref == 0 )     ; reached end of list
                        set findNPC to 0  
                        Return
                endif
                setx temp to npcref->xRefType
                if ( temp != 1598246990 )  ; not NPC
                        set temp to 0
                endif
                if ( temp )
                        npcref->additem gold_001 1
                endif
        endif

See Also[edit]

xSetRef
xRefType
xGetRef
xGetCombat
xGetPCTarget
xFirstItem
xFirstStatic
xNextRef