[SCR] [X3:TC/AP] [v1.9.8.12] [03/23/14] Galaxy Explorer

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
Rakeris
Posts: 407
Joined: Wed, 31. Dec 03, 04:25
x4

Post by Rakeris »

Now that I have it downloaded and checked it out, I have to say after trying several explorer and sat-network scripts this one is by far the best! Fairly simple and easy to configure and does everything I could want, even auto names the ships.

Thanks a lot!
gnasirator
Posts: 1114
Joined: Mon, 13. Dec 04, 16:15
x3tc

Post by gnasirator »

:) 8)

This is exactly, why I am doing this - making you guys happy and then reading about it :)
TestingTesting
Posts: 46
Joined: Sun, 8. Aug 04, 03:05

Post by TestingTesting »

bug in the script, assigning a homebase (says error)


also POI??? (i'm guessing "Point of Interest"?)
gnasirator
Posts: 1114
Joined: Mon, 13. Dec 04, 16:15
x3tc

Post by gnasirator »

correct guess .... every place that might be of interest gets covered by a sat (stations and gates)

by this you get an almost complete sector coverage.

What now still isn't covered, is simply not interesting ;P

@bug: I'll check it

edit: couldn't reproduce it.
could you please be a little more detailed in that bug description? OR provide me a savegame
TestingTesting
Posts: 46
Joined: Sun, 8. Aug 04, 03:05

Post by TestingTesting »

what a idiot i am, i didn't assign a homebase, the "error" word is misleading, i thought there was an error with the script, it was telling ME that i have made the "error" LOL
gnasirator
Posts: 1114
Joined: Mon, 13. Dec 04, 16:15
x3tc

Post by gnasirator »

okay, problem solved :)
User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle »

Greetings, Herr Gnasirator.

1) New game; new data on an old problem:

My Explorer just died when trying to enter Venus. Presumably, they will die whenever they try to enter any forbidden sector.

(By "forbidden sector", I mean that the sector is enemy, even though the race is friendly.)

In fact, *all* of my galaxy explorers are dead. Ten Discoverers. Ten Kestrels. Ten Spitfyres. A new Discoverer in a new game (killed by pirate in a hostile sector). A new kestrel in Venus (Terrans are friends but I only have Mars Access with ATF).

I know that you have avoided jump drives, but I really think that the only way to give the explorers reasonable life spans is to let them jump.

Most ships that one would use for exploring are jump-capable (Discoverers, Kestrels, Spitfyres).

So... how about letting your Galaxy Explorers jump when attacked?

(There is no need to worry about ecells. They do not have to use the jump drive for normal travel (unless you want them to). The important thing is to give them the ability to jump to a safe sector.).

2) Uranus now has 16 satellites, while many of the Boron/Paranid sectors in the South West have none. :roll:

Something in the search-for-next-sector logic is weak. Not really a bug, and certainly not fatal. Yet there is room for improvement. :)

Overall, Galaxy Explorers are still a simple (and good) solution to a common problem.

(PS: I am sure that I am not the only person who wants a Junk Truck (to sell salvage). Hint, hint. You will "sell" a million of them. People just don't know how badly they want them. Yet. ;) )
gnasirator
Posts: 1114
Joined: Mon, 13. Dec 04, 16:15
x3tc

Post by gnasirator »

Hi, Dr. Bullwinkle ;)

@forbidden sectors: good point. as far as I remember, I only checked, if the sector owner's race was friendly or not.
Can a sector be hostile to me while the owner's race isn't?

I'll check this!

About jumpdrives: I'm still not sure if this would help. Keep in mind that charging the drive takes quite some time and the ship remains stationary while doing so, hence relying only on shield strength. And strong they are NOT in small ships ...

JunkTrucks, jeah still got them on my radar ... :)
Let's see!

edit: how exactly can a SECTOR be hostile to you? I can only find a method to get the relation to a ship/station OR to a race. I can't check a relation to a sector.
SO how do I find out if a sector is hostile? Do you mean that all stations inside are hostile? Or only one specific? Or a certain amount of ships? What's your definition of hostile? I need that definition so that I can tailor a proper routine.
User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle »

Examples of hostile sectors when race is friendly:

- Terran sectors begin as hostile (if you start in the Commonwealth). The hostile flags are removed as you progress through the Terran plot.

- When your race rep is low, core sectors may be forbidden while border sectors are not. Paranid do this easily -- they require something like level 3 race rep before they will allow you to enter their core sectors.

If the player ship enters a hostile sector, you receive a comm message telling you to leave.

How does a script detect a hostile sector? I do not know the quick way. Most stations and ships will be hostile, but some may not be *sigh*.

I see what you mean about the jump timer. Maybe we are thinking about ship choice the wrong way? Perhaps Kestrels are not ideal explorers. Maybe something like a Springblossom would be better? Or a Boreas. ;)

Personally, I would treat emergency jumping as a different problem than regular jumping. I would use something like Gazz's Free Jump. (Not the entire script - just the jump routine). After all, the goal of Explorers is to get around the limitations of vanilla, so why not do exactly that? (Free Jump jumps immediately, without countdown timer, and uses no energy cells. It also works in Terran sectors.)

At one point we discussed scanning for enemies within, say, 10km, and checking whether they have the explorer targeted. Then flee/jump accordingly. What happened with that? Is it too "heavy" on cpu time?

Regarding the Junk Truck, your Galaxy Traders could do it if they sold *all* of their wares before taking on new trades. It might even be easier to maintain as an option rather than as a separate script.

(and just "Bullwinkle" is fine... I actually prefer that, but the name was already taken when I joined the forum. :( However, I suppose that I started it by calling you Herr Gnasirator. :) )
gnasirator
Posts: 1114
Joined: Mon, 13. Dec 04, 16:15
x3tc

Post by gnasirator »

DrBullwinkle wrote:However, I suppose that I started it by calling you Herr Gnasirator. :) )
True ... true ... ;)

About the hostility check:
I see what you mean - but still I don't know how to trigger on exactly this kind of 'weak' hostility. That's why I meant that I need more specific information. If you could tell me that hostile is 'More than 50% of the stations hostile' that's fine. Or 'Main Trade dock of the sector hostile' or 'ALL Stations hostile' or 'Race notoriety below 3' ..... and so on.
I need to figure out a graspable situation like that. Those conditions I can trigger on.

The script can get a race notoriety to an object (me) or can get the relation of <x> to <y>, where the relation is friend, neutral or enemy and the notoriety would be just a number resulting from my standing to the race.

The jumping COULD be solved very easily:
I could start the command <this> put into environment <safe sector>. That is some kind of instant jumping, even works with the player ship and then shows the jumping warp tunnel.
But ... even though I do know you attitude about keeping it simple, I don't want to implement any new mechanisms like 'super quick safe jump' into the game as that would be considered a cheat (not only by me). So the only possible jumping solution I would be willing to implement is the regular one using ECells. And that is no use because it needs a charging time.

I'm sorry :)

I already improved the scanning, making the explrers flee, if there is just an enemy inside of 5km range (given, that the explorers max speed is below 400 m/s). That should keep most explorers alive in the usual hostile contact situations.
If the explorers enter a hostile sector though, where there are sector patrols actively pursuing them ... of course their chances of survival are - well, reduced :)

Regarding the junk trucks, jeah practically they're just mk3 traders on a rest ware selling run and returning afterwards.
Still I am a bit too lazy right now, to start a new project ... :)
But hey, why don't you just do this? I'll gladly help you and explain my code to you![/code]
User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle »

gnasirator wrote:I see what you mean - but still I don't know how to trigger on exactly this kind of 'weak' hostility.
Right. If there is no easy test for an enemy sector, then it should be possible to tune the "test for malicious intentions within range" until it works.

5km is too short, especially for fast ships. No wonder my 32 explorers are dead, you murderer!

Just kidding. Luckily, none of the pilots were my friends. :)

OoS firing begins at 3km, and an attacking Harrier travels the 2km difference in 5 seconds. Maybe less if the explorer is moving toward the attacker.

How long is the OoS jump timer?

Ten kilometers would be a better starting point (14+ seconds). Twenty km may be necessary to avoid problems when queuing at gates and stations.

In-Sector is even worse. Frigates, destroyers, and carriers have a firing range of 6km.

5km would not be enough even for a Boreas Explorer* (not that the Boreas would have to flee). :)
And [normal jumpdrive] is no use because it needs a charging time.
Normal jumpdrive works fine to protect UT's. Well, mostly fine. :) A Spitfyre, TP, or TM should be at least as safe as a TS.
Regarding the junk trucks, jeah practically they're just mk3 traders on a rest ware selling run and returning afterwards.
Exactly. And I would settle for an mk3 that sold all of its wares before taking on new trades. That way, I can grab it at any time and fill it up with junk. The only time I would even have to sell its contents would be when it is full (which is rare).
Still I am a bit too lazy right now, to start a new project ... :)
But hey, why don't you just do this? I'll gladly help you and explain my code to you!
OK, but I am handing it right back to you when I'm done. I don't want to maintain the rest of your code. :)

Where do you decide whether to do a "rest ware" sale or take a new trade?

(*) Speaking of Boreas Explorers, that would be one way to patrol without having to specifically set patrol points. Just assign Boreas Explorers to plant satellites -- it should reduce enemy numbers throughout the universe. :twisted:
gnasirator
Posts: 1114
Joined: Mon, 13. Dec 04, 16:15
x3tc

Post by gnasirator »

ok increasing the scanning range is NO problem at all.
I'll try it with 10km. But keep in mind that this range only applies to ships slower than 400m/s. Faster ones still have to get relatively close until they can recognize the hostile ship as an attacker (<hostile> get attacker is set at a range of ~3km when oos).
Maybe I'll completely change to fleeing from any hostile ship within 10km. That should protect any explorer as good as possible.

about the oos jump timer, I think it is as long as in sector, isn't it?
For big ships with reasonable amounts of shields the emergency jump really would work, that's true.
I only use fast M5 ships as explorers, for them it would be useless.

-> Maybe I could give emergency jumping to ships with at least 25-50MW shields. They could make use of it AND have enough cargo space for ecells.

And sure you may hand the junk trucks back over to me after you're done. I'll gladly look into what you wrote :)

Here's a rough outline of how the MK3s work:

1. Init (set all variables, experience)

2. while (true)
2.1 Update dynamic variables (Name, ranges, fuel amounts)
2.2 Get a trade route (plugin.autotrade.getroute)
2.3 Buy ware
2.4 Sell Ware
2.5 After trade stuff (Accounting, salary, maintenance, upgrade buying)

All of this takes place in the plugin.autotrade.main script. From there, the other scripts are launched.
And because all of this is wrapped up nicely in subroutines it is very easy to find the correct place in the script for editing :)
User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle »

gnasirator wrote:I'll try it with 10km. But keep in mind that this range only applies to ships slower than 400m/s.
Why does the speed matter?
(<hostile> get attacker is set at a range of ~3km when oos)
Oh, I did not know that. That is completely useless then. By the time the enemy reaches 3km, it will start shooting.
Maybe I'll completely change to fleeing from any hostile ship within 10km. That should protect any explorer as good as possible.
Yes, from what you say, that seems like the only good choice.
about the oos jump timer, I think it is as long as in sector, isn't it?
For big ships with reasonable amounts of shields the emergency jump really would work, that's true.
I only use fast M5 ships as explorers, for them it would be useless.
Early in the game, M5's are OK. Most sectors are reasonably safe -- that is what allows undefended TS's to be effective as UT's.

However, later in the game, when there are enemies scattered everywhere, then it becomes more important to defend your assets. Also, I play a more challenging game than vanilla, with more and stronger enemies. So the M5's simply do not work for me. I was not kidding about considering Springblossoms for my next batch of Explorers. :)

So, yeah, I think that they have to jump.

As a side note, Litcube's Phanon Corp traders exhibit several non-vanilla defense strategies with good effect. I have seen them do in-sector jumps to escape attack. They do it before I am in firing range, and they do not stop for a count down. They see me coming and then jump away. They do not jump far... maybe 10-20 km. Just enough to make chasing them difficult. If I pursue, then they jump to another sector. :)

I don't think of that as cheating at all. It is just smarter AI. Of course, they are enemies rather than my own ships.

Also, RRF ships jump without a countdown, as well.
Maybe I could give emergency jumping to ships with at least 25-50MW shields. They could make use of it AND have enough cargo space for ecells.
What are you trying to achieve with that? Are you trying to let faster ships run rather than jump? If so, then simply test for a jumpdrive. Shields should not be the requirement, because you never know how the player's game is balanced.

You did not really answer my question about where rest-ware selling is decided, but I will take a look. Then maybe I can ask a more specific question. :)
All of this takes place in the plugin.autotrade.main script.
So you went to the trouble of rewriting all of the scripts without changing their names? Curious.
gnasirator
Posts: 1114
Joined: Mon, 13. Dec 04, 16:15
x3tc

Post by gnasirator »

the original names are plugin.autotrade.sector and plugin.autotrade.local ;p
User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle »

That is what I mean.

You had the perfect opportunity to change the name to plugin.galaxy.explorer... but you did not. I just figured that you would have changed it when you had a good opportunity, since the name seemed to be a stumbling block in your Master Plan.

No matter... it works the same. :)
gnasirator
Posts: 1114
Joined: Mon, 13. Dec 04, 16:15
x3tc

Post by gnasirator »

I understand, but I only wrote about 60-70% of the code myself. The rest is original MK3 code which I rearranged. So claiming this as my new project would be unfair.

I'd rather have this as the new official MK3 script :)

Your earlier questions:
@speed: I want to achieve that explorers flee only from hostile ships which are a REAL threat and actively trying to kill them.
But that I can only find out, if the ships are coming very close. So this method is only used for very fast ships which are then still able to flee.

I wish there would be some kind of getting the enemies ship target in oos combat so that I could just scan the whole sector at once and flee as soon as any ship decides to attack the explorer, no matter what range.
But somehow I couldn't achieve this.

If you know, how to do this ... ?
User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle »

gnasirator wrote:I want to achieve that explorers flee only from hostile ships which are a REAL threat and actively trying to kill them.
But that I can only find out, if the ships are coming very close. So this method is only used for very fast ships which are then still able to flee.
Yeah, that is not going to work the way that you describe it. Not OOS, anyway. Shooting starts at 3km OOS. A patrol of two Harriers will kill any M5 before the M5 has a chance to move. If the M5 attempts to return fire it will lose.

Your flee routine has to start at longer range. I am glad that we talked about this. The children of my 32 dead Explorers will thank you for the fixes that will come from this discussion. :)
I wish there would be some kind of getting the enemies ship target in oos combat so that I could just scan the whole sector at once and flee as soon as any ship decides to attack the explorer, no matter what range.
But somehow I couldn't achieve this.

If you know, how to do this ... ?
I am still noobish at reading other people's MCSI code. What we really need is SIGNAL_TARGETED (which does not exist, AFAIK). SIGNAL_ATTACKED is too late.

Have you tried something like the following?:

Code: Select all

find nearest enemy ship: max.distance = 10000
if get attack target = [Explorer]
  Jump/Flee
else if get command target = [Explorer]
  Evade
end
I am thinking that you do not need to test for which command the enemy is running. If it is an enemy, and it is targeting the Explorer, then avoid it.

Mr Miyagi: "Best block; no be there."

The main thing, with all of this, is to have a large enough search radius that the Explorer has a chance to respond. Presumably, you will not be running this check often. If you test, say, every 5,000 ms, then you want 3km + 5 seconds + jump countdown time + some extra. That is why I suggest 10-20 km search radius. Faster ships need a LARGER radius (although 20 km should cover any possible situation).

Also, the radius may need to be larger near gates and stations, where it may take the Explorer longer to respond.

===================================================
EDIT:
I found an X3R script that does the job: SIGNAL_TARGETED

It works like my psuedocode above, except that it also tests "get command target2", which I intentionally skipped (perhaps erroneously). Also, it finds any targeting ship in range, which is better than "find nearest enemy".

In any case, SIGNAL_TARGETED is already scripted and tested. So, yeah. Go for it. :)
===================================================
gnasirator
Posts: 1114
Joined: Mon, 13. Dec 04, 16:15
x3tc

Post by gnasirator »

wow! incredible!
I'll definitely try that signal_targeted thing.

Up to now I only checked for <enemy> -> get attack target and not for get command target (2).

great input here! but this is no business for today anymore. Time say hello to mr. sandman ;)

edit: if that script works as I hope it does, is would be a great addition for the MK3 trading script as well ...
User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle »

gnasirator wrote:if that script works as I hope it does, is would be a great addition for the MK3 trading script as well ...
Yep. It was written for Mk3 traders.

It is not really a native signal, of course, so it has a timer in a loop. It tests at 30 second intervals, and within 8km range. An M5 can move pretty far in 30 seconds, and TWO M5s, directly facing each other, can cover nearly 30km in 30 seconds. So you might have to experiment with the numbers to make it reliable.

I would try a 5 second timer and 15 km to start. Then refine from there.

(The reason I suggest a 5 second timer is that OOS events happen in 5 second intervals when the player is watching the sector map. )

(Of course, longer waits will be higher performance, and there is some performance penalty for any loop, even with waits. Thirty UTs could become "expensive", performance-wise.)

Suggestion: Set the variables for the Timer and the Radius at the top of your Main script, and read the values from the t file. That way we can easily adjust the values for testing.

(Also, keeping the values in a t file would allow a modder to adjust for different ship speeds and weapon ranges).
gnasirator
Posts: 1114
Joined: Mon, 13. Dec 04, 16:15
x3tc

Post by gnasirator »

great. I'll use a 5 sec timer then. This sounds very reasonable.

For the range, why limit it? The script checks only the closest enemy anyway.

But like you said, I can of course set those values in the t-file. as you wish :)

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