Ammo and Turret Ranges

Place to get help with not working mods / modding interface.
Post Reply
User avatar
MaxAstro
Burner Inserter
Burner Inserter
Posts: 13
Joined: Sun Nov 09, 2014 7:53 am
Contact:

Ammo and Turret Ranges

Post by MaxAstro »

Is it possible to alter the range of a turret based on the ammo it is equipped with?

I know it's not directly supported, but could it be done via Lua magic? For example, will the range field of the turret entity accept a variable or equation, and is it possible to find out the type of ammo a turret is loaded with?

If so, could you do something like (pseudocode):

extrarange = 0
if (ammo = longrangeammo)
then extrarange = 5
range = 17 + extrarange
"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark Twain

"True friends stab you in the front." - Oscar Wilde

User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: Ammo and Turret Ranges

Post by L0771 »

You can't modify prototypes after the game has loaded.
Can modify damage of towers or ammo damage with technologies

You can make some entities with modifications and destroy/create with findenemyunits

User avatar
MaxAstro
Burner Inserter
Burner Inserter
Posts: 13
Joined: Sun Nov 09, 2014 7:53 am
Contact:

Re: Ammo and Turret Ranges

Post by MaxAstro »

I figured the answer would be something like that.

Is it possible to make a turret accept only one kind of bullet - i.e. only piercing ammo, or only regular ammo?

I assume I could do this by making a new ammo type and separating piercing into it, but that would make the player's weapons unable to use that ammo, correct?

P.S. Thanks for the quick answer.
"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark Twain

"True friends stab you in the front." - Oscar Wilde

User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: Ammo and Turret Ranges

Post by L0771 »

Piercing ammo and regular ammo are bullets, i think you can't select only one bullet, but your turret can accept a kind of ammo (bullets, rockets, etc)

You can create a new ammo type (like arrows, rocks, darts, etc), you can modify the weapons to accept your ammo(accept only 1 ammo kind), or create new weapons for this new ammo.

I'm new here too, with mods and english...

n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: Ammo and Turret Ranges

Post by n9103 »

From what I've seen and done, you've got a single feasible option:
Make a custom turret that uses custom ammunition with longer range.
-Make a player-usable version of this new weapon if you want the player to be able to use the same ammo.

Perhaps you could make use of the already present but unused railgun and railgun dart?

I previously had a rather over-the-top suggestion that went along the lines of making a new attacking function, but some of the handles for that are still absent.
Though, I think a less-than-rigorous version of this idea is still possible, though it would be a bit more primitive than I'm thinking, and would probably be very costly in terms of cycles used for scripts.
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.

User avatar
MaxAstro
Burner Inserter
Burner Inserter
Posts: 13
Joined: Sun Nov 09, 2014 7:53 am
Contact:

Re: Ammo and Turret Ranges

Post by MaxAstro »

Actually, I think I've found a solution - it's a bit hackneyed and involved creating what is basically a duplicate turret (and also making the machinegun unable to fire regular bullets), but it does what I need it to do.

Thank you everyone for your advice!

EDIT: Okay, one more question. Is it possible for an entity's inventory to have a smaller maximum stack size for an item than the player's inventory does? Say I want an item to stack up to 100 in the player's inventory, but only up to 20 in the turret's inventory.
"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark Twain

"True friends stab you in the front." - Oscar Wilde

Post Reply

Return to “Modding help”