Skip to content

Instantly share code, notes, and snippets.

@DamianDominoDavis
Last active September 10, 2021 01:41
Show Gist options
  • Save DamianDominoDavis/34d6acb970b636041396eaf56dd8f716 to your computer and use it in GitHub Desktop.
Save DamianDominoDavis/34d6acb970b636041396eaf56dd8f716 to your computer and use it in GitHub Desktop.
//Renew Effects Before They Expire, for example to preserve your MP cap.
// from in your mood panel, an unconditional trigger can command, for example, "preserve_effect Tomato Power"
// or from CLI as "trigger unconditional, Tomato Power, preserve_effect Tomato Power"
int FWR_THAN = 1;
void preserve_one(effect ef, string cli) {
if (ef.have_effect() <= FWR_THAN) {
cli.cli_execute();
if (ef.have_effect() <= FWR_THAN)
abort('could not preserve effect ' + ef);
}
}
void preserve_one(effect ef) {
ef.preserve_one(ef.default);
}
void main(string eff) {
effect ef;
string[int] mood_parts;
if (eff == 'all_effects') {
foreach i,s in mood_list() {
mood_parts = s.split_string(' ?\\| ?');
ef = mood_parts[1].to_effect();
if (mood_parts[0] == 'lose_effect')
ef.preserve_one(mood_parts[2]);
}
return;
}
ef = eff.to_effect();
if (ef == $effect[none])
abort('what effect is "' + eff + '"?');
ef.preserve_one();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment