Jump to content
Sign in to follow this  
rip31st

How to make wing tip mounted guns fire...

Recommended Posts

I'm currently in work on a fixed wing fighter which has four wing mounted machine guns. Is it possible to get all four to work? I know I can get two working so far.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_u = _this select 0

_ammo = _u ammo (_this select 1)

_b = nearestObject [_u, _this select 4]

? (((_ammo mod 2) == 0) and (_b isKindOf "MG17")) : _offset1 = [0.2 , 3.3 , 0.53];_wpos1 = _u modelToWorld _offset1;_b setpos _wpos1

exit

Share this post


Link to post
Share on other sites

You need to mod by the number of MGs.  Eg:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_u = _this select 0;

_ammo = _u ammo (_this select 1);

_b = nearestObject [_u, _this select 4];

?!(_b isKindOf "MG17") : exit

_n = (_ammo mod 4);

? (_n == 1) : _offset = [0.2 , 3.3 , 0.53];

? (_n == 2) : _offset = [offset2...];

? (_n == 3) : _offset = [offset3...];

_wpos = _u modelToWorld _offset;

_b setpos _wpos;

exit

That way, bullets 0, 4, 8, 12 all come from the model's muzzle, 1, 5, 9, 13 come from offset1, 2, 6, 10, etc from offset2, 3, 7, etc from offset3.  If you have trouble w/ that let me know  wink_o.gif

Edit: typos in script

Share this post


Link to post
Share on other sites

What fixed wing plane you making ??

In OFP I experimented with multiple firing spots and it wouldn't keep up with the speed of the plane.

ex: flying at 600kph the firing would be coming from behind the plane

Share this post


Link to post
Share on other sites
What fixed wing plane you making ??

In OFP I experimented with multiple firing spots and it wouldn't keep up with the speed of the plane.

ex: flying at 600kph the firing would be coming from behind the plane

Would it be possible to shoot your own plane in that case?

Share this post


Link to post
Share on other sites

bf109e1

bf109e1_2-1.jpg

Thanks for the code. I will give it a shot later and report back on the results.

Share this post


Link to post
Share on other sites
You need to mod by the number of MGs.  Eg:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_u = _this select 0;

_ammo = _u ammo (_this select 1);

_b = nearestObject [_u, _this select 4];

?!(_b isKindOf "MG17") : exit

_n = (_ammo mod 4);

? (_n == 1) : _offset = [0.2 , 3.3 , 0.53];

? (_n == 2) : _offset = [offset2...];

? (_n == 3) : _offset = [offset3...];

_wpos = _u modelToWorld _offset;

_b setpos _wpos;

exit

That way, bullets 0, 4, 8, 12 all come from the model's muzzle, 1, 5, 9, 13 come from offset1, 2, 6, 10, etc from offset2, 3, 7, etc from offset3.  If you have trouble w/ that let me know  wink_o.gif

Edit: typos in script

Only have bullets coming two machine guns - from the right wing offset and center:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_u = _this select 0;

_ammo = _u ammo (_this select 1);

_b = nearestObject [_u, _this select 4];

?!(_b isKindOf "MG17") : exit

_n = (_ammo mod 4);

? (_n == 1) : _offset = [0.2 , 3.3 , 0.53];

? (_n == 2) : _offset = [2.493,3.24,-0.26];

? (_n == 3) : _offset = [-2.493,3.24,-0.26];

? (_n == 4) : _offset = [-2.493,3.24,-0.26];

_wpos = _u modelToWorld _offset;

_b setpos _wpos;

exit

sad_o.gif

Share this post


Link to post
Share on other sites
Only have bullets coming two machine guns - from the right wing offset and center:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_u = _this select 0;

_ammo = _u ammo (_this select 1);

_b = nearestObject [_u, _this select 4];

?!(_b isKindOf "MG17") : exit

_n = (_ammo mod 4);

? (_n == 1) : _offset = [0.2 , 3.3 , 0.53];

? (_n == 2) : _offset = [2.493,3.24,-0.26];

? (_n == 3) : _offset = [-2.493,3.24,-0.26];

? (_n == 4) : _offset = [-2.493,3.24,-0.26];

_wpos = _u modelToWorld _offset;

_b setpos _wpos;

exit

sad_o.gif

Mod never returns the number.  4 mod 4 is 0, not 4.  So whatever you check w/ _n == 4 will not work.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_u = _this select 0;

_ammo = _u ammo (_this select 1);

_b = nearestObject [_u, _this select 4];

?!(_b isKindOf "MG17") : exit

_n = (_ammo mod 4);

? (_n == 0) : exit;

? (_n == 1) : _offset = [0.2 , 3.3 , 0.53];

? (_n == 2) : _offset = [2.493,3.24,-0.26];

? (_n == 3) : _offset = [-2.493,3.24,-0.26];

_wpos = _u modelToWorld _offset;

_b setpos _wpos;

exit

When n is zero, the normal spot for rounds to fire from should work.  When n = 1, 2, or 3, it will go to the offset specified.  I've not tested this, but I'm fairly sure it will work.  If it is still giving your problems, but some debug lines in.  Eg: have it give you a hint format ["n: %1\n\noffset: %2", _n, _offset] right after the conditions.

BTW, you may want to consider, after you have it working, converting this to an SQF rather than an SQS script.  But to test it, using SQS is sometimes easier.  Also, if this script is packed into your pbo, that makes making changes difficult.  My advice would be to have your pbo reference a "test.sqs" or something like that.  Then put the "test.sqs" in a mission under the mission editor.  Then, if the script doesn't work well, you just alt-tab, edit the script, then try again.  It saves a ton of time versus rePBOing every time.

Good luck man!

Iuka  smile_o.gif

PS: I assume you have the rounds w/ tracers so you can see them. Also, this will not create a muzzleFlash or smoke effect at the other firing points.

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_u = _this select 0;

_ammo = _u ammo (_this select 1);

_b = nearestObject [_u, _this select 4];

?!(_b isKindOf "MG17") : exit

_n = (_ammo mod 4);

?(_n == 0) : exit

?(_n == 1) : _offset = [0.2 , 3.3 , 0.53];

?(_n == 2) : _offset = [2.493,3.24,-0.26];

?(_n == 3) : _offset = [-2.493,3.24,-0.26];

hint format ["n: %1\n\noffset: %2", _n, _offset]

_wpos = _u modelToWorld _offset;

_b setpos _wpos;

exit

Okay the hint is telling me that only the main weapon and offset 2 are firing. Visually confirmed. I am pulling my hair out trying to figure out why # 1 and # 3 aren't firing!

banghead.gif

smile_o.gif

here is the event handler code that activates it:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">fired = "_this exec ""\rip31st_bf109e1\fired.sqs"""

Share this post


Link to post
Share on other sites

in your weapon config, do you have burst=x; or multiplier=x;? Its possible that if you have a multiplier of say, 2, then instead of having an ammo count of 1, 2, 3, 4, 5, 6... you are getting 2, 4, 6, 8, 10... which would not give the same results when you mod by 4.

Share this post


Link to post
Share on other sites

That did the trick. In the gun core I changed the multiplier to one, it was at two. Isn't amazing how small things can make a big difference. Thanks for your help! I had a suspicion the problem lied within the config.

Here's the change I made to make it work:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

ammo="MG17";

multiplier=1;

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×