Recently I decided to make my Mortar script a little better by adding a mortar tube that would face the direction of the fire mission and fire *blank* rounds to simulate a real mortar tube.
In order to get the mortar to fire, I try to set up an invisible H (named IRTARGET) just a few hundred meters in front of the Mortar (FSO). Since my mortar is already facing the direction of the fire mission, I use sin and cos, but I either am using them wrong, or my syntax is wrong.
Here's the script. The problem line is marked:
;MFireAction request HE
player removeaction MSmokeaction
player removeaction MFlareaction
player removeaction Millumaction
player removeaction MFireaction
player removeaction MFFEaction
player removeaction MAdjustaction
player removeaction MEndaction
Player Globalradio "HEReqruest"
?(MortarHE <= 0):goto "Skip"
FSO doWatch getmarkerPos Firemarker
_ifdir= getDir FSO
;here's the problem
IFTarget setPos [ getpos FSO select 0 + 200 * sin _ifDir, FSO select 1 + 200 * cos _ifDir, FSO select 2 + 200]
_dist= FSO distance IFTarget
FSO doTarget IFTarget
FSO Globalradio "XShot"
FSO doFire ObjNull
_delay = _dist / 10
~_delay
FSO Globalradio "XSplash"
_dir = random 360
_dis = random 9
_Xx = Firex + sin (_dir) * _dis
_Yy = Firey + cos (_dir) * _dis
"MortarShell" createVehicle [_Xx, _Yy, 50]
_delay = random 5
_delay = _delay + 5
~_delay
MortarHe = MortarHe - 1
#TheEnd
MSmokeaction = player addAction ["Smoke Round", "FSO\Mortar\Smoke.sqs"]
MFlareaction = player addAction ["Flare", "FSO\Mortar\Flare.sqs"]
MIllumaction = player addAction ["Illuminate", "FSO\Mortar\Illuminate.sqs"]
MFireaction = player addAction ["Fire HE", "FSO\Mortar\Fire.sqs"]
MFFEaction = player addAction ["Fire For Effect", "FSO\Mortar\FFE.sqs"]
MAdjustaction = player addAction ["Adjust Fire", "FSO\Mortar\Adjust.sqs"]
MEndaction = player addAction ["End Mission", "FSO\Mortar\End.sqs"]
exit
#Skip
FSO sidechat "No more rounds left, over."
goto "TheEnd"