MasterAub Posted August 16, 2017 Share Posted August 16, 2017 Hello fine people from this board I need your help...again I have a animal companion and I would like to give him one order: "fetching an object for me"The idea is as follow:When pressing a key let's say "P" the animal switch into "pick up mode" I point toward with my mouse and click on it and the animal gets the object for me placing the object into a chest (his or mine).Is this possible. Is there an another way.In short any idead how I go about doing this. Thanks for your help gals and guys. Link to comment Share on other sites More sharing options...
QQuix Posted August 17, 2017 Share Posted August 17, 2017 OBSE has all the functions to implement this. OnKeyDown to detect the keyboard key pressGetCrosshairRef to identify the object pointed by the mouseSeveral SetPackage<xxx> to dynamically adjust the animal AI package to fetch the object Activate2 to move the object to the proper container I've been away from scripting for a while and coding details are starting to fade, but this is the general idea: A simple implementation would be an ever running quest the check for the key press every frame. When the key press is detected, it adjusts a pre-existing AI Package with data about the object under the cursor. When the animal reaches the object, the OnPackageDone block moves the object to the proper container. A more complex implementation would allow for queuing objects, so you could point-and-press various objects even before the animal reached the first one. Link to comment Share on other sites More sharing options...
Surilindur Posted August 17, 2017 Share Posted August 17, 2017 Also, as is mentioned on the GetCrosshairRef wiki page, you might need to adjust the iActivatePickLength but only for the duration needed to register a reference that is too far to be normally returned by GetCrosshairRef. I have done a system exactly as the one you described for my follower management system mod, and while the system could be improved a little (it is on my to-do list, but I have not had the time to work on anything mod-related for a while), the basic idea that definitely works is the one described by QQuix. For getting the ref at crosshair at a distance:run a quest every frame, starting with "idle state", and with at least two variables: a ref and a float - the ref to store the target crosshair reference, the float to store the original iActivatePickLengthif the player is not holding down the command hotkey, and the stored iActivatePickLength is < 1, skip everythingif the stored iActivatePickLength is > 0, then use GetCrosshairRef to get the currently-pointed-at ref (you can now use it, but remember, it can be None still, if the player is not pointing at anything!), and restore iActivatePickLength to the stored value and reset the stored value to 0otherwise, if the stored iActivatePickLength is < 1 and player is holding down the hotkey, then store the original iActivatePickLength value to a variable and raise the real value to your custom value (like 4000) - then skip all else and wait for a new frameSomething like that. As for the AI package, you can also use (if the animal has animations for it) some sort of use-item-at package or somesuch. I cannot remember what I used, exactly, myself, but it is possible to create an xmarker and an AI package with the AI package pointing at that xmarker and then move the xmarker to the target ref. But changing the location data of a package would definitely be a nice and neat way to do it! It is something I will try when I have a chance to update my mod. :smile: When scripted, maybe something like that, although you probably should not copy-paste it, being untested and more of an idea. scriptname SomeQuestScript float fQuestDelayTime ; <-- set to 0.01 to run basically every frame long YourCustomHotkey float OriginalActivatePickLength ref CrosshairRef begin _GameMode if eval ( !( OnKeyDown YourCustomHotkey ) && ( OriginalActivatePickLength < 1 ) ) return endif if eval ( OriginalActivatePickLength > 0 ) ; note that, according to wiki, this might return 0 for a few frames even though there is an object! ; the script might need adjusting to account for that - also something could be done to prevent the player ; from using the activate key to grab the item, too, if that is even possible let CrosshairRef := GetCrosshairRef SetNumericGameSetting iActivatePickLength OriginalActivatePickLength let OriginalActivatePickLength := 0 else ; somehow get the current value for this let CrosshairRef := 0 let OriginalActivatePickLength := GetGameSetting iActivatePickLength SetNumericGameSetting iActivatePickLength 4000 endif end Link to comment Share on other sites More sharing options...
MasterAub Posted August 18, 2017 Author Share Posted August 18, 2017 Thank you guys, both of you. I will probably work on Contrathetix script, try to understand it and test it extensively. I will come back to you guys and the board probably on monday. Thanks again for your kind help. Link to comment Share on other sites More sharing options...
Recommended Posts