Hello guys,
I downloaded a mod that made the SMG and pistol an aiming weapon with real projectiles coming out of the guns if normal bullets were used.
I managed to expand this behaviour to all kind of bullets for the named weapons and the vehicles.
But I am not able to do this for the turrets so far. For the hand and vehicle weapons I could just replace their ammo_type with a new ammo that behaves a bit like a single shotgun bullet.
But how can I do this for the gun turrets? They already use the same bullets and should behave like the weapons but they dont. Is there something I dont know about gun turrets? Is there some kind of "instahit" flag that overwrites the ammo behavior?
Can anyone help me out please?
Question about turrets and their weapon behaviour
-
- Inserter
- Posts: 30
- Joined: Tue Nov 13, 2018 4:50 pm
- Contact:
- Deadlock989
- Smart Inserter
- Posts: 2529
- Joined: Fri Nov 06, 2015 7:41 pm
Re: Question about turrets and their weapon behaviour
I've done this in my mod and it works just fine. You will have to tweak the turret's attack parameters a bit to get the animations right but it works straight away if you updated the ammo correctly or created new ammo types from scratch. You will also have to change the "force condition" setting of the projectiles if you don't want your own turrets to wreck your own base.
Without seeing your code it's hard to suggest what's wrong.
Without seeing your code it's hard to suggest what's wrong.
-
- Inserter
- Posts: 30
- Joined: Tue Nov 13, 2018 4:50 pm
- Contact:
Re: Question about turrets and their weapon behaviour
The code is very simple. For the base bullets this is what the original mod does:
And thats it. This will make all weapons of vehicles and the player to have real projectiles the player can aim. But the turrets are not effected by this and I dont know why.
Code: Select all
local am_type = {
category = "bullet",
target_type = "direction",
action = {
{
type = "direct",
action_delivery = {
{
type = "projectile",
projectile = 'shotgun-pellet',
starting_speed = 1.1,
direction_deviation = 0.1,
range_deviation = 0.3,
max_range = 30,
source_effects = {
{
type = "create-explosion",
entity_name = "explosion-gunshot"
}
},
target_effects = {
{
type = "damage",
damage = {
amount = 5,
type = "physical"
}
}
}
}
}
}
}
}
data.raw.ammo['firearm-magazine'].ammo_type = am_type
- Deadlock989
- Smart Inserter
- Posts: 2529
- Joined: Fri Nov 06, 2015 7:41 pm
Re: Question about turrets and their weapon behaviour
Hmm. That looks different to how I've done it. I create a series of new projectiles and the damage actions are defined in each projectile, not in the ammo type itself. The ammo type only has the visual gunshot "explosion" (the muzzle flash) and the projectile defined in its action deliveries. It could be that in your case, the turret is just applying the damage directly because it's defined in the ammo to be applied directly. If it is defined in the projectile instead then it is only applied when the projectile collides with something.
Creating an ammo type for an ammo item:
Creating a new projectile for that ammo type:
Creating an ammo type for an ammo item:
Code: Select all
function get_bullet_ammo_type(base_damage, colour)
local name = colour.."-"..base_damage
return {
action = {
{
action_delivery = {
source_effects = {
{
entity_name = "explosion-gunshot",
type = "create-explosion"
}
},
type = "instant"
},
type = "direct"
},
{
action_delivery = {
direction_deviation = 0.05,
max_range = DIR.ammo.range.magazine,
projectile = name,
range_deviation = 0,
starting_speed = DIR.projectile_speed.bullet,
type = "projectile"
},
repeat_count = 1,
type = "direct"
}
},
category = "bullet",
target_type = "entity"
}
end
Code: Select all
function create_projectile(base_damage, colour)
local name = colour.."-"..base_damage
if not data.raw.projectile[name] then
data:extend({{
name = name,
type = "projectile",
acceleration = 0,
action = {
action_delivery = {
target_effects = {
damage = {
amount = base_damage,
type = "physical"
},
type = "damage"
},
type = "instant"
},
type = "direct"
},
animation = {
filename = DIR.projectiles_path.."/bullet.png",
tint = DIR.bullet_colours[colour],
frame_count = 1,
height = 50,
priority = "high",
width = 3
},
collision_box = {{-0.05,-0.25},{0.05,0.25}},
direction_only = true,
flags = {"not-on-map"},
force_condition = "not-same",
}})
end
end