source_type of ammo items seems to be ignored

Place to get help with not working mods / modding interface.
Post Reply
Pi-C
Smart Inserter
Smart Inserter
Posts: 1639
Joined: Sun Oct 14, 2018 8:13 am
Contact:

source_type of ammo items seems to be ignored

Post by Pi-C »

Prototype/AmmoItem:
ammo_type

Type: table of AmmoType or AmmoType
When using an array of AmmoType, the AmmoType has an extra property:

source_type - AmmoSourceType - Mandatory. - Defines for which kind of entity this ammo type applies. Each entity kind can only be used once per array.

When using a plain AmmoType, the ammo type applies to everything ("default").
This definition should make the ammo only usable in turrets:

Code: Select all

{
  type = "ammo",
  ammo_type = {
    {
      category = BI.additional_categories.Bio_Cannon.cannon_ammo.name,
      source_type = "turret",
      target_type = "direction",
      action = {
        {
          type = "direct",
          action_delivery = {
            type = "projectile",
            projectile = "bi-bio-cannon-ammo-basic",
            starting_speed = 0.4,
            direction_deviation = 0.25,
            max_range = 105,
          }
        }
      }
    },
  },
…
}
According to the prototype browser, the "turret" source_type is set correctly, but I still can add the item to the character's ammo slots:
ammo_item-source_type.png
ammo_item-source_type.png (1.65 MiB) Viewed 2153 times
Is that a bug, a documentation bug, or a misunderstanding on my part? :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Bilka
Factorio Staff
Factorio Staff
Posts: 3123
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: source_type of ammo items seems to be ignored

Post by Bilka »

It's used to give the ammo different effects depending on where it is used, not for forbidding it to be used somewhere (which is why it only applies when used with an array of ammo type). Take a look at flamethrower ammo, that's the example of it being used in vanilla (flamy flames for player, small non-flamy flames for tank).
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1639
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: source_type of ammo items seems to be ignored

Post by Pi-C »

OK, so there's no way to prevent ammo from being inserted into an ammo inventory? Obviously, I couldn't add flamethrower ammo to a slot reserved by the rocket launcher because ammo_category wouldn't match. But nothing would prevent me from adding an artillery-shell to a player's ammo slot not yet associated with a weapon although there is no gun the player could use it with. Shouldn't that be fixed?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Bilka
Factorio Staff
Factorio Staff
Posts: 3123
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: source_type of ammo items seems to be ignored

Post by Bilka »

The same also goes for vanilla and I am not sure how you'd define "guns that you can never equip" as e.g. in editor mode you can just grab an artillery cannon and equip it as the player (and shoot arty!).

What you could do is make the ammo do nothing for the "player" source type, but I don't really see a reason for that since vanilla simply doesn't care about players equipping cannon/arty shells.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Qon
Smart Inserter
Smart Inserter
Posts: 2091
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: source_type of ammo items seems to be ignored

Post by Qon »

I didn't know this property existed or what it did. The flamer ammo being different when used in the tank should have been a clue, but I haven't used flamer ammo in tank for a long time now and forgot about it. Thinking about if I should use this for Capsule Ammo now, might be able to improve balancing with it. So thanks for bringing this up ;)

Pi-C
Smart Inserter
Smart Inserter
Posts: 1639
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: source_type of ammo items seems to be ignored

Post by Pi-C »

Bilka wrote:
Mon Jul 19, 2021 9:30 am
The same also goes for vanilla and I am not sure how you'd define "guns that you can never equip" as e.g. in editor mode you can just grab an artillery cannon and equip it as the player (and shoot arty!).
Apparently I can't do that (no mods, new game, editor mode), unless there is a special setting I haven't found yet:
editor-artillery-turret.png
editor-artillery-turret.png (2.16 MiB) Viewed 2103 times
… I don't really see a reason for that since vanilla simply doesn't care about players equipping cannon/arty shells.
Less confusion if it wasn't possible even with vanilla items. When I was playing, I knew that artillery shells are different from cannon shells (or was that cannon shells and rockets?), but still had to take special care when I was setting the recipe in assemblers, or trying to equip ammo. Stupid mistakes, I know, but they happen … :mrgreen:
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Qon
Smart Inserter
Smart Inserter
Posts: 2091
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: source_type of ammo items seems to be ignored

Post by Qon »

Pi-C wrote:
Mon Jul 19, 2021 10:32 am

Apparently I can't do that (no mods, new game, editor mode), unless there is a special setting I haven't found yet:
Equip the artillery GUN, not the turret that uses the gun. It's a bit hidden but I think using infinity chest allows you to spawn the actual gun (icon tank turret) the easiest way.

Bilka
Factorio Staff
Factorio Staff
Posts: 3123
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: source_type of ammo items seems to be ignored

Post by Bilka »

Not sure why you'd use an infinity chest when you can spawn items right in the gui:
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1639
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: source_type of ammo items seems to be ignored

Post by Pi-C »

Qon wrote:
Mon Jul 19, 2021 10:40 am
Equip the artillery GUN, not the turret that uses the gun.
Thanks, got it now! Actually, I've realized only yesterday that there's a difference between turrets and guns, and that you can assign trigger target masks to guns and even ammo items. Looks like I've accidentally found a solution to a problem that made my water-turrets mod almost unusable. :-D
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Qon
Smart Inserter
Smart Inserter
Posts: 2091
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: source_type of ammo items seems to be ignored

Post by Qon »

I have a use for target masking as well, I found some helpful topic (yours on that water turret mod) that had info on that that I will have to find again for one of my mods.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1639
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: source_type of ammo items seems to be ignored

Post by Pi-C »

Qon wrote:
Mon Jul 19, 2021 11:23 am
I found some helpful topic (yours on that water turret mod) that had info on that that I will have to find again
There's a link to that thread on the wiki page for trigger target masks.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!


Post Reply

Return to “Modding help”