Skip to content

Instantly share code, notes, and snippets.

@kyzentun
Last active June 29, 2021 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyzentun/cec777ac931ece195ca30b5187e2e573 to your computer and use it in GitHub Desktop.
Save kyzentun/cec777ac931ece195ca30b5187e2e573 to your computer and use it in GitHub Desktop.
local missiles = {
{name= "meteor", str= 6},
{name= "sidewinder", str= 12},
{name= "javelin", str= 3},
{name= "torpedo", str= 30},
{name= "typhoon", str= 40},
{name= "heavy rocket", str= 16},
{name= "nuke", str= 200},
{name= "pug seeker", str= 40},
{name= "korath mine", str= 35},
{name= "hai tracker", str= 16},
{name= "thunderhead", str= 12},
{name= "korath piercer", str= 73},
}
local antimissiles = {
{name= "anti-missile", str= 5, mass= 16, sps= 60/8},
{name= " heavy anty", str= 8, mass= 30, sps= 10},
{name= " bullfrog", str= 12, mass= 10, sps= 3},
{name= " chameleon", str= 16, mass= 22, sps= 4},
{name= " warder", str= 10, mass= 28, sps= 12},
{name= " wanderer", str= 40, mass= 24, sps= 3},
{name= " point def", str= 42, mass= 33, sps= 6},
}
local args={...}
local allow_quarg= false
local allow_t3= false
local allow_pug= false
local best_only= false
for i= 1, #args do
if args[i] == 'h' or args[i] == 'help' or args[i] == '--help' then
print(args[1] .. [[ [q] [quarg] [t] [tier3]
q, quarg - Show quarg anti-missile
t, tier3 - Show tier 3 anti-missile
p, pug - Show pug anti-missile]])
end
if args[i] == 'q' or args[i] == 'quarg' then
allow_quarg= true
end
if args[i] == 't' or args[i] == 'tier3' then
allow_t3= true
end
if args[i] == 'p' or args[i] == 'pug' then
allow_pug= true
end
if args[i] == 'best' then
best_only = true
end
end
if allow_quarg then
antimissiles[#antimissiles+1]=
{name= " quarg", str= 25, mass= 40, sps= 6}
end
if allow_t3 then
antimissiles[#antimissiles+1]=
{name= " tier 3", str= 100, mass= 67, sps= 10}
end
if allow_pug then
antimissiles[#antimissiles+1]=
{name= " pug", str= 5, mass= 41, sps= 30}
end
local function best_in_show(results, judge_field, indent)
local rank_size= 3
local rank_end= rank_size+1
local ranking= {}
for i, res in ipairs(results) do
local value= res[judge_field]
local not_added= true
local rin= 1
while not_added and rin <= rank_size do
if ranking[rin] then
if value > ranking[rin][judge_field] then
table.insert(ranking, rin, res)
not_added= false
end
else
ranking[rin]= res
not_added= false
end
rin = rin+1
end
ranking[rank_end]= nil
end
local info= {}
for i, ran in ipairs(ranking) do
info[#info+1]= ("%s %.2f"):format(ran.name, ran[judge_field])
end
print(judge_field..": "..indent..table.concat(info, ", "))
end
local function cmp_missile(miss)
print(miss.name)
local results= {}
for i, anti in ipairs(antimissiles) do
local total = miss.str * anti.str
local destroy = 0
for m = 1, miss.str do
if m < anti.str then
destroy = destroy + (anti.str - m)
end
end
local ratio = destroy / total
local per_second = ratio * anti.sps
results[#results+1]= {name= anti.name, total= total, destroy= destroy,
ratio= ratio, per_second= per_second,
per_ton= per_second / anti.mass}
end
if best_only then
best_in_show(results, "per_second", "")
best_in_show(results, "per_ton", " ")
else
for i, res in ipairs(results) do
print(("%s: /s %.2f, /s/t %.2f"):format(res.name, res.per_second, res.per_ton))
end
end
end
for i, miss in ipairs(missiles) do
cmp_missile(miss)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment