Author Topic: [committed] call-ssm-strike SEXP  (Read 3050 times)

0 Members and 2 Guests are viewing this topic.

[committed] call-ssm-strike SEXP
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.7z
Code: [Select]
Index: 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)
« Last Edit: January 13, 2014, 03:14:06 am by X3N0-Life-Form »

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: [patch submission] call-ssm-strike SEXP
I noticed this SEXP in your attempt to re-engineer the WCS code. It's actually one of your own rather than WCS one?
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 
Re: [patch submission] call-ssm-strike SEXP
Yup. My first reverse engineering attempt started at a time where I didn't have Internet access and had only one FSO codebase on my hard drive, so I basically copy-pasted what I had and started reverse engineering from that and didn't bother removing it :) .

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: [patch submission] call-ssm-strike SEXP
The code looks fine to me but I've never used SSM strikes in any of my campaigns so I don't know how to test the SEXP itself. But if you say it works, I'm happy to commit it. :)
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

  
Re: [patch submission] call-ssm-strike SEXP
Well, I've been tinkering with it for a while now, so I think it's robust enough to be committed.

 
Re: [committed] call-ssm-strike SEXP
Patch was committed to trunk by Karajorma in rev 10286.

Yay, I can mod from trunk again \o/

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: [committed] call-ssm-strike SEXP
Yeah, sorry to take so long about committing it.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 
Re: [committed] call-ssm-strike SEXP
No problem mate :) I know all too well how small stuff like that can get delayed for a looong time.

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: [committed] call-ssm-strike SEXP
I'm happy to test this out, since existing methods are indeed, uh, hilariously Rube Goldberg.