Zane's Car Turret


Adds a defensive tower using the car's gun. Slow shooting and easily destroyed, but cheap, it is meant for early defense (no research required :D). Adds a later game Gatling Turret with extra high fire rate and some range boost over the standard gun turret of the base game. Has support for low resolution and high resolution graphics since all the graphics come from the base game. Also has support for Krastorio 2.

Content
3 years ago
1.0 - 1.1
1.26K
Combat

b K2 Projectile range not matching turret range

2 years ago

Heya,

When enabling the more-realistic-weapon option in K2, the pistol clip projectile only travels 20 while this gun starts firing at 25, wasting the whole clip instead (bit of a problem when attempting to hit a target outside the projectile range).

The solution is to either reduce to 20 by default, or handle the attack distance together with the bullet type mod option, as the option to change ammo type would need to account for how far the projectile will actually travel.

The solution for now would be a patch until this is fixed in your mod (or for me to change the mod option, but I prefer to consume my pistol clips :).

And here's a picture: https://i.imgur.com/hAa5YMu.png

Best Regards,

2 years ago
(updated 2 years ago)

The solution that I used in the patch, for now, is the following code (could still use additional safety-checks):

-- Car Turret Mod
if mods["Krastorio2"] and mods["T-Zane-CarTurret"] then
-- we basically do exactly what the car-turret mod does, but we instead change the turret range
if krastorio.general.getSafeSettingValue("kr-more-realistic-weapon")
and settings.startup["zane-car-turret-pistol-ammo"].value=="Yes" then
local ammo = data.raw.ammo[ "firearm-magazine" ]
if ammo then
local action1 = ammo.ammo_type.action[1] or ammo.ammo_type.action
if action1 then
local action_delivery1 = action1.action_delivery[1] or action1.action_delivery
if action_delivery1 then
if action_delivery1.max_range then
local projectile_range = action_delivery1.max_range
log( "applying correct projectile range to car-turret (range: " .. projectile_range .. ")" )
data.raw["ammo-turret"]["car-turret"].attack_parameters.range = projectile_range -- subtract 2 ?
end
end
end
end
end
end

If the range changes within K2 then this should also keep the range on the turret up to date, as long as data layout doesn't change.

New response