Advertisement Create a free account

[Script] Party loot pile script.

1413902495

Edited 1413957550
Do you know the issue where you start handing out loot from the freshly slain boss, and then your players start talking amongst each other, forgetting to write down who took what? Well, I solved that problem in my group by creating a group loot pile. I will just add all the loot to the pile and show it to the players, and then they can pick what they want. It has built-in protection for double looting. It is very simple to use, just type !loot help for a complete list of commands. !loot pack might be a bit unclear, what it does is, it removes the taken items from the pile, so that their numbers are reused. You can get it here: <a href="https://gist.github.com/Villadelfia/9523dd8560f94a594ec8" rel="nofollow">https://gist.github.com/Villadelfia/9523dd8560f94a594ec8</a>
1413907236
Kevin the Barbarian
Pro
Sheet Author
API Scripter
Eeenteresting...
1413907351
The Aaron
Forum Champion
API Scripter
Ooh! Nice contribution! Don't be offended if I totally pilfer your idea and run with it, because that is completely brilliant! =D
1413908271

Edited 1413910077
The Aaron said: Ooh! Nice contribution! Don't be offended if I totally pilfer your idea and run with it, because that is completely brilliant! =D Well that's why I posted it :p I'm thinking of adding some json support, so you can pre-make some "loot packets" on your computer. I was thinking of something like this: !loot add json {"money": 2000, "items": ["Boots of Speed", "+1 Keen Scimitar"]} EDIT: Done. And that's the format.
1413912413
The Aaron
Forum Champion
API Scripter
Cool. =D
1413918051
Randy, I grabbed your script, loaded it, and got it to respond with a !loot help. But cannot get anything into the loot pile. I even grabbed your entry above verbatim !loot add json {"money": 2000, "items": ["Boots of Speed", "+1 Keen Scimitar"]}, and it still told me the loot pile was empty. What am I doing wrong?
1413918158

Edited 1413918619
Check if it has thrown an error on the API page. If it successfully adds something to the loot pile, it will whisper you back that it did. EDIT: Also make sure you are speaking as "xxx (GM)" in the chat.
1413919822
Hmm, no errors on the API just "Spinning up new sandbox." Speaking as "xxx (GM)." It does not whisper back to me.
1413921321

Edited 1413922007
The Aaron
Forum Champion
API Scripter
(Side note: you can't trust the (GM) in a player's name directly. A player adding (GM) to their name can game the system. I have a script that deals with determining who is a GM, which you are welcome to use if you want: <a href="https://app.roll20.net/forum/post/920764/script-is" rel="nofollow">https://app.roll20.net/forum/post/920764/script-is</a>... All you need to do is call isGM(msg.playerid) in your script to make use of it.) (and I see you're aware of that by your suggestion... =D )
Erich S. said: Hmm, no errors on the API just "Spinning up new sandbox." Speaking as "xxx (GM)." It does not whisper back to me. Can you try all of the commands given in the !loot help card, tell me which ones give any output. The Aaron said: (Side note: you can't trust the (GM) in a player's name directly. A player adding (GM) to their name can game the system. I have a script that deals with determining who is a GM, which you are welcome to use if you want: <a href="https://app.roll20.net/forum/post/920764/script-is" rel="nofollow">https://app.roll20.net/forum/post/920764/script-is</a>... All you need to do is call isGM(msg.playerid) in your script to make use of it.) (and I see you're aware of that by your suggestion... =D ) I know, I just wanted to keep dependencies out. Also, I know it can be gamed, but in the end it is meant to stop people from accidentally calling api scripts they shouldn't.
1413923336
Randy T. said: Can you try all of the commands given in the !loot help card, tell me which ones give any output. Okay, I had two other scripts running on that test campaign: Power Card and Mystara Calendar. I disabled both of those and it now appears to be working fine. I can add/take items and money. Should have disabled the other two first, sorry for the confusion.
1413927337
The Aaron
Forum Champion
API Scripter
Let me know if the Mystara Calendar is causing the issue and I'll help you track it down. That's my oldest script, and it shows. =D
1413928261
Aaron, it appears that it is not your Calendar. I can enable it and everything works fine. So I re-enabled Power Card and Loot stops working. Thanks again for creating these scripts for everyone's use. Next step is to ensure I have the latest version of Power Card.
1413936651
The Aaron
Forum Champion
API Scripter
If it persists, I'd be happy to help you track it down. Just PM me an invite. :)
I also had to disable Power Cards before Loot would work. I currently build Loot Decks and have my player pick from the deck, but I see good things in using the Loot script if you can play nice with Power Cards. Jim
1413941985
Ooh, loot decks are a neat idea, especially for consumable items. I just might have to start giving my players potion cards.
1413942717
BTW, the problem with the Power Cards script is that it modifies msg.who in the "chat:message" callback, stripping out the "(GM)" that this script is looking for. Modifying the members of the callback argument causes later callbacks to see the modified values, which can throw them off, so it's generally not a good idea to do so (incidentally, both that script and this one also modify msg.content in their respective callbacks).
manveti said: BTW, the problem with the Power Cards script is that it modifies msg.who in the "chat:message" callback, stripping out the "(GM)" that this script is looking for. Modifying the members of the callback argument causes later callbacks to see the modified values, which can throw them off, so it's generally not a good idea to do so (incidentally, both that script and this one also modify msg.content in their respective callbacks). The Aaron said: (Side note: you can't trust the (GM) in a player's name directly. A player adding (GM) to their name can game the system. I have a script that deals with determining who is a GM, which you are welcome to use if you want: <a href="https://app.roll20.net/forum/post/920764/script-is" rel="nofollow">https://app.roll20.net/forum/post/920764/script-is</a>... All you need to do is call isGM(msg.playerid) in your script to make use of it.) (and I see you're aware of that by your suggestion... =D ) So if Randy would use Aaron's IsGM script the Party Loot script would work?
Sample of an loot deck.
1413945706
Yeah, using isGM would work (if only because isGM requires a non-API chat message to work and the Power Cards callback returns without modifying non-API messages). Or you can add "msg = _.clone(msg);" right under the "// Get the API Chat Command" comment in the "chat:message" callback in the Power Cards script (and/or just move the "if(command=="!power"){" line above the "msg.who=msg.who.replace..." line). Of course, it would be a good idea to make a similar modification to this script (the "msg=_.clone(msg)" part) so that it'll play nice with other scripts too.
1413947603
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Each "on chat" gets its own copy of the msg... I thought.
1413950369

Edited 1413950446
The documentation doesn't make it clear one way or the other, and testing suggests that a single object is passed to all the callbacks: function logAndModifyMessage(msg){ log("old message from "+msg.who+": "+msg.content); msg.who=msg.who.replace(" (GM)", ""); msg.content+="blark"; } function logAndModifyAgain(msg){ log("another old message from "+msg.who+": "+msg.content); msg.who=msg.who.replace(" (GM)", ""); msg.content+="bleep"; } on("chat:message", logAndModifyMessage); on("chat:message", logAndModifyAgain); Typing "blah" into chat yields "blah" in chat and this in the log: "old message from manveti (GM): blah" "another old message from manveti: blahblark"
1413955212

Edited 1413956280
I will modify the script to clone msg before it changes it, and I will add optional support for isGM. Give me 30 minutes. EDIT: The gist has been updated. Changes: - It will now clone msg in the callback. - It checks for the existence of IsGM, and will use it if found, otherwise it will fall back to the old behaviour of checking for "(GM)".
1413956432
The Aaron
Forum Champion
API Scripter
manveti said: BTW, the problem with the Power Cards script is that it modifies msg.who in the "chat:message" callback, stripping out the "(GM)" that this script is looking for. Modifying the members of the callback argument causes later callbacks to see the modified values, which can throw them off, so it's generally not a good idea to do so (incidentally, both that script and this one also modify msg.content in their respective callbacks). OMG! Now it all makes sense!! When I wrote isGM I targeted chat messages because "they had removed the (GM) on API msgs." I just realized it was HB's power card script running along side it that was doing that!!!! The same msg obj is passed to every handler. I ran into this same problem with my Ammo script, which was expanding inline rolls on the msg object and (ironically) breaking HB's power card script for someone.
I think I squashed all the bugs now, I accidentally allowed index out of bounds when taking items, and taking a negative amount of money. I also added earlier return so that there is a minimum of overhead on the message handler. I changed the gist in the first post to a new one so that the preview is up to date. If you want, you can put the globals inside the event handler. I put them as globals because those functions are useful for other scripts to use (If you check my personal api script repository you'll see what I mean: <a href="https://github.com/Villadelfia/roll20-scripts" rel="nofollow">https://github.com/Villadelfia/roll20-scripts</a>)
Might I suggest more than one money pile? simply because having it drop as gp isn't very flexible. don't get me wrong, love the table, but I think it needs to have the money split into a table of its own, with the ability to take from each. for example: money: 1000 gp 530 sp 60 cp 20,956 rupees 45 credits also, to clear up the table a bit, could it be possible to split the help sections to a smaller text in italics outside of the loot box itself? berhaps in a clear white box of its own just underneath the actual loot table? having there is awesome, but it would be easier to track if it was seperated slightly from the table itself. i know all this would expand the script, but it makes it quite useful and universal in scope. also, the ability to have it whisper the output to the GM so he can check whats loaded into it without spaming player chat would be nice, as well as an option to have more than one loot table set up at a time. For instance, I would have the loot set up for a particular encounter, so that the players can pick and choose from it, and have one set up for each player, and another set up for the group treasury as well. with those two additions, this would go from being a cool little script to an awesome script i would use in every game, no matter what kind of game it was or how complex my monetary system got ( and i have some really complicated ones out there, which my players hate - to do with exchange rates and different currencies being used)
1414064569
Sky
Pro
The Aaron said: manveti said: BTW, the problem with the Power Cards script is that it modifies msg.who in the "chat:message" callback, stripping out the "(GM)" that this script is looking for. Modifying the members of the callback argument causes later callbacks to see the modified values, which can throw them off, so it's generally not a good idea to do so (incidentally, both that script and this one also modify msg.content in their respective callbacks). OMG! Now it all makes sense!! When I wrote isGM I targeted chat messages because "they had removed the (GM) on API msgs." I just realized it was HB's power card script running along side it that was doing that!!!! The same msg obj is passed to every handler. I ran into this same problem with my Ammo script, which was expanding inline rolls on the msg object and (ironically) breaking HB's power card script for someone. lol... I did that because when I was sending error messages via whispers to whomever used the script... it would append an extra (GM) in the message and was pissing me off. I could probably remove those two lines now and the script would still run fine.
1414069122

Edited 1414069235
Michael H. said: Might I suggest more than one money pile? simply because having it drop as gp isn't very flexible. don't get me wrong, love the table, but I think it needs to have the money split into a table of its own, with the ability to take from each. for example: money: 1000 gp 530 sp 60 cp 20,956 rupees 45 credits also, to clear up the table a bit, could it be possible to split the help sections to a smaller text in italics outside of the loot box itself? berhaps in a clear white box of its own just underneath the actual loot table? having there is awesome, but it would be easier to track if it was seperated slightly from the table itself. i know all this would expand the script, but it makes it quite useful and universal in scope. also, the ability to have it whisper the output to the GM so he can check whats loaded into it without spaming player chat would be nice, as well as an option to have more than one loot table set up at a time. For instance, I would have the loot set up for a particular encounter, so that the players can pick and choose from it, and have one set up for each player, and another set up for the group treasury as well. with those two additions, this would go from being a cool little script to an awesome script i would use in every game, no matter what kind of game it was or how complex my monetary system got ( and i have some really complicated ones out there, which my players hate - to do with exchange rates and different currencies being used) I have split the looting instructions from the pile. As for the money pile, it could be easily added, but I'm not going to do that. I have houseruled the money in my pathfinder campaigns as an abstract number because roleplaying how the shopkeep hands you change for your gold isn't really meaningful. What I have done is allow you to set your own currency, just change the currency variable on line 138 to change it. I might consider changing it later to support multiple currencies, but in such a way that it's completely optional and that it doesn't break the general use-case. As for multiple loot piles, it can be done, but I'm not convinced that it would easy for your players to use. The use case of using it to store loot is not actually intended, it's meant to be used as a way to give all the loot to the group and then having them divide it among each other with minimum effort for the GM. I added the whisper to gm functionality, just type !loot gm to get the output of !loot whispered to the gm.
1414105581

Edited 1414105768
Just like to say, that I love this script as it is, but I can see far greater potential for it than simply being a oneshot loot pile. The option to be able to include a custom money pile would be nice - not everyone likes the easy way to do it. For example, my players frequently make the choice of leaving behind sack fulls of copper or silver coins in favor of smaller more portable valuables, and burying what they can't carry somewhere to retrieve later, and hoping to find it again. all part of the fun, really. they have caches marked out on an actual treasure map they have constructed, with cryptic clues for themselves to follow if they happen to forget the exact details, because most of the time they can't afford to take the time to ferry it all back at once, and they are always trying to on-sell looted equipment that they have 'stored' to various villages and small towns, they just go and pick up the nearest cache of looted weapons if they manage to strike a deal. gives their characters something to do in their down time, and I've even based an session or two around them having exactly what someone needs who is desperate for a quick militia to be armed, striking up a deal, and then having to deliver the goods on time (they had a fair bit of travelling to do, between caches, and with a war gearing up around them, they couldn't move very quickly). But it all comes down to the players. mine enjoy immersion, mostly, and realistic rewards. they actually complain about monster drops. if there isn't a good reason for awesome gear to be there, they don't trust it and are kinda paranoid its a trap of some sort. totally not my fault, either, they started out that way, honest... The multiple piles of loot would be useful as well, as you can imagine there are several semi-permanent ones around in the above game, and being able to keep track of random loots like that would be a godsend. currently use excel sheet, and would love to get rid of it, its not that great, and I love your layout here with this. simple, accurate, and effective. if I may? a suggestion for multiple piles - have it set to be able to create and change loot piles via a gm only command, (Aarons script really is the bomb there, though manually putting in your own id works just as well) perhaps (Edit: Please note that these commands are listed here as examples only, use !loot help for a list of actual ingame commands) !loot create &lt;name&gt;, to create a loot list with a title. this appends itself to a loot table, listed with a generated sequential number and the name of the loot pile. !loot switch &lt;variable&gt;, this would switch the loot in memory to the created loot, using the number in question to pick the loot to be loaded (and of course whispering the GM the number and the name of the loot pile switched to, for confirmation of correct pile). entering !loot switch without a variable would print out a whispered list to the GM of the available loots by number and name. !loot delete &lt;variable&gt; This would delete the loot listed under the number in question, and preferably print back a gm whisper asking for comfirmation, listing the loot number and the name of the loot, to verify it should be wiped from memory. (i.e. (to GM: confirm deletion of loot stack #&lt;variable&gt;, &lt;name&gt;? !loot add &lt;name&gt; this would add an item to a list, as it does now, and print a return confirming the item and the loot pile it was added to, by name and number. Not entirely sure if anything else would be needed there, but I might have missed something: It would be simple enough to manage as a GM, and the players would not be able to mess with it if set up in such a way. Your generic commands for the players would remain essentially the same, with !loot take &lt;variable&gt; and !loot take money &lt;variable&gt; still removing the indicated loot from the loot pile, and adding it to a separate list that becomes the players personal list of gear; this would be automatic and only require one extra command to be able to work: !loot take &lt;number&gt; this takes loot from the loot pile and adds it to the players personal loot list (which i will call booty, for clarification purposes) !loot take money &lt;amount&gt; this works as above, removing the listed amount of cash from the loot pile and adding it to their personal booty. !loot give &lt;variable&gt; this would allow a player to put loot into the loot pile from their booty pile (loot pile set by the GM of course; I would have a default loot pile constantly up that was basically party loot, and only switch to another pile if they wished to interact with it) !loot give money &lt;variable&gt; same as above, except would allow a player to put money into the loot pile, as apposed to items. as for a player and their personal loot, or booty, as I would call it once claimed, I would have it work the same way, except when a player types !loot they get two lists: the current loot table from the GM, and their own personal loot listed underneath, via a whisper. this personal table would have to be coded to each player, created automatically upon taking the first item, and directly editable by the GM, accessable via gm only commands that allow him to individually list each automatically created player loot list, and edit them. !booty prints out a list of all the player-created loot lists, and allows the GM to be select from them to work with. !booty access &lt;variable&gt; works the same as !loot switch, allowing the GM to directly modify a particular personal loot table. !booty give &lt;name&gt; same as !loot give. adds an item to the list. !booty take &lt;variable&gt; same as !loot take, except it stores the item in the GM's own personal storage. (Sometimes you want a player to lose an item for a short time, not delete it completely). !booty clear clears the entire list, leaving the players loot list intact, but empty. !booty delete &lt;variable&gt; deletes the entire list and the entry, removing the players loot list entirely from memory. as a sidenote, whichever way you decide to go, I would have add a command that will output a list of loot in a string that can be copied for later re-entry using !loot add json &lt;string&gt;, perhaps via !loot print json or something similar?
1414160392

Edited 1414161055
I completely forgot about adding an export function, I will do that right away. I will add the multiple loot piles at a later date. EDIT: I added the !loot export command.
1414164305

Edited 1414164315
The Aaron
Forum Champion
API Scripter
I really like your Ideas Michael, they line up closely with some of my own when I saw this script. I share your love of the details of currency (have you read Name of the Wind by Patrick Rothfuss? Realistic treatment of fantasy currency I've read...), I think I might have to write a script around currencies of different lands and times, and exchange rates...
1414190490

Edited 1414220356
awesome, exporting makes the listing a lot easier, I just hope that I get my little Christmas wishlist of coding joy soon as well :P
1414214697
The Aaron
Forum Champion
API Scripter
Michael, that is very cool. I don't want to polute this thread, so PM me if you'd like to discuss... =D
1414352296

Edited 1414352429
I linked my repository a few posts back, I'll split off the loot script, so you can make a pull request if you wish to change anything. EDIT: Done.
1414876972

Edited 1414879183
Is there a way to add a list of items to the pile so they all come up under there own numbers? And is there a way to add multiple of the same item with out them all taking up there own numbers?
To the first question: Yes, using the json importer, the format is easy. !loot add {"money": amount, "items": ["Item 1", "Item 3", "Item 4"]} To the second question, not yet. I'll see about adding that.
1415223689
Yeah I'm loving this! Works great and saves tons of time while players are looting bodies. I just set all the loot each monster drops as a macro that drops all of it in to the loot pile. The only way I can think of to make this better would be if the script could search whats already in the pile and if another item of the same name gets added it will put it under the same number with like a X2 behind it. That would just help clean up things like when pc kill 15 things carrying short swords.
@Randy T. Can your API be modified to save the taken loot to the players character sheets? Jim