Jump to content
Sign in to follow this  
yogybear

Search: scud launch & impact script

Recommended Posts

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 sad_o.gif

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

thx hopefully Yogy crazy_o.gif

Share this post


Link to post
Share on other sites

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:

; the global variable 'userMarker' will equal the latest marker

; the global variable 'userMarkerPos' will equal the position of the latest marker

; the global variable 'userMarkerX' will equal the X coord of latest marker

; the global variable 'userMarkerY' will equal the Y coord of latest marker

; the global variable 'userMarkerSet' will equal true.

; it is YOUR responsibility to set userMarkerSet back to false! ie in your artillery script or wherever. If you don't it doesn'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!!!! THE DELETE BUTTON IS THE ACHILE'S HEEL OF THIS SCRIPT!!!!!

; PARAMETERS: 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 'destroy' icon before the marker will disappear, default is 1

; careful, you don't want the player adding new markers while we are waiting for the

; destroy icon to disappear, so don't make this value too high

_hidedelay = 3

; the icon to display for user-defined markers

_icon = "destroy"

; 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(userMarkerPause)

; find the id of what will be the next user-defined marker

_counter = _nEditorMarkers

#loop1

_markerposn = getMarkerPos format["_USER_DEFINED #0/%1",_counter]

? ((_markerposn select 0) == 0 AND (_markerposn select 1) == 0) : goto "nextmarkerspotfound"

_counter = _counter + 1

goto "loop1"

; 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

? ((_markerposn select 0) != 0 AND (_markerposn select 1) != 0) : _counter = _counter + 1

~_pause

_markerposn = getMarkerPos format["_USER_DEFINED #0/%1",_counter]

? (_markerposn select 0) == 0 AND (_markerposn select 1) == 0 : goto "loop2"

; remember the new marker information in userMarker, userMarkerPos, userMarkerPosX, userMarkerPosY

userMarker = format["_USER_DEFINED #0/%1",_counter]

userMarkerPos = _markerposn

userMarkerX = (_markerposn select 0)

userMarkerY = (_markerposn select 1)

; 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["Marker %1 placed at position: (%2,%3)",_counter,userMarkerX,userMarkerY]

; short pause to allow icon to change

~_hidedelay

; hide the marker (so the player will not intentionally delete it)

userMarker SetMarkerType "empty"

; loop back up to wait for the next marker

goto "missionLooop"

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 = "Acknowledged, preparing scud for launch, out"

; radio msg when rounds are inbound

_inboundmsg = "Scud inbound, out"

; radio msg when scud hits target

_hitmsg = "Scud made a direct hit with co-ordinates sir, out"

; radio msg if a scud launch is already in progress

_scudcalledmsg = "Scud launch in progress, wait out"

; radio msg if a scud launch is already in progress

_scuddamagedmsg = "shhhhhhh crackle crackle... shhhhhhhhhhhhhhhhhhhhh"

; radio msg if all three scuds have been used

_scudnoordinace = "Scud ordinace depleted sir, out"

; radio msg if target is not within 3000 meters

_scudoutrangemsg = "Target is not within range sir, out"

; radio msg if target to close (500m)

_scudtoclosemsg = "Target is to close sir, out"

; radio msg asking player to make marker on map

_makemarkermsg = "Please place target marker on map sir, out"

; is a script already running?

? scudcalled :  Driver scud_launcher SideChat _scudcalledmsg; exit

scudcalled = true

;check to see if scud launcher/driver are functional/alive

?(!canMove scud_launcher) or (!canMove Driver scud_launcher):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 [userMarkerX,userMarkerY,0]

_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 (3000m)

? (scud_launcher Distance _target1) > 3000 : Driver scud_launcher sidechat _scudoutrangemsg;scudcalled = false;exit

;check to see if target is to close (400m)

? (scud_launcher Distance _target1) < 400 : Driver scud_launcher sidechat _scudtoclosemsg;scudcalled = false;exit

;check to see how many scuds are left. If none, display message and exit

?(scudCount==3):Driver scud_launcher sidechat _scudnoordinace;scudcalled = false;exit

?(scudCount==2):_scudName=scud3;scudCount=3

?(scudCount==1):_scudName=scud2;scudCount=2

?(scudCount==0):_scudName=scud1;scudCount=1

;prepare scud for launch

Driver scud_launcher sidechat _scudpreparemsg;

;lift scud platform

scud_launcher action ["SCUD Launch"]

;wait for scud cradle on launcher to lift scud

~12

;launch scud

scud_launcher action ["SCUD Start"]

;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't create camera

? !camView : goto "skipCam"

;create scud camera

_cam = "camera" CamCreate [_stScudx,_stScudy,0]

;point the camera at target

_cam CamSetTarget _target1

;set an effect for the camera

_cam CameraEffect ["Internal","Back"]

;set field of view of camera

_cam camSetFOV 1.5

;put sphere overlay on-screen

cutOBJ ["Sphere","plain down",1000]

;execute camera changes

_cam CamCommit 0

#skipCam

;determine x and y distance to target

? _stScudx > _x : _scudIncrx=_stScudx - _x

? _stScudx < _x : _scudIncrx=_x - _stScudx

? _stScudy > _y : _scudIncry=_stScudy - _y

? _stScudy < _y : _scudIncry=_y - _stScudy

;move scud along path to target -  loop

#moveScud

;determine scud direction to target

? _stScudx < _x and _stScudy < _y: _finalDir=atan(_scudIncrx/_scudIncry)

? _stScudx > _x and _stScudy > _y: _finalDir=atan(_scudIncrx/_scudIncry) - 180

? _stScudx < _x and _stScudy > _y: _finalDir=atan(_scudIncry/_scudIncrx) + 90

? _stScudx > _x and _stScudy < _y: _finalDir=atan(_scudIncry/_scudIncrx) -90

? _finalDir < 0 : _finalDir = 360 + _finalDir

;determine new location of scud

_distanceTravel = _distanceTravel + _scudSpeed

_stScudx = _scudx + sin(_finalDir) * _distanceTravel

_stScudy = _scudy + cos(_finalDir) * _distanceTravel

;determine new location of camera (in front of scud)

_stCamx = _scudx + sin(_finalDir) * (_distanceTravel+5)

_stCamy = _scudy + cos(_finalDir) * (_distanceTravel+5)

;determine 2d distance to target

? _stScudx >= _x : _scud2Dx=_stScudx - _x

? _stScudx < _x : _scud2Dx=_x - _stScudx

? _stScudy >= _y : _scud2Dy=_stScudy - _y

? _stScudy < _y : _scud2Dy=_y - _stScudy

_distance2D=sqrt(_scud2Dx^2 + _scud2Dy^2)

;determine 3d distance to target (actual distance)

_scudDistance=(_scudName Distance _target1)

;determine z axis curve (scud height)

_stScudHeight = (_distance2D/2) + cos(atan(_stScudHeight/_distance2D)) * _distanceTravel

? camView : _stCamHeight = (_distance2D/2) + cos(atan(_stCamHeight/_distance2D)) * (_distanceTravel+5)

;play shhh sound when scud gets below 150 meters

? !_soundGo AND _stScudHeight < 500 AND _distance2D < 150: PlaySound "say_shhh";_soundGo=true

;display scud range to target

? _distance2D < 3015 and _distance2D > 3000 and !_scud3000 : Driver scud_launcher sidechat "3000 meters and closing";_scud3000=true

? _distance2D < 2015 and _distance2D > 2000 and !_scud2000 : Driver scud_launcher sidechat "2000 meters and closing";_scud2000=true

? _distance2D < 1015 and _distance2D > 1000 and !_scud1000 : Driver scud_launcher sidechat "1000 meters and closing";_scud1000=true

;check if scud is above target - if so, stop and detonate missile

? _distance2D < 5 AND _distance2D >-5  : goto "stopMove"

;check if scud height is at ground level - if so, stop and detonate missile

? _stScudHeight < 5 : goto "stopMove"

;check if scud is close to target - if so, stop and detonate missile

? _scudDistance < 1 : goto "stopMove"

;for debug purposes - displays various variables on-screen

;hint format ["%1,%2,%3 \n scud2Dx %4 \n scud2Dy %5 \n scudDir %6 \n 3d distance %7 \n 2d distance %8 \n %9,%10,%11", _stScudx,_stScudy,_stScudHeight,_scud2Dx,_scud2Dy,_finalDir,(_scudName Distance _target1),_distance2D,_x,_y,_z]

;update scud position

_scudName setpos [_stScudx,_stScudy,_stScudHeight]

;update camera position

? camView : _cam camsetpos [_stCamx,_stCamy,_stCamHeight]

? camView : _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 "moveScud"

;stop the scud and detonate at proper co-ordinates

#stopMove

;destroy camera and return to player

? camView : _cam CameraEffect ["Terminate","Back"]

? camView : CamDestroy _cam

? camView : cutRSC ["default","plain down",0]

;for debug purposes - displays various variables on-screen

;hint format ["%1,%2,%3 \n scud2Dx %4 \n scud2Dy %5 \n scudDir %6 \n 3d distance %7 \n 2d distance %8 \n %9,%10,%11", _stScudx,_stScudy,_stScudHeight,_scud2Dx,_scud2Dy,_finalDir,(_scudName Distance _target1),_distance2D,_x,_y,_z]

;set scud to target co-ordinates and detonate

_scudName setpos [_x, _y, 0]

_scudName setdammage 1

;multiple explosions on impact script

;-------------------------------------------------------

;number of explosion rings to set off

_ringCount=3

;spread (in meters) 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(_count*(360/_explosionsPerRing)) * (_ringSpread*_ring)

_ny = _y + cos(_count*(360/_explosionsPerRing)) * (_ringSpread*_ring)

;move explosion unit into position

_source setpos [_nx, _ny, 0]

;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 <= _explosionsPerRing : goto "bombLoop"

_ring = _ring + 1

;check if done all explosions

? _ring <= _ringCount : goto "ringLoop"

;move explosion unit to target location

_source setpos [_x, _y, 0]

;-------------------------------------------------------

;display remaining scuds on radio interface

1 setradiomsg format["Launch Scud (%1)",3-scudCount]

;target hit message

Driver scud_launcher sidechat _hitmsg

scudcalled = false

exit

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 : camView=false;2 setradiomsg "Turn ScudCam on";exit

? !camView : camView=true;2 setradiomsg "Turn ScudCam off";exit

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×