Results 1 to 6 of 6

Thread: Search: scud launch & impact script

  1. #1
    Hi,
    i am planning an MP-map in which a player can go to a radio. Then he gets the order to select a target on the map. After marking on the map the Scud launches. For e.g. after 30sec the scud hits his target. Then the scud reload and the play begins again. Every Player should be able to start this script. But only once at the same time! The targets should be variable on evey point on the map. I know it is to do with _getmarkerpos and camcreate with some satchels. I have also an example script
    search for "Scud Launch/Trajectory Scripts".
    But i have no idea what i do wrong when i try this script on my map. All works wonderfull up to the point when the player try to mark his target on the map. The scud doesn't get the markerpoint like in the example mission.....help

    i know...much text, but when it works it's a wonderfull effect!

    thx hopefully Yogy

  2. #2
    ok i c....it's stupid without the code...here we go:

    usermarker.sqs:
    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; this script will constantly monitor for new user-defined markers
    ; it is designed to be called right at the start of a mission

    ; every time a new user defined marker is created&#58;

    ; the global variable &#39;userMarker&#39; will equal the latest marker
    ; the global variable &#39;userMarkerPos&#39; will equal the position of the latest marker
    ; the global variable &#39;userMarkerX&#39; will equal the X coord of latest marker
    ; the global variable &#39;userMarkerY&#39; will equal the Y coord of latest marker
    ; the global variable &#39;userMarkerSet&#39; will equal true.

    ; it is YOUR responsibility to set userMarkerSet back to false&#33; ie in your artillery script or wherever. If you don&#39;t it doesn&#39;t matter, if the user enters a new marker then the new marker information will override the global variables

    ; it does not matter how many markers already exist on the map, this script will just hunt for the first user defined marker the player places, then the next etc.

    ; WARNING&#33;&#33;&#33;&#33; THE DELETE BUTTON IS THE ACHILE&#39;S HEEL OF THIS SCRIPT&#33;&#33;&#33;&#33;&#33;

    ; PARAMETERS&#58; takes the number of pre-defined markers you have already set in the editor
    ;----------------------------------------------

    ; BEGIN BITS U CAN EDIT
    ;----------------------

    ; set the time between marker checks - should be between 0.25 and 1
    _pause = 0.5

    ; time in seconds to show &#39;destroy&#39; icon before the marker will disappear, default is 1
    ; careful, you don&#39;t want the player adding new markers while we are waiting for the
    ; destroy icon to disappear, so don&#39;t make this value too high
    _hidedelay = 3

    ; the icon to display for user-defined markers
    _icon = &#34;destroy&#34;

    ; END BITS U CAN EDIT
    ;--------------------

    userMarkerPause = false
    userMarkerSet = false

    _nEditorMarkers = _this select 0

    ; this loop will run until the end of the mission
    #missionLooop

    ;wait for a marker to be added
    #loop2

    ;halt the script if requested
    @NOT&#40;userMarkerPause&#41;

    ; find the id of what will be the next user-defined marker
    _counter = _nEditorMarkers
    #loop1
    _markerposn = getMarkerPos format&#91;&#34;_USER_DEFINED #0/%1&#34;,_counter&#93;
    ? &#40;&#40;_markerposn select 0&#41; == 0 AND &#40;_markerposn select 1&#41; == 0&#41; &#58; goto &#34;nextmarkerspotfound&#34;
    _counter = _counter + 1
    goto &#34;loop1&#34;

    ; ok so now _counter will equal the position of where a new marker will go.
    #nextmarkerspotfound

    ; make sure another marker has not been added during the loop above
    ? &#40;&#40;_markerposn select 0&#41; &#33;= 0 AND &#40;_markerposn select 1&#41; &#33;= 0&#41; &#58; _counter = _counter + 1

    ~_pause

    _markerposn = getMarkerPos format&#91;&#34;_USER_DEFINED #0/%1&#34;,_counter&#93;
    ? &#40;_markerposn select 0&#41; == 0 AND &#40;_markerposn select 1&#41; == 0 &#58; goto &#34;loop2&#34;

    ; remember the new marker information in userMarker, userMarkerPos, userMarkerPosX, userMarkerPosY
    userMarker = format&#91;&#34;_USER_DEFINED #0/%1&#34;,_counter&#93;
    userMarkerPos = _markerposn
    userMarkerX = &#40;_markerposn select 0&#41;
    userMarkerY = &#40;_markerposn select 1&#41;

    ; change markers icon
    userMarker SetMarkerType _icon

    ; switch the userMarkerSet flag to true - it is your responsibility to switch it back to false
    userMarkerSet = true

    ; uncomment for information about new marker to be printed to screen
    ;hint format&#91;&#34;Marker %1 placed at position&#58; &#40;%2,%3&#41;&#34;,_counter,userMarkerX,userMark erY&#93;

    ; short pause to allow icon to change
    ~_hidedelay

    ; hide the marker &#40;so the player will not intentionally delete it&#41;
    userMarker SetMarkerType &#34;empty&#34;

    ; loop back up to wait for the next marker

    goto &#34;missionLooop&#34;[/QUOTE]

    launch_scud.sqs
    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; radio msg when preparing scud
    _scudpreparemsg = &#34;Acknowledged, preparing scud for launch, out&#34;

    ; radio msg when rounds are inbound
    _inboundmsg = &#34;Scud inbound, out&#34;

    ; radio msg when scud hits target
    _hitmsg = &#34;Scud made a direct hit with co-ordinates sir, out&#34;

    ; radio msg if a scud launch is already in progress
    _scudcalledmsg = &#34;Scud launch in progress, wait out&#34;

    ; radio msg if a scud launch is already in progress
    _scuddamagedmsg = &#34;shhhhhhh crackle crackle... shhhhhhhhhhhhhhhhhhhhh&#34;

    ; radio msg if all three scuds have been used
    _scudnoordinace = &#34;Scud ordinace depleted sir, out&#34;

    ; radio msg if target is not within 3000 meters
    _scudoutrangemsg = &#34;Target is not within range sir, out&#34;

    ; radio msg if target to close &#40;500m&#41;
    _scudtoclosemsg = &#34;Target is to close sir, out&#34;

    ; radio msg asking player to make marker on map
    _makemarkermsg = &#34;Please place target marker on map sir, out&#34;


    ; is a script already running?
    ? scudcalled &#58; ***Driver scud_launcher SideChat _scudcalledmsg; exit
    scudcalled = true


    ;check to see if scud launcher/driver are functional/alive
    ?&#40;&#33;canMove scud_launcher&#41; or &#40;&#33;canMove Driver scud_launcher&#41;&#58;Driver scud_launcher sidechat _scuddamagedmsg;scudcalled = false;exit


    ;stop scud launcher if moving
    dostop scud_launcher

    ; wait until the player has set a user marker
    Driver scud_launcher SideChat _makemarkermsg
    userMarkerSet = false
    @userMarkerSet


    ;Get position of source explosion unit
    _source = _this select 0


    ;Get position of target
    _target1 = _this select 1


    ;set position of target to user marker
    _target1 setpos &#91;userMarkerX,userMarkerY,0&#93;
    _targetpos = getpos _target1
    _x = _targetpos select 0
    _y = _targetpos select 1
    _z = 0


    ;Get position of scud launcher
    _scudLauncherpos = getpos scud_launcher
    _scudx = _scudLauncherpos select 0
    _scudy = _scudLauncherpos select 1
    _scudz = 0


    ;scud variables
    _stScudHeight=350
    _stCamHeight=350
    _stScudx=_scudx
    _stScudy=_scudy
    _soundGo=false
    _scudSpeed = 5
    _distance2D=0
    _distanceTravel=1


    ;for scud range display
    _scud3000=false
    _scud2000=false
    _scud1000=false
    _scud300=false


    ;check to see if target is in range &#40;3000m&#41;
    ? &#40;scud_launcher Distance _target1&#41; &#62; 3000 &#58; Driver scud_launcher sidechat _scudoutrangemsg;scudcalled = false;exit


    ;check to see if target is to close &#40;400m&#41;
    ? &#40;scud_launcher Distance _target1&#41; &#60; 400 &#58; Driver scud_launcher sidechat _scudtoclosemsg;scudcalled = false;exit


    ;check to see how many scuds are left. If none, display message and exit
    ?&#40;scudCount==3&#41;&#58;Driver scud_launcher sidechat _scudnoordinace;scudcalled = false;exit
    ?&#40;scudCount==2&#41;&#58;_scudName=scud3;scudCo unt=3
    ?&#40;scudCount==1&#41;&#58;_scudName=scud2;scudCo unt=2
    ?&#40;scudCount==0&#41;&#58;_scudName=scud1;scudCo unt=1


    ;prepare scud for launch
    Driver scud_launcher sidechat _scudpreparemsg;


    ;lift scud platform
    scud_launcher action &#91;&#34;SCUD Launch&#34;&#93;


    ;wait for scud cradle on launcher to lift scud
    ~12


    ;launch scud
    scud_launcher action &#91;&#34;SCUD Start&#34;&#93;


    ;missile inbound message
    Driver scud_launcher sidechat _inboundmsg;


    ;wait for scud to launch into air
    ~12


    ;check to see if scudcam has been turned off by the user radio. If so, don&#39;t create camera
    ? &#33;camView &#58; goto &#34;skipCam&#34;

    ;create scud camera
    _cam = &#34;camera&#34; CamCreate &#91;_stScudx,_stScudy,0&#93;

    ;point the camera at target
    _cam CamSetTarget _target1

    ;set an effect for the camera
    _cam CameraEffect &#91;&#34;Internal&#34;,&#34;Back&#34;&#93;

    ;set field of view of camera
    _cam camSetFOV 1.5

    ;put sphere overlay on-screen
    cutOBJ &#91;&#34;Sphere&#34;,&#34;plain down&#34;,1000&#93;

    ;execute camera changes
    _cam CamCommit 0
    #skipCam


    ;determine x and y distance to target
    ? _stScudx &#62; _x &#58; _scudIncrx=_stScudx - _x
    ? _stScudx &#60; _x &#58; _scudIncrx=_x - _stScudx
    ? _stScudy &#62; _y &#58; _scudIncry=_stScudy - _y
    ? _stScudy &#60; _y &#58; _scudIncry=_y - _stScudy


    ;move scud along path to target - ***loop
    #moveScud


    ;determine scud direction to target
    ? _stScudx &#60; _x and _stScudy &#60; _y&#58; _finalDir=atan&#40;_scudIncrx/_scudIncry&#41;
    ? _stScudx &#62; _x and _stScudy &#62; _y&#58; _finalDir=atan&#40;_scudIncrx/_scudIncry&#41; - 180
    ? _stScudx &#60; _x and _stScudy &#62; _y&#58; _finalDir=atan&#40;_scudIncry/_scudIncrx&#41; + 90
    ? _stScudx &#62; _x and _stScudy &#60; _y&#58; _finalDir=atan&#40;_scudIncry/_scudIncrx&#41; -90
    ? _finalDir &#60; 0 &#58; _finalDir = 360 + _finalDir


    ;determine new location of scud
    _distanceTravel = _distanceTravel + _scudSpeed
    _stScudx = _scudx + sin&#40;_finalDir&#41; * _distanceTravel
    _stScudy = _scudy + cos&#40;_finalDir&#41; * _distanceTravel


    ;determine new location of camera &#40;in front of scud&#41;
    _stCamx = _scudx + sin&#40;_finalDir&#41; * &#40;_distanceTravel+5&#41;
    _stCamy = _scudy + cos&#40;_finalDir&#41; * &#40;_distanceTravel+5&#41;


    ;determine 2d distance to target
    ? _stScudx &#62;= _x &#58; _scud2Dx=_stScudx - _x
    ? _stScudx &#60; _x &#58; _scud2Dx=_x - _stScudx
    ? _stScudy &#62;= _y &#58; _scud2Dy=_stScudy - _y
    ? _stScudy &#60; _y &#58; _scud2Dy=_y - _stScudy
    _distance2D=sqrt&#40;_scud2Dx^2 + _scud2Dy^2&#41;


    ;determine 3d distance to target &#40;actual distance&#41;
    _scudDistance=&#40;_scudName Distance _target1&#41;


    ;determine z axis curve &#40;scud height&#41;
    _stScudHeight = &#40;_distance2D/2&#41; + cos&#40;atan&#40;_stScudHeight/_distance2D&#41;&#41; * _distanceTravel
    ? camView &#58; _stCamHeight = &#40;_distance2D/2&#41; + cos&#40;atan&#40;_stCamHeight/_distance2D&#41;&#41; * &#40;_distanceTravel+5&#41;


    ;play shhh sound when scud gets below 150 meters
    ? &#33;_soundGo AND _stScudHeight &#60; 500 AND _distance2D &#60; 150&#58; PlaySound &#34;say_shhh&#34;;_soundGo=true


    ;display scud range to target
    ? _distance2D &#60; 3015 and _distance2D &#62; 3000 and &#33;_scud3000 &#58; Driver scud_launcher sidechat &#34;3000 meters and closing&#34;;_scud3000=true
    ? _distance2D &#60; 2015 and _distance2D &#62; 2000 and &#33;_scud2000 &#58; Driver scud_launcher sidechat &#34;2000 meters and closing&#34;;_scud2000=true
    ? _distance2D &#60; 1015 and _distance2D &#62; 1000 and &#33;_scud1000 &#58; Driver scud_launcher sidechat &#34;1000 meters and closing&#34;;_scud1000=true


    ;check if scud is above target - if so, stop and detonate missile
    ? _distance2D &#60; 5 AND _distance2D &#62;-5 ***&#58; goto &#34;stopMove&#34;


    ;check if scud height is at ground level - if so, stop and detonate missile
    ? _stScudHeight &#60; 5 &#58; goto &#34;stopMove&#34;


    ;check if scud is close to target - if so, stop and detonate missile
    ? _scudDistance &#60; 1 &#58; goto &#34;stopMove&#34;


    ;for debug purposes - displays various variables on-screen
    ;hint format &#91;&#34;%1,%2,%3 &#92;n scud2Dx %4 &#92;n scud2Dy %5 &#92;n scudDir %6 &#92;n 3d distance %7 &#92;n 2d distance %8 &#92;n %9,%10,%11&#34;, _stScudx,_stScudy,_stScudHeight,_scud2Dx,_scud2Dy, _finalDir,&#40;_scudName Distance _target1&#41;,_distance2D,_x,_y,_z&#93;


    ;update scud position
    _scudName setpos &#91;_stScudx,_stScudy,_stScudHeight&#93;


    ;update camera position
    ? camView &#58; _cam camsetpos &#91;_stCamx,_stCamy,_stCamHeight&#93;
    ? camView &#58; _cam CamCommit 0


    ;point scud toward target
    _scudName setDir _finalDir


    ;slight delay, so missile shows up while traveling to target
    ~0.00001


    ;start again, and move the scud another increment
    goto &#34;moveScud&#34;


    ;stop the scud and detonate at proper co-ordinates
    #stopMove


    ;destroy camera and return to player
    ? camView &#58; _cam CameraEffect &#91;&#34;Terminate&#34;,&#34;Back&#34;&#93;
    ? camView &#58; CamDestroy _cam
    ? camView &#58; cutRSC &#91;&#34;default&#34;,&#34;plain down&#34;,0&#93;


    ;for debug purposes - displays various variables on-screen
    ;hint format &#91;&#34;%1,%2,%3 &#92;n scud2Dx %4 &#92;n scud2Dy %5 &#92;n scudDir %6 &#92;n 3d distance %7 &#92;n 2d distance %8 &#92;n %9,%10,%11&#34;, _stScudx,_stScudy,_stScudHeight,_scud2Dx,_scud2Dy, _finalDir,&#40;_scudName Distance _target1&#41;,_distance2D,_x,_y,_z&#93;


    ;set scud to target co-ordinates and detonate
    _scudName setpos &#91;_x, _y, 0&#93;
    _scudName setdammage 1


    ;multiple explosions on impact script
    ;-------------------------------------------------------

    ;number of explosion rings to set off
    _ringCount=3

    ;spread &#40;in meters&#41; of explosion rings
    _ringSpread=15

    ;number of explosions per ring
    _explosionsPerRing=8


    ;counter to keep track of the number of rings
    _ring=1


    ;start ring loop
    #ringLoop


    ;reset explosion counter to zero
    _count = 0


    ;start bomb loop
    #bombLoop


    ;calculate new co-ordinates for explosion
    _nx = _x + sin&#40;_count*&#40;360/_explosionsPerRing&#41;&#41; * &#40;_ringSpread*_ring&#41;
    _ny = _y + cos&#40;_count*&#40;360/_explosionsPerRing&#41;&#41; * &#40;_ringSpread*_ring&#41;


    ;move explosion unit into position
    _source setpos &#91;_nx, _ny, 0&#93;


    ;blow up the explosion unit
    _source setdammage 1


    ;short delay so you see explosion
    ~0.1


    ;revive the unit
    _source setdammage 0


    ;increment counter
    _count = _count + 1


    ;check if done explosion round
    ?_count &#60;= _explosionsPerRing &#58; goto &#34;bombLoop&#34;

    _ring = _ring + 1

    ;check if done all explosions
    ? _ring &#60;= _ringCount &#58; goto &#34;ringLoop&#34;


    ;move explosion unit to target location
    _source setpos &#91;_x, _y, 0&#93;
    ;-------------------------------------------------------


    ;display remaining scuds on radio interface
    1 setradiomsg format&#91;&#34;Launch Scud &#40;%1&#41;&#34;,3-scudCount&#93;


    ;target hit message
    Driver scud_launcher sidechat _hitmsg


    scudcalled = false
    exit
    [/QUOTE]

    camView_toggle.sqs (i have no need with this, but for some interested guys...)
    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? camView &#58; camView=false;2 setradiomsg &#34;Turn ScudCam on&#34;;exit
    ? &#33;camView &#58; camView=true;2 setradiomsg &#34;Turn ScudCam off&#34;;exit
    [/QUOTE]

  3. #3
    What&#39;s the problem?
    Too easy, too compex or not interesting?

  4. #4
    IM not entirly sure the scud missile is a valid object to use, I think once it reaches a certain hieght it is deleted automatically.

    You would need to find a way of maybe intergrating the cruise missile template to the scud, that would be a good place to start, then hope someone creates a scud model that can be controlled.

  5. #5
    Did you notice you're replying to a 6 year old topic ?

  6. #6
    Please do not dig up old threads unless you have something significant to add.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •