Page 2 of 3

Posted: Mon Aug 20, 2007 10:39 pm
by Helvellyn
Looks like I'll have to overcome my inherent dislike of JS then. Anyway, I'd be an old hat too if Oolite had ever run on RISC OS :)

Incidentally, the add ships functions appear to crash the game if given a non-integer number of ships (as in Ahruman's example).

Edit: a couple of screenshots of them so far:
http://www.helvellyn.plus.com/oolite/caiman.png
http://www.helvellyn.plus.com/oolite/caiman1.png

Yep, another ship that's just a flying triangle :(

Posted: Mon Aug 20, 2007 11:25 pm
by JensAyton
Ouch. Yes, that’s a bug fixed as part of a general robustification of JS code for 1.70. In the mean time, Math.round(Math.random() * 5) should do the trick.

Posted: Fri Sep 07, 2007 9:33 pm
by Helvellyn
I am still (slowly) working on this. Now up to three ships, and one of them is only seen in a mission.

Sticking with the general pirate role of the Caiman, in order to make it consistent with the rest of the game, what should the relative chances of them appearing in each government type be? I.e. what are the mean number of pirates in each type of system?

Posted: Mon Sep 10, 2007 8:24 pm
by Eric Walch
I.e. what are the mean number of pirates in each type of system?
Very complex and a lot of randomisation. But in general it uses:

1 pirate in a Corporate state and 1 more for every lower political level and above that 25% extra for a anarchy. Added to this are 1 pirate for every 3 traders. And trader count itself depend with economic state of a system. The higher the economy the more traders. Surprising?

After this exact calculation there are added and subtracted a lot of pirates at random so you only can roughly say: the lower the political lever the more and the higher the economy the more. And this is what we all already saw.

But the exact number of added pirates is written down the the computers logfile on every witchspacejump with version 1.65 and with version 1.69 you can set this logging in the logcontrol.plist.

Posted: Mon Sep 10, 2007 9:38 pm
by Helvellyn
Eric Walch wrote:
The higher the economy the more traders. Surprising?
Considering that poor agriculturals are more profitable, yes, unless it's more to either end of the range (such a simple choice of where to trade is one of the serious problems Elite has always had).

Anyway, cheers for that, it's enough to go on to add my Caiman in approximate proportion to the rest of the pirates. Hmm, it's still adding pirates, therefore increasing the overall danger of each system. Might have to have a think about that one...

Posted: Tue Sep 11, 2007 9:56 am
by Eric Walch
Considering that poor agriculturals are more profitable.
I mend higher economic levels like industries have more traders as there is more to trade. In scripting strong economies have lower numbers. Could be confusing.
Anyway, cheers for that, it's enough to go on to add my Caiman in approximate proportion to the rest of the pirates.
Best thing is just add a role of "pirate" to the roles list in shipdata. Then the system itself will select your ships in the appropriate amount without influencing the overall count. An other way is doing it as the pirate_cove.OXP does. This OXP counts the numbers of pirates in the system after a witchspacejump. And then adds his own stuff based on this count.
And you can look at the "score_number". This is the hitcount of a player. Don't add tho much extra pirates with a player of harmless or poor rating.

Posted: Tue Sep 11, 2007 5:31 pm
by Helvellyn
Eric Walch wrote:
Best thing is just add a role of "pirate" to the roles list in shipdata. Then the system itself will select your ships in the appropriate amount without influencing the overall count. An other way is doing it as the pirate_cove.OXP does. This OXP counts the numbers of pirates in the system after a witchspacejump. And then adds his own stuff based on this count.
And you can look at the "score_number". This is the hitcount of a player. Don't add tho much extra pirates with a player of harmless or poor rating.
I don't want to just add them with role pirate, as explained earlier in this thread (because I want swarms of just them to appear on their own), although they can also appear in the pirate role as ordinary pirates too. I like the sound of the pirate_cover.OXP solution, so I may have a think about that one.

I'm totally against the hitcount approach. The universe should not change in relation to the player's actions, unless it's some justifiable mission-related alteration. A beginner should keep clear of dangerous systems, so perhaps I should bias their generation towards dangerous systems more than normal pirates, leaving the safe ones more or less unchanged.

Hmm, in order to keep the number of pirates the same, I wonder if it's possible to delete some existing ones upon system entry by generating a q-bomb in their areas :)

Posted: Wed Sep 12, 2007 7:08 am
by Commander McLane
You would have to know their areas first.

One way is to completely repopulate a system by starting with a sendAllShipsAway, which makes all jump-capable ships hyperspace away. Then you can start with zero.

It is not an ideal solution, though, because all the ships leave their wormholes, of course. So the player will ask himself for what reason this system is full of wormholes when he arrives.

@ Ahruman: Should I request a method for emptying a system without a trace of the action?

Posted: Sun Sep 30, 2007 9:41 pm
by Helvellyn
Just to prove that I'm still very, very occasionally working on ArcElite ships, I've run into a problem, which appears to be related to trying to do a loop in Javascript. The idea is to calculate a number of groups of Caiman (yes, back to that one!) to add to the system, then loop around adding them. Unfortunately if it decides to generate any the game just hangs (it might be going in an eternal loop). I could get around this by just using a few ifs (I don't intend to add more than 3 lots even in the worst Anarchies).

The code is:

Code: Select all

this.willExitWitchSpace = function()
{
  var pos  = Math.random();
  var gov  = 7 - system.government;

  if (gov==7)
  {
    gov=gov*2;
  }
  
  gov=(gov/3.5)*Math.random();
  
  var g=Math.round(gov);
  
  if (planetNumber>-1)
  {
    for (var i=0;i<g;i++)
    { 
      system.legacy_addShipsWithinRadius("caiman_swarm", Math.round(Math.random() * 5) + 7, "wpu",0, 0, pos, 100);
      system.legacy_addShipsWithinRadius("caiman_command",gov,"wpu",0,0,pos,100);
    }
  }
}
If I leave out the loop to just add one set it works OK.

Posted: Mon Oct 01, 2007 11:10 am
by Arexack_Heretic
the STATUS_EXITING_WITCHSPACE, which I guess is equivalent to willExitHyperspace i is triggered only once. And cannot be used to loop a script. (I tried to in Thargorn_threat, adding ships is AFTER the ExitFrom Hyperspace is complete, thus I couldnt check for added ships.)

Instead,
use STATUS_IN_FLIGHT for several loops and increment a timervariable to keep track of the times the loop has run.

Or use the Caiman themseves to run a check-for-Caiman(mother) routine in their launch_actions.

Posted: Mon Oct 01, 2007 12:16 pm
by JensAyton
Arexack_Heretic wrote:
the STATUS_EXITING_WITCHSPACE, which I guess is equivalent to willExitHyperspace i is triggered only once. And cannot be used to loop a script.
This type of restriction is not relevant to JavaScript.

Helvellyn, the obvious thing to do is add a Log("Adding " + g + " ships") before the loop to check that g is what you think it is. If this doesn’t expose an obvious problem, e-mail me a test case (I do look at them eventually…).

Posted: Mon Oct 01, 2007 6:25 pm
by Helvellyn
Ah, I've spotted what it is. I'm not sure how it got in there (it wasn't supposed to be in there!), but this line

Code: Select all

system.legacy_addShipsWithinRadius("caiman_command",gov,"wpu",0,0,pos,100);
shouldn't have "gov" as the second argument (it's supposed to be 1), and by this point gov is almost certainly not an integer, causing the same crash I had earlier.

Another bug was that I didn't recalculate pos, so the whole lot got generated at the same place, much to my surprise when I ran into them. The Q-bomb looking impressive, though. It would've been better if I'd still had some fuel to inject out of there after dropping it...

Sorry for the bother!

Posted: Tue Oct 02, 2007 7:02 am
by JensAyton
Helvellyn wrote:
Ah, I've spotted what it is. I'm not sure how it got in there (it wasn't supposed to be in there!), but this line

Code: Select all

system.legacy_addShipsWithinRadius("caiman_command",gov,"wpu",0,0,pos,100);
shouldn't have "gov" as the second argument (it's supposed to be 1), and by this point gov is almost certainly not an integer, causing the same crash I had earlier.
Ahh yes. I believe I’ve said it before, but there were a bunch of cases like that which are now fixed in the trunk (passing non-integers should be safe and result in rounding).

Posted: Tue Oct 02, 2007 6:12 pm
by Helvellyn
Yes, you have said it before, and I'm very sorry that I hadn't spotted I'd made a cockup!

Posted: Tue Oct 02, 2007 7:18 pm
by JensAyton
Meh. It’s a bug in Oolite. Keeping track of them all isn’t easy; I know I can’t.