aqualectrix
Member
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:
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
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
Attachments
Last edited: