Checking generator stats

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Checking generator stats

Post by EmperorJon »

Any way to check the laser and shield generator stats of a ship?

Or, failing that, to extract them from a file somewhere?

Eg, reading them from a tfile that exists and using the value?

Basically I need ot be able to get the Laser and shield generation value of every ship in the game as a variable (not at the same time :wink: )

This is in order to link generators, as suggested here: http://forum.egosoft.com/viewtopic.php?t=273550
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
Sam L.R. Griffiths
Posts: 10522
Joined: Fri, 12. Mar 04, 19:47
x4

Post by Sam L.R. Griffiths »

Here is my first stab at the main script

Code: Select all

001   if [DOCKEDAT] == null
002   |[THIS] -> set local variable: name='pwrlink.active' value=[FALSE]
003   else
004   |$carrier1 = [DOCKEDAT] -> get current shield strength
005   |while [THIS] -> get local variable: name='pwrlink.active'
006 @ ||= wait 1000 ms
007   ||if [DOCKEDAT] == null
008   |||[THIS] -> set local variable: name='pwrlink.active' value=[FALSE]
009   ||else
010   |||$carrier2 = [DOCKEDAT] -> get current shield strength
011   |||$shield = [THIS] -> get shield percent
012   |||if $shield >= 50
013   ||||$dmg = ( $carrier1 - $carrier2 ) / 100
014   ||||$dmg =  get maximum, $dmg, 0, null, null, null
015   ||||$ship = [THIS] -> get current shield strength
016   ||||$ship = $ship - $dmg
017   ||||$ship =  get maximum, $ship, 0, null, null, null
018   ||||[THIS] -> set current shield strength to $ship
019   ||||$shield = [THIS] -> get shield percent
020   ||||if $shield >= 50
021   |||||$regen = [THIS] -> get power generator 
022   |||||$laser = [DOCKEDAT] -> get current laser strength
023   |||||$max = [DOCKEDAT] -> get maximum laser strength
024   |||||$laser = $laser + ( $regen / 2 )
025   |||||$laser =  get maximum, $laser, $max, null, null, null
026   |||||[THIS] -> set laser energy to $laser
027   ||||end
028   |||end
029   |||$carrier1 = $carrier2
030   ||end
031   |end
032   end
033   return null
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
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

I'm confused now! :lol:

So you have Get Power Generator?

Is that for laser or shield?
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
LV
Sith Lord
Posts: 8255
Joined: Wed, 6. Nov 02, 20:31
x3tc

Post by LV »

p gen is recharge of shields time, poss laser also

the value will probably be held in tships, it is possible (but long and cpu intensive) to scan through allships in the game using maincodes and subtypes

Code: Select all

006   $main = 8
007   $subs =  get number of subtypes of maintype $main
009   
010   
011   while $subs > 0
012   |dec $subs = 
013   |$ware =  get ware from maintype $main and subtype $subs
018   end
the 2 commands are in the trade menu and this one is retuning lasers, check the tutorial stickie for a list of the other maintypes


there is probably also an easier way but i've not long been awake ;)
LV's TC Scripts
Readme's For All My Scripts


I felt a great disturbance in the forum, Like millions of voices cried out in terror, then were silenced

si tacuisses, philosophus mansisses
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Couldn't you just get the main and sub type of the ship you wanted and then run it?

Either

1. I'm being stupid

2. LV really is not at all awake
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
Sam L.R. Griffiths
Posts: 10522
Joined: Fri, 12. Mar 04, 19:47
x4

Post by Sam L.R. Griffiths »

EmperorJon wrote:I'm confused now! :lol:

So you have Get Power Generator?

Is that for laser or shield?
In the Script Editor, Get Power Generator is under weapon information thus I presume it is for the "Weapon Regen" if not then it's location is notionally a bug.

EDIT: Just done a debug test and it is the SHIELD power generator, so it's location is a bug.
Last edited by Sam L.R. Griffiths on Sun, 21. Mar 10, 12:08, edited 1 time in total.
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
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

That would make sense... yes...

Why is why you've done all the crazy calculations for the Shields I presume...


I didn't read through it myslef. I have trouble understanding TC scripting unless I wrote it. :oops:
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
Sam L.R. Griffiths
Posts: 10522
Joined: Fri, 12. Mar 04, 19:47
x4

Post by Sam L.R. Griffiths »

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
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Nice!

I was going to make this, but you're doing it for me.

:wink:

As long as I can use it in my Military plugin, that's fine. (Might be fine-tuned and changed though)

(I'm also going to include weapons, sheilds and speed transferrals. So, lose all your weapon energy but boost out of combat, but down your speed but recharge shields quickly etc.)
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
Sam L.R. Griffiths
Posts: 10522
Joined: Fri, 12. Mar 04, 19:47
x4

Post by Sam L.R. Griffiths »

EmperorJon wrote:Nice!

I was going to make this, but you're doing it for me.

:wink:

As long as I can use it in my Military plugin, that's fine. (Might be fine-tuned and changed though)
Well feel free... just include me as a tiny footnote in the credits and we are even ;)

EDIT 01-Apr-2010
And no this is not an April Fool :P

Although, I have authorised EmperorJon to include an implementation of the concept discussed here I would like to point towards my own implementation of it: Carrier Power Link System (CPLS).
Last edited by Sam L.R. Griffiths on Thu, 1. Apr 10, 10:48, edited 1 time in total.
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
User avatar
LV
Sith Lord
Posts: 8255
Joined: Wed, 6. Nov 02, 20:31
x3tc

Post by LV »

One problem i saw while skimming.

you should call this script (which appears ok in code) as a task.

otherwise it may sit dead in space while it's held in a loop.


get next available task then start task etc etc

as long as you don't start telling the ship to do things via this task script in will run at the same time as any ship command e.g. fight.attack.obj
LV's TC Scripts
Readme's For All My Scripts


I felt a great disturbance in the forum, Like millions of voices cried out in terror, then were silenced

si tacuisses, philosophus mansisses
User avatar
Sam L.R. Griffiths
Posts: 10522
Joined: Fri, 12. Mar 04, 19:47
x4

Post by Sam L.R. Griffiths »

LV wrote:One problem i saw while skimming.

you should call this script (which appears ok in code) as a task.

otherwise it may sit dead in space while it's held in a loop.


get next available task then start task etc etc

as long as you don't start telling the ship to do things via this task script in will run at the same time as any ship command e.g. fight.attack.obj
The intent in my script was that it would be the only command running on the fighter while it is docked and the fighter would cease to supply power if it undocks or is given another command and my initial testing proves it works as I intended.
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
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Yes, but that might not work as intended, because fighter set to protect carrier etc. will redock after the fight and not lend recharge. Ships set to follow the carrier won't, ships accidentally set to idle or standby won't...

I'm working on somethin new now anyway. Capital ship explosions upon death. :P
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
Sam L.R. Griffiths
Posts: 10522
Joined: Fri, 12. Mar 04, 19:47
x4

Post by Sam L.R. Griffiths »

EmperorJon wrote:Yes, but that might not work as intended, because fighter set to protect carrier etc. will redock after the fight and not lend recharge. Ships set to follow the carrier won't, ships accidentally set to idle or standby won't...
Perhaps, personally I would consider it a balancing feature, I was considering the recharge a role for the fighter rather than a carte-blanche bonus to the carrier while it is docked. If you retask the fighter to external detail then it returns, you would naturally have to reconnect all the cables for the power generator. I had been toying with something along the lines of it running in the background but I had concerns about the load on the processor.

But this is all down to design decision/intent at the end of the day and will come out in the wash. :wink:
EmperorJon wrote:I'm working on somethin new now anyway. Capital ship explosions upon death. :P
Kewl, but I already thought there were explosions on Capital ship death... or are you talking about something a little different?
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
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

reconnect all the cables for the power generator
Point taken. :lol:
but I already thought there were explosions on Capital ship death... or are you talking about something a little different?
I mean, actual, explosions. That like... kill you. :D
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
Sam L.R. Griffiths
Posts: 10522
Joined: Fri, 12. Mar 04, 19:47
x4

Post by Sam L.R. Griffiths »

EmperorJon wrote:
but I already thought there were explosions on Capital ship death... or are you talking about something a little different?
I mean, actual, explosions. That like... kill you. :D
Ahhh... collateral damage... nasty :twisted:
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
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Epic collateral damage.

As in, 1000000.

That'll wipe out any fighter, but at the same time, means M1 combat is useless... The fighters...
That's the problem. It's balanced (fighters shouldn't be able to stand an M2 next to them going 'nova) but at the same time... makes them useless.

So, I'll reduce it with range. That's it!

Right next to the M2- Dead
1 km away- Slight shaking. :lol:


One thing that will be funny, a capital ship combat ending almost neck and neck, will now be neck and neck. You kill your enemy and they'll kill you. :lol:
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”