{"name":"lootpet","enabled":true,"description":"Auto-loot mob drops","type":"group","id":1,"items":[{"type":"function","name":"Read_Me","enabled":true,"id":43,"code":"/* \n\nLootpet v1.0.3\nby: Zahan of Achaea\n\n\nYour very own lootpet! This \"pet\" will follow you around and pick up your loot!\nName it. Describe it. Show it off!\nIt tracks your gold and will even split what you've picked up with friends!\n\n\nUse LOOTPET in-game for options, settings, and syntaxes.\n\nExamples of the split command: \n LOOTPET SPLIT ZAHAN\n LOOTPET SPLIT ZAHAN THOTH PHAESTUS\n\n\nIf you have any problems or questions, send me a msg in the game or on the forum.\n\n\nThis plugin is provided for free but donations to Zahan (achaea) are always appreciated, no matter how small!\n\n\n
|\" + line + endsp + \"|
\");\n }\n var spaces = overall - 2;\n var space = \"\";\n for (i=0; i+-------------------------------------------------------------------------+
\");\nprint(\" \");"}],"text":"lootpet"},{"type":"group","name":"Functions","enabled":true,"id":42,"items":[{"type":"function","name":"onLoad","enabled":true,"id":3,"code":"// initiate table\nif (typeof lootpet === \"undefined\") {\n lootpet = {\n old: {},\n aff: [],\n grab: [],\n gold: parseInt(0),\n };\n}\n\n\nlootpet.stoppers = [\n \"aeon\",\n \"amnesia\",\n \"bound\",\n \"clumsiness\",\n \"confusion\",\n \"dizziness\",\n \"disrupted\",\n \"entangled\",\n //\"frozen\",\n \"hindered\",\n \"impaled\",\n \"paralysis\",\n //\"prone\",\n \"stupidity\",\n \"transfixation\",\n \"unconsciousness\",\n \"webbed\",\n];\n\n\n// default settings - don't change these (change settings with LOOTPET alias in-game)\nlootpet.settings = {\n name: \"a smart-looking pug\",\n desc: \"This tiny pug, quite literally, looks really smart. His fur is mostly off-white, but fades to black around his adorable pug nose. Adorning his stout frame is a fitted black business suit complete with a stark white undershirt, and a black silken tie. He has on his face a pair of round, black-rimmed spectacles, and around his neck is a thick silver chain. Hanging from the chain is a talisman containing the letters 'LP'.\",\n on: true,\n show_pet: true,\n my_kill_only: true,\n inp_gold: true,\n container: \"pack\",\n output_msg: true,\n stat_bar: true,\n track: true,\n tracked: parseInt(0),\n};\n\n\nlootpet.save_settings = function () {\n var settings = {};\n for (let key in lootpet.settings)\n settings[key] = lootpet[key];\n set_variable(\"lootpet\", settings);\n};\n\n\nlootpet.set_defaults = function () {\n for (let key in lootpet.settings)\n lootpet[key] = lootpet.settings[key];\n};\nlootpet.set_defaults();\n\n\n// load settings\nlootpet.saved = get_variable(\"lootpet\");\nif (lootpet.saved) {\n if (typeof lootpet.saved === \"string\") {\n // break apart variable if old string\n var lootpet_set = lootpet.saved.split(\"|\");\n for (i = 0; i < lootpet_set.length; i++) {\n lootpet_set[i] = lootpet_set[i].split(\":\");\n lootpet[lootpet_set[i][0]] = lootpet_set[i][1];\n }\n lootpet.save_settings();\n }\n else { \n // set from variable\n for (let key in lootpet.saved)\n lootpet[key] = lootpet.saved[key];\n }\n\n // turn off gmcp, if off\n if (!lootpet.on) {\n var gmcp = client.reflex_find_by_name(\"function\", \"onGMCP\", true, false, \"Lootpet\");\n reflex_disable(gmcp);\n }\n}\n\n\nlootpet.msg = function (text) {\n if (!lootpet.output_msg)\n return;\n ow_Write(\"#output_main\", \"[Lootpet]: \"+text+\"
\");\n print(\" \");\n};\n\n\nlootpet.note = function () {\n var args = arguments;\n var divi = args.length / 3;\n if (divi % 1 != 0) {\n display_notice(\"Invalid cnote(\\\"\"+args[0]+\"\\\"...)\", \"red\");\n display_notice(\"Paramaters must be in sets of 3!\", \"red\");\n return;\n }\n\n var line = \"\";\n for (var i=0; i\"+line+\"
\");\n send_command(\" \");\n};\n\n\n// pick up stuff\nlootpet.pickup = function() {\n // run checks\n if (!lootpet.grab || !lootpet.on || lootpet.looting)\n return;\n if (!lootpet.bal || !lootpet.eq)\n return;\n for (var i = 0; i < lootpet.stoppers.length; i++) {\n if (lootpet.aff[lootpet.stoppers[i]])\n return;\n }\n\n // send command\n for (var key in lootpet.grab) {\n ws_send(\"get \"+key + \"\\r\\n\");\n last_send = new Date().getTime();\n lootpet.getting = key;\n lootpet.looting = lootpet.grab[key];\n break\n }\n\n // turn off\n if (!lootpet.looting && !lootpet.packing) {\n var looting = client.reflex_find_by_name(\"group\", \"Looting\", true, false, \"Lootpet\");\n reflex_disable(looting);\n }\n};\n\n\n// put gold away\nlootpet.inp = function () {\n // run checks\n if (!lootpet.gold_out || !lootpet.inp_gold || lootpet.packing)\n return;\n if (!lootpet.bal || !lootpet.eq)\n return;\n for (var i = 0; i < lootpet.stoppers.length; i++) {\n if (lootpet.aff[lootpet.stoppers[i]])\n return;\n }\n\n // send command\n ws_send(\"put sovereigns in \"+lootpet.container + \"\\r\\n\");\n last_send = new Date().getTime();\n lootpet.packing = true;\n};\n\n//////////////////////\n\n// update_status_bar\nif (lootpet.old.update_status_bar)\n update_status_bar = lootpet.old.update_status_bar;\nelse\n lootpet.old.update_status_bar = update_status_bar;\n\nupdate_status_bar = (function() {\n var cached_function = update_status_bar;\n return function() {\n\n var result = cached_function.apply(this, arguments);\n\n if (!lootpet.stat_bar) {\n // hide it because IRE re-shows it\n $(\"#footer #status-tracked\").hide();\n return;\n }\n\n var tracked = lootpet.tracked;\n if (tracked > 0)\n tracked = \"+\"+tracked;\n\n // create div\n if (!lootpet.inserted) {\n $('#footer #status-target').after('');\n var div = $(\"#footer #status-tracked\");\n if (lootpet.track)\n div.css(\"color\", \"#3D670C\");\n else\n div.css(\"color\", \"#83210C\");\n div.html(tracked);\n lootpet.inserted = true;\n }\n\n // populate div\n if (lootpet.diff == 0 && !lootpet.redraw)\n return;\n $(\"#footer #status-tracked\").html(tracked);\n delete lootpet.redraw;\n };\n})();","items":[]},{"type":"function","name":"onGMCP","enabled":true,"id":18,"code":"// Target slain\nif (args.gmcp_method === \"IRE.Misc.Achievement\") {\n if (args.gmcp_args.name !== \"TotalCreaturesKilled\")\n return;\n lootpet.my_kill = true;\n}\n\n\n// Item dropped\nif (args.gmcp_method === \"Char.Items.Add\") {\n if (args.gmcp_args.location !== \"room\")\n return;\n if (args.gmcp_args.item.attrib !== \"t\")\n return;\n if (!lootpet.on)\n return;\n if (lootpet.my_kill_only && !lootpet.my_kill)\n return;\n\n var id = args.gmcp_args.item.id;\n var name = args.gmcp_args.item.name;\n if (!lootpet.grab)\n lootpet.grab = {};\n lootpet.grab[id] = name;\n\n var looting = client.reflex_find_by_name(\"group\", \"Looting\", true, false, \"Lootpet\");\n reflex_enable(looting);\n}\n\n\n// Gold acquired\nif (args.gmcp_method === \"Char.Status\") {\n if (!args.gmcp_args.gold)\n return;\n \n var gold = Number(args.gmcp_args.gold);\n if (gold == 0)\n return;\n \n if (lootpet.gold == 0) {\n lootpet.gold = gold;\n return;\n }\n \n lootpet.diff = gold - lootpet.gold;\n if (lootpet.diff == 0)\n return;\n \n lootpet.gold = gold;\n if (lootpet.track) {\n lootpet.tracked = Number(lootpet.tracked);\n lootpet.tracked += lootpet.diff;\n }\n \n if (lootpet.diff > 0) {\n lootpet.gold_out = true;\n if (lootpet.splitting)\n return;\n var looting = client.reflex_find_by_name(\"group\", \"Looting\", true, false, \"Lootpet\");\n reflex_enable(looting);\n }\n}\n\n\n// Vitals\nif (args.gmcp_method === \"Char.Vitals\") {\n if (lootpet.my_kill)\n delete lootpet.my_kill;\n\n if (args.gmcp_args.bal === \"1\")\n lootpet.bal = 1;\n else\n delete lootpet.bal;\n\n if (args.gmcp_args.eq === \"1\")\n lootpet.eq = 1;\n else\n delete lootpet.eq;\n\n if (!jQuery.isEmptyObject(lootpet.grab))\n lootpet.pickup();\n if (lootpet.gold_out && !lootpet.splitting)\n lootpet.inp();\n}\n\n\n// Item picked up\nif (args.gmcp_method === \"Char.Items.Remove\") {\n if (args.gmcp_args.location !== \"room\")\n return;\n var id = args.gmcp_args.item.id;\n if (lootpet.grab[id])\n delete lootpet.grab[id];\n}\n\n\n// Afflictions\nif (args.gmcp_method === \"Char.Afflictions.Add\") {\n var aff = args.gmcp_args.name;\n lootpet.aff[aff] = 1;\n}\n\nif (args.gmcp_method === \"Char.Afflictions.Remove\") {\n var aff = String(args.gmcp_args);\n delete lootpet.aff[aff];\n}"}],"actions":[]},{"type":"group","name":"Aliases","enabled":true,"id":41,"items":[{"type":"alias","name":"lootpet on|off","enabled":true,"id":31,"matching":"regexp","whole_words":false,"case_sensitive":false,"prefix_suffix":true,"actions":[{"action":"script","script":"var suffix = args[1];\nvar gmcp = client.reflex_find_by_name(\"function\", \"onGMCP\", true, false, \"Lootpet\");\nif (suffix === \"on\") {\n lootpet.on = true;\n reflex_enable(gmcp);\n}\nelse {\n lootpet.on = false;\n reflex_disable(gmcp);\n}\nlootpet.msg(\"You turn \"+suffix+\" the lootpet.\");\nlootpet.save_settings();"}],"text":"^lootpet (on|off)$"},{"type":"alias","name":"lootpet container <#>","enabled":true,"id":36,"matching":"regexp","whole_words":false,"case_sensitive":false,"prefix_suffix":true,"actions":[{"action":"script","script":"lootpet.container = args[1];\nlootpet.msg(\"You set your loot container to \"+args[1]+\".\");\nlootpet.save_settings();"}],"text":"^lootpet container (.*?)$"},{"type":"alias","name":"","enabled":true,"id":2,"matching":"exact","whole_words":true,"case_sensitive":true,"prefix_suffix":true,"actions":[{"action":"function","fn":"onLoad"}],"text":"lootpet reload","items":[]},{"type":"alias","name":"","enabled":true,"id":33,"matching":"exact","whole_words":false,"case_sensitive":false,"prefix_suffix":true,"actions":[{"action":"script","script":"lootpet.set_defaults();\nlootpet.msg(\"You revert all settings to lootpet defaults.\");\nlootpet.save_settings();"}],"text":"lootpet default"},{"type":"alias","name":"lootpet name