[Release] Space Crowds

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: another_commander, winston

Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 602
Joined: Sun Jul 21, 2013 12:26 pm

Re: [Release] Space Crowds

Post by Astrobe »

... But before that I have to fix a few minor issues:
  • Boulders spawn with a red glow. I believe that's because by default they spawn with a high temperature as if they were just fragmented by a mining laser.
  • Traders still have a tendency to jump out of the system, which is not a consistent behavior when you're in the middle of the planet-sun lane. I tried to prevent that by giving them a random quantity of fuel, but it doesn't work well - and I don't want them to be defenseless against predators (including the player). I wonder if giving them a route (to a station) would solve the problem.
  • One can clearly see that the first thing ships do is to position themselves to fly in formation. I have to find a way to spawn them already in formation and aligned to their destination.

dybal
Competent
Competent
Posts: 58
Joined: Mon Feb 10, 2020 12:47 pm
Location: São Paulo, Brasil

Re: [Release] Space Crowds

Post by dybal »

Greetings!

Yesterday I was hunting and Space Crowds provided me with a pack of pirates attacking some traders in the lane Main Station / Kiota Manufacturing Station... after disabling 5 or 6 of them, and once the others run beyond scanner range and didn't look like coming back, I started collecting escape pods, but before that I put a waypoint next to the most interesting derelict so I could find it if the escape pod searching got me beyond scanner range of it (the whole fight took a while and covered quite some ground...the farthest escape pod was 180km away...).

After collecting 5 escape pods (alone in deep space...no one in sight the whole way), I went back to the waypoint and the derelict was gone... locking at the Latest.log I saw a "Removed n ships" event from SpaceCrowds.

The other times something like that happened (derelicts disappearing), I had gone back to the main station towing one of them, then went back to the waypoint I left with the others and they were gone... I know the handwavium is that the derelicts were collected or destroyed by others while I was away, but that handwavium doesn't hold in this case, unless someone came to the derelict using a cloaking device and towed it away with both under the cloaking device...

Would it not be more interesting game-wise to let the derelicts be? Like this:

Code: Select all

this.$removeFarShips=function()
{
    var spawnedShips=this.$spawnedShips;
    var count=0;
    for(var i=0; i<spawnedShips.length; i++)
    {
       // ship might actually be long dead, but Oolite seems to handle that case well.
       if(!spawnedShips[i].isVisible)
       {
          if (!spawnedShips[i].isDerelict) {
             spawnedShips[i].remove();
             spawnedShips[i]=null; // for cleanup
             count++;
          }
       }
    }
    //cleanup
    if(count)
    {
       this.$spawnedShips=spawnedShips.filter(function(e) { return e!=null; });
       this.$report("Removed "+count+" ships");
    }

User avatar
Nite Owl
Dangerous
Dangerous
Posts: 122
Joined: Sat Jan 20, 2018 4:08 pm
Location: In The Dark

Re: [Release] Space Crowds

Post by Nite Owl »

Not quite the same circumstance but a similar occurence reported HERE with no response. As stated in that post from over a year ago any help would be greatly appreciated.
Humor is the second most subjective thing on the planet

Brevity is the soul of wit and vulgarity is wit's downfall

Good Night and Good Luck - Read You Soon

dybal
Competent
Competent
Posts: 58
Joined: Mon Feb 10, 2020 12:47 pm
Location: São Paulo, Brasil

Re: [Release] Space Crowds

Post by dybal »

Nite Owl wrote:
Thu Mar 12, 2020 6:54 pm
Not quite the same circumstance but a similar occurence reported HERE with no response. As stated in that post from over a year ago any help would be greatly appreciated.
The revised code bellow should take care of not vanishing boulders, cargo pods and derelict ships...it's a modified version of a function at the end of scripts.js in the OXP Config directory.

Perhaps I should post it in the Tweaks topic...

But I'm too new to Oolite, so I don't know the long term consequences of not removing those entities...

Code: Select all

this.$removeFarShips=function()
{
    var spawnedShips=this.$spawnedShips;
    var count=0;
    for(var i=0; i<spawnedShips.length; i++)
    {
       // ship might actually be long dead, but Oolite seems to handle that case well.
       if(!spawnedShips[i].isVisible)
       {
          if (spawnedShips[i].isShip && !spawnedShips[i].isDerelict) {
             spawnedShips[i].remove();
             spawnedShips[i]=null; // for cleanup
             count++;
          }
       }
    }
    //cleanup
    if(count)
    {
       this.$spawnedShips=spawnedShips.filter(function(e) { return e!=null; });
       this.$report("Removed "+count+" ships");
    }

User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 302
Joined: Mon May 30, 2016 3:54 am

Re: [Release] Space Crowds

Post by montana05 »

dybal wrote:
Fri Mar 13, 2020 1:47 pm
But I'm too new to Oolite, so I don't know the long time consequences of not removing those entities...
Well, worst-case scenario you will get the infamous "universe is full" message, meaning nothing (including subentities) could be added anymore. :lol:
Trying to survive behind the controls of a Caduceus Psi XT in Alpha test :lol:

dybal
Competent
Competent
Posts: 58
Joined: Mon Feb 10, 2020 12:47 pm
Location: São Paulo, Brasil

Re: [Release] Space Crowds

Post by dybal »

montana05 wrote:
Fri Mar 13, 2020 1:56 pm
dybal wrote:
Fri Mar 13, 2020 1:47 pm
But I'm too new to Oolite, so I don't know the long time consequences of not removing those entities...
Well, worst-case scenario you will get the infamous "universe is full" message, meaning nothing (including subentities) could be added anymore. :lol:
I've not experienced that one yet...

I don't think the entities spawned by SpaceCrowds do go into savefiles, so any witchspace jump or savefile reload would dump them... perhaps if they had a spawning timestamp (real-time, not game-time) they could be removed if they were old enough (let's say, 1 hour of real-time... if the player didn't deal with them in one hour of playing, I think (s)he has no plans for them... :lol:)

Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 602
Joined: Sun Jul 21, 2013 12:26 pm

Re: [Release] Space Crowds

Post by Astrobe »

Hello,

Sorry, I've been away from Oolite for a long time and rarely play it now (I'm into Minetest these days).

I have some unreleased code that goes like this:

Code: Select all

this.$removeFarShips=function()
{
	var spawnedShips=this.$spawnedShips;
	var count=0;
	for(var i=0; i<spawnedShips.length; i++)
	{
		// ship might actually be long dead, but Oolite seems to handle that case well.
		if(!spawnedShips[i].position.distanceTo(player.ship.position)>100E3)
		{
			spawnedShips[i].remove();
			spawnedShips[i]=null; // for cleanup
			count++;
		}
	}
	//cleanup
	if(count)
	{
		this.$spawnedShips=spawnedShips.filter(function(e) { return e!=null; });
		this.$report("Removed "+count+" ships");
	}
}
The isVisible method made sense at the time I coded this (or was it inherited from Deep Space Pirates?), but I didn't think at all about derelicts because I don't use the Towbar mod. I don't know how much this move to distanceTo improves things though, because I don't remember the range of isVisible.

Unfortunately, it generates errors ("position" is undefined). It seems to me that that "position" property is actually valid, so I suspect that the ship was already removed, as hinted by the comment. So the challenge here is to find an "existence check" procedure and just remove the ship from the list if it no longer exists.

dybal
Competent
Competent
Posts: 58
Joined: Mon Feb 10, 2020 12:47 pm
Location: São Paulo, Brasil

Re: [Release] Space Crowds

Post by dybal »

I tried that mod that check for isDerelict yesterday and was able to tow several derelicts from a single fight to the main station, one at a time.

And then from other fights I was able to tow the first one but when I got out of the station the derelict beacon (towbar puts a beacon when you attach to a derelict... when I found that out I stopped using waypoint and started attaching every derelict - to mine the cargo and put a beacon on it - before I start towing) didn't exist anymore... but I guess those were spawned by Deep Space Pirates (which I will tweak next :wink: )

User avatar
Nite Owl
Dangerous
Dangerous
Posts: 122
Joined: Sat Jan 20, 2018 4:08 pm
Location: In The Dark

Re: [Release] Space Crowds

Post by Nite Owl »

Code: Select all

if (spawnedShips[i].isShip && !spawnedShips[i].isDerelict)
The above code works for keeping Derelict Ships around when doing F5/F5/F8 for HyperCargo access. Without this when the first F5 was pressed the Derelict Ship would vanish. Modified the above code to the following to try and get a similar behavior for the Space Crowd Boulders.

Code: Select all

if (spawnedShips[i].isShip && !spawnedShips[i].isDerelict && !spawnedShips[i].isBoulders)
No such luck, the Boulders still vanish on the first F5 key press. About to try the code that Astrobe posted to see what the result in these two instances might be. Fingers crossed.
Humor is the second most subjective thing on the planet

Brevity is the soul of wit and vulgarity is wit's downfall

Good Night and Good Luck - Read You Soon

User avatar
phkb
Commodore
Commodore
Posts: 2507
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Re: [Release] Space Crowds

Post by phkb »

I think isRock would work more consisently. And isBoulders isn't quite right -- it's isBoulder, singlar.

User avatar
Nite Owl
Dangerous
Dangerous
Posts: 122
Joined: Sat Jan 20, 2018 4:08 pm
Location: In The Dark

Re: [Release] Space Crowds

Post by Nite Owl »

Thank you phkb.

Your suggestions have been added to my "to try" list should the current attempts fail once again. Have also added the randomly spawned Cargo Pods to the work list. So the want is to be able to F5/F5/F8 for HyperCargo access while the space around my ship has either a derelict ship, a bunch of boulders, or some cargo pods in it without any of those three things vanishing.

Addendum 1:
Astrobe's code...

Code: Select all

if(!spawnedShips[i].position.distanceTo(player.ship.position)>100E3)
works in all three instances. It might actually work too well as a boulder field was still floating around in the same spot after docking with a station and then returning to that spot. Anyhoots, the primary reason for my desire for this bit of code has been gratified. F5/F5/F8 to be able to load the stuff in my cargo hold into HyperCargo so that more stuff can be scooped without that stuff vanishing from within the game's exisitence now works. Thank you all for your time and patience.

Addendum 2:
The above code does work but it also generates A LOT of errors in Mr. Latest Log. A bit of a trade off as Astrobe originally reported and myself foolishly ignored in the hopes of a working solution. Will keep this one in mind but will continue the search for an errorless solution.
Humor is the second most subjective thing on the planet

Brevity is the soul of wit and vulgarity is wit's downfall

Good Night and Good Luck - Read You Soon

User avatar
Nite Owl
Dangerous
Dangerous
Posts: 122
Joined: Sat Jan 20, 2018 4:08 pm
Location: In The Dark

Re: [Release] Space Crowds

Post by Nite Owl »

Code: Select all

if (spawnedShips[i].isShip && !spawnedShips[i].isDerelict && !spawnedShips[i].isBoulder && !spawnedShips[i].is1t-cargopod)
The above is what is currently being tested as an error free solution to the code mentioned in my previous post. The isDerelict and isBoulder descriptors are working as desired on their respective counterparts. The problem that remains is with the Cargo Pods. Have tried several possibilities - isCargopod, isBarrel, and isCargocontainer, unfortunately all three of these caused the Cargo Pods to vanish as soon as they showed up; no key press, no nothing, just poof and they were gone a split second after they appeared on the scanner. The latest test subject,
is1t-cargopod, has yet to be fully tested as no Cargo Pods have popped up as yet, a possible indication of a deeper problem but time will tell on that possibility. At least with the other three attempts the Cargo Pods showed up before vanishing. Having taken a clue from phkb's previous post my exploration for these descriptors comes from the various names and roles assigned to Cargo Pods. Any other suggestions as to what the proper descriptor for this Cargo Pod problem might be would be much appreciated.
Humor is the second most subjective thing on the planet

Brevity is the soul of wit and vulgarity is wit's downfall

Good Night and Good Luck - Read You Soon

Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 602
Joined: Sun Jul 21, 2013 12:26 pm

Re: [Release] Space Crowds

Post by Astrobe »

Nite Owl wrote:
Fri Mar 20, 2020 8:33 am

Code: Select all

if (spawnedShips[i].isShip && !spawnedShips[i].isDerelict && !spawnedShips[i].isBoulder && !spawnedShips[i].is1t-cargopod)
unfortunately all three of these caused the Cargo Pods to vanish as soon as they showed up; no key press, no nothing, just poof and they were gone a split second after they appeared on the scanner.
If I recall correctly, I have observed this behavior before. Your code may not be to blame. The removeFarShips() function is called on timer with a ~2secs period. Actually this depends on the ship's max speed in order to keep the number of encounters the same for an Adder and a Cobra for a given distance, but for tests you can just set it to 5 or 10. Or you can trace in the logs what is being removed by the function.

BTW I think "is1t-cargopod" is wrong and is probably breaking your formula, Probably you meant "is1t_cargopod" ? But I can't find a function like that in the Oolite API.

cag
Dangerous
Dangerous
Posts: 89
Joined: Fri Mar 17, 2017 1:49 am

Re: [Release] Space Crowds

Post by cag »

Both "cargopod" and "1t-cargopod" are roles and you'd need to check

Code: Select all

spawnedShips[i].roles.indexOf('cargopod') < 0
But roles are problematic, as different oxp's make their own, eg. "[ups-barrel]", "[barrel]" (not sure why these have brackets).

If you want to preserve splinters, isRock will fail (they're scoopable, so isCargo is now true), so will isMinable (it's already mined). The one all 3 size of rocks have in common is isFrangible.

Using scanClass may be less prone to error, checking it's neither 'CLASS_CARGO' nor 'CLASS_ROCK'.
FYI: splinters are 'CLASS_CARGO' (they're scoopable), not 'CLASS_ROCK'.

My candidate for $removeFarShips is

Code: Select all

if (spawnedShips[i].isShip && !spawnedShips[i].isDerelict && spawnedShips[i].scanClass !== 'CLASS_CARGO' && spawnedShips[i].scanClass !== 'CLASS_ROCK')
"Better to be thought a fool, boy, than to open your trap and remove all doubt." - Grandma [over time, just "Shut your trap... fool"]
"The only stupid questions are the ones you fail to ask." - Dad
How do I...? Nevermind.

User avatar
Nite Owl
Dangerous
Dangerous
Posts: 122
Joined: Sat Jan 20, 2018 4:08 pm
Location: In The Dark

Re: [Release] Space Crowds

Post by Nite Owl »

Thank You Astrobe and cag.

Your suggestions have been taken under advisement and will be tested. Will report on the success or failure of the testing once it is complete. As always though, life first, so it may be a few days or more. Thanks again.
Humor is the second most subjective thing on the planet

Brevity is the soul of wit and vulgarity is wit's downfall

Good Night and Good Luck - Read You Soon

Post Reply