Home   Help Search Login Register  

Author Topic: i need a good artillery script  (Read 2641 times)

0 Members and 1 Guest are viewing this topic.

Offline Jffsieg

  • Members
  • *
i need a good artillery script
« on: 16 Mar 2007, 03:23:19 »
Im working on a mission in paraiso, your inside the city when the enemy begins to attack you with artillery, I tried this old script from OFP but for some reason its not working in arma:





;BarrageArea.sqs - script to Barrage a Triggered area
;make a tigger
;call this script on activate or deactivate: 
;[ID,Type,#shells,Xrange,Yrange,starting height,minimum time, variable time] exec "tripobject.sqs"
_tag    = _this select 0
_objtype = _this select 1
_amount    = _this select 2
_randomX = _this select 3
_randomY = _this select 4
_height  = _this select 5
_timemin = _this select 6
_timev    = _this select 7
_offsetX  = _randomX / 2
_offsetY  = _randomY / 2
_height  = _this select 4
_tX   = getpos _tag select 0
_tY   = getpos _tag select 1
_tZ   = getpos _tag select 2
#Loop
? (_amount < 1 ) : exit
_obj = _objtype CamCreate[((_tX+Random _randomX)-_offsetX),((_tY+Random _randomY)-_offsetY),_tZ+_height]
_amount = _amount - 1
~(_timemin+(random _timev))
goto "Loop"






heres the readme for the script:







BarrageArea.sqs - script to Barrage an Area
features:
-uses real shells raining down on the area
-can take out low flying aircraft, if they happen to get hit by an incoming shell
-can see shells coming down when close
-can hear shells coming if your near by
-can adjust starting height of the barrage
   (0 height causes instant explosions, 300 is recommend for realistic shells)
   (                  low flying aircraft beware!         )

-can barrage other game items 
   (some items do not barrage very well, aircraft are interesting though!)
-can adjust the time between shells

To use:
Create a one time trigger and call the script from the activate field.
You can place a text message to be display stating "Incoming Barrage!" in the effects settings
syntax to call script:
[ID,Type,#Shells,Xrange,YRange,StartHeight,min.Time,Var.Time] exec "BarrageArea.sqs"

Exampe with a Trigger called Barrage. 
Activation contains:  (call two different types of shells to make a great show!)
[Barrage,"Heat73",50,50,100,300,0,.7] exec "BarrageArea.sqs";
[Barrage,"Shell73",50,50,100,300,0,.7] exec "BarrageArea.sqs"


ID   = Trigger ID or Unit ID that you want the barrage area centered on
#Shells   = Number of shells to rain down         (50)
Xrange   = is the (a) width of the area to cover      (100)
Yrange   = is the (b) width of the area to cover      (100)
StartHeight = Height that you want the Barrage to start at (300 is a good value, give a little delay)
min.time    = The minimum time between shells      (0)
var.time    = Is the variable time between shells   (.7)

Time value examples;
min.time=0, var.time=1  ->  Will randomly be 0 to 1 second between shells
min.time=1, var.time=2  ->  Will be 1 second minimum + randomly 0 to 2 seconds between shells

Some good values are:
min.time=0, var.time=.7
min.time=.2, var.time=.7




I didnt make this script so i dont know alot about it. But this script worked perfectly in OFP, and I figured it might work in arma,
but it didnt so I was wonderin if anybody knew how to fix this script for arma, or if they had a script of there own which is like this?

Offline Cheetah

  • Former Staff
  • ****
Re: i need a good artillery script
« Reply #1 on: 16 Mar 2007, 15:34:06 »
Could you use the code and /code tags next time you post a large shunk of code? That makes things easier to read, well it does for me. As for the script, you might find it here.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline sharkattack

  • Former Staff
  • ****
Re: i need a good artillery script
« Reply #2 on: 02 Apr 2007, 22:13:25 »
"HOLY SARDINE" - see Shark-Attack meet his match

Offline Jffsieg

  • Members
  • *
Re: i need a good artillery script
« Reply #3 on: 05 Apr 2007, 00:42:07 »
nope thats not what im looking for, I want artillery that dosent need a unit on the map,  its just the shell that is created some 300 feet above the ground.  and it has to hit in random positions every time

Offline D_P_

  • Members
  • *
  • YAY! I'm a lama again! ...oh wait.
    • ArmaAddons
Re: i need a good artillery script
« Reply #4 on: 05 Apr 2007, 00:56:14 »
Maybe this is too easy....Place an object in the editor, name it TARGET and place this in the init:
this exec"bombs.sqs"

Code: [Select]
_i = 0
#loop
? _i >= 50: exit
_bomb = "Sh_125_HE" createvehicle [(getpos TARGET select 0) - 350 + random 700, (getpos TARGET select 1) - 350 + random 700, (getpos TARGET select 2) + 500]
_i = _i + 1
~3
goto "loop"
exit

crude but effective  :dunno:
just setpos & forgetpos!

Offline evilnate

  • Members
  • *
  • werd
Re: i need a good artillery script
« Reply #5 on: 20 Nov 2008, 19:52:38 »
I've been searching both BIS and these forums and haven't found an answer to this. I know it has to be fairly easy. I am looking for something similar to what this guy is wanting. Here's my scenario:

I'm making a MP coop template to create multiple missions on. There are three big "blufor detected by" triggers covering south sahrani one for opfor, indy, and civ.  When a blufor gets spotted by opfor I want artillery to rain down on the "spotted" position right before some paratroopers come in and start searching for the intruders. The indy and civilian triggers will send their own type of reinforcements. This makes the player honestly try to complete objectives without getting detected and keeps re playability interesting.
This is what I have so far, but I can't figure out how I would create or spawn an artillery barrage a few seconds after the player has been spotted. I'm envisioning 15 - 20 large explosions hitting the ground, one at a time, with a radius of 400 meters, every second from the center of _position.
Code: [Select]
;Reinforcement script. Detected by trigger gives location information of where player is spotted.
;Transport helicopters paradrop 3 groups that patrol created marker using kronzky's ups.
?(!isServer) : exit
~.1

;inputs
_trigger = _this select 0
_helo = _this select 1
_home = _this select 2
_troop1 = _this select 3
_troop2 = _this select 4
_troop3 = _this select 5
_troop1L = _this select 6
_troop2L = _this select 7
_troop3L = _this select 9

;get list of trigger activator(s)
_list = list _trigger
;change name of activator to location
_location = _list select 0
;move pre-loaded transport helo to location
_helo doMove (position _location)

;ETA and damage check
#cycle
?(getdammage _helo >= .7):goto "eject"
?(_location distance _helo < 300):goto "eject"
~3
goto "cycle"

;Each group ejects and disassociates it's self from _helo
;every second.
#eject
~0.5
{_x action ["eject",_helo]} forEach units _troop1
{unassignVehicle _x} forEach units _troop1
~1.1
{_x action ["eject",_helo]} forEach units _troop2
{unassignVehicle _x} forEach units _troop2
~1.1
{_x action ["eject",_helo]} forEach units _troop3
{unassignVehicle _x} forEach units _troop3

;A 400X400 marker is created at _location for UPS to work.
~1.1
_marker = createMarker ["hotzone", position _location ]
"hotzone" setMarkerSize [400, 400]

;UPS is called for each group leader.
~0.5
nul=[_troop1L,"hotzone"] execVM "scripts\ups-f.sqf";
~0.5
nul=[_troop2L,"hotzone"] execVM "scripts\ups-f.sqf";
~0.5
nul=[_troop3L,"hotzone"] execVM "scripts\ups-f.sqf";

;Helicopter is told to go to his defined Helipad
~1.1
_helo doMove (position _home)

exit

I was thinking that the code in the OP would be it but it's not?

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: i need a good artillery script
« Reply #6 on: 21 Nov 2008, 05:08:04 »
Well, apart from the fact that you need to remove the line,
Code: [Select]
_height  = _this select 4
that script looks fine (_height is read in twice, the second time using the Y-dispersion rather that the height parameter, which is a mistake)

You should be using something like:
Code: [Select]
[_location,"Bo_GBU12_LGB", 10, 400, 400, 300, 1, 0] exec "BarrageArea.sqs"
(note that it says save the file as "BarrageArea.sqs" but then tells you to exec "tripobject.sqs"; sure you worked that out though)
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline evilnate

  • Members
  • *
  • werd
Re: i need a good artillery script
« Reply #7 on: 21 Nov 2008, 06:43:28 »
Thanks for the advice. After spending my entire day off, i've made a script that i'm very happy with and learned some more about scripting. For now I am going to have the reinforcement script separate from the arty script, and here it is. It seems like I should be able to just have it count cycles instead of doing it "batch file" way, but as you can tell I am still a scripting nub. It would also help if "Random" included negative values... But it should also do what the OP was wanting if he's still interested.
Code: [Select]
;; Artillery script by evilnate
;; Make a detected by trigger and execute this script when it activates.
;;Usage [Triggername,"Shellname",maxArea#,maxHeight#,Frequencyinseconds#] exec "scripts\arty.sqs"

?(!isServer) : exit
~.1

_trigger = _this select 0
_ammo = _this select 1
_area = _this select 2
_height = _this select 3
_timing = _this select 4

;Store location array (position data) into _location
~0.1
_list = list _trigger
_location = _list select 0

~15.0
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) + (_ranx), (getpos _location select 1) + (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) + (_ranx), (getpos _location select 1) - (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) - (_ranx), (getpos _location select 1) + (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) - (_ranx), (getpos _location select 1) - (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) - (_ranx), (getpos _location select 1) + (_rany),(getpos _location select 2) + (_ranz)]
~_timing
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) + (_ranx), (getpos _location select 1) + (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) + (_ranx), (getpos _location select 1) - (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) - (_ranx), (getpos _location select 1) + (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) - (_ranx), (getpos _location select 1) - (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) - (_ranx), (getpos _location select 1) + (_rany),(getpos _location select 2) + (_ranz)]
~_timing
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) + (_ranx), (getpos _location select 1) + (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) + (_ranx), (getpos _location select 1) - (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) - (_ranx), (getpos _location select 1) + (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) - (_ranx), (getpos _location select 1) - (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) - (_ranx), (getpos _location select 1) + (_rany),(getpos _location select 2) + (_ranz)]
~_timing
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) + (_ranx), (getpos _location select 1) + (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) + (_ranx), (getpos _location select 1) - (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) - (_ranx), (getpos _location select 1) + (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) - (_ranx), (getpos _location select 1) - (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) - (_ranx), (getpos _location select 1) + (_rany),(getpos _location select 2) + (_ranz)]
~_timing
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) + (_ranx), (getpos _location select 1) + (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) + (_ranx), (getpos _location select 1) - (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) - (_ranx), (getpos _location select 1) + (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) - (_ranx), (getpos _location select 1) - (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) - (_ranx), (getpos _location select 1) + (_rany),(getpos _location select 2) + (_ranz)]
~_timing
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) + (_ranx), (getpos _location select 1) + (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) + (_ranx), (getpos _location select 1) - (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) - (_ranx), (getpos _location select 1) + (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) - (_ranx), (getpos _location select 1) - (_rany),(getpos _location select 2) + (_ranz)]
~0.1
_ranx = random _area
_rany = random _area
_ranz = random _height
_ammo createVehicle [(getpos _location select 0) - (_ranx), (getpos _location select 1) + (_rany),(getpos _location select 2) + (_ranz)]

exit

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: i need a good artillery script
« Reply #8 on: 21 Nov 2008, 18:06:18 »
random doesn't need negatives. See how the original poster manages it by calculating an offset to give a range of -_random/2 to +_random/2:
Code: [Select]
_offsetX  = _randomX / 2
_offsetY  = _randomY / 2

_obj = _objtype CamCreate[((_tX+Random _randomX)-_offsetX),((_tY+Random _randomY)-_offsetY),_tZ+_height]

If you are going to get anywhere, try to learn how to use loops, rather than endlessly repeating the same code. Ideally, new people should be learning SQF, not SQS, which makes looping easier in my opinion (SQS is obsolete but is still supported for backwards compatibility and because a lot of old-timers already know SQS and don't want to learn SQF ;P).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: i need a good artillery script
« Reply #9 on: 21 Nov 2008, 18:14:48 »
Quote
(SQS is obsolete but is still supported for backwards compatibility and because a lot of old-timers already know SQS and don't want to learn SQF ;P)

OUCH!!  i resemble that remark :P.
 I would love to have single handed proof that over use of sqf affects FSMs speed efficiency and overall AI behaviour (reason why bis dont over sqf int there missions and campaignsIMO) but it maybe my old stuck in my ways attitude, however i bow to efficiency of sqf in 90% of the time i will never subscribe to sqs being obsolete ;).
 apologies for offtopic but it did need a reply .
 
so i can add some useful info , i believe on BIS forums the guy from FDF released his source code from the ofp artillery they used.

« Last Edit: 21 Nov 2008, 18:17:17 by DeanosBeano »
I love ofp

Offline evilnate

  • Members
  • *
  • werd
Re: i need a good artillery script
« Reply #10 on: 23 Nov 2008, 17:50:02 »
@Spooner

I see your quoted code but I guess I don't see how it's working. It looks like it's taking a random offset then dividing it by 2, after that my brain looks at the CamCreate line and goes blank. I also wanted to use a loop but I figured that I needed to to count how many times it creates a artillery shell and then check to see if the count criteria has been met.

I do want to learn SQF but I've been learning this by myself so it's taking forever, OFP and ARMA are the only things that I've tried coding with. Anyway, I really appreciate the constructive criticism and appologize in advance if my questions or scripting examples seem weak. Hopefully I'll get it right soon.
« Last Edit: 23 Nov 2008, 18:05:11 by bedges »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: i need a good artillery script
« Reply #11 on: 23 Nov 2008, 21:14:44 »
_randomX is the width of the target zone and _randomY is its height. Thus, you want to create bombs somewhere between (x - width/2) and (x + width/2) and between (y - height/2) and (y + height/2). As you say, you can't have a negative result from random, so you first add a number from 0 to the width (random _random X), then you reduce it by half the width to offset the range and then This gives the final ((_tx + random _randomX) - _offsetX) which is equivalent to ((_tx + random _randomX) - (_randomX/2)). Same thing for the Y value.

e.g. to get a random number between +10 and +20, you could use (10 + random 10), but you could also use its centre value and use an offset (15 + (random 10) - (10/2)).

Hmm, lots of words to explain a simple concept. Not sure if that helps...
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Ext3rmin4tor

  • Members
  • *
Re: i need a good artillery script
« Reply #12 on: 26 Nov 2008, 11:01:54 »
Once I made this (it's for ArmA only, it doen'st work on OFP). It's very simple but effective. Usage infos are commented in the first lines of the script

Code: [Select]
; Arma bombing script
; USAGE [Position, Diameter, Bomb number, Bomb burts number, Waiting time] exec "artillery.sqs"
; Position defines the center of the bombed area
; Diameter defines the diameter of the bombed area
; Bomb number defines the number of shell salvos fired by the artillery team
; Bomb burst number defines the number of shells fired for each salvo
; Waiting time defines the max waiting time between two shots
; NOTE: the total ammount of bomb is given by: Bomb Number * Bomb Burst
; Initializing variables
_pos = _this select 0
_diameter = _this select 1
_num = _this select 2
_burst = _this select 3
_t = _this select 4
_i = 0
#salvoLoop
_j = 0
#bombLoop
"Sh_105_HE" createVehicle [(_pos select 0) - _diameter/2 + random_diameter, (_pos select 1) - _diameter/2 + random_diameter, _pos select 2]
_j = _j + 1
~random 1.5
?(_j < _burst):goto "bombLoop"
_i = _i + 1
~_t
?(_i < _num):goto "salvoLoop"
exit
How can you shoot women and children?
Easy! Ya' just don't lead'em so much! Ain't war hell?!!