|
39 | 39 | #include "object/objectsnd.h" |
40 | 40 | #include "parse/parselo.h" |
41 | 41 | #include "scripting/scripting.h" |
| 42 | +#include "scripting/api/objs/subsystem.h" |
42 | 43 | #include "playerman/player.h" |
43 | 44 | #include "popup/popup.h" |
44 | 45 | #include "render/3d.h" |
@@ -113,7 +114,7 @@ void do_subobj_destroyed_stuff( ship *ship_p, ship_subsys *subsys, vec3d* hitpos |
113 | 114 | object *ship_objp; |
114 | 115 | model_subsystem *psub; |
115 | 116 | vec3d g_subobj_pos; |
116 | | - int type, i, subsystem_index, log_index; |
| 117 | + int type, i, log_index; |
117 | 118 |
|
118 | 119 | // get some local variables |
119 | 120 | sip = &Ship_info[ship_p->ship_info_index]; |
@@ -217,6 +218,7 @@ void do_subobj_destroyed_stuff( ship *ship_p, ship_subsys *subsys, vec3d* hitpos |
217 | 218 | Assert( ship_p->ship_info_index < 65535 ); |
218 | 219 |
|
219 | 220 | // get the "index" of this subsystem in the ship info structure. |
| 221 | + int subsystem_index; |
220 | 222 | for (subsystem_index = 0; subsystem_index < sip->n_subsystems; ++subsystem_index ) { |
221 | 223 | if ( &(sip->subsystems[subsystem_index]) == psub ) |
222 | 224 | break; |
@@ -271,11 +273,9 @@ void do_subobj_destroyed_stuff( ship *ship_p, ship_subsys *subsys, vec3d* hitpos |
271 | 273 |
|
272 | 274 | // call a scripting hook for the subsystem (regardless of whether it's added to the mission log) |
273 | 275 | Script_system.SetHookObject("Ship", ship_objp); |
274 | | - Script_system.SetHookVar("SubsysName", 's', psub->name); |
275 | | - Script_system.SetHookVar("SubobjName", 's', psub->subobj_name); |
276 | | - Script_system.SetHookVar("SubsysIndex", 'i', subsystem_index); |
| 276 | + Script_system.SetHookVar("Subsystem", 'o', scripting::api::l_Subsystem.Set(scripting::api::ship_subsys_h(ship_objp, subsys))); |
277 | 277 | Script_system.RunCondition(CHA_ONSUBSYSDEATH, ship_objp); |
278 | | - Script_system.RemHookVars(4, "Ship", "SubsysName", "SubobjName", "SubsysIndex"); |
| 278 | + Script_system.RemHookVars(2, "Ship", "Subsystem"); |
279 | 279 |
|
280 | 280 | if ( psub->subobj_num > -1 ) { |
281 | 281 | shipfx_blow_off_subsystem(ship_objp,ship_p,subsys,&g_subobj_pos,no_explosion); |
|
0 commit comments