Ok, I have some success in coding the script... it comes in 2 parts...
Carrier Power Link start script
Code: Select all
001 $docked = [THIS] -> get ship array from sector/ship/station
002 $idx = size of array $docked
003 while $idx
004 |dec $idx =
005 |$ship = $docked[$idx]
006 @ |START $ship -> call script 'test.rg.pwrlink' :
007 end
008 return null
Docked Ship Power Link script
Code: Select all
001 infinite loop detection enabled=[FALSE]
002 $regen = [THIS] -> get power generator
003 $msg = 'Power Generator for ' + [THIS] + ' is ' + $regen
004 write to player logbook $msg
005 loop:
006 $shield = [THIS] -> get shield percent
007 while $shield < 100
008 @ |= wait 1000 ms
009 |$ship = [THIS] -> get current shield strength
010 |$max = [THIS] -> get maximum shield strength
011 |$ship = $ship + ( $regen / 2 )
012 |$ship = get maximum, $ship, $max, null, null, null
013 |[THIS] -> set current shield strength to $ship
014 |$shield = [THIS] -> get shield percent
015 end
016 $msg = 'Power Link engaging for ' + [THIS]
017 display subtitle text: text=$msg duration=3000 ms
018 $carrier1 = [DOCKEDAT] -> get current shield strength
019 while $shield >= 50
020 @ |= wait 1000 ms
021 |$carrier2 = [DOCKEDAT] -> get current shield strength
022 * Calculate excess shield damage to carrier
023 |$dmg = ( $carrier1 - $carrier2 ) / 100
024 |$dmg = get maximum, $dmg, 0, null, null, null
025 * Apply 1% of excess shield damage to docked ship
026 |$ship = [THIS] -> get current shield strength
027 |$ship = $ship - $dmg
028 |$ship = get maximum, $ship, 0, null, null, null
029 |[THIS] -> set current shield strength to $ship
030 * Check that docked ship has 50% or more remaining
031 |$shield = [THIS] -> get shield percent
032 |if $shield >= 50
033 * Pass on power from docked ship to carrier weapons
034 ||$laser = [DOCKEDAT] -> get current laser strength
035 ||$max = [DOCKEDAT] -> get maximum laser strength
036 ||$laser = $laser + ( $regen / 2 )
037 ||$laser = get maximum, $laser, $max, null, null, null
038 ||[DOCKEDAT] -> set laser energy to $laser
039 |end
040 |$carrier1 = $carrier2
041 end
042 $msg = 'Power Link disengaged for ' + [THIS]
043 display subtitle text: text=$msg duration=3000 ms
044 goto label loop
045 return null
With just a Pirate Kestral docked at my Hyperion I can fire ISR continuously so the efficiency co-efficient (currently 50% for weapon power/docked shield regen) probably needs to be severely reduced if we are to continue using shield power for the script.
As a proof of concept the above works but it needs further refinement.
The Docked Ship Power Link script does not allow the Power Link to start unless the docked ship has 100% shields and will use the redirected power to charge the shields if necessary.
Once the Power Link has engaged the docked ship will redirect it's power to the Carrier's weapons and will sustain 1% of the excess damage that the carrier takes to it's shields. When the docked ship looses 50% or more of it's shields it will disengage and recharge the shields back to 100% before re-engaging.
Lenna (aka
[SRK] The_Rabbit)
"Understanding is a three edged sword... your side, their side... and the Truth!" - J.J. Sheriden, Babylon 5 S4E6 T28:55
"May god stand between you and harm in all the dark places you must walk." - Ancient Egyption Proverb
"When eating an elephant take one bite at a time" -
Creighton Abrams