[X3LU] Script Question, find nearest enemy based from station

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

Post Reply
Wanabe
Posts: 82
Joined: Wed, 26. Dec 07, 08:05
x4

[X3LU] Script Question, find nearest enemy based from station

Post by Wanabe » Thu, 25. Jun 15, 10:46

In developing my mod to enhance Phanon from LUV I just recently noticed that their station monitor script only scans for player ships which can lead to a fun situation of them feeding the OCV several delicious TS treats.

I thought I'd make use of "find nearest enemy ship: distance=x, class=y" (custom command from LUV) to find a nearest enemy instead of doing a separate scan for each race but it seems that it may not work when based from a station.

I also tried some alternatives for finding enemies. I copied my lines below. Only enemy 2 and enemy 4 return a value.

Does anyone know what range the "find nearest enemy ship in range: class=z" scans within when based from a station? If it's a static number and it's a high enough range I'm thinking maybe that will be okay. Otherwise, it probably won't be *too* bad of a performance loss to just use the find ship command twice (for player/OCV) because it only needs to check that when traders are required for a station which isn't very often at all.

Thanks.

Code: Select all

* test: only enemy 2 and 4 return OCV OX
$Enemy=[THIS]->find nearest enemy ship: distance=40000, class=[Moveable Ship]
$Enemy2= find ship: sector=[SECTOR] class or type=[Moveable Ship] race=[OCV] flags=[Find.Nearest] refobj=[THIS] maxdist=40000 maxnum=1 refpos=null
$Enemy3=[THIS]->find nearest enemy ship: max.dist=40000
$Enemy4=[THIS]->find nearest enemy ship in range: class=[Moveable Ship]

User avatar
Joubarbe
Posts: 4796
Joined: Tue, 31. Oct 06, 12:11
xr

Post by Joubarbe » Thu, 25. Jun 15, 19:49

Code: Select all

$Enemy2= find ship: sector=[SECTOR] class or type=[Moveable Ship] race=[OCV] flags=[Find.Nearest] refobj=[THIS] maxdist=40000 maxnum=1 refpos=null 
Why don't you use this flag instead :

Code: Select all

$flag = [Find.Nearest] | [Find.Enemy]
And put "null" into the race parameter ?

But I'm not sure of what you're trying to achieve here.

Wanabe
Posts: 82
Joined: Wed, 26. Dec 07, 08:05
x4

Post by Wanabe » Fri, 26. Jun 15, 02:00

Haha, yeah derp you're right that'll do the trick I'm sure. Brain fart I guess. thanks dude.

Post Reply

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