From 7b410b2116f3dafa6bd9327a019d25e4673d61a7 Mon Sep 17 00:00:00 2001 From: Goober5000 Date: Wed, 20 Sep 2023 23:22:32 -0400 Subject: [PATCH] some fixes for setting HomingSubsystem in script 1. Allow setting the homing subsystem if the homing object has already been set 2. Use the `weapon_set_tracking_info` function if setting both object and subsystem, as it handles several important homing things --- code/scripting/api/objs/weapon.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/code/scripting/api/objs/weapon.cpp b/code/scripting/api/objs/weapon.cpp index e5f57607d1a..25a7a3cedfd 100644 --- a/code/scripting/api/objs/weapon.cpp +++ b/code/scripting/api/objs/weapon.cpp @@ -263,16 +263,17 @@ ADE_VIRTVAR(HomingSubsystem, l_Weapon, "subsystem", "Subsystem that weapon will { if(wp->target_sig != newh->sig) { - wp->homing_object = newh->objp; + weapon_set_tracking_info(OBJ_INDEX(objh->objp), objh->objp->parent, OBJ_INDEX(newh->objp), 1, newh->ss); + } + else + { wp->homing_subsys = newh->ss; get_subsystem_pos(&wp->homing_pos, wp->homing_object, wp->homing_subsys); } } else { - wp->homing_object = &obj_used_list; - wp->homing_pos = vmd_zero_vector; - wp->homing_subsys = NULL; + weapon_set_tracking_info(OBJ_INDEX(objh->objp), objh->objp->parent, -1); } // need to update the position for multiplayer.