OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: GI-YO on 03 Feb 2005, 22:44:22
-
I want to simulate minigun fire from a spooky gunship (Nam era). I was thinking of placing a gamelogic and camcreating bullets on that, I would want to have the bullets in a circul about 30 meters around the GL with a bullets made every 1/4 of a meter. How could this be scripted or done? Hope you can understand what I mean. Thanks in advance.
GI-YO
-
Cant help with the scripting.. ask one of the pro's
But this (http://www.ofpec.com/editors/browse.php?browseon=&browsewhat=2&category=2&subcategory=2_-1&numreturn=25&displayformat=0&ofpv=1&searchstring=chain&searchwhat=1&searchlevel=0&searchopts=") might be off help to you.
You can camcreate the bullets, if possible, and set their direction and velocity towards the unit.
Rhys
-
thanks rhysduk, maybe its me being stupid but I cant see which script your pointing out to me, is it Easy AI Artillery (UA Compatible) by General Barron?
Thanks for the help.
GI-YO
-
Untested, but maybe a step towards what you're looking for:
; [marker object,time (seconds),radius (metres),rate of fire (rounds per min)] Exec "minigun.sqs"
_markerobj = _this Select 0
_firetime = _this Select 1
_strikeradius = _this Select 2
_rateoffire = _this Select 3
_strikex = GetPos _markerobj Select 0
_strikey = GetPos _markerobj Select 1
_delay = 60 / _rateoffire
_stoptime = time + _firetime
#fire
; POI
_angle = random 360
_radius = random _strikeradius
; swap with either to taste:
; _radius = _strikeradius * (random 1)^2
; _radius = _strikeradius * sqrt (random 1)
_strike = "Bullet7_6W" CamCreate [_strikex + (_radius * Sin _angle),_strikey + (_radius * Cos _angle),2]
_strike SetVelocity [0,0,-500]
~_delay
?(time > _stoptime): exit
Goto "fire"
exit
These are for random scatters - might look wrong if it's too geometric (also more maths and loops).
Use GetMarkerPos if you mark with markers instead of objects.
Bullets appear 2m above ground so they have a chance of killing something if that's required.
-
Awesome i'll have a play and see what it looks like, thanks ACF! :wave:
GI-YO
EDIT :help:
Im getting the error "_strike = "Bullet7_6W" CamCreate [_strikex + (_radius Sin _angle),_strikey + (_radius Cos _angle),2]: error unkown operator Sin"
Im calling the script like this [target, (30), (40), (1000)] Exec "minigun.sqs" and target is an empty jeep.
Im know scripter so i cant see whats wrong with this, any ideas? Thanks for the script and any help recieved.
-
Sorry GIYO,
The "chain" snippet/script by Igor Drukov is what i was pointing you too.
Never call a script like this:
[target, (30), (40), (1000)] Exec "minigun.sqs".. Instead use quotation marks like so:
[target, "30", "40", "1000"] Exec "minigun.sqs"
Seeing as they are numbers, i dont think you need teh quotation marks there. Theres a certain value you need to quotate, like a string for example.
Rhys
-
Ah-ha (sorry!)
Missed out the "*" in:
_strike = "Bullet7_6W" CamCreate [_strikex + (_radius * Sin _angle),_strikey + (_radius * Cos _angle),2]
Had my trig head on.
Regarding the execution:
[myjeep, 30, 40, 1000] Exec "minigun.sqs"
Sorry - brackets in the comment were to state the units. Calkling a jeep 'target' might be a problem in itself as I think it's a class name.
Any better?
-
Thanks for all the help I'll have to check this out tomorow now cause i have to go to work soon :(. But thanks again!
GI-YO
-
right then i'm getting another error now :
'_strikex = _markerobj Select 1[ # ]':error select: type object, expected array
Can anyone see whats happening with this? Thanks for all the help so far this script looks awesome!:thumbsup:
GI-YO
-
_strikex = GetPos _markerobj Select 0
_strikey = GetPos _markerobj Select 1
Really should eat my lunch OR script, not try to multitask!
-
To atone for my sins - a tested version reposted for clarity:
; minigun.sqs
_markerobj = _this Select 0
_firetime = _this Select 1
_strikeradius = _this Select 2
_rateoffire = _this Select 3
_strikex = GetPos _markerobj Select 0
_strikey = (GetPos _markerobj Select 1) - 6
_delay = 60 / _rateoffire
_stoptime = time + _firetime
#fire
; POI
_angle = random 360
; _radius = random _strikeradius
; swap with either to taste:
_radius = _strikeradius * (random 1)^2
; _radius = _strikeradius * sqrt (random 1)
; _strike = "Bullet12_7W" CamCreate [_strikex + (_radius * Sin _angle),_strikey + (_radius * Cos _angle),3]
_strike = "Bullet7_6W" CamCreate [_strikex + (_radius * Sin _angle),_strikey + (_radius * Cos _angle),3]
_strike SetVelocity [0,500,-300]
~_delay
?(time > _stoptime): exit
Goto "fire"
exit
; Syntax:
; [marker object,time in seconds,radius in metres,rate of fire in rounds per min] Exec "minigun.sqs"
; notes
; bullets 'fired' at 30 degree angle to maximise chance of hitting something,
; point of aim is offset from target object to compensate.
; _radius = random _strikeradius - linear distribution
; _radius = _strikeradius * (random 1)^2 - concentrates fire on point of aim
; _radius = _strikeradius * sqrt (random 1) - even spread across area
If 7.62 doesn't cut the mustard, swap with the 12.7! As it's posted it defaults to a concentrated burst. Just remember troops won't react to camcreated rounds.
-
:thumbsup: eggselent stuff :thumbsup:. You should put this script into the ed department if you havent already, the world needs this kind of thing, especialy those 'Nam missions. Keep up the good work.
GI-YO
EDIT
just given this a test. one word. awesome just what i was looking for. i recomend this script to anyone who wants addon free gunship support.