Hard Light Productions Forums

Modding, Mission Design, and Coding => The Scripting Workshop => Topic started by: Wanderer on February 19, 2007, 01:06:56 pm

Title: Actually useful bomber turrets
Post 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.

Code: [Select]
#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.
Title: Re: Actually useful bomber turrets
Post by: Grizzly on May 20, 2007, 02:11:58 pm
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...
Title: Re: Actually useful bomber turrets
Post by: WMCoolmon on May 20, 2007, 06:14:01 pm
You need to change
Code: [Select]
            stringBomberSubsystem = subsystemBomber:getName()to
Code: [Select]
            stringBomberSubsystem = subsystemBomber.Name
Title: Re: Actually useful bomber turrets
Post by: Bob-san on June 03, 2007, 01:53:01 pm
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.
Title: Re: Actually useful bomber turrets
Post by: Bobboau on June 03, 2007, 02:44:57 pm
I'll have to remember this BWO could probably use this for the Vanir.
Title: Re: Actually useful bomber turrets
Post by: Wanderer on June 03, 2007, 02:58:42 pm
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.
Title: Re: Actually useful bomber turrets
Post by: Bob-san on June 04, 2007, 07:14:59 am
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%.
Title: Re: Actually useful bomber turrets
Post by: Grizzly on June 04, 2007, 02:06:34 pm
Quote
my accuracy was over 120%.

(http://static.pardus.at/images/chat/mellow.png)
Title: Re: Actually useful bomber turrets
Post by: Bob-san on June 05, 2007, 07:33:50 am
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!
Title: Re: Actually useful bomber turrets
Post by: Fabian on June 08, 2007, 07:37:01 pm
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
Title: Re: Actually useful bomber turrets
Post by: Wanderer on June 09, 2007, 12:59:37 am
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)
Title: Re: Actually useful bomber turrets
Post by: Flaser on June 12, 2007, 02:46:01 pm
...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
Title: Re: Actually useful bomber turrets
Post by: Bob-san on June 12, 2007, 03:24:31 pm
That setup could be fun.... like hit scrolllock to switch between the three.
Title: Re: Actually useful bomber turrets
Post by: Grizzly on June 17, 2007, 04:04:49 am
...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.
Title: Re: Actually useful bomber turrets
Post by: Flaser on June 17, 2007, 06:18:38 am
...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.