Is it possible to add Stations to Warelists?

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

Post Reply
User avatar
RoverTX
Posts: 1426
Joined: Wed, 16. Nov 11, 18:37
x4

Is it possible to add Stations to Warelists?

Post by RoverTX » Tue, 11. Dec 12, 22:21

I just created a warelist that only contained a station. I then tried making the Job for the Lifter in the moon sector use this warelist, but when I went into the game the station wasn't in the lifters cargo. Is this just not possible, or even with one object is it not 100% chance of adding the ware?

User avatar
apricotslice
Posts: 14129
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice » Wed, 12. Dec 12, 05:59

Is the lifter capable of taking station sized cargo ?

User avatar
RoverTX
Posts: 1426
Joined: Wed, 16. Nov 11, 18:37
x4

Post by RoverTX » Wed, 12. Dec 12, 06:39

Yes its ST. Tried it again this time adding in three stations to the list and adjusting the front number, and making sure the line number up top had also been adjusted. No luck...

I am trying to add stations to TLs around the galaxy so that one could end up getting enemy race stations by piracy. I tried to run a script to do it, but it ran into problems because when I tried to check to make sure I wasn't adding a station to a TL that already had one the check would fail, because the stations weren't being considered ware objects so it would return that there weren't in any ST sized objects in the hold even if there was a station in there...
Last edited by RoverTX on Wed, 12. Dec 12, 06:42, edited 1 time in total.

User avatar
apricotslice
Posts: 14129
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice » Wed, 12. Dec 12, 06:40

I wonder how much of the lifter stuff is hardcoded ?

User avatar
RoverTX
Posts: 1426
Joined: Wed, 16. Nov 11, 18:37
x4

Post by RoverTX » Wed, 12. Dec 12, 06:44

I added them via script and the stations did seem to dispersal after a while, so maybe there cargo is getting wiped at some point.

It would go from 5 in their holds to 0, and I could never figure out why... Well will try it out on some other TLs when I get a chance then...

Thanks that was a good point!

User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle » Wed, 12. Dec 12, 07:59

RoverTX wrote:I am trying to add stations to TLs around the galaxy so that one could end up getting enemy race stations by piracy.
Good idea, RoverTX!

A script is more compatible than modifying jobs and warelists. If the stations disappear over time, then that is OK, right? It creates more randomness. If you are using TL's that already have jobs scripts attached to them then it is possible that GoD uses them for other tasks. See !god.tl.deliver.factory.

I tried the following test code and it produced expected results. Perhaps it will help you?:

Code: Select all

$PageID = <your number here>

$target = get player tracking aim
$factory.type = {Pirates Incendiary Bomb Launcher Forge}
$amt = $target-> get free amount of ware $factory.type in cargo bay

* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$msg = 'Available Space before adding = ' + $amt
write to log file $PageID append=1 value=$msg
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

if $amt
  = $target-> add 1 units of $factory.type
end
$amt = $target-> get amount of ware $factory.type in cargo bay

* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$msg = 'Number in cargo hold = ' + $amt
write to log file $PageID append=1 value=$msg
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

$amt = $target-> get free amount of ware $factory.type in cargo bay

* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$msg = 'Available space after adding = ' + $amt
write to log file $PageID append=1 value=$msg
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

return null


User avatar
RoverTX
Posts: 1426
Joined: Wed, 16. Nov 11, 18:37
x4

Post by RoverTX » Wed, 12. Dec 12, 21:28

Going off what ya'll said I came up with the following al script. Still working on it but the general idea is there.

https://s3.amazonaws.com/forums-rover/stcap.zip

It runs every 5 minutes. It first finds all the shipyards for each race. Then gets from them all the factories for sale from each race. It then finds every TL in the universe and adds stations to them from their respective race, but it wont add more then one station at the moment.

It also tries to weight the food and bio factories used by player stations so they show up more often sense you need more of them, even though they only make up a fraction of all the different type of factories.

Haven't tested it all together just yet, but some feed back on the structure of the plugin would be cool!

PS: It should work with custom factories as long as they are for sale some where, and it shouldn't pick up non-complex-able Terran facts, because its only going off what is being sold. It also doesn't pick up Docks or Trading Posts atm because they aren't of the class Factories.

User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle » Wed, 12. Dec 12, 22:56

That all sounds pretty good, RoverTX.

IMHO, it should not include factories that are not for sale (other than maybe a rare IBL Forge).

I will take a look at your code later, but it sounds as though you are on the right track.

User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle » Thu, 13. Dec 12, 05:34

Your code looks basically sound, as well, RoverTX.

You will be adding stations to Casinos and Hospitals, in addition to other TL's, of course. You are not making the stations rare -- you are just making them available, in case the race will not sell them, right? I think that will be a huge help to those playing pirate or race-response games!

A possible option would be to include a few rare stations that are not sold at shipyards, such as IBL Forges or Ghoul Missile Manufacturing Plants. I am sure that you would make some new friends if you did that! An easy way to let the player choose whether to use an option is to put it into the t file.

If you are looking for tips:

- While loops should always have a WAIT.

- In-game text, such as the description string, should really come from a language file since this is an international game.

- file names should really be plugin.stcap... rather than al.stcap... except for the actual al script which should be named al.plugin.stcap... (These are EgoSoft's published naming conventions).

- If you are looking for formatting and naming ideas, then take a look at al.plugin.bw.organic.hulls.event (part of Organic Boron Hulls) for a good example.
Last edited by DrBullwinkle on Thu, 13. Dec 12, 06:10, edited 1 time in total.

User avatar
apricotslice
Posts: 14129
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice » Thu, 13. Dec 12, 05:47

DrBullwinkle wrote: - file names should really be plugin.stcap... rather than al.stcap... except for the actual al script which should be name al.plugin.stcap... (These are EgoSoft's published naming conventions).
Where are they specified ? I've never seen them.

Besides, I ignore that on the basis that I want all my scripts easily identifiable as mine, and dont want them mixed up in the general plugin ones. Too easy to lose a script that way.

User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle » Thu, 13. Dec 12, 06:07

apricotslice wrote:Where are [the naming conventions] specified ? I've never seen them.
The clearest definition is on the L3+ forum under instructions for submitting scripts. But not everyone has L3 access, so another source is page 11 of the MSCI Programmer's Handbook.

And here is another reminder from KlausM: Contact persons for signing scripts and .... rules.
Last edited by DrBullwinkle on Thu, 13. Dec 12, 06:12, edited 1 time in total.

User avatar
apricotslice
Posts: 14129
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice » Thu, 13. Dec 12, 06:11

Ah that explains it. I dont write signable scripts, so its never going to be an issue :)

User avatar
RoverTX
Posts: 1426
Joined: Wed, 16. Nov 11, 18:37
x4

Post by RoverTX » Thu, 13. Dec 12, 07:51

Whats the normally wait time required? Is that a good idea because other scripts can run while its waiting?

User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle » Thu, 13. Dec 12, 08:46

There may be a better answer, but here is my approach:

Loops should have a minimum of 1 ms WAIT to allow other scripts to interrupt.
  • (There are some rare exceptions, but not in your script.)
Slower loops generally have less impact on the overall game performance, so I tend to make the WAIT "as long as is reasonable". However, all of your loops *must* complete before the AL timer (to prevent AL "pileups" which cannot be cleared by a script). In your case, with a 300 second timer, that gives you a good amount of time with which to work.

Loops running on many ships should be slower than loops running on a single object (or running globally, as in an Artificial Life Plugin).

Also, I think I read somewhere that "WAIT Randomly" gives more flexibility to the scheduler, although that might be more important for a script running on multiple objects.

So, in this case, I would try: "WAIT Randomly from 100 to 200 ms". Test it, and see how it works. The script should do its job well before the 300 second AL timer, and you should see no lag from your script, even under heavy combat conditions.

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

Post by Cycrow » Thu, 13. Dec 12, 09:59

apricotslice wrote:I wonder how much of the lifter stuff is hardcoded ?
The answer is nothing.

the lifters you see in vanilla are just spawned like any other ship, via jobs. And then controlled via scripts.

Post Reply

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