Author Topic: [MOD] Ohm/DPS calculation display  (Read 24543 times)

kuro11

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    6
    • View Profile
on: February 08, 2017, 11:54:33 PM
I couldn't find a way to display DPS/Ohms at a glance so I made this.

Just put that in 'data/scripts/lib/tooltipmaker.lua' at line 360
(Should be right before 'return tooltip' within the 'makeTurretTooltip' function.)

Video with description / install instructions better made than my two lines:
Made a little spotlight video that your free to add and install instructions at the end.



Code: [Select]
if turret.stoneEfficiency == 0 and turret.metalEfficiency == 0 then       
        tooltip:addLine(TooltipLine(15, 15))
       
        local multiShotMod = 1
       
        if turret.simultaneousShooting then
            multiShotMod = math.pow(0.85,turret.numWeapons - 1) -- hack for multi-shooting weapons with heat issues? found with very poor sample size of a 'study'
        end
       
        local averageHeat = turret.heatPerShot * turret.shotsPerSecond - turret.coolingRate
        local hotFireTime = multiShotMod*turret.maxHeat*0.85 / averageHeat
        local coolTime = turret.maxHeat*0.85 / turret.coolingRate
        local modifier = 1
       
        if turret.maxHeat > 0 then
            modifier = hotFireTime / (hotFireTime + coolTime)
        end
       
        local line = TooltipLine(lineHeight, fontSize)
        line.ltext = "N-DPS: " .. round(turret.dps * modifier,0)
        line.lcolor = ColorRGB(1.0, 0.7, 0.7)
        tooltip:addLine(line)
 
        local line = TooltipLine(lineHeight, fontSize)
        line.ltext = "S-DPS: " .. round(turret.dps * modifier * turret.shieldDamageMultiplicator,0)
        line.lcolor = ColorRGB(0.7, 0.7, 1.0)
        tooltip:addLine(line)
       
        local line = TooltipLine(lineHeight, fontSize)
        line.ltext = "H-DPS: " .. round(turret.dps * modifier * turret.hullDamageMultiplicator,0)
        line.lcolor = ColorRGB(0.7, 1.0, 0.7)
        tooltip:addLine(line)
       
        if turret.maxHeat > 0 then       
            local line = TooltipLine(lineHeight, fontSize)
            line.ltext = "Hot Fire Time: " .. round(hotFireTime,1)
            line.lcolor = ColorRGB(1, 1, 1)
            tooltip:addLine(line)
           
            local line = TooltipLine(lineHeight, fontSize)
            line.ltext = "Cool Time: " .. round(coolTime,1)
            line.lcolor = ColorRGB(1, 1, 1)
            tooltip:addLine(line)
                   
            local line = TooltipLine(lineHeight, fontSize)
            line.ltext = "HR/SPF/CR: " .. round(turret.heatPerShot, 1) .. "/" .. round(turret.shotsPerFiring, 1) .. "/" .. round(turret.coolingRate, 1)
            line.lcolor = ColorRGB(1, 1, 1)
            tooltip:addLine(line)           
        elseif turret.shotsPerFiring > 1 then
            local line = TooltipLine(lineHeight, fontSize)
            line.ltext = "SPF: " .. round(turret.shotsPerFiring, 1)
            line.lcolor = ColorRGB(1, 1, 1)
            tooltip:addLine(line)       
        end
       
        if turret.simultaneousShooting then
            local line = TooltipLine(lineHeight, fontSize)
            line.ltext = "Multifire: " .. turret.numWeapons
            line.lcolor = ColorRGB(1, 1, 1)
            tooltip:addLine(line)
        end   
    end   


Here is what it looks like: http://imgur.com/a/RVw3C

N-DPS is the nominal without mods
S-DPS is shield DPS
H-DPS is hull DPS

Hot Fire Time is how long the gun will shoot after one overheat->cooldown cycle while holding the trigger
Cool Time is how long the gun will shoot after one overheat->cooldown cycle while holding the trigger
HR/SPF/CR: HR = heat gained per bullet/heat rate, SPF = shots per pull of trigger, CR = cooling rate
Multifire = #, the number of barrels that fire in one pull of trigger

I was able to make some really odd turrets like a SPF of 3 on a Multifire of 4 to fire 12 rounds each trigger bull.
SPF is like the "burst fire" and Multifire is where all the bullets come out at once.

Anyway, not guaranteed to work 100%, but it at least gives you an easy glance approximation.
Likely easily applied to fighters because turrets and fighters share so many of the same properties. but I don't use them, so...  :P

Code under WTFPL
« Last Edit: February 09, 2017, 03:43:28 PM by kuro11 »



LordMaddog

  • Full Member
  • ***
  • Status:
    Offline
    Posts:
    224
    • View Profile
on: February 09, 2017, 12:03:05 AM
O WOW THANK YOU!!!!

Testing it now.



LoSboccacc

  • Full Member
  • ***
  • Status:
    Offline
    Posts:
    104
    • View Profile
on: February 09, 2017, 02:18:25 AM
Can you also add dps adjusted with cooldown directly on the lines there? It's nice to know the dps at regime while holding the mouse button down, especially for cannons that overheat every burst.



WARGAMES

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    37
    • View Profile
on: February 09, 2017, 03:37:43 AM
my question would be is this showing the actual dps when double, triple or multishot are all added in.  in some cases that more than one barrel seem to not do more but others have multiple shots instead.



kuro11

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    6
    • View Profile
on: February 09, 2017, 04:02:54 AM
DPS listings take into account both cooldown times AND multi-barreled / "burstfire" and whatever combination thereof.
Or, should be somewhat accurate - it is designed to do that (no warrenty on it REALLY doing that)



WARGAMES

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    37
    • View Profile
on: February 09, 2017, 04:53:53 AM
I heard some barrels aren't more than 1 shot but others show it is for some dps stats.  is it just the energy weapons that more than one barrel don't mean anything?  because then it may clear up some things.



Kane Hart

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    271
  • The Talk Too Much Guy!
    • View Profile
    • My Youtube
on: February 09, 2017, 06:05:39 AM
Thank god this has been finally made. thank you so much :)



lyravega

  • Jr. Member
  • **
  • Status:
    Offline
    Posts:
    85
    • View Profile
    • Steam
on: February 09, 2017, 06:30:52 AM
DPS listings take into account both cooldown times AND multi-barreled / "burstfire" and whatever combination thereof.
Or, should be somewhat accurate - it is designed to do that (no warrenty on it REALLY doing that)

maxHeat can go over 10; if you have a cannon that generates 9.5 heat per shot for example, 2nd shot will take it up to 18. The game has 2 variables called shootingTime and coolingTime but due to this the latter is incorrect. Depending on the cooldownRate, shootingTime wildly varies as well but they both can be used for approximations.
Detailed Turret Tooltips - mod for all your turret info needs
Compass-like Gate Pixel Icons - unnecessary quality of life improvement

Poke me on Steam for updates



kuro11

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    6
    • View Profile
on: February 09, 2017, 06:44:44 AM
@WARGAMES
All visuals aside, the key to DPS calc from my testing (again, not 100% confident) are two things:
* "simultaneousShooting"
* "shotsPerFiring"
These two properties are represented as
"Multibarrel" on the bottom and "SPF" respectively in this mod.
I forced all combinations of those two on testing.

An easy example are cannons, which seem to have a higher incidence of "Multibarrel"- when you click once there are X bullets that appear at once.
SPF > 1 represents the "burstfire"

So, in this gun (an odd case):
http://i.imgur.com/C5eoF6C.png
There are 9.4 Damage projectiles.
A "Fire" occurs 2 times per second.
And Multifire = 3
Thus, 9.4*2*3=56.4 visual.
The "TurretTemplate" type itself has a "dps" property, which is displayed as the N-DPS value (from what I see, this is likely more accurate than calculating it myself each time based on shots and stuff)

(rate of fire, damage are rounded in the UI AND I round the DPS - so that is why we have that 56.4 vs 58)

Thus, you get - at a glance - reasonable DPS with all factors accounted for.

This includes heat, which is significantly trickier to deal with and before this mod you had basically NO idea how much that factored into a weapons effectiveness.


@lyravega
That is a really good point - I don't take that into account.
I did find a really strange thing ('addressed' by the hack comment in the code) where multibarrel weapons heat up MUCH faster (at 4 barrels - with simultaneousShooting == true ) than expected.

Cooldown times were (in the cases I tested, about 20-50 guns generated with /inventory mod) very close to expected in all cases - it was only the getting to overheat that seemed to behave strangely.

However, these numbers are accurate enough for me thus far so I don't think I'm going to try and improve them at the moment (I want to actually play the game :P





lyravega

  • Jr. Member
  • **
  • Status:
    Offline
    Posts:
    85
    • View Profile
    • Steam
on: February 09, 2017, 07:06:35 AM
@lyravega
That is a really good point - I don't take that into account.
I did find a really strange thing ('addressed' by the hack comment in the code) where multibarrel weapons heat up MUCH faster (at 4 barrels - with simultaneousShooting == true ) than expected.

Cooldown times were (in the cases I tested, about 20-50 guns generated with /inventory mod) very close to expected in all cases - it was only the getting to overheat that seemed to behave strangely.

However, these numbers are accurate enough for me thus far so I don't think I'm going to try and improve them at the moment (I want to actually play the game :P)

Each weapon ("barrel") generates that much heat, so if simultaneousShooting==true then heatPerShot=2 actually generates 8 heat for that turret as all weapons are fired at the same time. cooldownRate is for turret so it is what you see unlike heatPerShot.

And I get you. I've been working on my tooltip thing for a while, now just wanna play the game :)
Detailed Turret Tooltips - mod for all your turret info needs
Compass-like Gate Pixel Icons - unnecessary quality of life improvement

Poke me on Steam for updates



Kane Hart

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    271
  • The Talk Too Much Guy!
    • View Profile
    • My Youtube
on: February 09, 2017, 08:22:18 AM
Made a little spotlight video that your free to add and install instructions at the end.




kuro11

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    6
    • View Profile
on: February 09, 2017, 03:40:46 PM
@Kane Hart
Neat. I feel internet famous now 8)

I'll put that video in the OP since it helps people install it.

Not a big fan of having a download / overwrite of the whole script - but if that is the standard at the moment I'll go ahead and do so.

Ideally, the dev will allow for decoration of methods as a separate file - much reducing the chance of an update / conflicting mod breaking things.
(New to LUA, normally in C# land so I don't know how reasonable that is. Disclaimer my knowledge on that front is ~5 minutes google to here: http://lua-users.org/wiki/DecoratorsAndDocstrings )
« Last Edit: February 09, 2017, 03:47:06 PM by kuro11 »



Kane Hart

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    271
  • The Talk Too Much Guy!
    • View Profile
    • My Youtube
on: February 09, 2017, 07:05:25 PM
Yeah I agree your method is better but then again you have to sometimes put your shoes in theirs. I prefer your method but then 80% of people will have more issues with it sadly till modding gets a bit of a fix.

That being said is the n-dps for example counting the cooldowns and such? Someone kept saying they did not think it did in the video and found it useless and did not want to lie in the comments with a reply on it hehe.



kuro11

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    6
    • View Profile
on: February 09, 2017, 10:30:04 PM
It SHOULD be taking into account cooldown time loop.

e.g.
A gun that shoots 1 damage bullets
3 times per second
with a Cool Time of 5 seconds
and a Hot Fire Time of 2 seconds

The calculator would show:
1*3 * ( 2 / (2+5) ) ~= 0.85 DPS
(it would round but whatever)

In your demo video, the gun does:
196.7 Damage per bullet
24 times per second
with a Cool time of 1.8
and a Hot Fire Time of 0.8
that means:
196.7 * 24 * ( 0.8 / ( 0.8 + 1.8 ) ~= 1452

Now, it IS different than the 1521 displayed there in the video, but likely because the display values are not the full (unrounded) values. Also, I use the "dps" property of the weapon provided by the engine as I assumed it is more accurate.

Still, that is like a 6% error depending on how I calculate it - still valid for apples to apples and since all guns are calculated the same way you at least know if one gun is better than the next (except Multi fire > 1 and overheating - which, as mentioned, is odd/hacky in how I 'solved' it)

« Last Edit: February 10, 2017, 04:53:20 PM by kuro11 »



Kane Hart

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    271
  • The Talk Too Much Guy!
    • View Profile
    • My Youtube
on: February 10, 2017, 10:34:02 AM
I wish this mod could do something with Power ones like say WARNING SHITTY WEAPONS DETECTED lol.. So many power lasers I get can't even run more then 2 seconds hehe.