Effects array and managing songs

relyk

New member
How can you get an array of current effects on your character and does Mafia keep an array of current songs active? As far as I can find, you have to construct the array yourself to parse through, but kolmafia seems to already have an array with the use of "effects" cLI command. The implication is to make room for new songs to avoid the common "too many songs in head" error.
 

me259259

Member
I don't think mafia keeps a list of that. Normally something like that would be in the settings folder, under your character's preferences. I want to say that mafia just looks at the charpane every once in awhile, instead of keeping track of every single effect for you, but I can't say for sure.

I'm currently in a HC path so I can't test it, but I think this might work for you:

PHP:
int [effect] currentATBuffs ;

foreach skill in $skills[]
	{
	if (skill.class == $class[accordion thief] && skill.buff == true) // looks for all AT buffs
		if (have_effect(to_effect(skill) ) > 0 ) // AT skills and effects have the same name, checks to see if you have the effect of the skill the script is looking it
			currentATBuffs [to_effect(skill)] = have_effect(to_effect(skill) ) ; // adds effect to currentATBuffs if you have it, along with how many turns of it you have left
	}
 

slyz

Developer
r11008 adds the int[effect] my_effects() ASH function.

Not the most urgent Mafia update, but it sounded fun. I'll try to think of a good way to check for the number of AT songs from ASH.

EDIT:
Would people prefer a function that gives you the number of AT songs currently active? Or the number of song "slots" that are available? Or both?

int current_songs()
int max_songs()
int possible_songs()

I need help with function names :(
 
Last edited:

Theraze

Active member
I'd probably do the first two. The possible_songs varies based on both equipment and current_songs, so it's more mutable than max_songs.
 

slyz

Developer
But are scripters always going to use check "max_songs() - current_songs()", or are they going to use those functions by themselves too?
 

me259259

Member
But are scripters always going to use check "max_songs() - current_songs()", or are they going to use those functions by themselves too?

I wouldn't mind the shortcut. If you don't mind adding the extra function to mafia... why not?
 

Theraze

Active member
They could use max_songs() to check if they currently have one of the +1 max equipment items already on. I'd have a different set of songs I'd prefer based on how many my max is... if someone got something useless and gave it a ton of turns, they probably wouldn't like me shrugging it off even though it isn't useful for my script. Say, someone using Donho and I've written a nemesis script. Donho is not useful overwater. :) Great if they're using briniest depths for their turn burning between nemesis and final assassin though...

So based on that, I could check what their current max is, then look for if they have anything that can increase it, if I need more spots and they're possible. If they're at their max though, and I can't get them higher, I may abort the script and tell them to shrug something or run it again with a "painful" flag or something similar. :)
 

Fluxxdog

Active member
Code:
int AT_buff_limit(){
	return 3+to_int(boolean_modifier("Four Songs"))+to_int(boolean_modifier("Additional Song"));}
int[effect] active_songs(){ int[effect] a_s;
	foreach stanza,bars in my_effects() if(to_skill(stanza).class==$class[Accordion Thief]) a_s[stanza]=bars;
	return a_s;}
int active_song_count(){ return count(active_songs());}
effect weakest_song(){ effect w_s;
	foreach stanza,bars in active_songs() w_s=(bars<have_effect(w_s) || w_s==$effect[none])? stanza : w_s;
	return w_s;}
void open_song_spot(){ while(active_song_count()>=AT_buff_limit()) cli_execute("uneffect "+weakest_song());}
my_effects() simply replaced another bit of code I had written before that did the exact same thing ^^ I wrote this for casting AT buffs whenever I wanted. It would kill the weakest song until I had enough AT buffs shrugged so I could cast my new buff.
 

ereinion

Member
Hmm, so I was going to use some of these functions in a script I am updating, but with the skill revamp there seems to be other accordion thief buffs which satisfies the conditions in the function "active_songs()".
Code:
[COLOR=olive]> ash import <simple farming>;AT_buff_limit();[/COLOR]

Returned:      4

[COLOR=olive]> ash import <AT_song_support>;active_songs();[/COLOR]

Returned:      aggregate int [effect]
Aloysius' Antiphon of Aptitude => 1442
Fat      Leon's Phat Loot Lyric => 1448
Knowing Smile => 1164
Polka of      Plenty => 391
Ur-Kel's Aria of Annoyance => 1579

[COLOR=olive]>      ash import <AT_song_support>;active_song_count();[/COLOR]

Returned:      5
For knowing smile I can add a check for skills being facial expressions, and dismiss those that are, but then I started wondering about e.g. Moxie of the Mariachi, which I could dismiss by checking for it being a buff, etc.

So I'll probably have a look at what I can do to sort out just the AT songs, but before I put in the work doing that, I just wanted to make sure that I am not overlooking some obvious way to check if a given effect comes from an AT song? Couldn't see anything obvious from examining the proxy fields for $effect or $skill, or by doing a few ashref and prefref searches, but I could of course be missing something.
 

Veracity

Developer
Staff member
effect -> skill: to_skill( effect )
skill is an AT skill: skill.class == $class[ accordion thief ]
skill is a buff: skill.buff == true

> ashq print( "AT = " + ( $skill[ ur-kel's aria of annoyance ].class == $class[ accordion thief ] ) + " buff = " + $skill[ ur-kel's aria of annoyance ].buff )

AT = true buff = true

> ashq print( "AT = " + ( $skill[ knowing smile ].class == $class[ accordion thief ] ) + " buff = " + $skill[ knowing smile ].buff )

AT = true buff = false
Note that we do have skill.song, but that is for skills that have the same semantics as Boris songs: you can have one up, and if you cast another, the first one goes away. "AT songs" are all "buffs"
 

ereinion

Member
Yeah, I derped, it was a problem with all passive AT skills, not just expressions. I changed the function to:
PHP:
int[effect] active_songs(){ int[effect] a_s;
    skill s;
    foreach stanza,bars in my_effects() { s = to_skill(stanza); if(s.class==$class[Accordion Thief] && s.buff) a_s[stanza]=bars; }
    return a_s;}
Now it works as I want it to :) Thanks a lot for your input, though, I did have a look at $skills.songs, but on printing them I saw that they returned Boris songs.
 
Top