rmatthews Posted August 26, 2015 Posted August 26, 2015 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.
Odessa Posted August 27, 2015 Posted August 27, 2015 Post your script. I suspect the issue is that you are checking GetType on an empty ref for some reason.
rmatthews Posted August 28, 2015 Author Posted August 28, 2015 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
DoctaSax Posted August 28, 2015 Posted August 28, 2015 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.
rmatthews Posted August 28, 2015 Author Posted August 28, 2015 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.
Odessa Posted August 28, 2015 Posted August 28, 2015 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
Recommended Posts
Archived
This topic is now archived and is closed to further replies.