Files
nmslib/rpcg.go
2021-05-18 04:57:05 +00:00

48 lines
1.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
[P][SSS][YY][ZZZ][XXX] (P = Planet Index / S = Star System Index / Y = Height / Z = Width / X = Length)
`Solar System Index
A Solar System Index is assigned to each star system in a region. It always begins at SolarSystemIndex=001
and counts up by one for every star system. The number of star systems in a region is variable so the
maximum value of the Solar System Index is also variable, though the two correspond directly. To date there
is no discovered value that is higher than SolarSystemIndex=243 (Mamundi-Kate in the Baadossm Anomaly of
Euclid galaxy), meaning that 579 is the maximum number of star systems yet discovered in a region. Based
on the evidence that every region has a SolarSystemIndex=079 and SolarSystemIndex=07A (with the former
always having a Black Hole and the latter always having an Atlas Station), it is known that every region has
at least 122 star systems. SolarSystemIndex=000 always leads to the region's first system, just like
PlanetIndex=0 always leads to the first portal of a system due to the error proximity mechanic.`
Source https://nomanssky.fandom.com/wiki/Portal_address#Solar_System_Index
*/
package nmslib
import (
"fmt"
"math/rand"
"time"
)
/*
RndPortal - Random Portalcode generator
Requires no input required
Returns a string
*/
func RndPortal() (final string) {
rand.Seed(time.Now().UnixNano())
min := 0x1
ymax := 0xFF
xzmax := 0xFFF
ssimax := 0x242 // set this low to lower chances of an invalid address
x := rand.Intn(xzmax-min+1) + min
z := rand.Intn(xzmax-min+1) + min
y := rand.Intn(ymax-min+1) + min
ssi := rand.Intn(ssimax-min+1) + min
final = fmt.Sprintf("%00X%03X%02X%03X%03X", 1, ssi, y, z, x)
return
}