List all clubs in inventory

ereinion

Member
I wrote the following snippet to list all the clubs I currently have in my inventory:

Code:
void main() {
    item it;
    buffer it_desc;
    matcher club_matcher;
    string pattern;
    
    pattern = "Type: <b>weapon \\((\\d+-handed) club\\)<\\/b>";
    
    foreach it in get_inventory() {
        if (weapon_type(it) == $stat[muscle]) {
            it_desc = visit_url("desc_item.php?whichitem=" + to_string(it.descid));
            club_matcher = create_matcher(pattern, it_desc);
            if (find(club_matcher)) {
                print (it.name + " - " + group(club_matcher, 1), "green");
            }
        }
    }
}

This works, but I am curious if there is any way to get a list of all available clubs without parsing and searching the descriptions of all the items in my inventory? I assume this information is available to e.g. the modifier-maximizer, since you can specify that you just want to equip clubs there, but I haven't found any way to make this information available to my script.
 

ckb

Minion
Staff member
Code:
foreach it in get_inventory() {
	if (item_type(it)=="club") { print(it); }
}

Also, I find these functions useful:

Code:
boolean IsAccord(item it) {
	return (item_type(it)=="accordion");
}


boolean IsClub(item it) {
	return (item_type(it)=="club");
}
 
Last edited:

lostcalpolydude

Developer
Staff member
I use
Code:
foreach it in get_inventory()
{
	if ( item_type( it ) == "club" && weapon_hands( it ) == 1 )
	{
		print_html( it + ": " + get_power( it ) );
	}
}
Usually I only want 1-handed clubs. I also tend to go with print_html() to avoid cluttering my session log with the script's output.
 

xKiv

Active member
When I know what enchantment I am looking for, I have alias:
Code:
findmoda=> ash foreach it in get_inventory() { int modval = numeric_modifier(it, $string[%%]); if (modval!=0) { print(it + ": " + modval); } }

If you just want "any enchantment" or enumerate all enchantments on an item ... I don't know how.
 

Pazleysox

Member
When I know what enchantment I am looking for, I have alias:
Code:
findmoda=> ash foreach it in get_inventory() { int modval = numeric_modifier(it, $string[%%]); if (modval!=0) { print(it + ": " + modval); } }

If you just want "any enchantment" or enumerate all enchantments on an item ... I don't know how.

I'm looking for the enchantment "Adventures at rollover"
 

xKiv

Active member
Looking at modifiers.txt in mafia source, that's just "Adventures". Inside mafia, you can either check some item you know has the enchantment using string_modifier (item, "Modifiers"), or ... the modtrace command? And there's at least one more command that lists all modifiers that can be associated with something ... modref?.
 

Pazleysox

Member
Using "modtrace adv" would let you know that Adventures is what you want.

Is there a way to pull information from this? I didn't know that you could even do this, it works great for the script I'm writing, but it would be beneficial for me if I could print out the info. Or is there another way of figuring it out?
 

lostcalpolydude

Developer
Staff member
Is there a way to pull information from this? I didn't know that you could even do this, it works great for the script I'm writing, but it would be beneficial for me if I could print out the info. Or is there another way of figuring it out?

You can use "modtrace" to see every modifier available. You can use something after it to filter the options.

If you're asking if there's something available that doesn't require reading and understanding the output, or if you're worried that you won't be able to remember "modtrace", then I don't know if there's anything to help you. Or maybe I don't even understand your question.
 

AlbinoRhino

Active member
PHP:
foreach i in $items[]
{
 if ( numeric_modifier(i, "Adventures") > 0 )
 {
  print(i+" --> "+numeric_modifier(i, "Adventures")+" advs");
 }
}

I'm not sure what you are trying to do either. But, as an example, the above code should print all items in the game that have an "Adventures" modifier, along with how many it gives.
 

Pazleysox

Member
You can use "modtrace" to see every modifier available. You can use something after it to filter the options.

If you're asking if there's something available that doesn't require reading and understanding the output, or if you're worried that you won't be able to remember "modtrace", then I don't know if there's anything to help you. Or maybe I don't even understand your question.

I've put the modtrace into my script so I can see the final output of the rollover bonus turns I will receive. What i was wondering is, is there a way to say for example:

print ("You will get " + adv " bonus turns for rollover");
 

Pazleysox

Member
PHP:
foreach i in $items[]
{
 if ( numeric_modifier(i, "Adventures") > 0 )
 {
  print(i+" --> "+numeric_modifier(i, "Adventures")+" advs");
 }
}

I'm not sure what you are trying to do either. But, as an example, the above code should print all items in the game that have an "Adventures" modifier, along with how many it gives.

Is there a way to find this information for which items are available for use in a "standard" ascension?
 

Pazleysox

Member
Is there a way to find this information for which items are available for use in a "standard" ascension?

I did it a little bit of an old fashioned way. I found the info I needed, and I'm currently working on a script now, with all available rollover items that will work in "Standard" ascensions.
 
Top