Inside3D!
     

HUB level system?

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
jim



Joined: 05 Aug 2005
Posts: 400
Location: In The Sun

PostPosted: Thu Oct 04, 2007 1:59 pm    Post subject: HUB level system? Reply with quote

Is it possible? I'm not going to start coding it right away, but since I'm soon starting to design some levels, I'll need to design them different if I can or can't go back and forth between the levels and have the enemies, corpses, weapon, item, bonus pickups stay wherever they were when you left the level and come back. Then also some functions like getting some door open in another map?

Possibly it could transport some entities to the another map, if they were in some transport area, so you don't see them disappear or appear suddenly. Alternatively I could just desing the areas near the changelevel trigger in a way that monsters don't come there.

I think I know how to get the code for setting player into the right position done pretty easy. Using that similar system as in Half-Life, those landmarks and then offsetting player start position from the specified landmark and then I have seamless transitions between levels.

Also if it's going to give headache for months, then I think I'll pass and just have old style levels.
_________________
zbang!
Back to top
View user's profile Send private message Visit poster's website
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Thu Oct 04, 2007 2:36 pm    Post subject: Reply with quote

Well, you have 16 float parms. It's possible to pack 23 or 24 bits (I think) of integer values per parm if you use bitwise operations, or the full 32 bits if you use LordHavoc's incredibly evil 1000+ line code from hell. You could fit the relative player origin in the parms, but you'll never get nearby entities to fit in there, let alone a hub system.

There have been hacks. One old Quake mod I believe devoted one bit to the alive/dead state of each monster in all of the several maps it used. You probably had to assign a unique 'bit number' to each monster entity in the level editor, and could only fit so many monsters, and it wouldn't remember their position or health.

As long as you're using a custom engine, it's customary to use FRIK_FILE for hub systems. I did this for an old dead mod of mine (Fniggium), and was considering linking you to the code for reference. But it's pretty much indecipherable and mostly covers other things. But anyway, you can still look at the embarrassing mess if you want. I think it worked, but I don't remember for sure.

What I do is similar to what I think Quake2 does. Saves are created in folders, with each map getting its own save file in the folder. The current game state is held in the '_current' save folder. When you load a save game, it copies all the files of that save folder to the _current folder, and vice versa for saving. In addition to the map save files, you have a global 'game state' file, which probably contains the current map, and the player information. (Note that this idea of a _current save will probably bork up completely if you run two copies of the game at once, which worked fine in Quake 1).

The entities are written to the files in your own formatting, and read back using tokenize() (courtesy of KRIMZON_SV_PARSECLIENTCOMMAND) to parse it.
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Back to top
View user's profile Send private message
Dr. Shadowborg
Inside3D Staff


Joined: 16 Oct 2004
Posts: 726

PostPosted: Thu Oct 04, 2007 4:08 pm    Post subject: Reply with quote

Or you could use an engine such as MhQuake.
_________________
"Roboto suggests Plasma Bazooka."
Back to top
View user's profile Send private message
leileilol



Joined: 15 Oct 2004
Posts: 1321

PostPosted: Thu Oct 04, 2007 4:22 pm    Post subject: Reply with quote

or hexen 2
_________________
Back to top
View user's profile Send private message
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Thu Oct 04, 2007 5:41 pm    Post subject: Reply with quote

or fte. Smile

http://wiki.quakesrc.org/index.php/FTE_SV_REENTER

All that's left is to position the player where you want.
(Ignore the ClientReEnter, unless you have a _lot_ of information to transfer over each map change).

Using fte's changelevel2 (changelevel with an extra parameter) maps are preserved and reloaded when you return to them. The startspot parameter is set to the startspot in the new/earlier map when you return, so its got all the basics that are needed to implement it fairly easily. You can support coop with it too.

But its only fte that supports this.
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
jim



Joined: 05 Aug 2005
Posts: 400
Location: In The Sun

PostPosted: Thu Oct 04, 2007 6:33 pm    Post subject: Reply with quote

Well.. I'm using DarkPlaces, so I'll have to ignore the engine suggestions Razz

That qc file looks allright to me, not too hard to understand what's going on... also looks like you had thinked the same stuff as I for some new attributes for the monsters...

My transportation area idea was something like.. if the entity is inside a brush entity and player exits the level, then that entity will be spawned to the next level and removed from the level player exited, all it's attributes would copied, so it doesn't suddenly get full health or something... and it's position would be offsetted from that landmark entity just like player.
_________________
zbang!
Back to top
View user's profile Send private message Visit poster's website
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Thu Oct 04, 2007 6:59 pm    Post subject: Reply with quote

Yeah, that's a lot simpler than full hub systems Smile (though a full hub system usually includes it)
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Back to top
View user's profile Send private message
Urre



Joined: 05 Nov 2004
Posts: 1073
Location: Sweden

PostPosted: Fri Oct 05, 2007 6:33 am    Post subject: Reply with quote

Sajt: didn't Fniggium have a custom MQC menu? </offtopic>

jim: I say FRIK_FILE, done it meself a few times, works great! You can even transfer entities (like monsters close to the exit or whatever) if you're insane Wink
_________________
Look out for Twigboy
Back to top
View user's profile Send private message Visit poster's website
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Fri Oct 05, 2007 4:38 pm    Post subject: Reply with quote

Urre wrote:
Sajt: didn't Fniggium have a custom MQC menu? </offtopic>


Blegh... I barely remember anything about that, I can't remember if I used Black's .menu parsing stuff or started it over from scratch (as I was 'wont' to do, which is probably one of the main factors of Fniggium's demise)
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Back to top
View user's profile Send private message
Urre



Joined: 05 Nov 2004
Posts: 1073
Location: Sweden

PostPosted: Sat Oct 06, 2007 7:35 am    Post subject: Reply with quote

Sajt: it did seem to me you used your own, in which case it would be more than interesting to see
_________________
Look out for Twigboy
Back to top
View user's profile Send private message Visit poster's website
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Sat Oct 06, 2007 5:14 pm    Post subject: Reply with quote

Really doubt I have it anymore, I can't find any of my Fniggium stuff (except the qc on sourceforge) Sad
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Back to top
View user's profile Send private message
FrikaC
Site Admin


Joined: 08 Oct 2004
Posts: 947

PostPosted: Mon Oct 08, 2007 1:24 am    Post subject: Reply with quote

Sajt wrote:
Well, you have 16 float parms. It's possible to pack 23 or 24 bits (I think) of integer values per parm if you use bitwise operations, or the full 32 bits if you use LordHavoc's incredibly evil 1000+ line code from hell. You could fit the relative player origin in the parms, but you'll never get nearby entities to fit in there, let alone a hub system.

There have been hacks. One old Quake mod I believe devoted one bit to the alive/dead state of each monster in all of the several maps it used. You probably had to assign a unique 'bit number' to each monster entity in the level editor, and could only fit so many monsters, and it wouldn't remember their position or health.

As long as you're using a custom engine, it's customary to use FRIK_FILE for hub systems. I did this for an old dead mod of mine (Fniggium), and was considering linking you to the code for reference. But it's pretty much indecipherable and mostly covers other things. But anyway, you can still look at the embarrassing mess if you want. I think it worked, but I don't remember for sure.

What I do is similar to what I think Quake2 does. Saves are created in folders, with each map getting its own save file in the folder. The current game state is held in the '_current' save folder. When you load a save game, it copies all the files of that save folder to the _current folder, and vice versa for saving. In addition to the map save files, you have a global 'game state' file, which probably contains the current map, and the player information. (Note that this idea of a _current save will probably bork up completely if you run two copies of the game at once, which worked fine in Quake 1).

The entities are written to the files in your own formatting, and read back using tokenize() (courtesy of KRIMZON_SV_PARSECLIENTCOMMAND) to parse it.


If you're just doing single player and don't want to worry about custom engines you can just also use regular save games. I wrote up a system to do this for a SP mod I worked on years ago. and I'd post the code here, but it's too atrocious, worse even than Sajt's. But it's actually pretty simple in principle.

There's three things you have to do. When you hit a changelevel instead of doing a fresh changelevel, load a ".hub" save of the map.

Instead of using parms for level changing data, use cvars (scratch1-4/saved1-4 are handy). Also store in the cvars a numerical index of which trigger_changelevel that was used, so you can spawn at the corrent entrance/exit on each map.

As you pass through you can mark each changelevel trigger as dirty as soon as you use it. If it's already dirty, load the previous hub save. If not, run a new map (this somewhat eradicates a persistant world if the player goes back and chooses new game.) It's also a good idea to put some safety on the 'parms'. Basically if they are blanked it's probably a new game or from a previous save.

You can use the FrikQCC "nosave" keyword to make a savegame detector. This will detect when the player is entering a hub save from another level and will allow you to evaluate their 'parms' How you do it is thus:

Code:

nosave var float is_reloaded = 1;


The is_reloaded value will be 1 whenever the game has started or resumed from a save game state. You can then just check the flag on PlayerPreThink, if set, set it to 0 and do your 'parm' handling. Teleport to a hub player start if their hub entrance parm is set, etc etc.

Did I say it's simple? Well I meant it it simpler than Sajt's suggestion. I guess.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group