Weapon firing arcs

Place to get help with not working mods / modding interface.
Post Reply
Kill3rCat
Burner Inserter
Burner Inserter
Posts: 17
Joined: Wed Aug 10, 2016 12:28 am
Contact:

Weapon firing arcs

Post 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.

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: Weapon firing arcs

Post 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.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

Kill3rCat
Burner Inserter
Burner Inserter
Posts: 17
Joined: Wed Aug 10, 2016 12:28 am
Contact:

Re: Weapon firing arcs

Post by Kill3rCat »

Is there any way to prevent the player from firing the weapon, then?

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Weapon firing arcs

Post 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.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

Kill3rCat
Burner Inserter
Burner Inserter
Posts: 17
Joined: Wed Aug 10, 2016 12:28 am
Contact:

Re: Weapon firing arcs

Post 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.

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: Weapon firing arcs

Post 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.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

Post Reply

Return to “Modding help”