VoteByGaming Posted May 29, 2012 Share Posted May 29, 2012 (edited) So I'm having a couple problems. Well, mainly one. Here's a ref-walk script for picking items up off the ground (possibly soon to be published as the sequel to Auto Loot): scn codeStickyFingersScript ref refItem ref refItemTest ref refItemBase ref refItemOwned ref refItemCheck int shrtKeyPressed int shrtItemQuantity int intItemCountTotal int intItemDistance int intItemOwnerFaction int intConfirmOwnership int intPlayerFactionRank Begin GameMode if shrtKeyPressed != IsKeyPressed 38 set shrtKeyPressed to IsKeyPressed 38 if shrtKeyPressed == 1 && glbStickyFingersToggle == 0 set glbStickyFingersToggle to 1 messageex "Your aura has grown..." set intConfirmOwnership to 0 elseif shrtKeyPressed == 1 && glbStickyFingersToggle == 1 set glbStickyFingersToggle to 0 messageex "Your aura has receded..." endif endif if glbStickyFingersToggle == 1 set intItemCountTotal to GetNumRefs 201 1 set refItem to GetFirstRef 201 1 Label 1 if intConfirmOwnership == 1 if refItem.GetDisabled == 0 printc "Problem: Disabled?" if intItemCountTotal > 0 set intItemDistance to refitem.GetDistance player printc "Problem: Distance?" if intItemDistance <= 200 set refItemBase to refItem.gbo printc "Problem: Base Object?" set shrtItemQuantity to refItem.GetRefCount if shrtItemQuantity > 1 set shrtItemQuantity to shrtItemQuantity - 1 refitem.Activate Player 1 player.AddItem refItemBase shrtItemQuantity 1 set shrtItemQuantity to 0 printc "Problem: Right before disable?" refItem.disable printc "Problem: Right AFTER disable?" else if refItem != 0 printc "Problem: Right before disable (1 item)?" refItem.Activate Player 1 refItem.disable printc "Problem: Right AFTER disable (1 item)?" endif endif printc "One down, %.0f to go." intItemCountTotal endif endif endif printc "Before Pencil?" set refitem to Pencil01 printc "After Pencil?" printc "Next Ref probs: %n" refItem set refItem to GetNextRef set refItemBase to refItem.GetBaseObject printc "Getting next ref? %n %n" refItem refItemBase set intItemCountTotal to intItemCountTotal - 1 printc "Item total count?" set intConfirmOwnership to 0 printc "Confirming ownership?" Goto 1 endif if intItemCountTotal > 0 set intItemOwnerFaction to 255 if refItem.GetOwner == 0 set refItemCheck to refItem.GetParentCellOwner if refItemCheck == 0 set intConfirmOwnership to 1 Goto 1 else if refItemCheck.GetType == 6 set intItemOwnerFaction to refItemCheck.GetParentCellOwningFactionRequiredRank endif endif else if refItemCheck.GetType == 6 set intItemOwnerFaction to refItemCheck.GetOwningFactionRequiredRank endif endif if intItemOwnerFaction < 255 set intPlayerFactionRank to player.GetFactionRank refItemCheck printc "Variable set. Checking Actor: %n" refItemCheck if intPlayerFactionRank >= intItemOwnerFaction ;|| refItemCheck.IsActorEvil == 1 ;if refItemCheck.IsActorEvil printc "Could be evil?" set intConfirmOwnership to 1 Goto 1 ;endif else set refItemOwned to refItem.GetOwner if refItemOwned == 7 set intConfirmOwnership to 1 Goto 1 else set refitem to Pencil01 set refItem to GetNextRef set intItemCountTotal to intItemCountTotal - 1 Goto 1 endif endif else set refitem to Pencil01 set refItem to GetNextRef set intItemCountTotal to intItemCountTotal - 1 Goto 1 endif endif endif End Everything was running great until I finally killed an actor and that actor dropped a weapon. When getting within range for me to pick up the item, the game does an immediate CTD. As should be obvious with the 'printc' statements, I've been trying to locate the source of the crash. It happens directly after setting the reference to Pencil01, aka the GetNextRef portion. I've repeated it several times just to verify. My question, then, is how do I filter out "actor's dropped inventory items"? I've already set it to watch for items not belonging to me but... I'm at a bit of a loss. Edited May 29, 2012 by CDTalmas Link to comment Share on other sites More sharing options...
rickerhk Posted May 29, 2012 Share Posted May 29, 2012 GetFirstREF will return zero when there are no references and GetNextRef will return zero when the loop runs out of references in the cell. This can cause it to crash when you perform functions such as GetBaseObject, etc. It's always a good idea to make sure refItem is non-zero before performing functions on it, and use the null returned as a condition to exit the loop. example: Label 1 if refItem if intConfirmOwnership == 1 .... set refItem to GetNextRef if refItem set refItemBase to refItem.GetBaseObject ...... endif endif Link to comment Share on other sites More sharing options...
VoteByGaming Posted May 29, 2012 Author Share Posted May 29, 2012 GetFirstREF will return zero when there are no references and GetNextRef will return zero when the loop runs out of references in the cell. This can cause it to crash when you perform functions such as GetBaseObject, etc. It's always a good idea to make sure refItem is non-zero before performing functions on it, and use the null returned as a condition to exit the loop. example: Label 1 if refItem if intConfirmOwnership == 1 .... set refItem to GetNextRef if refItem set refItemBase to refItem.GetBaseObject ...... endif endif Actually, I found out something a little disturbing... So after a bit of investigation, I found that the weapon attempting to be picked up was a PN weapon. Evidently attempting to Activate a non-vanilla item is causing the CTD. And so far it's JUST the PN crowbar. Any ideas on this one? I can Activate items from other mods without a hitch! And the refItem was never null. It always had a reference (though, occasionally it would show as "<no name>" when performing a %n; the base object was just an empty sarsaparilla bottle). 'Tis why I also have the "if intItemCountTotal > 0" in place. Oh, I also read that utilizing a null/empty explosion for the area effect search will actually speed up the game. I'm looking into it. Have found very little on it thus far however. If you have any info on that, I'd be in your debt! Link to comment Share on other sites More sharing options...
rickerhk Posted May 29, 2012 Share Posted May 29, 2012 I don't see anything strange about the PN crowbar. Except that an item that has been dropped has a dynamic reference that is destroyed when you pick it up. An item placed in the geck always has it's reference available to the game engine, even if it's been picked up. Since you are picking up inventory items, have you tried just using the default activation to pick them up? (refitem.Activate Player).Then you don't need the refitem.Disable. Or actually, i'm curious why the disable function is there? As far as other scanning methods, explosions can be used to scan for actors by having a script effect on them. They have a radius, can be 0 damage, and ignore LOS.You can do the same with a spell, with a touch radius, ignore LOS, etc. Which is my preferred method. The explosions will make your shield icon on the hud light up.But both of these only work on actors. And sometimes activators. I don't know of another method for scanning anything else, other than refwalks. Link to comment Share on other sites More sharing options...
VoteByGaming Posted May 30, 2012 Author Share Posted May 30, 2012 I don't see anything strange about the PN crowbar. Except that an item that has been dropped has a dynamic reference that is destroyed when you pick it up. An item placed in the geck always has it's reference available to the game engine, even if it's been picked up. Since you are picking up inventory items, have you tried just using the default activation to pick them up? (refitem.Activate Player).Then you don't need the refitem.Disable. Or actually, i'm curious why the disable function is there? As far as other scanning methods, explosions can be used to scan for actors by having a script effect on them. They have a radius, can be 0 damage, and ignore LOS.You can do the same with a spell, with a touch radius, ignore LOS, etc. Which is my preferred method. The explosions will make your shield icon on the hud light up.But both of these only work on actors. And sometimes activators. I don't know of another method for scanning anything else, other than refwalks. Regarding the refItem.Disable, I noticed that I was Activating items after a small delay (usually after a quick travel or movement between multiple locations)... that I'd already picked up. I picked up the whiskey bottles all around the campfire south of Goodsprings four or five times. However, I'm now thinking that perhaps activating the item disables it and I should be able to work with the GetDisabled without disabling the items. I'll run a couple more tests just to be sure but I'm almost certain that activating it didn't disable it. Maybe I should run a check to see if the Ref still exists after activating it? Or perhaps picking up the Dynamic ref is the issue. I'm more inclined to think that it's the former rather than the latter. One quick question regarding ref-walking that I think a few people have asked before: Ref-Walking has a third option labeled "include taken refs". Now, what exactly does that look for? Picked up items? Are items that are picked up disabled and tagged as "taken"? Does it check for disabled items? I'm a little curious about adding that one in to test... but I'm going to just try working with the GetDisabled value and see what happens with that. Link to comment Share on other sites More sharing options...
VoteByGaming Posted May 30, 2012 Author Share Posted May 30, 2012 Activating items does not disable them, unfortunately. Also, now, I'm trying to get GetOwner to work, along with GetType and they're both pulling up 0's. Hope this doesn't require a whole new game... I did manage to clear the crash by setting up a second REF variable (by having the first variable move on to the next ref BEFORE the second ref activates the item). Link to comment Share on other sites More sharing options...
VoteByGaming Posted May 30, 2012 Author Share Posted May 30, 2012 Alright, looks like I got everything working. For some reason, it wasn't detecting items with Player ownership... but now it does. I've gotten the crashes out of the way, though my roommate says that it's not picking up currencies. They SHOULD be listed under form ID 201, right? I'm sure I'll be able to fix it with a couple of verification statements... Link to comment Share on other sites More sharing options...
rickerhk Posted May 31, 2012 Share Posted May 31, 2012 One quick question regarding ref-walking that I think a few people have asked before: Ref-Walking has a third option labeled "include taken refs". Now, what exactly does that look for? Picked up items? Are items that are picked up disabled and tagged as "taken"? Does it check for disabled items? I'm a little curious about adding that one in to test... but I'm going to just try working with the GetDisabled value and see what happens with that. 'Taken refs' are items that have been picked up. They were objects placed in the Geck editor, so the game engine still 'knows' about their REF Id's. And can access these ref ids when a cell is loaded from the plugins. They are marked as 'taken', and a ref-walk can include those too. Though in your case, you probably don't want that.If you pick up a Geck-placed item, then drop it, the dropped item's reference is not the original Geck-placed REF ID, but a dynamic ref, and only available in the save game. If you pick it up again, the dynamic ref ID is deleted from the game. Link to comment Share on other sites More sharing options...
VoteByGaming Posted May 31, 2012 Author Share Posted May 31, 2012 So, theoretically, I should be able to switch that option on and not have to worry about the whole "Disabled" aspect? (Sorry, one of my shorter posts) Link to comment Share on other sites More sharing options...
VoteByGaming Posted May 31, 2012 Author Share Posted May 31, 2012 (edited) Now I've run into another problem... but this one related to NVSE: It can't find casino chips. I've looked through the code and it says that it's listed as 6C, which translates to 198. It also mentions that it is a part of "Inventory Items". Still not picking it up (in console or in game) :/ [Edit]Problem resolved. Simply performed a second ref walk once the first was complete (lots of aggravation setting up the checks, mind you). I am going to start a new thread now for further problems involving ref walking, as more and more issues keep spawning. Edited May 31, 2012 by CDTalmas Link to comment Share on other sites More sharing options...
Recommended Posts