This is observable in vanilla but I came across it because I am trying to make different tiers of spidertrons have differently ranged cannons. It appears that this is not possible because of the following.
The tank cannon has range 25 (called "Range" on the cannon tooltip). The cannon shell has max_range 30 (called "Projectile range" on the shell tooltip). The shells are clearly travelling 30 tiles.
I'd expect projectiles to travel a distance equal to the minimum of the weapon's range and the ammo's max_range, so 25 in this case.
[Klonan] [1.1.41] Vehicle weapon range is being ignored
[Klonan] [1.1.41] Vehicle weapon range is being ignored
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Re: [1.1.41] Vehicle weapon range is being ignored
This looks slightly more complicated than just "use lower of the 2".
Gun's AttackParameters define a range for a gun which is used to decide if you can shoot given target/position. It is however not used when you have an ammo item with ammo_type.target_type=="direction" as in this case you are not aiming at a given position nor given entity but you only show the general direction for the gun to shoot. After this the ammo being applied just do not care from what it was being shot. Extra case for this is that the cannon-projectile's prototype has direction_only which means even if you would change the ammo to have target_type="position" which will fix the "can shoot" check, the particle will still travel full distance from the ammo.
Changing cannon-shell to have ammo_type.target_type="position" and changing cannon-projectile to direction_only=false you would get your expected outcome by not allowing gun to shoot when the target is out of gun's range.
Gun's AttackParameters define a range for a gun which is used to decide if you can shoot given target/position. It is however not used when you have an ammo item with ammo_type.target_type=="direction" as in this case you are not aiming at a given position nor given entity but you only show the general direction for the gun to shoot. After this the ammo being applied just do not care from what it was being shot. Extra case for this is that the cannon-projectile's prototype has direction_only which means even if you would change the ammo to have target_type="position" which will fix the "can shoot" check, the particle will still travel full distance from the ammo.
Changing cannon-shell to have ammo_type.target_type="position" and changing cannon-projectile to direction_only=false you would get your expected outcome by not allowing gun to shoot when the target is out of gun's range.
Re: [1.1.41] Vehicle weapon range is being ignored
This is basically just a base game Lua prototype error,
Since all the projectiles in the base game have the max range of 30,
I will just change the range of the tank cannon to be the 30 as with the projectile, even though it actually makes no difference
There is nothing wrong with the logic in the game, projectiles can have a range different than the guns targeting range, there won't be any logic changes in that regard,
And all of this can be tweaked and fixed with mods,
The base game is just defining things in a poor way leading to confusion
Since all the projectiles in the base game have the max range of 30,
I will just change the range of the tank cannon to be the 30 as with the projectile, even though it actually makes no difference
There is nothing wrong with the logic in the game, projectiles can have a range different than the guns targeting range, there won't be any logic changes in that regard,
And all of this can be tweaked and fixed with mods,
The base game is just defining things in a poor way leading to confusion
Re: [1.1.41] Vehicle weapon range is being ignored
Thank you very much for the detailed explanation. I think that I got a bit lost amongst all the different prototypes/types (AmmoItem, AmmoType, Trigger, TriggerItem, TriggerDelivery, Projectile ) and didn't appreciate that there were so many different ways of doing it. Now I understand the differences between machine gun bullets, cannons and rockets it clears up some of the confusion I had whilst playing vanilla as well.boskid wrote: ↑Wed Sep 29, 2021 9:00 am This looks slightly more complicated than just "use lower of the 2".
Gun's AttackParameters define a range for a gun which is used to decide if you can shoot given target/position. It is however not used when you have an ammo item with ammo_type.target_type=="direction" as in this case you are not aiming at a given position nor given entity but you only show the general direction for the gun to shoot. After this the ammo being applied just do not care from what it was being shot. Extra case for this is that the cannon-projectile's prototype has direction_only which means even if you would change the ammo to have target_type="position" which will fix the "can shoot" check, the particle will still travel full distance from the ammo.
Changing cannon-shell to have ammo_type.target_type="position" and changing cannon-projectile to direction_only=false you would get your expected outcome by not allowing gun to shoot when the target is out of gun's range.
Changing the ammo_type.target_type from "direction" to "position" and setting ammo_type.clamp_position = true seems to keep the behaviour exactly as it was (you can aim beyond the range and it will just go to that range) except that it now clamps to the gun range instead of the projectile range - perfect!
I then change every cannon shell's action_delivery.max_range to be that of the largest gun range and set the projectile's direction_only=false (I'd likely have never found that if you hadn't mentioned it!) and all seems to be working how I wanted it!
I'm also doing the same for shotguns: interestingly shotgun-shell already has `clamp_position = true` despite `target_type = "direction"` (wiki says this has no effect)... it all works the same with the above modifications though, which is great!
I agree with Klonan - the game engine now seems fine, just some questionable choices in the base prototypes. Certainly the tank-cannon range mismatch is the most egregious, but I'm unsure why target_type = "direction" is ever actually useful (vs "position" and clamp_position=true).
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Re: [1.1.41] Vehicle weapon range is being ignored
Ok, I see a difference now - clamp_position works when you fire to a point beyond the gun range, but if you fire at a point less than the gun range then "direction" will still travel the full max_range of the ammo, whereas "position"+clamp_position will only travel to the cursor position.
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Re: [1.1.41] Vehicle weapon range is being ignored
Errrrr, this behaviour is what I observed, but the docs disagree! "The gun will fire at the maximum range in the direction of the target position" - https://wiki.factorio.com/Types/AmmoType#clamp_positionXorimuth wrote: ↑Wed Sep 29, 2021 2:38 pmOk, I see a difference now - clamp_position works when you fire to a point beyond the gun range, but if you fire at a point less than the gun range then "direction" will still travel the full max_range of the ammo, whereas "position"+clamp_position will only travel to the cursor position.
I'd prefer the behaviour to change to match the docs, but one of them should certainly be changed.
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Re: [1.1.41] Vehicle weapon range is being ignored
The behaviour is correct,Xorimuth wrote: ↑Wed Sep 29, 2021 3:09 pm
Errrrr, this behaviour is what I observed, but the docs disagree! "The gun will fire at the maximum range in the direction of the target position" - https://wiki.factorio.com/Types/AmmoType#clamp_position
I'd prefer the behaviour to change to match the docs, but one of them should certainly be changed.
Its IF the position is too far away, the gun will fire at the max range
Re: [1.1.41] Vehicle weapon range is being ignored
Fair enough, I see what you mean now.Klonan wrote: ↑Wed Sep 29, 2021 4:28 pmThe behaviour is correct,Xorimuth wrote: ↑Wed Sep 29, 2021 3:09 pm
Errrrr, this behaviour is what I observed, but the docs disagree! "The gun will fire at the maximum range in the direction of the target position" - https://wiki.factorio.com/Types/AmmoType#clamp_position
I'd prefer the behaviour to change to match the docs, but one of them should certainly be changed.
Its IF the position is too far away, the gun will fire at the max range
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Re: [Klonan] [1.1.41] Vehicle weapon range is being ignored
For the next release the cannon range is set to 30,
It doesn't actually change any of the behavior, just to remove it as a possible point of confusion for players
It doesn't actually change any of the behavior, just to remove it as a possible point of confusion for players