Here is all the code and stuff you'll need.
I'm so happy I figured this out after trial and error.
Player (Soldier, West)
Init: this addEventHandler ["fired",{_Missile = nearestObject [vehicle(player), _this select 4];[_missile] exec "OICW.sqs"}]
OICW.SQS
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
#fired
_Missile = ***_this select 0
_BigGun = "Shell73" createvehicle getpos _missile
_BigGun setvelocity (velocity _missile)
dir=getDir(_Missile)
_BigGun setdir dir
goto "alivechk"
#alivechk
max=player distance _BigGun
?(max == range) : goto "fuze"
?(max > range) : goto "fuze"
~0.001
goto "alivechk"
#fuze
Hint format["Debug: Range %1 reached!",max]
Fuze = "FxExploGround1" camcreate getpos _BigGun
end
[/QUOTE]
Range?: Range is the variable that is manually imputted for the 20mm round to burst. You must make a game logic defining range (case sensitive) to a number. I recommend 200. Range is measured in meters.
How do I increment range?: I had made two radio triggers that either decreased or increased the value of range by 25.
For those who don't know and probably thinking "Is this guy a moron? And why does he keep spamming the bloody message board?!@!@"
First off, this script is meant to emulate the OICW's 20mm grenade launcher. For those who don't know, The M29 OICW features a 20mm modular grenade launcher which uses electronic shells, the scope on the weapon has a rangefinder which calculates the range using a laser and then tells the shell how to explode (the actual method is how many spins the shell does)
This is no where near perfect. Example? When a shell explodes and the debug information appears, it'll usually be 100 meters off to where you set it (depending on where you're standing). Why?
You may be standing on hill\depression.
You may be firing up\down.
Slight error in the script's timer (0.001)
All which lead to this large error.
(For compairison, the real OICW has a range of error of 1 meter at 1000m)
While not perfect, it's a start.
This isn't some quake weapon (it isn't meant to have 30 shots) but just beta testing it out.
Another issue is, the bullet still explodes when it hits soilds.
Real OICW doesn't do this.
For a challange in it's accuracy, put a bunch of soldiers into a house and try to get level with windows (this way if the airburst doesn't work while directly inside the house, nobody dies and it flys out the other parallel window).
See how many soldiers you can get with an airburst.
Well, sorry for this long post, all the spamming, etc, but I actually got a project done within a short ammount of time.
Post comments, complaints, etc.
Thanks to all helpers, people on the boards, Uiox's m16 to shell125 example to give me new insight to using getvelocity\setvelocity.
I'm not sure how real gun's and addons are made (using same .sqs format & scripting) but if so, this is a step in the right direction.
With luck, OFP will be the first game which has a fully working OICW 20mm grenade launcher.
edit: a typo of an old command I deleted in script (for camera)
Godspeed and goodnight everybody.
HOME 
Reply With Quote


