[REQ] Proximity Alert

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
Grimm Spector
Posts: 137
Joined: Thu, 23. Oct 08, 17:06
x3tc

[REQ] Proximity Alert

Post by Grimm Spector » Tue, 28. Oct 08, 17:28

We need a proximity alert feature script for player ships that will have a user configurable list of ship types ie.; Stations, Asteroids, M6, M1, M5 etc. that can each be toggled on or off and a user settable range, when an NPC ship that it's one of your own ships comes within that range we should get a verbal warning such as "Proximity Alert" or "Collision Warning" and a written warning indicating the name, class and speed of the approaching ship, maybe in Red if it's an enemy and Blue if it's neutral. This should have a hotkey to toggle it on/off in combat...

Can anyone do this? :) it'd keep me from being plowed over by the ninja silent TLs while sitting in system all the time :(

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

Post by s9ilent » Wed, 29. Oct 08, 00:21

It is do-able, but very in-efficient (i.e. It'll burn up lots of computing power)

The main reason is that distance has a square root in its equation, which means it essentially does maths like 20 times until it gives the correct distance. Then it'd have to do a distance check on every ship in the sector, then asteroids, and debris etc.

And then I'd assume you'd want to run this proximity check fair frequently (Every second? few seconds? a couple times a second?).

And of course, when running seta x10, it does 10x as many checks.


Now i'm running on a... AMD64 3000 (which is a 2Ghz equiv) with 2gb of ram (sadly running at 2700, ie ddr 333, dual channel). And when I wrote something similar, I almost froze my computer when I ran it on 15 ships at once. It went from a smooth 40+ fps, to about 0.5 fps.
Now I'm sure your saying yeh I'll just run it on 1 ships. But.. if you had that one ship on seta, it would be like running it on 10 ships. So it'd give you like 2 fps..



So in short, yes its totally do able.
But, it will cook your computer.
And even if you have a fast computer, its still not advisable as all apps will tend to run at 100% any way.
And lastly, and most importantly, tbh, its easier just to look, or if your just idle seta-ing, seta next to an asteroid/station, or run the command idle and seta, as all flight scripts have collision avoidance.


Presumably the game's stock collision avoidance system is more efficient as it runs seamlessly, but there is no known way of getting into it.

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22227
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Wed, 29. Oct 08, 00:25

for ships, you can just use a single command, 4 times a second, and u should have no problem with performance

Code: Select all

dist = [THIS] -> size of object
dist = dist + 500
$ship = find ship: sector=[SECTOR], maxdist=$dist, refobj=[THIS]
can repeat the same for asteroids, althou i wouldn't both with stations, especially terran ones, as thier collosion bubble is huge

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

Post by s9ilent » Wed, 29. Oct 08, 00:37

Whoops... Cycrow is right, (The reason why mine lagged, -i completely forgot abotu it- was that I made mine check 100 times a second, across those 15 ships).

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22227
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Wed, 29. Oct 08, 01:46

s9ilent wrote:Whoops... Cycrow is right, (The reason why mine lagged, -i completely forgot abotu it- was that I made mine check 100 times a second, across those 15 ships).
100 times a second is never good :P

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

Post by s9ilent » Wed, 29. Oct 08, 02:12

Hey it was apart of my hyperspace (like slipstream) script. And for smoothness and dont kill-me-ness I thought it be wise to do anti collision at every tic forward (10'ms)

Any way, needless to say, after that... one bad test run... I canned it, and instead I just use the games collision avoidance instead. I run the hyperspace separately, and if the ship tries to turn, then i kill it. (I think I said a tolerance of up to 200 rotation units... although I have no idea any more..)

Grimm Spector
Posts: 137
Joined: Thu, 23. Oct 08, 17:06
x3tc

Post by Grimm Spector » Wed, 29. Oct 08, 03:18

Cycrow you're a genius, besides you don't have to check every second, an object shouldn't be so close to you that you need to check every second, every few should be enough, I mean it checks scanner ranges as it is, it can't be too difficult, I don't suppose Cycrow could whip together that script into something I could use? :)

User avatar
corhen
Posts: 338
Joined: Thu, 16. Oct 08, 08:45
x3tc

Post by corhen » Wed, 29. Oct 08, 23:29

i would like a auto-distance

would it be possible to run it, on the 5 closest objects?

you could further reduce load a distance limit, like 200M (presumably if you are worried bout a collision, you aren't running at 200M/S

Im running a Quad core, a Q6600 (2.4x4) 4 Gb of ram (ddr 1066) so i have plenty of calc's per second.

Khaak_Slayer
Posts: 403
Joined: Sun, 18. Apr 04, 17:04
x4

Post by Khaak_Slayer » Thu, 30. Oct 08, 02:23

I'd love this. When in my new Split Elephant, i am forever plowing over unfortunate freighters when exiting a gate. It's so hard to tell where ships are in relation to your own capital ship at times. Also at times i forget to hit the boost extension when exiting gates, so i kind of drift slowly a short distance, and get rammed in the engines by another freighter/ship also exiting the gate, so they eat my hull plating before they can swerve. Or i just fly along not really paying attention to where i'm going and run over multiple smaller ships. Whoops.
Rawr.

Grimm Spector
Posts: 137
Joined: Thu, 23. Oct 08, 17:06
x3tc

Post by Grimm Spector » Thu, 30. Oct 08, 21:33

Khaak_Slayer wrote:I'd love this. When in my new Split Elephant, i am forever plowing over unfortunate freighters when exiting a gate. It's so hard to tell where ships are in relation to your own capital ship at times. Also at times i forget to hit the boost extension when exiting gates, so i kind of drift slowly a short distance, and get rammed in the engines by another freighter/ship also exiting the gate, so they eat my hull plating before they can swerve. Or i just fly along not really paying attention to where i'm going and run over multiple smaller ships. Whoops.
I'm more worried about being the one run over :P

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22227
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Thu, 30. Oct 08, 21:45

corhen wrote:i would like a auto-distance

would it be possible to run it, on the 5 closest objects?

you could further reduce load a distance limit, like 200M (presumably if you are worried bout a collision, you aren't running at 200M/S

Im running a Quad core, a Q6600 (2.4x4) 4 Gb of ram (ddr 1066) so i have plenty of calc's per second.
the performance problem mentioned by s9ilent, is that the mathimatical calculation to compute the distance between 2 objects requires a square root, which is quite taxing on the CPU, so using an excessive of these can slow things down.

the only way to find out what the 5 closest objects are is to run this calcutation on every ship in the sector. So the number of ships you use or the distance you choose to limit it to would make absolutly no difference to the performance problem, as you still need to check every ship before you know they are outside of your limit.

infact, having a bigger limit can actually help. The bigger the limit, the more likly a ship would be detected. If one is detected, it could simply quite of the loop without needing to do all ships. So the more chance of finding a ship the more chance the loop can be cut short.

however, this problem only exists if you try to check too often. Im talking ms here.

so a few times a second really isn't a problem, its when you start trying to check 100 times a second to be really acurate, which tbh, isn't required


im abit busy right now, but if i get chance ill see if i can make the script, should only take me a few mins to make it

Grimm Spector
Posts: 137
Joined: Thu, 23. Oct 08, 17:06
x3tc

Post by Grimm Spector » Fri, 31. Oct 08, 16:47

Cycrow wrote:
corhen wrote:i would like a auto-distance

would it be possible to run it, on the 5 closest objects?

you could further reduce load a distance limit, like 200M (presumably if you are worried bout a collision, you aren't running at 200M/S

Im running a Quad core, a Q6600 (2.4x4) 4 Gb of ram (ddr 1066) so i have plenty of calc's per second.
the performance problem mentioned by s9ilent, is that the mathimatical calculation to compute the distance between 2 objects requires a square root, which is quite taxing on the CPU, so using an excessive of these can slow things down.

the only way to find out what the 5 closest objects are is to run this calcutation on every ship in the sector. So the number of ships you use or the distance you choose to limit it to would make absolutly no difference to the performance problem, as you still need to check every ship before you know they are outside of your limit.

infact, having a bigger limit can actually help. The bigger the limit, the more likly a ship would be detected. If one is detected, it could simply quite of the loop without needing to do all ships. So the more chance of finding a ship the more chance the loop can be cut short.

however, this problem only exists if you try to check too often. Im talking ms here.

so a few times a second really isn't a problem, its when you start trying to check 100 times a second to be really acurate, which tbh, isn't required


im abit busy right now, but if i get chance ill see if i can make the script, should only take me a few mins to make it
thanks Cycrow, you're the best :)

Post Reply

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