[SCRIPT] Salvage Network 2.8 [08.11.08]

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

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

stealthhammer
Posts: 1461
Joined: Fri, 12. Sep 08, 04:27

Post by stealthhammer » Tue, 16. Dec 08, 21:51

Yeah i was going to get it from amazon.com when I save up enough money currently got a $1,200 bill credit card bill due to college and so forth.

Wonder if squiddy is ok, we haven't heard from him for a time.

Schabernack
Posts: 216
Joined: Wed, 18. Apr 07, 19:32

Post by Schabernack » Sun, 1. Mar 09, 12:28

hi, i allready use
cycrows salvage claim software 1.05
http://forum.egosoft.com/viewtopic.php?t=112957 and
Gazz's Bhruic's SatelliteDeploy / Satelliten-Verteiler v2.00
http://forum.egosoft.com/viewtopic.php?t=176829

Is there a version without these options in your mod or are those completly compatible with yours? How can i deactivate those features of your script so there are no unnecessary scripts and commands installed?

If i deploy satellites of my own or by another script, does the Salvage Claim Network use them too ? Does it try to deploy Satelites there where i have allready deployed them by myself?
learn from the past, live the moment, dream of the future
tc-ap minimax

User avatar
TECSG
Posts: 1604
Joined: Tue, 17. Feb 04, 22:06
x3tc

Post by TECSG » Sun, 1. Mar 09, 21:30

Hi Schabernack,

I think those script should be compatible, although you may end up with two 'Claim ship' type commands and/or similar duplication.

You don't have to use the Satellite Network component or the Claim component of my scripts, (using the other two instead), but they will still be installed as they will be referenced by the setup script and possibly the plugins. Although you could deactivate the commands, it would mean modifying the main setup script.

My Salvage Network will use any satellites (or advanced satellites) deployed, regardless of what/who deployed them.

Schabernack
Posts: 216
Joined: Wed, 18. Apr 07, 19:32

Post by Schabernack » Mon, 2. Mar 09, 02:59

thanks for the fast answer 8)

i'll try it
learn from the past, live the moment, dream of the future
tc-ap minimax

Katorone
Posts: 378
Joined: Thu, 12. Oct 06, 10:49
x4

Post by Katorone » Sat, 7. Mar 09, 13:29

Hi TECSG

I haven't tried this script yet, but I do have a few questions:
- This script is compatible with XTM, but does this mean it will also spawn XTM ships?
- Since XTM has more sectors, is the chance of a spawning increased?
- Are there AI options for the different components of the script? For instance, I use another sat deploy script (in this script i can control in which race's sector I'm putting sats in, by using the friend/foe settings). This gives me more flexibility with satelite limited traders.

Thanks!

User avatar
TECSG
Posts: 1604
Joined: Tue, 17. Feb 04, 22:06
x3tc

Post by TECSG » Sat, 7. Mar 09, 17:52

Hi Katorone,

The script will compile a list of available ships when you first run it (or restart it), therefore, it is capable of spawning any ships from any mods (including XTM) you have installed.

The chance of spawning does not rely on the number of sectors as such, but as (I believe) XTM adds more 'safe' sectors than 'unsafe' ones, the chance of the spawn routine picking a 'safe' sectors is very slightly increased.

The Satellite Deployment script only places satellites in 'friendly' sectors, to reduce the risk of them being destroyed, but it should take into accound any sectors in which you already have a satellite.

Of course, you do not have to even use the satellite deployment script, (accessed through a BBS advert), if you prefer another or deploying them yourself. :)

Katorone
Posts: 378
Joined: Thu, 12. Oct 06, 10:49
x4

Post by Katorone » Sat, 7. Mar 09, 18:18

Perfect! Thanks for the reply! :)

I'm actually trying to code something myself, but I might be in over my head.
Filtering out the list of ships is something on the todo. I suppose I have to use the array which has all the scripts in them, but then I need to filter the ships according to the type of cargo (S,M,L,XL) they can use.
At least, I hope it's possible to get all the variables from a ship,(cargo,speed,energy) which hasn't been built.
Do you know if there's a comprehensive list of all functions and global variables/arrays? I'm currently using xscriptor because the in-game scripting engine doesn't like my keyboard.

User avatar
TECSG
Posts: 1604
Joined: Tue, 17. Feb 04, 22:06
x3tc

Post by TECSG » Sat, 7. Mar 09, 18:35

As far as I know you can't get any information about a ship that doesn't technically (physically in the X-Universe) exist.

You cannot, for example, have something like:

$ship = 'Discoverer' <- where this is a string
$class =
get class of object $ship

This is because when the script checks the object 'ship' to see what class it is, it finds the object doesn't exist and returns 'null' instead.

To get information about an object (ship, station, etc.), the object must exist at the time the information request is made.

When my script compiles a list of all the available ships, it has to create each one individually, get the class (M5, M4, etc.) then destroy the ship. The ships are then sorted into arrays depending on their class.

This is all done OOS, so no models have to be rendered or calculations done, it takes about a second to do all the X3/XTM ships.

Katorone
Posts: 378
Joined: Thu, 12. Oct 06, 10:49
x4

Post by Katorone » Sun, 8. Mar 09, 04:54

oh.
That's... harsh. I would've imagined X3 keeping some lists and arrays in memory of what belongs to what.
Would you be interested in creating a lib which does the following:
- loop through all ships & get the cargo sizes, then returning an array which contains an array per ship/cargo size. (or possible create a list of all gettable properties of all ships... might be fun to export to import in a ship database for instance)
- loop through all stations, get their values (in particular their cost, the products they make and use, the storage available for each product and the turn around rate, but perhaps even their dimensions? (but i guess doing this OOS is impossible)). I'm thinking for instance there are a lot of scrips which are incompatible with ashley's magnificent XL & XXL fabs mod. The rurn around rate for mines would probably be impossible to get, since it doesn't seem to behave linear with the yield of asteroids.

I'm also looking at the available objects and find it strange that I don't see any values for the station cargo types (when a station is loaded in a TL). I do, however see a list with all the stations in it.

Having the lib with just the (global?) vars would be wonderful, I would then like to adjust it and let it take commands as arguments.
so you could do:

Code: Select all

$storage = [THIS]->a.ship.and.station.info command='getshipstorage' ship='Argon Buster' 
It seems doable even in a for loop to quickly decide which array index should be used to get the info needed, without the need for a big nested if/elseif or skip if tree.

I'm currently learning a bit how to script X3 by trying to remove all errors generated by the Exscriptor. The weird thing is that Exscriptor finds a lot more conflicts than Cycrows Package Manager. I do have some experience with TCL and php, so at least I don't have to learn the logics of scripting.

Is there a reliable way for X3 to time the execution of a command? For instance, set a var to the current Ticks, execute a command and compare the stored Ticks with the current Ticks? (I'm a write-fast-code-nut/perfectionist. :-/)

Regards,
Peter


EDIT, I'm noticing that there are 4 distinct Argon Busters in my game. This could screw things up... Unless only ships available to buy at a shipyard are checked. Though this leaves an incompatibility for scrips which just add a ship as a derelict, and don't bother adding it to a shipyard. Perhaps all ships can be created one by one OOS, but if the script finds it already has data for this ship, it tries to load the data from this ship type from the shipyard? If not found in a shipyard, the info could default to the first ship being examined?
Is this way of thinking the fastest solution for X3:R?

Code: Select all

create an array shipyardships()
create an array allships()
loop through all stations which are a shipyard (incl PHQ if possible) {
  find the ships, create them and get their stats
  add the examined ships to a local array, shipyardships
}
loop through all ships {
  if $ship not in shipyardships AND allships {
    create the ship and get the stats
    add this ship to another local array, allships
  }
}
The only problem I see are stations which are effectively ships, eg the lasertower. Should it be the script calling the library which makes this distinction, or should the library add exceptions? Personally I think the calling script should handle this.

I'm thinking I'm a but too ambitious though... For instance I'm thinking about an indexing system. Something like this would be lightning fast:

Code: Select all

$ship = replace('Argon Buster',' ','')
$$ship = 10
Then the index for the Argon Buster could be found in $ArgonBuster
However, I guess a one dimensional array would suffice. A for loop with step 2 could easily string compare, and return the current index + 1 as the index of the bigger array with all ship info.
Last edited by Katorone on Sun, 8. Mar 09, 05:49, edited 1 time in total.

User avatar
TECSG
Posts: 1604
Joined: Tue, 17. Feb 04, 22:06
x3tc

Post by TECSG » Sun, 8. Mar 09, 05:29

X3 keeps all the ship information in the TSHIPS file, which, unfortunately, you cannot access directly through the Script Editor...

If you look in your scripts folder, there is a script called scs.get.all.ships, this is my script for parsing all the available ships.

You can modify the script by removing the lines 103-131 and replacing it with code to get the cargo class instead.

I did recently write a routine for X3TC to detect the ship class (not cargo class) of all available ships, as I wanted to know what ships were deemed 'Special ship', 'Little ship', 'Big ship', etc... Not just those that were classed 'M5', 'M4', etc.

The code for getting Station information would again require the creation of each station to get the information, I can't remember off-hand what trade commands are available for X3R, but there must be some that get/return the stations ware/product list. I know there's commands to get product cycle times and such.

Not sure if you can get the dimensions of *any* object through the SE, I don''t even think that information is stored in the TSHIPS or TSTATION files.

The only way to get the volume of a 'packed' station (as far as I can tell), would be to create a Mammoth and put a factory in it and see how much room it takes?

I've not seen any information on 'packed' sizes for stations, but presumably once you 'created' one inside a TL, it would report the cargo size as for any normal item... Maybe...

Your code example would require you to know the names of all ships (if passed as a string), or already have a list of all the ships as objects. The latter would require the creation of all ships as discussed before, and to then additionally go and get the information for that ship, would require the creation of all the ships again!

You would be better off (initially) modifying my routine to get the cargo class instead of the ship class, once you have a working routine, you can then rewrite or remove any information not necessary for your script, like having different arrays for M1/M2/etc.

I've not used Exscriptor, I just use the SE, so I can't comment on any conflicts that might be thrown up, presumable though, Cycrow's PM is expecting scripts to be from X3, and any slight deviation by Exscriptor could cause a non-fatal error/conflict...

I'm not sure if you can time a command per se, the only timing commands at all are the two 'wait' commands. For a lengthy command, you could time it by getting the flight time of the ship at the start and end, then subtracting... But that's very messy and probably not very accurate!

I wouldn't worry about the timing, certainly not until you have an up-n-running script, then at least, you can post or have testers go through it... I'm sure they or the community will let you know if the script is too slow! :P

Katorone
Posts: 378
Joined: Thu, 12. Oct 06, 10:49
x4

Post by Katorone » Sun, 8. Mar 09, 06:29

TECSG wrote:X3 keeps all the ship information in the TSHIPS file, which, unfortunately, you cannot access directly through the Script Editor...
Logic: 0 - X3: 1
TECSG wrote: If you look in your scripts folder, there is a script called scs.get.all.ships, this is my script for parsing all the available ships.

You can modify the script by removing the lines 103-131 and replacing it with code to get the cargo class instead.
Great! Thanks! :-D
Can I spam this thread again should I have some questions about the things you're doing in this script? I'm capable of using the search function and google, so I wouldn't come knocking at your door every 2 minutes. ;-)
TECSG wrote: I did recently write a routine for X3TC to detect the ship class (not cargo class) of all available ships, as I wanted to know what ships were deemed 'Special ship', 'Little ship', 'Big ship', etc... Not just those that were classed 'M5', 'M4', etc.
Hm, I noticed this distinction also exists in X3:R. What's the use for it?
TECSG wrote: The code for getting Station information would again require the creation of each station to get the information, I can't remember off-hand what trade commands are available for X3R, but there must be some that get/return the stations ware/product list. I know there's commands to get product cycle times and such.
Great! I should start with a clean X3 install in a different folder for script writing though. I'm noticing a lot of command which seem to have been added by other scripts.
Should I ever add wares, would it be safer to use the wares option of the package manager, or should I use the EMP mod? Personally my favorite would be the package manager, but when looking at my loaded scripts I don't see any which uses it's functions. They all use EMP.
TECSG wrote: Not sure if you can get the dimensions of *any* object through the SE, I don''t even think that information is stored in the TSHIPS or TSTATION files.
Logic: 0 - X3: 2
Would it then -in theory- be possible to create a new station, say deep space 9 8), which encompasses an entire sector? (Disregarding the obvious FPS hit of doing a thing like this.) Or do you think X3 calculates the dimensions of a station by using the packed size somehow?
TECSG wrote: The only way to get the volume of a 'packed' station (as far as I can tell), would be to create a Mammoth and put a factory in it and see how much room it takes?
Great tip! Thanks!
TECSG wrote: I've not seen any information on 'packed' sizes for stations, but presumably once you 'created' one inside a TL, it would report the cargo size as for any normal item... Maybe...
Or, like you said, 60000 - cargo space left. (iirc a mammoth had 60000 cargo). Would it be possible to temporarily add a mammoth with 2.000.000 cargo units for testing purposes? Or would this require the creation of a totally new Tship?
TECSG wrote: Your code example would require you to know the names of all ships (if passed as a string), or already have a list of all the ships as objects. The latter would require the creation of all ships as discussed before, and to then additionally go and get the information for that ship, would require the creation of all the ships again!
But how can you create all ships, if the list can only be made by creating all ships? :-/ Doesn't X3 have a foreach loop which you can use on the ships object? Anyway, I'd better make a clean install first, for all I know someone has entered all these ships manually and created an object from it.
I'll have a look at your code, I'm sure that will clear things up. :-D
TECSG wrote: You would be better off (initially) modifying my routine to get the cargo class instead of the ship class, once you have a working routine, you can then rewrite or remove any information not necessary for your script, like having different arrays for M1/M2/etc.
Thanks for the offer! Should the script ever be released, you will -of course- get an acknowledgment. :-D
TECSG wrote: I've not used Exscriptor, I just use the SE, so I can't comment on any conflicts that might be thrown up, presumable though, Cycrow's PM is expecting scripts to be from X3, and any slight deviation by Exscriptor could cause a non-fatal error/conflict...
It throws up things like:
X3 data loaded, but with errors:
- Ware with ID '3871' already exists as Fighter drone. It will be replaced with: Fighter Drone from 447212.xml
- Ware with ID '7031' already exists as LX. It will be replaced with: LX from 447212.xml
- Ware with ID '10015' already exists as Super Freighter. It will be replaced with: Super Freighter XL from 447212.xml
- Conflict in file 447734: long command name with ID 327 (Fight Command Software MK3: not installed) already exists
- Conflict in file 447734: short command name with ID 327 (FCS.MK3) already exists
- Ware with ID '21561' already exists as Gamma Kyon Emitter Forge. It will be replaced with: This factory manufactures the massive Gamma version of the Kha'ak Kyon Emitter weapon. from 448400.xml
The last error is probably something wrong in the ashleys XL+XXL fabs.
The conflict in file 447734 also popped up in the plugin manager, but it seems to be by design. (And very well done even, telling the player the script is working, but the package needed hasn't been installed on the ship)
The first errors are probably caused by XTM overwriting some ships.
TECSG wrote: I'm not sure if you can time a command per se, the only timing commands at all are the two 'wait' commands. For a lengthy command, you could time it by getting the flight time of the ship at the start and end, then subtracting... But that's very messy and probably not very accurate!
And it would only return a result in seconds? Or is the flight time internally kept in milliseconds? Sounds a bit icky though. :-/
TECSG wrote: I wouldn't worry about the timing, certainly not until you have an up-n-running script, then at least, you can post or have testers go through it... I'm sure they or the community will let you know if the script is too slow! :P
Sounds like a plan! :-D Though I don't have the feeling this forum is still getting a lot of attention from all the scripting gods. ;-)
But, I also have to admit. I want to learn how to script in X3 because it already has a very big codebase to fall back on and to learn from. When switching to X3:TC, scripting for that version shouldn't be as hard to learn.

Thanks for your replies, they are very helpful!
Regards
Peter

User avatar
TECSG
Posts: 1604
Joined: Tue, 17. Feb 04, 22:06
x3tc

Post by TECSG » Sun, 8. Mar 09, 07:26

Presumable the devs didn't think anyone would ever need to get the details of a non-existant item, and, it they needed to, they could just access the hardcoded information or the TSHIPS file!

I have a slightly updated script to 'get all ships', but it's for X3TC, so I'm not sure if that would be any use to you...

You can always ask a question, but I can't guarantee I'll have he answer! :D

I think the 'extra' ship definitions allow you to select multiple types in one go, ie, 'Freighter' will select TS and some TP ships...

If you're going to add custom wares, try to use one of the internal slots (SS_WARE_NEW_xx), it's a lot less work, but you'll be lucky to find one these days!

Failing that, I'd use a custom ware through the Package Manager, it saves you having to specify the EMP scrips are needed, (as you'll also have to link to them and make sure any alterations to the EMP scripts don't break your own script, which I should think unlikely, but you never know).

The SCS3.02 script of mine use the Package Manager to create a new ware-type, as the original ware-slot I'd used was 'stolen' by someone else (even though I'd requested (and been granted) it through the Community Index List).

I'm not sure how the models are stored (or collision detection calculated), but presumably the model itself has some size information with it?

I've seen a mod that recreates the city from Stargate Atlantis, I would think that's quite a large model, but not sure how that would compare to DS9...

The volume of the largest stations is (from what I've seen) 25,000, not sure if Ashley's mod creates bigger ones, but 60,000 should be more than enough. If you're using XTM, the Terran TL (who's name I think is the Asgard), has 130,000 cargo capacity...

Increasing the cargo capacity would require an alteration to the TSHIPS file, but you could try installing a few thousand Cargobay Extentions to see if you can 'over-expand' the ship. X3TC does clip the cargobay at the indicated max. size, but I seem to remember X3R might not...

All the ships are wares of maintype 7, you can get the number of ships from the 'get number of subtypes for waretype' command, then use the 'get ware of maintype 7 with subtype x' command in a loop to get all the ships to create, like this:

$Ships = array alloc: size=0
$Class = array alloc: size=0

$count = get number of subtypes of maintype 7
while $count
dec $count =
$type = get ware from maintype 7 and subtype $count
$shp = create ship: type=$type owner=Friendly Race addto=null x=0 y=0 z=0
$max = $ship -> get max. ware transport class
append $ship to array $Ships
append $max to array $Class
$ship -> destruct: show no explosion=[TRUE]
end


That won't strip out the invalid ship types, but it's the basic 'core' of the routiine. It will produce 2 arrays, one of the ship names (as null-object pointers), one of the max cargo class for that ship, and, incidentally, should you need to create the ship again, the subtype is:

$count - $index of the array (you have to preserve $count though, as it's decreased in the loop).

You can use the above code to create your lists, but remember to check the array to see what ships you need to remove.

Most of those conflicts are caused by the way X3 handles mods, basically, when someone replaces an existing item in a .cat/.dat file, the file with the higher number overwrites the previous ones. I guess Cycrow's PM has the sence to ignore what is technically not an error, or maybe Exscriptor is just being thorough. :lol:

I'm not sure what format the return value from the get flight time command is, the MSCI handbook may tell you.

Most of the scripters (myself included) have moved on to TC, but most will also still support their old scripts. I'm currently working on V3.1 of the salvage scripts, (much improved) for TC, but once that is finished, I will try to incorporate some of the improvements into the X3R version...

There is very little difference between scripting for X3R and TC, there are a few more commands in TC, and some have been removed that were in X3R, most scripts will port across relatively 'intact', but some changes may be required if you address information directly (like ship or ware types)...

Katorone
Posts: 378
Joined: Thu, 12. Oct 06, 10:49
x4

Post by Katorone » Sun, 8. Mar 09, 16:23

Thanks a lot for your time and effort in replying!
Presumable the devs didn't think anyone would ever need to get the details of a non-existant item, and, it they needed to, they could just access the hardcoded information or the TSHIPS file!
That's just bad practice... They should assume a scripter wants to access everything! :-D The only alternative would be to create this information manually and store it in arrays... But this would mean that the script would be incompatible with custom ships/stations, would require a lot of manual work and is prone to errors.

It's the same thing with eg Oblivion, though Beth has learned from previous versions that players really love to think out of the box concerning scripting. Someone even created a program for it supplying Oblivion with new commands/triggers/whatnot, so you can script things which aren't even in the original game, like locational damage.

Personally, I'd love to see X3 already having available all static properties of all objects.


Just one more question, you use sector null to create the ships in? I'm guessing this is a special sector which can't be traveled to?
Is it possible to view this sector somehow, so I can make sure I don't leave anything behind when I'm done? Or should I add the ships/stations to my own race first for debugging purposes?

I downloaded the MSCI handbook yesterday and also dug up some threads which explained the new commands for X3.

Thanks again!t

User avatar
TECSG
Posts: 1604
Joined: Tue, 17. Feb 04, 22:06
x3tc

Post by TECSG » Sun, 8. Mar 09, 16:40

Hi Katorone,

It would be handy if you could access all the specs. of an object regardless of whether or not it exists, but as there are ways around it, I guess it won't get implemented directly.

Sector 'null' doesn't technically exist, although you can create/put objects there (if they're owned by you, they show up in the first 'legitimate' sector you have things in in the Properties List). It's a handy location to put stuff where you know it won't influence any other aspects of the game.

Also, if you create a ship in the 'null' sector and then 'jump' it to the location you really want it, it appears immediately, there is no 'jumpdrive charging' delay. You cannot jump there yourself, as the jumpdrive routine appears to check for a valid sector destination.

Whilst working on a script, change it to create the objects/ships as 'Friendly Race', and they appear to be automatically deleted when a script reinit is triggered (either manually or by loading a savegame). This is useful if your scripts terminate early or you have to terminate them yourself.

Katorone
Posts: 378
Joined: Thu, 12. Oct 06, 10:49
x4

Post by Katorone » Sun, 8. Mar 09, 19:37

Wonderful! Thanks for your help! :D

User avatar
TECSG
Posts: 1604
Joined: Tue, 17. Feb 04, 22:06
x3tc

Post by TECSG » Sun, 8. Mar 09, 19:39

No problem! :)

Varek Raith
Posts: 329
Joined: Thu, 23. Aug 07, 21:33
xr

Post by Varek Raith » Sun, 24. May 09, 09:36

*Casts Resurrection*

Hello, TECSG. I was curious as to how the Reunion version of you script is going. For the first time in my game, I am interested in the CLSMk2 ware. However since it conflicts with your script I was hoping you could inform me as to how to fix it. Is it as simple as changing the ware id or is it more involved? I have no problem digging into and editing scripts, I just need a push in the right direction. Thanks for the cool script!

User avatar
TECSG
Posts: 1604
Joined: Tue, 17. Feb 04, 22:06
x3tc

Post by TECSG » Sun, 24. May 09, 11:18

Hi Varek Raith,

I'm not sure if the CLSMK2 still clashes, I had to modify my script because the person who wrote the CLSMK2 scripts uesd (without asking) the same ware slots I had requested and reserved.

You can try the two scripts together, worst case scenarion is that they won't work and you have to uninstall one and maybe go back a save or two (remember to save to a 'proper' save slot before you install the second script, not an auto-save slot that will get overwritten relatively quickly.)

The TC version (which takes most of my free time) is a major improvement, whereas the X3R version has 3 commands, the TC version is currently up to about 14 (it even has it's own menu!). You can salvage crates, ships and debris, and even claim and repair them remotely (via another of your ships).

The TC scripts are in beta testing at the moment, but are almost ready for RC1.

cnecktor
Posts: 337
Joined: Thu, 11. Dec 03, 05:53
x3

Post by cnecktor » Sat, 27. Jun 09, 07:44

Hi I was wondering how do you stop sat placement its killing my its starting to kill my founds now and there is like 10 sats in every sector.

User avatar
TECSG
Posts: 1604
Joined: Tue, 17. Feb 04, 22:06
x3tc

Post by TECSG » Sat, 27. Jun 09, 12:36

Hi cnecktor,

The Sat. Deployment script shouldn't deploy a satellite if there is already one in the sector, but I can't check it at the minute as my PC was fried by a lightning strike last week and is now being salvaged to build a new one, so I'm currently reduced to a laptop that has enough trouble running windows, let alone one of the 'X' games...

If you look through this thread, something like this was covered before (someone running out of credits), there should be a script called something like 'A1.SatelliteNetworkTERM' (or something similar), if you go into the script editor in the game, find (highlight) that script in the list and press 'R', then ENTER twice.

That should terminate the satellite deployment script.

Let me know how you get on.

Post Reply

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