Author Topic: BC 1.1 - Secondary shield generators  (Read 5120 times)

Offline Bat66wat6

  • Posts: 144
  • Cookies: 34
  • Running custom BC 1.1
BC 1.1 - Secondary shield generators
« on: September 14, 2011, 06:14:53 AM »
I was unsure as to where I should put this topic, BC Modding or BC Scripting, however since seemingly everything in the game is dictated by a Python script in one way or another I decided on the BC Scripting area.

The Scimitar is capable of being a great ship in Bridge Commander however there are a few technical problems. Leaving out 'fire through cloak' the big problem I am stuck on now is how to make the Secondary Shield Generator actually do something.
-----------------------------------------
How feasible is the notion of a functioning Secondary shield generator on a ship in Bridge Commander version 1.1?

Would it be possible to put down some Python code that toggles the "primary" switch of the shield generator hardpoints so that when the primary shield generator is damage to 75% (disabled) it's "primary" hardpoint value is toggle to 0 while the secondary shield generator "primary" value is toggled to 1. Then, when and if the primary shield generator is repaired to say 80% the opposite happens and the primary values of both hardpoints are switched.

Because I know very little about Python scripting I don't know how feasible it is to pull this off, which is obviously why I am asking here. However, there are so many other seemingly far more complex things that the BC modding community has created such as Galaxy charts, Kobayashi Maru, warp core ejection, warp engine plasma leaks etc etc etc.

Thanks for taking the time to read I look forward to your replies.
Great men are not peacemakers! Great men are conquerors!

Offline KrrKs

  • Posts: 461
  • Cookies: 25
Re: BC 1.1 - Secondary shield generators
« Reply #1 on: September 14, 2011, 08:29:24 AM »
I'm not sure if toggling the "primary" setting is really necessary. I remember on of the DS9 Stations (not sure which one) had three Shield Generators.
When one of those was disabled, the Overall Shield- Strength simply dropped by that Generators Value. (I.E. Overall Shield Strengh was 15K, after one Generator disabled, Shield Strength dropped to 10K, assuming every Generator ads 5K.)
Maybe you have to experiment with the "Primary" setting.

Offline Bat66wat6

  • Posts: 144
  • Cookies: 34
  • Running custom BC 1.1
Re: BC 1.1 - Secondary shield generators
« Reply #2 on: September 14, 2011, 09:22:57 AM »
I had not thought of it in that way. When it was announced in the movie that there was a secondary shield generator I thought it implied the generator as a backup. Something that would only be active when the primary generator was knocked offline.

My severely limited knowledge of Python scripting and what goes on behind everything I see in the game only restricts me to turning the Primary of the hardpoints on and off, however this has no real ingame effect. Two primary generators can't exist at the same time, one cancels each other out so ingame there is still one useless generator.

Having both generators on at once is something i'd rather not do as then it would be a backup generator, it'd just all be one big generator but with two hardpoints to attack.
Great men are not peacemakers! Great men are conquerors!

Offline King Class Scout

  • Posts: 1775
  • Cookies: 893
  • the other half of SFRD
Re: BC 1.1 - Secondary shield generators
« Reply #3 on: September 14, 2011, 10:34:33 AM »
this question was asked concerning the Star Empire when I released it through SFRD (as the novel has the ship have Trinary shields). I believe the general consensus was that it couldn't be pulled off in the BC engine due to the engine's sheer age.
OS novel fan

Coming Soon: King's Mod Tuning Shop

best line I've ever read
Me: mine [my bridges] would probably be simple to get the characters to use.  the only person that sits is the captian.
Baz: space is vast there[sic] legs will be tired by the time they get to the next planet

Offline Bat66wat6

  • Posts: 144
  • Cookies: 34
  • Running custom BC 1.1
Re: BC 1.1 - Secondary shield generators
« Reply #4 on: September 14, 2011, 10:53:24 AM »
I have this knack for pursuing things that aren't possible in games  :banghead:
Are you absolutely sure? Is there no validity in KrrKs statement?

I'm not sure if toggling the "primary" setting is really necessary. I remember on of the DS9 Stations (not sure which one) had three Shield Generators.
When one of those was disabled, the Overall Shield- Strength simply dropped by that Generators Value. (I.E. Overall Shield Strengh was 15K, after one Generator disabled, Shield Strength dropped to 10K, assuming every Generator ads 5K.)
Maybe you have to experiment with the "Primary" setting.

How is it that you can create so many complex features and additions such as Kobayashi Maru, with fire through cloak, warp core ejections and all that crazy complex stuff (Galaxy Charts springs to mind) but can't have two shield generators?

 :cry:
Great men are not peacemakers! Great men are conquerors!

Offline Bones

  • Moderator
  • Posts: 3354
  • Cookies: 639
  • SPAAAAAAAAACE !!!
Re: BC 1.1 - Secondary shield generators
« Reply #5 on: September 14, 2011, 11:02:44 AM »
As far as I know, secondary shield generator will do nothing in BC, it will be just another shield gen property that won't be used in game althou you can still see it on the targets list and shoot it.

Offline Bat66wat6

  • Posts: 144
  • Cookies: 34
  • Running custom BC 1.1
Re: BC 1.1 - Secondary shield generators
« Reply #6 on: September 14, 2011, 11:26:36 AM »
Precisely. It's useless ingame unless there is some functionality behind it. Some kind of magical piece of Python code that looks at the Primary Genny and goes "okay it's broken and not working, let's turn on the second shield generator".

 :help: Cross my fingers a Python wizard walks through the door and says it's not another impossible idea of mine :help:
Great men are not peacemakers! Great men are conquerors!

Offline King Class Scout

  • Posts: 1775
  • Cookies: 893
  • the other half of SFRD
Re: BC 1.1 - Secondary shield generators
« Reply #7 on: September 14, 2011, 12:48:50 PM »
Quote
Cross my fingers a Python wizard walks through the door and says it's not another impossible idea of mine
i swear I heard somewhere that Python's a bit...obsolete as a programming language?
who knows. if Soverign or defiant (the KM guy) walks in...

quote from the responses on the SE's comments
Quote
unfortunately, the way BC handles hardpoints, the secondary shield generator won't kick in until the first generator is disabled, by the time that happens, it's probably too late to save the ship.

---Aces High
OS novel fan

Coming Soon: King's Mod Tuning Shop

best line I've ever read
Me: mine [my bridges] would probably be simple to get the characters to use.  the only person that sits is the captian.
Baz: space is vast there[sic] legs will be tired by the time they get to the next planet

Offline Bat66wat6

  • Posts: 144
  • Cookies: 34
  • Running custom BC 1.1
Re: BC 1.1 - Secondary shield generators
« Reply #8 on: September 14, 2011, 01:00:04 PM »
That last quote in your post doesn't bother me, that's exactly what I want to accomplish. Disable to Primary shield generator in battle and then the secondary shield generator kicks in until the Primary is repaired to a given %

From a Python noobs perspective, such as a feature seems very simple compared to other BC fan made creations that exist. :cry:
Great men are not peacemakers! Great men are conquerors!

Offline Mario

  • Senior Software Developer
  • Administrator
  • Posts: 2187
  • Cookies: 1706
  • Life is life
Re: BC 1.1 - Secondary shield generators
« Reply #9 on: September 14, 2011, 02:11:42 PM »
Should be possible with something like this and possibly some clever scripting
Code: [Select]
# some code logic which checks the state of primary shield then in an if statement
pPrimaryShield.SetPrimary(0)
pSecondaryShield.SetPrimary(1)
# some more code

However it really depends how will BC recognize and accept the changes or we need to reinit the hp and transfer damage values back to the reinitialized HP. I can't say what would happend as I've never tried it.
Acta, non verba.
aka USS Sovereign

Offline Bat66wat6

  • Posts: 144
  • Cookies: 34
  • Running custom BC 1.1
Re: BC 1.1 - Secondary shield generators
« Reply #10 on: September 14, 2011, 02:50:22 PM »
I am by all accounts a scripting noob however I think I see the difficulties you are touching on. If I am correct the HP file is can't be changed once the game has loaded it to create the ship so simply toggling the primary values on/off is something BC might not like?

Other things created such as the Breen drain weapon can disable all of a ships systems so.... There has to be some way this can be done. One shield on and one shield off. Seems extremely easy compared to other BC fan made creations, but yet again I don't know what the snake will and won't let you do.
Great men are not peacemakers! Great men are conquerors!

Offline Mario

  • Senior Software Developer
  • Administrator
  • Posts: 2187
  • Cookies: 1706
  • Life is life
Re: BC 1.1 - Secondary shield generators
« Reply #11 on: September 14, 2011, 03:27:55 PM »
Quote
Seems extremely easy compared to other BC fan made creations, but yet again I don't know what the snake will and won't let you do.

So did one of our early mods called Emergency System Repair and in the end it turned out to be a 1700 line monster.
Acta, non verba.
aka USS Sovereign

Offline Bat66wat6

  • Posts: 144
  • Cookies: 34
  • Running custom BC 1.1
Re: BC 1.1 - Secondary shield generators
« Reply #12 on: September 14, 2011, 03:38:30 PM »
I am just at the beginning of the programming trails and already know that it's easy to say something and another to do it in code but DAMN, 1700 lines!  :idk:

I hope what I am suggesting, if possible at all, doesn't even come close to that line count!
Great men are not peacemakers! Great men are conquerors!

Offline Defiant

  • Posts: 398
  • Cookies: 1105
    • BC: Kobayashi Maru
Re: BC 1.1 - Secondary shield generators
« Reply #13 on: September 15, 2011, 09:23:50 AM »
The script KrrKs is talking of was by me and is - of course - part of KM ;)

http://kobmaru.de/svn/trunk/scripts/Custom/QBautostart/ShieldGenerators.py

It should be easily adaptable for your wishes.

Offline Bat66wat6

  • Posts: 144
  • Cookies: 34
  • Running custom BC 1.1
Re: BC 1.1 - Secondary shield generators
« Reply #14 on: September 15, 2011, 03:22:47 PM »
Thank you for the script Defiant, much appreciated however...

I feel like such a hopeless noob. I look over the code and have no concrete idea of how it is supposed to work as it is let alone how I could adapt it to switch between primary and secondary shield generators pile both into one super strong shield.

The syntax is alien to me, the functions...I have no idea what some of them do. I go looking for them in App, Foundation and MissionLib only to find more and more imports in those scripts... >  :(

I have ran through the script over and over, some of the functions I understand but most of it... :idk: :banghead:

GetAllShieldGenerators(pShip)
  You set up some form of array (list) comprised of all the shield subsystems and their properties that don't are not Primary(1)

SetUpShip(pShip)
  Not sure why you do what I think you are doing here.
  "Make our 'real' shield generator undestroyable" ? Why, don't see how that even... ?
  I also have no idea why you are setting the disabled ( SetDisabledPercentage(0.0) ) and repair complexity ( SetRepairComplexity(0.0) ) values, aren't they already set in the /scripts/ships/hardpoints/*.py file ?

RedefineShieldGenerators(pShip, ShieldGenerators)
  I know only that in this function you are piling all of the non-disabled shield values into one super shield

Init
  I only know it stands for Initialization and gets the script in motion but beyond that ... ?

All other functions
  Are some form of Python event handler that gets the details of the sub-system, check if it's a shield generator on the players ship and check the count of shield generators on the players ship then call RedefineShieldGenerators if there is > 1. gennies

I say all of this because I want you to understand that I didn't simply download the script, glance at it and run straight here to cry about how it doesn't "do what I want". One of the worst things I think any programmer could endure is to try and help someone who doesn't understand the language.

I also want you to know that I don't like being spoon fed but I am also strongly against the notion of having to learn an entire language just to get a few features into one computer game.

I completely understand if you don't want to practically spoon-feed me everything or do all the work for me and post the script black-box style.
Great men are not peacemakers! Great men are conquerors!

Offline Defiant

  • Posts: 398
  • Cookies: 1105
    • BC: Kobayashi Maru
Re: BC 1.1 - Secondary shield generators
« Reply #15 on: September 15, 2011, 03:50:23 PM »
Note that you need at least 3 Generators:

1x Not Targetable and Primary:
This is the real shield generator BC will use. It can not be destroyed.
BC can only handle 1 Generator. So we need to work around it by changing its values.

2x Not Primary but Targetable.
These are the generators you will be able to shoot at. They provide the shield strength and reload rate, nothing else.

And this is how it works. The important part is in the function RedefineShieldGenerators().

First in line 48 we get how much generators we have in the variable NumTotalGenerators.

Next (Line 53) we do our calculation for every shield (left, right, aft, ...) and start with 0 for all values.
Code: [Select]
       for Shield in range(App.ShieldClass.NUM_SHIELDS):
                ShieldMax = 0
                ShieldReload = 0
                NumDisabledGenerators = 0
                ShieldPercentage = pShields.GetSingleShieldPercentage(Shield)

So in line for every shield we iterate over every Generator. If the generator is disabled we ignore it. If not we add the strength and reload to the total count.
Code: [Select]

                # for every shield generator
                for Generator in ShieldGenerators:
                        # don't use the disabled generators
                        if Generator.IsDisabled():
                                NumDisabledGenerators = NumDisabledGenerators + 1
                                continue
                        
                        # sum their values
                        ShieldMax = ShieldMax + Generator.GetMaxShields(Shield)
                        ShieldReload = ShieldReload + Generator.GetProperty().GetShieldChargePerSecond(Shield)

Finally the last lines (73) sets the new recharge rate and strength:
Code: [Select]
               pShields.GetProperty().SetMaxShields(Shield, ShieldMax)
                pShields.GetProperty().SetShieldChargePerSecond(Shield, ShieldReload)
                PercentageShieldGeneratorsWorking = 1 - NumDisabledGenerators / float(NumTotalGenerators)
                pShields.SetCurShields(Shield, ShieldMax * PercentageShieldGeneratorsWorking * ShieldPercentage)
So the new shield strength is the sum of all values from all working generators in the hp.

So all you have to do is changing the calculation in lines 73-76.

Offline Defiant

  • Posts: 398
  • Cookies: 1105
    • BC: Kobayashi Maru
Re: BC 1.1 - Secondary shield generators
« Reply #16 on: September 15, 2011, 04:01:08 PM »
...oh and

So did one of our early mods called Emergency System Repair and in the end it turned out to be a 1700 line monster.

Kobayashi Maru only exists because I wanted to play against AI ships in MP.

Offline Bat66wat6

  • Posts: 144
  • Cookies: 34
  • Running custom BC 1.1
Re: BC 1.1 - Secondary shield generators
« Reply #17 on: September 15, 2011, 04:08:54 PM »
Damn, I was editing my post and you read the original pre-edit then posted before I could finish.  :picardfacepalm:

Thank you for trying to explain how the script works and what it does. I have a better understanding now however a vague understanding of what it does and how it does it won't give a magical boost that takes me to changing the whole script round to switch between disabled and active generators (primary on - secondary off), (primary off, secondary on).

I genuinely hate my position. I don't want to be a leach.
Great men are not peacemakers! Great men are conquerors!

Offline King Class Scout

  • Posts: 1775
  • Cookies: 893
  • the other half of SFRD
Re: BC 1.1 - Secondary shield generators
« Reply #18 on: September 15, 2011, 07:37:43 PM »
gotta remember to keep this script in mind, as I'm retexturing the existing Star Empire, and might use this.
OS novel fan

Coming Soon: King's Mod Tuning Shop

best line I've ever read
Me: mine [my bridges] would probably be simple to get the characters to use.  the only person that sits is the captian.
Baz: space is vast there[sic] legs will be tired by the time they get to the next planet

Offline Bat66wat6

  • Posts: 144
  • Cookies: 34
  • Running custom BC 1.1
Re: BC 1.1 - Secondary shield generators
« Reply #19 on: September 16, 2011, 08:29:25 AM »
Easily adaptable to you maybe.

For me on the other hand changing the way your current script works to the way I want isn't easy.

In my implementation I want the two targetable generators to operate seperately only when the other is knocked out, meaning only one generator at a time. Say for example someone breaks through the top shield and disabled the primary generator. The primary would then go offline, the shields would drop (obviously) then the secondary would kick in and all of the shields would appear to be at full strength again (the secondary shield is half as tough as the primary though).

If the primary is repaired (no longer disabled) I want the secondary to drop and the primary (with all of the shield strength values it had when it went offline, for example the top shield is still red).

I've said what I want in English now putting it into Python code is all I have to do.... :coffee:

EDIT:
Just some noob questions. I am unsure as to the context and scope of how the scripts in QBautostart are executed.

Does the ShieldGenerators.py script in the QBautostart folder apply to all ships?
By this I mean it it executed for every ship that is loaded in QB? Say a battle with 10 ships means it is executed 10 times?

I want this script, for now, only to apply to the Scimitar since it is the only ship in my version of BC that has two shield generators. It would be pointless to have it execute and try to work on every other ship as well.

Additionally, I am assuming that the script is continuously executed in order to work (keep swapping values round when shields are disabled/enabled) right?

Thanks
Great men are not peacemakers! Great men are conquerors!