Home   Help Search Login Register  

Author Topic: Help with arty script  (Read 893 times)

0 Members and 1 Guest are viewing this topic.

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Help with arty script
« on: 09 Jan 2003, 11:54:08 »
ok, heres a script ive been working on with lots of help from people a long time ago, but i dusted it off and wanted to use it again...

now, the script consists of 2 scripts, one for user defined marker (clicking on the map) and the actual barrage...

now first u call for arty - they ask you to send co-ordinates - you click on map - they send red smoke round - you either confirm or cancel fire mission - fire mission begins.

problem is, that the script is very inaccurate - where the player clicks and the smoke comes down is generally off by 100m or so - in any direction - and the rounds that come after that are another 50m or so off from the smoke - not good.

could some1 check out my scripts to see how to make them more accurate? cheers.

Usermarker script:

Code: [Select]
; user defined marker detection script v1
; by snYpir for the OFP editing center

;---------------------------------------------
; 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"

Smoke/arty script:

Code: [Select]
colour = "SmokeShellRed"
_startmsg = "Send coordinates for fire mission, over"
_inboundmsg = "Acknowledged, smoke rounds inbound, out"
_endmsg = "Rounds complete, out"
_smokecalledmsg = "Fire mission in progress, wait out"
_confirmMsg= "Confirm correct target. Out. "
_inboundArtmsg = "Acknowledged, live rounds imbound. Take cover. Out."
shelllimit= 30

? smokecalled :  (_this select 0) SideChat _smokecalledmsg; exit
smokecalled = true

_smokeArr = units group (_this select 0)
"RemoveAllWeapons _x" foreach _smokeArr


_tmp = 0
#for3
(_smokeArr select _tmp) disableAI "move"
? _tmp < count _smokeArr : _tmp = _tmp + 1; goto "for3"

? _startmsg != "null" : (_this select 0) SideChat _startmsg

; wait until the player has set a user marker
userMarkerSet = false
@userMarkerSet

? _inboundmsg != "null" : (_this select 0) SideChat _inboundmsg

_salvos = _this select 1
? _salvos == 0 : hint "Invalid number of salvos. Must be greater than 1."; exit

_startPos = GetPos (_this select 0)
userMarkerY = userMarkerY + 150

_salvocount = 1
#salvoloop

~4

_tmp = 0
#for2

_randx = RANDOM 100
_tmprndx = RANDOM 10
_randy = RANDOM 100
_tmprndy = RANDOM 10
? _tmprndy < 5 : _randy = _randy * -1
? _tmprndx < 5 : _randx = _randx * -1

_smokey= "SmokeShellRed" camCreate [userMarkerX + _randx,userMarkerY + _randy,500]

;? _tmp < count _smokeArr : _tmp = _tmp + 1; goto "for2"

~9

;? _salvocount <= _salvos : _salvocount = _salvocount + 1; goto "salvoloop"

? _endmsg != "null" : (_this select 0) SideChat _Confirmmsg

2 setradiomsg "Affirmative"
3 setradiomsg "Negative"

#for5
? confirmed==1:goto "Barrage"
? confirmed==2:goto "Retry"
~0.5
goto "for5"

#retry

player sidechat "Negative base, attempting to relay new co-ordinates to you."

Confirmed=0

2 setradiomsg "null"
3 setradiomsg "null"

smokecalled=false

exit

;AT THIS POINT RE-MARK THE MAP AND RADIO AGAIN!
#Barrage

(_this select 0) SideChat _inboundArtmsg

2 setradiomsg "null"
3 setradiomsg "null"

shellssofar=0

#for6
_shel= "laserguidedbomb" CamCreate [(getpos _smokey select 0) +(random 100), (getpos _smokey select 1) + (random 100), 200]

shellssofar=shellssofar + 1

?shellssofar>=shelllimit: (_this select 0) SideChat _Endmsg;goto "delay"

~Random 5

goto "for6"

#delay

~120

smokecalled=false

and another thing - the actual barrage works great on flat areas - but on hills the number of explosions goes from about 15 to 4 - for some reason it doesnt like hills - can that be sorted?

and, just if it cud be done, is there anyway of adding that arty noise just before the shell strikes? that kinda of ripping through the air noise that scares the craphola outa every1

hope u can help :thumbsup:
Proud Member of the Volunteer Commando Battalion

Gameer_77

  • Guest
Re:Help with arty script
« Reply #1 on: 10 Jan 2003, 13:02:15 »
Mmmm, this script looks awful familiar. ;D

I don't know, but you can try making the height for the smoke and the height for the shells the same. The wind could be blowing it off course. (Try making it a low number like 200)

If it is the same thing i helped you out on about 4 months ago, then why don't it work now? ??? :P

Cheers

Gameer

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Help with arty script
« Reply #2 on: 10 Jan 2003, 18:24:42 »
it is indeed...

ive been told to change the 'random 100' numbers to lower ones - hopefully that shud work...

it worked fine on desert island, but as soon as u apply it to terrain it goes bonkers  ::)
Proud Member of the Volunteer Commando Battalion

Gameer_77

  • Guest
Re:Help with arty script
« Reply #3 on: 10 Jan 2003, 19:19:37 »
OK...I gotta solution, but it ain't glamorous ;D

Basically, i just used trial and error and it's near enough on the marker, though you may wanna adjust it pending...

To do so, just mess around with this bit:

Code: [Select]
_smokey= "SmokeShellRed" camCreate [userMarkerX,userMarkerY - 160,300]
(It's the '- 160' bit your looking at ;))

Code: [Select]
_colour = "SmokeShellRed"
_startmsg = "Send coordinates for fire mission, over"
_inboundmsg = "Acknowledged, smoke rounds inbound, out"
_endmsg = "Rounds complete, out"
_smokecalledmsg = "Fire mission in progress, wait out"
_confirmMsg= "Can you confirm the artillery co-ordinates?"
_inboundArtmsg = "Acknowledged, smoke rounds inbound, out"
shelllimit= 30

? smokecalled :  (_this select 0) SideChat _smokecalledmsg; exit
smokecalled = true

_smokeArr = units group (_this select 0)
"RemoveAllWeapons _x" foreach _smokeArr


_tmp = 0
#for3
(_smokeArr select _tmp) disableAI "move"
? _tmp < count _smokeArr : _tmp = _tmp + 1; goto "for3"

? _startmsg != "null" : (_this select 0) SideChat _startmsg

; wait until the player has set a user marker
userMarkerSet = false
@userMarkerSet

? _inboundmsg != "null" : (_this select 0) SideChat _inboundmsg

_salvos = _this select 1
? _salvos == 0 : hint "Invalid number of salvos. Must be greater than 1."; exit

_startPos = GetPos (_this select 0)
userMarkerY = userMarkerY + 150

_salvocount = 1
#salvoloop

~4

_tmp = 0
#for2

_randx = RANDOM 1
_tmprndx = RANDOM 1
_randy = RANDOM 1
_tmprndy = RANDOM 1
? _tmprndy < 5 : _randy = _randy * -1
? _tmprndx < 5 : _randx = _randx * -1

_smokey= "SmokeShellRed" camCreate [userMarkerX,userMarkerY - 160,300]

;? _tmp < count _smokeArr : _tmp = _tmp + 1; goto "for2"

~9

;? _salvocount <= _salvos : _salvocount = _salvocount + 1; goto "salvoloop"

? _endmsg != "null" : (_this select 0) SideChat _Confirmmsg

2 setradiomsg "Affirmative"
3 setradiomsg "Negative"

#for5
? confirmed==1:goto "Barrage"
? confirmed==2:goto "Retry"
~0.5
goto "for5"

#retry

player sidechat "Negative base, attempting to relay new co-ordinates to you."

Confirmed=0

2 setradiomsg "null"
3 setradiomsg "null"

smokecalled=false

exit

;AT THIS POINT RE-MARK THE MAP AND RADIO AGAIN!
#Barrage

(_this select 0) SideChat _inboundArtmsg

2 setradiomsg "null"
3 setradiomsg "null"

shellssofar=0

#for6
_shel= "shell120" CamCreate [(getpos _smokey select 0) +(random 40), (getpos _smokey select 1) + (random 40), 200]

shellssofar=shellssofar + 1

?shellssofar>=shelllimit: (_this select 0) SideChat _Endmsg;goto "delay"

~Random 3

goto "for6"

#delay

~120

smokecalled=false

Copy this over (Or just make a new one if you wanna be safe) the old smokescript.

It has been tested on all the standard islands (Nogova, Koljugev, Malden, Everon and even desert island strangely enough ???) and hits it almost spot on.

OK?

Cheers

Gameer
« Last Edit: 10 Jan 2003, 19:22:21 by Gameer »