@@ -12438,27 +12438,39 @@ bool is_implicit_argument_provider_op(const int op_const)
12438
12438
// Goober5000
12439
12439
int sexp_functional_if_then_else(int node)
12440
12440
{
12441
- int num1, num2, n;
12442
- bool is_nan, is_nan_forever ;
12441
+ int num1, num2, n = node ;
12442
+ bool is_nan1, is_nan_forever1, is_nan2, is_nan_forever2 ;
12443
12443
12444
- Assertion(CAR(node ) >= 0, "The condition in functional-if-then-else must be an operator!");
12444
+ Assertion(CAR(n ) >= 0, "The condition in functional-if-then-else must be an operator!");
12445
12445
12446
12446
// decision time
12447
- int condition = eval_sexp(CAR(node));
12447
+ int condition = eval_sexp(CAR(n));
12448
+ n = CDR(n);
12448
12449
12449
12450
// we need to evaluate both numbers regardless of which one we pick
12450
- n = CDR(node);
12451
- eval_nums(n, is_nan, is_nan_forever, num1, num2);
12452
- if (is_nan)
12453
- return SEXP_NAN;
12454
- if (is_nan_forever)
12455
- return SEXP_NAN_FOREVER;
12451
+ num1 = eval_num(n, is_nan1, is_nan_forever1);
12452
+ n = CDR(n);
12453
+ num2 = eval_num(n, is_nan2, is_nan_forever2);
12456
12454
12457
12455
// pick one
12458
12456
if (condition == SEXP_TRUE || condition == SEXP_KNOWN_TRUE)
12459
- return num1;
12457
+ {
12458
+ if (is_nan1)
12459
+ return SEXP_NAN;
12460
+ else if (is_nan_forever1)
12461
+ return SEXP_NAN_FOREVER;
12462
+ else
12463
+ return num1;
12464
+ }
12460
12465
else
12461
- return num2;
12466
+ {
12467
+ if (is_nan2)
12468
+ return SEXP_NAN;
12469
+ else if (is_nan_forever2)
12470
+ return SEXP_NAN_FOREVER;
12471
+ else
12472
+ return num2;
12473
+ }
12462
12474
}
12463
12475
12464
12476
// Goober5000
@@ -38052,9 +38064,10 @@ SCP_vector<sexp_help_struct> Sexp_help = {
38052
38064
"\t1:\tName of ship to check (evaluation returns NAN until ship is in-mission)." },
38053
38065
38054
38066
{ OP_HITS_LEFT, "Hits left (Status operator)\r\n"
38055
- "\tReturns the current level of the specified ship's hull as a percentage.\r\n\r\n"
38067
+ "\tReturns the current level of the specified ship's hull as a percentage Note: for ships that have not arrived yet, or have departed, "
38068
+ " or have been destroyed (even if the ship is 'in-mission' but doing a death roll) this returns NaN.\r\n\r\n"
38056
38069
"Returns a numeric value. Takes 1 argument...\r\n"
38057
- "\t1:\tName of ship to check (evaluation returns NAN until ship is in-mission)." },
38070
+ "\t1:\tName of ship to check (evaluation returns NAN unless ship is in-mission and alive )." },
38058
38071
38059
38072
{ OP_HITS_LEFT_SUBSYSTEM, "Hits left subsystem (status operator, deprecated)\r\n"
38060
38073
"\tReturns the current level of the specified ship's subsystem integrity as a percentage of the damage done to *all "
@@ -38064,7 +38077,7 @@ SCP_vector<sexp_help_struct> Sexp_help = {
38064
38077
"this operator is deprecated. Mission designers are strongly encouraged to use hits-left-subsystem-specific rather than "
38065
38078
"the optional boolean parameter.\r\n\r\n"
38066
38079
"Returns a numeric value. Takes 2 or 3 arguments...\r\n"
38067
- "\t1:\tName of ship to check (evaluation returns NAN until ship is in-mission).\r\n"
38080
+ "\t1:\tName of ship to check (evaluation returns NAN unless ship is in-mission and alive ).\r\n"
38068
38081
"\t2:\tName of subsystem on ship to check.\r\n"
38069
38082
"\t3:\t(Optional) True/False. When set to true only the subsystem supplied will be tested; when set to false (the default), "
38070
38083
"all subsystems of that type will be tested." },
@@ -38076,7 +38089,7 @@ SCP_vector<sexp_help_struct> Sexp_help = {
38076
38089
"example, if the integrity of all engine subsystems (that is, the combined strength of all engines divided by the maximum "
38077
38090
"total strength of all engines) is less than 30%, the player cannot warp out.\r\n\r\n"
38078
38091
"Returns a numeric value. Takes 2 arguments...\r\n"
38079
- "\t1:\tName of ship to check (evaluation returns NAN until ship is in-mission)\r\n"
38092
+ "\t1:\tName of ship to check (evaluation returns NAN unless ship is in-mission and alive )\r\n"
38080
38093
"\t2:\tName of subsystem type to check\r\n" },
38081
38094
38082
38095
{ OP_HITS_LEFT_SUBSYSTEM_SPECIFIC, "hits-left-subsystem-specific (status operator)\r\n"
@@ -38086,7 +38099,7 @@ SCP_vector<sexp_help_struct> Sexp_help = {
38086
38099
"and will not appear in the operator list; it can only be used if you type it in manually. Old missions using hits-left-subsystem "
38087
38100
"will still work, but mission designers are strongly encouraged to use the new operators instead.)\r\n\r\n"
38088
38101
"Returns a numeric value. Takes 2 arguments...\r\n"
38089
- "\t1:\tName of ship to check (evaluation returns NAN until ship is in-mission)\r\n"
38102
+ "\t1:\tName of ship to check (evaluation returns NAN unless ship is in-mission and alive )\r\n"
38090
38103
"\t2:\tName of subsystem to check\r\n" },
38091
38104
38092
38105
{ OP_SIM_HITS_LEFT, "Simulated Hits left (Status operator)\r\n"
0 commit comments