lasere200 Posted June 27, 2011 Share Posted June 27, 2011 Hello, I need some help modifying a mod for my personal use. I'm a completionist and the main reason I don't play new vegas anymore is because i spend too much time looting. I ran across an auto loot mod that is close to what i need from a looting mod. I am trying to get it to loot items in the world also not only containers. This is what i got so far. This is basically the auto loot cheaters edition script to which I added the miscRef segment. I'm just a nub but I suspect 2 things. Either there's an issue with whatever the container for a object not in an actual container might be or the getfirstref doesn't work as I think :) So what is the container for objects scattered around the wasteland?_______________________________________________________________ scn MagneticPersonalityItemScript short itemOffsetref itemRefshort itemCountshort lootableshort keytoggle ref lootingRefref containerRefref npcRefref creatureRefref miscRef begin GameMode If keytoggle != IsKeyPressed 38 ; L key set keytoggle to IsKeyPressed 38 If keytoggle == 1 && MagneticPersonalityToggle == 0 ; that's a global variable for possible use in more scripts set MagneticPersonalityToggle to 1 showmessage MagneticPersonalityON Elseif keytoggle == 1 && MagneticPersonalityToggle == 1 set MagneticPersonalityToggle to 0 showmessage MagneticPersonalityOFF Endif Endif If MagneticPersonalityToggle == 1 ; if AutoLoot is enabled by the Hotkey set containerRef to GetFirstRef 27 1 0 ; Containers Label 10 if containerRef if player.Getdistance containerRef < 128 set lootingRef to containerRef if lootingref.Getlocked == 1 lootingRef.unlock endif set lootable to 1 endif set containerRef to Pencil01 ; Prevent apple bug set containerRef to GetNextRef Goto 10 endif set NpcRef to GetFirstRef 42 1 0 ; NPCs Label 11 if NpcRef if player.Getdistance NpcRef < 128 && NpcRef.GetDead == 1 set lootingRef to NpcRef set lootable to 1 endif set NpcRef to Pencil01 set NpcRef to GetNextRef Goto 11 endif set creatureRef to GetFirstRef 43 1 0 ; Creatures Label 12 if creatureRef if player.Getdistance creatureRef < 128 && creatureRef.GetDead == 1 set lootingRef to creatureRef set lootable to 1 endif set creatureRef to Pencil01 set creatureRef to GetNextRef Goto 12 endif set miscRef to GetFirstRef 31 1 0 ; Misc Label 13 if miscRef if player.Getdistance miscRef < 128 set lootingRef to miscRef set lootable to 1 endif set miscRef to Pencil01 set miscRef to GetNextRef Goto 13 endif if (lootable != 0) set itemOffset to 0 Label 1 if (itemOffset < ListGetCount MagneticPersonalityFormList) set itemRef to ListGetNthForm MagneticPersonalityFormList itemOffset set itemCount to lootingRef.GetItemCount itemRef if (itemCount > 0) lootingRef.RemoveItem itemRef itemCount 1 Player.AddItem itemRef itemCount endif set itemOffset to itemOffset + 1 GoTo 1 endif set lootable to 0 endif endif endif endif endif end Link to comment Share on other sites More sharing options...
rickerhk Posted June 27, 2011 Share Posted June 27, 2011 If it's a misc item in the world, then you want to use:lootingRef.Activate Player To pick it up. Link to comment Share on other sites More sharing options...
TheTalkieToaster Posted June 27, 2011 Share Posted June 27, 2011 (edited) Just a note, your code is pretty hard to decipher without indentation. When posting code for others to look at, use the [code] tags. Edited June 27, 2011 by TheTalkieToaster Link to comment Share on other sites More sharing options...
lasere200 Posted June 27, 2011 Author Share Posted June 27, 2011 (edited) Sorry for that. scn MagneticPersonalityItemScript short itemOffset ref itemRef short itemCount short lootable short keytoggle ref lootingRef ref containerRef ref npcRef ref creatureRef ref miscRef begin GameMode If keytoggle != IsKeyPressed 38 ; L key set keytoggle to IsKeyPressed 38 If keytoggle == 1 && MagneticPersonalityToggle == 0 ; thats a global variable for possible use in more scripts set MagneticPersonalityToggle to 1 showmessage MagneticPersonalityON Elseif keytoggle == 1 && MagneticPersonalityToggle == 1 set MagneticPersonalityToggle to 0 showmessage MagneticPersonalityOFF Endif Endif If MagneticPersonalityToggle == 1 ; if AutoLoot is enabled by the Hotkey set containerRef to GetFirstRef 27 1 0 ; Containers Label 10 if containerRef if player.Getdistance containerRef < 128 set lootingRef to containerRef if lootingref.Getlocked == 1 lootingRef.unlock endif set lootable to 1 endif set containerRef to Pencil01 ; Prevent apple bug set containerRef to GetNextRef Goto 10 endif set NpcRef to GetFirstRef 42 1 0 ; NPCs Label 11 if NpcRef if player.Getdistance NpcRef < 128 && NpcRef.GetDead == 1 set lootingRef to NpcRef set lootable to 1 endif set NpcRef to Pencil01 set NpcRef to GetNextRef Goto 11 endif set creatureRef to GetFirstRef 43 1 0 ; Creatures Label 12 if creatureRef if player.Getdistance creatureRef < 128 && creatureRef.GetDead == 1 set lootingRef to creatureRef set lootable to 1 endif set creatureRef to Pencil01 set creatureRef to GetNextRef Goto 12 endif set miscRef to GetFirstRef 31 1 0 ; Misc Label 13 if miscRef if player.Getdistance miscRef < 128 set lootingRef to miscRef set lootable to 1 endif set miscRef to Pencil01 set miscRef to GetNextRef Goto 13 endif if (lootable != 0) set itemOffset to 0 Label 1 if (itemOffset < ListGetCount MagneticPersonalityFormList) set itemRef to ListGetNthForm MagneticPersonalityFormList itemOffset set itemCount to lootingRef.GetItemCount itemRef if (itemCount > 0) lootingRef.RemoveItem itemRef itemCount 1 Player.AddItem itemRef itemCount endif set itemOffset to itemOffset + 1 GoTo 1 endif set lootable to 0 endif endif endif endif end Edited June 27, 2011 by lasere200 Link to comment Share on other sites More sharing options...
lasere200 Posted June 27, 2011 Author Share Posted June 27, 2011 set miscRef to GetFirstRef 31 1 0 ; Misc Label 16 if miscRef if player.Getdistance miscRef < 128 miscRef.Activate player 0 set lootable to 0 endif set miscRef to Pencil01 set miscRef to GetNextRef Goto 16 endif This is how I did it so far and it works. Thanks rickerhk for the suggestion. Now I would like to add a filter. I only want to pick up misc items with a value to weight ration of at least 10. Why does something like this not work? if player.Getdistance miscRef < 128 && miscRef.GetWeight / miscRef.GetValue <= 1 / 10 Link to comment Share on other sites More sharing options...
rickerhk Posted June 28, 2011 Share Posted June 28, 2011 You might want to try something like this, if ((player.Getdistance miscRef < 128) && (miscRef.GetWeight / miscRef.GetValue) <= .1) But I would get the weight and the value first with a couple of float variables, then make sure that the value of the item was not zero before dividing, because that will halt the script. You never know if some mod will throw an item out there with zero value. Link to comment Share on other sites More sharing options...
tunaisafish Posted June 28, 2011 Share Posted June 28, 2011 Might be a good idea to add a GetDisbled check to some of these before looting - to make it more compatible with other mods/quests.At best you'd cheat yourself some items, at worst you'd break the other mod/quest. Link to comment Share on other sites More sharing options...
lasere200 Posted June 28, 2011 Author Share Posted June 28, 2011 (edited) that's interesting. I will do more work on it tonight and try to use the GetDisable thingy. could you please explain what a disabled reference is... I mean i'm really noob and don't really know how that works ingame and how would I be able to loot it if disabled. I also noticed that the form list the initial addon used can lead to heavy slowdown if you add like 2.000 items on that list so I am going to have to do something so it doesn't really come to that. also I don't like it unlocks containers for which you don't have the skill and I'll change that too.i'm also probably gonna increase the range because since it's being done anyways it shouldn't be tedious and have you walking in room corners just for autolooting basically I want it to save time without taking away from the game experience (more than it is by autolooting - so i still want lockpick minigames to be there and to still have to invest in lockpick skill) i've noticed in the ammo list some ammo that has an actor as a suffix. something like MissileRobot... is this a npc or npc type specific ammo that I will never posses or do I loot it off those NPCs of that type when they die and get it and somehow magically transforms to normal ammo? Edited June 28, 2011 by lasere200 Link to comment Share on other sites More sharing options...
tunaisafish Posted June 28, 2011 Share Posted June 28, 2011 that's interesting. I will do more work on it tonight and try to use the GetDisable thingy. could you please explain what a disabled reference is... I mean i'm really noob and don't really know how that works ingame and how would I be able to loot it if disabled. From the wiki for the Disable command... "Disabled the calling reference. Disabled references are not rendered, and disabled actors will not process their AI. Scripts will run on disabled references." For example, a lot of the containers in the Lucky 38 are disabled. They are in position with any contents intact, but invisible and unselectable to the player. You can manipulate the contents via script regardless of the desabled state.So the liquor cabinet and SS machine could be lootable by script even though you hadn't yet bought the upgrade.That was the first place I looked for an example. Not a huge game breaking example I admit :) I also noticed that the form list the initial addon used can lead to heavy slowdown if you add like 2.000 items on that list so I am going to have to do something so it doesn't really come to that. I hadn't looked that closely before at how that formlist was used. But that's a big list of lootable items?If so you can forget what I said about the quest breaking part. I doubt you'd have quest items in that list. But yeah the algorythm could be much better. It actually doesn't look like it work.ie, assume that you are standing next to a dead molerat.The Container and NPC refwalk may find and set the lootinRef variable.But so long as there's a dead molerat there, that variable will always be overwritten before the end where the contents are scanned.If you increased the range then this would be more evident. So really you should loot during the refwalk, as you now do with the misc items. To avoid the slowdown...Instead of looping over 2000+ items, you could loop over the contents of the NPC or container.With each of those items use the IsInList command. Another way which will probably work too, is to scrap the list and just use the RemoveAllItems command.That command will avoid the non-playable items like the MissileRobot you mentioned, and will also automatically loot items added by mods (which won't be on your orig list). It will grab the worthless stuff though.There's another command RemoveAllItemsOfType, which allows you to remove all say... MISC items but you can supply a formlist of exclusions.These two commands also have the benefit of not automatically repairing the weapon or armor to 100%. When you use RemoveItem and AddItem, a damaged pistol would be deleted, and a pristine one added. also I don't like it unlocks containers for which you don't have the skill and I'll change that too.i'm also probably gonna increase the range because since it's being done anyways it shouldn't be tedious and have you walking in room corners just for autolooting basically I want it to save time without taking away from the game experience (more than it is by autolooting - so i still want lockpick minigames to be there and to still have to invest in lockpick skill) Well too much range could be cheaty too. There's a cave with a dead NPC with some great loot, guarded by several deathclaws.I always enjoy that one. If I had the loot aleady it would kind of spoil the reward. If it ran on command, then it wouldn't be so bad. So you could clear the cell of enemies and then just press L to gather the loot to save time.A popup warning saying that there's a locked box somewhere would be handy too so you don't miss out. Lots of ideas to think on there, and I hope it makes sense :) It's probably one of those scripts that you'll have to keep tweaking and testing in-game to get the right balance. Link to comment Share on other sites More sharing options...
lasere200 Posted June 28, 2011 Author Share Posted June 28, 2011 (edited) Wow.. thanks. a lot of good arguments and ideas in there. i'll see what I can make happen with my severely limited knowledge :) edit: indeed remove item and add item is the absolute wrong way to go. I didn't know the items added were fully repaired. edit: THANKS A BUNCH AGAIN... it's starting to look pretty decent... still can't get the filter for weight to value ratio to work. Does the item have to be in your inventory to getweight and getvalue? edit: 4 in the morning. got it to pick up plants also. filter for value to weight ratio is working. it's actually playable right now without too many issues. cleaned it up quite a bit set miscRef to GetFirstRef 31 1 0 Label 31 if miscRef if player.Getdistance miscRef < 256 && miscRef.GetDisabled == 0 if miscRef.IsInList MagneticPersonalityMiscFormList == 1 miscRef.Activate player 0 else set vFloat to miscRef.GetValue set wFloat to miscRef.GetWeight if wFloat == 0 miscRef.Activate player 0 elseif vFloat / wFloat >= 10 miscRef.Activate player 0 endif endif endif set miscRef to Pencil01 set miscRef to GetNextRef Goto 31 endif for some reason i couldn't use the OR operator for wFloat == 0 || vFloat / wFloat >= 10 . it wouldn't pick up bottle caps but i solved it like above. right now picking up from the open world is working fine and I like how i can filter it picking up from containers isn't as flexible though set NpcRef to GetFirstRef 42 1 0 Label 42 if NpcRef if player.Getdistance NpcRef < 256 && NpcRef.GetDisabled == 0 && NpcRef.GetDead == 1 ;NpcRef.RemoveAllTypedItems Player 1 1 24 NpcRef.RemoveAllTypedItems Player 1 1 25 ;NpcRef.RemoveAllTypedItems Player 1 1 26 NpcRef.RemoveAllTypedItems Player 1 1 29 NpcRef.RemoveAllTypedItems Player 1 1 31 NpcRef.RemoveAllTypedItems Player 1 1 40 NpcRef.RemoveAllTypedItems Player 1 1 41 NpcRef.RemoveAllTypedItems Player 1 1 46 NpcRef.RemoveAllTypedItems Player 1 1 47 NpcRef.RemoveAllTypedItems Player 1 1 49 NpcRef.RemoveAllTypedItems Player 1 1 50 endif set NpcRef to Pencil01 set NpcRef to GetNextRef Goto 42 endif even if I add lists to filter it's quite a bit of work just because you have to include everything you want picked up unlike picking up from the open world where i can just add a list for everything that doesn't fit my filter as show in the miscRef example above and for quick referenceref activatorRef : Activator 21ref armorRef ; Armor 24ref bookRef ; Book 25ref clothingRef ; Clothing 26ref containerRef ; Container 27ref ingredientRef ; Ingredient 29ref miscRef ; Misc 31ref weaponRef ; Weapon 40ref ammoRef ; Ammo 41ref npcRef ; NPC 42ref creatureRef ; Creature 43ref keyRef ; Key 46ref alchemyRef ; Alchemy Item 47ref noteRef ; Note 49ref coRef ; Constructible Object 50float vFloatfloat wFloat and something else I want to do. I want to make it so that it only STEALS when I am not detected. eventually weather it will steal at all should be an option but until then I do not know how to check if any item is an item i can take normally or steal... i know how to handle the detection but not the ownership stuff. maybe you could point me in the right direction. thanks again Edited June 29, 2011 by lasere200 Link to comment Share on other sites More sharing options...
Recommended Posts