The Ur-Quan Masters Home Page Welcome, Guest. Please login or register.
Did you miss your activation email?
October 04, 2024, 06:05:19 pm
Home Help Search Login Register
News: Celebrating 30 years of Star Control 2 - The Ur-Quan Masters

+  The Ur-Quan Masters Discussion Forum
|-+  The Ur-Quan Masters Re-Release
| |-+  General UQM Discussion (Moderator: Death 999)
| | |-+  Randomizing locations
« previous next »
Pages: [1] 2 Print
Author Topic: Randomizing locations  (Read 3237 times)
RenaissanceMan
Zebranky food
*
Offline Offline

Posts: 2



View Profile
Randomizing locations
« on: January 28, 2017, 02:52:32 pm »

First post here.

So I was thinking... I know NOTHING about programming... but how hard would it be to take the source code and tweak it so that the starting locations of the various and items were somewhat randomized (or even pseudo-randomized) instead of fixed assets?  Think about how replay value and extra interest it would add for experienced players!  There would need to be a few parameters specified for story/logic reasons.  That I can think of off the top of my head (SPOILERS):

- Ur-Quan and Kohr-Ah space must heavily overlap
- other spheres of influence should not overlap
- Sun Device must be in Mycon space
- all Shattered Worlds must be in or near Mycon space
- Utwig Bomb must be in Utwig space (since they describe themselves as the "Stewards of the Bomb")
- Aqua Helix must be in Thraddash space (since a lot of dialogue refers to it being the cornerstone of their culture)
- Sa-Matra must be in Ur-Quan/Kohr-Ah space
- UNKNOWN star (natural Quasi-Space portal) must be in or near Arilou space
- Supox space should be near Utwig space
- Zoq-Fot-Pik space should be in or near Ur-Quan/Kohr-Ah space
- starting location (Sol) must not be within anyone else’s space (game would be near impossible if you started in the center of Ilwrath or Ur-Quan space)
- Rainbow Worlds should form a rough arrow (but orientation and obliquity are randomizable)

But within those parameters, there are countless possibilities for randomization, and thus for interesting new exploration.  Imagine having to search for the Sun Device, or for the Sa-Matra, or for the Utwig, all over again... and again... and again!

My point is that this doesn't SEEM like it should be that hard from a programming perspective... but maybe I'm wrong.  Can any programmers tell me if this is even within the realm of possibility?
Logged
Krulle
Enlightened
*****
Offline Offline

Gender: Male
Posts: 1115


*Hurghi*! Krulle is *spitting* again!


View Profile
Re: Randomizing locations
« Reply #1 on: January 28, 2017, 03:11:53 pm »

Has been proposed before, but how will you handle the text by the internal help system (Melnorme)?


re: unknown star: you could place it anywhere, and move the Arilou space with it....
Logged
JHGuitarFreak
Enlightened
*****
Offline Offline

Posts: 1374



View Profile WWW
Re: Randomizing locations
« Reply #2 on: January 29, 2017, 12:52:24 am »

Randomizing an entire star system might not be too hard but still pretty difficult with the way the code is laid out.

The problem would be changing the dialog to match.
Logged

The artist once again known as Kohr-Ah Death 213.

Get your MegaMod HERE
RenaissanceMan
Zebranky food
*
Offline Offline

Posts: 2



View Profile
Re: Randomizing locations
« Reply #3 on: January 29, 2017, 03:47:44 am »

I didn't mean randomizing all the star system data (i.e. the starmap, how many/what kind of planets each star has).  I was envisioning the map itself staying the same, but where things are ON the map being more randomized.

As for what Krulle said about the unknown star, yes, that's what I meant for all of the parameters I listed.  Arilou space could be anywhere on the map, but wherever it is, the UNKNOWN star needs to be in or near it.  Utwig space could be anywhere on the map, but wherever it is, the Bomb needs to be in it, etc.

How hard would all that be to program?

And yes, I did imagine that the dialogue tied to specific locations would be far harder (or at least more tedious) to change.  Like I said, I know nothing about programming, but I would imagine you would have to define the location of each race and object as a variable, then scour the dialogue for each and every reference to a specific geographic location and replace it with a string designed to point to the correct variable.  So, for example, instead of Tanaka telling you about observing a strange Mycon ceremony on Beta Brahe I, the code would say "a strange Mycon ceremony on %STRING1" or something like that, where %STRING1 is designed to point to where is assigned to the Mycon Sun Device in this iteration of the game.  I don't know how hard that would be... but it would certainly be tedious.

Again, is this even in the realm of possibility?  It seems like a couple of people could maybe do this over a summer or something...?  Am I crazy?
Logged
JHGuitarFreak
Enlightened
*****
Offline Offline

Posts: 1374



View Profile WWW
Re: Randomizing locations
« Reply #4 on: January 29, 2017, 08:43:55 am »

I was envisioning the map itself staying the same, but where things are ON the map being more randomized.

That's more or less what I was talking about.


As for what Krulle said about the unknown star, yes, that's what I meant for all of the parameters I listed.  Arilou space could be anywhere on the map, but wherever it is, the UNKNOWN star needs to be in or near it.  Utwig space could be anywhere on the map, but wherever it is, the Bomb needs to be in it, etc.

How hard would all that be to program?

And yes, I did imagine that the dialogue tied to specific locations would be far harder (or at least more tedious) to change.  Like I said, I know nothing about programming, but I would imagine you would have to define the location of each race and object as a variable, then scour the dialogue for each and every reference to a specific geographic location and replace it with a string designed to point to the correct variable.  So, for example, instead of Tanaka telling you about observing a strange Mycon ceremony on Beta Brahe I, the code would say "a strange Mycon ceremony on %STRING1" or something like that, where %STRING1 is designed to point to where is assigned to the Mycon Sun Device in this iteration of the game.  I don't know how hard that would be... but it would certainly be tedious.

Again, is this even in the realm of possibility?  It seems like a couple of people could maybe do this over a summer or something...?  Am I crazy?

The main problem you would run into is that you would need to make it so it would only randomize once and save that particular random seed in each save file so it could be recalled.

I don't particular know how the dialog works. From a cursory glance it looks as though it's structured in blocks of text and audio that gets called from a variable in the code.

Text file:

Code:
#(HOSTILE_SPACE_HELLO_1) thraddash-000.ogg
So, what's this? SNORT! An unknown alien species?
How wonderful! Someone new to fight!
We, the Thraddash of Culture Nineteen -- famous Ur-Quan Combat Thralls
know well the value of a good fight.
Either you win and prove your superiority...
SNORT! Or you lose and are vanquished.
If the vanquished is lucky, it may survive to learn an important lesson from its defeat.
This is the way of the Thraddash! We fight and learn and improve!
All other cultural schemes are inferior. This is a proven fact.
What have you to say before we begin combat?

Relevant code:

Code:
NumVisits = GET_GAME_STATE (THRADD_VISITS);
switch (NumVisits++)
{
case 0:
NPCPhrase (HOSTILE_SPACE_HELLO_1);
break;
case 1:
NPCPhrase (HOSTILE_SPACE_HELLO_2);
break;
case 2:
NPCPhrase (HOSTILE_SPACE_HELLO_3);
break;
case 3:
NPCPhrase (HOSTILE_SPACE_HELLO_4);
--NumVisits;
break;
}
SET_GAME_STATE (THRADD_VISITS, NumVisits);

This means that you would have to hard code the star location dialogue and split the old dialogue up into a minimum of 3 blocks to fit the new variable in where it would be mentioned.

At least that's the way I see it. There could be a much more elegant way to do it that I'm not picking up looking at the Thraddash dialogue blocks.
Logged

The artist once again known as Kohr-Ah Death 213.

Get your MegaMod HERE
CelticMinstrel
Enlightened
*****
Offline Offline

Posts: 522



View Profile
Re: Randomizing locations
« Reply #5 on: January 31, 2017, 06:43:53 am »

Wasn't there someone working on exactly this last year? Or at least something similar.
Logged
Death 999
Global Moderator
Enlightened
*****
Offline Offline

Gender: Male
Posts: 3874


We did. You did. Yes we can. No.


View Profile
Re: Randomizing locations
« Reply #6 on: January 31, 2017, 08:15:14 pm »

Yes, there was.
Logged
TalkingPet
Zebranky food
*
Offline Offline

Posts: 6



View Profile
Re: Randomizing locations
« Reply #7 on: September 17, 2017, 10:19:46 pm »

I did some work on this a while ago, and managed to get randomized placement of alien "fleets" and home planets without too much pain.



As others have said the real difficulty would be updating the in game text to be dynamic and match the new star system.

There's also the issue of placing things meaningfully - the pkunk should be close to the ilwrath, the ZFP should be within urquan space, etc.

I'm thinking about returning to this soon if I have time but I think updating the dialogue system might be a huge task.  It would probably be a better use of time to abstract out a lot of this stuff rather than trying to get it to work within the existing system.
Logged
TalkingPet
Zebranky food
*
Offline Offline

Posts: 6



View Profile
Re: Randomizing locations
« Reply #8 on: September 17, 2017, 11:31:16 pm »

for anyone interested my brief and hacky way of getting to the above was by making a function which "shuffled" the "alien presence" field of starmap_array in plandata.c.  Then I called that function in InitGameStructures of globdata.c.

The meaty part is actually only a few lines of code:

(click to show/hide)

There were also a few helpers and fixups for places that later relied on hardcoded stuff.

There are a bunch of problems still to be solved with an approach like this:
  • dialogue correction (hard)
  • placing special stars (like the ship vault, the mycon trap star, the precursor bomb etc) within the right space (easy-ish)
  • making sure that related spheres of influence are close (easy-ish)
  • making fleets move to the right place for special events like pkunk returning to yehat (not sure how hard).

I also never tried to actually play through so like someone mentioned above I'm not sure how much it will break on save/reload.

It's really just a proof of concept hack and not real solution.  BUT I think all the above CAN be sorted out, with dialogue being the hardest nut to crack.

There is already some support in the code for insertions - for inserting your captain name, your ship name, and the alliance name.

For example in starbas.c there is the following code:

Code:
construct_response (
shared_phrase_buf,
tell_me_about_fuel0,
GLOBAL_SIS (ShipName),
tell_me_about_fuel1,
(UNICODE*)NULL);

which references this struct:

Code:
typedef struct
{
SIS_STATE SIS_state;
GAME_STATE Game_state;
} GLOBDATA;

It shouldn't be too hard to add some more state for the positions of all the shuffled stuff and set it up when randomizing the locations.  Any dialogue that references that stuff would have to have some code added to it's comms file to use construct_phrase, but that shouldn't be too hard, just kind of tedious. It might be possible to write a better solution but that would take some more architecting whereas just doing what they do for ship/captain name could work with some brute force.
« Last Edit: September 17, 2017, 11:46:17 pm by TalkingPet » Logged
Death 999
Global Moderator
Enlightened
*****
Offline Offline

Gender: Male
Posts: 3874


We did. You did. Yes we can. No.


View Profile
Re: Randomizing locations
« Reply #9 on: September 17, 2017, 11:47:23 pm »

So with this code you also didn't shuffle the Ur-quan?
Logged
TalkingPet
Zebranky food
*
Offline Offline

Posts: 6



View Profile
Re: Randomizing locations
« Reply #10 on: September 17, 2017, 11:51:00 pm »

The urquan sphere of influence is defined by the location of the sa-matra, which I do shuffle in that code.

edit to add: I want to reiterate that what I posted is pretty hacky, it gets the star map I showed above, but is pretty far from a complete solution.
Logged
Death 999
Global Moderator
Enlightened
*****
Offline Offline

Gender: Male
Posts: 3874


We did. You did. Yes we can. No.


View Profile
Re: Randomizing locations
« Reply #11 on: September 18, 2017, 02:01:41 am »

I'd keep the Sa-Matra near the middle, because it's… pretty central, and makes getting around a little less convenient.
Logged
JHGuitarFreak
Enlightened
*****
Offline Offline

Posts: 1374



View Profile WWW
Re: Randomizing locations
« Reply #12 on: September 18, 2017, 03:11:21 am »

  • dialogue correction (hard)
  • placing special stars (like the ship vault, the mycon trap star, the precursor bomb etc) within the right space (easy-ish)
  • making sure that related spheres of influence are close (easy-ish)
  • making fleets move to the right place for special events like pkunk returning to yehat (not sure how hard).

For the dialog the easiest way I could think of is completely remove any named mentions of star systems, have the characters go by star coordinates instead. That means dialogue would have to be recreated specifically for the numbers and the lead up and following dialog.

Making fleets move might be a bit more difficult.

All of that code is in gameev.c.

It might be possible to break up all the randomly generated parts into "RaceX, RaceY" then add some maths in there to compensate for the specifics of what used to be hardcoded.
Like sending the Ilwrath to fight the Thraddash. The Ilwrath do not go straight to the center of the Thradd SOI, it's a position slightly left, and the Thradd move slightly south during their war.

I only know this because I had to stare at that code for days on end trying to get what I wanted out of it for the MegaMod.

Then there is what to do with the silly maths that are already coded:

if (IlwrathPtr->loc.x == ((2500 + 2535) >> 1) && IlwrathPtr->loc.y == ((8070 + 8358) >> 1))

So 2500+2535=5035 shifted once to the right is 2057, that's your CoordX.

8070+8358=16428 shifted once to the right is 8214, that's your CoordY.

Why IlwrathPtr->loc.x and IlwrathPtr->loc.y couldn't equal 2057 and 8214 respectively is anyone's guess.
Logged

The artist once again known as Kohr-Ah Death 213.

Get your MegaMod HERE
TalkingPet
Zebranky food
*
Offline Offline

Posts: 6



View Profile
Re: Randomizing locations
« Reply #13 on: September 18, 2017, 03:19:38 am »

Just using coordinates would definitely be a little bit easier, but I think most of the dialogue falls into a few buckets:
  • a specific "special star" (like the exact home star)
  • just the constellation that a special star is directly in
  • a constellation NEAR to a special star
  • coordinates near the special star

The constellation NEAR a star is hardest but if I add a function like "give me all the star indices of stars in your sphere of influence" and then just pick one randomly that should work.

I think what I can do is build a special string table that has an entry for each of the buckets, for each of the special stars, and then insert that into dialogue.

There might also be a few edge cases where they name specific directions like "coreward" or phrase things in a fluffy way like "the third star of gemini" or something that I might just hack out the dialogue like you suggest (change it to be one of the buckets above).
Logged
TalkingPet
Zebranky food
*
Offline Offline

Posts: 6



View Profile
Re: Randomizing locations
« Reply #14 on: September 18, 2017, 03:25:16 am »

I'd keep the Sa-Matra near the middle, because it's… pretty central, and makes getting around a little less convenient.

Yeah that might be true.  This could be something baked into whatever "rules" there are (like saying supox and utwig have to be close together, there might be a rule saying sa-matra has to be somewhat central.

You could definitely get into some unwinnable games where key early game stuff was in urquan space - or worse, as in the screenshot above, where urquan overlaps sol.
Logged
Pages: [1] 2 Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!