Page 1 of 1

sysCreateWeaonFire premature expolosions

Posted: Thu May 28, 2009 2:51 am
by Bobby
I have code designed to launch a missile from the cargo hold at the current target, unfortunately, when a fragmenting missile is used, they detonate immediately. I have set the condition to ignore failsafes to both "true" and "false", but they explode immediately.

also, missiles don't fragment on direct hits, but that's a different topic completely.

here's the important bit, the rest is devoted to deciding what to do.

Code: Select all

	(block Nil
		(sysCreateWeaponFire (objGetData gSource "sweapon") gSource (objGetPos gSource) (intVectorAngle gSource (objGetTarget gSource)) 40 (objGetTarget gSource) False)
		(objRemoveItem gSource (itmCreate (objGetData gSource "sweapon") 1) 1)
	)
where the data in "sweapon" is the unid for a fragmentation missile and intVectorAngle finds the direction to the target.

Re: sysCreateWeaonFire premature expolosions

Posted: Thu May 28, 2009 5:21 am
by alterecco
Bobby wrote:unfortunately, when a fragmenting missile is used, they detonate immediately.
Does this only happen with fragmenting missiles?

Posted: Thu May 28, 2009 7:40 am
by Prophet
My "Capship Weapons mod" has an auton firing a fragmenting missile with sysCreateWeaponsFire and I did not have a problem with premature fragmentation (snicker)

Perhaps it is due to setting the point of origin as (objGetPos gSource) and it's hitting the ship it's installed on? try setting it to (sysVectorPolarOffset gSource (shpGetDirection gSource) 5) to have it created just infront. I was calling the missile from a small ship and had no problems.

Posted: Thu May 28, 2009 8:24 pm
by Bobby
well, I tried the offset and no dice, they still detonate immediately, and it throws off the aim, additionaly i know it's not hitting the ship because it doesn't damage me, and trackers track the target.

and yes, only the fragmenters detonate, the others, like longbows and quantumsphere shells operate as desired.

Posted: Fri May 29, 2009 3:08 am
by george moromisato
I think the problem might be with the last parameter to (sysCreateWeaponFire)

You passed in 'False'. But 'False' is not a valid identifier. You should pass in Nil (or simply omit the last parameter).

Try that and see if it helps.

Posted: Fri May 29, 2009 3:13 am
by Bobby
it worked, thanks!

Posted: Fri May 29, 2009 11:54 am
by digdug
i know it's not hitting the ship because it doesn't damage me
One little additional note, that might not be true.
All the fragments do NOT damage the source ship unless canHitSource= "true" is put in the fragment.