Untitled diff

Created Diff never expires
404 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
454 lines
690 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
740 lines
package.path = package.path .. ";data/scripts/lib/?.lua"
package.path = package.path .. ";data/scripts/lib/?.lua"
package.path = package.path .. ";data/scripts/?.lua"
package.path = package.path .. ";data/scripts/?.lua"


require ("utility")
require ("utility")
require ("stringutility")
require ("stringutility")


local lyr_debug = false

local iconColor = ColorRGB(0.5, 0.5, 0.5)
local iconColor = ColorRGB(0.5, 0.5, 0.5)


local headLineSize = 25
local headLineSize = 22
local headLineFont = 15
local headLineFont = 16


local function fillWeaponTooltipData(obj, tooltip)
local function fillWeaponTooltipData(obj, tooltip)

local lyr = {}
-- rarity name
local line = TooltipLine(5, 12)
lyr.generatesHeat = obj.maxHeat == 10
line.ctext = tostring(obj.rarity)
lyr.usesPower = obj.coolingType == 2
line.ccolor = obj.rarity.color
lyr.drainsEnergy = obj.coolingType == 1
tooltip:addLine(line)
lyr.burstFire = obj.shootingTime < 2

-- primary stats, one by one
lyr.isBeam = obj.continuousBeam
local fontSize = 14
lyr.isProjectile = not lyr.isBeam
local lineHeight = 20

lyr.activeWeapons = obj.simultaneousShooting and obj.numWeapons > 1 and obj.numWeapons or 1
local line = TooltipLine(lineHeight, fontSize)
lyr.projectilePerTurret = lyr.activeWeapons * obj.shotsPerFiring
line.ltext = "Tech"%_t
lyr.damage = lyr.projectilePerTurret * obj.damage --lyr.damagePerShot
line.rtext = round(obj.averageTech, 1)
line.icon = "data/textures/icons/circuitry.png";
lyr.adjustedFireRate = obj.fireRate
line.iconColor = iconColor
tooltip:addLine(line)
if lyr.usesPower or lyr.drainsEnergy then

lyr.heatPerShot = lyr.activeWeapons * obj.heatPerShot
-- empty line
lyr.energyIncreasePerSecond = lyr.activeWeapons*obj.energyIncreasePerSecond
tooltip:addLine(TooltipLine(15, 15))
elseif lyr.generatesHeat then

lyr.coolingRate = obj.coolingRate
if obj.damage > 0 then
lyr.coolingPerShot = lyr.coolingRate/obj.fireRate
if obj.continuousBeam then
lyr.heatPerShot = lyr.activeWeapons * obj.heatPerShot

local line = TooltipLine(lineHeight, fontSize)
lyr.accumulatedHeat = lyr.heatPerShot
line.ltext = "Damage /s"%_t
--lyr.timeToCooldown
line.rtext = round(obj.dps, 1)
lyr.timeToOverheat = 0
line.icon = "data/textures/icons/screen-impact.png";
lyr.shotsToOverheat = 1
line.iconColor = iconColor
lyr.timePerShot = 1/ obj.fireRate
tooltip:addLine(line)
lyr.uptimeRatio = 1

else
lyr.adjustedHeatPerShot = lyr.heatPerShot - lyr.coolingPerShot
-- damage
lyr.adjustedMaxHeat = obj.maxHeat - lyr.heatPerShot
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Damage"%_t
lyr.neverOverheats = false
line.rtext = round(obj.damage, 1)
lyr.instantlyOverheats = false
if obj.shotsPerFiring > 1 then
--lyr.coolingEfficiency
line.rtext = line.rtext .. " x" .. obj.shotsPerFiring
end
if lyr.heatPerShot >= obj.maxHeat then
line.icon = "data/textures/icons/screen-impact.png";
lyr.instantlyOverheats = true
line.iconColor = iconColor
elseif lyr.coolingPerShot >= lyr.heatPerShot then
tooltip:addLine(line)
lyr.neverOverheats = true

else
-- fire rate
lyr.shotsToOverheat = math.ceil( lyr.adjustedMaxHeat / lyr.adjustedHeatPerShot ) +1
local line = TooltipLine(lineHeight, fontSize)
lyr.accumulatedHeat = lyr.accumulatedHeat + ( lyr.shotsToOverheat -1) * lyr.adjustedHeatPerShot
line.ltext = "Fire Rate"%_t
lyr.timeToOverheat = lyr.timeToOverheat + ( lyr.shotsToOverheat -1) * lyr.timePerShot
line.rtext = round(obj.fireRate, 1)
end
line.icon = "data/textures/icons/bullets.png";
line.iconColor = iconColor
lyr.timeToCooldown = lyr.accumulatedHeat / lyr.coolingRate
tooltip:addLine(line)
lyr.cycle = lyr.timeToCooldown + lyr.timeToOverheat
end
end
if lyr.instantlyOverheats then

if lyr.timePerShot <= lyr.timeToCooldown then
if obj.otherForce > 0 then
lyr.adjustedFireRate = 1/ lyr.timeToCooldown
local line = TooltipLine(lineHeight, fontSize)
end
line.ltext = "Push"%_t
elseif not lyr.neverOverheats then
line.rtext = toReadableValue(obj.otherForce, "N /* unit: Newton*/"%_t)
lyr.uptimeRatio = lyr.timeToOverheat / (lyr.cycle)
line.icon = "data/textures/icons/back-forth.png";
end
line.iconColor = iconColor
tooltip:addLine(line)
--lyr.coolingEfficiency = lyr.adjustedFireRate / obj.fireRate *100
elseif obj.otherForce < 0 then
lyr.coolingEfficiency = lyr.coolingPerShot / (lyr.heatPerShot*lyr.adjustedFireRate)
local line = TooltipLine(lineHeight, fontSize)
lyr.damagePerCycle = lyr.shotsToOverheat * lyr.damage
line.ltext = "Pull"%_t
lyr.dps = lyr.damagePerCycle / lyr.cycle
line.rtext = toReadableValue(-obj.otherForce, "N /* unit: Newton*/"%_t)
end
line.icon = "data/textures/icons/back-forth.png";
line.iconColor = iconColor
-- rarity name
tooltip:addLine(line)
local line = TooltipLine(5, 12)
end
line.ltext = "Tech: "..round(obj.averageTech, 1) --lyr_nt

line.ctext = tostring(obj.rarity)
if obj.selfForce > 0 then
line.rtext = obj.material.name
local line = TooltipLine(lineHeight, fontSize)
line.rcolor = obj.material.color
line.ltext = "Self Push"%_t
line.ccolor = obj.rarity.color
line.rtext = toReadableValue(obj.selfForce, "N /* unit: Newton*/"%_t)
tooltip:addLine(line)
line.icon = "data/textures/icons/back-forth.png";
line.iconColor = iconColor
tooltip:addLine(line)
elseif obj.selfForce < 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Self Pull"%_t
line.rtext = toReadableValue(-obj.selfForce, "N /* unit: Newton*/"%_t)
line.icon = "data/textures/icons/back-forth.png";
line.iconColor = iconColor
tooltip:addLine(line)
end

if obj.stoneEfficiency > 0 and obj.metalEfficiency > 0 then

local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Eff. Stone"%_t
line.rtext = round(obj.stoneEfficiency * 100, 1)
line.icon = "data/textures/icons/recycle.png";
line.iconColor = iconColor
tooltip:addLine(line)


local line = TooltipLine(lineHeight, fontSize)
-- primary stats, one by one
line.ltext = "Eff. Metal"%_t
local fontSize = 14
line.rtext = round(obj.metalEfficiency * 100, 1)
local lineHeight = 20
line.icon = "data/textures/icons/recycle.png";
line.iconColor = iconColor
tooltip:addLine(TooltipLine(25,15))
tooltip:addLine(line)
if lyr.isBeam then --beam weapons: teslaGun, repairBeam, laser, forceGun, salvagingLaser, miningLaser
if obj.stoneEfficiency > 0 or obj.metalEfficiency > 0 then
if obj.stoneEfficiency > 0 and obj.metalEfficiency > 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Mining & Salvaging" --lyr_nt
line.rtext = round(obj.dps, 1).."/s"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 1
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Efficiencies" --lyr_nt
line.rtext = round(obj.stoneEfficiency * 100, 1).."% & "..round(obj.metalEfficiency * 100, 1).."%"
line.icon = "data/textures/icons/recycle.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
elseif obj.stoneEfficiency > 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Mining" --lyr_nt
line.rtext = round(obj.dps, 1).."/s"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 1
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Efficiency" --lyr_nt
line.rtext = round(obj.stoneEfficiency * 100, 1).."%"
line.icon = "data/textures/icons/recycle.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
else --if obj.metalEfficiency > 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Salvaging" --lyr_nt
line.rtext = round(obj.dps, 1).."/s"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 1
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Efficiency" --lyr_nt
line.rtext = round(obj.metalEfficiency * 100, 1).."%"
line.icon = "data/textures/icons/recycle.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
end
elseif obj.otherForce ~= 0 or obj.selfForce ~= 0 then
-- if obj.otherForce == 0 or obj.selfForce == 0 then
-- tooltip:addLine(TooltipLine(lineHeight, fontSize)) --line 1
-- end
if obj.otherForce > 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Push"%_t
line.rtext = toReadableValue(obj.otherForce, "N /* unit: Newton*/"%_t)
line.icon = "data/textures/icons/back-forth.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 1 or 2
elseif obj.otherForce < 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Pull"%_t
line.rtext = toReadableValue(-obj.otherForce, "N /* unit: Newton*/"%_t)
line.icon = "data/textures/icons/back-forth.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 1 or 2
end
if obj.selfForce > 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Self Push"%_t
line.rtext = toReadableValue(obj.selfForce, "N /* unit: Newton*/"%_t)
line.icon = "data/textures/icons/back-forth.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
elseif obj.selfForce < 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Self Pull"%_t
line.rtext = toReadableValue(-obj.selfForce, "N /* unit: Newton*/"%_t)
line.icon = "data/textures/icons/back-forth.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
end
elseif obj.hullRepairRate > 0 or obj.shieldRepairRate > 0 then
-- if obj.hullRepairRate == 0 or obj.shieldRepairRate == 0 then
-- tooltip:addLine(TooltipLine(lineHeight, fontSize)) --line 1
-- end
if obj.hullRepairRate > 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Hull Repair" --lyr_nt
line.rtext = round(obj.hullRepairRate, 1).."/s"
line.icon = "data/textures/icons/health-normal.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 1 or 2
end
if obj.shieldRepairRate > 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Shield Charge" --lyr_nt
line.rtext = round(obj.shieldRepairRate, 1).."/s"
line.icon = "data/textures/icons/health-normal.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
end
else --if obj.damage > 0
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Continuous Damage" --lyr_nt
line.rtext = round(obj.dps, 1).."/s"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 1
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Tick Damage" --lyr_nt
line.rtext = round(obj.damage, 1).."/tick"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
end
else --projectile weapons: railGun, lightningGun, rocketLauncher, cannon, plasmaGun, bolter, chainGun
if lyr.generatesHeat and not lyr.neverOverheats then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Weighted Damage" --lyr_nt
line.rtext = round(lyr.dps, 1).."/s"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 1
if lyr.burstFire then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Burst Damage" --lyr_nt
line.rtext = round(lyr.damagePerCycle, 1).."/burst"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
else
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Projectile Damage" --lyr_nt
line.rtext = lyr.projectilePerTurret > 1 and lyr.projectilePerTurret.."x"..round(obj.damage, 1).."/shot" or round(obj.damage, 1).."/shot"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
end
else
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Sustained Damage" --lyr_nt
line.rtext = round(obj.dps, 1).."/s"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 1
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Projectile Damage" --lyr_nt
line.rtext = lyr.projectilePerTurret > 1 and lyr.projectilePerTurret.."x"..round(obj.damage, 1).."/shot" or round(obj.damage, 1).."/shot"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
end
end


elseif obj.stoneEfficiency > 0 then
-- fire rate
local line = TooltipLine(lineHeight, fontSize)
if lyr.burstFire then
line.ltext = "Efficiency"%_t
local line = TooltipLine(lineHeight, fontSize)
line.rtext = round(obj.stoneEfficiency * 100, 1)
line.ltext = "Burst Rate" --lyr_nt
line.icon = "data/textures/icons/recycle.png";
line.rtext = round(lyr.cycle, 1).."s/burst"
line.iconColor = iconColor
line.icon = "data/textures/icons/bullets.png";
tooltip:addLine(line)
line.iconColor = iconColor
elseif obj.metalEfficiency > 0 then
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
else
line.ltext = "Efficiency"%_t
local line = TooltipLine(lineHeight, fontSize)
line.rtext = round(obj.metalEfficiency * 100, 1)
line.ltext = lyr.isBeam and "Tick Rate" or "Fire Rate" --lyr_nt
line.icon = "data/textures/icons/recycle.png";
line.rtext = round(lyr.adjustedFireRate, 1).."/s"
line.iconColor = iconColor
line.icon = "data/textures/icons/bullets.png";
tooltip:addLine(line)
line.iconColor = iconColor
end
tooltip:addLine(line)
end


if obj.hullRepairRate > 0 then
local line = TooltipLine(lineHeight, fontSize)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Accuracy"%_t
line.ltext = "Hull Dmg /s"%_t
line.rtext = (lyr.isBeam or obj.accuracy == 1) and "Absolute" or round(obj.accuracy * 100, 1).."%"
line.rtext = round(obj.hullRepairRate, 1)
line.icon = "data/textures/icons/reticule.png";
line.icon = "data/textures/icons/health-normal.png";
line.iconColor = iconColor
line.iconColor = iconColor
tooltip:addLine(line)
tooltip:addLine(line)
end


if obj.shieldRepairRate > 0 then
local line = TooltipLine(lineHeight, fontSize)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Velocity" --lyr_nt
line.ltext = "Shield Dmg /s"%_t
line.rtext = (lyr.isBeam or obj.shotSpeed > obj.reach*60) and "Instant" or round(obj.shotSpeed*10, 0).."m/s"
line.rtext = round(obj.shieldRepairRate, 1)
line.icon = "data/textures/icons/blaster.png";
line.icon = "data/textures/icons/health-normal.png";
line.iconColor = iconColor
line.iconColor = iconColor
tooltip:addLine(line)
tooltip:addLine(line)
end


local line = TooltipLine(lineHeight, fontSize)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Accuracy"%_t
line.ltext = "Range"%_t
line.rtext = round(obj.accuracy * 100, 1)
line.rtext = round(obj.reach*10/1000, 2).."km"
line.icon = "data/textures/icons/reticule.png";
line.icon = "data/textures/icons/target-shot.png";
line.iconColor = iconColor
line.iconColor = iconColor
tooltip:addLine(line)
tooltip:addLine(line)


local line = TooltipLine(lineHeight, fontSize)
-- empty line
line.ltext = "Range"%_t
tooltip:addLine(TooltipLine(15, 15))
line.rtext = round(obj.reach * 10 / 1000, 2)
line.icon = "data/textures/icons/target-shot.png";
if lyr.usesPower then
line.iconColor = iconColor
local line = TooltipLine(lineHeight, fontSize)
tooltip:addLine(line)
line.ltext = "Power Demand" --lyr_nt
line.rtext = round(lyr.heatPerShot+lyr.energyIncreasePerSecond, 1).."MW/s"
line.icon = "data/textures/icons/electric.png";
line.iconColor = iconColor
tooltip:addLine(line)


-- empty line
local line = TooltipLine(lineHeight, fontSize)
tooltip:addLine(TooltipLine(15, 15))
line.ltext = "Accumulation" --lyr_nt
line.rtext = "+"..round(lyr.energyIncreasePerSecond, 0).."MW/s"
line.icon = "data/textures/icons/electric.png";
line.iconColor = iconColor
tooltip:addLine(line)


if obj.coolingType == 1 or obj.coolingType == 2 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Dispersion" --lyr_nt
line.rtext = "-"..round(obj.coolingRate, 0).."MW/s"
line.icon = "data/textures/icons/electric.png";
line.iconColor = iconColor
tooltip:addLine(line)


local line = TooltipLine(lineHeight, fontSize)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Demand Ratio" --lyr_nt
line.rtext = round(obj.coolingRate/lyr.energyIncreasePerSecond).."x"
line.icon = "data/textures/icons/electric.png";
line.iconColor = iconColor
tooltip:addLine(line)


if obj.coolingType == 2 then
-- empty line
line.ltext = "Energy /s"%_t
tooltip:addLine(TooltipLine(15, 15))
else
elseif lyr.drainsEnergy then
line.ltext = "Energy /shot"%_t
local line = TooltipLine(lineHeight, fontSize)
end
line.ltext = "Energy Drain" --lyr_nt
line.rtext = round(obj.baseEnergyPerSecond)
line.rtext = round(lyr.heatPerShot+lyr.energyIncreasePerSecond, 1).."MJ/shot"
line.icon = "data/textures/icons/electric.png";
line.icon = "data/textures/icons/battery-pack-alt.png";
line.iconColor = iconColor
line.iconColor = iconColor
tooltip:addLine(line)
tooltip:addLine(line)


local line = TooltipLine(lineHeight, fontSize)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Energy Increase /s"%_t
line.ltext = "Accumulation" --lyr_nt
line.rtext = round(obj.energyIncreasePerSecond, 1)
line.rtext = "+"..round(lyr.energyIncreasePerSecond*lyr.adjustedFireRate, 0).."MJ/s"
line.icon = "data/textures/icons/electric.png";
line.icon = "data/textures/icons/battery-pack-alt.png";
line.iconColor = iconColor
line.iconColor = iconColor
tooltip:addLine(line)
tooltip:addLine(line)


-- empty line
local line = TooltipLine(lineHeight, fontSize)
tooltip:addLine(TooltipLine(15, 15))
line.ltext = "Dispersion" --lyr_nt
end
line.rtext = "-"..round(obj.coolingRate, 0).."MJ/s"
line.icon = "data/textures/icons/battery-pack-alt.png";
line.iconColor = iconColor
tooltip:addLine(line)


local line = TooltipLine(lineHeight, fontSize)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Material"%_t
line.ltext = "Drain Ratio" --lyr_nt
line.rtext = obj.material.name
line.rtext = round((obj.coolingRate/lyr.energyIncreasePerSecond)/lyr.adjustedFireRate).."x"
line.rcolor = obj.material.color
line.icon = "data/textures/icons/battery-pack-alt.png";
line.icon = "data/textures/icons/metal-bar.png";
line.iconColor = iconColor
line.iconColor = iconColor
tooltip:addLine(line)
tooltip:addLine(line)


-- empty line
tooltip:addLine(TooltipLine(15, 15))
elseif lyr.generatesHeat and not lyr.neverOverheats then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Heat Generation" --lyr_nt
line.rtext = "+"..round(lyr.heatPerShot*10, 0).."%/shot"
line.icon = "data/textures/icons/flame.png";
line.iconColor = iconColor
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Overheat Time" --lyr_nt
line.rtext = round(lyr.timeToOverheat, 1).."s"
line.icon = "data/textures/icons/flame.png";
line.iconColor = iconColor
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Heat Dissipation" --lyr_nt
line.rtext = "-"..round(obj.coolingRate*10, 0).."%/s"
line.icon = "data/textures/icons/flame.png";
line.iconColor = iconColor
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Cooldown Time" --lyr_nt
line.rtext = round(lyr.timeToCooldown, 1).."s"
line.icon = "data/textures/icons/flame.png";
line.iconColor = iconColor
tooltip:addLine(line)
-- empty line
tooltip:addLine(TooltipLine(15, 15))
end
--lyr_test
if lyr_debug then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "drainTest"
line.rtext = obj.baseEnergyPerSecond/obj.shotsPerSecond+obj.energyIncreasePerSecond
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "numWeapons"
line.rtext = obj.numWeapons and round(obj.numWeapons, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "numVisibleWeapons"
line.rtext = obj.numVisibleWeapons and round(obj.numVisibleWeapons, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "coolingType"
line.rtext = obj.coolingType and round(obj.coolingType, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "coolingTime"
line.rtext = obj.coolingTime and round(obj.coolingTime, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "shootingTime"
line.rtext = obj.shootingTime and round(obj.shootingTime, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "heatPerShot"
line.rtext = obj.heatPerShot and round(obj.heatPerShot, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "dps"
line.rtext = obj.dps and round(obj.dps, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "damage"
line.rtext = obj.damage and round(obj.damage, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "heat"
line.rtext = obj.heat and round(obj.heat, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "requiredShootingEnergy"
line.rtext = obj.requiredShootingEnergy and round(obj.requiredShootingEnergy, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "fireRate"
line.rtext = obj.fireRate and round(obj.fireRate, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "maxHeat"
line.rtext = obj.maxHeat and round(obj.maxHeat, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "coolingRate"
line.rtext = obj.coolingRate and round(obj.coolingRate, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "baseEnergyPerSecond"
line.rtext = obj.baseEnergyPerSecond and round(obj.baseEnergyPerSecond, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "energyIncreasePerSecond"
line.rtext = obj.energyIncreasePerSecond and round(obj.energyIncreasePerSecond, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "firingsPerSecond"
line.rtext = obj.firingsPerSecond and round(obj.firingsPerSecond, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "shotsPerSecond"
line.rtext = obj.shotsPerSecond and round(obj.shotsPerSecond, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "shotsPerFiring"
line.rtext = obj.shotsPerFiring and round(obj.shotsPerFiring, 3) or "-"
tooltip:addLine(line)
tooltip:addLine(TooltipLine(15, 15))
end
--lyr_test
end
end


local function fillDescriptions(obj, tooltip, additional)
local function fillDescriptions(obj, tooltip)

local ignoreList = {["Burst Fire"] = true, ["Consumes Energy"] = true, ["Overheats"] = true}
-- now count the lines, as there will have to be lines inserted
--local ignoreList = {}
-- to make sure that the icon of the weapon won't overlap with the stats
local extraLines = 0
-- now count the lines, as there will have to be lines inserted
local fontSize = 14
-- to make sure that the icon of the weapon won't overlap with the stats
local lineHeight = 18
local extraLines = 1
additional = additional or {}
local fontSize = 12

local lineHeight = 15
-- one line for flavor text
local line = TooltipLine(lineHeight, fontSize)
line.ltext = obj.flavorText
line.lcolor = ColorRGB(1.0, 0.7, 0.7)
tooltip:addLine(line)

extraLines = extraLines + 1

local descriptions = obj:getDescriptions()

for desc, value in pairs(descriptions) do
local line = TooltipLine(lineHeight, fontSize)

if value == "" then
line.ltext = desc % _t
else
line.ltext = string.format(desc % _t, value)
end

local existsAlready
for _, desc in pairs(additional) do
if desc == line.ltext then
existsAlready = true
end
end


if not existsAlready then
-- one line for flavor text
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
extraLines = extraLines + 1
line.ltext = obj.flavorText
end
line.lcolor = ColorRGB(1.0, 0.7, 0.7)
end
tooltip:addLine(line)


if obj.seeker then
local descriptions = obj:getDescriptions()
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Seeker Missiles"%_t
tooltip:addLine(line)
extraLines = extraLines + 1
end


for _, text in pairs(additional) do
for desc, value in pairs(descriptions) do
local line = TooltipLine(lineHeight, fontSize)
if not ignoreList[desc] then
line.ltext = text
extraLines = extraLines + 1
tooltip:addLine(line)
end
extraLines = extraLines + 1
end
end


for i = 1, 3 - extraLines do
for i = 1, 3 - extraLines do
-- empty line
-- empty line
tooltip:addLine(TooltipLine(15, 15))
tooltip:addLine(TooltipLine(lineHeight, fontSize))
end
end


for desc, value in pairs(descriptions) do
if not ignoreList[desc] then
local line = TooltipLine(lineHeight, fontSize)
if value == "" then
line.ltext = desc % _t
else
line.ltext = string.format(desc % _t, value)
end
tooltip:addLine(line)
end
end
end
end


function makeTurretTooltip(turret)
function makeTurretTooltip(turret)
local tooltip = Tooltip()
local tooltip = Tooltip()

local description = {}
-- create tool tip
tooltip.icon = turret.weaponIcon

-- build title
local title = ""

local weapon = turret.weaponPrefix .. " /* Weapon Prefix*/"
weapon = weapon % _t

local tbl = {material = turret.material.name, weaponPrefix = weapon}


if turret.stoneEfficiency > 0 or turret.metalEfficiency > 0 then
-- create tool tip
if turret.numVisibleWeapons == 1 then
tooltip.icon = turret.weaponIcon
title = "${material} ${weaponPrefix} Turret"%_t % tbl
elseif turret.numVisibleWeapons == 2 then
title = "Double ${material} ${weaponPrefix} Turret"%_t % tbl
elseif turret.numVisibleWeapons == 3 then
title = "Triple ${material} ${weaponPrefix} Turret"%_t % tbl
elseif turret.numVisibleWeapons == 4 then
title = "Quad ${material} ${weaponPrefix} Turret"%_t % tbl
else
title = "Multi ${material} ${weaponPrefix} Turret"%_t % tbl
end
else
if turret.numVisibleWeapons == 1 then
title = "${weaponPrefix} Turret"%_t % tbl
elseif turret.numVisibleWeapons == 2 then
title = "Double ${weaponPrefix} Turret"%_t % tbl
elseif turret.numVisibleWeapons == 3 then
title = "Triple ${weaponPrefix} Turret"%_t % tbl
elseif turret.numVisibleWeapons == 4 then
title = "Quad ${weaponPrefix} Turret"%_t % tbl
else
title = "Multi ${weaponPrefix} Turret"%_t % tbl
end
end


-- head line
-- build title
local line = TooltipLine(headLineSize, headLineFont)
local title = ""
line.ctext = title
line.ccolor = turret.rarity.color
tooltip:addLine(line)


local fontSize = 14;
local weapon = turret.weaponPrefix .. " /* Weapon Prefix*/"
local lineHeight = 20;
weapon = weapon % _t


fillWeaponTooltipData(turret, tooltip)
local tbl = {material = turret.material.name, weaponPrefix = weapon}


-- size
if turret.stoneEfficiency > 0 or turret.metalEfficiency > 0 then
local line = TooltipLine(lineHeight, fontSize)
if turret.numVisibleWeapons == 1 then
line.ltext = "Size"%_t
title = "${material} ${weaponPrefix} Turret"%_t % tbl
line.rtext = round(turret.size, 1)
elseif turret.numVisibleWeapons == 2 then
line.icon = "data/textures/icons/shotgun.png";
title = "Double ${material} ${weaponPrefix} Turret"%_t % tbl
line.iconColor = iconColor
elseif turret.numVisibleWeapons == 3 then
tooltip:addLine(line)
title = "Triple ${material} ${weaponPrefix} Turret"%_t % tbl
elseif turret.numVisibleWeapons == 4 then
title = "Quad ${material} ${weaponPrefix} Turret"%_t % tbl
else
title = "Multi ${material} ${weaponPrefix} Turret"%_t % tbl
end
else
if turret.numVisibleWeapons == 1 then
title = "${weaponPrefix} Turret"%_t % tbl
elseif turret.numVisibleWeapons == 2 then
title = "Double ${weaponPrefix} Turret"%_t % tbl
elseif turret.numVisibleWeapons == 3 then
title = "Triple ${weaponPrefix} Turret"%_t % tbl
elseif turret.numVisibleWeapons == 4 then
title = "Quad ${weaponPrefix} Turret"%_t % tbl
else
title = "Multi ${weaponPrefix} Turret"%_t % tbl
end
end


-- automatic/independent firing
-- head line
if turret.automatic then
local line = TooltipLine(headLineSize-5, headLineFont)
local line = TooltipLine(lineHeight, fontSize)
line.ctext = title
line.ltext = "Independent Targeting"%_t
line.ccolor = turret.rarity.color
line.icon = "data/textures/icons/cog.png";
tooltip:addLine(line)
line.iconColor = iconColor
tooltip:addLine(line)
end


-- empty line
local fontSize = 14
tooltip:addLine(TooltipLine(15, 15))
local lineHeight = 20


-- crew requirements
fillWeaponTooltipData(turret, tooltip)
local crew = turret:getCrew()
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Size"%_t
line.rtext = round(turret.size, 1)
line.icon = "data/textures/icons/shotgun.png";
line.iconColor = iconColor
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Tracking Speed" --lyr_nt
line.rtext = round(turret.turningSpeed, 1)
line.icon = "data/textures/icons/clockwise-rotation.png";
line.iconColor = iconColor
tooltip:addLine(line)
-- crew requirements
local crew = turret:getCrew()


for crewman, amount in pairs(crew:getMembers()) do
for crewman, amount in pairs(crew:getMembers()) do


if amount > 0 then
if amount > 0 then
local profession = crewman.profession
local profession = crewman.profession


local line = TooltipLine(lineHeight, fontSize)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = profession.name
line.ltext = profession.name
line.rtext = round(amount)
line.rtext = round(amount)
line.icon = profession.icon;
line.icon = profession.icon;
line.iconColor = iconColor
line.iconColor = iconColor
tooltip:addLine(line)
tooltip:addLine(line)


end
end
end
end
-- empty line
tooltip:addLine(TooltipLine(15, 15))
local addBlankLine = false


-- empty line
if turret.automatic then
tooltip:addLine(TooltipLine(15, 15))
local line = TooltipLine(lineHeight, fontSize+2)
line.ltext = "Independent Targeting" --lyr_nt
line.lcolor = ColorRGB(0.6, 1.0, 0.0)
line.icon = "data/textures/icons/processor.png";
line.iconColor = iconColor
tooltip:addLine(line)
--table.insert(description, "Programmable Turret: Can be set to fire automatically")
addBlankLine = true
end
if turret.simultaneousShooting and turret.numWeapons > 1 then
local line = TooltipLine(lineHeight, fontSize+2)
line.ltext = "Synchronized Weapons" --lyr_nt
line.lcolor = ColorRGB(0.45, 1.0, 0.15)
line.icon = "data/textures/icons/missile-pod.png";
line.iconColor = iconColor
tooltip:addLine(line)
--table.insert(description, "Synchronized Weapons: Fires all weapons at the same time")
addBlankLine = true
end
if turret.shotsPerFiring > 1 then
local line = TooltipLine(lineHeight, fontSize+2)
line.ltext = "Multiple Projectiles" --lyr_nt
line.lcolor = ColorRGB(0.30, 1.0, 0.3)
line.icon = "data/textures/icons/missile-swarm.png";
line.iconColor = iconColor
tooltip:addLine(line)
--table.insert(description, "Multiple Projectiles: Weapons fire multiple projectiles")
addBlankLine = true
end
--if turret.shootingTime == 1 then
if turret.shootingTime < 2 then
local line = TooltipLine(lineHeight, fontSize+2)
line.ltext = "Burst Fire" --lyr_nt
line.lcolor = ColorRGB(0.15, 1.0, 0.45)
line.icon = "data/textures/icons/bullets.png";
line.iconColor = iconColor
tooltip:addLine(line)
--table.insert(description, "Burst Fire: Fires rapidly for a second, then cools down")
addBlankLine = true
end
if turret.seeker then
local line = TooltipLine(lineHeight, fontSize+2)
line.ltext = "Guided Missiles" --lyr_nt
line.lcolor = ColorRGB(0.0, 1.0, 0.6)
line.icon = "data/textures/icons/rocket-thruster.png";
line.iconColor = iconColor
tooltip:addLine(line)
--table.insert(description, "Guided Missiles: Missiles track the targets")
addBlankLine = true
end


local description = {}
-- empty line
if turret.automatic then
if addBlankLine then tooltip:addLine(TooltipLine(15, 15)) end
table.insert(description, "Independent targeting, but deals less damage"%_t)
end


fillDescriptions(turret, tooltip, description)
fillDescriptions(turret, tooltip, description)


return tooltip
return tooltip
end
end




function makeFighterTooltip(fighter)
function makeFighterTooltip(fighter)

-- create tool tip
-- create tool tip
local tooltip = Tooltip()
local tooltip = Tooltip()
tooltip.icon = fighter.weaponIcon
tooltip.icon = fighter.weaponIcon

-- title
local title = "${weaponPrefix} Fighter"%_t % fighter

local line = TooltipLine(headLineSize, headLineFont)
line.ctext = title
line.ccolor = fighter.rarity.color
tooltip:addLine(line)

-- primary stats, one by one
local fontSize = 14
local lineHeight = 20

fillWeaponTooltipData(fighter, tooltip)

-- size
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Size"%_t
line.rtext = round(fighter.volume)
line.icon = "data/textures/icons/fighter.png";
line.iconColor = iconColor
tooltip:addLine(line)

-- empty line
tooltip:addLine(TooltipLine(15, 15))

-- durability
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Durability"%_t
line.rtext = round(fighter.durability)
line.icon = "data/textures/icons/health-normal.png";
line.iconColor = iconColor
tooltip:addLine(line)

if fighter.shield > 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Shield"%_t
line.rtext = round(fighter.durability)
line.icon = "data/textures/icons/health-normal.png";
line.iconColor = iconColor
tooltip:addLine(line)
end

-- empty line
tooltip:addLine(TooltipLine(15, 15))

-- maneuverability
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Maneuverability"%_t
line.rtext = round(fighter.turningSpeed, 2)
line.icon = "data/textures/icons/dodge.png";
line.iconColor = iconColor
tooltip:addLine(line)


-- velocity
-- title
local line = TooltipLine(lineHeight, fontSize)
local title = "${weaponPrefix} Fighter"%_t % fighter
line.ltext = "Speed"%_t
line.rtext = round(fighter.maxVelocity * 10.0)
line.icon = "data/textures/icons/afterburn.png";
line.iconColor = iconColor
tooltip:addLine(line)


-- empty line
local line = TooltipLine(headLineSize-5, headLineFont)
tooltip:addLine(TooltipLine(15, 15))
line.ctext = title
line.ccolor = fighter.rarity.color
tooltip:addLine(line)


-- crew requirements
-- primary stats, one by one
local pilot = CrewProfession(CrewProfessionType.Pilot)
local fontSize = 14
local lineHeight = 20


local line = TooltipLine(lineHeight, fontSize)
fillWeaponTooltipData(fighter, tooltip)
line.ltext = pilot.name
line.rtext = round(fighter.crew)
line.icon = pilot.icon
line.iconColor = iconColor
tooltip:addLine(line)


-- durability
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Durability"%_t
line.rtext = round(fighter.durability)
line.icon = "data/textures/icons/health-normal.png";
line.iconColor = iconColor
tooltip:addLine(line)


-- empty line
local line = TooltipLine(lineHeight, fontSize)
tooltip:addLine(TooltipLine(15, 15))
line.ltext = "Shield"%_t
line.rtext = fighter.shield > 0 and round(fighter.durability) or "None"
line.icon = "data/textures/icons/health-normal.png";
line.iconColor = iconColor
tooltip:addLine(line)


fillDescriptions(fighter, tooltip)
-- empty line
tooltip:addLine(TooltipLine(15, 15))


return tooltip
-- size
end
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Size"%_t
line.rtext = round(fighter.volume)
line.icon = "data/textures/icons/fighter.png";
line.iconColor = iconColor
tooltip:addLine(line)


-- maneuverability
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Maneuverability"%_t
line.rtext = round(fighter.turningSpeed, 2) --what's the unit?
line.icon = "data/textures/icons/dodge.png";
line.iconColor = iconColor
toolt