@@ -766,7 +766,9 @@ SCP_vector<sexp_oper> Operators = {
766766 { "nebula-change-fog-color", OP_NEBULA_CHANGE_FOG_COLOR, 3, 3, SEXP_ACTION_OPERATOR, }, // Asteroth
767767 { "nebula-change-storm", OP_NEBULA_CHANGE_STORM, 1, 1, SEXP_ACTION_OPERATOR, }, // phreak
768768 { "nebula-toggle-poof", OP_NEBULA_TOGGLE_POOF, 2, 2, SEXP_ACTION_OPERATOR, }, // phreak
769+ { "nebula-set-poofs", OP_NEBULA_SET_POOFS, 1, INT_MAX, SEXP_ACTION_OPERATOR, }, // Goober5000
769770 { "nebula-fade-poof", OP_NEBULA_FADE_POOF, 3, 3, SEXP_ACTION_OPERATOR, }, // MjnMixael
771+ { "nebula-fade-poofs", OP_NEBULA_FADE_POOFS, 2, INT_MAX, SEXP_ACTION_OPERATOR, }, // Goober5000
770772 { "nebula-set-range", OP_NEBULA_SET_RANGE, 1, 1, SEXP_ACTION_OPERATOR, }, // Goober5000
771773 { "volumetrics-toggle", OP_VOLUMETRICS_TOGGLE, 1, 1, SEXP_ACTION_OPERATOR, }, // Lafiel
772774 { "set-skybox-model", OP_SET_SKYBOX_MODEL, 1, 8, SEXP_ACTION_OPERATOR, }, // taylor
@@ -16588,47 +16590,94 @@ void sexp_nebula_change_storm(int n)
1658816590 nebl_set_storm(CTEXT(n));
1658916591}
1659016592
16591- void sexp_nebula_toggle_poof (int n )
16593+ void sexp_nebula_set_poofs (int node, bool legacy )
1659216594{
16593- auto name = CTEXT(n);
16594- bool result = is_sexp_true(CDR(n));
16595- size_t i;
16595+ bool result;
16596+ int n = node;
1659616597
16597- for (i = 0; i < Poof_info.size(); i++)
16598+ // new and legacy sexps have different argument orders
16599+ if (legacy)
16600+ result = is_sexp_true(CDR(n));
16601+ else
1659816602 {
16599- if (!stricmp(name, Poof_info[i].name))
16600- break;
16603+ result = is_sexp_true(n);
16604+ n = CDR(n);
16605+ }
16606+
16607+ // toggle all the poofs
16608+ if (n < 0)
16609+ {
16610+ int count = static_cast<int>(Poof_info.size());
16611+ for (int i = 0; i < count; ++i)
16612+ neb2_toggle_poof(i, result);
1660116613 }
16614+ // toggle the selected poofs
16615+ else
16616+ {
16617+ for (; n >= 0; n = CDR(n))
16618+ {
16619+ auto name = CTEXT(n);
16620+
16621+ int index = find_item_with_string(Poof_info, &poof_info::name, name);
16622+ if (index >= 0)
16623+ neb2_toggle_poof(index, result);
1660216624
16603- //coulnd't find the poof
16604- if (i == Poof_info.size()) return;
16625+ if (legacy)
16626+ break; // the legacy sexp affects only one poof
16627+ }
16628+ }
1660516629
16606- neb2_toggle_poof(static_cast<int>(i), result);
16630+ // do this once at the end of all the toggling
16631+ neb2_toggle_poof_finalize();
1660716632}
1660816633
16609- void sexp_nebula_fade_poofs(int n )
16634+ void sexp_nebula_fade_poofs(int node, bool legacy )
1661016635{
16611- bool is_nan, is_nan_forever;
16612-
16613- auto name = CTEXT(n);
16614- n = CDR(n);
16615- int time = eval_num(n, is_nan, is_nan_forever);
16616- if (is_nan || is_nan_forever)
16617- return;
16618- n = CDR(n);
16619- bool result = is_sexp_true(n);
16620- size_t i;
16636+ bool result, is_nan, is_nan_forever;
16637+ int duration;
16638+ int n = node;
1662116639
16622- for (i = 0; i < Poof_info.size(); i++) {
16623- if (!stricmp(name, Poof_info[i].name))
16624- break;
16640+ // new and legacy sexps have different argument orders
16641+ if (legacy)
16642+ {
16643+ duration = eval_num(CDR(n), is_nan, is_nan_forever);
16644+ if (is_nan || is_nan_forever)
16645+ return;
16646+ result = is_sexp_true(CDDR(n));
16647+ }
16648+ else
16649+ {
16650+ result = is_sexp_true(n);
16651+ n = CDR(n);
16652+
16653+ duration = eval_num(n, is_nan, is_nan_forever);
16654+ if (is_nan || is_nan_forever)
16655+ return;
16656+ n = CDR(n);
1662516657 }
1662616658
16627- // coulnd't find the poof
16628- if (i == Poof_info.size())
16629- return;
16659+ // fade all the poofs
16660+ if (n < 0)
16661+ {
16662+ int count = static_cast<int>(Poof_info.size());
16663+ for (int i = 0; i < count; ++i)
16664+ neb2_fade_poof(i, duration, result);
16665+ }
16666+ // fade the specified poofs
16667+ else
16668+ {
16669+ for (; n >= 0; n = CDR(n))
16670+ {
16671+ auto name = CTEXT(n);
1663016672
16631- neb2_fade_poofs(static_cast<int>(i), time, result);
16673+ int index = find_item_with_string(Poof_info, &poof_info::name, name);
16674+ if (index >= 0)
16675+ neb2_fade_poof(index, duration, result);
16676+
16677+ if (legacy)
16678+ break; // the legacy sexp affects only one poof
16679+ }
16680+ }
1663216681}
1663316682
1663416683void sexp_nebula_change_pattern(int n)
@@ -29017,12 +29066,14 @@ int eval_sexp(int cur_node, int referenced_node)
2901729066 break;
2901829067
2901929068 case OP_NEBULA_TOGGLE_POOF:
29020- sexp_nebula_toggle_poof(node);
29069+ case OP_NEBULA_SET_POOFS:
29070+ sexp_nebula_set_poofs(node, op_num == OP_NEBULA_TOGGLE_POOF);
2902129071 sexp_val = SEXP_TRUE;
2902229072 break;
2902329073
2902429074 case OP_NEBULA_FADE_POOF:
29025- sexp_nebula_fade_poofs(node);
29075+ case OP_NEBULA_FADE_POOFS:
29076+ sexp_nebula_fade_poofs(node, op_num == OP_NEBULA_FADE_POOF);
2902629077 sexp_val = SEXP_TRUE;
2902729078 break;
2902829079
@@ -31513,7 +31564,9 @@ int query_operator_return_type(int op)
3151331564 case OP_REMOVE_SUN_BITMAP:
3151431565 case OP_NEBULA_CHANGE_STORM:
3151531566 case OP_NEBULA_TOGGLE_POOF:
31567+ case OP_NEBULA_SET_POOFS:
3151631568 case OP_NEBULA_FADE_POOF:
31569+ case OP_NEBULA_FADE_POOFS:
3151731570 case OP_NEBULA_CHANGE_PATTERN:
3151831571 case OP_NEBULA_CHANGE_FOG_COLOR:
3151931572 case OP_NEBULA_SET_RANGE:
@@ -34248,6 +34301,12 @@ int query_operator_argument_type(int op, int argnum)
3424834301 else
3424934302 return OPF_BOOL;
3425034303
34304+ case OP_NEBULA_SET_POOFS:
34305+ if (argnum == 0)
34306+ return OPF_BOOL;
34307+ else
34308+ return OPF_NEBULA_POOF;
34309+
3425134310 case OP_NEBULA_FADE_POOF:
3425234311 if (argnum == 0)
3425334312 return OPF_NEBULA_POOF;
@@ -34256,6 +34315,14 @@ int query_operator_argument_type(int op, int argnum)
3425634315 else
3425734316 return OPF_BOOL;
3425834317
34318+ case OP_NEBULA_FADE_POOFS:
34319+ if (argnum == 0)
34320+ return OPF_BOOL;
34321+ else if (argnum == 1)
34322+ return OPF_POSITIVE;
34323+ else
34324+ return OPF_NEBULA_POOF;
34325+
3425934326 case OP_NEBULA_CHANGE_FOG_COLOR:
3426034327 case OP_NEBULA_SET_RANGE:
3426134328 return OPF_POSITIVE;
@@ -36579,7 +36646,9 @@ int get_category(int op_id)
3657936646 case OP_REMOVE_SUN_BITMAP:
3658036647 case OP_NEBULA_CHANGE_STORM:
3658136648 case OP_NEBULA_TOGGLE_POOF:
36649+ case OP_NEBULA_SET_POOFS:
3658236650 case OP_NEBULA_FADE_POOF:
36651+ case OP_NEBULA_FADE_POOFS:
3658336652 case OP_NEBULA_CHANGE_PATTERN:
3658436653 case OP_NEBULA_CHANGE_FOG_COLOR:
3658536654 case OP_NEBULA_SET_RANGE:
@@ -37223,7 +37292,9 @@ int get_subcategory(int op_id)
3722337292 case OP_REMOVE_SUN_BITMAP:
3722437293 case OP_NEBULA_CHANGE_STORM:
3722537294 case OP_NEBULA_TOGGLE_POOF:
37295+ case OP_NEBULA_SET_POOFS:
3722637296 case OP_NEBULA_FADE_POOF:
37297+ case OP_NEBULA_FADE_POOFS:
3722737298 case OP_NEBULA_CHANGE_PATTERN:
3722837299 case OP_NEBULA_CHANGE_FOG_COLOR:
3722937300 case OP_NEBULA_SET_RANGE:
@@ -41979,34 +42050,49 @@ SCP_vector<sexp_help_struct> Sexp_help = {
4197942050 },
4198042051
4198142052 { OP_NEBULA_CHANGE_STORM, "nebula-change-storm\r\n"
41982- "\tChanges the current nebula storm\r\n\r\n"
42053+ "\tChanges the current nebula storm. Has no effect if the nebula is not currently active. \r\n\r\n"
4198342054 "Takes 1 argument...\r\n"
4198442055 "\t1:\tNebula storm to change to\r\n"
4198542056 },
4198642057
41987- { OP_NEBULA_TOGGLE_POOF, "nebula-toggle-poof\r\n"
42058+ { OP_NEBULA_TOGGLE_POOF, "nebula-toggle-poof (deprecated in favor of nebula-set-poofs) \r\n"
4198842059 "\tToggles the state of a nebula poof\r\n\r\n"
4198942060 "Takes 2 arguments...\r\n"
41990- "\t1:\tName of nebula poof to toggle\r\n"
41991- "\t2:\tA True boolean expression will toggle this poof on. A false one will do the opposite."
42061+ "\t1:\tName of the nebula poof to toggle\r\n"
42062+ "\t2:\tA true boolean expression will turn this poof on. A false one will turn this poof off."
42063+ },
42064+
42065+ { OP_NEBULA_SET_POOFS, "nebula-set-poofs\r\n"
42066+ "\tSets the state of one or more nebula poofs\r\n\r\n"
42067+ "Takes 1 or more arguments...\r\n"
42068+ "\t1:\tA true boolean expression will turn the poofs on. A false one will turn them off.\r\n"
42069+ "\tRest:\tName of a nebula poof to set. If no poofs are listed, all tabled poofs will be set.\r\n"
4199242070 },
4199342071
41994- { OP_NEBULA_FADE_POOF, "nebula-fade-poof\r\n"
42072+ { OP_NEBULA_FADE_POOF, "nebula-fade-poof (deprecated in favor of nebula-fade-poofs) \r\n"
4199542073 "\tSets a poof pattern to fade in or out over time\r\n"
4199642074 "Takes 3 arguments...\r\n"
4199742075 "\t1:\tName of the nebula poof to fade\r\n"
4199842076 "\t2:\tTime in milliseconds to fade\r\n"
41999- "\t3:\tWhether or not to fade in or out. True to fade in, false to fade out\r\n"
42077+ "\t3:\tWhether to fade in or out. True to fade in, false to fade out\r\n"
42078+ },
42079+
42080+ { OP_NEBULA_FADE_POOFS, "nebula-fade-poofs\r\n"
42081+ "\tSets one or more poof patterns to fade in or out over time\r\n"
42082+ "Takes 2 or more arguments...\r\n"
42083+ "\t1:\tWhether to fade in or out. True to fade in, false to fade out.\r\n"
42084+ "\t2:\tTime in milliseconds to fade.\r\n"
42085+ "\tRest:\tName of a nebula poof to fade. If no poofs are listed, all tabled poofs will be faded.\r\n"
4200042086 },
4200142087
4200242088 { OP_NEBULA_CHANGE_PATTERN, "nebula-change-pattern\r\n"
42003- "\tChanges the current nebula background pattern (as defined in nebula.tbl)\r\n\r\n"
42089+ "\tChanges the current nebula background pattern (as defined in nebula.tbl). Has no effect if the nebula is not currently active. \r\n\r\n"
4200442090 "Takes 1 argument...\r\n"
4200542091 "\t1:\tNebula background pattern to change to\r\n"
4200642092 },
4200742093
4200842094 { OP_NEBULA_CHANGE_FOG_COLOR, "nebula-change-fog-color\r\n"
42009- "\tChanges the current nebula fog color\r\n\r\n"
42095+ "\tChanges the current nebula fog color. Has no effect if the nebula is not currently active. \r\n\r\n"
4201042096 "Takes 3 arguments...\r\n"
4201142097 "\t1:\tRed (0 - 255)\r\n"
4201242098 "\t2:\tGreen (0 - 255)\r\n"
0 commit comments