Author Topic: Actually useful bomber turrets  (Read 4984 times)

0 Members and 1 Guest are viewing this topic.

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
Actually useful bomber turrets
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.
Do not meddle in the affairs of coders for they are soggy and hard to light

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

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: Actually useful bomber turrets
You need to change
Code: [Select]
            stringBomberSubsystem = subsystemBomber:getName()to
Code: [Select]
            stringBomberSubsystem = subsystemBomber.Name
-C

 

Offline Bob-san

  • Wishes he was cool
  • 210
  • It's 5 minutes to midnight.
Re: Actually useful bomber turrets
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.
NGTM-1R: Currently considering spending the rest of the day in bed cuddling.
GTSVA: With who...?
Nuke: chewbacca?
Bob-san: The Rancor.

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
Re: Actually useful bomber turrets
I'll have to remember this BWO could probably use this for the Vanir.
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
Re: Actually useful bomber turrets
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.
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline Bob-san

  • Wishes he was cool
  • 210
  • It's 5 minutes to midnight.
Re: Actually useful bomber turrets
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%.
NGTM-1R: Currently considering spending the rest of the day in bed cuddling.
GTSVA: With who...?
Nuke: chewbacca?
Bob-san: The Rancor.

 
Re: Actually useful bomber turrets
Quote
my accuracy was over 120%.


 

Offline Bob-san

  • Wishes he was cool
  • 210
  • It's 5 minutes to midnight.
Re: Actually useful bomber turrets
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!
NGTM-1R: Currently considering spending the rest of the day in bed cuddling.
GTSVA: With who...?
Nuke: chewbacca?
Bob-san: The Rancor.

  

Offline Fabian

  • AI Code Modulator
    Temporal Mechanic
  • 25
Re: Actually useful bomber turrets
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

 

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
Re: Actually useful bomber turrets
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)
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline Flaser

  • 210
  • man/fish warsie
Re: Actually useful bomber turrets
...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
"I was going to become a speed dealer. If one stupid fairytale turns out to be total nonsense, what does the young man do? If you answered, “Wake up and face reality,” you don’t remember what it was like being a young man. You just go to the next entry in the catalogue of lies you can use to destroy your life." - John Dolan

 

Offline Bob-san

  • Wishes he was cool
  • 210
  • It's 5 minutes to midnight.
Re: Actually useful bomber turrets
That setup could be fun.... like hit scrolllock to switch between the three.
NGTM-1R: Currently considering spending the rest of the day in bed cuddling.
GTSVA: With who...?
Nuke: chewbacca?
Bob-san: The Rancor.

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

 

Offline Flaser

  • 210
  • man/fish warsie
Re: Actually useful bomber turrets
...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.
"I was going to become a speed dealer. If one stupid fairytale turns out to be total nonsense, what does the young man do? If you answered, “Wake up and face reality,” you don’t remember what it was like being a young man. You just go to the next entry in the catalogue of lies you can use to destroy your life." - John Dolan