Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 27

Thread: SmashLib: Expected results from smashing

  1. #1
    Senior Member
    Join Date
    Feb 2009
    Posts
    182

    Default SmashLib: Expected results from smashing

    SmashLib 1.2

    SmashLib attempts to tell you what you're going to get when you smash something. Since it's impossible to know exactly what you're going to get, it takes an expected value approach: if half the time you'll get a twinkly powder, and half the time you'll get a cold powder, it tells you you'll get .5 twinkly powders and .5 cold powders.

    SmashLib handles both regular equipment and any weird stuff that Mafia deals with in pulverize.ash. In essence, SmashLib is designed to be a script version of the Pulverize Helper, and should tell you the same thing with a little more detail.

    SmashLib requires ZLib

    For Scripters:
    SmashLib provides a way for scripts to get at the results of smashing things via three basic functions:

    float [string] get_smash_element(item it) : Returns a map of elements/pseudo-elements to fraction of results of that element. Possible elements are: twinkly, cold, hot, sleaze, stench, useless, epic, sea salt, ultimate, sugar, depleted Grimacite, and Crovacite

    string get_smash_tier(item it) : Returns a string representing the smash tier: 1P, 2P, 3P, 1N, 2N, 3N, 1W, 2W, 3W, or exception. "exception" serves as flag to note that the item is smashable, but not a normal smashable.

    float [item] get_smash_yield(item it) : Combines element and tier to give all the expected results of smashing the item (including elemental jewels).

    Keys are not present in maps unless they are actual results.

    Other functions include:
    boolean is_smashable(item it);
    boolean is_malusable(item it);
    boolean smash(int quantity, item it);
    // a wrapper for CLI's "smash" command
    item to_jewel(element el);
    float [string] get_wad_yield(item it, boolean malus);
    float [string] get_wad_yield(int [item] its, boolean malus);
    void print_smash_report(item it);
    void print_smash_report(string it_str);


    For Users:
    Although primarily for scripters, others may like SmashLib as an alternative to the Pulverize Helper for items you don't have at the moment. Create this alias to get a smash report for any item:

    alias sr => ash import <SmashLib.ash> print_smash_report($item[%%]);

    For example, typing sr demonskin jacket in the CLI gives this output:

    Code:
    demonskin jacket
    Tier: 1N
    Elements:
     hot: 0.5
     twinkly: 0.5
    Expected Yields:
     hot nuggets: 0.25
     hot powder: 1.0
     twinkly nuggets: 0.25
     twinkly powder: 1.0
    A call for testing: I'd very much appreciate if one or two people could verify my math in the wads section of get_smash_yield(). Those elemental jewel chances make things fiddly, and I'm not sure I trust my math.

    Version History:
    1.2: added smash(int quantity, item it) function (it just wraps the equivalent cli command)
    1.1: fixed bounds problem in get_smash_tier(); switched from abort() to zlib's vprint(); suggested a better command for the alias
    1.01: changed record holding equipment.txt data; Mafia doesn't like to read in fields that aren't there any more
    Attached Files
    Last edited by aqualectrix; 02-07-2010 at 11:55 PM. Reason: actually update version history

  2. #2
    Senior Member Raven434's Avatar
    Join Date
    May 2007
    Location
    Virginia
    Posts
    461

    Default

    Sweet.

    I was asking about something like this back in the summertime.

    Will definitely check it out.

  3. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    2

    Default

    In the get_smash_tier function, line 270 should be
    Code:
    if (requirement >= 75) return "3W";
    instead of
    Code:
    if (requirement > 75)  return "3W";
    This way, equipment with 75 power like Elmley shades and Energy Drink IV will no longer return a tier of "".

    Same thing for equipment with a power of 180. That should have a tier of "3W", not "".
    Last edited by Quincunx; 12-30-2009 at 05:33 AM.

  4. #4
    Senior Member
    Join Date
    Feb 2009
    Posts
    182

    Default

    Thanks for finding that bug, Quincunx! It should be fixed in 1.1.

  5. #5
    Senior Member Raven434's Avatar
    Join Date
    May 2007
    Location
    Virginia
    Posts
    461

    Default

    Yep - very handy!

    Thanks!

  6. #6
    Senior Member
    Join Date
    Feb 2009
    Posts
    202

    Default

    I just downloaded this script. When I run it, it tells me to me upgrade from version 1.2 to 1.1.

  7. #7
    Senior Member
    Join Date
    Feb 2009
    Posts
    182

    Default

    That's because I'm an idiot, and forgot to update the number in the post. The warning should go away soon.

  8. #8
    Developer
    Join Date
    Nov 2008
    Location
    Paris, France
    Posts
    4,510

    Default

    I saw you load equipment.txt to get the power of items. Why not use get_power()?

  9. #9

    Default

    Could you please create a boolean smash_item( int q , item i ) version of the smash() function that will do nothing but return true when the quantity is zero or negative, similar to the put_closet() and similar functions? Because I've been unexpectedly shafted more than once by how the smash command auto-interprets it.
    I could make a function myself, it would be trivial, but I thought it would be best if SmashLib were to provide this functionality in the first place.

  10. #10
    Developer
    Join Date
    Aug 2009
    Posts
    2,916

    Default

    For future reference (as close to aqua's style as possible):
    PHP Code:
    boolean smash_item(int qitem i);
    ...
    boolean smash_item(int qitem i)
    {
        if(
    q<1) return true;
        return 
    smash(q,i);


Similar Threads

  1. Replies: 0
    Last Post: 09-07-2015, 09:00 PM
  2. 16271: You can walk away from smashing barrels
    By RSS Bot in forum Latest SVN Changes
    Replies: 0
    Last Post: 09-03-2015, 03:26 AM
  3. New Content - Implemented Recognize smashing A Stone Shrine
    By Bale in forum Bug Reports
    Replies: 2
    Last Post: 03-06-2015, 10:23 AM
  4. Replies: 0
    Last Post: 01-13-2014, 04:10 PM
  5. New Content Smashing Pumpkins
    By Veracity in forum Bug Reports
    Replies: 3
    Last Post: 08-20-2012, 11:52 PM

Posting Permissions

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