[Discussion] Generic X3TC S&M questions I

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

Locked
Osiris_sam
Posts: 422
Joined: Thu, 24. Aug 06, 13:45
x4

Post by Osiris_sam » Fri, 10. Jul 09, 01:38

the global script make: set: ...
command should overwrite the previous one (you probably need to set the script command upgrade too as normal)
init scripts run before setup files, so that should not be a problem (please correct me if im wrong)

you can also do it on a ship to ship basis if you want to change only some ships.

ThisIsHarsh
Posts: 1135
Joined: Sun, 19. Oct 08, 18:46
x3tc

Post by ThisIsHarsh » Fri, 10. Jul 09, 01:51

Yeah tried all sorts of combinations can't seem to override the default mapping.

Even tried just removing the command altogether (global script map: remove), and still no difference - the command is still available and whatsmore still runs the stock script. Tried running my setup script manually. Tried different ship classes... there must be some trick to doing this, I'm sure it's been mentioned before.

EDIT: tried 'global script map: ignore' and that worked to remove the command. But then, wierdly, when I add a 'global script map: set' after the 'ignore' and pass it my own script, the command reappears - but still uses the stock script!!!

Osiris_sam
Posts: 422
Joined: Thu, 24. Aug 06, 13:45
x4

Post by Osiris_sam » Fri, 10. Jul 09, 02:13

which command are you trying to overwrite?

ThisIsHarsh
Posts: 1135
Joined: Sun, 19. Oct 08, 18:46
x3tc

Post by ThisIsHarsh » Fri, 10. Jul 09, 02:19

Aha! Sorted it. The weird behaviour was because the stock command (Deploy Satellite Network) had preload script assigned! I had to overwrite both the command script and command preload script in order to get it to work. Sorted now, cheers.

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

Post by Cycrow » Fri, 10. Jul 09, 02:30

preloads are used to display the menu.

these are run before the actual script command, so when u tested it, u most likly only saw the preloaded menu, before getting to your script change ;)

what would have happened is, when u selected the menu, then ur command would start and u will see the changes, if u want to change the input, u'll need to also change the preload.

when u said u overright the preload, did u use the same script for both ?
coz its not advised to do that

ThisIsHarsh
Posts: 1135
Joined: Sun, 19. Oct 08, 18:46
x3tc

Post by ThisIsHarsh » Fri, 10. Jul 09, 05:09

Cycrow wrote:preloads are used to display the menu.

these are run before the actual script command, so when u tested it, u most likly only saw the preloaded menu, before getting to your script change ;)

what would have happened is, when u selected the menu, then ur command would start and u will see the changes, if u want to change the input, u'll need to also change the preload.

when u said u overright the preload, did u use the same script for both ?
coz its not advised to do that
I wrote my own preload script and overwrote it with that.

As I say, the weird thing is that if I only overwrite the command script and the leave the preload script alone, then it doesn't do anything, I *have* to overwrite the preload script as well. Unfortunately there is no 'remove command preload' script command, so the only method is to write a (very small in this case) replacement preload script.

Makes sense in a way to block replacing of command script whilst the preload script remains the same - stop the (potentially) wrong input going to the new command script.

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

Post by Cycrow » Fri, 10. Jul 09, 16:02

well as i said, the preload script is run first.

so when you start the command, what happens, is the preload script is run.

this script then returns an array of arguments. If those arguments match the command script, then the command will start.

otherwise, the command will not begin at all.

preloads basically allow you to create a menu system for the command without starting the command straight away.

if u put a menu in the command script itself, then the existing command will stop to display this menu, so if u then quit out the menu to cancel the command, u will lose any existing commands running as well.

with a preload it allows the existing commands to continue running until u've finished and accepted the menu selection

ThisIsHarsh
Posts: 1135
Joined: Sun, 19. Oct 08, 18:46
x3tc

Post by ThisIsHarsh » Fri, 10. Jul 09, 18:05

Ah OK, I think I understand - actually that explains another weird behaviour where the script wouldn't start at all sometimes.

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

Post by Cycrow » Fri, 10. Jul 09, 18:48

yeah if ur using a preload, jsut make sure ur returning an array of arguments, even if the command script only has 1 argument.

the idea of preloads is to basically allow you to create a script to select what arguments are being passed to the command, instead of the game simply getting input for each argument.

if you use one argument as a Var/Ship, then when u run the command u will get the standard ship selection menu then the command will run using that ship.

if u use a preload, u can make a custom menu for a different ship selection, then simply return that ship as an array.

u cant do this

Code: Select all

return $ship
u need to make it into an array

Code: Select all

$arr = create array with arguments = $ship, null, null, null, null
return $arr
then each element of that array is passed to the command script arguments

if u dont return an array, then the command terminates, ie, if u want to quit out the menu coz u no longer want to run the command, then u can just return null and the command will then never be run

User avatar
ScytheBlade1
Posts: 42
Joined: Fri, 26. Oct 07, 04:38
x3tc

.cat/.dat format?

Post by ScytheBlade1 » Sun, 12. Jul 09, 00:26

I've searched high and low, and while it is entirely possible that the answer is right in front of me, I can't find it..

For various reasons, I'm looking to write a .cat/.dat parser. Everywhere I look simply says "don't do this, just use one of these tools: X Y or Z" or it just says "don't do this." :)

Which doesn't help me much.

Seeing as this is the generic S&M thread, I figured it'd be worth it to ask and see if anyone (a) knows the formats in question well enough to describe it and (b) would be willing to do so. :)

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

Re: .cat/.dat format?

Post by Cycrow » Sun, 12. Jul 09, 14:26

ScytheBlade1 wrote:I've searched high and low, and while it is entirely possible that the answer is right in front of me, I can't find it..

For various reasons, I'm looking to write a .cat/.dat parser. Everywhere I look simply says "don't do this, just use one of these tools: X Y or Z" or it just says "don't do this." :)

Which doesn't help me much.

Seeing as this is the generic S&M thread, I figured it'd be worth it to ask and see if anyone (a) knows the formats in question well enough to describe it and (b) would be willing to do so. :)
it really depends what you want to do.
there are a few options. u could get doubleshadows library which u can use in your program, assuming ur writing it in c++

or u could use a command line tool to do what u want, that could be ran inside your program.

or do u plan to create everything from scratch ?

the format is fairly simple, the cat file is simply a file list, of each file in the archive and the size and position its at.

and the dat files is basically all the files joined together.

these files are compressed using zlib, and can sometimes be encypted with Xor

User avatar
ScytheBlade1
Posts: 42
Joined: Fri, 26. Oct 07, 04:38
x3tc

Re: .cat/.dat format?

Post by ScytheBlade1 » Mon, 13. Jul 09, 00:27

Cycrow wrote:it really depends what you want to do.
there are a few options. u could get doubleshadows library which u can use in your program, assuming ur writing it in c++

or u could use a command line tool to do what u want, that could be ran inside your program.

or do u plan to create everything from scratch ?
I'd probably wind up creating it from scratch. It'd be in Java, too - my laptop is linux, which is what I do a lot of my dev on.
Cycrow wrote:the format is fairly simple, the cat file is simply a file list, of each file in the archive and the size and position its at.

and the dat files is basically all the files joined together.

these files are compressed using zlib, and can sometimes be encypted with Xor
1) zlib - as in the simple gzip applied to nearly everything, right? A unix standard 'gzip -d file' (renamed to .gz) works on most everything that I've extracted with other tools.
2) zlib --> xor, or xor --> zlib? I want to say xor first, zlib second from a simple experiment, but I just wanted to be sure.
3) Don't suppose you know the xor key offhand, or where I could find it? :)
4) Are the .cat/.dat files themselves gzipped? No? Only one? Both?
5) I've noticed that the game provided archives pretty commonly contain gzipped files - not all, but many. Is it possible to have a gzipped archive that contains gzipped files?

Once I can get the stupid files opened, if they are as simple as you described, I'll be able to figure out the rest on my own - but from what I can tell, I just need to get the .cat/.dat files in a more "plaintext" state and things will go smoothly.

And thanks!

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

Post by Cycrow » Mon, 13. Jul 09, 18:29

the Xor is applied after the compression, so when reading it, u need to do it first

the magic key is placed in the first character of the file

Code: Select all

unsigned char magic = data[0] ^ 0xC8;
		
for ( size_t i = 1; i < datasize; i++ )
	data[i] ^= magic;
++data;
--datasize;
then use zlib to uncompress the data chunk


it was easier in previous games, unfortuataly the format changed, basically, the encycrption is no longer always there.

in previous games it was always encrypted, but in X3TC its not, althou it still can be

so u need to check that before doing Xor

Code: Select all

bool IsDataPCK ( const unsigned char *data, size_t size )
{
	if ( size >=3 )
	{
		unsigned char magic=data[0] ^ 0xC8;
		return ((data[1] ^ magic)==0x1F && (data[2] ^ magic)==0x8B);
	}
	else
		return false;

}
if it the actually files u wanted, or was it just the list of whats in there ?

the xor/zlib is for the dat file, the cat file is abit different, its basically a plaintext file thats encrypted

Code: Select all

bool CCatFile::DecryptData ( unsigned char *data, size_t size )
{
	unsigned char cl=0xDB, dh=0xDC, dl=0xDD, ah=0xDE, ch=0xDF, al;
	unsigned char *ptr = data, *end = data + size;
	size_t i = 0;

	for ( ptr = data; ptr < end; ptr += 5)
	{
		al=ch;
		ch+=5;
		*(ptr + 4) ^= al;
		al=ah;
		ah+=5;
		*(ptr + 3) ^= al;
		al=dl;
		dl+=5;
		*(ptr + 2) ^= al;
		al=dh;
		dh+=5;
		*(ptr + 1) ^= al;
		al=cl;
		cl+=5;
		*(ptr + 0) ^= al;
	}

	return true;
}

User avatar
ScytheBlade1
Posts: 42
Joined: Fri, 26. Oct 07, 04:38
x3tc

Post by ScytheBlade1 » Mon, 13. Jul 09, 19:35

Awesome. Thank you much!

someone else
Posts: 2972
Joined: Sun, 18. Jun 06, 13:37
x3tc

Post by someone else » Thu, 16. Jul 09, 12:14

I modded TS to be compatible with 200mj shields but they come equipped by shipyards with 200mj shields in all versions, this bugs me... is it fixable someway?

another question: i tried to make a beam reusing a unused purple beam file (that works well in game) and modified its texture to have a different colour, then saved it and assigned its name into the beam bod file where it should be.
when i fire that beam I get a "phantasmal" beam like this, instead of a beam with a different colour than the original.

thanks for any answer... :D
Trade, Fight, Build, Think, Modify.
Ship Rebalance Mod
OOS Rebalance
Resized Aldrin Big Rock
SIDE/TOP/FRONT Ship Size Comparison
Remember young Padawan: money stolen can be, time cannot.

User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER » Fri, 24. Jul 09, 23:03

I have some questions, concerning stations and their "behaviour".

1. If a station produces many wares, in which order are they produced?

2. How is the cargo space a station has divided between those wares?

3. Is there really no account for secondary ressource? And if so, why is there a command like this:

Code: Select all

<RetVar> = <RefObj> -> get production cycle time: account for secondary resources=<Var/Number>
4. Does anybody know how exactly the cycle time is calculated? I know it has something to do with the RelValue, but nothing more specific.

5. In the X3 Editor by doubleshadow you can set a factories subtype to SG_FAC_STORAGE. I didn't notice a change to the normal SG_FAC_TECH - is there any?

6. In the Exscriptor (and in the MD) you can choose an object class called "Scrapyard". It does not appear in the SE and there seems to be no station of the class "Scrapyard". Is there a way to create one, and if so, how?

If hope there is someone to answer all my questions. :D

Greets,
ScRaT

ThisIsHarsh
Posts: 1135
Joined: Sun, 19. Oct 08, 18:46
x3tc

Post by ThisIsHarsh » Sat, 25. Jul 09, 04:17

Can't answer all those, but these are the ones I know.

1. Arbitrary, from start of the list to the end, whatever order they are added to the fab.

2. Each ware gets it's own cargo irrespective of the others. The amount only varies by station type (e.g. XL fab has much more than a TD).

3. Secondary resources speed up production, though I don't know by how much.

... the rest of those questions I have no idea, but I would also be interested in the answer.

User avatar
Killjaeden
Posts: 5366
Joined: Sun, 3. Sep 06, 18:19
x3tc

Post by Killjaeden » Sat, 25. Jul 09, 12:53

If i want to open the Scene file of a ship that has a enty like this in the Tship
"Ship scene: 4704" - where do i find this scene?

I found the bodies in objects\v\... but there are no scene files?
[ external image ]
X-Tended TC Mod Team Veteran.
Modeller of X3AP Split Acinonyx, Split Drake, Argon Lotan, Teladi Tern. My current work:
Image

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

Post by Gazz » Sat, 25. Jul 09, 13:02

A scene is nothing but a collection of body files and you can access the body file directly.
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.

someone else
Posts: 2972
Joined: Sun, 18. Jun 06, 13:37
x3tc

Post by someone else » Sat, 25. Jul 09, 13:10

huh... the Khaak Clusters!

open the ship whith Model Viewer and there is a button to find out where are and what is the name of ALL the files used. (the one that looks like an eye)

that cluster looks to point to a scene file located into the objects\cut folder.

04704.pbd

most old ships have their scene file there.
Trade, Fight, Build, Think, Modify.
Ship Rebalance Mod
OOS Rebalance
Resized Aldrin Big Rock
SIDE/TOP/FRONT Ship Size Comparison
Remember young Padawan: money stolen can be, time cannot.

Locked

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