ASH maps - Calculations?

muffins

Member
I know a few of you are currently working on equipment maps right now, so maybe you can help... don't worry, I don't need anything nearly as comprehensive as the things you've got!

All I want to do is have a map of one-handed +spell damage weapons, with their values, then, if I just so happen to have more than one in my inventory, it will calculate whichever is best (based on the spell damage value) and equip that one.

So far, all I've been successful with is creating the map and returning the spell damage value of the item with the following code.

Code:
int [item] oneHanded;
oneHanded[$item[star spatula]] = 15;
oneHanded[$item[silver shrimp fork]] = 14;
oneHanded[$item[oversized pizza cutter]] = 13;
oneHanded[$item[chopsticks]] = 12;
oneHanded[$item[iron pasta spoon]] = 10;
oneHanded[$item[huge spoon]] = 10;
oneHanded[$item[Knob Goblin melon baller]] = 8;
oneHanded[$item[filthy pestle]] = 7;
oneHanded[$item[jack flapper]] = 5;
oneHanded[$item[shiny butcherknife]] = 5;
oneHanded[$item[Knob Goblin spatula]] = 4;
oneHanded[$item[gnollish slotted spoon]] = 3;
oneHanded[$item[gnollish pie server]] = 3;
oneHanded[$item[eggbeater]] = 2;
oneHanded[$item[little paper umbrella]] = 1;
oneHanded[$item[corn holder]] = 1;

foreach key in oneHanded {
if(item_amount(key) > 0 && can_equip(key)) {
print("You have and can equip " + oneHanded[key] + ".");
}
}

I'm honestly not even sure if that's the best structure for the map, or if it should be defined with the items and ints switched, and I really have absolutely no clue as to how to go about calculating which is "best", even though I've looked through the wiki, the tutorials on ASH and maps, and searched through tons of threads and scripts on this board. :(

Can anyone at least point me in the right direction of some documentation that might explain how I would go about doing this, or, if one exists and I missed it, an example script that does something similar?
 

Veracity

Developer
Staff member
It looks reasonable. Note that when you do a foreach on a map, you get the items back in whatever internal order the Java implementation of a map stores the keys in. I'd search for the "best" doing something like this:

Code:
item weapon = $item[ none ];
foreach key in oneHanded
    if ( item_amount( key ) > 0 && can_equip( key ) && oneHanded[ key ] > oneHanded[ weapon ] )
        weapon = key;

print( "Best available spell damage weapon: " + weapon );

... which depends on mapping a key that isn't present returning the empty value for the data type stored - 0, for an int. Some might prefer to just keep track of best spell damage in a separate variable as you loop...
 

Nightmist

Member
[quote author=muffins link=topic=790.msg3816#msg3816 date=1172425658]
I'm honestly not even sure if that's the best structure for the map, or if it should be defined with the items and ints switched, and I really have absolutely no clue as to how to go about calculating which is "best", even though I've looked through the wiki, the tutorials on ASH and maps, and searched through tons of threads and scripts on this board. :([/quote]
Hmm in my opinion, DONT use a equipment[ int] map... Why? Because if equipment share the same increase in damage, they have the same int, which means they will result in overwriting eachother.
Eg:
Code:
item [int] oneHanded;
oneHanded[3] = $item[gnollish slotted spoon];
oneHanded[3] = $item[gnollish pie server];
Will result in the first entry, the spoon to be overwritten by the pie server. (Meaning even if you did have a spoon it wouldn't be used) So the current structure is probably the best your going to have with just this simple map. (In terms of keeping it simple, I don't know anything about the way Java//mafia will parse and handle maps so in terms of efficiency I wouldn't know in those terms)
 

Metraxis

Member
My own equipment map is in the repsository in a couple places already. I'll not repost as the current version has maybe 2 more items in it than the last one I did post. Recall that there is a weapon_hands(item) function already, so two maps are not neccessary.
 

muffins

Member
Veracity said:
... which depends on mapping a key that isn't present returning the empty value for the data type stored - 0, for an int. Some might prefer to just keep track of best spell damage in a separate variable as you loop...

What you posted looks close enough to what I'll be needing, thanks! I'm not too sure about how I'd even begin to go about doing what you mentioned right there, though. :p
 
Top