2018-06-19 18:33 EDT


View Issue Details Jump to Notes ] Related Changesets ]
IDProjectCategoryView StatusLast Update
0003018FSSCPscriptingpublic2014-03-15 13:26
ReporterAxem 
Assigned Tom_m 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
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.
Attached Files
  • patch file icon 3018.patch (2,038 bytes) 2014-03-10 06:04 -
    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;
     		}
     	}
    
    patch file icon 3018.patch (2,038 bytes) 2014-03-10 06:04 +

-Relationships
+Relationships

-Notes

~0015646

m_m (developer)

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.

~0015660

The_E (administrator)

Patch looks good, ship it.

~0015661

m_m (developer)

Fix committed to trunk@10494.
+Notes

+Related Changesets

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