Messiah 2 Posted March 7, 2006 i recently made a flare gun, and using examples from working configs, created my own flare gun (sidearm) now, it works ingame, it fires a 'round' but then no flare is created above... what am i doing wrong? I'm sure i wrote everything correctly. The relevant part of the config: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> class CfgAmmo { class Default{}; class BulletSingle:Default {}; class BulletSingleW: BulletSingle{}; class Grenade: Default{}; class MortarShell: Grenade{}; class AT3 : Default {}; class CarlGustav : AT3{}; class UKF_LAW80Rocket : CarlGustav { hit=820; indirectHit=290; indirectHitRange=3.100000; minRange=50; minRangeProbab=0.99; midRange=590; midRangeProbab=0.99; maxRange=620; maxRangeProbab=0.01; thrustTime=0.200000; thrust=1200; maxSpeed=156; initTime=0; soundHit[]={"Explosions\explosion_at3",100.000008,1}; soundFly[]={"weapons\rocketflying",0.010000,2}; soundEngine[]={"objects\noise",0.001000,1}; cost=5000; }; class AA : CarlGustav {}; class ukf_JavelinAmmo : AA { model="\ukf_ukweps\jav\ukf_javR.p3d"; hit=1000; indirectHit=500; indirectHitRange=10; ThrustTime=5000; thrust=50; initTime=0.6; maneuvrability=4.4; canLock=LockYes; airLock=true; irLock=true; laserLock=true; soundHit[]={"\ukf_ukweps\jav\jav_ground.wss",db25,1}; SoundHitArmor1[]={"\ukf_ukweps\jav\jav_arm1.wss",db30,1}; SoundHitArmor2[]={"\ukf_ukweps\jav\jav_arm2.wss",db30,1}; SoundHitArmor3[]={"\ukf_ukweps\jav\jav_arm3.wss",db30,1}; hitArmor[]={soundHitArmor1,0.33, soundHitArmor2,0.33, soundHitArmor3,0.33}; soundFly[]={"\ukf_ukweps\jav\javelin_fly.ogg",db18,1}; }; class ukf_556blank: BulletSingle { access=2 hit=0; indirectHit=0; //non HE indirectHitRange=0; visibleFire=14; audibleFire=14; visibleFireTime=2; tracerColor[]={0,0.000000,0.00000,0}; soundFly[]={}; minRange=1; minRangeProbab=1; midRange=1; midRangeProbab=1; maxRange=1; maxRangeProbab=1; }; class ukf_White_Flare : Grenade { hit=10;indirectHit=6;indirectHitRange=3.0; cost=100; simulation=shotIlluminating; simulationStep=0.050; explosive = False; soundHit[]={,0,1}; lightColor[] = {1, 1, 1, 0}; }; class ukf_Red_Flare : ukf_White_Flare { lightColor[] = {1, 0, 0, 0}; }; }; ///Weapon definitions; class CfgWeapons { class Default {}; class MGun: Default {}; class Riffle: MGun {}; class M16:Riffle{}; class HandGunBase: Riffle {}; class ukf_paraflareR : Handgunbase { access=2; scopeWeapon=2; scopeMagazine=2; aiRateOfFire=0.500000; aiRateOfFireDistance=50 model="\ukf_ukweps\flare\ukf_flare"; modelOptics=""; picture="\ukf_ukweps\flare\flareRicon.pac"; displayName="Para Flare (Red)"; displayNameMagazine="Flare"; shortNameMagazine="Flare"; count=1; weaponType=2; magazineType=32; magazineReloadTime=3; autoReload=0; soundContinuous=0; sound[]={}; drySound[]={}; reloadMagazineSound[]={}; magazines[] = {ukf_red_flare}; backgroundReload=0; autoFire=0 dispersion=0.002000; multiplier=1; burst=1; reloadTime=5; }; class ukf_paraflareW : ukf_paraflareR { model="\ukf_ukweps\flare\ukf_flareW"; displayName="Para Flare (White)"; magazines[] = {ukf_white_flare}; picture="\ukf_ukweps\flare\flareWicon.pac"; }; class ukf_White_Flare: ukf_paraflareW { scopeWeapon=0; scopeMagazine=2; displayNameMagazine= "Para Flare (White)"; picture="\ukf_ukweps\flare\flareWAicon.pac"; initSpeed=80; }; class ukf_Red_Flare: ukf_paraflareR { scopeWeapon=0; scopeMagazine=2; displayNameMagazine= "Para Flare (Red)"; picture="\ukf_ukweps\flare\flareRAicon.pac"; initSpeed=80; }; on the same note, i was wondering if it would be at all possible to create a working paraflare? Say using a dummy ammo, which after firing, cam creates a parachute above the player, that floats down with a flare? not sure on the application? Share this post Link to post Share on other sites
h - 169 Posted March 7, 2006 Quote[/b] ]if it would be at all possible to create a working paraflare? Say using a dummy ammo, which after firing, cam creates a parachute above the player, that floats down with a flare? Probably, but just not with the 'real' OFP flare... Afaik the flare has hardcoded bits that make it illuminate after some time it was created (or shot) and so you would need to use something like a fireplace object to simulate the flare... But then there's the problem of fireplace objects not 'accepting' setVelocity so you would need to do it with a fast setPos loop and that's no gouda... (waiting to be proven wrong in 6 minutes...) About the problem, try inheriting the flare of yours from the BIS flare class.. You never know if it has some hardcoded stuff like the engineer class (Miner) has.. Share this post Link to post Share on other sites
Messiah 2 Posted March 7, 2006 will try and inherit from the flare class Share this post Link to post Share on other sites
chris330 0 Posted March 14, 2006 I'm sure (well not entirely sure) I've got an old script lying around that does exactly this kind of thing. I'll try and dig it out Share this post Link to post Share on other sites
Guest RKSL-Rock Posted March 15, 2006 Just thinking out loud, how about this for an idea... I dont know about the gun mechanism itself but the parachute flare could be simulated using a vehicle with multiple lights point (See Inuisitor's Disco Jeep)? If you were to create a parachute class object, attach multiple lights to it and force it to have it lights on - either by looping a setbehaviour or some other script/code? You'd need to time it so it ran out afer 10-15 seconds... If you group enough of the the light sources properly it could look fairly realistic and with the right scripts etc. You can use the config settings to adjust the light strength fairly easily... Like i said its really only thinking out loud but it might be worth an experiment? Share this post Link to post Share on other sites
Messiah 2 Posted March 15, 2006 i was considering something similiar - it think it could work, although perhaps there would be trouble with making it sit on a parachute? although now i think of it, i'd also need to work out how to create my own parachute. Share this post Link to post Share on other sites
chris330 0 Posted March 15, 2006 I'll have to make this quick as I'm in work and it's a bit naughty to be using work computers for private interests If you can tell me a way to detect the presence of ammunition fired from a gun then I can defo make a script for you that will make this work fine. It runs along the idea of getting the ammo's position, then deleting the ammo (or defining the ammo as harmless) and then setvelocity-ing a flare which mimics the position and pitch of the ammo. Seen the flare setvelocity thing done in a flare script I've got for an old Vietnam mission I never released. It was made by someone whose name I have forgotten but it worked perfectly As for the parachute I don't think it would be that hard to make a new one. My landmine script might help you with light display ideas too Share this post Link to post Share on other sites
Footmunch 0 Posted March 15, 2006 If you can tell me a way to detect the presence of ammunition fired from a gun then I can defo make a script for you that will make this work fine. It runs along the idea of getting the ammo's position, then deleting the ammo (or defining the ammo as harmless) and then setvelocity-ing a flare which mimics the position and pitch of the ammo. Chris - Ammo grabbing code: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; Init our local vars _array = _this select 0 _weapon = _array select 1 _ammoname = _array select 4 _unit = _array select 0 ; Get the missile object _missobj = nearestobject[_unit , _ammoname] ; Get the missile direction _missdir = direction _missobj etc The sqs is started from something like: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class EventHandlers { fired="[_this] exec {\boing\grabmissile.sqs}"; } Share this post Link to post Share on other sites
chris330 0 Posted March 15, 2006 That's great stuff. Thanks very much mate Share this post Link to post Share on other sites
chris330 0 Posted March 16, 2006 Nearly there now just need to know how to get the EventHandler working properly. Which bit of the config file do I put it in? Comref says "fired" eventhandler returns following array: "Fired" string:weapon,string:muzzle,string:mode,string:ammo I have this in my config: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class EventHandlers { fired="[_this] exec {\UKF_Flaregun\playerdead.sqs}"; }; ..just to try and execute a player kill script to make sure it is working. So far it is not. I must therefore have something wrong in the eventhandler code or it is in the wrong part of the config file? Everything else works fine. Custom flare class works ok and everything (haven't tested an illuminating version though). Oddly enough if you define your flare magazine as having a very low (e.g. 10) initspeed the game calls the throw hand grenade animation when you fire! Increase the initspeed and this does not happen. Pretty weird. If I can get the eventhandler to work then I have thought of a way to make it look like the grenade launcher has launched a parachute flare too. Would look really,really good. I'll give more details if someone can help me with the eventhandler bit Share this post Link to post Share on other sites
chris330 0 Posted March 16, 2006 Everything is almost cool now. Just need to know how to get the ID of the unit that fired the weapon to be passed into the script. The fired Eventhandler only passes strings related to ammo and weapon names. It does not include a unit ID. So how does anyone know how I get this? Share this post Link to post Share on other sites
h - 169 Posted March 16, 2006 Fired event does return the one who fired.. _this select 0 : who _this select 1 : weapon _this select 2 : muzzle _this select 3 : mode _this select 4 : type of ammo Anyway, you probably should 'catch' the flare in the fired event, not with a script executed by it, to avoid the possibility to 'lose' the flare under low FPS environment although the flare is quite slow so that may not happen.. Something like this... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class EventHandlers { fired="_flr=nearestObject [_this select 0,_this select 4];[_this select 0,_flr] exec {\UKF_Flaregun\playerdead.sqs}"; }; Share this post Link to post Share on other sites
chris330 0 Posted March 16, 2006 Top job, will try that out now. Thank you very much indeed Share this post Link to post Share on other sites
chris330 0 Posted March 18, 2006 I have already posted this on the UKF website forums, but here it is again for those who haven't seen it. Flare Launch This is a scripted flare launch and very closely matches the default type done by the game. Instead it is done by a script and an eventhandler not the game's internal engine. Maybe it will open up a few new possibilities? Couldn't get a custom sound to work for the muzzle though, would appreciate some help on that Code sample: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 0 _refflare = _this select 1 _firespeed = 100 _ammoType = "Flare" _x1 = getpos _refflare select 0 _y1 = getpos _refflare select 1 _z1 = getpos _refflare select 2 ~0.001 _x2 = getpos _refflare select 0 _y2 = getpos _refflare select 1 _z2 = getpos _refflare select 2 _x = (_x2 - _x1) _y = (_y2 - _y1) _adj = sqrt ((_x^2) + (_y^2)) _opp = _z2 - _z1 _pitch = atan(_opp/_adj) _fv = cos(_pitch) * _firespeed _uv = sin(_pitch) * _firespeed _dir = getdir _unit _xfv = cos(_dir) * _fv _yfv = sin(_dir) * _fv _flare = _ammotype camcreate getpos _refflare deletevehicle _refflare _flare setvelocity [_yfv,_xfv,_uv] exit Thanks a great deal to everyone who helped me out with the code for this. Now I have a much better understanding of how to use eventhandlers, and a load of other stuff. Thanks again Share this post Link to post Share on other sites
h - 169 Posted March 19, 2006 Pardon me but that is a bit 'Microsofty' way of dealing with the current problem I would still solve this problem from the root, not just put some bandate on it.. @Messiah: So inheriting the flare class didn't work? Try this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class CfgAmmo { class Default{}; class BulletSingle:Default {}; class BulletSingleW: BulletSingle{}; class Grenade: Default{}; class MortarShell: Grenade{}; class AT3 : Default {}; class CarlGustav : AT3{}; class UKF_LAW80Rocket : CarlGustav { hit=820; indirectHit=290; indirectHitRange=3.100000; minRange=50; minRangeProbab=0.99; midRange=590; midRangeProbab=0.99; maxRange=620; maxRangeProbab=0.01; thrustTime=0.200000; thrust=1200; maxSpeed=156; initTime=0; soundHit[]={"Explosions\explosion_at3",100.000008,1}; soundFly[]={"weapons\rocketflying",0.010000,2}; soundEngine[]={"objects\noise",0.001000,1}; cost=5000; }; class AA : CarlGustav {}; class ukf_JavelinAmmo : AA { model="\ukf_ukweps\jav\ukf_javR.p3d"; hit=1000; indirectHit=500; indirectHitRange=10; ThrustTime=5000; thrust=50; initTime=0.6; maneuvrability=4.4; canLock=LockYes; airLock=true; irLock=true; laserLock=true; soundHit[]={"\ukf_ukweps\jav\jav_ground.wss",db25,1}; SoundHitArmor1[]={"\ukf_ukweps\jav\jav_arm1.wss",db30,1}; SoundHitArmor2[]={"\ukf_ukweps\jav\jav_arm2.wss",db30,1}; SoundHitArmor3[]={"\ukf_ukweps\jav\jav_arm3.wss",db30,1}; hitArmor[]={soundHitArmor1,0.33, soundHitArmor2,0.33, soundHitArmor3,0.33}; soundFly[]={"\ukf_ukweps\jav\javelin_fly.ogg",db18,1}; }; class ukf_556blank: BulletSingle { access=2 hit=0; indirectHit=0; //non HE indirectHitRange=0; visibleFire=14; audibleFire=14; visibleFireTime=2; tracerColor[]={0,0.000000,0.00000,0}; soundFly[]={}; minRange=1; minRangeProbab=1; midRange=1; midRangeProbab=1; maxRange=1; maxRangeProbab=1; }; class ukf_White_Flare : Grenade { hit=10;indirectHit=6;indirectHitRange=3.0; cost=100; simulation=shotIlluminating; simulationStep=0.050; explosive = False; soundHit[]={,0,1}; lightColor[] = {1, 1, 1, 0}; }; class ukf_Red_Flare : ukf_White_Flare { lightColor[] = {1, 0, 0, 0}; }; }; ///Weapon definitions; class CfgWeapons { class Default {}; class MGun: Default {}; class GrenadeLauncher: Default {}; class Flare: GrenadeLauncher {}; class Riffle: MGun {}; class M16:Riffle{}; class HandGunBase: Riffle {}; class ukf_paraflareR : Handgunbase { access=2; scopeWeapon=2; scopeMagazine=2; aiRateOfFire=0.500000; aiRateOfFireDistance=50 model="\ukf_ukweps\flare\ukf_flare"; modelOptics=""; picture="\ukf_ukweps\flare\flareRicon.pac"; displayName="Para Flare (Red)"; displayNameMagazine="Flare"; shortNameMagazine="Flare"; count=1; weaponType=2; magazineType=32; magazineReloadTime=3; autoReload=0; soundContinuous=0; sound[]={}; drySound[]={}; reloadMagazineSound[]={}; magazines[] = {ukf_red_flare}; backgroundReload=0; autoFire=0 dispersion=0.002000; multiplier=1; burst=1; reloadTime=5; }; class ukf_paraflareW : Flare { model="\ukf_ukweps\flare\ukf_flareW"; displayName="Para Flare (White)"; magazines[] = {ukf_white_flare}; picture="\ukf_ukweps\flare\flareWicon.pac"; }; class ukf_White_Flare: Flare { scopeWeapon=0; scopeMagazine=2; displayNameMagazine= "Para Flare (White)"; picture="\ukf_ukweps\flare\flareWAicon.pac"; initSpeed=80; }; class ukf_Red_Flare: Flare { scopeWeapon=0; scopeMagazine=2; displayNameMagazine= "Para Flare (Red)"; picture="\ukf_ukweps\flare\flareRAicon.pac"; initSpeed=80; }; Share this post Link to post Share on other sites
chris330 0 Posted March 19, 2006 Pardon me but that is a bit 'Microsofty' way of dealing with the current problem I would still solve this problem from the root, not just put some bandate on it.. I take it you're a linux fan then (so am I but I'm still in the closet on that one) It was not just an attempt to put a patch over the problem, rather more an experiment to see if it could be done, and well, it could. It may turn out to be useful to somebody, you never know when it will be handy. Ideally though a config fix would be better for a weapon which is intended to run on conventional lines. By the way can anyone help me with the custom muzzle sound? Share this post Link to post Share on other sites
h - 169 Posted March 19, 2006 Quote[/b] ]I take it you're a linux fan then Well, not really, since it can only run about 1 of the several software I use very frequently... However, the point was that this kind of fix is not very good practise, especially as it's by no means MP friendly, although that would not take that many lines to 'fix'.. Not to mention checks that the flare is not fired every time you fire a weapon, and on burst/auto you get a ton of flares Quote[/b] ]By the way can anyone help me with the custom muzzle sound? I think you need to define the sound in the mission's description.ext or in the addon config, then use the say function.. playSound should work too.. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit say "soundname" <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">playSound "soundname" Share this post Link to post Share on other sites