View Issue Details

IDProjectCategoryView StatusLast Update
0003018FSSCPscriptingpublic2014-03-15 17:26
ReporterAxem Assigned Tom_m  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Summary0003018: Setting a weapon's Target/HomingObject/HomingPosition etc doesn't work
DescriptionIt looks like the lua functions are missing weapon_set_tracking_info() that's also called in the weapon-create sexp. The lua functions do try to set homing objects and positions, but it doesn't look like its enough to actually get the weapons to home in on new objects.
Steps To ReproduceSo if I were to do this...

    local weapon = mn.createWeapon(tb.WeaponClasses["Drop Pod Effect"], effectOrientation, effectStart)

And then do one of the following...

    weapon.Target = thisObject --This just causes the weapon to fly straight
    weapon.HomingObject = thisObject --Same here
    weapon.HomingPosition = thisObject.Position --and this actually crashes the game!
TagsNo tags attached.

Activities

m_m

2014-03-10 10:04

developer   ~0015646

Good catch with the missing weapon_set_tracking_info(), uploaded patch fixes the issue in my test case, homing position seems to only work if there is actually a homing object so I clarified that in the documentation.
I'm not sure what the differences between the homing object and the target objects are so for now both functions do the same.

m_m

2014-03-10 10:04

developer  

3018.patch (2,038 bytes)   
Index: code/parse/lua.cpp
===================================================================
--- code/parse/lua.cpp	(revision 10481)
+++ code/parse/lua.cpp	(working copy)
@@ -9801,14 +9801,12 @@
 		{
 			if(wp->target_sig != newh->sig)
 			{
-				wp->target_num = OBJ_INDEX(newh->objp);
-				wp->target_sig = newh->sig;
+				weapon_set_tracking_info(OBJ_INDEX(objh->objp), objh->objp->parent, OBJ_INDEX(newh->objp), 1);
 			}
 		}
 		else
 		{
-			wp->target_num = -1;
-			wp->target_sig = 0;
+			weapon_set_tracking_info(OBJ_INDEX(objh->objp), objh->objp->parent, -1);
 		}
 	}
 
@@ -9870,20 +9868,16 @@
 
 	if(ADE_SETTING_VAR)
 	{
-		if(newh != NULL && newh->IsValid())
+		if (newh != NULL && newh->IsValid())
 		{
-			if(wp->target_sig != newh->sig)
+			if (wp->target_sig != newh->sig)
 			{
-				wp->homing_object = newh->objp;
-				wp->homing_pos = newh->objp->pos;
-				wp->homing_subsys = NULL;
+				weapon_set_tracking_info(OBJ_INDEX(objh->objp), objh->objp->parent, OBJ_INDEX(newh->objp), 1);
 			}
 		}
 		else
 		{
-			wp->homing_object = NULL;
-			wp->homing_pos = vmd_zero_vector;
-			wp->homing_subsys = NULL;
+			weapon_set_tracking_info(OBJ_INDEX(objh->objp), objh->objp->parent, -1);
 		}
 	}
 
@@ -9893,7 +9887,8 @@
 		return ade_set_object_with_breed(L, OBJ_INDEX(wp->homing_object));
 }
 
-ADE_VIRTVAR(HomingPosition, l_Weapon, "vector", "Position that weapon will home in on (World vector)", "vector", "Homing point, or null vector if weapon handle is invalid")
+ADE_VIRTVAR(HomingPosition, l_Weapon, "vector", "Position that weapon will home in on (World vector), setting this without a homing object in place will not have any effect!",
+	"vector", "Homing point, or null vector if weapon handle is invalid")
 {
 	object_h *objh;
 	vec3d *v3;
@@ -9913,14 +9908,10 @@
 	{
 		if(v3 != NULL)
 		{
-			wp->homing_object = NULL;
-			wp->homing_subsys = NULL;
 			wp->homing_pos = *v3;
 		}
 		else
 		{
-			wp->homing_object = NULL;
-			wp->homing_subsys = NULL;
 			wp->homing_pos = vmd_zero_vector;
 		}
 	}
3018.patch (2,038 bytes)   

The_E

2014-03-15 17:24

administrator   ~0015660

Patch looks good, ship it.

m_m

2014-03-15 17:26

developer   ~0015661

Fix committed to trunk@10494.

Related Changesets

fs2open: trunk r10494

2014-03-15 12:29

m_m


Ported: N/A

Details Diff
Fix for Mantis 3018: Setting a weapon's Target/HomingObject/HomingPosition etc doesn't work Affected Issues
0003018
mod - /trunk/fs2_open/code/parse/lua.cpp Diff File

Issue History

Date Modified Username Field Change
2014-03-09 19:18 Axem New Issue
2014-03-10 10:04 m_m Note Added: 0015646
2014-03-10 10:04 m_m Assigned To => m_m
2014-03-10 10:04 m_m Status new => code review
2014-03-10 10:04 m_m File Added: 3018.patch
2014-03-15 17:24 The_E Note Added: 0015660
2014-03-15 17:26 m_m Changeset attached => fs2open trunk r10494
2014-03-15 17:26 m_m Note Added: 0015661
2014-03-15 17:26 m_m Status code review => resolved
2014-03-15 17:26 m_m Resolution open => fixed