Effect from potion

matt.chugg

Moderator
if there a way to get the associated effect of an item, for example

effect_of_item($item[purple snowcone]) == $effect[purple tongue]
 
Mafia simply does not have that information. It does have the opposite: statuseffects.txt may contain a CLI command for obtaining each effect, for example the entry for Purple Tongue contains "use 1 purple snowcone".
 
hmm ok, I suppose I could map that file and check invertedly for "use 1 " + to_string(item it)

maybe! I think that might do what i'm after. thanks!
 
ok, i'm struggling with this, is it actually possible to map the string "use 1" + to_string(item) to the effect, using file_to_map on statuseffects.txt, I'm going round and round in circles I think!
 
Try this:
Code:
record effectentry {
	string name;
	string filename;
	string descid;
	string command;
};
effectentry[int] statuseffects;
file_to_map("statuseffects.txt", statuseffects);

effect[item] item2effect;
matcher cmdparser = create_matcher("(use|chew|eat|drink) (\\d+ )?([^;]+)", "");
foreach id in statuseffects {
	effectentry e = statuseffects[id];
	cmdparser.reset(e.command);
	if (!cmdparser.find()) continue;	// not a recognized command
	item itm = to_item(cmdparser.group(3));
	if (itm == $item[none]) continue;	// failed to parse somehow
	item2effect[itm] = to_effect(e.name);
}

// Testing:
foreach itm in item2effect {
	print(itm + " => " + item2effect[itm]);
}
 
awsome, thank you!

I actually wrote a quick script in .net to parse statuseffects and recreate a new file for me to map, I didn't think it was possible in .ash, thats perfect! thanks again!
 
Back
Top