major woody 11 Posted March 23, 2007 I've found this old artilleryscript on ofpedc looong time ago (Before the big server crash). IMHO this is the best artillery script next to CoC UA. Would anybody be so kind helping me to convert this into ArmA? ArtilleryCommand.sqs Quote[/b] ]; [_option] Exec "ArtilleryCommand.sqs" ; Provides radio menu and relevant globals for use with "FireArtillery.sqs" ; direct fire artillery script. ; - To use this, create eight triggers for eight radio channels in the mission. ;  The OnActivation box for each trigger should have ;  [<1-8>] Exec "ArtilleryCommand.sqs" where the number corresponds to the ;  number of the radio channel. ; - Use the radio from the map screen for easiest use. ; - The targeting menu accepts X and Y grid coordinates. The number after ;  the decimal point is in tenths of a 128 m x 128 m grid square, e.g. ;  EG.5 43.5 is the center of grid square EG,43. The +/- buttons increment ;  in larger steps when clicking fast. ; - Select "Prep" to switch to the fire menu. ; - "Fire1" fires one round for adjustment purposes. ; - The EL+/EL- adjusts the barrel elevation in 0.05 deg increments. Higher barrel ;  elevation increases range. (M60 can't get high enough for lofted trajectories.) ; - "Fire for effect" lets loose with everything until "Cease fire" is selected ;  or the tanks run out of ammo. This currently uses 4 M60's which must be ;  named Art1, Art2, Art3, Art4 in the mission. ; - A player object named Spotter is used to initialize the grid coordinates ; ;  Foster NOV 2001 _option = _this Select 0 _charvect = ["A","B","C","D","E","F"," ;G","H","I","J"] _time = (DayTime)*3600 _artillerylist = [Art1,Art2,Art3,Art4] _nartillery = Count _artillerylist _artlead = _artillerylist Select 0 ? (_option == 0) : Goto "Case0" ? (_time - lasttime > 0.25) : _deltaxy = 12.8 ? (_time - lasttime <= 0.25) : _deltaxy = 128 ? (radiomenu==1) : _option = _option + 8 ? (_option == 1) : Goto "Case1" ? (_option == 2) : Goto "Case2" ? (_option == 3) : Goto "Case3" ? (_option == 4) : Goto "Case4" ? (_option == 5) : Goto "Case5" ? (_option == 6) : Goto "Case6" ? (_option == 7) : Goto "Case7" ? (_option == 8) : Goto "AllDone" ? (_option == 9) : Goto "Case9" ? (_option == 10) : Goto "Case10" ? (_option == 11) : Goto "Case11" ? (_option == 12) : Goto "Case12" ? (_option == 13) : Goto "Case13" ? (_option == 14) : Goto "Case14" ? (_option == 15) : Goto "Case15" ? (_option == 16) : Goto "Case16" Goto "AllDone" ;------------------------------------------------------------ #Case0 ; Initialization targetx = (GetPos Spotter) Select 0 targety = (GetPos Spotter) Select 1 elcomp = 0 xcomp = 0 ycomp = 0 targetheight = 50 targetpattern = 0 targetradius = 5 radiomenu = 0 fireoption = 0 Goto "UpdateRadio" ;------------------------------------------------------------ #Case1 Me Say "FFF22" targetx = targetx + _deltaxy Goto "UpdateRadio" ;------------------------------------------------------------ #Case2 targetx = targetx - _deltaxy Goto "UpdateRadio" ;------------------------------------------------------------ #Case3 targety = targety - _deltaxy Goto "UpdateRadio" ;------------------------------------------------------------ #Case4 targety = targety + _deltaxy Goto "UpdateRadio" ;------------------------------------------------------------ #Case5 targetheight = targetheight + 1 Goto "UpdateRadio" ;------------------------------------------------------------ #Case6 targetheight = targetheight - 1 Goto "UpdateRadio" ;------------------------------------------------------------ #Case7 radiomenu = 1 Goto "UpdateRadio" ;------------------------------------------------------------ #Case9 xcomp = xcomp + 5 Goto "UpdateRadio" ;------------------------------------------------------------ #Case10 xcomp = xcomp - 5 Goto "UpdateRadio" ;------------------------------------------------------------ #Case11 ycomp = ycomp + 5 Goto "UpdateRadio" ;------------------------------------------------------------ #Case12 ycomp = ycomp - 5 Goto "UpdateRadio" ;------------------------------------------------------------ #Case13 [_artlead,[targetx,targety,targetheight],2] Exec "FireArtillery.sqs" _artlead SideRadio "firingone" ~1 Goto "UpdateRadio" ;------------------------------------------------------------ #Case14 ? (fireoption == 0) : Goto "FFE" #CeaseFire fireoption = 0 _artlead SideRadio "ceasingfire" ~1 Goto "UpdateRadio" #FFE fireoption = 1 ; lead artillery takes calibrated target, others spread [_artlead,[targetx,targety,targetheight],1] Exec "FireArtillery.sqs" _loopind = 1 #loopstart ? (_loopind > _nartillery - 1) : Goto "loopdone" _dx = targetradius*cos(360*_loopind/(_nartillery-1)) _dy = targetradius*sin(360*_loopind/(_nartillery-1)) _arti = _artillerylist Select _loopind [_arti,[targetx+_dx,targety+_dy,targetheight],0] Exec "FireArtillery.sqs" _loopind = _loopind + 1 Goto "loopstart" #loopdone _artlead SideRadio "firingforeffect" ~1 Goto "UpdateRadio" ;------------------------------------------------------------ #Case15 ? (targetpattern == 0) : Goto "pwide" #pnarrow targetpattern = 0 targetradius = 5 Goto "UpdateRadio" #pwide targetpattern = 1 targetradius = 40 Goto "UpdateRadio" ;------------------------------------------------------------ #Case16 radiomenu = 0 elcomp = 0 fireoption = 0 Goto "UpdateRadio" ;------------------------------------------------------------ #UpdateRadio _returnlabel = "Ret1" Goto "GridCalc" #Ret1 ? (radiomenu == 1) : Goto "FireMenu" #TargetMenu 1 SetRadioMsg "  X+" 2 SetRadioMsg "  X-" 3 SetRadioMsg "  Y+" 4 SetRadioMsg "  Y-" 5 SetRadioMsg "  Height+" 6 SetRadioMsg "  Height-" 7 SetRadioMsg Format ["Prep %1%2.%3 %4%5.%6 H %7",_xc1,_xc2,_xc3,_yc1,_yc2,_yc3,targetheight] 8 SetRadioMsg "---" Goto "AllDone" #FireMenu 1 SetRadioMsg "  Correct East" 2 SetRadioMsg "  Correct West" 3 SetRadioMsg "  Correct North" 4 SetRadioMsg "  Correct South" 5 SetRadioMsg Format ["Fire1 %1%2.%3 %4%5.%6 H %7 E %8 N %9 ",_xc1,_xc2,_xc3,_yc1,_yc2,_yc3,targetheight,xcomp,ycomp] ? (fireoption == 0) : 6 SetRadioMsg Format ["Fire for effect"] ? (fireoption != 0) : 6 SetRadioMsg Format ["Cease fire"] ? (targetpattern == 0) : 7 SetRadioMsg "Set pattern wide" ? (targetpattern != 0) : 7 SetRadioMsg "Set pattern tight" 8 SetRadioMsg "Clear target" Goto "AllDone" ;------------------------------------------------------------ #AllDone lasttime = _time exit #GridCalc _xc1 = (targetx / 1280) _xc1 = _xc1 - (_xc1 % 1) _xc1 = _charvect Select _xc1 _xc2 = (targetx % 1280) / 128 _xc2 = _xc2 - (_xc2 % 1) _xc2 = _charvect Select _xc2 _xc3 = (targetx % 128) / 12.8 _xc3 = _xc3 - (_xc3 % 1) _yc1 = (12800 - targety) / 1280 _yc1 = _yc1 - (_yc1 % 1) _yc2 = ((12800 - targety) % 1280) / 128 _yc2 = _yc2 - (_yc2 % 1) _yc3 = ((12800 - targety) % 128) / 12.8 _yc3 = _yc3 - (_yc3 % 1) Goto _returnlabel FireArtillery.sqs Quote[/b] ]; [_artillery,_datum,_verb] Exec "FireArtillery.sqs" ; Direct fire artillery script using M60 tank ; ; Notes ; - Started with the "Direct Fire Mission Simulator" scripts by "Marlboro" ; - Includes geometric method for terrain altitude calculation using a ;  sea-level marker placed in the mission. This is also used to set the dummy ;  target elevation in a way that isn't as sensitive to the flatness of the ;  local terrain. Target object is used to call the Distance function then ;  Watch is used with a position argument to set the barrel elevation. ; - Uses linearly interpolated el-range points to set gun elevation. A height ;  adjustment is factored in assuming a 45 degree final trajectory. I tried ;  to fit a number of ballistic models to the data without any real success, ;  first and second order drag models didn't work well. The ideal no drag ;  r = v^2/g*sin(2*el) is too optimistic. Best accuracy is between 3 and 4 km. ;  For shorter distances the trajectory is too shallow to predict range ;  accurately with this method. A modified vehicle with greater max gun elevation ;  could be used for more accurate short range lofted trajectories. Or perhaps ;  a shell with more drag or less mass. ; - Use with the "ArtilleryCommand.sqs" script, to enter target location in map ;  grid notation and zero-in on target before firing for effect. ; ;  Foster NOV 2001 ; ------------------------------------------------------------------------------ ; _artillery is the M60 tank object to act as artillery ; _datum is an [x,y,z] position vector for the target _artillery = _this Select 0 _datum = _this Select 1 _verb = _this Select 2 ; Check to see if artillery is occupied ? ((CombatMode _artillery) == "BLUE") : Goto "AbortBlue" _pos = GetPos _artillery _posx = _pos Select 0 _posy = _pos Select 1 _posz = _pos Select 2 _artillery SetBehaviour "COMBAT" _artillery SetCombatMode "BLUE" _artillery DisableAI "Move" ; create dummy target, start in water for terrain height calc _target = "Radio" CamCreate [0,0,0] ~4 _posdatx = (_datum Select 0) + xcomp _posdaty = (_datum Select 1) + ycomp _posdatz = _datum Select 2 ~2 ; ------------------------------------------- ; Calculate terrain height for artillery location ; I do this geometrically using a sea-level marker to move the radio ; target for lack of a better method. Accuracy is affected by the ; distance between the sea-level marker and artillery. The height ; returned is 2-3 m higher than terrain height due to the unit height ; of the M60. _posSL = GetMarkerPos "SeaLevel" _posSLx = _posSL Select 0 _posSLy = _posSL Select 1 _target SetPos _posSL _dx = (_posx - _posSLx) _dy = (_posy - _posSLy) _rangetest = _artillery Distance _target _zart = sqrt(_rangetest^2 - _dx^2 - _dy^2) _zdiff = _posdatz - _zart ? (_verb > 1) : _artillery SideChat Format ["Artillery height ASL %1 m (diff %2)",_zart,_zdiff] ;_artillery SideChat Format ["Target height (estimated) ASL %1 m",_posdatz] ;_artillery SideChat Format ["Differential height %1 m",_zdiff] ; ------------------------------------------- _dx = (_posdatx - _posx) _dy = (_posdaty - _posy) _rangedatum = sqrt(_dx^2 + _dy^2) ? (_verb > 0) : _artillery SideChat Format ["Range (slant) to target %1 m",_rangedatum] ~2 ; ------------------------------------------- ; Linearly interpolate to find approx gun el ;            x   x   x   x   x   x    x   x    x _elvect = [2.0,  2.4, 2.43, 3.35, 4.20, 5.33, 5.89, 6.37,  7.0, 10.83, 13.1] _rvect = [2000, 2500, 2900, 3140, 3320, 3585, 3700, 3790, 3900,  4300, 4450] _rmin = (_rvect Select 0) - _zdiff _rmax = (_rvect Select ((Count _rvect)-1)) - _zdiff ? (_rangedatum < _rmin) : Goto "AbortMin" ? (_rangedatum >= _rmax) : Goto "AbortMax" _ind = 0 #NextR _ri = (_rvect Select _ind) - _zdiff ? (_ri > _rangedatum) : Goto "BracketFound" _ind = _ind + 1 ~0.01 Goto "NextR" #BracketFound _rp = (_rvect Select (_ind - 1)) - _zdiff _ela = _elvect Select (_ind - 1) _elb = _elvect Select _ind _el = (_elb - _ela)*(_rangedatum - _rp)/(_ri - _rp) + _ela ;_artillery SideChat Format[ "ri %1 rp %2 ela %3 elb %4 el %5",_ri,_rp,_ela,_elb,_el] _el = _el + elcomp _firecount = 1 ; ------------------------------------------- #head _artillery SetPos _pos ; call CalcBearing *** ; randomize bearing _rand1 = Random 1 _rand2 = Random 1 _pi = 3.14159 _randn1 = sqrt(-2*ln(_rand1))*cos(2*_pi*_rand2) _randn2 = sqrt(-2*ln(_rand1))*sin(2*_pi*_rand2) _posxa = _posx _posxb = _posdatx + 5*_randn1 _posya = _posy _posyb = _posdaty + 5*_randn1 _rettagb = "Ret0" Goto "CalcBearing" #Ret0 _tbearing = _bearing ; ------------------------------------------- ; This attempts to account for varying terrain heights. _tr = 100 _posb = [_posx+(_tr*sin(_tbearing)),_posy+(_tr*cos(_tbearing)), 200] _target SetPos _posb _trange = _artillery Distance _target _theight = sqrt(_trange^2 - _tr^2) - 200 _tsetheight = _tr*tan(_el) - _theight _posb = [_posx+(_tr*sin(_tbearing)),_posy+(_tr*cos(_tbearing)), _tsetheight] _posb2 = [_posx+(_tr*sin(_tbearing)),_posy+(_tr*cos(_tbearing)), 2*_tsetheight] ; ------------------------------------------- ;_rangenodrag = ((720^2)/9.8)*sin(2*_el) ? (_verb > 1) : _artillery SideChat Format["Gun el:%1 ",_el] ~1 ~ (Random 2) ; Call LockToTarget *** _observer = _artillery _rettag = "Ret1" Goto "LockToTarget" #Ret1 _ammo = _artillery Ammo "" ;? (_ammo <= 1) : Goto "AbortAmmo" ? (_verb > 0) : _artillery SideChat Format ["Firing %1 at bearing of %2 deg (%3)",_firecount,GetDir _artillery,_ammo] _artillery Fire ["D30"] @((_artillery Ammo "Sh_122_HE")==(_ammo - 1)) _target SetPos _posb2 ~1 _firecount = _firecount + 1 ;? (_firecount <= 1) : Goto "head" ? (fireoption == 1) : Goto "head" CamDestroy _target _artillery SetCombatMode "YELLOW" ? (_verb > 0) : _artillery SideChat "Sequence complete" exit ; ------------------------------------------------------------------------------ ; ------------------------------------------------------------------------------ #Abort _artillery SetCombatMode "YELLOW" _artillery SideChat Format["Fire control, unable to target. B %1 C %2 Aborting mission.",_posb,_posc] _artillery SideChat Format["Combat mode %1",CombatMode _artillery] exit ; ------------------------------------------------------------------------------ ; ------------------------------------------------------------------------------ #AbortMin _artillery SetCombatMode "YELLOW" _artillery SideChat Format ["Target is inside of minimum range (%1 km). Aborting mission.",_rmin] exit ; ------------------------------------------------------------------------------ ; ------------------------------------------------------------------------------ #AbortMax _artillery SetCombatMode "YELLOW" _artillery SideChat Format ["Target is out of range (%1 km). Aborting mission.",_rmax] exit ; ------------------------------------------------------------------------------ ; ------------------------------------------------------------------------------ #AbortBlue _artillery SideChat "Already engaged." exit ; ------------------------------------------------------------------------------ ; ------------------------------------------------------------------------------ #AbortAmmo _artillery SideChat "Out of ammunition." exit ; ------------------------------------------------------------------------------ ; ------------------------------------------------------------------------------ #LockToTarget _posobs = GetPos _observer ; ------------------------------------------- _loopcount = 0 #loopstart _loopcount = _loopcount + 1 _observer SetDir _tbearing ~0.5 _observer DoWatch _posb ~8.0 _curdir = GetDir _observer ; Check bearing error _dsin = abs(sin(_curdir) - sin(_tbearing)) _dcos = abs(cos(_curdir) - cos(_tbearing)) _dsum = _dsin + _dcos ? (_dsum < 0.03) : Goto "lockdone" ;_observer SideChat Format ["Position error %1, adjusting %2",_dsum,_loopcount] _observer SetPos _posobs ~1 Goto "loopstart" #lockdone Goto _rettag ; ------------------------------------------------------------------------------ ; ------------------------------------------------------------------------------ #CalcBearing ; Calculate bearing to datum _dx = (_posxb - _posxa) _dy = (_posyb - _posya) ? (_dy != 0) : Goto "divok" _dy = 0.0001 #divok _bearing = atan (_dx/_dy) ? (_dy < 0) : Goto "Q34" Goto "Q12" #Q34 _bearing = _bearing + 180.0 #Q12 ? _bearing < 0 : _bearing = _bearing + 360.0 ;_artillery SideChat Format ["CalcBearing:%1",_bearing] Goto _rettagb DisplayGrid,sqs Quote[/b] ]; [_obj] Exec "DisplayGrid.sqs"; SideChat's grid coords of _obj ; DK NOV2001 _obj = _this Select 0 _charvect = ["A","B","C","D","E","F"," ;G","H","I","J"] _pos = GetPos _obj _posx = _pos Select 0 _posy = _pos Select 1 _xc1 = (_posx / 1280) _xc1 = _xc1 - (_xc1 % 1) _xc1 = _charvect Select _xc1 _xc2 = (_posx % 1280) / 128 _xc2 = _xc2 - (_xc2 % 1) _xc2 = _charvect Select _xc2 _yc1 = (12800 - _posy) / 1280 _yc1 = _yc1 - (_yc1 % 1) _yc2 = ((12800 - _posy) % 1280) / 128 _yc2 = _yc2 - (_yc2 % 1) ~4 _obj SideChat Format ["Current pos %1%2,%3%4",_xc1,_xc2,_yc1,_yc2] Hope the scripts are enough - otherwise PM me to recive a copy of the mission Share this post Link to post Share on other sites
major woody 11 Posted March 26, 2007 3 days and 64 views later with no replies I assume nobody has an answer for this? Â Â Share this post Link to post Share on other sites
Guest Posted March 26, 2007 And in those 3 days........how much progress did you make yourself? Share this post Link to post Share on other sites