OmniMax 0 Posted January 18, 2004 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 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. Share this post Link to post Share on other sites
KamikazyWar 0 Posted January 18, 2004 Cool...BTW the OICW aint qualified as a grenade launcher since the bullets that are qualified as exlosives are fillet with C4...so its a gun that shoots bullets from 2 different barrels...but it can use ammo with explosive compound. Think I'll go test this... Share this post Link to post Share on other sites
OmniMax 0 Posted January 19, 2004 Yeah, I know it fires from two barrels but I've never modeled, .cpp coded a gun before, I'm not even sure how to begin, but this is certainly a step in the right direction. I recommend using the SVD with analog range finder to burst over infantry. Or use M60 to shoot down planes, it's quite funny. I'll have a practice mission soon up on a site, so stay tuned, folks. Share this post Link to post Share on other sites
DBR_ONIX 0 Posted May 11, 2005 Theres a OCIW addon you know INQ's site has it (Search on OFP.info for INQ, in news, has the site somewhere) - Ben Share this post Link to post Share on other sites
Big Dawg KS 6 Posted May 12, 2005 Very interesting script, but, honestly, I don't get it, why are you using a BMP Sabot? Hmm, oh whatever, anyways, can I suggest some improvements? unit addeventhandler ["fired",{_this exec "OICW.sqs"}] <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> #fired _Unit = _this select 0 ? _this select 4 != "BulletSingle" : exit ; BulletSingle is an example, it depends on what ammo type ; you are using as the false 20mm round _Missle = nearestobject [_unit,_this select 4] _BigGun = "Grenade" createvehicle getpos _missile _BigGun setvelocity (velocity _missile) dir=getDir(_Missile) _BigGun setdir dir #alivechk ?! (alive _BigGun) : exit max=_BigGun distance _unit ?(max >= range) : goto "fuze" ~0.001 goto "alivechk" #fuze Hint format["Debug: Range %1 reached!",max] Fuze = "FxExploGround1" camcreate getpos _BigGun ; Not sure about this part, I was under the impression that ; FXExploGround1 is just a visual explosion effect? ; If that is the case you will need to use a real object ; with a fire geo or geo LOD to block the round in midair, ; causing it to air burst... exit There are of course other things that could be done to make the entire thing use local variables instead of public ones, but most of it would require the use of custom addons... Hope that helps... Â Share this post Link to post Share on other sites
InqWiper 0 Posted May 12, 2005 Quote[/b] ]Posted on Jan. 19 2004,01:30 Quote[/b] ]Posted on May 11 2005,20:12 Share this post Link to post Share on other sites
Big Dawg KS 6 Posted May 12, 2005 Whew, I didn't even realize that... Share this post Link to post Share on other sites
OmniMax 0 Posted May 14, 2005 Hi. I'm not sure Placebo will like you digging up year old threads, however I will provide a blow-by-blow comment for the script. this addEventHandler ["fired",{_Missile = nearestObject [vehicle(player), _this select 4];[_missile] exec "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 is the "beam" of which is stored by getnearestobject ; which is called in eventhandler "fired" _Missile = _this select 0 ;_BigGun is the "grenade" that follows the trajectory of _missile _BigGun = "Shell73" createvehicle getpos _missile ; _BigGun is created to where _missile is inside it _BigGun setvelocity (velocity _missile) ;point the same direction as _missile dir=getDir(_Missile) _BigGun setdir dir ;commense to the fuze goto "alivechk" #alivechk ;this script simply is the ranged fuze max=player distance _BigGun ?(max == range) : goto "fuze" ?(max > range) : goto "fuze" ~0.001 goto "alivechk" #fuze ;debug information used during developement Hint format["Debug: Range %1 reached!",max] ;put a small object infront of _BigGun (Shell73) to make it ;explode! Fuze = "FxExploGround1" camcreate getpos _BigGun ;oops, mistake, end should be exit! end Basicly, when you shoot your gun, you get the nearest object (which since tied to fired eventhandler) will always be the bullet from the gun you fired. It spawns a big Shell73 to where the bullet from the gun is INSIDE the shell, Shell73 assumes the same direction and projectory of the bullet and then the fuze kicks in. It's very crude, however, you can skip the messy projectile part AND the fuze part if you could make a custom projectile. I have asked once or twice on the boards in the addon section on how to code a projectile as an addon, but alas, I couldn't get any answers. The reason I say is bypass the projectile part and the fuze part is because you could make an addon which assumes a semi-straight projectory (similar to the ones OICW fires, forget the exact model names) and since we can define it's speed in the .cpp or addon, all we need to do is a simple math calculation and tell it when to blow up in the time - speed - distance ratio/relation. Then we could actually customize each type of shell, fragmentation and HE and all, and attempt to make real throwable fragmentation grenades. If I remember correctly, Suma said it wasn't possible, but within a addon .pbo, you could simply add a script that spawns many bullets flying from the grenades epicenter. Mind you, not as many bullets from a real fragmentation device (~100-200) but enough to be fairly realistic. If you have any information about coding projectiles at the addon level (in the form of "OFP C++" .cpp) please PM me as I would love to finish what I have started so long ago. Then, OFP would be the first game with a working M29 OICW. Then of course, we could move to the similiar working technologies: FN2000 General Dynamics 12.7mm / .50 XM312 There is another american one which is a standalone 25MM and a few asian OICW clones that are in development, but not much is known about them execpt maybe a snapshot. Kegetys has done some work on projectiles (his RPG-7 and variants that have been used by the very execelent FDF mod blow up after ~700 meters, just like in real life) but he is busy with trying to get external save support and such for OFP at the moment. Greetings. Share this post Link to post Share on other sites
Grendel 0 Posted May 14, 2005 Hey again everyone (hope someone remembers who I am lol) I actually just started messing around again and it just so happens I made a script for 25mm airburst fuzed ammo (I did it to tweak a new XM109 Addon I found the other day on the CZ site) It is rather involved (multiple scripts due to SOFLAM compatibility and such), and some constants would have to be changed to work for different muzzle velocities of different addons, but it is a working beta right now. You can use a laser designator (BAS_Soflam) to range to the target, and then switch to the XM109 (or whatever weapon really), and the fuze is automaticaly set for the 25mm munition. I have also come up with a proprietary targeting system as well that would take a while to explain, but basically works with the (player knowsabout _unit >0) and some drop created "HUD" effects. Trust me it works Anyway, the script uses the good ol' fired eventhandler, but it also uses the getheightASL .SQF to basically form the A and B sides of a right triangle, then a simple sqrt(A^2+ B^2) to find the length of C (the actual range from player to target). It then calculates the time of flight (in fractions of a second) until the round would reach that range, deletes the fired round, camcreates two JAM M433 grenades, and some nice Drop created 'airburst" effects. I have tested it out to 1000m on .intro island and it is ahem...VERY effective. If anyone is interested I can upload it to say...OFPEC script submissions or e-mail it to you. BTW, expect a suprise in a week or so...dum dum DUUUUUMMMM!!! Share this post Link to post Share on other sites
OmniMax 0 Posted May 15, 2005 Your method is way more fanicer and efficient than mine and I'm a bit jealous! (I'm not too good at the maths) (laser glockenspiel) I understand about the laser aimer, however is it able to spawn a laser with a specific name or atleast randomize it's name so that multiple M29 OICW platforms could be used and scanned within a giant trigger and a simple getdistance? Actually, would it be possible to when in creation of the laser aimer to already know it's name without doing a giant trigger scan method (save cycles and bandwidth)? (projectory glockenspiel) While I like your method (very clever, btw) the real OICW works more on a simple time equation which would be simplified since OFP isn't superduper-dynamic like the real world. Already knowing it's speed (as determined by the .cpp) all you have to do is make a ratio of range to time (time in flight) and you're all set. (other glockenspeil) For the FN2000, I don't think it's really possible since you can't get the z heading of a unit. (for those who don't know, FN2000 range finds, and the scope tells you at what angle to fire -- for greater accuracy) Share this post Link to post Share on other sites
Grendel 0 Posted May 15, 2005 OmniMax, I think the multiple laser issue (multiplayer I assume) could be problamatic, but possible. I'll work on it. on the "projectory glockenspiel", that is pretty much how it works already. Some adjustments have to be made as the fired eventhandler doesn't pick up the fired bullet right away (after about 50m) and this effects the pure range/velocity=TOF calculation a bit. As you can see, this is only the fourth time I have posted on the official forum (used to be an exclusive OFPEC forum surfer) and I can't see how to attatch files to the post....so I could e-mail you an example mission if you would like to see how it works. I can also work something out about an adjusted aimpoint as well, believe it or not. Share this post Link to post Share on other sites