Bridge Commander Central
BC Forums => BC Scripting => Topic started by: vonfrank on November 11, 2012, 10:52:16 PM
-
Those of you who have played SFC3 will know what I mean. For those of you who don't, here's pretty much how it works...
SFC3 has 4 shield vectors, and you have the ability to choose one particular shield to divert power to. If you reinforce your forward shield, 33.3% of the power form your Port, Starboard, and Aft shields would be diverted to your Forward Shield, giving it ~200% of its normal power.
So my goal for a simple BC script is to make this type of shield reinforcement possible. It would work something like this...
A button on Felix's tactical menu allows you to enable shield reinforcement on a particular vector (6 vectors, so 6 buttons). If you select the forward shield, the script will check to see if the other 5 vectors have at least 20% of their full strength and then divert 10% form each one towards the forward shield giving it a boost of 50%.
-Edit-
Upon extensive searching I found some functions listed in the App.py file in the main script directory. I wrote the script and it works, but my problem now is that my shields will not actually go above 100%. Is there any way to get the shield values to go up to 150% of max?
-
Defiant's Advanced Power Mod allows you to boost the shields to 200% IIRC...
and I think that reinforce shields was part of BCS:TB?
-
that is correct - BCS:TB has a "Boost Shields" option...
this is from the BCS:TB readme:
"Hull breaches detected on Decks 34, 35, and 36!"
"Get more power to the shields! Drain it straight from the warp core if you have to!"
"GAK!" (crewman dies as console explodes for no reason)
Finally, this can be you. Strategic use of the shield booster options in the new submenu at Tactical can keep you alive for a lot longer than you'd expect. Pick the shield to boost, watch your power levels fall off as that power begins the 10 second transfer to your chosen shields. The more shields you recharge, the less energy you'll have left over, so be careful. Of course, we made sure you wouldn't overextend yourself too quickly simply by adding a 45-second recharge period between boosts. You've got to give Chief Brex a break, you know.
BS Strategy:
You may not assume this section is B.S. solely because it is labeled "BS Strategy." Seriously, do like they do in Star Trek: once you've recharged a shield, make sure that shield takes the majority of the beating. Try boosting early in the battle rather than later. By the time your shields are red, you generally need every ounce of warp core power you can squeeze out. Also, make sure you're not sucking so much power that you lose your weapons or, worse, your engines.
-
Theres also the "redistribute shields" script too...
-
I think that's the one I was thinking of actually!
Can I just take this opportunity to say how much I love the BCS:TB readme - along with all the random comments in the scripts!
-
I think that's the one I was thinking of actually!
no, you were on the right track, that is the Advanced Power Control your talking about, all it does it just allocate more power to the shields like you normally would in brex's 4 slider bars.
you just have WAY more control over how the power is distributed, but beware, putting TOO much power to a device (namly torpedo launchers, pulse weapons, and phaser arrays) can LITERALLY burn out and get destroyed.
the redistribute shields script is a button in felix's menu that when clicked, LITERALLY redistributes the remaining HP of ALL the shield vectors across them all.
so say you have 6 vectors (dorsal, ventral, ETC.)
4 out of 6 is @ 100%
2 are @ 75%
clicking the button than makes all shields up to 90%(?)
im not TOTALLY sure on the math, but thats the basic jist of it.
Can I just take this opportunity to say how much I love the BCS:TB readme - along with all the random comments in the scripts!
#init scripts :funny i remember digging through thouse....
IIRC one had a "contest" in it lol
-
I'm aware of the Redistribute Shields script, but that is not what I'm trying to accomplish with this script.
Just so you have an idea, here is the script which, as of now, only allows you to reinforce the Forward Shield:
from bcdebug import debug
import App
import Foundation
import MissionLib
import Lib.LibEngineering
def ReinforceForward(pObject, pEvent):
pPlayer = MissionLib.GetPlayer()
if pPlayer and pPlayer.GetShields():
pShields = pPlayer.GetShields()
fRightShield_p = pShields.GetSingleShieldPercentage(App.ShieldClass.RIGHT_SHIELDS)
fLeftShield_p = pShields.GetSingleShieldPercentage(App.ShieldClass.LEFT_SHIELDS)
fForwardShield_p = pShields.GetSingleShieldPercentage(App.ShieldClass.FRONT_SHIELDS)
fBackShield_p = pShields.GetSingleShieldPercentage(App.ShieldClass.REAR_SHIELDS)
fLowerShield_p = pShields.GetSingleShieldPercentage(App.ShieldClass.BOTTOM_SHIELDS)
fUpperShield_p = pShields.GetSingleShieldPercentage(App.ShieldClass.TOP_SHIELDS)
fRightShield_v = pShields.GetCurShields(App.ShieldClass.RIGHT_SHIELDS)
fLeftShield_v = pShields.GetCurShields(App.ShieldClass.LEFT_SHIELDS)
fForwardShield_v = pShields.GetCurShields(App.ShieldClass.FRONT_SHIELDS)
fBackShield_v = pShields.GetCurShields(App.ShieldClass.REAR_SHIELDS)
fLowerShield_v = pShields.GetCurShields(App.ShieldClass.BOTTOM_SHIELDS)
fUpperShield_v = pShields.GetCurShields(App.ShieldClass.TOP_SHIELDS)
fRightShield_m = pShields.GetMaxShields(App.ShieldClass.RIGHT_SHIELDS)
fLeftShield_m = pShields.GetMaxShields(App.ShieldClass.LEFT_SHIELDS)
fForwardShield_m = pShields.GetMaxShields(App.ShieldClass.FRONT_SHIELDS)
fBackShield_m = pShields.GetMaxShields(App.ShieldClass.REAR_SHIELDS)
fLowerShield_m = pShields.GetMaxShields(App.ShieldClass.BOTTOM_SHIELDS)
fUpperShield_m = pShields.GetMaxShields(App.ShieldClass.TOP_SHIELDS)
if (fRightShield_p > 0.2) and (fLeftShield_p > 0.2) and (fBackShield_p > 0.2) and (fLowerShield_p > 0.2) and (fUpperShield_p > 0.2) and (fForwardShield_p <= 1.5):
pShields.SetCurShields(App.ShieldClass.RIGHT_SHIELDS,(fRightShield_v - (fRightShield_m * 0.1)))
pShields.SetCurShields(App.ShieldClass.LEFT_SHIELDS,(fLeftShield_v - (fLeftShield_m * 0.1)))
pShields.SetCurShields(App.ShieldClass.REAR_SHIELDS,(fBackShield_v - (fBackShield_m * 0.1)))
pShields.SetCurShields(App.ShieldClass.BOTTOM_SHIELDS,(fLowerShield_v - (fLowerShield_m * 0.1)))
pShields.SetCurShields(App.ShieldClass.TOP_SHIELDS,(fUpperShield_v - (fUpperShield_m * 0.1)))
pShields.SetCurShields(App.ShieldClass.FRONT_SHIELDS,(fForwardShield_v + (fForwardShield_m * 0.5)))
return
def init():
Lib.LibEngineering.CreateMenuButton("Reinf. Fore Shield", "Tactical", __name__ + ".ReinforceForward")
Lib.LibEngineering.AddKeyBind("Reinf. Fore Shield", __name__ + ".ReinforceForward")
Overall, the script works the way I want, except for 2 things.
1. (As I said before), the reinforced shield does not seem to be able to go above 100%, meaning that if you reinforce your forward shield when all of your shields are at 100%, the forward one will remain at 100% while the others go down to 90%. I need to be able to let the shields go above 100%.
2. The shortcut key does not work. It does not appear in the Key Binding menu.
-
2) IIRC Keybindings are a bit curious - if you start QuickBattle and look it should be there?
1) My advice would be to look at the Advanced Power Options Mod and see how Defiant overcomes the 100% limit?
Sorry, I replied to those in the wrong order!
-
I'm aware of the Redistribute Shields script, but that is not what I'm trying to accomplish with this script.
Just so you have an idea, here is the script which, as of now, only allows you to reinforce the Forward Shield:
Overall, the script works the way I want, except for 2 things.
1. (As I said before), the reinforced shield does not seem to be able to go above 100%, meaning that if you reinforce your forward shield when all of your shields are at 100%, the forward one will remain at 100% while the others go down to 90%. I need to be able to let the shields go above 100%.
2. The shortcut key does not work. It does not appear in the Key Binding menu.
Well it's an admirable concept, but what your looking for is in both Defiant's Advanced Power mod and BCS's Boost Shields. If I understand your two points correctly. You can allocate more power (125%) to a given shield vector with Defiant's mod (depending on how you have your hardpoints configured) If your using a weak ship, the power usage stats will reflect this in the Power GUI. On the BCS's Boost Shields you can perform a energy dump into a specific shield vector.
I'm not knocking your attempts at all, but mods like APM, Boost Shields and Redistribute Shields are definitive.
Good luck on your project. :D
BR32
-
I'm not really sure if the Advanced Power tools is right for the job. After all, I'm not trying to allocate more POWER to the shields, I'm just trying to set the STRENGTH of the shield to a higher value.
For example:
Lets say the my ship has the following shield values in the hardpoint...
ShieldGenerator.SetMaxShields(ShieldGenerator.FRONT_SHIELDS, 12000.000000)
ShieldGenerator.SetMaxShields(ShieldGenerator.REAR_SHIELDS, 12000.000000)
ShieldGenerator.SetMaxShields(ShieldGenerator.TOP_SHIELDS, 12000.000000)
ShieldGenerator.SetMaxShields(ShieldGenerator.BOTTOM_SHIELDS, 12000.000000)
ShieldGenerator.SetMaxShields(ShieldGenerator.LEFT_SHIELDS, 12000.000000)
ShieldGenerator.SetMaxShields(ShieldGenerator.RIGHT_SHIELDS, 12000.000000)
If my ship is just sitting there and not being attacked, my shields are all at 100% (which is 12,000 each). If I reinforce my forward shield, that shield will go up to 18,000 and the other 5 shields will go down to 10,800. Now, the actual MAX Shield value in the hardpoint is not changing, it stays at 12,000 for all 6 shield vectors, its just the CURRENT shield value that gets either increased or decreased. If I have the shield percentages mod equipped, I should see my forward shield at 150% (18,000 / 12,000) and the other 5 shields at 90% (10,800 / 12,000).
The problem here is that I'm not sure if the game engine can handle a particular shield's CURRENT value being higher than it's MAX value. If this is the case I may have to tweak the script and make the reinforcement only selectable if the shield is already at 50% or less, which would ensure that the script never tries to set the shield above 100%.
As for the shortcut key binding, I have no clue how to do this. Is this even the correct code to make a key binding?
Lib.LibEngineering.AddKeyBind("Reinf. Fore Shield", __name__ + ".ReinforceForward")
If anyone has experience with custom keybinds, please let me know what I'm doing wrong.
-
do you have the specific menu listed in the script?
for example, code from Boost Shields:
def init():
global pMain, pForward, pRear, pTop, pBottom, pLeft, pRight, pAll
if App.g_kUtopiaModule.IsMultiplayer():
return
if not Libs.LibEngineering.CheckActiveMutator("BCS:TB: Boost Shields"):
return
pMain = Libs.BCSTNGLib.CreateMenu("Shield Controls", "Tactical")
# In order or appearence in BC All, Front, Rear, Bottom, Top, Left and Right
pBottom = Libs.BCSTNGLib.CreateButton("Boost Ventral", "Tactical", __name__ + ".BoostBottom", "Shield Controls")
pTop = Libs.BCSTNGLib.CreateButton("Boost Dorsal", "Tactical", __name__ + ".BoostTop", "Shield Controls")
pRight = Libs.BCSTNGLib.CreateButton("Boost Starboard", "Tactical", __name__ + ".BoostRight", "Shield Controls")
pLeft = Libs.BCSTNGLib.CreateButton("Boost Port", "Tactical", __name__ + ".BoostLeft", "Shield Controls")
pRear = Libs.BCSTNGLib.CreateButton("Boost Aft", "Tactical", __name__ + ".BoostRear", "Shield Controls")
pForward = Libs.BCSTNGLib.CreateButton("Boost Forward", "Tactical", __name__ + ".BoostFront", "Shield Controls")
pAll = Libs.BCSTNGLib.CreateButton("Boost All", "Tactical", __name__ + ".BoostAll", "Shield Controls")
-
What if you add in something like:
if pShields.SetCurShields(App.ShieldClass.FRONT_SHIELDS,(fForwardShield_v + (fForwardShield_m * 0.5))) > pShields.GetMaxShields(App.ShieldClass.FORWARD_SHIELDS):
pShields.SetMaxShields(App.ShieldClass.FRONT_SHIELDS,(fForwardShield_v + (fForwardShield_m * 0.5)))
So you in effect tell the game to replace the old max shield level with what it is after your mod boosts the level?
You could also add in a function which finds out what the shield level is when you start the game, so add into init()
GetMaxShields()
and then add in a function
GetMaxShields
global g_pForwardShields, g_pAftShields (Etc)
g_pForwardShields = pShields.GetMaxShields(App.ShieldClass.FRONT_SHIELDS)
You could then add in a thing to monitor what the shield level is and if you boost above the max, you could start a 30 second (for example) timer, at which point the default max shields are restored - to stop people trying to exploit the mod to permanently boost the shield limit?
-
What does the "Boost Shield" function actually do anyway? I know that it's built default into the game, but I have no clue what it really does.
As for the shortcut key, I'm still totally lost. :idk:
I've taken a look at the way other mods have done it and I've tried to copy that with no success. I see that there is a way to do it by making a custom mutator, but can I do it without doing that? For example, can I make the QBautostart mutator load this as well?
-
Boost Shields isnt built default into the game, tho Redistribute Shields is... Redistribute Shields was one of those things that would have been used (one of many things) and was input into the stock game, but the game was put out sooner than it should have been and a number of things were left in unused... however, Boost Shields was a script built by BCS as part of the BCS:TB mod...
as far as what it does, i quoted the readme of it some posts up in this thread...
im not sure i understand how you mean "shortcut key"?
-
But "Boost Shield" is in the stock game's App.py file: (its the second line)
ShieldClass.GetNumShields = new.instancemethod(Appc.ShieldClass_GetNumShields, None, ShieldClass)
ShieldClass.BoostShield = new.instancemethod(Appc.ShieldClass_BoostShield, None, ShieldClass)
ShieldClass.GetShieldPercentage = new.instancemethod(Appc.ShieldClass_GetShieldPercentage, None, ShieldClass)
ShieldClass.GetSingleShieldPercentage = new.instancemethod(Appc.ShieldClass_GetSingleShieldPercentage, None, ShieldClass)
ShieldClass.SetCurShields = new.instancemethod(Appc.ShieldClass_SetCurShields, None, ShieldClass)
ShieldClass.GetCurShields = new.instancemethod(Appc.ShieldClass_GetCurShields, None, ShieldClass)
ShieldClass.GetMaxShields = new.instancemethod(Appc.ShieldClass_GetMaxShields, None, ShieldClass)
ShieldClass.IsShieldBreached = new.instancemethod(Appc.ShieldClass_IsShieldBreached, None, ShieldClass)
ShieldClass.IsAnyShieldBreached = new.instancemethod(Appc.ShieldClass_IsAnyShieldBreached, None, ShieldClass)
ShieldClass.RedistributeShields = new.instancemethod(Appc.ShieldClass_RedistributeShields, None, ShieldClass)
ShieldClass.GetShieldChargePerSecond = new.instancemethod(Appc.ShieldClass_GetShieldChargePerSecond, None, ShieldClass)
ShieldClass.IsShieldDamaged = new.instancemethod(Appc.ShieldClass_IsShieldDamaged, None, ShieldClass)
ShieldClass.SetShieldDamaged = new.instancemethod(Appc.ShieldClass_SetShieldDamaged, None, ShieldClass)
ShieldClass.GetOppositeShield = new.instancemethod(Appc.ShieldClass_GetOppositeShield, None, ShieldClass)
ShieldClass.GetShieldGlowDecay = new.instancemethod(Appc.ShieldClass_GetShieldGlowDecay, None, ShieldClass)
I see a number of other things in there including Redistribute Shields.
By "shortcut key" I mean the configurable keyboard bindings that are in the config menu. I'd like to make a new one for this Reinforce Shield function.
-
Boost Shields isnt built default into the game, tho Redistribute Shields is... Redistribute Shields was one of those things that would have been used (one of many things) and was input into the stock game, but the game was put out sooner than it should have been and a number of things were left in unused... however, Boost Shields was a script built by BCS as part of the BCS:TB mod...
as far as what it does, i quoted the readme of it some posts up in this thread...
Script built by: BCS
Using stock API functions: Yes
def init():
Lib.LibEngineering.CreateMenuButton("Reinf. Fore Shield", "Tactical", __name__ + ".ReinforceForward")
Lib.LibEngineering.AddKeyBind("Reinf. Fore Shield", __name__ + ".ReinforceForward")
Keybind added this way will require your QB script to be initialized first which is achieved by actually starting up QuickBattle at least once.
-
Keybind added this way will require your QB script to be initialized first which is achieved by actually starting up QuickBattle at least once.
Does that mean that every time I start the game I will have to enter QB before I can set and use the keybinding?
-
Yes, the answer is kind of obvious though. There are other ways of doing keybind take walkfx for example.
-
Just had a look at the WalkFX script - I thought I'd read it before, but I clearly haven't! I think I see how you did the KeyBindings there...but at the same time i'm pretty tired!
What i really wanted to say is how much I enjoy reading the "The Beginning" Scripts - there's something I like about all the random asides! You guys obviously had a lot of fun putting them together!
-
yeah the whole time BCS:TB was being made, and in the BCS forums, we all did have such a good time together :)
-
I agree those script comments are really funny :)
-
Most come from a man most of you guys don't know his name was Wowbagger.