evllprchn Posted November 29, 2010 Share Posted November 29, 2010 I've been trying to get an automatic loot script working for a while now. The general idea is that I always want to pick up ammo, caps, drugs, and other such things. Every time I open a container, I don't want to always look for those; I want them to be grabbed automatically and just see what's left for me to decide on. So far, the script has been making good progress. Here are my current problems with my script: 1. I can search containers perfectly, but I can't search corpses/downed enemies/whatever you want to call them.1b. If I modify my script so I'm not checking the crosshair reference type, then I auto-loot whoever I was talking to. Not exactly ideal.2. Right now I'm using RemoveItem and AddItem to take the item from the container and give it to the player. This has the unintended side effect of bypassing the normal "stealing" mechanism (negative karma, alerting of guards, etc.). I'd much rather have the script NOT bypass stealing, but I'll take what I can get at this point. Does anyone have ideas on how to solve either of these problems? Here's the GameMode portion of my script thus far: begin GameMode ; if the Activate control is pressed if IsControlPressed 5 PrintToConsole "Activate key pressed" ; so I can tell if the script is running set crosshairRef to GetCrosshairRef ; Debugging to figure out the types of containers vs creatures short type set type to crosshairRef.GetType PrintToConsole "%f" type if (crosshairRef != 0 && crosshairRef.GetIsObjectType Container == 1) set itemOffset to 0 Label 1 if (itemOffset < ListGetCount MagneticPersonalityFormList) set itemRef to ListGetNthForm MagneticPersonalityFormList itemOffset set itemCount to crosshairRef.GetItemCount itemRef if (itemCount > 0) crosshairRef.RemoveItem itemRef itemCount 1 Player.AddItem itemRef itemCount endif set itemOffset to itemOffset + 1 GoTo 1 endif crosshairRef.Activate endif endif end Link to comment Share on other sites More sharing options...
rickerhk Posted November 30, 2010 Share Posted November 30, 2010 If you use an activation perk, you can check for all kinds of container types, etc. and get the crosshair REF. I use it for getting the Ref of terminals, doors, and containers for my companion mod. You can use multiple perks if you have a wide variety of things you want to check for. Here's a thread about the method: http://forums.bethso... Link to comment Share on other sites More sharing options...
evllprchn Posted November 30, 2010 Author Share Posted November 30, 2010 That thread is actually where I first found GetCrosshairRef! :biggrin: I had tried using perk activation originally, but for some reason anything I put in my perk scripts (I eventually tried it with a `PrintToConsole "Test"`) crashed Fallout. After banging my head against it for a few days I just made an item script, and that's how I got where I am. I'm actually getting the ref of creatures (my PrintToConsole prints out 43.000). The real problem is I can't distinguish between a live creature and a dead one. In a perfect world I would want the script to only grab things from corpses, not from NPCs standing up and walking around. And, of course, the stealing issue is still there. Any ideas? Link to comment Share on other sites More sharing options...
rickerhk Posted December 1, 2010 Share Posted December 1, 2010 That thread is actually where I first found GetCrosshairRef! :biggrin: I had tried using perk activation originally, but for some reason anything I put in my perk scripts (I eventually tried it with a `PrintToConsole "Test"`) crashed Fallout. After banging my head against it for a few days I just made an item script, and that's how I got where I am. I'm actually getting the ref of creatures (my PrintToConsole prints out 43.000). The real problem is I can't distinguish between a live creature and a dead one. In a perfect world I would want the script to only grab things from corpses, not from NPCs standing up and walking around. And, of course, the stealing issue is still there. Any ideas? Once you have the Ref of an actor, actorRef.GetDead will return 1 if it is dead, so use that to make the distinction. http://geck.bethsoft.com/index.php/GetDead Link to comment Share on other sites More sharing options...
evllprchn Posted December 1, 2010 Author Share Posted December 1, 2010 Perfect! That will nicely solve my looting-of-the-living problem. One down, one to go. Anyone have any ideas on the stealing issue? The wiki for Container lists "NPC" and "Faction" values for items within the container's item list, but I'm not entirely sure how to get at those values. Right now I'm looping through a FormList rather than the Container, so I don't have references to the items in the actual container. Link to comment Share on other sites More sharing options...
Recommended Posts