many script instances slow down SETA (spaceflies, Anarkis/Pirate Guild)

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

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

User avatar
Aldebaran_Prime
Posts: 1386
Joined: Sat, 20. Feb 10, 17:47
x4

Post by Aldebaran_Prime » Sat, 23. Jun 18, 00:52

SirNukes wrote:...
In short, the fundamental problem is either bad documentation or bad behavior of the "create ship" command (depending on which angle you look at it). When a spacefly is requested, the script engine redirects from Create to CreateSwarm, so a whole flock of spaceflies are created and their scripts started. The documentation doesn't mention this, and modders do not expect this behavior.


... They destroy the single spacefly they meant to create, but not the unexpected extra swarm.


....
Very good, that you find a potential reason for the mess of spaceflys!
But maybe you can give us more details of the scripts and places of problematic code in this scripts/mods?
It sounds like, that the spaceflys are created as helper beacons in these cases - so alternatively to modify the create ship behavior in general, it may be another approach to modify the problematic code in these mods...

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Post by SirNukes » Sat, 23. Jun 18, 12:13

Improved Races appears to have its main problem in xtl.lib.ship.choose.xml around line 49, though there are a couple other places it creates ships in the null sector that I didn't look at closely.

Grepping around also found some seemingly problematic code in the MARS setup.plugin.gz.missile.def.mk2.xml file, though that script appears to deactivate itself in AP (even though it is packaged with a version of Mars that works with AP).

I must apologize for thinking XRM was to blame for my second spacefly swarm; after applying some better care, it is actually Salvage Command Software that is the problem. Looking through the code, I can see potential spots where the bug might be cropping up, but there is no obvious 'loop over tships' code like in the above two mods. At any rate, SCS causes a hiccup shortly after loading a save that will pop out a swarm.


As for the style of the fix, my own preference is a clever catch-all solution. Finding and editing every script with this problem feels clumsy, both in carrying it out and sharing the edits. My gut feeling is that no one has ever used "create ship" to purposefully make a spacefly swarm, given the lack of of documentation of this behavior and lack of general interest in spacefly mods.

User avatar
Aldebaran_Prime
Posts: 1386
Joined: Sat, 20. Feb 10, 17:47
x4

Post by Aldebaran_Prime » Sat, 23. Jun 18, 23:26

Thank you! Yes, I found this:

Code: Select all

...
$WareSubType = get number of subtypes of maintype 7
while $WareSubType
dec $WareSubType
$cShipWare = get ware from maintype 7 and subtype $WareSubType
gosub CheckType:
if $EvalRet == [FALSE]
continue
end

$SpawnedShip = create ship: type=$cShipWare owner=[Unbekannt] addto=null x=0 y=0 z=0
...
I can see, that also spaceflys will created in sector NULL in this case and I believe you, that not only a singel Spacefly, but a swarm will be created, but not deleted afterwards.

additionally to patch the create ship command in the Egosoft obj-files, an other approach can be, in this special case, to correct the code of this IR2.0 script not to to create a spacefly in this loop. (I'm really impressed maximal, what knowlege you have! I will try your X3 Customizer, too)

I found, that the subroutine "CheckType:", which is called before the create ship statement, checks for several shiptypes and then not creates a ship in sector NULL:

Code: Select all

CheckType:
$EvalRet = [FALSE]
$eval = $cShipWare
if $eval == {Argonen Truelight Seeker}
endsub
else if $eval == {Terraner #deca.deaf}
endsub
else if $eval == {Terraner #deca.cefa}
endsub
I just would add a

Code: Select all

else if $eval == {Unbekannt Raumfliegen}
endsub
there and the problem is fixed, too.

- or do I think wrong?

If I'm right, we may post this research in the thread of IR2.0, too, to prevent other players to run into this problem.

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Post by SirNukes » Sun, 24. Jun 18, 01:19

I agree, your fix would slot very nicely into that IR code.

There is another case of creating/destroying ships in xtl.xtlc.comm.order.checkout.xml, but it looks like that might only ever handle ships the player can order from a shipyard, so I'm thinking that won't ever make spaceflies.

Salvage Command Software took a while to track down the culprit, but it looks like it is in scs.library.xml around line 2618. (Annoyingly, grepWin wasn't finding this with "create.*ship.*addto.*null", even though notepad++ matches just fine. I ended up finding it by just reading through the code starting from setup.)

Side note: early on I looked into Zanzal's Ship Browser, since I knew that looped over ships and made them to record information. The interesting code is in plugin.zanzal.shipbrowser.menu.xml around line 422. That mod has no spacefly problem because it will pull the class of the ship subtype and compare it to the desired class (eg. M4) before creating it. Spaceflies have their own special class, and so are always skipped.

SCS, on the other hand, appears to think the ship has to be made first to be able to check its class, and so ends up making everything, spaceflies included. It does do some name checks for filtering out unwanted ships, so spaceflies could be added there. Though, now that I look at it, that name check (eg. "$tmp = find position of pattern 'Beacon' in $shp") wouldn't work on non-English versions, would it?

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22225
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Sun, 24. Jun 18, 16:16

SirNukes wrote: SCS, on the other hand, appears to think the ship has to be made first to be able to check its class, and so ends up making everything, spaceflies included. It does do some name checks for filtering out unwanted ships, so spaceflies could be added there. Though, now that I look at it, that name check (eg. "$tmp = find position of pattern 'Beacon' in $shp") wouldn't work on non-English versions, would it?
my guess on this is that SCS is an older script, and was probably made before the command to check a types class was added.

alot of older scripts suffer from problems like this where they have to use hacks or workarounds due to the available commands not doing the job.

The cheats scripts is full of them as it was made before alot of the commands in TC were added (was made well before the release of TC).

the create ship command does have special handling of spaceflies where a swarm is automatically created, but only the "leader" is returned. And as there is no way to get spaceflies then the script cant destruct them

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Post by SirNukes » Sun, 24. Jun 18, 19:36

Cycrow wrote:my guess on this is that SCS is an older script, and was probably made before the command to check a types class was added.
Ah, thanks for pointing that out. My apologies for throwing some shade on these older scripts.

User avatar
N8M4R3
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 398
Joined: Fri, 24. Nov 06, 15:48
x4

Post by N8M4R3 » Sun, 24. Jun 18, 20:47

Hello Guys,

unfortunately, I can not contribute to the help from too little experience, but I am very happy to see and follow with the fact that here known and experienced people deal with the problem! :thumb_up: :thumb_up: :thumb_up: :)
Neue Erweiterung für X3 verfügbar: Farnham's Legacy | +Optional: weitere Verbesserungen im inoffiziellen Patch v1.3.14 *** Modified*** :khaak: :thumb_up:
Diese Woche im Angebot: HUD-GUI-Mix (FL) | Text-DB 0001-L049 (FL) | Textkorrekturen & Verbesserungen (FL)
Weitere Veröffentlichungen hier: N8workX
Nützliches Tool für nicht mehr vorhandene Downloads: web.archive.org
Externes Archiv für MOD/SCR Ressourcen: xdownloads.co.uk | code.google.com/archive/p/x3tcscripts/

User avatar
The Captain
Posts: 169
Joined: Tue, 7. Sep 10, 18:18

Re: many script instances slow down SETA (spaceflies, Anarkis/Pirate Guild)

Post by The Captain » Thu, 28. Oct 21, 04:07

I seem to have run into a similar issue as described in the first post in this thread, but I couldn't for the life of me follow what steps were taken to remedy the issue in the replies that were posted afterwards.

I did notice that one script I am running seems to have way higher numbers than all of the others (Pirate Guild), and it was soon after installing that script that I started to notice the slowdown. I've also noticed that if I engage SETA, it will run as expected for a random amount of seconds, then slow right back to what looks like normal operation until I cancel it. I can start it again immediately and it will speed up again, but continually tapping the j key is a little tedious.

Is there a fix for this?

Post Reply

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