Author Topic: [ALPHA RELEASE]: Configurable Capship Command  (Read 9103 times)

0 Members and 1 Guest are viewing this topic.

Offline Dragon

  • Citation needed
  • 212
  • The sky is the limit.
Re: [ALPHA RELEASE]: Configurable Capship Command
Try adding stuff instead of replacing. It seems that replacing causes problems sometimes. My father intended this to work like that, probably because he once worked with Freelancer. It appears that this script was written like it was meant to have a "supported ships list" that would be added to, eventually supporting just about every ship out there. Obviously, due to how FS modding works, such approach is unfeasible, but with FL-like setup, this is the default approach.

 

Offline procdrone

  • Formerly TheHound
  • 29
  • Balance breaker! Thats me!
    • Skype
Re: [ALPHA RELEASE]: Configurable Capship Command
Thank you Dragon, I'll check this solution out, and give you possible feedback on what happened, and if it worked the way I wanted :) (It's to late for doing this now :) )
--Did it! It's RELEASED! VeniceMirror Thread--

 

Offline procdrone

  • Formerly TheHound
  • 29
  • Balance breaker! Thats me!
    • Skype
Re: [ALPHA RELEASE]: Configurable Capship Command
Alright, i managed to test out your adivce, it helped, partialy, but somehow it helped.

Here is the fragments for ship tables and the configurable script itself:

Code: [Select]
#Ship Classes


$Name: GTVFg Arpyia#Player
$Short name: TaaCor
$Species: Terran
+Tech Description:
XSTR("RNI systems and Ahketon Corporation collaborated to produce Arpyia-class frigate based on demands from the GTVA security council requesting a tactical rapid-response craft with carrier capability. Taking notes from the design of the successful Deimos-class corvette, the first Arpyia class elegantly integrates a a large fighterbay into well-rounded frame. The first Arpyia class vessel launched six years after the Capella incident.", -1)
$end_multi_text
$POF file: arpyia.pof
$Detail distance: (0, 1350, 8000)
$Show damage: YES
$Density: 1
$Damp: 0.2
$Rotdamp: 2.0
$Max Velocity: 0.0, 0.0, 28.0
$Rotation time: 140.0, 140.0, 100.0
$Rear Velocity: 0.0
$Forward accel: 8.0
$Forward decel: 4.0
$Slide accel: 0.0
$Slide decel: 0.0
$Expl inner rad: 150.0
$Expl outer rad: 750.0
$Expl damage: 200.0
$Expl blast: 11000.0
$Expl Propagates: YES ;; If set to Yes, then when the ship dies, the explosion propagates through it.
$Shockwave Speed: 400.0 ;; speed shockwave expands at, 0 means no shockwave
$Shockwave Count: 3
$Default PBanks: ()
$Default SBanks: ()
$SBank Capacity: ()
$Shields: 0
$Power Output: 200.0
$Max Oclk Speed: 60.0
$Max Weapon Eng: 200.0
$Hitpoints: 100000
$Flags: ( "big damage" "corvette" "in tech database" "player_ship" )
$AI Class: Captain
$Afterburner: NO
$Countermeasures: 0
$Scan time: 2000
$EngineSnd: 128 ;; Engine sound of ship
$Closeup_pos: 0.0, 0.0, -1000
$Closeup_zoom: 0.5
$Score: 1100
$Subsystem: turret01,0.625, 2.0
$Default PBanks: ( "TerSlash" )
$Subsystem: turret02,0.625, 2.0
$Default PBanks: ( "TerSlash" )
$Subsystem: turret03,0.625, 2.0
$Default PBanks: ( "TerSlash" )
$Subsystem: turret04,0.625, 2.0
$Default PBanks: ( "TerSlash" )
$Subsystem: turret05,0.833,1.0
$Default PBanks: ( "AAAf" )
$Subsystem: turret06,0.833,1.0
$Default PBanks: ( "AAAf" )
$Subsystem: turret07,0.833,1.0
$Default PBanks: ( "AAAf" )
$Subsystem: turret08,0.833,1.0
$Default PBanks: ( "AAAf" )
$Subsystem: turret09,0.833,1.0
$Default PBanks: ( "AAAf" )
$Subsystem: turret10,0.833,1.0
$Default PBanks: ( "Standard Flak" )
$Subsystem: turret11,0.833,1.0
$Default PBanks: ( "Standard Flak" )
$Subsystem: turret12,0.833,1.0
$Default PBanks: ( "TerSlash" )
$Subsystem: turret13,0.833,1.0
$Default PBanks: ( "Standard Flak" )
$Subsystem: turret14,1.875, 3.0
$Default PBanks: ( "Heavy Flak" )
$Subsystem: turret15,1.875, 3.0
$Default PBanks: ( "Heavy Flak" )
$Subsystem: turret16,0.833,1.0
$Default PBanks: ( "Piranha" )
$Subsystem: turret17,0.833,1.0
$Default PBanks: ( "Piranha" )
$Subsystem: turret18,0.833,1.0
$Default PBanks: ( "Piranha" )
$Subsystem: turret19,0.833,1.0
$Default PBanks: ( "Piranha" )
$Subsystem: turret20,0.833,1.0
$Default PBanks: ( "Piranha" )
$Subsystem: turret21,0.833,1.0
$Default PBanks: ( "Piranha" )

$Subsystem: turret22,1.875, 3.0
$Default PBanks: ( "Terran Huge Turret" )
$Turret Reset Delay: 1000
$Flags: ( "reset when idle" )
$animation: triggered
$type: initial
+relative_angle: 70, 0, 0

$Subsystem: turret23,1.875, 3.0
$Default PBanks: ( "Terran Huge Turret" )
$Turret Reset Delay: 1000
$Flags: ( "reset when idle" )
$animation: triggered
$type: initial
+relative_angle: 70, 0, 0

$Subsystem: turret24,1.875, 3.0
$Default PBanks: ( "Terran Huge Turret" )
$Turret Reset Delay: 1000
$Flags: ( "reset when idle" )
$animation: triggered
$type: initial
+relative_angle: 70, 0, 0

$Subsystem: fighterbay, 5,0.0
$Subsystem: radar, 5,0.0
$Subsystem: sensors, 5,0.0
$Subsystem: navigation, 5,0.0
$Subsystem: communications, 5,0.0
$Subsystem: weapons, 5,0.0
$Subsystem: engine1, 5,0.0
$Subsystem: engine2, 5,0.0
$Subsystem: engine3, 5,0.0
$Subsystem: engine4, 5,0.0
$Subsystem: engine5, 5,0.0
$Subsystem: engine6, 5,0.0
#End

Code: [Select]
-- config stuff start
-- turret group, UI display, R, G, B, Brace padding

turretInit("pd", "Point Defense Turrets: ", 61, 93, 255, 8)
turretInit("flak", "Flak Turrets: ", 61, 93, 255, 8)
turretInit("md", "mass drivers: ", 255, 93, 48, 11)
turretInit("gauss", "gauss cannons: ", 255, 187, 53, 14)
turretInit("torpedo", "apocalypse torpedoes: ", 255, 255, 53, 17)
turretInit("missile", "Missile Launchers: ", 255, 255, 53, 17)
turretInit("gattler", "gattler: ", 255, 187, 53, 14)
turretInit("rapier", "rapier: ", 255, 187, 53, 14)
turretInit("beams", "Beam Cannons: ", 255, 187, 53, 14)
turretInit("lasers", "Lasers: ", 255, 187, 53, 14)
turretInit("aaaf", "Anti-Fighter Beams: ", 255, 187, 53, 14)

end

function defineWeapons()
csc.weapondef = {}

--weaponClassName -> turret group

weaponInit("Point Defense Turret", "pd")
weaponInit("Standard Flak", "flak")
weaponInit("Heavy Flak", "flak")
weaponInit("PD Turret#Player", "pd")
weaponInit("Burst Flak", "flak")
weaponInit("Mass Driver", "md")
weaponInit("Gauss Cannon", "gauss")
weaponInit("Apocalypse", "torpedo")
weaponInit("Warhammer", "missile")
weaponInit("Gattler", "gattler")
weaponInit("Rapier", "rapier")
weaponInit("TerSlash", "beams")
weaponInit("AAAf", "aaaf")
weaponInit("Piranha", "missile")
weaponInit("Terran Huge Turret", "lasers")

end

function defineShips()
csc.shipdef = {}

local
--Karuna
--Entry number - don't forget to change while copypasting this one
i = 1
csc.shipdef[i] = {}
csc.shipdef[i].shipClassName = "UEFg Karuna#Player"
--turrets showing target braces
csc.shipdef[i].turretTargets={"pd", "flak", "md", "gauss", "torpedo"}
--turrets aviable in UI
csc.shipdef[i].turretControl={"md", "gauss", "torpedo"}
--turrets to calculate target range
csc.shipdef[i].turretRange={"turret01", "turret02", "turret03", "turret04"}
-- possible turret weapon groups:
-- {"pd", "flak", "md", "gauss", "torpedo", "gattler", "missile"}

--Custos
i = 2
csc.shipdef[i] = {}
csc.shipdef[i].shipClassName = "UEC Custos#Player"
csc.shipdef[i].turretTargets={"pd", "missile"}
csc.shipdef[i].turretControl={"pd", "missile"}
csc.shipdef[i].turretRange={}


--Arpyia
--Entry number - don't forget to change while copypasting this one
i = 3
csc.shipdef[i] = {}
csc.shipdef[i].shipClassName = "GTVFg Arpyia#Player"
--turrets showing target braces
csc.shipdef[i].turretTargets={"beams", "flak", "lasers", "aaaf", "missile"}
--turrets aviable in UI
csc.shipdef[i].turretControl={"beams", "flak", "lasers", "aaaf", "missile"}
--turrets to calculate target range
csc.shipdef[i].turretRange={"turret01", "turret02", "turret03", "turret04", "turret05", "turret06", "turret07", "turret08", "turret09", "turret10", "turret11", "turret12", "turret13", "turret14", "turret15", "turret16", "turret17", "turret18", "turret19", "turret20", "turret21", "turret22", "turret23", "turret24"}
-- possible turret weapon groups:
-- {"beams", "flak", "lasers", "aaaf", "missile"}

end
-- config stuff end


So here is what came up:

All my weapons turrets now fire on the specified target (or in automatic on their own), but, they cannot be turned off (with the Off-line state), and continue to fire on target.
I also found out that missiles won't fire, no matter what state, changing state changes the target, but still no missiles are launched.

There are maybe something that I must put up in mission on the ship like turret lock's, or other stuff up in events or anything? (Right now I'm only using the "All beams free on mission start" in mission specs).
--Did it! It's RELEASED! VeniceMirror Thread--

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: [ALPHA RELEASE]: Configurable Capship Command
Diff your script against the capship command script shipped with BP2: Tenebra (used in bp2-20 'One Future'). I know that script successfully handles missiles, at least.

 

Offline procdrone

  • Formerly TheHound
  • 29
  • Balance breaker! Thats me!
    • Skype
Re: [ALPHA RELEASE]: Configurable Capship Command
Truly, that missiles are least of my worries, I need the turrets to respond on off-line status, I will check out that script you told, however... maybe with missiles the turret's will work too as they should, who knows?
--Did it! It's RELEASED! VeniceMirror Thread--

 

Offline procdrone

  • Formerly TheHound
  • 29
  • Balance breaker! Thats me!
    • Skype
Re: [ALPHA RELEASE]: Configurable Capship Command
After looking into the original CSC script that goes like this

Code: [Select]
;The CSC script. Messy and unreadable, but functional enough to allow effective control over capital ship turrets.

#Conditional Hooks

$Application: FS2_Open

$On Key Pressed: [[csc_KeyPressed.lua]]
$On Key Released: [[csc_KeyReleased.lua]]

$On Game Init:
[
ui_keyToggleFunctions = {}
InputStates = {}

ui_keyToggleFunctions["Up Arrow"]    = function(val) InputStates.up    = val end
ui_keyToggleFunctions["Down Arrow"]  = function(val) InputStates.down  = val end
ui_keyToggleFunctions["Left Arrow"]  = function(val) InputStates.left  = val end
ui_keyToggleFunctions["Right Arrow"] = function(val) InputStates.right = val end
ui_keyToggleFunctions["0"] = function(val) InputStates.zero = val end

function getTargetName(target)
local targetname
if target then
local targetship = mn.getObjectFromSignature(target:getSignature())
if targetship:isValid() then
if targetship:getBreedName() == "Ship" then
targetname = targetship.Name
end
else
targetname = "None"
end
else
targetname = "None"
end
return targetname
end

function getTargetClass(target)
local targetname
if target then
local targetship = mn.getObjectFromSignature(target:getSignature())
if targetship:isValid() then
if targetship:getBreedName() == "Ship" then
targetname = targetship.Class.Type.Name
end
else
targetname = "None"
end
else
targetname = "None"
end
return targetname
end

function drawTurretUIKaruna()
--Mass drivers
if csc.acnum == 1 then
gr.setColor(255, 255, 255)
else
gr.setColor(255, 93, 48)
end
gr.drawString("Mass drivers: " .. csc.mdmode[csc.mdstatus], 5, gr.getScreenHeight() * 0.6)
gr.setColor(255, 93, 48)
for i = 1, #csc.mdguns, 1 do
local targetname = getTargetName(csc.mdguns[i].Target)
if not targetname then targetname = "None" end
gr.drawString("  " .. csc.mdguns[i].Name .. ": " .. targetname)
end

--Gauss cannons
if csc.acnum == 2 then
gr.setColor(255, 255, 255)
else
gr.setColor(255, 187, 53)
end
gr.drawString("Gauss Cannons: " .. csc.railgunmode[csc.rgstatus])
gr.setColor(255, 187, 53)
for i = 1, #csc.railguns, 1 do
local targetname = getTargetName(csc.railguns[i].Target)
if not targetname then targetname = "None" end
gr.drawString("  " .. csc.railguns[i].Name .. ": " .. targetname)
end

--Apocalypse
if csc.acnum == 3 then
gr.setColor(255, 255, 255)
else
gr.setColor(255, 255, 53)
end
gr.drawString("Apocalypse Torpedoes: " .. csc.apocalypsemode[csc.apostatus])
gr.setColor(255, 255, 53)
for i = 1, #csc.apocalypse, 1 do
local targetname = getTargetName(csc.apocalypse[i].Target)
if not targetname then targetname = "None" end
gr.drawString("  " .. csc.apocalypse[i].Name .. ": " .. targetname)
end

gr.setColor(255, 255, 255)
local targetname = getTargetName(csc.CurrentTarget)
local classname = getTargetClass(csc.CurrentTarget)
if not classname then classname = "None" end
if not targetname then targetname = "Invalid" end
gr.drawString("Current Target: " .. targetname .. " Class: " .. classname)
end

function fillturretlist(ship)
local turretnum = 1
ba.print("CSC: Entered fillturretlist\n")
csc.turrets = {}
for i = 1, 60, 1 do
if i < 10 then
turretname = "turret0" .. i
else
turretname = "turret" .. i
end

ba.print("CSC: Looking for turret: " .. turretname .. "\n")

if ship[turretname]:isValid() then
csc.turrets[turretnum] = ship[turretname]
ba.print("CSC: Found Turret.\n")
turretnum = turretnum + 1
end
end
end

function groupTurrets()

local pdnum = 1
local flaknum = 1
local railgunnum = 1
local mdnum = 1
local aponum = 1
local gatnum = 1
local rapnum = 1
local misnum = 1

ba.print("CSC: Entered GroupTurrets\n")

for i = 1, #csc.turrets, 1 do
if csc.turrets[i].PrimaryBanks[1].WeaponClass:isValid() or csc.turrets[i].SecondaryBanks[1].WeaponClass:isValid() then
if string.find(csc.turrets[i].PrimaryBanks[1].WeaponClass.Name, "Point Defense Turret") then
csc.pdTurrets[pdnum] = csc.turrets[i]
ba.print("CSC: Found PD Turret. Turret Number: " .. i .. " pdnum: " .. pdnum .. "\n")
pdnum = pdnum + 1
elseif string.find(csc.turrets[i].PrimaryBanks[1].WeaponClass.Name, "PD Turret#Player") then
csc.pdTurrets[pdnum] = csc.turrets[i]
ba.print("CSC: Found PD Turret. Turret Number: " .. i .. " pdnum: " .. pdnum .. "\n")
pdnum = pdnum + 1
elseif string.find(csc.turrets[i].PrimaryBanks[1].WeaponClass.Name, "Burst Flak") then
csc.flakTurrets[flaknum] = csc.turrets[i]
ba.print("CSC: Found Flak Turret. Turret Number: " .. i .. " flaknum: " .. flaknum .. "\n")
flaknum = flaknum + 1
elseif string.find(csc.turrets[i].PrimaryBanks[1].WeaponClass.Name, "Gauss Cannon") then
csc.railguns[railgunnum] = csc.turrets[i]
ba.print("CSC: Found Gauss Cannon. Turret Number: " .. i .. " railgunnum: " .. railgunnum .. "\n")
railgunnum = railgunnum + 1
elseif string.find(csc.turrets[i].PrimaryBanks[1].WeaponClass.Name, "Mass Driver") then
csc.mdguns[mdnum] = csc.turrets[i]
ba.print("CSC: Found Mass Driver. Turret Number: " .. i .. " mdnum: " .. mdnum .. "\n")
mdnum = mdnum + 1
elseif string.find(csc.turrets[i].SecondaryBanks[1].WeaponClass.Name, "Apocalypse") then
csc.apocalypse[aponum] = csc.turrets[i]
ba.print("CSC: Found Apocalypse. Turret Number: " .. i .. " aponum: " .. aponum .. "\n")
aponum = aponum + 1
elseif string.find(csc.turrets[i].PrimaryBanks[1].WeaponClass.Name, "Gattler") then
csc.gattler[gatnum] = csc.turrets[i]
ba.print("CSC: Found Gattler. Turret Number: " .. i .. " gatnum: " .. gatnum .. "\n")
gatnum = gatnum + 1
elseif string.find(csc.turrets[i].PrimaryBanks[1].WeaponClass.Name, "Rapier") then
csc.rapier[rapnum] = csc.turrets[i]
ba.print("CSC: Found Rapier. Turret Number: " .. i .. " rapnum: " .. rapnum .. "\n")
rapnum = rapnum + 1
elseif string.find(csc.turrets[i].SecondaryBanks[1].WeaponClass.Name, "Warhammer") then
csc.missile[misnum] = csc.turrets[i]
ba.print("CSC: Found Missiles. Turret Number: " .. i .. " misnum: " .. misnum .. "\n")
misnum = misnum + 1
end
end
end

csc.initComplete = true
end

function drawTargets(turrets, r, g, b, padding)
gr.setColor(r, g, b)
for i = 1, #turrets, 1 do
target = turrets[i].Target
if target:isValid() then
gr.drawTargetingBrackets(target, true, padding)
end
end
end

function doInput()
MissionTime = mn.getMissionTime()

if OldMissionTime ~= MissionTime and MissionTime ~= 0 then
if InputStates.up and not csc.inputstates.keyup then
csc.acnum = csc.acnum - 1
if csc.ship == "Karuna" then
if csc.acnum == 0 then
csc.acnum = 3
end
elseif csc.ship == "Custos" then
if csc.acnum == 0 then
csc.acnum = 2
end
end
csc.inputstates.keyup = true
elseif not InputStates.up then
csc.inputstates.keyup = false
end

if InputStates.down and not csc.inputstates.keydown then
csc.acnum = csc.acnum + 1
if csc.ship == "Karuna" then
if csc.acnum == 4 then
csc.acnum = 1
end
elseif csc.ship == "Custos" then
if csc.acnum == 3 then
csc.acnum = 1
end
end
csc.inputstates.keydown = true
elseif not InputStates.down then
csc.inputstates.keydown = false
end

if InputStates.left and not csc.inputstates.keyleft then
if csc.ship == "Karuna" then
if csc.acnum == 1 then
csc.mdstatus = csc.mdstatus - 1
if csc.mdstatus == 0 then
csc.mdstatus = 4
end
end
if csc.acnum == 2 then
csc.rgstatus = csc.rgstatus - 1
if csc.rgstatus == 0 then
csc.rgstatus = 4
end
end
if csc.acnum == 3 then
csc.apostatus = csc.apostatus - 1
if csc.apostatus == 0 then
csc.apostatus = 4
end
end
elseif csc.ship == "Custos" then
if csc.acnum == 1 then
csc.pdstatus = csc.pdstatus - 1
if csc.pdstatus == 0 then
csc.pdstatus = 4
end
end
if csc.acnum == 2 then
csc.missilestatus = csc.missilestatus - 1
if csc.missilestatus == 0 then
csc.missilestatus = 4
end
end
end
csc.inputstates.keyleft = true
elseif not InputStates.left then
csc.inputstates.keyleft = false
end

if InputStates.right and not csc.inputstates.keyright then
if csc.ship == "Karuna" then
if csc.acnum == 1 then
csc.mdstatus = csc.mdstatus + 1
if csc.mdstatus == 5 then
csc.mdstatus = 1
end
end
if csc.acnum == 2 then
csc.rgstatus = csc.rgstatus + 1
if csc.rgstatus == 5 then
csc.rgstatus = 1
end
end
if csc.acnum == 3 then
csc.apostatus = csc.apostatus + 1
if csc.apostatus == 5 then
csc.apostatus = 1
end
end
elseif csc.ship == "Custos" then
if csc.acnum == 1 then
csc.pdstatus = csc.pdstatus + 1
if csc.pdstatus == 5 then
csc.pdstatus = 1
end
end
if csc.acnum == 2 then
csc.missilestatus = csc.missilestatus + 1
if csc.missilestatus == 5 then
csc.missilestatus = 1
end
end
end
csc.inputstates.keyright = true
elseif not InputStates.right then
csc.inputstates.keyright = false
end

if InputStates.zero or io.isMouseButtonDown(MOUSE_LEFT_BUTTON) then
csc.CurrentTarget = csc.plrship.Target
csc.inputstates.zero = true
elseif not InputStates.zero or not io.isMouseButtonDown(MOUSE_LEFT_BUTTON) then
csc.inputstates.zero = false
end
OldMissionTime = MissionTime
end
end

function doTurretModeKaruna()
if csc.mdstatus == 1 then
for i = 1, #csc.mdguns do
csc.mdguns[i]:targetingOverride(false)
end
elseif csc.mdstatus == 2 then
for i = 1, #csc.mdguns do
csc.mdguns[i].Target = csc.plrship.Target
end
elseif csc.mdstatus == 3 then
if csc.CurrentTarget then
if csc.CurrentTarget:isValid() then
for i = 1, #csc.mdguns do
csc.mdguns[i].Target = csc.CurrentTarget
end
end
end
elseif csc.mdstatus == 4 then
for i = 1, #csc.mdguns do
csc.mdguns[i]:targetingOverride(true)
end
end

if csc.rgstatus == 1 then
for i = 1, #csc.railguns do
csc.railguns[i]:targetingOverride(false)
end
elseif csc.status == 2 then
for i = 1, #csc.railguns do
csc.railguns[i].Target = csc.plrship.Target
end
elseif csc.rgstatus == 3 then
if csc.CurrentTarget then
if csc.CurrentTarget:isValid() then
for i = 1, #csc.railguns do
csc.railguns[i].Target = csc.CurrentTarget
end
end
end
elseif csc.rgstatus == 4 then
for i = 1, #csc.railguns do
csc.railguns[i]:targetingOverride(true)
end
end

if csc.apostatus == 1 then
for i = 1, #csc.apocalypse do
csc.apocalypse[i]:targetingOverride(false)
end
elseif csc.apostatus == 2 then
for i = 1, #csc.apocalypse do
csc.apocalypse[i].Target = csc.plrship.Target
end
elseif csc.apostatus == 3 then
if csc.CurrentTarget then
if csc.CurrentTarget:isValid() then
for i = 1, #csc.apocalypse do
csc.apocalypse[i].Target = csc.CurrentTarget
end
end
end
elseif csc.apostatus == 4 then
for i = 1, #csc.apocalypse do
csc.apocalypse[i]:targetingOverride(true)
end
end
end

function drawRangeDisplayKaruna()
csc.range = nil
csc.range = {}
csc.range.Shipname = {}
csc.range.Range = {}
local plrship = hv.Player
if plrship:isValid() then
plrship = mn.getObjectFromSignature(csc.plr:getSignature())
end
local turpos1 = (plrship.Position + plrship["turret01"].Position)
local turpos2 = (plrship.Position + plrship["turret02"].Position)
local turpos3 = (plrship.Position + plrship["turret03"].Position)
local turpos4 = (plrship.Position + plrship["turret04"].Position)
items = 1
for i = 1, #mn.Ships do
local tempship = mn.Ships[i]
local class = getTargetClass(tempship)
if class ~= "Fighter" and class ~= "Bomber" then
if tempship ~= csc.plrship then
local temp = tempship.Position
local temprange1 = math.sqrt( (temp[1] - turpos1[1])^2 + (temp[2] - turpos1[2])^2 + (temp[3] - turpos1[3])^2 )
local temprange2 = math.sqrt( (temp[1] - turpos2[1])^2 + (temp[2] - turpos2[2])^2 + (temp[3] - turpos2[3])^2 )
local temprange3 = math.sqrt( (temp[1] - turpos3[1])^2 + (temp[2] - turpos3[2])^2 + (temp[3] - turpos3[3])^2 )
local temprange4 = math.sqrt( (temp[1] - turpos4[1])^2 + (temp[2] - turpos4[2])^2 + (temp[3] - turpos4[3])^2 )
csc.range.Shipname[items] = tempship.Name
csc.range.Range[items] = math.floor( (temprange1 + temprange2 + temprange3 + temprange4) / 4 )
items = items + 1
end
end
end
gr.setColor(255,255,255)
gr.drawString("Range:", gr.getScreenWidth() * 0.17, gr.getScreenHeight() * 0.78)
for i = 1, #csc.range.Shipname do
if csc.range.Range[i] < 1000 then
local c = math.floor((csc.range.Range[i] / 4)) + 5
gr.setColor(255, c, c)
gr.drawString("  " .. csc.range.Shipname[i] .. ": " .. csc.range.Range[i])
gr.setColor(255, 255, 255)
else
gr.drawString("  " .. csc.range.Shipname[i] .. ": " .. csc.range.Range[i])
end
end
end

function drawRangeDisplayCustos()
end

function drawTurretUICustos()
--Rapier
if csc.acnum == 1 then
gr.setColor(255, 255, 255)
else
gr.setColor(61, 93, 255)
end
gr.drawString("Point Defense turrets: " .. csc.pdmode[csc.pdstatus], 5, gr.getScreenHeight() * 0.6)
gr.setColor(61, 93, 255)
for i = 1, #csc.pdTurrets, 1 do
local targetname = getTargetName(csc.pdTurrets[i].Target)
if not targetname then targetname = "None" end
gr.drawString("  PD Turret: " .. targetname)
end

--Missiles
if csc.acnum == 2 then
gr.setColor(255, 255, 255)
else
gr.setColor(255, 255, 53)
end
gr.drawString("Missile Launchers: " .. csc.missilemode[csc.missilestatus])
gr.setColor(255, 255, 53)
for i = 1, #csc.missile, 1 do
local targetname = getTargetName(csc.missile[i].Target)
if not targetname then targetname = "None" end
gr.drawString("  " .. csc.missile[i].Name .. ": " .. targetname)
end

gr.setColor(255, 255, 255)
local targetname = getTargetName(csc.CurrentTarget)
local classname = getTargetClass(csc.CurrentTarget)
if not classname then classname = "None" end
if not targetname then targetname = "Invalid" end
gr.drawString("Current Target: " .. targetname .. " Class: " .. classname)
end

function doTurretModeCustos()
if csc.pdstatus == 1 then
for i = 1, #csc.pdTurrets do
csc.pdTurrets[i]:targetingOverride(false)
end
elseif csc.pdstatus == 2 then
for i = 1, #csc.pdTurrets do
csc.pdTurrets[i].Target = csc.plrship.Target
end
elseif csc.pdstatus == 3 then
if csc.CurrentTarget then
if csc.CurrentTarget:isValid() then
for i = 1, #csc.pdTurrets do
csc.pdTurrets[i].Target = csc.CurrentTarget
end
end
end
elseif csc.pdstatus == 4 then
for i = 1, #csc.pdTurrets do
csc.pdTurrets[i]:targetingOverride(true)
end
end

if csc.missilestatus == 1 then
for i = 1, #csc.missile do
csc.missile[i]:targetingOverride(false)
end
elseif csc.missilestatus == 2 then
for i = 1, #csc.missile do
csc.missile[i].Target = csc.plrship.Target
end
elseif csc.missilestatus == 3 then
if csc.CurrentTarget then
if csc.CurrentTarget:isValid() then
for i = 1, #csc.missile do
csc.missile[i].Target = csc.CurrentTarget
end
end
end
elseif csc.missilestatus == 4 then
for i = 1, #csc.missile do
csc.missile[i]:targetingOverride(true)
end
end
end

function cscInit()
csc = {}
if not csc.initComplete then
if not csc.plrship then
csc.plr = hv.Player
if csc.plr:isValid() then
csc.plrship = mn.getObjectFromSignature(csc.plr:getSignature())
end

if csc.plrship:getBreedName() == "Ship" then
if csc.plrship.Class.Name ~= "UEFg Karuna#Player" and csc.plrship.Class.Name ~= "UEC Custos-X" then
csc.disable = true
end
if csc.plrship.Class.Name == "UEFg Karuna#Player" then
csc.ship = "Karuna"
elseif csc.plrship.Class.Name == "UEC Custos-X" then
csc.ship = "Custos"
end
else
csc.disable = true
end

if not csc.disable then
if not csc.turrets then
csc.pdTurrets = {}
csc.pdmode = {"Automatic", "Track", "Lock", "Offline"}
csc.pdstatus = 1

csc.flakTurrets = {}

csc.railguns = {}
csc.railgunmode = {"Automatic", "Track", "Lock", "Offline"}
csc.rgstatus = 1

csc.mdguns = {}
csc.mdmode = {"Automatic", "Track", "Lock", "Offline"}
csc.mdstatus = 1

csc.apocalypse = {}
csc.apocalypsemode = {"Automatic", "Track", "Lock", "Offline"}
csc.apostatus = 1

csc.gattler = {}
csc.gattlermode = {"Automatic", "Track", "Lock", "Offline"}
csc.gattlerstatus = 1

csc.missile = {}
csc.missilemode = {"Automatic", "Track", "Lock", "Offline"}
csc.missilestatus = 1

csc.active = {"*", " ", " "}
csc.acnum = 1
csc.inputstates = {}

inputlocked = false

fillturretlist(csc.plrship)
groupTurrets()
ShieldmanOverride = true
BettyOverride = true
OldMissionTime = cscMissionTime
end
end
end
end
end
]

$State: GS_STATE_GAME_PLAY

$On Frame:
[
cscMissionTime = mn.getMissionTime()


if cscOldMissionTime ~= cscMissionTime and cscMissionTime ~= 0 then
if not csc then
cscInit()
end

if csc then
if not csc.disable and csc.initComplete then
doInput()
if csc.ship == "Karuna" then
doTurretModeKaruna()
drawTargets(csc.pdTurrets,   61, 93, 255,  8)
drawTargets(csc.flakTurrets, 61, 93, 255,  8)
drawTargets(csc.mdguns,     255, 93,  48, 11)
drawTargets(csc.railguns,   255, 187, 53, 14)
drawTargets(csc.apocalypse, 255, 255, 53, 17)
elseif csc.ship == "Custos" then
doTurretModeCustos()
drawTargets(csc.pdTurrets,   61, 93, 255,  8)
drawTargets(csc.missile, 255, 255, 53, 17)
end
end
end
cscOldMissionTime = cscMissionTime
end
]

$On HUD Draw:
[
if csc then
if not csc.disable and csc.initComplete then
if csc.ship == "Karuna" then
drawRangeDisplayKaruna()
drawTurretUIKaruna()
elseif csc.ship == "Custos" then
drawRangeDisplayCustos()
drawTurretUICustos()
end
end
end
]

$On State End:
[
csc = nil
ShieldmanOverride = false
BettyOverride = false
]

#End

I find myself pretty unable to edit it for cooperation with beams, or to do anything with it :D
I just hope that Dragon will come up with a solution :/
--Did it! It's RELEASED! VeniceMirror Thread--

 

Offline procdrone

  • Formerly TheHound
  • 29
  • Balance breaker! Thats me!
    • Skype
Re: [ALPHA RELEASE]: Configurable Capship Command
I'm sorry for so multiple post on here, but I done some testing with the system, and I observed something.

I've changed the capital ship to something simpler, and I picked a simple Fenris, and coded it into the CSC.

The turret that has it's target never cease to fire, as long as it has it's range and its not destroyed.
On the other hand, if you are able to turn offline before turret get's any target, it won't open fire according to the offline state, and this is correct, but changing the status after the turret has it's target, brings no effect (switching between targets actually works, but shutting down the turrets don't)...
So it comes to the solution, that maybe the offline state is corrupted in the system itself? Can you and your father "Tygrys" look into this matter?
--Did it! It's RELEASED! VeniceMirror Thread--

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: [ALPHA RELEASE]: Configurable Capship Command
Have you tried 'Offline' with the Tenebra version of the script? (My suspicion is that it won't work either, but...)

 

Offline Dragon

  • Citation needed
  • 212
  • The sky is the limit.
Re: [ALPHA RELEASE]: Configurable Capship Command
RL keeps us both busy right now, but when we both have time, we'll look into that. It was last tested quite a few FSO versions ago, and only with mods. It worked fine when I last tested it.
That said, I don't know when I will have free time. I'm mostly modding KSP now, haven't actually started up FS for quite some time (though I did some modding/FREDing).