GreepTheSheep / openplanet-MXRandom

An Openplanet plugin that takes a random map from MX / TMX and play it
https://openplanet.dev/plugin/mxrandom
GNU General Public License v3.0
19 stars 28 forks source link

[Feature request] Randomly seeding random maps #37

Closed Fjf closed 2 years ago

Fjf commented 2 years ago

It would be great if instead of having a fully random map, we can seed this and do the same (randomly sampled) maps together with a friend. I tried to fix it myself but I cannot test anything due to signatures etc.

GreepTheSheep commented 2 years ago

Seeds is complicated to do, since the randomizer fetches the map from the TMX API and there are no servers that store maps you played, the better solution is to share the recently played maps located in C:\Users\%username%\OpenplanetNext\TMXRandom_PlayedMaps.json to your friend, then they can replay it with the Randomizer GUI.

Fjf commented 2 years ago

I noticed if you query /mapsearch2/search?api=on&limit=1 you get the latest map Id, the only thing you then need to do is generate a random number between 1 and this latest map id. I couldnt find any builtins from angelscript which could generate random integers, but in the worst case you can just query windows %RANDOM% in an exec() call. Or is there some other related thing as to why this will not work?

GreepTheSheep commented 2 years ago

you can just query windows %RANDOM% in an exec() call.

Impossible, Openplanet can't execute client-side commands, also this can be a security risk.

is there some other related thing as to why this will not work?

The plugin uses the random endpoint from TMX, it will never lists all maps and then pick a random map from the list, because there are +20k maps from the database and the server load would be high. So it pick an endpoint that outputs a random map from the database. The plugin does the same thing that we do for picking a random map (going to TMX, select maps, and click to the "Random map" button)