Jump to content
Sign in to follow this  
muerto

Simple Attack move

Recommended Posts

Okay, maybe not the best topic, sorry. Been using the editor a along time now and I'm just curious to know if there is a easy way in the editor, or by script make... say for example a aircraft drop its munitions on a special place say like a village. Think of it like an attack move but the unit/vehicle just drops its payload on the designated target. kind of like the old COC arty, which could use aircraft. Of course there is destroy, but that is limited. there is also search & destroy, but also limited as AI air-units will only target vehicles. Enlighten me on this topic, thanks.

Share this post


Link to post
Share on other sites

Invisible targets addon might do the trick, they are like invisible and indestructible vehicles that the AI will attack on it's own. Just delete them after the plane is done so your AT guys, tanks or whatever won't attack them.

Maybe even the laser target would do if you don't want to use any addons (class names LaserTargetW or LaserTargetE) but those work only with LGBs and missiles I think.

Share this post


Link to post
Share on other sites

Look at the usage example line inside the comments (you may create your own endairmission.sqs script (it will be executed after the end of the airstrike), or just change it by "".

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;mandoairstrike.sqs

;By Mandoble, valdelar@terra.es

;

;Executes high accuracy free-fall bombs attacks

;

;If the plane gets too much damage during the mission, the crew will eject and,

;if alive, the pilot will radio his map coordinates

;

;Arguments:

; striking plane

; target array

; bombscript (script that spawns the bombs, it receives plane, velocity and direction for bombs, time to impact and camera).

; Accuracy (1.0 max, 0.0 min.) Min accuracy means plane can miss by up to 100m from the target

; Maximum allowabe damage before ejecting crew (0.1-0.9)

; Climb rate in m/s after releasing bombs, this is applied for few secons after dropping bombs

; Range from target to drop bombs (0-990), -1 if automatically calculated for freefall bombs.

; Retry if bombs fail target (true/false)

; radio on/off (true/false)

; camera on/off (true/false)

; script to execute when assigned mission is finished or "" if none. The script receives the plane and end mission status (true ok, false eject).

;

; Example:

; [plane1,[tank1,bmp1,tank2,building2],"bigbombs.sqs",1.0,0.6,10.0,-1,false, true,true,"endairmission.sqs"]exec"mandoairstrike.sqs"

;

_letras1 = ["A","B","C","D","E","F","G","H","I","J"]

_letras2 = ["a","b","c","d","e","f","g","h","i","j"]

_numeros1 = ["9","8","7","6","5","4","3","2","1","0"]

_numeros2 = ["9","8","7","6","5","4","3","2","1","0"]

_maxx1 = 12800

_maxx2 = 1280

_maxy1 = 12800

_maxy2 = 1280

_plane = _this select 0

_targets = _this select 1

_bombscript = _this select 2

_accuracy = _this select 3

_maxdmg = _this select 4

_climbrt = _this select 5

_droprange = _this select 6

_retry = _this select 7

_radio = _this select 8

_camera = _this select 9

_endscript = _this select 10

?(_maxdmg > 0.9)||(_maxdmg < 0.1):_maxdmg = 0.5

?(_accuracy > 1.0)||(_accuracy < 0.0):_accuracy = 0.8

?(_climbrt < 2.0) || (_climbrt > 15.0):_climbrt= 8.0

?(_droprange < -1) || (_droprange > 990): _droprange = -1

?_camera:_plane switchCamera "EXTERNAL"

_pilot = driver _plane

_behpilot = behaviour _pilot

_gunner = gunner _plane

_behgunner = behaviour _gunner

_combatpilot = combatMode _pilot

_combatgunner = combatMode _pilot

_det = "EmptyDetector" camCreate [0,0,0]

_log = "logic" camCreate [0,0,0]

_ntargets = count _targets

_pilot setBehaviour "CARELESS"

_gunner setBehaviour "CARELESS"

_pilot setCombatMode "BLUE"

_gunner setCombatMode "BLUE"

_dir = getDir _plane

_log1 = "logic" camCreate [(getPos _plane select 0)+1500*sin(_dir), (getPos _plane select 1)+1500*cos(_dir),80]

~1

_pilot doTarget _log1

_gunner doTarget _log1

~1

deleteVehicle _log1

_t = 0

#target

_target = _targets select _t

#start

?_plane distance _target > 2000:goto "align"

_ang = ((getPos _target select 0)-(getPos _plane select 0)) atan2 ((getPos _target select 1)-(getPos _plane select 1))

_ang = _ang + 180

_pos = [(getPos _target select 0)+sin(_ang)*2000,(getPos _target select 1)+cos(_ang)*2000,0]

_pilot doMove _pos

?_radio: _pilot sideChat "Moving to attack position"

~1

@(unitReady _pilot)|| (damage _plane > _maxdmg)

?damage _plane > _maxdmg:goto "eject"

#align

?_radio: _pilot sideChat "Aligning with the target"

_ang = ((getPos _target select 0)-(getPos _plane select 0)) atan2 ((getPos _target select 1)-(getPos _plane select 1))

_ang = _ang + 180

_pos = [(getPos _target select 0)+sin(_ang)*1000,(getPos _target select 1)+cos(_ang)*1000,0]

_log setPos _pos

_det setPos [getPos _target select 0, getPos _target select 1, 0]

_dst0 = _det distance _target

_det setPos [_pos select 0, _pos select 1, 0]

_dstl = _det distance _log

_delta = _dstl - _dst0

?_delta < 80.0: _plane flyInHeight (80.0 + abs(_delta))

?_delta >= 0.0: _plane flyInHeight 80.0

_posfin = getPos _target

_pilot doMove _posfin

@((_plane distance _target) < 1000) || (damage _plane > _maxdmg)

?damage _plane > _maxdmg:goto "eject"

_ang = ((getPos _target select 0)-(getPos _plane select 0)) atan2 ((getPos _target select 1)-(getPos _plane select 1))

?_radio: _pilot sideChat "Final aproach"

;_dir = getDir _plane

_dir = _ang

_spd = speed _plane

_spd = _spd / 3.6

_det setPos [getPos _plane select 0, getPos _plane select 1, 0]

_dst1 = _det distance _plane

_dst = _dst1 - _dst0

_dst = _dst - 1.0

_log setPos[getPos _target select 0, getPos _target select 1, _dst]

_vfin = sqrt(2*9.8*_dst)

_tim = _vfin / 9.8

_rang = _spd*_tim

_rang = _rang + (1.0-_accuracy)*(100.0 - random 200.0)

_vel = [sin(_dir)*_spd,cos(_dir)*_spd,0]

?_droprange != -1:_rang = _droprange;_tim = 6

#aim

_plane setDir _dir

_plane setVelocity _vel

?damage _plane > _maxdmg:goto "eject"

~0.01

?(_log distance _plane) > _rang: goto "aim"

?_radio: _pilot sideChat "Bombs away!"

[_plane, _target, _vel, _dir, _tim, _camera]exec _bombscript

_rang = _rang / 2.0

_vel = [_vel select 0, _vel select 1, _climbrt]

#aim2

_plane setDir _dir

_plane setVelocity _vel

?damage _plane > _maxdmg:goto "eject"

~0.01

?(_log distance _plane) > _rang: goto "aim2"

~(_tim + 4)

;?_camera:_plane switchCamera "EXTERNAL"

?_radio && (damage _target > 0.9):_pilot sideChat "Target destroyed!"

?_radio && (damage _target <= 0.8) && _retry:_pilot sideChat "Trying again"

?_radio && (damage _target <= 0.8) && !_retry:_pilot sideChat "Target not destroyed"

?(damage _target <= 0.8)&& _retry:goto "start"

_t = _t + 1

?(_t < _ntargets)&&_radio:_pilot sideChat "Proceeding with next target"

?_t < _ntargets:goto "target"

?_radio:_pilot sideChat "Mission accomplished"

_pilot setBehaviour _behpilot

_gunner setBehaviour _behgunner

_pilot setCombatMode _combatpilot

_gunner setCombatMode _combatgunner

deleteVehicle _det

deleteVehicle _log

?_camera:player switchCamera "EXTERNAL"

?_endscript != "":[_plane, true]exec _endscript

exit

#eject

?_radio:_pilot sideChat "We got too much damage, ejecting!"

_crew = crew _plane

"_x action [""eject"",_plane]" forEach _crew

deleteVehicle _det

deleteVehicle _log

~3

?_camera:vehicle _pilot switchCamera "EXTERNAL"

@vehicle _pilot == _pilot

?_camera:_pilot switchCamera "EXTERNAL"

~4

?!alive _pilot && _camera: player switchCamera "EXTERNAL"

?!alive _pilot: goto "fin"

_pilot setBehaviour "AWARE"

_pilot setCombatMode "RED"

_gunner setBehaviour "AWARE"

_gunner setCombatMode "RED"

_pilot move getPos _pilot

_xu = getPos vehicle _pilot select 0

_yu = getPos vehicle _pilot select 1

_l1 = 10 * _xu / _maxx1

_l1 = _l1 - (_l1 mod 1)

_n1 = 10 * _yu / _maxy1

_n1 = _n1 - (_n1 mod 1)

_xu = _xu - _l1*_maxx2

_l2 = 10 * _xu / _maxx2

_l2 = _l2 - (_l2 mod 1)

_yu = _yu - _n1*_maxy2

_n2 = 10 * _yu / _maxy2

_n2 = _n2 - (_n2 mod 1)

_coordstr = format["%1%2-%3%4", _letras1 select _l1, _letras2 select _l2, _numeros1 select _n1, _numeros2 select _n2]

_msg = format["We are downed, position %1", _coordstr]

?_radio:_pilot sideChat _msg

?_camera:player switchCamera "EXTERNAL"

#fin

?_endscript != "":[_plane, false]exec _endscript

exit

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;bigbombs.sqs by Mandoble

;Mission specific script to spawn bombs

;In this case, it is called by mandoairstrike.sqs and mandoairstrikeauto.sqs to spawn pairs big bombs

;

;As any weapon script called by mandoairstrike.sqs and mandoairstrikeauto.sqs it receives the following arguments:

;plane from where spawn the bombs or ordinance

;target, for free fall bombs you dont need it, for missile attacks (using mandomisil.sqs) you'll need it

;velocity vector to apply to free fall bombs

;direction to apply to free ball bombs

;estimated time until impact for free fall bombs

;camera true/false to follow the bombs as they fall

;

_plane = _this select 0

_target = _this select 1

_vel = _this select 2

_dir = _this select 3

_seconds = _this select 4

_camera = _this select 5

;cutText[format["%1 %2 %3", _plane, _seconds, _camera], "PLAIN"]

_pos = getPos _plane

;Change the following six lines if you need more than two bombs per attack

_bomb1 = "LaserGuidedBomb" createVehicle[(_pos select 0)+sin(_dir+90)*3, (_pos select 1)+cos(_dir+90)*3,(_pos select 2)-1]

_bomb1 setDir _dir;_bomb1 setVelocity _vel

_bomb2 = "LaserGuidedBomb" createVehicle[(_pos select 0)+sin(_dir-90)*3, (_pos select 1)+cos(_dir-90)*3,(_pos select 2)-1]

_bomb2 setDir _dir;_bomb2 setVelocity _vel

?_camera:_bomb1 switchCamera "EXTERNAL"

~(_seconds + 4)

?_camera:_plane switchCamera "EXTERNAL"

exit

If you want demo missions, follow deanosbeano link wink_o.gif

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×