I wanted to make a mission where you can control a cruiser. I made a modified version of my Marauder (I called it the GTC Orff), and modified WiH's capship control script (and then I switched to Dragon's because blueplanet's script kept crashing FSO when I reloaded the mission). Everything's working right, except that I can't control the Orff's torpedo launcher. I think this is because the Orff's missile launcher is named "turret09a-01-main" instead of "turret09". So, I either need help with the script, or I need somebody to open up a modeling program and change the Orff's turret name. I'm hesitant to ask somebody to do that for me (I know it sounds really lazy), but I have no skill with 3d modeling, and with all my schoolwork and work on my campaign I don't have time to learn.
Ships.tbl Entry:
(I know it looks ridiculously overpowered, but it's no stronger than the upgunned Deimos I'm using)
$Name: GTC Orff
$Short name: TBattleCruise
$Species: Terran
+Tech Description:
XSTR("The GTC Orff is one of the oldest warships in the GTVA. First put into service during the TV-War, the Orff was originally a Fenris-class cruiser that repeatedly managed to survive engagements with much larger warships-most notably the GTD Hades. During the Second Shivan Incursion, the Orff was rebuilt into one of the first Marauder-class cruisers. The Orff's most important modificatons, however, came from a captured SC Lilith. The Shivan cruiser's incredibly powerful reactor was used to upgrade the Orff's beam and torpedo weaponry, giving it a punch comparable to a corvette. Far stronger armor plating and engine technology (including an afterburner) were added, greatly increasing its survivability. Relative to its size, the Orff is one of the strongest warships in the GTVA.
____________________
STATISTICS
Type: Heavy Cruiser
Commanding Officer: Rear Admiral Casey Noland
Manufacturer: Han-Ronald Corp/GTVI
Max Velocity: 40 m/s
Armor: 80000
____________________
ARMAMENT
GTVA Turbolaser X 3
Standard Flak X 2
Anti-Fighter Beam X 2
Arctic Typhoon X 1
Megacyclone X 1", -1)
$end_multi_text
$POF file: Orff.pof
$Detail distance: (0, 600, 1500, 5000)
$Show damage: YES
$Density: 1
$Damp: 0.2
$Rotdamp: 1.0
$Max Velocity: 0.0, 0.0, 40.0
$Rotation time: 20.0, 20.0, 20.0
$Rear Velocity: 0.0
$Forward accel: 10.0
$Forward decel: 5.0
$Slide accel: 0.0
$Slide decel: 0.0
$Expl inner rad: 125.0
$Expl outer rad: 650.0
$Expl damage: 200.0
$Expl blast: 3500.0
$Expl Propagates: YES ;; If set to Yes, then when the ship dies, the explosion propagates through it.
$Shockwave Speed: 500.0 ;; speed shockwave expands at, 0 means no shockwave
$Default PBanks: ()
$Default SBanks: ()
$SBank Capacity: ()
$Shields: 0
$Power Output: 90.0
$Max Oclk Speed: 40.0
$Max Weapon Eng: 100.0
$Hitpoints: 80000
$Armor Type: HeavyArmor
$Flags: ( "cruiser" "big damage" "in tech database" "player_ship" "generate icon" "show ship" "no pain flash" )
$AI Class: Eos-General
$Afterburner: YES
+Aburn Max Vel: 0.0, 0.0, 80.0
+Aburn For accel: 0.7
+Aburn Fuel: 400.0
+Aburn Burn Rate: 50.0
+Aburn Rec Rate: 25.0
$Countermeasures: 0
$Scan time: 2000
$EngineSnd: 128 ;; Engine sound of ship
$Closeup_pos: 0.0, 0.0, -315
$Closeup_zoom: 0.5
$Score: 300
$Thruster Bitmap 2: thruster02-01LessHaze
$Thruster02 Radius factor: 0.75
$Thruster02 Length factor: 0.6
$Radar Image 2D: radar-cruiser
$Subsystem: turret01, 2, 5.0
$Default PBanks: ( "GTVA Turbolaser" )
$Flags: ( "check hull" )
$Subsystem: turret02, 3, 5.0
$Default PBanks: ( "HBlue" )
$Flags: ( "check hull" )
$Subsystem: turret03, 2, 5.0
$Default PBanks: ( "Standard Flak" )
$Flags: ( "check hull" )
$Subsystem: turret04, 2, 5.0
$Default PBanks: ( "AAAf" )
$Flags: ( "check hull" )
$Subsystem: turret05, 2, 5.0
$Default PBanks: ( "Standard Flak" )
$Flags: ( "check hull" )
$Subsystem: turret06, 2, 5.0
$Default PBanks: ( "AAAf" )
$Flags: ( "check hull" )
$Subsystem: turret07, 2, 5.0
$Default PBanks: ( "GTVA Turbolaser" )
$Flags: ( "check hull" )
$Subsystem: turret08, 2, 5.0
$Default PBanks: ( "GTVA Turbolaser" )
$Flags: ( "check hull" )
$Subsystem: turret09a-01-main, 8, 10.0
$Default SBanks: ( "Megacyclone" )
$Flags: ( "check hull" "reset when idle" )
$animation: triggered
$type: initial
+relative_angle: 90,180,0
$Subsystem: radar01a-dish, 5, 0.0
$Subsystem: sensors, 4, 0
$Subsystem: communication, 4, 0.0
$Subsystem: navigation, 4, 0.0
$Subsystem: weapons, 4, 0.0
$Subsystem: engine, 30, 0.0
$Engine Wash: Default100
]
Eos-csc-sct.tbm
;The CSC script. No longer messy and unreadable. Allows 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 setTurretColor(weapon)
gr.setColor(csc.turretColors[weapon][1], csc.turretColors[weapon][2], csc.turretColors[weapon][3])
end
function drawTurretUI()
local sel = csc.shipdef[csc.shipIdx].turretControl[csc.acnum]
local weapon
gr.drawString("", 5, gr.getScreenHeight() * 0.6)
for i = 1, #csc.shipdef[csc.shipIdx].turretControl, 1 do
weapon = csc.shipdef[csc.shipIdx].turretControl[i]
ba.print("CSC: ui: " .. weapon)
if sel == weapon then
gr.setColor(255, 255, 255)
else
setTurretColor(weapon)
end
gr.drawString(csc.turretDisplay[weapon] .. csc.turretMode[weapon][csc.turretStatus[weapon]])
setTurretColor(weapon)
for i = 1, #csc.turretGroup[weapon], 1 do
local targetname = getTargetName(csc.turretGroup[weapon][i].Target)
if not targetname then targetname = "None" end
if weapon == "pd" then
gr.drawString(" PD Turret: " .. targetname)
else
gr.drawString(" " .. csc.turretGroup[weapon][i].Name .. ": " .. targetname)
end
end
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()
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
for j = 1, #csc.weapondef, 1 do
if string.find(csc.turrets[i].PrimaryBanks[1].WeaponClass.Name, csc.weapondef[j].weapon) then
csc.turretGroup[csc.weapondef[j].turret][#csc.turretGroup[csc.weapondef[j].turret] + 1] = csc.turrets[i]
ba.print("CSC: Found " .. csc.weapondef[j].weapon .. ". Turret Number: " .. i .. " weaponnum: " .. #csc.turretGroup[csc.weapondef[j].turret] .. "\n")
end
end
end
end
csc.initComplete = true
end
function drawTargetBraces(weapon)
setTurretColor(weapon)
for i = 1, #csc.turretGroup[weapon], 1 do
target = csc.turretGroup[weapon][i].Target
if target:isValid() then
gr.drawTargetingBrackets(target, true, csc.turretColors[weapon][4])
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.acnum == 0 then
csc.acnum = #csc.shipdef[csc.shipIdx].turretControl
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.acnum == #csc.shipdef[csc.shipIdx].turretControl + 1 then
csc.acnum = 1
end
csc.inputstates.keydown = true
elseif not InputStates.down then
csc.inputstates.keydown = false
end
local weapon = csc.shipdef[csc.shipIdx].turretControl[csc.acnum]
if InputStates.left and not csc.inputstates.keyleft then
if csc.turretStatus[weapon] <= 1 then
csc.turretStatus[weapon] = #csc.turretMode[weapon]
else
csc.turretStatus[weapon] = csc.turretStatus[weapon] - 1
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.turretStatus[weapon] >= #csc.turretMode[weapon] then
csc.turretStatus[weapon] = 1
else
csc.turretStatus[weapon] = csc.turretStatus[weapon] + 1
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 doTurretMode()
local weapon
for j = 1, #csc.shipdef[csc.shipIdx].turretControl, 1 do
weapon = csc.shipdef[csc.shipIdx].turretControl[j]
if csc.turretStatus[weapon] == 1 then
for i = 1, #csc.turretGroup[weapon] do
csc.turretGroup[weapon][i]:targetingOverride(false)
end
elseif csc.turretStatus[weapon] == 2 then
for i = 1, #csc.turretGroup[weapon] do
csc.turretGroup[weapon][i].Target = csc.plrship.Target
end
elseif csc.turretStatus[weapon] == 3 then
if csc.CurrentTarget then
if csc.CurrentTarget:isValid() then
for i = 1, #csc.turretGroup[weapon] do
csc.turretGroup[weapon][i].Target = csc.CurrentTarget
end
end
end
elseif csc.turretStatus[weapon] == 4 then
for i = 1, #csc.turretGroup[weapon] do
csc.turretGroup[weapon][i]:targetingOverride(true)
end
end
end
end
function drawRangeDisplay()
local turposCount = #csc.shipdef[csc.shipIdx].turretRange
if turposCount > 0 then
csc.range = nil
csc.range = {}
csc.range.Shipname = {}
csc.range.Range = {}
local plrship = hv.Player
local turpos = {}
for j = 1, turposCount, 1 do
turpos[j] = (plrship.Position + plrship[csc.shipdef[csc.shipIdx].turretRange[j]].Position)
end
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 tempsum = 0
for j = 1, turposCount, 1 do
tempsum = tempsum + math.sqrt( (temp[1] - turpos[j][1])^2 + (temp[2] - turpos[j][2])^2 + (temp[3] - turpos[j][3])^2 )
end
csc.range.Shipname[items] = tempship.Name
csc.range.Range[items] = math.floor( tempsum / turposCount)
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
end
function turretInit(weapon, display, r, g, b, p)
csc.turretGroup[weapon] = {}
csc.turretMode[weapon] = {"Automatic", "Track", "Lock", "Offline"}
csc.turretStatus[weapon] = 1
csc.turretColors[weapon] = {r, g, b, p}
csc.turretDisplay[weapon] = display
ba.print("CSC: Turret init " .. weapon .. "\n")
end;
function weaponInit(weapon, turret)
local i = #csc.weapondef + 1
csc.weapondef[i] = {}
csc.weapondef[i].weapon = weapon
csc.weapondef[i].turret = turret
ba.print("CSC: Weapon init " .. weapon .. "\n")
end
function defineTurrets()
csc.turretGroup = {}
csc.turretStatus = {}
csc.turretColors = {}
csc.turretMode = {}
csc.turretDisplay = {}
-- 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("maul", "Maul Turbolasers: ", 0, 100, 255, 10)
turretInit("pulsar", "Pulsar Turrets: ", 0, 100, 255, 10)
turretInit("quasar", "Quasar Turrets: ", 0, 100, 255, 10)
turretInit("aaaf", "AAA Beams: ", 255, 255, 255, 10)
turretInit("sflak", "Flak Cannons: ", 255, 100, 0, 10)
turretInit("hflak", "Heavy Flak Cannons: ", 255, 100, 0, 10)
turretInit("lrflak", "LR Flak Cannons: ", 255, 100, 0, 10)
turretInit("mx52", "MX-52 Swarm Missiles: ", 255, 0, 0, 10)
turretInit("mcyclone", "Megacyclone Torpedos: ", 255, 0, 0, 20)
turretInit("hblue", "Arctic Typhoon: ", 0, 0, 255, 2)
end
function defineWeapons()
csc.weapondef = {}
--weaponClassName -> turret group
weaponInit("Point Defense Turret", "pd")
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("Point Defense Turret", "pd")
weaponInit("GTVA Turbolaser", "maul")
weaponInit("GTVA Turret", "pulsar")
weaponInit("GTVA Huge Turret", "quasar")
weaponInit("AAAf", "aaaf")
weaponInit("Standard Flak", "sflak")
weaponInit("Heavy Flak", "hflak")
weaponInit("Long Range Flak", "lrflak")
weaponInit("MX-52", "mx52")
weaponInit("Megacyclone", "mcyclone")
weaponInit("HBlue", "hblue")
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={}
--Orff
--Entry number - don't forget to change while copypasting this one
i = 3
csc.shipdef[i] = {}
csc.shipdef[i].shipClassName = "GTC Orff"
--turrets showing target braces
csc.shipdef[i].turretTargets={"maul", "sflak", "aaaf", "hblue", "mcyclone"}
--turrets aviable in UI
csc.shipdef[i].turretControl={"maul", "sflak", "aaaf", "hblue", "mcyclone"}
--turrets to calculate target range
csc.shipdef[i].turretRange={"turret01", "turret02", "turret03", "turret04", "turret05", "turret06", "turret07", "turret08", "turret09a-01-main"}
-- possible turret weapon groups:
-- {"maul", "sflak", "aaaf", "hblue", "mcyclone"}
end
-- config stuff end
function cscInit()
csc = {}
if not csc.initComplete then
defineShips()
defineWeapons()
ba.print("CSC: init \n")
if not csc.plrship then
csc.plrship = hv.Player
csc.disable = true
if csc.plrship:getBreedName() == "Ship" then
csc.shipIdx = 0
for i = 1, #csc.shipdef, 1 do
if csc.plrship.Class.Name == csc.shipdef[i].shipClassName then
csc.shipIdx = i
csc.disable = false
ba.print("CSC: Ship found " .. csc.shipdef[i].shipClassName)
end
end
end
if not csc.disable and not csc.turrets then
defineTurrets()
csc.active = {"*", " ", " "}
csc.acnum = 1
csc.inputstates = {}
inputlocked = false
fillturretlist(csc.plrship)
groupTurrets()
--The Shieldman and Betty script overrides
ShieldmanOverride = true
BettyOverride = true
end
end
end
end
]
$On Gameplay Start:
[
if (csc) then
ba.warning("There was already a CSC table present when initing the CSC script!")
end
cscInit()
]
$State: GS_STATE_GAME_PLAY
$On Frame:
[
cscMissionTime = mn.getMissionTime()
if cscMissionTime ~= 0 then
if csc then
if not csc.disable and csc.initComplete then
doInput()
doTurretMode()
for j = 1, #csc.shipdef[csc.shipIdx].turretTargets, 1 do
drawTargetBraces(csc.shipdef[csc.shipIdx].turretTargets[j])
end
end
end
end
]
$On HUD Draw:
[
if csc then
if not csc.disable and csc.initComplete then
drawRangeDisplay()
drawTurretUI()
end
end
]
$On Mission End:
[
csc = nil
ShieldmanOverride = false
BettyOverride = false
]
#End