Hard Light Productions Forums
Modding, Mission Design, and Coding => The Scripting Workshop => Topic started by: Wanderer on February 19, 2007, 01:06:56 pm
-
So fighter/bomber turrets that actually track the closest enemy ship instead of targetting the bombers current target.
#Global Hooks
$Simulation:
[
missiontime = mn.getMissionTime()
if missiontime > 0.5 then
for r = 1,#mn.Ships do
bomber = mn.Ships[r]
stringBomberType = bomber.Class.Type.Name
vectorBomberPosition = bomber.Position
teamBomber = bomber.Team.Name
if stringBomberType == "Bomber" or stringBomberType == "Fighter" then
numberBomberSubsystems = #bomber
for t =1,numberBomberSubsystems do
subsystemBomber = bomber[t]
stringBomberSubsystem = subsystemBomber:getName()
if stringBomberSubsystem == "laser turret" then
tableTargetDistance = nil
tableTargetDistance = {}
tableTargetOrder = nil
tableTargetOrder = {}
for g=1,#mn.Ships do
target = mn.Ships[g]
teamTarget = target.Team.Name
if teamTarget ~= teamBomber then
vectorTargetPosition = target.Position
numberTargetDistance = math.floor(vectorBomberPosition:getDistance(vectorTargetPosition))
tableTargetDistance[numberTargetDistance] = target
table.insert(tableTargetOrder,numberTargetDistance)
end
end
table.sort(tableTargetOrder)
if tableTargetOrder[1] ~= nil then
numberNewTargetDistance = tableTargetOrder[1]
newtarget = tableTargetDistance[numberNewTargetDistance]
if newtarget ~= nil then
subsystemBomber.Target = newtarget
end
end
end
end
end
end
end
]
#End
Script can be easily changed into shipclass specific.
-
LUA ERROR: [string "Simulation"]:13: attempt to call method 'getName' (a nil value)
------------------------------------------------------------------
ADE Debug:
------------------------------------------------------------------
Name: (null)
Name of: (null)
Function type: (null)
Defined on: 0
Upvalues: 0
Source: (null)
Short source:
Current line: 0
------------------------------------------------------------------
------------------------------------------------------------------
LUA Stack:
------------------------------------------------------------------
------------------------------------------------------------------
Could not find index 'getName' in type 'subsystem'
------------------------------------------------------------------
ADE Debug:
------------------------------------------------------------------
Name: (null)
Name of: (null)
Function type: (null)
Defined on: 0
Upvalues: 0
Source: (null)
Short source:
Current line: 0
------------------------------------------------------------------
------------------------------------------------------------------
LUA Stack:
------------------------------------------------------------------
1: Userdata [subsystem]
2: String [getName]
------------------------------------------------------------------
LUA ERROR: [string "Simulation"]:13: attempt to call method 'getName' (a nil value)
------------------------------------------------------------------
ADE Debug:
------------------------------------------------------------------
Name: (null)
Name of: (null)
Function type: (null)
Defined on: 0
Upvalues: 0
Source: (null)
Short source:
Current line: 0
------------------------------------------------------------------
------------------------------------------------------------------
LUA Stack:
------------------------------------------------------------------
------------------------------------------------------------------
Could not find index 'getName' in type 'subsystem'
------------------------------------------------------------------
ADE Debug:
------------------------------------------------------------------
Name: (null)
Name of: (null)
Function type: (null)
Defined on: 0
Upvalues: 0
Source: (null)
Short source:
Current line: 0
------------------------------------------------------------------
------------------------------------------------------------------
LUA Stack:
------------------------------------------------------------------
1: Userdata [subsystem]
2: String [getName]
------------------------------------------------------------------
LUA ERROR: [string "Simulation"]:13: attempt to call method 'getName' (a nil value)
------------------------------------------------------------------
ADE Debug:
------------------------------------------------------------------
Name: (null)
Name of: (null)
Function type: (null)
Defined on: 0
Upvalues: 0
Source: (null)
Short source:
Current line: 0
------------------------------------------------------------------
------------------------------------------------------------------
LUA Stack:
------------------------------------------------------------------
------------------------------------------------------------------
Could not find index 'getName' in type 'subsystem'
------------------------------------------------------------------
ADE Debug:
------------------------------------------------------------------
Name: (null)
Name of: (null)
Function type: (null)
Defined on: 0
Upvalues: 0
Source: (null)
Short source:
Current line: 0
------------------------------------------------------------------
------------------------------------------------------------------
LUA Stack:
------------------------------------------------------------------
1: Userdata [subsystem]
2: String [getName]
------------------------------------------------------------------
and some more...
-
You need to change
stringBomberSubsystem = subsystemBomber:getName()
to
stringBomberSubsystem = subsystemBomber.Name
-
I never found anything wrong with my Ursa's turret--the Kayser works excellently. I have had so many kills with a turret when playing various bomber missions--I have received over 100% accuracy several times because of the turret making the annoying kills (like keeping a Ulysses above me, the turret takes care of it and keeps it from making a run).
Whatever-I'll look at this code I guess.
-
I'll have to remember this BWO could probably use this for the Vanir.
-
I never found anything wrong with my Ursa's turret--the Kayser works excellently. I have had so many kills with a turret when playing various bomber missions--I have received over 100% accuracy several times because of the turret making the annoying kills (like keeping a Ulysses above me, the turret takes care of it and keeps it from making a run).
Whatever-I'll look at this code I guess.
True.. if you continuously keep the Ulysses targeted then the Kayser will shoot at it. However if you try to attack against capital ship then the turret wont shoot any of the fighters attacking the bomber.. Which kinda defeats the purpose of having defensive turrets at all.
-
Good point too... I generally can't attack a capital ship in an Ursa if there are any fighters left. I've ran into the problem in the first bomber mission in the nebula--I had to fight for quite a long time until all the Shivan fighters were destroyed. That mission in particular, my accuracy was over 120%.
-
my accuracy was over 120%.
(http://static.pardus.at/images/chat/mellow.png)
-
That's what happens when you take sure shots at cap ships and let your turret do the rest! The turret's shots missed doesn't count on your record, though the hits do! So do the kills. I have a few missions where I shot fewer times then I killed--and I mean with primaries!
-
I never found anything wrong with my Ursa's turret--the Kayser works excellently. I have had so many kills with a turret when playing various bomber missions--I have received over 100% accuracy several times because of the turret making the annoying kills (like keeping a Ulysses above me, the turret takes care of it and keeps it from making a run).
Whatever-I'll look at this code I guess.
True.. if you continuously keep the Ulysses targeted then the Kayser will shoot at it. However if you try to attack against capital ship then the turret wont shoot any of the fighters attacking the bomber.. Which kinda defeats the purpose of having defensive turrets at all.
What about changing it then to:
- Attack target of bomber if target is not CAPSHIP.
- If target is capship, target whatever attacks you, be it fighter or cap ships beam or laser cannons ...
cu
Fabian
-
Backwards compatibility... So only optional changes would be possible. But i would prefer fighter/bomber turrets to have options which could probably be settable via subsystem flags...
Like
i) Attack the current target (yeah, the current one - as bombers can have beam turrets :P )
ii) Attack the closest targetable enemy (the way capship turrets do)
-
...or a turret "minimenu", where you can set the behaviour for each turret a'la Archimedean Dynasty:
1. Attack my target
2. Synchronise to my gun (it acts as another gun point)
3. Defensive mode
-
That setup could be fun.... like hit scrolllock to switch between the three.
-
...or a turret "minimenu", where you can set the behaviour for each turret a'la Archimedean Dynasty:
1. Attack my target
2. Synchronise to my gun (it acts as another gun point)
3. Defensive mode
Change that to: A'la X-Wing Alliance.
-
...or a turret "minimenu", where you can set the behaviour for each turret a'la Archimedean Dynasty:
1. Attack my target
2. Synchronise to my gun (it acts as another gun point)
3. Defensive mode
Change that to: A'la X-Wing Alliance.
...as well.
Looks like I've played more classics.