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

|K.O.S.H.
Posts: 3724
Joined: Fri, 19. Dec 03, 10:36
x3tc

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

Post by |K.O.S.H. » Mon, 5. Feb 18, 07:33

Hi,

i've allready started a topic in the german forum without success.
There three scripts running on many instances and i can't stop them:

!ship.cmd.follow.spacefly: ~6500 instances
!ship.cmd.idle.spacefly: 551 instances
anarkis.pirate.sig.pb.attacked: ~1200 instances (that one comes from the pirate guild - plugin (maybe an old version))

Those scripts are subject to slow down my seta (only works 2x)


I focussed on the spacefly scripts and tried to stop them via:
- return null -> does not work, because the are cached
- find spaceflies via "find ship" with shipttype (from main and subtype) -> no spaceflies found, even if tehre were some in my sector
- find spaceflies via "find ship" with object class -> no spaceflies found, even if tehre were some in my sector
- changed object class, types and objectid!! in tships to target them via scripteditor
- kill everything manually via modded weapon, that clears a sector
- kill all ships, stations, asteroids, debries, planets, nebulas via script

It seems like these scripts run on something else, than a spacefly. All spaceflies - even in the unfocused sectors - get destroyed, when my ship leaves the sector.

The anarkis script also remains, after all ships and stations are destroyed via script.

On which objects can they run at?
I think they may have been startet in the mission director, but i have no experience with it.


My savegame is ten years old, i really want to keep it. But without seta it gets complicated...

Can somebody help me please?
Wing Commander Mod - German Topic
06.07.11 - v1.1 RELEASED!

|K.O.S.H.
Posts: 3724
Joined: Fri, 19. Dec 03, 10:36
x3tc

Post by |K.O.S.H. » Tue, 6. Feb 18, 18:12

no ideas? :(
Wing Commander Mod - German Topic
06.07.11 - v1.1 RELEASED!

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

Post by X2-Illuminatus » Wed, 7. Feb 18, 18:08

It wouldn't surprise me if you cannot find Spaceflies with the Script Editor, as in the vanilla game they are created and treated differently to other ships. There are also other ingame objects (like suns) which the Script Editor cannot find. You may have more luck with the Mission Director's find ship/object commands, but that is pure speculation from my side.
|K.O.S.H. wrote:All spaceflies - even in the unfocused sectors - get destroyed, when my ship leaves the sector.
Everything is destroyed in the Unfocussed Jumpdrive sector, when you leave it. So this alone isn't special. What you could test is what happens when you create spaceflies OOS (i.e. in a sector you're currently not in, except for the UFJD sector). Do they persist or are they destroyed immediately? If they persist, then what happens when you enter and leave the sector they were created in shortly afterwards? If leaving the sector destroys them, writing a script which jumps your ship to every possible sector and waits a short while, before jumping to the next, might be a viable solution to get rid of the spaceflies.
What could prove difficult is when the spaceflies were created in sector null. Some scripts use this area to create objects in a safe place, before they are used later, or to read their properties upfront for which you need the actual object. If, for example, a script was looping through all TShips entries and forgot to clean up afterwards, this may explain why there are Spaceflies you cannot find in the normal universe.
|K.O.S.H. wrote:It seems like these scripts run on something else, than a spacefly.
In theory it could be another ship. But then again, you mentioned you destroyed all of them already. Considering that the spacefly scripts use ship specific commands I doubt that they would even run on something else than a ship without throwing errors or even causing a game freeze.
|K.O.S.H. wrote:The anarkis script also remains, after all ships and stations are destroyed via script.

On which objects can they run at?
I think they may have been startet in the mission director, but i have no experience with it.
I feel that's rather unlikely. Interaction of Mission Director and Script Editor is rather limited. While it's possible to start MSCI scripts from the MD, the cleaner and easier way is using the SE directly. Of course, there are cases where the MD may have to call scripts. However, looking at the script in question - as its name already suggests it's a custom signal script connected via a secondary signal by another script to Pirate Bases - this is hardly the case here. Besides iirc Serial Kicked wasn't a big fan of the MD to begin with.
I can remember that there was some discussion about secondary signals not working correctly, I think some of them firing twice, with some older X3TC version. But I don't recall the details. Maybe this led to a problem with the clean-up after destruction, too. But again that's pure speculation, and not really possible to prove.
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!

|K.O.S.H.
Posts: 3724
Joined: Fri, 19. Dec 03, 10:36
x3tc

Post by |K.O.S.H. » Fri, 9. Feb 18, 08:05

Thx alot for your answer and your ideas.

I allready visited all sectors manually, but nevertheless i made that jump script.
I also tried everything else:

Creating a spacefly via maintype 7, subtype 275 and "create ship" command does create a whole spacefly wing, not a single one. Thats interesting, because if you use subtype 276 (stardust ship) it only cretes a single ship.

Creating spaceflies in an OOS, entering and leaving this sector destroys them.

So a i created that jump script and jumped all sectors. After my journey there as many spaceflies, as before.

Creating spaceflies with "null" als sector does not work. Well, at least, no more script instances get startet.


I checked some of the MD scripts and noticed that they create spaceflys - maybe as dummies. So this will be my next attempt (i still have almost zero knowlegde of the MD).
Wing Commander Mod - German Topic
06.07.11 - v1.1 RELEASED!

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

Post by Cycrow » Fri, 9. Feb 18, 10:54

i seem to remembering someone else mentioning this happen as well. I think it was coming from some script, but i cant remember which one.

but just to confirm, there isn't a way to get the spacefly objects in scripts, they are classed as special objects in the sector, and not part of the ship arrays.

And they are only in the active sector.
They are created in swarms, with the leader getting the script !ship.cmd.idle.spacefly, and the rest getting !ship.cmd.follow.spacefly.

based on the ratio, it would seem likely they are running on spaceflies.

maybe do a file search in your current script directory, for all scripts that are using the create spacefly command

|K.O.S.H.
Posts: 3724
Joined: Fri, 19. Dec 03, 10:36
x3tc

Post by |K.O.S.H. » Fri, 9. Feb 18, 12:22

I also tried to delete all scripts without "!", but with no success.

I think they have been generated in sector null, maybe it was possible in some earlier versions of the game...

I think i did a file search with total commander, but to be sure i will do it (again).
Wing Commander Mod - German Topic
06.07.11 - v1.1 RELEASED!

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

Post by SirNukes » Fri, 9. Feb 18, 20:56

One out of the box approach would be to figure out how running scripts are stored in the save file, find where the spacefly scripts are, then edit them directly to exit out. Off the top of my head, the general steps would be:

1) Decompress the save; it is in a gzip format. (Since the pck files are gzipped, I gave a shot at unzipping a save the same way, successfully.)

2) Find where and how any spacefly scripts are cached. The aim would be to find the code sections, which contain the commands used by the script. They might show up multiple times; in the save I looked at, a particular comment line from the spacefly idle script is present 120 times. This part could be somewhat bothersome, if a lot of pointer chasing will be involved.

3) Find some convenient node in the script that can be swapped to something that will exit it (a 'return' (code 103) or a 'break' replacing a part of the loop that will be reachable). It would be safest if the replacement node is the same size as the replaced node (when including any extra arguments), for the cleanest edit. Apply the change to all of the scripts found, and hope for the best.

|K.O.S.H.
Posts: 3724
Joined: Fri, 19. Dec 03, 10:36
x3tc

Post by |K.O.S.H. » Sat, 10. Feb 18, 09:00

I also had the idea to edit the savegame. The for the information about the zipping.

My approach will be to find the objects, delete them directly or change the sector if possible.

edit: i unzipped it, some things are readable, but ist still somehow encoded.
That will Need some time.. ;)

Maybe Egosoft wants to help me? (hahaha)
Wing Commander Mod - German Topic
06.07.11 - v1.1 RELEASED!

|K.O.S.H.
Posts: 3724
Joined: Fri, 19. Dec 03, 10:36
x3tc

Post by |K.O.S.H. » Sat, 10. Feb 18, 10:50

It Looks like the scripts and objects are not stored plain or ordered.

There seems to be links/addresses, which are badly encoded, so you cant even search them in the file.

I managed to edit the savegame, and rename the idle scripts name, trying to inject my return script, but of course i didnt work ;)

Only the name was changed
Wing Commander Mod - German Topic
06.07.11 - v1.1 RELEASED!

|K.O.S.H.
Posts: 3724
Joined: Fri, 19. Dec 03, 10:36
x3tc

Post by |K.O.S.H. » Tue, 13. Feb 18, 10:50

I managed to get all possible cue name from the egosofts scripts (2258) and canceled them all. - no success...
Wing Commander Mod - German Topic
06.07.11 - v1.1 RELEASED!

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

Post by Cycrow » Tue, 13. Feb 18, 11:34

One thing you could try is to start a new game eave it running for awhile then check if it has the same problem. If it doesn't, then you will know that it's a script in your save game that's causing it. Have you also checked if any scripts are running globally, and cancelled them?

|K.O.S.H.
Posts: 3724
Joined: Fri, 19. Dec 03, 10:36
x3tc

Post by |K.O.S.H. » Tue, 13. Feb 18, 12:13

Yes, I stopped all global scripts.

I have an eye on the instances, the number does not increse anymore.
I patched the two (spacefly) scripts, so that i can kill any new instances, but he old ones remain :/

If there was a way to restart running scripts with a newer version, my problem would be solved.

Or a command to get all objects, that run a certain script.
Wing Commander Mod - German Topic
06.07.11 - v1.1 RELEASED!

User avatar
ubuntufreakdragon
Posts: 5189
Joined: Thu, 23. Jun 11, 14:57
x4

Post by ubuntufreakdragon » Tue, 13. Feb 18, 22:02

already tried find flying ware: sector=<Var/Sector> maintype=<Var/Number> subtype=<Var/Number> flags=<Var/Number> refobj=<Value> maxdist=<Var/Number> maxnum=<Var/Number>, refpos=<Var/Array> instead of find ship?
My X3 Mods

XRebirth, things left to patch:
In General; On Firing NPC's; In De Vries; Out Of Zone; And the Antiwishlist

|K.O.S.H.
Posts: 3724
Joined: Fri, 19. Dec 03, 10:36
x3tc

Post by |K.O.S.H. » Thu, 15. Feb 18, 14:26

yes, but thanks :/
Wing Commander Mod - German Topic
06.07.11 - v1.1 RELEASED!

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

Post by Aldebaran_Prime » Fri, 8. Jun 18, 00:28

X2-Illuminatus wrote:...
What could prove difficult is when the spaceflies were created in sector null. Some scripts use this area to create objects in a safe place, before they are used later, or to read their properties upfront for which you need the actual object. ....
do you have an example of the syntax for us? Maybe we can delete them there in the NULL device?

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

Post by Aldebaran_Prime » Fri, 8. Jun 18, 00:33

|K.O.S.H. wrote:Yes, I stopped all global scripts.

I have an eye on the instances, the number does not increse anymore.
I patched the two (spacefly) scripts, so that i can kill any new instances, but he old ones remain :/

If there was a way to restart running scripts with a newer version, my problem would be solved.

Or a command to get all objects, that run a certain script.
please, may you publish the code here? I would include this into my mod to prevent new players to run into this problem

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

Post by Aldebaran_Prime » Tue, 12. Jun 18, 22:37

Hi all, because nobody posted here an answer, maybe somebody can check if the following approach works as I thought and it seems to.

The idea is, not to restart the spacefly script, if the version changes, but to destroy the whole spacefly if the version of its script changes.
This is possible without too many disadvantages for the player, because spaceflys are destroyed and re-created normally, if the player changes a sector. So latest after an update and one sector change the typical amout of spaceflys are back in sector.

I put the following code at the top of the !ship.cmd.idle.spacefly-script:

Code: Select all

* set local variable to current script version
$CurrentSpaceflyVersion = get script version
* get last saved script version from global variable and save in local variable
$LastSpaceflyVersion = get global variable: name= 'idle.spacefly.version'
* set golbal variable to current version
set global variable: name='idle.spacefly.version' value =$CurrentSpaceflyVersion

*now compare current version with version of global variable
if not $LastSpaceflyVersion ==$CurrentSpaceflyVersion 
 write to player logbook 'Debug: ship.cmd.idle.spacefly: different Script versions- I will kill myself'
* destroys the object where the sript is runnung on... only the next instance of a spacefly will survive 
[THIS] -> destroy object: killer=null, show no explosion=0
return null
end
...
If the script version is not identically with the last saved version of this script, all spaceflys should kill themselfs, including their script instances

The same method may be used to examine an other global variable which can be manually set to "TRUE" to kill all running instances of spaceflys in the universe

Code: Select all

...
*now examine global kill-variable 
$KillSpaceFly = get global variable: name= 'KillSpaceFly'

if  $KillSpaceFly == [TRUE]
 write to player logbook 'Debug: ship.cmd.idle.spacefly:  KillSpaceFly == TRUE - I will kill myself'
* destroys the object where the sript is runnung on... as long  als KillSpaceFly ist true, no spacefly will survive
[THIS] -> destroy object: killer=null, show no explosion=0
return null
end
...

If we put this code in the spacefly-scripts we are prepared for future inflation of spaceflys.

what dou you think? Are there better approaches out there in x-universe?

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

Post by Cycrow » Wed, 13. Jun 18, 10:32

Theres actually a proper command to check for new versions, which would be better to use, as you wont need to use global variables

something like, if is new version of script available.

as the problem seems to be that spaceflys are in the null sector, you could simply put a check in for the current sector, if its null, then you could just destruct them as well.

one other thing, remember the followers as well, as spaceflies are in swarms

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

Post by SirNukes » Wed, 13. Jun 18, 19:03

Killing the script on version change doesn't seem like it would have any advantage over rebooting the script on version change, unless you want to use a version change as an explicit hack to end all running copies. It would be cleaner to do a proper reboot and then just adding other tweaks to the new script to end it under some conditions.

One idea to prevent immortal spaceflies would be to add a lifetime to the spacefly script: after 2 hours (or whatever), the script can kill the spacefly off and end. Followers that then swap to the leader script would kick off a new timer and eventually die as well.

Though one worry is that the spaceflies might be unkillable. A couple of times in game I have run across immortal ships that could not be killed by any method I tried, including direct script commands or docking them and then killing their dock. The '!ship.cmd.idle.spacefly' script should probably be given its own timeout, since such spaceflies only swap to the leader script if the leader stops existing.

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

Post by Aldebaran_Prime » Wed, 20. Jun 18, 00:10

unfortunately, I was not able to get the

Code: Select all

If is a new script version available 
...
end
version to running. So for the moment I stay to the old fashioned way with the global script version variable. But if somebody has some code snipplets for me to do it right, I will try it again.

I tested further, and found, that spaceflys NOT always killed by sector management, if the player leaves the sector.
I found this, because of some debugging messages of my modified spacefly scripts are writing into the player log now. And after back an forth changing of the sector, some old instances of spacefly scripts were still running.
I also found, that my dectector script (see below) showed me some spaceflys at position 0,0,0 - but I was not able to hibernate them at this position with the ion-disruptor. At other detected positions it worked correctly.

I modified now the scripts:
!ship.cmd.idle.spacefly and !ship.cmd.follow.spacefly ...
That they will kill themselves and their spaceflys if a new script version is available OR a global variable $KillSpaceFly was set to TRUE by another script.
Therefore I wrote 2 additional scripts: ...
1. aaKillSpaceFly
2. aaEnableSpaceFly
... which will either set the $KillSpaceFly to TRUE or FALSE

At the moment these scripts needed to be started manually in script editor to kill spaceflys - but it works! Also for the 0,0,0 spaceflys.
For sure with the known restriction, that instances of older spaceflys which are running in the nowhere are still not killable.

As a bonus add-on, the leading spaceflys will now show their positions in the map temporarily, if the player ship is equipped with a spacefly collector and the distance between player ship and spacefly swarm is below 10.000 m

These scripts can be downloaded by anyone interested in here: https://1drv.ms/u/s%21AleWkrAhnZL_gfA0JJHW1CfzEg5jLA

I think, I will puplish this as a separate "Advanced Spacefly MOD" soon, too.
Hope, this may help others to find a final solution for the zombie-spaceflys which slow down our game.

Post Reply

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