Feature - Rejected Restore MP up to amount, rather than percentage

Muhandes

Member
This is something that is bugging me for some time now, but I never stopped to suggest it since it seemed to much work.

I usually don't need my MP settings to be up to a percentage, but rather up to a number. For example, I am using Summer Siesta. I always want to have at least 10 MP when I start the fight. Right now I need to do the math and check what percentage it is, and furthermore, it keeps changing.
Or when planning to use olfaction - I want 40 MP and I don't care what the percentage is.

Thanks in advance for considering this feature.
 

Bale

Minion
Write a mood that checks and manually adjusts the percentage.

Save this as restore_mp.ash
Code:
void main(int amount) {
   int percentage = amount / my_maxmp();
   set_property("mpAutoRecovery", percentage);
   if(get_property("mpAutoRecoveryTarget") < percentage)
      set_property("mpAutoRecoveryTarget", percentage);
   if(get_property("manaBurningThreshold") < percentage)
      set_property("manaBurningThreshold", percentage);
}


Use this in your mood. Change 10 to 40 when you're using olfaction.
Trigger On: Unconditional trigger
Check For:
Command: call restore_mp 10
 

Bale

Minion
Yes.

Actually, the code I posted above might be bugged. Use this instead:

Code:
void set_prop(string prop, int setting) {
   if(get_property(prop.to_int() < setting)
      set_property(prop, setting.to_string());
}

void main(int amount) {
   int percentage = amount / my_maxmp();
   set_prop("mpAutoRecovery", percentage);
   set_prop("mpAutoRecoveryTarget"), percentage);
   set_prop("manaBurningThreshold"), percentage);
}
 
Last edited:

Bale

Minion
I don't understand your question. Are you confused about the mood I posted an example of? Do you not know what to do with the script I posted? If you tell me what you did to get it running, then I may be able to tell you what your error was.
 

Muhandes

Member
Just a stupid mistake on my side, forgot the "call".

Anyway, I still didn't manage to get it working. I corrected all the wrong parenthesis, but still it always sets to zero. I figured percentage might be a float rather than an int, but changing it I still get 0.0
I'm not proficient enough with ash to get it further.
 

Bale

Minion
Ick. Yeah. It should be a float. Stupid me. Two integers divided produce an integer even if you want to save it as a float. Use this:

Code:
void set_prop(string prop, float setting) {
   if(get_property(prop.to_float() < setting)
      set_property(prop, setting.to_string());
}

void main(int amount) {
   float percentage = to_float(amount) / my_maxmp();
   set_prop("mpAutoRecovery", percentage);
   set_prop("mpAutoRecoveryTarget"), percentage);
   set_prop("manaBurningThreshold"), percentage);
}
 
Top