EDIT - patch committed to trunk
I've always found current ways to call ssm strikes through SEXPs to be a bit cumbersome, so I wrote a straight-forward easy-to-use SEXP in an attempt to make things slightly easier.
Calls a subspace missile strike on the specified ship.
Takes 3 arguments...
1: Strike index. (from ssm.tbl)
2: Calling team.(friendly, hostile, etc.)
Rest: List of ships the strike will be called on.
Thoughts?
The following .7z archive contains:
- a patch file
- a pair of release and debug build
- a small mod using retail assets and a single test mission
http://www.mediafire.com/download/c9sb65n2q4mv1t4/call-ssm-strike.7zIndex: code/parse/sexp.cpp
===================================================================
--- code/parse/sexp.cpp (revision 10168)
+++ code/parse/sexp.cpp (working copy)
@@ -657,6 +657,7 @@
{ "remove-weapons", OP_REMOVE_WEAPONS, 0, 1, SEXP_ACTION_OPERATOR, }, // Karajorma
{ "set-time-compression", OP_CUTSCENES_SET_TIME_COMPRESSION, 1, 3, SEXP_ACTION_OPERATOR, },
{ "reset-time-compression", OP_CUTSCENES_RESET_TIME_COMPRESSION, 0, 0, SEXP_ACTION_OPERATOR, },
+ { "call-ssm-strike", OP_CALL_SSM_STRIKE, 3, INT_MAX, SEXP_ACTION_OPERATOR, }, // X3N0-Life-Form
//Variable Category
{ "modify-variable", OP_MODIFY_VARIABLE, 2, 2, SEXP_ACTION_OPERATOR, },
@@ -21529,6 +21530,26 @@
}
}
+void sexp_call_ssm_strike(int node) {
+ int ssm_index = eval_num(node);
+ node = CDR(node);
+ int calling_team = iff_lookup(CTEXT(node));
+ if (ssm_index < 0 || calling_team < 0)
+ return;
+
+ for (int n = node; n != -1; n = CDR(n)) {
+ int ship_num = ship_name_lookup(CTEXT(n));
+ // don't do anything if the ship isn't there
+ if (ship_num >= 0) {
+ int obj_num = Ships[ship_num].objnum;
+ object *target_ship = &Objects[obj_num];
+ vec3d *start = &target_ship->pos;
+
+ ssm_create(target_ship, start, ssm_index, NULL, calling_team);
+ }
+ }
+}
+
extern int Cheats_enabled;
int sexp_player_is_cheating_bastard() {
if (Cheats_enabled) {
@@ -23943,6 +23964,11 @@
sexp_change_team_color(node);
break;
+ case OP_CALL_SSM_STRIKE:
+ sexp_val = SEXP_TRUE;
+ sexp_call_ssm_strike(node);
+ break;
+
case OP_PLAYER_IS_CHEATING_BASTARD:
sexp_val = sexp_player_is_cheating_bastard();
break;
@@ -24934,6 +24960,7 @@
case OP_COPY_VARIABLE_FROM_INDEX:
case OP_COPY_VARIABLE_BETWEEN_INDEXES:
case OP_SET_ETS_VALUES:
+ case OP_CALL_SSM_STRIKE:
return OPR_NULL;
case OP_AI_CHASE:
@@ -25875,6 +25902,14 @@
else
return OPF_SHIP;
+ case OP_CALL_SSM_STRIKE:
+ if (argnum == 0)
+ return OPF_NUMBER;
+ else if (argnum == 1)
+ return OPF_IFF;
+ else
+ return OPF_SHIP;
+
case OP_SELF_DESTRUCT:
return OPF_SHIP;
@@ -28637,6 +28672,7 @@
case OP_REMOVE_WEAPONS:
case OP_CUTSCENES_SET_TIME_COMPRESSION:
case OP_CUTSCENES_RESET_TIME_COMPRESSION:
+ case OP_CALL_SSM_STRIKE:
return CHANGE_SUBCATEGORY_SPECIAL_EFFECTS;
case OP_MODIFY_VARIABLE:
@@ -32344,6 +32380,15 @@
"\t3:\tRest: List of ships this sexp will operate on."
},
+ {OP_CALL_SSM_STRIKE, "call-ssm-strike\r\n"
+ "\tCalls a subspace missile strike on the specified ship.\r\n"
+ "\tRequires a ssm table (ssm.tbl).\r\n"
+ "Takes 3 arguments...\r\n"
+ "\t1:\tStrike index.\r\n"
+ "\t2:\tCalling team.\r\n"
+ "\tRest:\tList of ships the strike will be called on."
+ },
+
{OP_PLAYER_IS_CHEATING_BASTARD, "player-is-cheating\r\n"
"\tReturns true if the player is or has been cheating in this mission.\r\n"
}
Index: code/parse/sexp.h
===================================================================
--- code/parse/sexp.h (revision 10168)
+++ code/parse/sexp.h (working copy)
@@ -717,6 +717,7 @@
#define OP_COPY_VARIABLE_BETWEEN_INDEXES (0x0021 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // Goober5000
#define OP_GET_ETS_VALUE (0x0022 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // niffiwan
#define OP_SET_ETS_VALUES (0x0023 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // niffiwan
+#define OP_CALL_SSM_STRIKE (0x0024 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // X3N0-Life-Form
// defined for AI goals
#define OP_AI_CHASE (0x0000 | OP_CATEGORY_AI | OP_NONCAMPAIGN_FLAG)