OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: OFPfreak on 12 Dec 2005, 10:48:34
-
Hey guys, I made an artillery script modified from Bedger's code and the "shells" only go up and down (not the z axis up and down but the y axis up and down!) Here's the code:
_x = getpos target select 0
_y = getpos target select 1
_dir = getdir target
_randomdir = random 360
_i = 0
#create
_r = random 500
target setdir _randomdir
_bang = "maverick" camcreate [_x + (_r*sin(dir)), _y + (_r*cos(dir)), 400]
_i = _i + 1
#godown
_bang setvelocity [0,0,-550]
? not (alive _bang) : goto "create"
?not (_i>=20):goto "godown"
exit
-
Im not very experienced whit the SIN/COS thing.. but.. what are they doing there??? =P and have you added some delay to the script??
and.. what all the setdir random 360 means??? =P
Saludos
-
So what's the problem? Apart from the fact that you use dir instead of _dir in the script, and the check for _bang being alive will always be true assuming alive works in this case.
-
Is there a specific reason why you are creating maverick missles? I believe when you camcreate a missle, it will propel itself forward like when it is fired. If you just want shells to drop from the sky, use "shell120" or another class.
My suggestion however would be to use Fision's Generic Artillery script (http://www.ofpec.com/editors/resource_view.php?id=193). The wheel has already been invented, so you don't have to make your own script :). It's the script I've always used. And it is generic, yet customizable so you can get exactly the type of barrage you need.
-
The missile gives the trail effect and it reminds me a bit of battlefield 2. I have not added a loop but it doesn't lag much either. I added a a 360 dir thingy too so maybe the direction of the target changes (logic) and it actually fires more than 2 ways but it seems to still fire 2 ways (north and south). Yes the checking if it's alive works because they do come down after each other. Oh and I've updated my script and it doesn't work anymore! What have I done wrong!?
[side player, "hq"] sideChat "Artillery firing! ETA. 30 seconds!"
_pos = _this select 0
"targmarker" setmarkerpos _pos
target setpos (getpos _pos)
~33
_x = getpos target select 1
_y = getpos target select 2
_dir = getdir target
_i = 0
#create
_r = random 100
_bang = "maverick" camcreate [_x + (_r*sin(_dir)), _y + (_r*cos(_dir)), 400]
_i = _i + 1
#godown
_bang setvelocity [0,0,-550]
? not (alive _bang) : goto "create"
?not (_i>=20):goto "godown"
exit
The shells come down alright but somewhere in the sea to the west! What have I done wrong with the _pos? Is there any variable that determines the map click? e.g. MapClick :P?
-
I fixed it :D! I created 4 scripts (all the same except they get _bang1 to _bang4 and target1 to target4.
I placed the 4 logic targets on top of each other facing these directions:
0 and 90 for the first two and 45 and 315 for the last two. It's awesome!
edit: It isn't random enough :(! They keep coming down on almost the same spots!
-
If you want the artillery randomly exploding in an area with a radius of 100 meters, do something like this:
_bang = "maverick" camcreate (random 100 - random 100), (random 100 - random 100), 400]
Or if you want the area with a diameter of 100, do something like this:
_bang = "maverick" camcreate (random 50 - random 50), (random 50 - random 50), 400]
Naturally the shells will be more concentrated in the middle, but they should be quite randomnized.
-Pilot
-
Does that actually make the shells come down at the "target"? I don't see it anywhere.
-
No, the shells should fall on their own accord. My code simply randomnizes the footprint the shells will create.
-Pilot