Finally, a proper way to control job ship spawning for sector takeover scripts?

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

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

Finally, a proper way to control job ship spawning for sector takeover scripts?

Post by ThisIsHarsh »

I've been doing some playing around to find the best way for implementing sector takeover in my military base revamp script.

Turns out that whenever a ship spawns it fires SIGNAL_CHANGESECTOR. This alone isn't enough, because, of course, the ship could just be changing sector, so you have to check "get flight time" is 0. However, again this isn't enough, since when a ship undocks it fires SIGNAL_CHANGESECTOR and its flight time is 0. But if a ship is undocking "get current action" returns ACTION_START_IN_STATION, whereas when spawning it returns ACTION_NONE.

So in summary, we can check for ship spawning the instant it spawns by:
  1. Attaching a secondary signal to SIGNAL_CHANGESECTOR.
  2. In the signal script check "get flight time" is 0.
  3. and also check "get current action" is ACTION_NONE.
Notes: I noticed these conditions are met for when Fighter Drones are launched, so watch out for that (i.e. make sure to 'remove secondary signal' for Drones). Also, I ran the same tests for station spawning (tested every single signal to see if it would fire when spawning a station) and nada, so stations must be handled the old fashioned "brute force" way.

I haven't done extensive testing (just SETA for 5 mins or so) to see if these three conditions can occur when a ship does anything else other than spawning. Does anyone know of any other conditions, or is this finally a nice clean way to stop ships spawning in captured sectors (either by destroying instantly or moving instantly to a better sector)?
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.
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Why not just the equiping script of the job if you want to get more control over the spawn locations? The script is defined in the job file, and is "usually" used to equip a ship, but it's just a script that is fired after the ship is created, so you should easily be able to do
-> move into environment, set xyz etc. in the equip script.
djrygar
Posts: 1842
Joined: Mon, 10. Aug 09, 02:09
x3ap

Post by djrygar »

this thing works just fantastic

I'm going to use it in IR right away

spent several hours yesterday testing in with different things and it's amazing



s9ilent:

not all ships are spawned by jobs
there are cases when engine spawns ships directly bypassing jobs
(change sector owner to Khaak and wait 20-40 seconds and you will see for yourself)
djrygar
Posts: 1842
Joined: Mon, 10. Aug 09, 02:09
x3ap

Post by djrygar »

I have other idea how to use it:

it could be used to create jump-flash effect for newly spawned ships

would require 3 custom object containing this effect that could be spawned at ship position with disabled collision and then removed

(maybe its even how ES does it? )
User avatar
Trickmov
Posts: 1431
Joined: Wed, 7. Nov 07, 19:48
x3tc

Post by Trickmov »

Great thing :D

I didn't know, that SIGNAL_CHANGESECTOR is fired during spawning, will also include this into STO.

Using a loop to check and destroy all ships in the sector is somewhat ineffective ;)


Thanks a lot :)

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