e3 - Event updateLootSetting

Discussion in 'E3' started by Tharsis, Feb 25, 2021.

  1. Tharsis

    Tharsis Orc Legionnaire

    Messages:
    143
    Event updateLootSetting didn't seem to be called and didn't seem to work with the current e3. I threw this together.




    Code:
    |--------------------------------------------------------------------|
    |- Update Loot Setting
    #EVENT updateLootSetting "<#1#> Set Loot Setting for #2# /#3#"
    #EVENT updateLootSetting "[MQ2] Set Loot Setting for #2# /#3#"
    SUB EVENT_updateLootSetting(line, ChatSender, itemName, iniSetting)
    /if (${Debug} || ${Debug_Loot}) /echo |- EVENT_updateLootSetting ==>
       /if (${ChatSender.Equal[${Me.CleanName}]} || !${Defined[ChatSender]}) {
           /declare itemToCheck string local ${itemName}
    
    
           | - update itemName and itemToCheck to use e3_7.0  LootSettings.ini format
           /declare itemValue string local
           /varset itemValue ${Cursor.Value}
           /varset itemValue ${If[${Bool[${itemValue.Left[${Math.Calc[${itemValue.Length} - 3].Int}]}]},${itemValue.Left[${Math.Calc[${itemValue.Length} - 3].Int}]}p,]}${If[${Bool[${itemValue.Mid[${Math.Calc[${itemValue.Length} - 2].Int}]}]},${itemValue.Mid[${Math.Calc[${itemValue.Length} - 2].Int}]}g,]}${If[${Bool[${itemValue.Mid[${Math.Calc[${itemValue.Length} - 1].Int}]}]},${itemValue.Mid[${Math.Calc[${itemValue.Length} - 1].Int}]}s,]}${If[${Bool[${itemValue.Right[1]}]},${itemValue.Right[1]}c,]}
           /declare iniEntryVariables string local
           /varset iniEntryVariables ${If[${Cursor.Stackable},(${Cursor.StackSize}),]}${If[${Cursor.NoDrop},(ND),]}${If[${Cursor.Lore},(L),]}${If[${Cursor.Container},(C),]}    
           /varset itemToCheck ${itemName} ${itemValue}${iniEntryVariables}
    
           /if (${itemToCheck.Find[:]}) /varset itemToCheck ${itemToCheck.Replace[:,;]}
           /declare i int local 1
        
        
           |- update to use e3_7.0 LootSettings.ini format for search and writing
            :check_Loot_Ini
           /if (${Bool[${Ini[${Loot_Ini},${itemToCheck.Left[1]},${itemToCheck}]}]}) {
               /call WriteToIni "${Loot_Ini},${itemToCheck.Left[1]},${itemToCheck}" "${iniSetting}" 1
               /delay 15
               /echo >>> Loot_Ini entry for [${itemName}] has been changed to [ ${Ini[${Loot_Ini},${itemToCheck.Left[1]},${itemToCheck}]} ]. <<<
           } else {
               /echo No entry found.
           }
     
       }
    /if (${Debug} || ${Debug_Loot}) /echo <== EVENT_updateLootSetting -|
    /RETURN
    
    To use, hold an item on your cursor and type in the trigger phrase. To make it easier, use an alias.

    Add this to MacroQuest.ini:
    Code:
    /sell=/bc Set Loot Setting for ${Cursor.Name} /Keep/Sell
    Type this into an EQ chat box:
    Code:
    /noparse /alias /sell /bc Set Loot Setting for ${Cursor.Name} /Keep/Sell
    Similar alias' can be made for Keep or Destroy

    Edited:
    02/27/21 - alias changed based on Bandy's feedback to avoid making changes to SUB lootCorpse
    02/07/22 - fixed "No Entry Found" error for large Ini Sections
     
    Last edited: Feb 7, 2022
    • Like Like x 1
  2. Tharsis

    Tharsis Orc Legionnaire

    Messages:
    143
    This part is no longer needed with the updated alias.

    SUB lootCorpse doesn't like the new "Sell" setting. One line needs to be tweaked.


    Search for this snippit.
    Code:
        /if (${lootSetting.Find[Destroy]}) {
          /echo [Loot]: Destroying [${Corpse.Item[${i}].Name}]
          /if (${Corpse.Item[${i}].Lore} && ${FindItemCount[=${Corpse.Item[${i}].Name}]}) /goto :skip_Loot
          /call loot_Handle ${i} destroy
          | Keep the item
        } else /if (${lootSetting.Find[Keep]}) {
    
    and add the part in yellow.
    Code:
        /if (${lootSetting.Find[Destroy]}) {
          /echo [Loot]: Destroying [${Corpse.Item[${i}].Name}]
          /if (${Corpse.Item[${i}].Lore} && ${FindItemCount[=${Corpse.Item[${i}].Name}]}) /goto :skip_Loot
          /call loot_Handle ${i} destroy
          | Keep the item
        } else /if (${lootSetting.Find[Keep]} || ${lootSetting.Find[Sell]}  ) {
    
    With this update, e3 will now loot items marked as Sell and will also autosell those items when using the /autosell alias.
     
    Last edited: Feb 27, 2021
  3. clippy

    clippy A Griffin

    Messages:
    229
    The format of loot setting that e3 does understand is "Keep/Sell" where the first part "Keep" is whether to loot or not, and the optional second part "Sell" if e3 autosell should sell or not.
     
    • Like Like x 1
  4. Tharsis

    Tharsis Orc Legionnaire

    Messages:
    143
    Interesting. I'm not finding a reference to that format. Have a link? The supplied Loot_Settings.ini doesn't have any Sell references to compare.


    Edit:
    Looking through the sell code.... as long as "Sell" is somewhere in the value sting, it will sell.
    Looking through the loot code... as long as "Keep" is somwhere in the value string, it will go to the next step in the loot process, which is to check for item count validity. That check seems to require a very specific format (and why I wrote the first post). I'm not seeing a valid format which works for Keep/Sell and also passes the item count process.
     
    Last edited: Feb 27, 2021
  5. Tharsis

    Tharsis Orc Legionnaire

    Messages:
    143
    You're right Bandy. "Keep/Sell" works. When you take out the ## part of Keep|## and you don't have to worry about exact format anymore. As a bonus, it makes more sense too. Why check for item count if you are going to sell it?

    The alias needs to be changed to:
    Code:
    /sell=/bc Set Loot Setting for ${Cursor.Name} /Keep/Sell
    This version does not require making changes to Sub lootCorpse mentioned in the second post.
     
    • Like Like x 1
  6. clippy

    clippy A Griffin

    Messages:
    229
    I dont remember where I picked it up but maybe it is in Chance's e3 guide somewhere.
    Anyway, first value can be Keep or Skip iirc.
    Second value can be Sell or Destroy
     
  7. trpling

    trpling Orc Centurion

    Messages:
    54
    You can probably do some validation check on the iniSettings var
     
  8. Tharsis

    Tharsis Orc Legionnaire

    Messages:
    143
    I found a fix for the dreaded "No Entry Found" error which pops up when your "Loot Settings.ini" grows large.

    If you wish to fix this on your own copy:
    Look inside e3_Loot.ini
    Look for "#EVENT updateLootSetting"
    Find this line:
    /if (${Ini[${Loot_Ini},${itemToCheck.Left[1]}].Find[${itemToCheck}]}) {

    Replace with:
    /if (${Bool[${Ini[${Loot_Ini},${itemToCheck.Left[1]},${itemToCheck}]}]}) {

    The first post has been updated with this fix.
     
    Last edited: Aug 23, 2022
  9. chance

    chance Enraged War Boar

    Messages:
    732
    @Tharsis Thank you! i didn't see this update until just now. I haven't thought about it until /Keep and /Sell came up in ooc today.