Thus, should your much more readable code still have the old tendency of selecting the same systems, maybe it's enough to simply request n times (for n seconds) a random number before running that code - and I'd guess that the next version of GalNavy would then come with a shorter and better script
What's this about random numbers? The existing code from the OXP (Galactic Navy 5.0) doesn't use random numbers for ReserveDutySystemDetermination
It only uses galaxy and system.ID for one description per system. The same description per system.
Last edited by pmw57 on Mon Oct 26, 2009 10:16 pm, edited 1 time in total.
A trumble a day keeps the doctor away, and the tax man;
even the Grim Reaper keeps his distance.
-- Paul Wilkins
Hey guys. Maybe you should spend some time with OSE and fix the bugs there instead of talking about Galactic Navy or RH. It seems you haven't took a look at all in RH, then you'd know that LB has scripted it in XML, not in JS (only the ship-scripts are JS). And before you say 'I can translate it'. LB is still here and HE has to work work with it, so this wouldn't be a great help and would stop any further development.
If you really want to do something, give him a pm and talk about it, instead of posting non-existing 'fixes', or write a JS-Tutorial for Oolite for us 'noobs'.
What's this about random numbers? The existing code from the OXP (Galactic Navy 5.0) doesn't use random numbers for ReserveDutySystemDetermination
It only uses galaxy and system.ID for one description per system. The same description per system.
That's wrong, really. Add the log line and give the modified version from me a try...it's selecting randomly one of the values in that array. Since the random generator is usually using the same random seed, it usually does select the same all the time.
What my modification does is that it add's some more randomness to the selection process (even more than there are numbers, thus surely enough).
I was astonished about how JS works when I did have a look at that code myself.
Hmmm...and I really do wish that I could simply move all these messages from here to the GalNavy thread...
It seems you haven't took a look at all in RH, then you'd know that LB has scripted it in XML, not in JS (only the ship-scripts are JS).
If XML cannot use time or something like that to achive more randomness before it uses random values, maybe it'd be an idea to call a JS that simply "uses up" some random numbers before it's using random numbers so that it also does achieve more randomness?
About modernising older OXPs: pmw57, what about converting Taranis?
Provided you contact the original oxp maker and they give you the go-ahead, I'm sure there won't be any problem with you converting that to js. Plus the Taranis HQ could really do with some shadery updates, instead of using flashers - they look so old-fashioned!
Last edited by Kaks on Mon Oct 26, 2009 10:38 pm, edited 2 times in total.
About modernising older OXPs: pmw57, what about converting Taranis?
Provided you contact the original oxp maker and they give you the go-ahead, I'm sure there won't be any problem with you converting that to js. Plus the Taranis HQ could really do with some shader update, instead of using flashers!
I will certainly take a look, however regarding graphical stuff, be warned: my artistic skills are below sub-par.
A trumble a day keeps the doctor away, and the tax man;
even the Grim Reaper keeps his distance.
-- Paul Wilkins
Because of the size of the project, I started writing it on Oolite 1.65 (no JS available then), so the script is written in legacy with some bolt on JS scripts for ships and other objects which set legacy mission variables which the main legacy script then acts on. The randomness of system selection isn't therefore as random as it could be as the systems are picked from a list in descriptions (as this was the only way to do it when I wrote it). If I was starting it now I'd have written in JS, but I haven't got the heart (or the time really) to translate the legacy script to a JS one. Its just too darn big, so when I have the time to finishs it, it'll just have to be left in legacy as it would be too time consuming (and would probabley break stuff) to re-write it. Its like the old joke: "Q: How do I get to Dublin?", "A: Well I woudn't start from here."
OXPS : The Assassins Guild, Asteroid Storm, The Bank of the Black Monks, Random Hits, The Galactic Almanac, Renegade Pirates can be downloaded from the Elite Wiki here.
If I was starting it now I'd have written in JS, but I haven't got the heart (or the time really) to translate the legacy script to a JS one. Its just too darn big, so when I have the time to finishs it, it'll just have to be left in legacy as it would be too time consuming (and would probabley break stuff) to re-write it. Its like the old joke: "Q: How do I get to Dublin?", "A: Well I woudn't start from here."
There are cunning techniques that can reduce the conversion time. It's amazing what can be done with regular expressions (not necessarily within the game, but for converting the code).
Would you consider my taking a look at things?
A trumble a day keeps the doctor away, and the tax man;
even the Grim Reaper keeps his distance.
-- Paul Wilkins
Yeah sure, if you want to convert it. I've put comments in the script so you can see what each bit is meant to be doing, but its a real looooong script!
I don't think though there is a way though to calculate the position on the map to a system picked with a random number though. ATM the position is done manually ie: system oneof a, b, c, d, e, etc set sector = "North West". Basically I had to look at the map and manually code in where each system that RH could generate a mission was. Wouldn't fancy doing that with over 2000 systems, which is partly why lists are used! Also some systems are unreachable. Eg there are about 50 systems in G7 that you cannot actually get to as the cluster is more than 7 light years from anywhere else. ATM Random Hits won't generate missions at these systems as they would be impossible to complete (I just didn't include them on the lists). Again the disadvantage of a random number picked system is I don't think there'd be a way for Ooolite to know that a system it picked at random from all 255 systems in the current Galaxy (rather than picking a system at random from a pre-set list) is one that the player cannot actually reach.
I'd checked this with another commander before resorting to lists and there is not a mathmetical relationship between planetnumbers that can be used to calaculate distance between two systems or the position of a given system, only between the co-ordinates of two system, which I don't think is accessable with an OXP script.
OXPS : The Assassins Guild, Asteroid Storm, The Bank of the Black Monks, Random Hits, The Galactic Almanac, Renegade Pirates can be downloaded from the Elite Wiki here.
Yeah sure, if you want to convert it. I've put comments in the script so you can see what each bit is meant to be doing, but its a real looooong script!
So was OSE but most of that was duplicate repeating structures that were easily brought down to size.
When I separate bits that change from the bits that don't (there's a fancy name for that somewhere) the code will be a lot smaller, and easier to follow.
I don't think there'd be a way for Ooolite to know that a system it picked at random from all 255 systems in the current Galaxy (rather than picking a system at random from a pre-set list) is one that the player cannot actually reach.
I'd checked this with another commander before resorting to lists and there is not a mathmetical relationship between planetnumbers that can be used to calaculate distance between two systems or the position of a given system, only between the co-ordinates of two system, which I don't think is accessable with an OXP script.
There is systemNameForID but apart from that, nothing else that's useful.
It would be nice if there was a systemDistance(targetID [, sourceID]) which returned false (or -1) for not reachable.
Hmm, maybe that should be a scripting request for the developers.
A trumble a day keeps the doctor away, and the tax man;
even the Grim Reaper keeps his distance.
-- Paul Wilkins
So was OSE but most of that was duplicate repeating structures that were easily brought down to size.
When I separate bits that change from the bits that don't (there's a fancy name for that somewhere) the code will be a lot smaller, and easier to follow.
Random Hits also contains a fair part of repeating code. Legacy does not allow for functions so when you need some code part 20 times, you must add it 20 times.
When you look at Galactic Navy, you see that its legacy version of over 16000 code lines was reduced to about 1850 lines by Nemordicus.
Random hits is a bit smaller (about 9000 lines) and has less repeating code that GN had, but a reduction to one quarter would be a very realistic number. (But still a hell of a job)
Double hmmm, it looks like I need to create a completely new SystemInfo page to add that to the wiki. I suppose I better do that. And we still need to add a lot of the future stuff mentioned in the Progress thread.
You might want to have a look at the Progress thread. It's a goldmine of information not yet ported to the wiki, like this post!