Jump to content

GetType 0 issues


rmatthews

Recommended Posts

Posted

I am working on a loot mod and I have an issue with GetType equal 0 appearing.      This condition only happens after a combat in the area where the NPC drop their weapon.   Until I manually loot the corpse the mod only returns all references as type 0.   Does anyone know how to get around this problem.

 

 

Posted

The  GetTYpe is only called once in the script

 

Here is the snippet of the script

int  i_totalCount

int  i_index

 

ref r_currentREF

 

set i_totalCount to GetNumRefs

set r_currentREF to GetFirstRef

 

Label 1

if i_index < i_totalCount
   set i_type to GetType r_currentREF

   if i_type == 42 ; NPC

      printC "NPC found: (%n %i)"  r_currentREF r_currentREF

   endif

 
   set r_currentREF to Pencil01 ; Apple Bug 
   set r_currentREF to GetNextRef
   set i_index to i_index + 1
   goto 1
endif
 

 

Posted

If you can stand using arrays, you can use GetRefs and cut down that script snippet down to almost nothing in terms of size because you're not using the old ref walking functions, not worry about the apple bug etc (whatever it was, I forgot), and avoid inherent flaws with the label/goto loops in the first place. There has to be something in your structure, the timing of things, that prevents your loop from returning a proper value. Getting rid of the loop entirely is imo the best option. For a loot-related mod, it's probably also worth pointing out that nvse has inventory ref functions and you can walk the contents of any container using a foreach loop too.

 

 

Posted

If you can stand using arrays, you can use GetRefs and cut down that script snippet down to almost nothing in terms of size because you're not using the old ref walking functions, not worry about the apple bug etc (whatever it was, I forgot), and avoid inherent flaws with the label/goto loops in the first place. There has to be something in your structure, the timing of things, that prevents your loop from returning a proper value. Getting rid of the loop entirely is imo the best option. For a loot-related mod, it's probably also worth pointing out that nvse has inventory ref functions and you can walk the contents of any container using a foreach loop too.

 

  The scripts works a good percentage of the time.   The problem arises when an NPC enters the cell and is killed in that cell.   I am wondering if this is a bug with the old method of walking the references within a cell.    

Posted

The 'apple bug' was actually fixed in OBSE, before the ref walking functions were ported to NVSE, but a lot of modders didn't realize.

 

In any case, I'd use:

 

array_var Entry
ref scan
 
foreach Entry <- (GetRefs 42)
    let scan := *Entry
    printC "NPC found: (%n %i)"  scan, scan
loop

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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