[Discussion] Generic X3TC S&M questions II

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

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

Post by Cycrow »

i assume u have $station defined as an argument at the top in the main script ?
xiriod
Posts: 1131
Joined: Wed, 6. Nov 02, 20:31
x3tc

Post by xiriod »

Cycrow wrote:i assume u have $station defined as an argument at the top in the main script ?
Yes.
mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren »

In your preload script, try this

Code: Select all

$station = [THIS]->get user input: type=[Var/Station], title=null 

....snip 

return $station 
Because if the return is an array and if you feeding that into an argument and are not getting the $station out of the array you will be trying to find the sector for the array, not the station. are you doing something like this to get $station out of the array.

$station = $station [0]

MarCon
xiriod
Posts: 1131
Joined: Wed, 6. Nov 02, 20:31
x3tc

Post by xiriod »

Tried that, didn't work for some strange reason as well. I've decided to start from scratch again. Some times, albeit not too often, one can take too many wrong turns and in the end become baffled by one's own code and not figure out where it all goes wrong.

I don't mind much, and I will find a way in the end. I'm trying to make OWP's boardable, which was almost successful except for the issue above. When I entered the target sector directly in to the script it worked.

I guess the reason OWPs aren't boardable is because they are controlled and deployed outside the normal job-system. If you destroy an OWP's supporting ships a new wing is auto-created/sent from nearby sectors. I destroyed an OWPs wing and noticed the new wing was being sent from Kingdom End.

So I used Cycrows cheat script to see what would happen if I did a destroy sector in K.E. and that wing could not be destroyed. Or rather, once I destroyed it, it was respawned instantly.

Why the OWPs could not be deployed through normal Job is beyond me, at the moment.
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Because if the return is an array and if you feeding that into an argument and are not getting the $station out of the array you will be trying to find the sector for the array, not the station. are you doing something like this to get $station out of the array.

$station = $station [0]
No, that would be wrong. He's using a preload script, which returns the arguments for the callscript as an array. But instead of passing that array to the callscript, the first array element becomes the first argument, the second element the second, etc..
Tried that, didn't work for some strange reason as well. I've decided to start from scratch again.
Well, of course that's always a possibility, especially when you're still learning to script you surely have learned new, better ways to reach your goal.

Still, I'd find it annoying not to know what went wrong. Did you put debug-messages into your scripts (the preload script and the callscript) to see where exactly that $station is getting lost?

Greetings,
ScRaT
sharpneli
Posts: 4
Joined: Sun, 2. May 10, 15:29
x3tc

Post by sharpneli »

s9ilent wrote:@sharpneli Even if you took it to the second order (I'm assuming you mean just in terms of x-y-z), you would be totally ignoring the affects of rotations and rotational acceleration, which is a large component of why ships can evade projectiles.
The ship dimensions are not that different (e.g the length is not >> compared to width) so rotation would have any meaningful contribution, so we can safely assume that simply aiming for the center of mass is sufficient as the ships really don't have any holes in them.
s9ilent wrote: Further more, the projectiles are modified by the vector the firing ship is going (as well as the vector it's firing at)
You have to remember that in a 3 dimensional world, you can actually move in 6 directions (along the 3 axis, and rotate along at least 3 axis)
Also, as you move to the second order, you start to depend more heavily on squared and squared root functions, and given that the script engine only run's with int's, this is unlikely to happen.
As I wrote above the 3 rotational degrees of freedom are meaningless. And it's quite bad to say "move in 6 directions" as angular momentum does not change the location of the systems center of mass in any way.

Simple first order targeting calculation is just taking the derivatives of the position vector [of the enemy] for each of the different axis (x,y,z) with respect to time. One can improve the predictive power of that by adding filter (autoregressive model, check wiki) which is calculated simply by adding and multiplying (so strictly speaking it would not be 'second order' as it does not take the second time derivative into account explicitly). Even small one would remove one of the biggest annoyances, such as where you can evade all fire by simply flying in circle. It always makes the gunnery guys look like retards as so trivial trajectory is able to completely evade all incoming fire.

Ofcourse calculating the intersection of the predicted trajectory and the bullet could require square root. Movement of firing ship can simply be subtracted from the target ships velocity (as a vector ofcourse) to provide compensation for the firing ships movement.

And for Gazz. If the first order targeting is hardcoded then there is nothing that can be done about it. That makes also all other points null in relation to X3 as nothing can be implemented :p
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

@ xiriod
Doesn't the first argument of a preload script, have to be the object your running it on or something?
(e.g. array[0] "this" then array[1-5] are your args 1-5?)
(I could be imagining this again.. I have a tendency to do that..)

Also I would strongly recommend printing the $station to the log book, I really do think it is null. And once your affirmed that it is, backtrack and find where is it first null (probably the top of the script) and when is it last not null (at the end of the pre load?)



@sharpneli
I'm not so concerned about the angle changing the "target profile" of the ship, the angle changes the direction of the acceleration, and the magnitude of a ship acceleration is always 0/maximum.

An AR also doesn't really apply (as an AR model is a time series model, and your suggesting to use X' and X''), the more suitable model is just to solve systems of equations, and when your only taking first order conditions (i.e. speed) it is easy to solve, as you have V D * t + (X1' - X2' ) * t= X1 -X1 (Where D is your firing direction and is a unit vector, V is your bullet velocity, and x1' x2' are your 2 object speeds -' is for first order, not transpose, x1 x2 are the positions of the two objects, solve for D)

This equation becomes easy to solve, as you there is no T-time in the equation (as it can be factored out). The moment you bring in acceleration, you can no longer factor out time.

But the moment you bring in acceleration, you can't factor out T any more, and you have a complex system of equations to solve, as on the LHS you need to add 0.5*t^2 *( x1' ' - x1' ' )
Meaning that you now have to solve for D and T, and the function is quadratic in T, so you essentially have 5-1 degrees of freedom ( 3 from the D vector). Now to solve that equation, you have to assume X ' ' ' is 0 (i.e. take rotations out of the picture) and take first order conditions of that equation. This gives you a solution for t = (x1' - x2') / (x1'' - x2'') but t is a magnitude, and not a vector, so just take the magnitude of that vector function And if you sub that back in you will get, hugely ugly expression (where z = x1 - x2, )
v D * z' / z'' + 1/2 z'^2 / z' = z
Solving for d you get:
d = 1/v (z - 1/2 z'^2 / z' ) (z'/z'')*
note (z'/z'')* = (z'/z'') transpose
note some of the divisions are matrix divisions, some arn't
note this equation also makes an adhoc steps by taking the derivative, its mathematically incorrect but gives a good approximation.

Where as originally you just had:
v D + z' = z, which can be solved directly
d = (z - z') v

And well... yeah you can't solve that with ints....
Also, there could possibly no solution
(In the previous case, whilst it is possible that the projectile will never hit as t-> infinity, you can still get the direction the project needs to travel int to do that)

And of course, there is the point that Gazz said as well... (thou you can easily create a double object (But doing the maths is cooler)
User avatar
cheezy379
Posts: 159
Joined: Wed, 2. Sep 09, 01:49
x3tc

Post by cheezy379 »

Going back to a post I made yesterday.

I'm trying to make my first script and i jsut want to add a menu. I'm pritty sure ive got the idea from the tutorials ive read but the menu just never appears. Am I right in thinking I have to add the menu ive made into a pre-existing script that makes the menus? Where would this be?

I've followed up on the xai-corp surgestion, I've dled a PDF explaining it and ive tryed googleing it but all i get is the same few tutorials (which ive tried) and a load of pages on "Dl this cheat script here".

I'm pritty sure Ive got the idea right, I just dont get how to add it to the pre-existing menu/array.

Sorry to be a total noob, but you gotta statrt somewhere.
mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren »

cheezy379 wrote:Going back to a post I made yesterday.

I'm trying to make my first script and i jsut want to add a menu. I'm pritty sure ive got the idea from the tutorials ive read but the menu just never appears. Am I right in thinking I have to add the menu ive made into a pre-existing script that makes the menus? Where would this be?

I've followed up on the xai-corp surgestion, I've dled a PDF explaining it and ive tryed googleing it but all i get is the same few tutorials (which ive tried) and a load of pages on "Dl this cheat script here".

I'm pritty sure Ive got the idea right, I just dont get how to add it to the pre-existing menu/array.

Sorry to be a total noob, but you gotta statrt somewhere.
A menu is just an Array that is being displayed.
You don't need to feed it into an existing script. You create them in any of your scripts that require them.
When a menu opens all it is doing is displaying the arrays contents as a 'List' (basically)
You can display most any array as a menu, but here is a basic create menu and get it to open.

So you need to create the menu (which is only an array) with

<RetVar> = create custom menu array

Or if you want to put a heading straight in, use

<RetVar> = create custom menu array: heading =<Var/String>

Then add something to it, i'll use the add item to array command as an example

add custom menu item to array <Value>: text =<Var/String> returnvalue =<Value>
'array <Value>' is the menu you are adding it to.
'text =<Var/String>' is what is going to be displayed.
'returnvalue =<Value>' is what is returned if the player selects this option.

Then you open the menu

<RetVar/IF> open custom menu: title =<Var/String> description = <Var/String> option array =<Var/Array>
(this opens the std narrow menu, the other one with 'Info Menu' and 'Max Options' at the end is the wider menu)
'<RetVar/IF>' is what option is chosen by the player.
'title =<Var/String>' is the heading at the top of the menu.
'description = <Var/String>' is the text at the top right side on some menus, 'null' in here means dont display anything there.
'option array =<Var/Array>' is the array you want opened for display.

So you can write this script as a test if you want.

$menu = create custom menu array: heading ='Info'

add custom menu item to array $menu: text ='This is my menu' returnvalue = 1

$ret = open custom menu: title = 'My Menu' description = 'I'm in the corner' option array =$menu

And when you run it from the script editor your menu will open.

Hope this helps a bit.

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

Post by ScRaT_GER »

Hi cheezy379,

in your previous post you referenced my tutorial on menus and I actually wonder how you can be asking that question (I know, this sounds bigheaded, but I really wonder).
Actually it's all explained in section "2.5 - Example code". I explicitly mention line 13, where the menu is opened:
"013: Open the menu and save the returnvalue of the selected menu item in the variable $ret"

So, could/should I improve the explanations or did you somehow skip this part?

Greetings,
ScRaT
User avatar
cheezy379
Posts: 159
Joined: Wed, 2. Sep 09, 01:49
x3tc

Post by cheezy379 »

ahhh I've figured out my misstake, my problem was I was assuming the menu would come up when I pressed shift+C and was looking for it there as opposed to runing it in the script editor. Thanks mark_a_condren.

Sorry ScRaT_GER, it wasnt a dig at youre tutorial, I've been following it as closely as possible but when I did it I couldnt see how it liked into the "shift+C" menu and when I wrote out youre example and it didnt appear I assumed id missed out a simple step (like i did), so I was looking for an even more idiot proff tutorial. As I said, I'm starting from scratch and have no idea at all what im doing yet.
Chestburster2
Posts: 214
Joined: Sat, 25. Mar 06, 13:19
x3tc

Post by Chestburster2 »

Question -> What files are currently used to create the X3TC interface?

There's so much "garbage" from previous games inside the cat.. is there a list of used files around? Or does some1 know what files are used?

4 files are known by me
gui_master
interface_icons
interface_framework_xt_diff
interface_template_blackpearl_diff
sharpneli
Posts: 4
Joined: Sun, 2. May 10, 15:29
x3tc

Post by sharpneli »

s9ilent wrote: @sharpneli
I'm not so concerned about the angle changing the "target profile" of the ship, the angle changes the direction of the acceleration, and the magnitude of a ship acceleration is always 0/maximum.
Heh. I kinda guessed that there's a misunderstanding like this. Acceleration usually means whatever which is changing the velocity vector, remember that change of direction is still a change! We're talking about dv/dt not d|v|/dt. So moving your mouse slightly also produces acceleration (orthogonal to your current velocity vector). It's just the vector derivative of the velocity. So by acceleration I do not refer to changing engine setting but the standard vector derivative notation.

s9ilent wrote: An AR also doesn't really apply (as an AR model is a time series model
First order lead calculation can also be expressed as a time series model. The filter taps (for each component) is just [1,-1]. E.g the output for z is 1*z(t)+(-1)*z(t-1) (z here is the time series of z component of some vessels position vector). You can make the ships position a time series by sampling it at regular intervals.

The pitfall here seems to be twofold. 1st of all the lack of floating point calculations and 2nd the inability to sample the enemy position with sufficient precision on regular intervals. Though who knows. Maybe I'll try it someday, even if it's most likely an exercise in futility :)
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22438
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

Chestburster2 wrote:Question -> What files are currently used to create the X3TC interface?

There's so much "garbage" from previous games inside the cat.. is there a list of used files around? Or does some1 know what files are used?

4 files are known by me
gui_master
interface_icons
interface_framework_xt_diff
interface_template_blackpearl_diff
all the types/data files will still be used.

the main files that might not be used anymore would be the models, but most likly they are still linked somewhere in the data files even if they arn't used by the standard game
User avatar
TrixX
Posts: 2035
Joined: Wed, 18. Aug 10, 14:28
x4

Post by TrixX »

Just wondering if there is a way to alter the colour of the text used in the HUD and Menu's. Currently it's limited to that described in the interface_template_blackpearl_diff.dds but altering the colours there doesn't alter it ingame.
"If you’re not prepared to be wrong, you’ll never come up with anything original."
Sir Ken Robinson
Gravitycontrol
Posts: 396
Joined: Sat, 7. Jan 06, 19:27
x4

Post by Gravitycontrol »

Code: Select all

001   $ATFships =  get ship type array: maker race=ATF class=Ship
002   $Counter =  size of array $ATFships
003   dec $Counter = 
004   while $Counter > -1
005   |$Schiff = $ATFships[$Counter]
006   |write to player logbook $Schiff
007   |$Schiff -> destruct: show no explosion=[TRUE]
008   |dec $Counter = 
009   end
010   return null
I wrote this little script that is supposed to kill/destroy all ATF ships can anyone tell me if this is correct? ^^ im more or less a rookie considered in the script editor xD
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22438
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

the logic is slightly wrong

Code: Select all

001   $ATFships =  get ship type array: maker race=ATF class=Ship 
002   $Counter =  size of array $ATFships 
003   while $Counter
004   |dec $Counter = 
005   |$Schiff = $ATFships[$Counter] 
006   |write to player logbook $Schiff 
007   |$Schiff -> destruct: show no explosion=[TRUE] 
008   end
i would also suggest changing the class from Ship to Moveable Ship.
this would prevent destroying nav beacons/satalites, etc
Gravitycontrol
Posts: 396
Joined: Sat, 7. Jan 06, 19:27
x4

Post by Gravitycontrol »

Code: Select all

001   $ATFships =  get ship type array: maker race=ATF class=Moveable Ship
002   $Counter =  size of array $ATFships
003   while $Counter
004   |dec $Counter = 
005   |$Schiff = $ATFships[$Counter]
006   |write to player logbook $Schiff
007   |$Schiff -> destruct: show no explosion=[TRUE]
008   end
I changed it to this now ^^ but when i run it it writes the ship classes in the logbook but it doesn't destroy them?
User avatar
Carlo the Curious
Posts: 16999
Joined: Mon, 5. Mar 07, 22:03
x4

Post by Carlo the Curious »

I'm not sure what 'get ship type array' does - are you sure it's returning actual ships rather than just the ship types of that race?

I usually loop through sectors and use 'find ship' to do that kind of thing.
Gravitycontrol
Posts: 396
Joined: Sat, 7. Jan 06, 19:27
x4

Post by Gravitycontrol »

hmm yeah according to loogbook it seems to give only the types ( odin valhalla, etc) but how can i cycle through the whole universe? ^^

Edit: replaced with get ship array and it works now ty^^

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