fodev.net

FOnline Development => Questions and Answers => Topic started by: JovankaB on July 12, 2014, 08:16:59 pm

Title: How to make FOnline:2238 work in Singleplayer mode
Post by: JovankaB on July 12, 2014, 08:16:59 pm
The steps necessary to run FOnline:2238 in so called "Singleplayer mode":

Sadly the result is not (https://i.cubeupload.com/BqPCyx.jpg) satisfying (https://i.cubeupload.com/vO6UGK.jpg). Something tells me it's the step 4...

Before I get my hands dirty in the scripts, maybe someone else tried it and knows what to do or can point me in a good direction?
Title: Re: How to make FOnline:2238 work in Singleplayer mode
Post by: JovankaB on July 14, 2014, 05:12:34 pm
Unfortunately the thing is more problematic than I thought.

In Singleplayer mode the world isn't generated until you create a character - which is a problem because in the start() function there is tons of features relying on existence of various game objects. So moving most of the stuff from start() to the loop() and making sure the stuff runs only once sounded like a good idea, except one small detail - turns out loop() starts before world generation too...

What's worse 9 out of 10 times I get "character already logged in". I don't know if it goes away once all the null pointer errors get fixed. At this point I lost interest. Maybe I will return to the idea later, but if someone is interested, here is a pseudocode showing what needs to be done (that's the point 4. ???)

In main.fos you have to move stuff from start() to loop() and rewrite loop() like that:

Code: [Select]
loop() {
 if worldGenerated() {
  if (firstTime) {
   stuf_from_start();
 }
  stuff_from_loop();
 }
}


How to check if the world is generated? I don't know if there is some nice way, but there is plenty of functions that run during the generation - map scripts, critter_inits etc. so it shouldn't be too hard to abuse them. Last but not least, thanks to Wipe for help.
Title: Re: How to make FOnline:2238 work in Singleplayer mode
Post by: loord on May 16, 2015, 07:06:38 pm
How to implement save/load options? its possible?
Title: Re: How to make FOnline:2238 work in Singleplayer mode
Post by: Wipe on May 16, 2015, 10:48:35 pm
Singleplayer save/load is similiar to what's used in multiplayer mode, so it shouldn't be much of a problem [once you defeat previously mentioned issues ofc]. For sure you'd have to recheck login/save/load client screens, as we never had reason to care about them. Note that singleplayer mode can be used only on Windows.
Title: Re: How to make FOnline:2238 work in Singleplayer mode
Post by: Voiddweller on June 15, 2015, 06:13:16 pm
Do you really need a singleplayer mode? I mean it will still run a background server process, you can't speed up time, and when you load a save inside some dungeon, you may end up dead, because all enemies respawned  I guess making player keep his/her inventory after death might be more useful. And i am still trying to find out how to enforce turn based mode in fixed locations.