@@ -2409,7 +2409,8 @@ int parse_create_object_sub(p_object *p_objp)
24092409 }
24102410 }
24112411
2412- if (Game_mode & GM_IN_MISSION) {
2412+ // If the ship is in a wing, this will be done in mission_set_wing_arrival_location() instead
2413+ if (Game_mode & GM_IN_MISSION && shipp->wingnum == -1 ) {
24132414 if (anchor_objnum >= 0 )
24142415 Script_system.SetHookObjects (2 , " Ship" , &Objects[objnum], " Parent" , &Objects[anchor_objnum]);
24152416 else
@@ -6026,6 +6027,7 @@ void mission_parse_close()
60266027void mission_set_wing_arrival_location ( wing *wingp, int num_to_set )
60276028{
60286029 int index;
6030+ int anchor_objnum = -1 ;
60296031
60306032 // get the starting index into the ship_index array of the first ship whose location we need set.
60316033
@@ -6035,7 +6037,7 @@ void mission_set_wing_arrival_location( wing *wingp, int num_to_set )
60356037 object *objp;
60366038
60376039 objp = &Objects[Ships[wingp->ship_index [index]].objnum ];
6038- mission_set_arrival_location (wingp->arrival_anchor , wingp->arrival_location , wingp->arrival_distance , OBJ_INDEX (objp), wingp->arrival_path_mask , NULL , NULL );
6040+ anchor_objnum = mission_set_arrival_location (wingp->arrival_anchor , wingp->arrival_location , wingp->arrival_distance , OBJ_INDEX (objp), wingp->arrival_path_mask , NULL , NULL );
60396041
60406042 index++;
60416043 }
@@ -6049,7 +6051,8 @@ void mission_set_wing_arrival_location( wing *wingp, int num_to_set )
60496051 // or in front of some other ship.
60506052 index = wingp->current_count - num_to_set;
60516053 leader_objp = &Objects[Ships[wingp->ship_index [index]].objnum ];
6052- if (mission_set_arrival_location (wingp->arrival_anchor , wingp->arrival_location , wingp->arrival_distance , OBJ_INDEX (leader_objp), wingp->arrival_path_mask , &pos, &orient) != -1 ) {
6054+ anchor_objnum = mission_set_arrival_location (wingp->arrival_anchor , wingp->arrival_location , wingp->arrival_distance , OBJ_INDEX (leader_objp), wingp->arrival_path_mask , &pos, &orient);
6055+ if (anchor_objnum != -1 ) {
60536056 // modify the remaining ships created
60546057 index++;
60556058 wing_index = 1 ;
@@ -6068,10 +6071,21 @@ void mission_set_wing_arrival_location( wing *wingp, int num_to_set )
60686071 }
60696072 }
60706073
6071- // create warp effect if in mission and not arriving from docking bay
6072- if ( (Game_mode & GM_IN_MISSION) && (wingp->arrival_location != ARRIVE_FROM_DOCK_BAY) ) {
6074+ if (Game_mode & GM_IN_MISSION) {
60736075 for ( index = wingp->current_count - num_to_set; index < wingp->current_count ; index ++ ) {
6074- shipfx_warpin_start ( &Objects[Ships[wingp->ship_index [index]].objnum ] );
6076+ object *objp = &Objects[Ships[wingp->ship_index [index]].objnum ];
6077+
6078+ if (anchor_objnum >= 0 )
6079+ Script_system.SetHookObjects (2 , " Ship" , objp, " Parent" , &Objects[anchor_objnum]);
6080+ else
6081+ Script_system.SetHookObjects (2 , " Ship" , objp, " Parent" , NULL );
6082+
6083+ Script_system.RunCondition (CHA_ONSHIPARRIVE, 0 , NULL , objp);
6084+ Script_system.RemHookVars (2 , " Ship" , " Parent" );
6085+
6086+ if (wingp->arrival_location != ARRIVE_FROM_DOCK_BAY) {
6087+ shipfx_warpin_start (objp);
6088+ }
60756089 }
60766090 }
60776091}
0 commit comments