+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 19

  Click here to go to the first Rift Team post in this thread.   Thread: [Addon] Autwofit

  1. #1
    Telaran
    Join Date
    Mar 2012
    Posts
    83

    Default [Addon] Autwofit

    Hi everyone,

    I spent some time recently to create an addon to fix a thing that is annoying me in Rift: automatic gear change on a role change. The addon is available on Curse: http://www.curse.com/addons/rift/autwofit

    The idea of this addon is to provide an unintrusive, intuitive and small feature, so I decided against a GUI or other configuration stuff and to provide only the basic feature: switch gear if you switch role.
    The way the addon handles this is to hook the role-change event and in case it fires, it saves your current gear to your previous role and equips the gear for your new role. Unequipped items are put in the last bag to prevent accidental selling of your stuff. In a future version it will learn where you usually store your items and will try to put all items in their usual places, but yet I am struggling a bit with the Item.Move command.

    After some testing and feedback, I hope it is bug-free, however should you get stuck you can reset all settings with the command "/atf wipe". I'd love to get your feedback and - if any - bug reports.
    Last edited by TwoThe; 03-15-2012 at 04:38 AM.

  2. #2
    Plane Touched
    Join Date
    Feb 2012
    Posts
    228

    Default

    Perhaps Inspect.TEMPORARY.Role is what you want? Also Event.TEMPORARY.Role.

  3. #3
    Rift Chaser
    Join Date
    Oct 2011
    Posts
    398

    Default

    Quote Originally Posted by Baanano View Post
    Perhaps Inspect.TEMPORARY.Role is what you want? Also Event.TEMPORARY.Role.
    I would think so. Any other way I tried with Quick Cooldowns didn't work well to get the player's role. The temporary methods work fine. If I remember correctly, they are indefinitely temporary until ZorbaTHut implements full on soul support.

  4. #4
    Telaran
    Join Date
    Mar 2012
    Posts
    83

    Default

    Tested and works, thanks!

    Using Event.TEMPORARY.Role now as written above and it seems to work all fine now. I changed the download link to the updated version.
    Last edited by TwoThe; 03-12-2012 at 03:12 PM.

  5. #5
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default

    Quote Originally Posted by TwoThe View Post
    In a future version it will learn where you usually store your items and will try to put all items in their usual places, but yet I am struggling a bit with the Item.Move command.
    Wouldn't it be more useful to swap items in-place between roles? You can use Command.Item.Move() to swap items, just tested it with:
    Code:
    /script Command.Item.Move("si02.006", Utility.Item.Slot.Equipment("chest"))
    /script Command.Item.Move(Utility.Item.Slot.Equipment("chest"), "si02.006")
    The "si02.006" slot had a chest item and both commands worked as expected.

    Besides, my character isn't 50 yet (spending too much time writing Addons, heh) thus I haven't bothered creating a second role. So I can't test it yet.

  6. #6
    Telaran
    Join Date
    Mar 2012
    Posts
    83

    Default

    Quote Originally Posted by Imhothar View Post
    Wouldn't it be more useful to swap items in-place between roles?
    The script actually does that. It creates a list of items that need to be equipped and those that need to be removed and only moves those items. The issue I am facing however is that you cannot apply 2 move commands to one item at the same time (e.g. move A to bag1, then move A to bag5, in one script execution), therefore I need to place some items somewhere in the bag instead of their previous bag places.

    Your script test works, because you are applying the move commands one after another. Put them both in the same script and they should fail.

  7. #7
    Plane Touched CoreSyntax's Avatar
    Join Date
    Aug 2011
    Posts
    294

    Default

    I don't wish to step on your feet or anything, but whats wrong with the 1 click macro?

    Role 1
    Loadequip 1

  8. #8
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default

    Quote Originally Posted by TwoThe View Post
    The script actually does that. It creates a list of items that need to be equipped and those that need to be removed and only moves those items. The issue I am facing however is that you cannot apply 2 move commands to one item at the same time (e.g. move A to bag1, then move A to bag5, in one script execution), therefore I need to place some items somewhere in the bag instead of their previous bag places.

    Your script test works, because you are applying the move commands one after another. Put them both in the same script and they should fail.
    My example was just there to show that it works in both directions.

    You can solve your problem by creating a coroutine:
    Code:
    c = coroutine.create(function()
    	for *items to be moved* do
    		Command.Item.Move(...)
    		coroutine.yield()
    	end
    end)
    Then hook up System.Update.Begin and run the following:
    Code:
    if(not coroutine.resume(c))
    	*finished or error*
    end
    This way you move one item per system update. If you still run into queue throttling issues you might increase the delay and only resume the coroutine every 2 or 3 frames.
    The thing is: you can write a function which looks like it moves all items at once and execute it piecewise.
    More infos on coroutines: http://www.lua.org/manual/5.1/manual.html#2.11

    If equpping all items in one update is not the problem then you coulddo that right away and scedule the coroutine until Event.Item.Slot has occurred enough times so you know all items have been equipped/unequipped. Remember the function you put in the coroutine can have captures, that making life easier.

  9. #9
    Telaran
    Join Date
    Mar 2012
    Posts
    83

    Default

    Quote Originally Posted by CoreSyntax View Post
    I don't wish to step on your feet or anything, but whats wrong with the 1 click macro?
    Nothing, they work fine. However you need to create one role load and save macro for each role you have and click it. With this addon you have the same, just fully automatic.

    You can solve your problem by creating a coroutine
    Interesting idea, didn't think about that. It feels a little too much to execute code every frame just to check some equipment however, but I am going to dig into that idea tomorrow, maybe there is something with less overhead.

  10.   Click here to go to the next Rift Team post in this thread.   #10
    Rift Team
    Join Date
    Oct 2010
    Posts
    927

    Default

    Quote Originally Posted by TimeBomb View Post
    The temporary methods work fine. If I remember correctly, they are indefinitely temporary until ZorbaTHut implements full on soul support.
    This is correct - they won't be going away until we have a fully functional alternative.

  11. #11
    Telaran
    Join Date
    Mar 2012
    Posts
    83

    Default

    While doing some testing today I found another bug: if you let's say switch the order of your weapons the item movement will fail. While this is a bug in my code, I learned that this as well caused the game to hang in some parts.

    In my code a list of items to equip/unequip is generated and then executed by first removing all gear and then equipping all gear. In my code this list is separated into a remove and equip list, if you however merge this list (as I tried during some cleanup) the items are arbitrary either equipped or switched with the current equip set, which can - under some condition - cause the game to block certain items from being moved or equipped until you log off and back on (reloadui does not work).

    Part of the code that caused the lockup:
    Code:
    local equipToChange = getEquipChangeList(equipOnPlayer, roleSet)
    
    for itemID, targetSlotID in pairs(equipToChange) do
      Command.Item.Move(itemID, targetSlotID)
    end
    Where the essential part for getEquipChangeList is (in loop over the player's equipment by slot):
    Code:
      ...
      equipToChange[itemID] = dropLocation  -- equipped item needs to be put in this free bag slot
    end
    if (roleSetItemID ~= false) then
      equipToChange[roleSetItemID] = slotID  -- equip from bag/other equip slot needs to be equipped in this slot
    end
      ...
    Although nothing else is printed out beside the usual "You are using this function wrong", the item is sometimes no longer movable. In my case this is reproducibly the helmet that after switching gear refuses to be either moved or equipped until I relog.

  12. #12
    Champion
    Join Date
    Jun 2011
    Posts
    561

    Default

    If it helps you could look into my addon nkWardrobe how I did it. If you want to reuse something out of it just let me know.

    Cheers
    N.

  13. #13
    Telaran
    Join Date
    Mar 2012
    Posts
    83

    Default

    Quote Originally Posted by Naifu View Post
    If it helps you could look into my addon nkWardrobe how I did it.
    That was the first thing I did. ;)

  14.   This is the last Rift Team post in this thread.   #14
    Rift Team
    Join Date
    Oct 2010
    Posts
    927

    Default

    Quote Originally Posted by TwoThe View Post
    While doing some testing today I found another bug: if you let's say switch the order of your weapons the item movement will fail. While this is a bug in my code, I learned that this as well caused the game to hang in some parts.

    In my code a list of items to equip/unequip is generated and then executed by first removing all gear and then equipping all gear. In my code this list is separated into a remove and equip list, if you however merge this list (as I tried during some cleanup) the items are arbitrary either equipped or switched with the current equip set, which can - under some condition - cause the game to block certain items from being moved or equipped until you log off and back on (reloadui does not work).
    If you can provide reproducible test cases for either of these situations, I'll take a look at 'em. Those would both be considered bugs.

  15. #15
    Telaran
    Join Date
    Mar 2012
    Posts
    83

    Default

    Quote Originally Posted by ZorbaTHut View Post
    If you can provide reproducible test cases for either of these situations, I'll take a look at 'em. Those would both be considered bugs.
    The broken version can be downloaded here: http://www.curseforge.com/media/file...fit.broken.zip
    The essential code parts are in main.lua:102 and main.lua:75-78

    Steps to reproduce:
    I am using my rogue Kyrlaoy on Brutmutter for this test if you want to fetch specific details of my equipment, I however do not think this is equipment related. I have two skills "dps" and "tank" with different gear sets. The items that are switched are helmet, chest, pants, boots. Please note that the addon works reliably fine if the items are separated in two lists, one containing the items to remove and one containing the items to equip, and those lists are processed in order equipToRemove then equipToEquip.
    1. Autwofitter should greet you during startup, saying that is is active. If not please check your installation.
    2. Switch to role DPS
    3. Put on gear in all slots.
    4. Switch to role tank.
    5. Exchange helmet, chest, pants and boots with other equipment (note that I store my stuff in bag5 if that makes a difference)
    6. Switch to role DPS. 1st Bug: Autwofitter now exchanges your gear to your previous equip-set, however items get randomly placed in bag5 instead of in order as expected. Might be related to LUA giving no guarantee of the order of pairs(), therefore items might be switched in place, but that should usually place them in bag1 and not in bag5.
    7. Switch to role Tank.
    8. Unequip the off-hand.
    9. Switch to role DPS. 2nd Bug: All items but the helmet (in my case) get properly equipped (including the unequipped off-hand). The helmet from the DPS set is now stuck in my inventory and cannot be equipped. Other helmets and items can be equipped. The stuck helmet can be moved around in the inventory but will refuse to be equipped in any way. /reloadui does not help but relogging does.

    I can reproduce these bugs with a 100% success rate.
    Last edited by TwoThe; 03-13-2012 at 07:13 AM.

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts