Page 1 of 1

Weapon firing arcs

Posted: Wed Aug 10, 2016 7:47 pm
by Kill3rCat
I hope this is the right subforum to post this...

Is there any way to limit a vehicle's weapon firing ability to an arc in front of the vehicle (i.e. 45')? Some weapons just shouldn't be able to fire in a 360' arc.

Re: Weapon firing arcs

Posted: Thu Aug 11, 2016 5:01 am
by Adil
No.
Not unless you're willing to reimplement firing logic in lua, which would be rather ineffective approach to fast weapons like machinegun or flamethrower.

Re: Weapon firing arcs

Posted: Fri Aug 12, 2016 11:15 am
by Kill3rCat
Is there any way to prevent the player from firing the weapon, then?

Re: Weapon firing arcs

Posted: Fri Aug 12, 2016 11:19 am
by aubergine18
When player enters vehicle, you could move any weapons the player has in their inventory to the vehicle inventory, then move the weapon back to player when player exits the vehicle. If you need sample code to see how to access stuff in inventory, check out this mod which should have plenty of examples in its code.

Re: Weapon firing arcs

Posted: Fri Aug 12, 2016 12:04 pm
by Kill3rCat
That's not quite what I mean; I am talking about preventing the player from firing the weapons of the vehicle they are in. With a little bit of trig, I am sure I could mock up a firing arc restriction.

Re: Weapon firing arcs

Posted: Sun Aug 14, 2016 5:00 pm
by Adil
If your vehicle will use some special ammo that cannot be fired by nothing else that shouldn't have ark limitation, then
Make a vehicle gun use a special ammo, which effect consists solely in creation of shortlived dummy entity (like explosion type) and use on_trigger_created_entity event, to detect the act of shooting.
Then see if player is in vehicle and if vehicle orientation is right then create real projectile.
You can have the weapon create dummy entities both in source and destination position, and the corresponding on_trigger_created_entity events will be always risen in a particular order one right after another. This way you can detect which of several players fired a gun in multiplayer.

Something similar was working in my mod but it was lost to a disk cleanup gone wrong, thus I cannot provide the examples.