Singleplayer
Moderator: Moderators
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Singleplayer
This is a loose outline of a long term idea for creating a singleplayer mode within the engine. Essentially what I think it needs are
(1) A Spring.Reload, much like Spring.Restart, but that does not start a new instance of Spring.
(2) A new lua state & the attached baggage, essentially like luaintro but without the engine loading going on in the background, and with access to LuaSocket. Plus some trigger for this to load in place of the normal loading sequence.
(3) Integration of pr-downloader and a lua API for it.
I think that these three things would be enough to allow a game to have a fully fledged singleplayer mode, written in lua/chili in the usual way, with the ability to download its own content and then Spring.Reload into missions (made with the already existing systems) and back again.
Having had a nose around the code, I think most of the functionality for (2), and to a lesser extent (1), already exists. (3) looks like more work.
I'm putting this post here mostly to record the idea for later - I do plan to work on this one day but certainly not before Christmas. I'd also be interested to hear if
- if anyone who has already made singleplayer modes or mission systems thinks more/less would be needed/useful.
- if any of the engine devs would rate (1)-(3) as easy/feasible/impossible or suggest modifications.
(1) A Spring.Reload, much like Spring.Restart, but that does not start a new instance of Spring.
(2) A new lua state & the attached baggage, essentially like luaintro but without the engine loading going on in the background, and with access to LuaSocket. Plus some trigger for this to load in place of the normal loading sequence.
(3) Integration of pr-downloader and a lua API for it.
I think that these three things would be enough to allow a game to have a fully fledged singleplayer mode, written in lua/chili in the usual way, with the ability to download its own content and then Spring.Reload into missions (made with the already existing systems) and back again.
Having had a nose around the code, I think most of the functionality for (2), and to a lesser extent (1), already exists. (3) looks like more work.
I'm putting this post here mostly to record the idea for later - I do plan to work on this one day but certainly not before Christmas. I'd also be interested to hear if
- if anyone who has already made singleplayer modes or mission systems thinks more/less would be needed/useful.
- if any of the engine devs would rate (1)-(3) as easy/feasible/impossible or suggest modifications.
Re: Singleplayer
(1) What would Spring.Reload do exactly? Restart Spring but in the same window, or something else? Note that Spring needs restarts between games and it would be too hard to code it not to. The main issue here is that Spring.Restart works with only one engine, so the multi-engine support other lobbies currently have is lost here - not sure how to solve this.Silentwings wrote:This is a loose outline of a long term idea for creating a singleplayer mode within the engine. Essentially what I think it needs are
(1) A Spring.Reload, much like Spring.Restart, but that does not start a new instance of Spring.
(2) A new lua state & the attached baggage, essentially like luaintro but without the engine loading going on in the background, and with access to LuaSocket. Plus some trigger for this to load in place of the normal loading sequence.
(3) Integration of pr-downloader and a lua API for it.
I think that these three things would be enough to allow a game to have a fully fledged singleplayer mode, written in lua/chili in the usual way, with the ability to download its own content and then Spring.Reload into missions (made with the already existing systems).
Having had a nose around the code, I think most of the functionality for (2), and to a lesser extent (1), already exists. (3) looks like more work.
I'm putting this post here mostly to record the idea for later - I do plan to work on this one day but certainly not before Christmas. I'd also be interested to hear if
- if anyone who has already made singleplayer modes for their games thinks more/less would be needed/useful.
- if any of the engine devs would rate (1)-(3) as easy/feasible/impossible or suggest modifications.
(2) Not entirely essential I think. It's just a minor (few seconds) inconvenience to load a nearly empty (ingame lobby-only) mod.
(3) Shouldn't be too hard I think, but I'll leave the pr-downloader lib linking to abma/jk. I could help to provide a Lua API for archive downloading and handling with unitsync (also pretty important).
Re: Singleplayer
tl;dr:
Test/fix Spring.Restart()
How should players get into the in-mod menu? http://springrts.com/phpbb/viewtopic.php?f=64&t=30376
----
(I like to call in-mod singleplayer instead of in-engine, because the later can be confused with the default menu of spring.exe, with the beach picture)
In-mod singleplayer is imo already possible and has been done seperately by zwszg and by me.
You can have menus to setup up games/select missions, you can start the game, can return to the menu from within game, restart a mission...
When going from menu into starting a game via Spring.Restart , one can notice for a second how spring closes and then restarts. Bit strange, but not a big problem.
(Idea of Spring.Reload is to make that look smoother?)
I think all that is needed exists and it is only small quirks holding back in-mod singleplayer.
Two problems that I recall:
A) After initially having worked ok, Spring.Restart () had some problems.
http://springrts.com/mantis/view.php?id=4262 , http://springrts.com/mantis/view.php?id=4161 , http://springrts.com/mantis/view.php?id=4329
Latest mantis is status:feedback, so maybe should test again.
B) Once you get into the in-mod menu, everything is awesome. But how do you get there in the first place?
Needs a button in the lobby "Launch Single Player", which starts spring/the mod in with some "special argument" that tells the mod to show its SP screen.
This is what this thread was about: http://springrts.com/phpbb/viewtopic.php?f=64&t=30376
Beside "Lua-pr-downloader" there might be other ways:
a) Instead of spring.exe displaying its "archive XYZ not found"-message it starts pr-downloader, downloads the archive, then continues starting.
->Not sure if such functionality belongs into engine?
b) Lobbies already do download dependency files defined in modinfo.lua.
Idea: put all the nessecary files in there.
->For example could be made so that if the lobby downloads a game, it also downloads a mappack or a mission pack.
->I never actually tested that, because cumbersome to test.


----
(I like to call in-mod singleplayer instead of in-engine, because the later can be confused with the default menu of spring.exe, with the beach picture)
In-mod singleplayer is imo already possible and has been done seperately by zwszg and by me.
You can have menus to setup up games/select missions, you can start the game, can return to the menu from within game, restart a mission...
When going from menu into starting a game via Spring.Restart , one can notice for a second how spring closes and then restarts. Bit strange, but not a big problem.
(Idea of Spring.Reload is to make that look smoother?)
I think all that is needed exists and it is only small quirks holding back in-mod singleplayer.
Two problems that I recall:
A) After initially having worked ok, Spring.Restart () had some problems.
http://springrts.com/mantis/view.php?id=4262 , http://springrts.com/mantis/view.php?id=4161 , http://springrts.com/mantis/view.php?id=4329
Latest mantis is status:feedback, so maybe should test again.
B) Once you get into the in-mod menu, everything is awesome. But how do you get there in the first place?
Needs a button in the lobby "Launch Single Player", which starts spring/the mod in with some "special argument" that tells the mod to show its SP screen.
This is what this thread was about: http://springrts.com/phpbb/viewtopic.php?f=64&t=30376
Yes, needs a way to make sure that the player has all nessecary files .(for ex maps or mission files)Silentwings wrote:with the ability to download its own content
[...]Integration of pr-downloader and a lua API for it.
Beside "Lua-pr-downloader" there might be other ways:
a) Instead of spring.exe displaying its "archive XYZ not found"-message it starts pr-downloader, downloads the archive, then continues starting.
->Not sure if such functionality belongs into engine?
b) Lobbies already do download dependency files defined in modinfo.lua.
Idea: put all the nessecary files in there.
->For example could be made so that if the lobby downloads a game, it also downloads a mappack or a mission pack.
->I never actually tested that, because cumbersome to test.
Re: Singleplayer
(1) : What need is Spring.Restart to be reliable. It doesn't really matter to me if it starts a new instance or wipe clean the state of the current instance. However it does matter that it work on all O.S., no matter where Spring is installed, and not break every couple engine version.
(2) : jK is working on it.
(2) : jK is working on it.
Re: Singleplayer
@1: c&p what gajop said
@2: it's named LuaIntro (and not LuaLoadscreen) for a reason
@2: it's named LuaIntro (and not LuaLoadscreen) for a reason
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: Singleplayer
(1) @gajop: Yes, I am thinking of exactly Spring.Restart but in the same window/fullscreen. Bluntly, I think quit/restart with desktop visible everytime you restart a mission looks super ugly. I am not worried about relying on using the same Spring version for reload; it would be madness for a singleplayer game to demand one Spring version for its menu and another for its missions.
(2) @zwzsg, jK; If jK is working on it, I've not heard of it but of course I don't want to duplicate work, so this would be useful to know.
(3) Yes, I know abma has been thinking about doing this (in fact most of the plan above came out of discussion with abma).
(2) @zwzsg, jK; If jK is working on it, I've not heard of it but of course I don't want to duplicate work, so this would be useful to know.
(3) Yes, I know abma has been thinking about doing this (in fact most of the plan above came out of discussion with abma).
And also by me - for BAR, although not released. Basically this is a list of the things I would want to fix/change before I'd feel happy to think of my missions as a "proper" singleplayer game. Without (1) it looks a bit cobbled together. Without (2) afaics the only way to get an ingame menu is with hacky stuff (did I miss something here?) and without (3) the whole thing has to come in one massive pre-packaged download (although I take knorkes point about modinfo dependencies - but its still a huge single download).In-mod singleplayer is imo already possible and has been done seperately by zwszg and by me.
Last edited by Silentwings on 26 Sep 2014, 17:52, edited 4 times in total.
Re: Singleplayer
^ 100% in agreement!Silentwings wrote:(1) @gajop: Yes, I am thinking of exactly Spring.Restart but in the same window. Bluntly, I think quit/restart with desktop visible everytime you restart a mission looks super ugly. I am not worried about relying on using the same Spring version for reload; it would be madness for a singleplayer game to demand one Spring version for its menu and another for its missions.
Re: Singleplayer
With Spring.Restart the delay between closing the old spring instance and the new one starting is less than a second.
A longer delay might be confusing and cause thoughts of "Has it crashed?"
But like this it is "only a bit ugly" and if everything else works then it is not an essential problem to me.
The result is something like this: http://abload.de/img/st_singleplayermenuikar.png
Without black()-ing of the screen, one notice that the previous game is still running (paused) in the background: http://abload.de/img/screen00648r0ywb.png
Is it that what you consider hack?
I think it is okay because the player never notices what is happening.
Instead of just black one could of course have something nicer, like a background picture or some animation etc.
Also if a player has entered the menu he can chose to not start a new game and instead continue his current game by leaving the menu.
A longer delay might be confusing and cause thoughts of "Has it crashed?"
But like this it is "only a bit ugly" and if everything else works then it is not an essential problem to me.
Not sure what you consider hacky or why new Lua state is needed, so short description how my ingame menu works. There is a widget which that does:Silentwings wrote:Without (2) afaics the only way to get an ingame menu is with hacky stuff (did I miss something here?)
Code: Select all
function widget:DrawScreen()
if (menu==true) then
black()
draw_buttons(gfx_buttons)
drawmenu()
end
Without black()-ing of the screen, one notice that the previous game is still running (paused) in the background: http://abload.de/img/screen00648r0ywb.png
Is it that what you consider hack?
I think it is okay because the player never notices what is happening.
Instead of just black one could of course have something nicer, like a background picture or some animation etc.
Also if a player has entered the menu he can chose to not start a new game and instead continue his current game by leaving the menu.
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: Singleplayer
Yes (although I admit it's pretty strict to call it a hack) and I had also thought of doing exactly that. A new lua state as in (2) would not need a map loaded and then hidden, and would also be a natural place to build a lualobby in.Is it that what you consider hack? I think it is okay because the player never notices what is happening.
Re: Singleplayer
Ok, but why is it bad?
There is imo only two disadvantages:
1) This way it is not possible to use the game graphics to create a dynamic 3D background, like for example C&C Generals has - https://www.youtube.com/watch?v=Q-LCdNQNMVA
But there is so many other ways to create decent looking menus or backgrounds, it acceptable imo.
2) On first time going into the SP menu (via the mentioned "Lauch Singleplayer" that lobbies would need to implent) spring is loading a map that is then never seen. Makes the loading take a little bit longer...but nothing problematic?
There is imo only two disadvantages:
1) This way it is not possible to use the game graphics to create a dynamic 3D background, like for example C&C Generals has - https://www.youtube.com/watch?v=Q-LCdNQNMVA
But there is so many other ways to create decent looking menus or backgrounds, it acceptable imo.
2) On first time going into the SP menu (via the mentioned "Lauch Singleplayer" that lobbies would need to implent) spring is loading a map that is then never seen. Makes the loading take a little bit longer...but nothing problematic?
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: Singleplayer
It's not that bad, and of course it works (with slightly increased load time), but hiding the map behind a black wall after going all though that map load, pathing, associated shaders etc, is a hack.Ok, but why is it bad?
Re: Singleplayer
Or like I've done in Spring five years ago:knorke wrote:possible to use the game graphics to create a dynamic 3D background, like for example C&C Generals has

