!Move.Jump Jumpdrive check editing/Change autojump on all ships in universe

The place to discuss scripting and game modifications for X³: Reunion.

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

Post Reply
irR4tiOn4L
Posts: 663
Joined: Wed, 19. Oct 05, 14:07
x3tc

!Move.Jump Jumpdrive check editing/Change autojump on all ships in universe

Post by irR4tiOn4L » Tue, 19. Jul 11, 08:59

Hi everyone, yet another question but first a bit of background.

In my heavily modified game i have modded the Tships and Warelists files to solve a problem id posted about a long time ago - the pain in the behind of buying 20-30 different upgrades for all ships. Basically, ive given most classes their own warelists entry and made most wares built in (with some allowance for ship price/features, eg M3 is better equipped by default than M4, and S/M cargo restrictions)

One of the things I did was to make jumpdrives inbuilt, but this broke autojumping and jumping by the AI in general. I have since narrowed the problem down to this check in the !Move.Jump default script;

Code: Select all

skip if [THIS]->get true amount of ware {Jumpdrive 3983} in cargo bay
  return {FLRET_ERROR} 

Code: Select all

if [THIS]->is docked
  = [THIS]->call script '!move.undock' :
end
 
skip if [THIS]->get true amount of ware {Jumpdrive 3983} in cargo bay
  return {FLRET_ERROR}
 
$sector = $target 
skip if $target->is of class {Sector 2001}
  $sector = $target->get sector
 
$energy = [THIS]->needed jump drive energy for jump to sector $sector
$nume = [THIS]->get true amount of ware {Energy Cells 2013} in cargo bay
skip if $nume >= $energy 
  return {FLRET_ERROR}
 
* big ships take longer to jump than fighter escorts. So the escorts fly back
* by having the big ship jump before tellings escorts to jump we avoid that
skip if not [THIS]->is of class {Big Ship 2073}
  $r = [THIS]->use jump drive: target=$target
 
if $withfollowers 
  $afollowers = [THIS]->get formation follower ships
  if $afollowers 
    $s = size of array $afollowers
    while $s > 0 
      dec $s =
      $ship = $afollowers[$s]
      $docked = $ship->get environment
      if $docked != [THIS] 
        * 12Jan09: only ships that are not docked at leader undock for jump
        $ship->interrupt with script '!ship.signal.leaderjumps' and prio 20: arg1=[THIS] arg2=$target arg3=$withfollowers arg4=null
      end
    end
  end
end
 
* big ships should already have jumped
skip if [THIS]->is of class {Big Ship 2073}
  $r = [THIS]->use jump drive: target=$target
 
return $r
By removing the highlighted code, I have been able to get ANY ship with ecells to jump and autojump, even ones without jumpdrives, so i know this code is not recognising inbuilt jumpdrives as 'truly' present in the cargo hold.


My first question is - what would be an appropriate check to put in its place so it looks for jumpdrive ware, but does not require it to be 'truly' present in the cargo hold or be an installed, rather than inbuilt, extension?

My second question follows on from this - since most trade ships now have inbuilt jumpdrives, I would like to edit ALL AI ship settings, universe wide, to turn on autojump - ie, to edit their autojump settings. However, editing the Jobs file does not allow this option and im wondering if anyone knows a way to do this.

The last question is more difficult but flows from above - if the above two tasks were achieved, is there any EASY way to get ships with a jumpdrive to refuel their ecell supply when it drops below a certain level, or every so often? (Maybe the 'refuel jump' quantity in autojump settings, so that if they land in a station with ecells they automatically refuel?)


Thanks for all comments and help!

User avatar
Moonrat
Posts: 1353
Joined: Sun, 20. Apr 08, 16:20
x4

Post by Moonrat » Tue, 19. Jul 11, 09:13

I have a question for you, seeing as you've obviously got way further into this than me :).
Where does it define the E-cell factor for jumps, ie. is it it possible in one or two places to alter this to a higher/lower value?

irR4tiOn4L
Posts: 663
Joined: Wed, 19. Oct 05, 14:07
x3tc

Post by irR4tiOn4L » Tue, 19. Jul 11, 09:33

Moonrat wrote:I have a question for you, seeing as you've obviously got way further into this than me :).
Where does it define the E-cell factor for jumps, ie. is it it possible in one or two places to alter this to a higher/lower value?
Do you mean how many ecells it takes TO jump or have many jumps worth of ecells autojump allows you to tell a ship to restock?

Im not really all that familiar with these scripts, actually, ive never edited scripts for this game or looked at them until today. However, i would investigate how these commands work;

Code: Select all

$energy = [THIS]->needed jump drive energy for jump to sector $sector
$nume = [THIS]->get true amount of ware {Energy Cells 2013} in cargo bay
skip if $nume >= $energy 
  return {FLRET_ERROR}
 
* big ships take longer to jump than fighter escorts. So the escorts fly back
* by having the big ship jump before tellings escorts to jump we avoid that
skip if not [THIS]->is of class {Big Ship 2073}
  $r = [THIS]->use jump drive: target=$target
Whether its autojump or the jumpdrive energy requirements that you are trying to change, i dont think its in this script. Ill keep an eye out as im editing and let you know if i find anything, but Gazz and others would be far better sources

User avatar
Moonrat
Posts: 1353
Joined: Sun, 20. Apr 08, 16:20
x4

Post by Moonrat » Tue, 19. Jul 11, 09:38

Thanks. It's the "how many ecells it takes TO jump" factor I'm interested in. Is there a universal constant anywhere defined or used de facto inside the coding (and if so which file / script is it in).

irR4tiOn4L
Posts: 663
Joined: Wed, 19. Oct 05, 14:07
x3tc

Post by irR4tiOn4L » Tue, 19. Jul 11, 09:49

Moonrat wrote:Thanks. It's the "how many ecells it takes TO jump" factor I'm interested in. Is there a universal constant anywhere defined or used de facto inside the coding (and if so which file / script is it in).
I think there should be, ill have a look for you right now.

For all visitors - QUESTION 1 SOLVED. All I did (easiest edit ever) was drop the 'true' phrase - it used to read;

Code: Select all

skip if [THIS]->get true amount of ware {Jumpdrive 3983} in cargo bay
  return {FLRET_ERROR}
- it now reads;

Code: Select all

skip if [THIS]->get amount of ware {Jumpdrive 3983} in cargo bay
  return {FLRET_ERROR}
Thats right - ONE word was changed!

I would appreciate if experienced scripters looked over this change and alerted me to any problems with this edit, though i dont suppose there will be any.

Also, why did Egosoft check for 'true' (ie, NOT inbuilt) jumpdrives anyway? I think my version is more versatile and flexible, and should have been the code to begin with - though i dont suppose Egosoft will change the jumpcode just to please someone like me and make the vanilla game more compatible with inbuilt jumpdrives.


EDIT: All the scripts ive had a look at seem to use a command called

Code: Select all

needed jump drive energy for jump to sector
They seem to use it just like 'get amount of ware' and so on, not link back to another script or variable.

Again, im no expert, but it looks like there hardcoded code for working this out. Maybe there is a variable in some file out or some piece of the code, but i cant find it

Sorry

irR4tiOn4L
Posts: 663
Joined: Wed, 19. Oct 05, 14:07
x3tc

Post by irR4tiOn4L » Tue, 19. Jul 11, 10:22

A little google search confirms that it seems to be (or was in X3, and i doubt its changed) hardcoded.

However, Azz in this thread (look near the bottom) seems to suggest that the command could be bypassed by modifying the jumping scripts to essentially produce a jumpdrive which doesnt use energy
http://after-domination.net/xfpboards/v ... 70684a4ed6

However, many scripts would be affected and you would need to edit them to not rely on 'needed jump drive energy for jump to sector'.

So no easy way, but you could work around it

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Tue, 19. Jul 11, 12:14

irR4tiOn4L wrote:My second question follows on from this - since most trade ships now have inbuilt jumpdrives, I would like to edit ALL AI ship settings, universe wide, to turn on autojump - ie, to edit their autojump settings. However, editing the Jobs file does not allow this option and im wondering if anyone knows a way to do this.
You're already editing !move.jump, no?
What's the problem with putting the check/setting in there?
Ships (especially traders) move somewhere rather often so it's pretty likely they will come across it.

Use some ALP or whatever to write the desired setting to a global var and the ships will fetch it when needed.


irR4tiOn4L wrote:Also, why did Egosoft check for 'true' (ie, NOT inbuilt) jumpdrives anyway? I think my version is more versatile and flexible, and should have been the code to begin with - though i dont suppose Egosoft will change the jumpcode just to please someone like me and make the vanilla game more compatible with inbuilt jumpdrives.
The TRUE check ignores anything that is flagged as "ship hardware".
That's it's purpose.

Why was this specialty function it used? Simple mistake is my best guess.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

irR4tiOn4L
Posts: 663
Joined: Wed, 19. Oct 05, 14:07
x3tc

Post by irR4tiOn4L » Tue, 19. Jul 11, 12:21

Gazz wrote:
irR4tiOn4L wrote:My second question follows on from this - since most trade ships now have inbuilt jumpdrives, I would like to edit ALL AI ship settings, universe wide, to turn on autojump - ie, to edit their autojump settings. However, editing the Jobs file does not allow this option and im wondering if anyone knows a way to do this.
You're already editing !move.jump, no?
What's the problem with putting the check/setting in there?
Ships (especially traders) move somewhere rather often so it's pretty likely they will come across it.

Use some ALP or whatever to write the desired setting to a global var and the ships will fetch it when needed.
Wait - is !Move.Jump activated even by ships with autojump turned off? I thought this was only activated when a ship tries to actually jump, because autojump told it to
Gazz wrote:The TRUE check ignores anything that is flagged as "ship hardware".
That's it's purpose.

Why was this specialty function it used? Simple mistake is my best guess.
Does look that way. I wonder if Egosoft could fix this in a patch. Right now, the only way to override this file is to create your own !Move.Jump.xml in a cat/dat or pasted into scripts AND to delete the original. Not exactly intuitive installation

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Tue, 19. Jul 11, 12:30

irR4tiOn4L wrote:Wait - is !Move.Jump activated even by ships with autojump turned off? I thought this was only activated when a ship tries to actually jump, because autojump told it to
I didn't look up which script is calling which but at some point there is a call for !move.jump if/when the ship is supposed to jump or possibly the call returns immediatelyif the ship HAS no JD installed, in which case it hooves it.

You could also tie something like that into !move.undock because just about every script calls that before doing anything - just in case.



Does look that way. I wonder if Egosoft could fix this in a patch. Right now, the only way to override this file is to create your own !Move.Jump.xml in a cat/dat or pasted into scripts AND to delete the original. Not exactly intuitive installation
I wouldn't hold my breath for an official patch to fix a non-issue that your personal script has. =P
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 24961
Joined: Sun, 2. Apr 06, 16:38
x4

Post by X2-Illuminatus » Tue, 19. Jul 11, 13:51

irR4tiOn4L wrote:Right now, the only way to override this file is to create your own !Move.Jump.xml in a cat/dat or pasted into scripts AND to delete the original. Not exactly intuitive installation
Or you simply put your !Move.Jump.xml in a pck-archive, which would overwrite the current one in the scripts-folder (at least, if the user allows it).
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!

LowkeeDragon33
Posts: 68
Joined: Sun, 29. May 11, 17:27

Post by LowkeeDragon33 » Tue, 19. Jul 11, 14:55

Is there a streamlined way to say, make every ES script editable in SE. The !Move.Jump. script, which I believe is a pck already, is off limits to me. I have to open it with NSIS, and change some things around to get it editable in-game.

My Disco Raider, with built in FCS 1&2, will automatically initiate the attack scripts when attacked. Makes me think EgoSoft just assumed that there would be no built in jump drives when doing the check.

As for altering the amount of EC needed, not hardcoded too hard.

Code: Select all

$energy = [THIS]->needed jump drive energy for jump to sector $sector
$nume = [THIS]->get true amount of ware {Energy Cells 2013} in cargo bay
$nume = $nume / 2
skip if $nume >= $energy
  return {FLRET_ERROR}
Then simply remove the ECs that the jump didn't really use. This would double the amount need to jump, which is what you wanted, right? :) Of course, you have issues with cargo space...

For refueling, I think you could look here:

Code: Select all

skip if $nume >= $energy
  return {FLRET_ERROR}
Rather than to return an error, the ship runs a "find ssp" script. The complications of this, AFAIK, would be to find a station that uses most of the EC available and returns a station that is along the route to the destination.

Now, my scripting is pretty, brute; I am not aware of many things. I also don't know what is simple. In most cases, the less complex, the less precise. What if the ship has no EC at all, or there are no SSP within range?

I would find the Number Values of the current and target sector. Then you need the Jump Range of the ship, and convert this to a sector number that is between the current and target sectors. At this point, you have choices of how complicated you want to be. You could do some looping, counting from the max jump range to your current sector, looking for a SSP. You could also say something like (these are things the script is doing, not a ship) "Find the furthest jump sector, move 2 sectors (via number system) closer to the current sector, search for the closest ssp within 2 sectors of that sector".

The first option could always get you the best station, the second option is far simpler. Complications ensue, like if the sectors don't exist...

irR4tiOn4L
Posts: 663
Joined: Wed, 19. Oct 05, 14:07
x3tc

Post by irR4tiOn4L » Tue, 19. Jul 11, 16:06

Gazz wrote: You could also tie something like that into !move.undock because just about every script calls that before doing anything - just in case.
Thats an excellent idea! Thanks for that one
Gazz wrote:I wouldn't hold my breath for an official patch to fix a non-issue that your personal script has. =P
No, im certainly not. Especially as ive found WHY they checked for 'true' number in cargo bay - in my testing ive found that now the INSTALLED jumpdrives dont work! LOL

I guess ill have to change the check again! Whoops!

EDIT: No I wont, im just stupid
X2-Illuminatus wrote:
irR4tiOn4L wrote:Right now, the only way to override this file is to create your own !Move.Jump.xml in a cat/dat or pasted into scripts AND to delete the original. Not exactly intuitive installation
Or you simply put your !Move.Jump.xml in a pck-archive, which would overwrite the current one in the scripts-folder (at least, if the user allows it).
For the life of me i could not get a program to create a .pck file! I messed around with pwpack for a good half hour. For a lot of that it just kept creating 1kb files, and when it finally did make a proper sized file, it wasnt readable by winrar (which the game's pck files are). I just gave up and deleted the original
Last edited by irR4tiOn4L on Tue, 19. Jul 11, 16:30, edited 1 time in total.

irR4tiOn4L
Posts: 663
Joined: Wed, 19. Oct 05, 14:07
x3tc

Post by irR4tiOn4L » Tue, 19. Jul 11, 16:27

EDIT: Ok never mind, im an IDIOT

I forgot that the script was included in a cat/dat, not pasted in, and by disabling that cat dat while testing it obviously prevented ships jumping

STUPID ME

User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 24961
Joined: Sun, 2. Apr 06, 16:38
x4

Post by X2-Illuminatus » Tue, 19. Jul 11, 16:56

For the life of me i could not get a program to create a .pck file!
Modmanager or X3 Editor 2 by doubleshadow. Add the xml file to a cat/dat and extract it afterwards without decompressing it.
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!

irR4tiOn4L
Posts: 663
Joined: Wed, 19. Oct 05, 14:07
x3tc

Post by irR4tiOn4L » Wed, 20. Jul 11, 07:10

X2-Illuminatus wrote:
For the life of me i could not get a program to create a .pck file!
Modmanager or X3 Editor 2 by doubleshadow. Add the xml file to a cat/dat and extract it afterwards without decompressing it.
I didnt realise it could do that!

I use X3 Editor 2 to decompress pck files, and it obviously repacks them when you put something in a cat/dat, but i never managed to get it to extract them without decompressing.

Silly me!

Post Reply

Return to “X³: Reunion - Scripts and Modding”