[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

Coruskane
Posts: 851
Joined: Fri, 13. Jun 08, 13:14
x4

Post by Coruskane »

ThisIsHarsh wrote:
Coruskane wrote:
ThisIsHarsh wrote:e.g. current player notoriety, notoriety of ship vs. sector, player fight rank, etc, etc
hmm true.
Point Man
Posts: 22
Joined: Wed, 15. Sep 10, 08:48

Post by Point Man »

Currently I am in the Process of Developing a Weapon mod but I have hit a snag...When I update the Tlaser and Tbullet files within the .cat file they do not update...They save and when reopened the saved changes are there but the VFS does not seem to update ingame and the Weapons are still the same..Why is That?

Note: I am using X3 Editor 2
User avatar
Ketraar
EGOSOFT
EGOSOFT
Posts: 12187
Joined: Fri, 21. May 04, 17:15
x4

Post by Ketraar »

Seams you are not extracting the files. The Editor does not save files within cats.

Editing Terran Conflict - The Very Basics by enenra

MFG

Ketraar
Image
Point Man
Posts: 22
Joined: Wed, 15. Sep 10, 08:48

Post by Point Man »

Thanks for the quick reply, should have looked a bit harder for tuts :P

EDIT: Found what was wrong silly me The entries for bullets start at 0 and the Tdebugger starts at 2 just had to take 2 off each entry that I added and hey it worked!
Last edited by Point Man on Thu, 16. Sep 10, 02:55, edited 2 times in total.
lettuceman44
Posts: 120
Joined: Sat, 3. Jan 09, 03:57
x3tc

Post by lettuceman44 »

Does someone know of a mod that makes ships quicker?

Also, is it even a good idea to have quicker ships? Also what is the max speed the ai can handle?
User avatar
TrixX
Posts: 2035
Joined: Wed, 18. Aug 10, 14:28
x4

Post by TrixX »

Actually I am doing some research into that. I am going to put low poly and untextured models of the ships at +10% size in the scene files. See if that aids with the problematic autopilot...

Cadius uses separate ship collision files similar to this, but his scene files work without the base model being present, so I'm guessing that is the collision field for the ship. Increase the size of the collision field and reduce the polies and it may just solve the issues with autopilot and IS suicides on Solar Panels...
"If you’re not prepared to be wrong, you’ll never come up with anything original."
Sir Ken Robinson
lettuceman44
Posts: 120
Joined: Sat, 3. Jan 09, 03:57
x3tc

Post by lettuceman44 »

Interesting........in theory it seems plausible as the model itself isn't as complex, although I don't see how an increased collision field would help?
Wouldn't that make it so the ai would go more bonkers as it would collide with things from further away?


Also, uh, I tried looking for an answer, but just couldn't find it. How do you spawn ships in game using the editor?
User avatar
Carlo the Curious
Posts: 16999
Joined: Mon, 5. Mar 07, 22:03
x4

Post by Carlo the Curious »

In the SE? create ship.
lettuceman44
Posts: 120
Joined: Sat, 3. Jan 09, 03:57
x3tc

Post by lettuceman44 »

Thank you so much!. Oo, bookmarking that site too :P.
Thanks again! :D
User avatar
TrixX
Posts: 2035
Joined: Wed, 18. Aug 10, 14:28
x4

Post by TrixX »

Actuall the Fleet Collision Fix mod worked similarly to this except instead of making the collision field bigger (in the scene file) it made all the ships tiny and redid the scene positioning of the emissive parts to compensate. This made all fighters about 10% of current size (screwing up sound and so on) but also made them able to fly in squadrons and avoid crashing easily. I am just reversing the idea and increasing the collision box itself so formation flying and solar suicides are less common (after FCF broke my first game :( )
"If you’re not prepared to be wrong, you’ll never come up with anything original."
Sir Ken Robinson
Coruskane
Posts: 851
Joined: Fri, 13. Jun 08, 13:14
x4

Post by Coruskane »

Hello,

I am having some problems with a global variable and arrays:

Code: Select all

* Update reference global variable with this new ship type we have found
$Lib.Ships.ArraySize = size of array $Lib.Ships
inc $Lib.Ships.ArraySize =
resize array $Lib.Ships to $Lib.Ships.ArraySize
$Lib.Ships[$Lib.Ships.ArraySize][0] = $ship.Ship
$Lib.Ships[$Lib.Ships.ArraySize][1] = $ship.Power.Max
$Lib.Ships[$Lib.Ships.ArraySize][2] = $ship.Power.Lasers
$Lib.Ships[$Lib.Ships.ArraySize][3] = $ship.Power.Engines
set global variable: name='plugin.Cor.SS.Lib.Ships' value=$Lib.Ships

I suspect that I am either instancing a 2d array wrong, or I am incorrectly adding arrays to a global variable.

I would appreciate you having a look..tearing my hair out :)

The full script is attached https://www.humyo.com/FWQbYxl/Public/a. ... tvIczaztqE
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

resize array $Lib.Ships to $Lib.Ships.ArraySize
$Lib.Ships[$Lib.Ships.ArraySize][0] = $ship.Ship
$Lib.Ships has now $Lib.Ships.ArraySize elements, which means that the last element is $Lib.Ships.ArraySize - 1.
Thus you try to assign to a array element which does not exist.

Additionally $Lib.Ships[$Lib.Ships.ArraySize][0...3] does not simply exist, but you have to explicitly put an array there.

I'd do it like this:

Code: Select all

$new.Ship = create new array, arguments=$ship.Ship, $ship.Power.Max, $ship.Power.Lasers, $ship.Power.Engines, null
append $new.Ship to array $Lib.Ships
Greetings,
ScRaT
mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren »

I would be tempted to do it this way to avoid the whole "size starts at 1" and "index starts at 0" thing.

Code: Select all

* Update reference global variable with this new ship type we have found 

$new.ship.array = array aloc: size = 4

$new.ship.array [0] = $ship.Ship
$new.ship.array [1] = $ship.Power.Max
$new.ship.array [2] = $ship.Power.Lasers 
$new.ship.array [3] = $ship.Power.Engines 

append $new.ship.array to array: $Lib.Ships

set global variable: name='plugin.Cor.SS.Lib.Ships' value=$Lib.Ships 
EDIT:
Beaten by ScRaT_GER


MarCon
Coruskane
Posts: 851
Joined: Fri, 13. Jun 08, 13:14
x4

Post by Coruskane »

ok, thanks. Good stuff

@ScraT:
ScRaT_GER wrote:
resize array $Lib.Ships to $Lib.Ships.ArraySize
$Lib.Ships[$Lib.Ships.ArraySize][0] = $ship.Ship
$Lib.Ships has now $Lib.Ships.ArraySize elements, which means that the last element is $Lib.Ships.ArraySize - 1.
Thus you try to assign to a array element which does not exist.
whoops! n-1 coming 'atcha.
Additionally $Lib.Ships[$Lib.Ships.ArraySize][0...3] does not simply exist, but you have to explicitly put an array there.
Hmm, so to extract a global variable of Array type I first have to instanciate an array within which to place the extracted array? I didn't realise X was slightly-strongly-typed :)..assumed it would make the datatype of the new variable, $Lib.Ships, the same as the data it is receiving.

Well, that is good in a way. I prefer explicit language...fewer headaches and unexpected errors. (Ruby is the devil's language...:D)
I'd do it like this:

Code: Select all

$new.Ship = create new array, arguments=$ship.Ship, $ship.Power.Max, $ship.Power.Lasers, $ship.Power.Engines, null
append $new.Ship to array $Lib.Ships
Wouldn't that make a 4 dimensional array?

And to be able to find the relevant ship's array, wouldn't I need the global variable to have an index column comprised of the ship type, with the x column comprised of the references to the nested array? Therefore 2d array is minimum for the global?

@Mark:
mark_a_condren wrote:I would be tempted to do it this way to avoid the whole "size starts at 1" and "index starts at 0" thing.

Code: Select all

* Update reference global variable with this new ship type we have found 

$new.ship.array = array aloc: size = 4

$new.ship.array [0] = $ship.Ship
$new.ship.array [1] = $ship.Power.Max
$new.ship.array [2] = $ship.Power.Lasers 
$new.ship.array [3] = $ship.Power.Engines 

append $new.ship.array to array: $Lib.Ships

set global variable: name='plugin.Cor.SS.Lib.Ships' value=$Lib.Ships 
So you are saying have a unique array for each ship, with the global variable array simply referencing each array as opposed to what I was trying (and failing to do) which was have a multi-dimensional global array within which all the elements I want will sit as-is.

In that case, what will the 1-d array actually have as its data? Won't its [y][0] values be the name of the array placed there? i.e. [0][0]=$new.Ship.Array?

If that is the case, then how can I extract the correct index from the global variable, when knowing only $Ship.Type?
EDIT:
Beaten by ScRaT_GER
Goodie...More stuff for me to thiink about :)

I undestand multi-dimensional arrays, because I understand matrices. I would search the [n][0] values for the $Ship.Type, then extract the corresponding [search result][0...Xn-1] elements of info.

However, I am not sure I understand nested arrays :P..time to experiment :D

Thanks you two, apologies for the long reply.
Point Man
Posts: 22
Joined: Wed, 15. Sep 10, 08:48

Post by Point Man »

How do I make a ware run a script....I mean When a ware is in the cargo bay of the ship make it run a script constantly? I can't figure out what to use (Trying to make a Shield regenerator that regens 5% every 20 secs). I got the script down and working but only runs once...and that brings me to my second question how do I get the script running multiple times?

Sorry bout the newby questions but only just got into scripting and run outta tuts to follow so trying my own crap now!

Any help you could give to get me started on it would be nice

Cheers

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

Post by ScRaT_GER »

I didn't realise X was slightly-strongly-typed
The type system of X is like the one in Python. You can assign any value to any variable, but every variable has a certain type at every time.
Wouldn't that make a 4 dimensional array?
No, it's actually the same thing mark_a_condren does, but a bit more compact.
You could reference the $ship.Power.Max of the 10th ship in $Lib.Ships by writing $Lib.Ships[9][1] - so it's two dimensional.
And to be able to find the relevant ship's array, wouldn't I need the global variable to have an index column comprised of the ship type, with the x column comprised of the references to the nested array?
You could do a linear search through all first indices or you could use two arrays, one holding the ship types, the other one the values.
However, I am not sure I understand nested arrays
Nested arrays ARE mutli-dimensional arrays. An array of arrays is like a matrix and is two dimensional. An array of arrays of arrays is three dimensional, like an array of matrices.
I got the script down and working but only runs once...and that brings me to my second question how do I get the script running multiple times?
Use a loop:

Code: Select all

while ($someConditionIsTrue)
  * Do something 
end
Greetings,
ScRaT
mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren »

Point Man

To expand on ScRaT_GER's reply, you could do something like,

$current.shield.percent = $target.ship get shield percent

while $current.shield.percent < 100

| Add the required amount of shield percentage

|@ = wait 12000 ms

| $current.shield.percent = $target.ship get shield percent
end

This would loop every 20 seconds adding the required shield amount until the shields are back to 100%

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

Post by ThisIsHarsh »

No help for my query before, so here it is again:

Anyone know any resource or simple method whereby I can obtain the exact notoriety gains/losses caused by killing enemy/friendly ships?
There are 10 types of people in the S&M forums - those who understand binary, and those who don't.

Black holes are where God divided by zero.
Point Man
Posts: 22
Joined: Wed, 15. Sep 10, 08:48

Post by Point Man »

Thanks for the replies it works...damn it's so obvious...now anyway :P

EDIT: I still don't know how to make the item have to be in a ship for it to work though....any ideas?
Coruskane
Posts: 851
Joined: Fri, 13. Jun 08, 13:14
x4

Post by Coruskane »

Harsh, just to confirm; you mean before the event?

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