Bit out of topic... but here goes... sort of alternate lead indicator that does the job but requires a bit more work..
#Global Hooks
$GameInit:
[
-- building weapon velocity library as the data is inaccessible via Lua atm
weaponvelocity = function(name)
if name == tb.getWeaponClassByName("Halo") then
wclassvel = 485
end
if name == tb.getWeaponClassByName("Akheton SDG") then
wclassvel = 500
end
if name == tb.getWeaponClassByName("Morning Star") then
wclassvel = 1000
end
if name == tb.getWeaponClassByName("Prometheus S") then
wclassvel = 750
end
if name == tb.getWeaponClassByName("Maxim") then
wclassvel = 1500
end
if name == tb.getWeaponClassByName("UD-8 Kayser") then
wclassvel = 650
end
if name == tb.getWeaponClassByName("Subach HL-7") or name == tb.getWeaponClassByName("Lamprey") or name == tb.getWeaponClassByName("Circe") or name == tb.getWeaponClassByName("Prometheus R") then
wclassvel = 450
end
--its nice to return the value too...
return wclassvel
end
-- draw ugly lead indicator, perhaps simple bitmap would be better...
drawleadreticle = function(x1,y1)
gr.drawLine(x1-5,y1-2,x1-5,y1+2)
gr.drawLine(x1+5,y1-2,x1+5,y1+2)
gr.drawLine(x1-2,y1-5,x1+2,y1-5)
gr.drawLine(x1-2,y1+5,x1+2,y1+5)
gr.drawGradientLine(x1,y1,x1+10,y1)
gr.drawGradientLine(x1,y1,x1,y1+10)
gr.drawGradientLine(x1,y1,x1-10,y1)
gr.drawGradientLine(x1,y1,x1,y1-10)
end
--where the weapon intercepts the target assuming it flies along its current velocity (vector)
leadreticle = function(weaponvel)
if playertrg ~= nil then
-- gather required data
local targetpos = playertrg.Position
local targetvel = playertrg.Velocity
local lenghttargetvel = targetvel:getMagnitude()
local playerpos = plr.Position
local plrtotrg = playerpos - targetpos
local lenghtplrtotrg = plrtotrg:getMagnitude()
--use cosine to get the interception time basicaly derived from c^2 = a^2 + b^2 - 2ab cos(C)
--use dotproduct to get ab cos(C)
local trgangle = plrtotrg:getDotProduct(targetvel)
local a = (( weaponvel * weaponvel ) - ( lenghttargetvel * lenghttargetvel ))
local b = ( 2 * trgangle )
local c = -( lenghtplrtotrg * lenghtplrtotrg )
local discrim = ((b * b) - 4 * a * c)
--idiot checks, i dont think lua can handle imaginary values...
if discrim >= 0 and a ~= 0 then
multipl1 = (( -b + math.sqrt(discrim)) / ( 2 * a))
multipl2 = (( -b - math.sqrt(discrim)) / ( 2 * a))
--we dont want negative lead do we?
if multipl1 >=0 and multipl1 <= multipl2 and multipl2 >= 0 then
targetmult = multipl1
elseif multipl1 >=0 and multipl2 < 0 then
targetmult = multipl1
elseif multipl2 >=0 then
targetmult = multipl2
else targetmult = nil
end
--with interception time we get the interception coordinates
if targetmult ~= nil then
local leadvel = targetvel/(1/targetmult)
local leadpos = targetpos + leadvel
if leadpos:getScreenCoords() ~= false then
leadx, leady = leadpos:getScreenCoords()
drawleadreticle(leadx,leady)
end
end
end
end
end
]
$HUD:
[
if plr ~= nil then
if plr.PrimaryBanks[1] ~= nil and plr.PrimaryBanks[1] ~= false then
wepname = plr.PrimaryBanks[1].WeaponClass
weaponvel1 = weaponvelocity(namewep)
end
if plr.PrimaryBanks[2] ~= nil and plr.PrimaryBanks[2] ~= false then
wepname = plr.PrimaryBanks[2].WeaponClass
weaponvel2 = weaponvelocity(namewep)
end
if plr.PrimaryBanks[3] ~= nil and plr.PrimaryBanks[3] ~= false then
wepname = plr.PrimaryBanks[3].WeaponClass
weaponvel3 = weaponvelocity(namewep)
end
if plr.Target ~= false then
playertrg = plr.Target
if playertrg:getBreed() == "Ship" or playertrg:getBreed() == "Weapon" then
if playertrg.Team.Name == "Hostile" or playertrg.Team.Name == "Traitor" then
gr.setColor(255,0,0,200)
elseif playertrg.Team.Name == "Friendly" then
gr.setColor(0,255,0,200)
elseif playertrg.Team.Name == "Unknown" then
gr.setColor(255,0,0,200)
elseif playertrg.Team.Name == "Neutral" then
gr.setColor(255,0,255,200)
else gr.setColor(0,0,255,200)
end
else gr.setColor(255,255,255,0)
end
if weaponvel1 ~= nil then
leadreticle(weaponvel1)
end
if weaponvel2 ~= nil then
leadreticle(weaponvel2)
end
if weaponvel3 ~= nil then
leadreticle(weaponvel3)
end
end
end
]
#End
EDIT: Hmmm.. managed to paste the wrong version......