[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

User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Changed which value from 1 to 10?
I'm going to assume you changed the length and not the width and height?

The rapid box and the visible bullet are two separate things.

The rapid box is used to determine if it hits or not. The visible bullet is just eye candy.
rusky
Posts: 458
Joined: Sun, 4. Jan 09, 17:17
x4

Post by rusky »

I changed the width and height, i assumed the length didn't affect what i was going for.

I am interested in both the hitbox and the eye candy being thicker, but neither was after the change. Tried shooting a beam really close to one of my ships for testing and i did not hit the ship still.
Coruskane
Posts: 851
Joined: Fri, 13. Jun 08, 13:14
x4

Post by Coruskane »

@Rusk:

if it uses the standard X unit for length (whatever that is: the same oen used for missile explosion radius, get object size and so on) then 10 is actually still really very small (a firestorm has 100000).

Try larger...:D
rusky
Posts: 458
Joined: Sun, 4. Jan 09, 17:17
x4

Post by rusky »

:o ... ook, well I'll try using something crazy like 10.000.000 and see if there's any difference.
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Interesting fun facts
(I am working on an xml deserializer, and possibly a serializer in x3)


1. It is possible to pass a more or less fully qualified xml string into X3 (doing conversion on special chars where needed, c# does this internally, thank god...)

2. The game is entirely capable of holding large strings read from text files. And you can perform operations on them. (e.g. substring, length)

3. You can crash your game if you logbook, or subtitle, text that is too long
e.g. 48k characters...


I will experiment more and try to find a max char limit

The game crashes at exactly 10,000 character's (when writing that to the log/subtitles)
9,999 is totally cool thou.
(I do find this crash to be unusual thou given the some what ... artificial number)
User avatar
peroxyde
Posts: 2230
Joined: Sun, 2. Apr 06, 00:12
x3tc

Post by peroxyde »

ScRaT_GER wrote:* $someVariable is a variable, which can be null (!)
$num = 12 + $someVariable
Aaah... This explain why i got strange result sometimes...
On turret script, which are frozen OOS and réinit IS, some variable become null and causes bugs. Now i know why! Thanks!

====================================================



I would like to create a turret commande which is available only if One laser type is mounted. (industrial repair laser)

I know how to add the command on spécific ship only with this command:

Code: Select all

042   |set script command upgrade: command=REPARER_FLOTTE  upgrade=[TRUE]  script='AA.Pero.TRep.M1.Type.Check'
043   |global script map: set: key=REPARER_FLOTTE, class=M1, race=Player, script='AA.Pero.Tourelle.Reparation', prio=0
044   |global script map: set: key=REPARER_FLOTTE, class=TM, race=Player, script='AA.Pero.Tourelle.Reparation', prio=0]
And the check script :

Code: Select all

Script AA.Pero.TRep.M1.Type.Check
Arguments
    * 1: Ship , Var/Ship owned by Player , 'Cuirassé'

001   skip if not $Ship -> is of class TM
002   |return [TRUE]
003   
004   if $Ship -> is of class M1
005   |skip if not $Ship -> is of type 3C Mobile
006   ||return [TRUE]
007   end
008   return [FALSE]
And it work, command appairs only on Goner M1 and all TM race.

But i want that the commands are grayed (available but Deactivated ) when other lasers type are also installed on the same turret, without deactivated the same command for the nearby turret if the lasers which are installed on it are correct

I try somethings like this :

Code: Select all

Script AA.Pero.T.Rep.OrdreDispo
Arguments
    * 1: Ship , Var/Ship owned by Player , 'Vaisseau'
001   $Task = get task ID
003   $NbLaser = $Ship -> get max. number of lasers in turret $Task
004 
005   $Laser.dispo = 0
006   while $NbLaser
007   |$laser = $Ship -> get laser type in turret $Task at slot $NbLaser
008   |skip if not $laser != Laser de Réparation Industriel AND $laser != null
009   ||return [CmdConCheck.Disabled]
010   |skip if not $laser == Laser de Réparation Industriel
011   ||inc $Laser.dispo = 
012   end
013   skip if not $Laser.dispo != 0
014   |return [CmdConCheck.Available]
015   return [CmdConCheck.Disabled]
But i don't know how to connect the script to te turret and not to the ship.
Already that :

Code: Select all

set script command upgrade: command=REPARER_FLOTTE  upgrade=[TRUE]  script='AA.Pero.TRep.M1.Type.Check'
don't ask for the 'cuirassé' argument and work all the same...

Someone know how to do :?:
[ external image ]
"On apprend en faisant des erreurs, mais le problème c'est qu'en explosifs, l'erreur est fatale." Aldébaran v10
[ external image ]<-- Clef Des Toilettes Privées Du Forum Français décernée par Thoto le 23/06/07
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Bonjoir mon ami!

Ah, this is something I've wanted to do for a long time, the repair laser turret command...

But alas, I do not know how. :(

:P
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

For available and greyed you need to do.......

set script command upgrade: command=<Object Command/Signal> upgrade=<Var/Ware> script=<Script Name>

And that script ... does something... If you look at the stickies and specifically the older stickies (i.e. x3r and x2) it will have more info



I've mostly forgotten how, but this is how my script does it


Setup script:

011 $ware = Trade Command Software MK2
012 $cmd = COMMAND_TYPE_TRADE_42
013
014
015 set script command upgrade: command=$cmd upgrade=$ware script='plugin.sfm.global.ship.cmdcheck'
016 set ship command preload script: command=$cmd script='plugin.sfm.ship'
017
018 global script map: set: key=$cmd, class=Little Ship 2133, race=Player, script='plugin.sfm.ship.loop', prio=0
019 global script map: set: key=$cmd, class=M6 2026, race=Player, script='plugin.sfm.ship.loop', prio=0
020 global script map: ignore: key=$cmd, class=Fighter Drone (object class), race=$race
021 global script map: ignore: key=$cmd, class=Freight Drone 2092, race=$race
022


cmd check script

args 0 $ship
args1 $ware
001 if $ship == [PLAYERSHIP]
002 |$ret = null
003 else
004 |$ret = [CmdConCheck.Available]
005 end
006
007 return $ret


And there are many more cmdconcheck's that can be bit-or'ed together
i.e. aaa|bbb|ccc|ddd|ee
And the one your after is called like disabled or something
(I return null as I want it to be not visible at all)

(Your after whats on line 15)
User avatar
peroxyde
Posts: 2230
Joined: Sun, 2. Apr 06, 00:12
x3tc

Post by peroxyde »

I will see older stickies, perhaps i will find something.
Since the problem is not the use of this script commande (on your line 15 which is on my line 42) but the check script.

I want to separate turrets. But in the Check script, $Task = get task ID don't give me the turret ID.
So, for now, the best i can do is greying all turret if only one have a destructive laser. :/
EmperorJon wrote:Ah, this is something I've wanted to do for a long time, the repair laser turret command...
The command itself is working 'perfectly' (IS and OOS). You will see it soon in the New Horizon mod in a couple of day, as soon as i've finished this script!
Of course i can still improve the script IS (targeting ship who is in turret field of vision) But i'm already glad of what it do.


[edit]
Nothing found on olds topics. At best just what is already done, but nothing on greying command turret separetly.
016 set ship command preload script: command=$cmd script='plugin.sfm.ship'
I don't know how this commande work, but it's perhaps the solution...
I will try what $Task = get task ID return in a preload script, and if i could transmit the result to the check script.

Thank for helping me, i hope not detroy Shakespeare language to much... :)
[ external image ]
"On apprend en faisant des erreurs, mais le problème c'est qu'en explosifs, l'erreur est fatale." Aldébaran v10
[ external image ]<-- Clef Des Toilettes Privées Du Forum Français décernée par Thoto le 23/06/07
FriedTrix
Posts: 63
Joined: Fri, 13. Jan 06, 03:12
x4

Post by FriedTrix »

Could be taken as a request but firstly as a question

Is it possible to create a script that would use turrets ship to fire in a barrage pattern? Kind of looking if there are 2 or more ennemy fighters in close proximity and then just make the ships gun -not- target/fire at any of these ships but fire something like 10-20 burst in a grid pattern in the direction of these? (Targeting empty space instead of object)
Coruskane
Posts: 851
Joined: Fri, 13. Jun 08, 13:14
x4

Post by Coruskane »

not to my knowledge no. All turret commands require a defined target.

Besides, the likelihood of a hit without turret tracking a single target is sooooo small.
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Not directly no, what you can do thou is you can create a dummy object and fire at that instead.
And there is also what Coruskane said. The idea of a barrage hitting anything in a 3d space is pretty slim. It is hard enough for turrets to hit ships period, let alone when they aren't firing directly at a target.
Darkone8752
Posts: 58
Joined: Tue, 4. May 10, 23:07
x3tc

Post by Darkone8752 »

Maybe a stupid question, but is there a way to do a performance analysis on X3 scripts like you would with a program? That is, at some point in my game where it's lagging incredibly badly, could I do something to see how many scripts, what scripts, or how mjuch time a script is using? Would be greatly useful in figuring out why 3 or so capships are lagging sometimes but not others.

Edit: As o the above, this is actually because they're too accurate. It's a rough problem in Naval shuffle with beam weapons for example, that they'll miss very nearly due to gentle manuevering of either ship. Typically, in a low accuracy situation, you want to saturate the target with shots: Rather than aiming at where they will be, aim at where they could be. Compare the hit rate of a single FBC in NS to the hit range of 6 of them, each with a tiny innaccuracy. The solution is either to make the weapons slower and more destructive (it doesn't matter if you miss several antifighter shots when one good hit blows off half their health!) or faster with shorter "beam" durations, so that the randomizer can trigger more often - closer to projectile weapons and their small spread + high fire rate 'cone'.
Coruskane
Posts: 851
Joined: Fri, 13. Jun 08, 13:14
x4

Post by Coruskane »

yes 'sort of', TC has an inbuilt listing of all the scripts on stack. It will count how many times they are called/executed. This gives a very very rough idea: a script called 10 times will almost certainly have less impact than a script called 200000 times.

*However*, unfortunately it gives no indication of how many cycles have been required for each execution of the script. So, a script that exits after only a few functions will have much less impact than a major script but there is no built in way of saying so.

In addition we, as scripters, dont really have much info on how the functions we are able to call are actually executed and so have no real idea over how much processing is involved for each. E.g. the processing required for a 'get object size' function (essentially calling a method/function that has been hardcoded)

As a weak workaround: Gazz wrote a little lib script to return the engine fps to quite a degree of accuracy. You could use this to benchmark the performance impact of some scripts.

And to specifically answer your concern over a few specific ships: try and see what tasks are running on the ships (by tasks I dont mean commands; e.g. not "Action avoiding" in the ship info panel but rather script tasks on stack for the ship)
Darkone8752
Posts: 58
Joined: Tue, 4. May 10, 23:07
x3tc

Post by Darkone8752 »

Specific case is IR mod with response ships (fighters and capitals) active in a system with 3 teladi huge ships all hostile. Looking away is smooth, but looking at the ships temporarily lagged up. Will need to test more as it could be me hitting my free RAM limit of about 3.3gigs. It is certainly not graphical either. It could be a comination of MARS + IR's Improved Carrier feature.
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Given that you indicated that looking at them is causing slow downs, it is more likely a graphics issue and not a script issue. (Unless you specifically made your script do many more things, when ships are in front of you)

What makes you think it is not graphical?
Darkone8752
Posts: 58
Joined: Tue, 4. May 10, 23:07
x3tc

Post by Darkone8752 »

Mostly because this game is very very light graphically for my card. I get better performance on higher settings than low ones :o Second, unless this game pauses the engine when waiting on a frame to render...

Going to boot up now, and see if my RAM was just full. Bloody game eats so much o.o

edit: Yep, appeared to be RAM related. I just booted up into the sector, and while it lagged once initially when looking, it now smoothly loads the ships into view.
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

The game does pause to render frames. I used to run x3r on a VERY old geforce 3 (min requirements is like gf 4 or 5+ or something). The game would literally go to about 1/10th the speed and render a frame about every 2 seconds. The game is single threaded so it has to complete one action before it can move on.


Are you sure it isn't just that when you first look at a ship it lags?
As I know with AQC I find it actually makes performance worse for me, as it keeps loading the different quality textures and models. (as loading the resources, does seem to tax the computer more heavily than continuing to render existing stuff)
Darkone8752
Posts: 58
Joined: Tue, 4. May 10, 23:07
x3tc

Post by Darkone8752 »

As far as I can tell, it has to do with running out of RAM after playing for a while. Maybe scripts are lowering my 'buffer' and I'm just noticing lag that was already there now. Gonna try with medium shaders. Could also be my card's memory getting pissed, depending on how much VRAM X3 takes at high settings on 1920x1080

Edit:How do I get that list of script calls? Well, found some, but it only shows 80 each for two scripts, even though it says about 9800 are running
User avatar
TrixX
Posts: 2035
Joined: Wed, 18. Aug 10, 14:28
x4

Post by TrixX »

If you are running out of RAM and getting skipping/stuttering its more likely VRAM than normal RAM. Even if your normal RAM usage is high when looking at objects which cause a stutter is the VRAM that is getting overfilled.
"If you’re not prepared to be wrong, you’ll never come up with anything original."
Sir Ken Robinson

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