[0.16.36]on_entity_damaged shotgun damage inaccurate ++

This subforum contains all the issues which we already resolved.
ultro
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sun May 15, 2016 5:26 am
Contact:

[0.16.36]on_entity_damaged shotgun damage inaccurate ++

Post by ultro »

Hello, I was recently testing floating damage lua for when you attack biters, etc.
All of the original_damage_amount and final_damage_amount is calculated properly for all weaponry except for shotgun-shell damage and piercing-shotgun-shells damage and fire damage.

It throws 6 damage on a 12 x 5 regular shotgun shell shot instead of at least the minimum 12 damage if one pellet connects or a maximum of 60 damage on all pellets connecting when hitting a mob or spawner base regardless of damage or no damage resistance.

Image

And it throws 9.6 damage on a 16 x 8 piercing shotgun shell shot instead of at least 16 minimum or 128 maximum whether it be a mob or a spawner base regardless of damage or no damage resistance.

Image

So it seems the pellets weren't added for the calculation and the initial pellet damage as well. And for the fire ammo damage instead of 13/sec initial its a decimal place value like 0.15 0.23 0.33 etc. instead of at least 13 base damage.

Also, the market right click does not sell items only the single click on the market is working. The right click to get 5 items at a time which is great for ammo, etc. does not work sadly.

Thank you for your time, the custom additions you are making are awesome. The added luas make for some really nice custom gameplay, even with vanilla softmodding. If these could be added to the next update it would be greatly appreciated, thanks again.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14328
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.16.36]on_entity_damaged shotgun damage inaccurate ++

Post by Rseding91 »

Thanks for the report. I think you're confusing the numbers. "12 x 5" is "12 pellets x 5 damage each" not "12 damage each x 5 pellets".

Regarding the market right-click not working - I've fixed that for the next version of 0.16 or 0.17 - which ever comes first.
If you want to get ahold of me I'm almost always on Discord.
ultro
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sun May 15, 2016 5:26 am
Contact:

Re: [0.16.36]on_entity_damaged shotgun damage inaccurate ++

Post by ultro »

Ok, thanks.
Yea, sorry, however the damage inaccuracy is still present. What I should have said was it only displays 1 pellet as the damage not a (#ofpellets that connect x physical damage = final_damage_output) as the damage.

So what I meant to say was on the 12x5 shot - it displays 6 as the damage instead of the minimum damage being 5 for 1 pellet connecting up to a maximum 60 damage if all pellets connected. Same with 16 x 8 piercing shot - it displays 9.6 as the damage instead of the minimum of 8 as the damage for one pellet and up to a maximum of 128 damage for all pellets connecting, etc.

The reason you saw multiple 6s or 10s on the floating text on the images I posted was because I was shooting multiple biters. But for some reason it still only calculates 1 pellet as the damage output even though multiple pellets on that shot instance are hitting/connecting.

I did a game.print(event.final_damage_amount) test so i can see the damage when i hit the mob etc. And no matter how many pellets connect on that shot, it still will print and flying text as if only 1 pellet connected sadly. And I know its more damage for that output instance because when you hit lets say a biter nest you will see 80+ damage to the nest etc when highlighted over it, but only 10 or 6 dmg floating text or 6 or 9.6 on the game.print.

Is there anyway to combine the damage for that shot when its a shotgun damage to entity?

All the rest of the damage outputs are accurate for physical and explosive type ammo. IE a firearm magazine round with 5 damage will display and game.print 5 damage when it hits the mob, a 35 explosion 35 damage etc, but a let's say a 4pellet x 5 shot will not be 20damage displayed but 6damage, sadly - or a 7pellet x 8 shot will not be 56damage displayed but instead a 9.6 damage, sadly.

Thanks again,
Ultro.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14328
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.16.36]on_entity_damaged shotgun damage inaccurate ++

Post by Rseding91 »

You're experiencing the message spam prevention. It's printing the same value 12 times in the same tick and the game ignores 11 of the messages.

Change your printing so it includes some value that makes the message unique and you'll see it's printing the number for each pellet that connects.
If you want to get ahold of me I'm almost always on Discord.
ultro
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sun May 15, 2016 5:26 am
Contact:

Re: [0.16.36]on_entity_damaged shotgun damage inaccurate ++

Post by ultro »

Thanks, chief finally figured how to lua that

Ok, got it to print each pellet by doing this in a control.lua :

Code: Select all

script.on_event(defines.events.on_entity_damaged, function(event)
    if event.cause == nil then return end
    if event.force.name == "main_force" and event.entity.type == "unit" then
      if event.damage_type.name == "fire" then return end
      local color = {r=17,g=255,b=33}
      local damage = math.floor(event.final_damage_amount+0.5)
      local eposition = event.entity.position
      DamageText(damage, {eposition.x, eposition.y-2}, color)
      game.print(damage .. "[" .. global.damagecount .. "]")
      global.damagecount = global.damagecount+1
    end
end)
This is what it looks like when hitting a biter spawner shooting once and all 16pellets connect for the 6.46dmg

Image

But this proves a real problem for scripting, unless you know how to do it of course cause I have no clue lol - every single pellet on a shotgun shot is its own damage amount event on_entity_damage call there is no combination for physical damage type hits, i.e shotgun physical type vs machinegun physical type. the damage_type.name is simply physical for both kinds of weapons - so how the heck would you combine the 16pellets or however many that hit on an entity in that split-second or so time period into one flyingtext damage total output etc. instead of just spamming 6.46 damage 16 times using unique flyingtext :cry:

If you know anything, i'd greatly appreciate the input, thank you.
sparr
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: [0.16.36]on_entity_damaged shotgun damage inaccurate ++

Post by sparr »

store a table somewhere mapping entities to damage totals (by type?). increment those values on the damage event. then on_tick, print whatever is in that table and empty it.

I'm not sure if on_tick fires before or after the other events, so your damage display might be delayed by one tick.
ultro
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sun May 15, 2016 5:26 am
Contact:

Re: [0.16.36]on_entity_damaged shotgun damage inaccurate ++

Post by ultro »

the problem is there is no difference in shotgun-physical and bullet-physical added in the game yet for damage_type in the event on_entity_damaged.

Maybe the devs can add it after seeing this post because that table option will easily work but I need a damage_type differentiation like event.damage_type == "physical-shell" or something so only that damage type will trigger a table storage and on tick every 2/10 sec flying text total or something similar.

Because all the rest of the damage is accurate. and would not work in a table storage anyway because the timing on the event call with flying text is already accurate for every weapon in the game except shotgun shells.

At the moment though, this table option will definitely work for fire damage per second totals on a mob.

I simply will have to learn the code to store damage_type == "fire" into a table.insert by entity unit_number, final_damage_output - then like every 3/10 of a sec or so check if the table is has values then if so add the values in the table and flyingtext the total, then clear the table so the on_tick only triggers when damage is recorded.

If you know anything, add it to the post if you want. Hopefully the devs will see this and add some more damage_type for the event that differentiates between physical-shell damage and physical-bullet damage etc. Then the entity storage can be utilized.

Thanks again.
Post Reply

Return to “Resolved Problems and Bugs”