Fade to Black

Locked
rbottoms
Posts: 27
Joined: Wed Jan 11, 2006 4:00 am

Fade to Black

Post by rbottoms »

Anyone know how to fade to black in Q3. I have added a Teleport function that jumps the player from the current map to another map or another server. My game is more of an RPG so moving between worlds is essential.

But, there is a 1-2 second delay before the map load kicks in where the user has a bright white screen. I'd like to drop/fade to black or better yet show the next levelshot before initiating the transfer.

This easy to do with the UI, but I need to make this happen inside /game/g_misc.c

Here the code at the moment:

void TeleportPlayer
( gentity_t *player, vec3_t origin, vec3_t angles ) {

// new mod warp
if(mapFlag == 0)
{

// fade out goes here
trap_SendConsoleCommand( EXEC_NOW, "map m2" );
mapFlag = 1;

}
else
{
// fade out goes here
trap_SendConsoleCommand( EXEC_NOW, "map m1" );
mapFlag = 0;

}

}


Thanks.
rbottoms
Posts: 27
Joined: Wed Jan 11, 2006 4:00 am

Post by rbottoms »

I've come to understand that what I want has two parts:

-- a sever command that tells the client fade to black

-- the fade to black code executed by the client
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Fade to Black

Post by ^misantropia^ »

rbottoms wrote:This easy to do with the UI, but I need to make this happen inside /game/g_misc.c
Difficult if not impossible. As soon as you execute the 'map' command, Q3A unloads both the server and client QVM|DLL, loading the UI instead. You could work around this by modifying the engine itself, of course.
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

rbottoms wrote:-- a sever command that tells the client fade to black
You'll need to synchronize the client and the server, because it'd be bad if the client was still fading out the current map while the server had already switched to the next. Easy enough. In your trigger_teleport_player_touch() function do:

Code: Select all

const char *mapname;
/* ... set mapname ... */
trap_SendServerCommand( -1, va( "fadeout %s", mapname ) );
Make the client catch it in CG_ServerCommand (cg_servercmds.c):

Code: Select all

if ( !strcmp( cmd, "fadeout" ) ) {
    CG_Fadeout(); // you'll have to define this yourself
    trap_SendClientCommand( va( "warpMap %s", CG_Argv(1) ) );
    return;
}
Finally, catch the "warpMap" command in g_cmds.c. In ClientCommand(), add:

Code: Select all

else if (Q_stricmp (cmd, "warpMap") == 0)
    Cmd_WarpMap_f(ent);
And somewhere above aforementioned function, add:

Code: Select all

void Cmd_WarpMap_f( gentity_t *ent ) {
    char mapname[MAX_TOKEN_CHARS];
    trap_Argv( 1, mapname, sizeof( mapname ) );
    trap_SendConsoleCommaned( EXEC_APPEND, va( "map %s\n", mapname ) );
}
This isn't too safe, of course, so you might want to add a challenge (say a large random number or random string) to the "fadeout" command sequence. Preferably, make it time out after a while (e.g. the challenge becomes invalid after 60 seconds).
rbottoms wrote:-- the fade to black code executed by the client
Probably easiest if you add a new trap that does the fading out inside the engine.
rbottoms
Posts: 27
Joined: Wed Jan 11, 2006 4:00 am

Post by rbottoms »

>You'll need to synchronize the client and the >server

Ahh, you've made me see that what I am doing is the opposite of my intent.

What I am doing is switching the map the server is using.

What I intended was for the client to switch the map it is connected.

So it looks like for my purposes I have to always have more than one server running, each on a different port, then issue a "connect 192.168.1.100:29760" "connect 192.168.1.101:29770", etc.. for each different map(server) I want to warp to.

No wonder I've had such a hard time getting this answered.

So the missing piece is still the same.

Fade the client to black. I don't need to do that in the engine because the server isn't changing it's map, the client is just changing the server it's connected to.

Wonderful things these forums.


edit:

That's not working so well. From the console in the game issuing the "connect ip:port" works just fine.

If I do it from g_misc.c like so: trap_Cmd_ExecuteText( EXEC_NOW, va( "connect 127.0.0.1:29770")); I go into some type of infinite loop.

Suggetions?
rbottoms
Posts: 27
Joined: Wed Jan 11, 2006 4:00 am

Post by rbottoms »

I think what I "really" want to do is:

Client A -> Server:
Execute TeleportPlayer_29770

Server -> Client A:
Disconnect from Server 127.0.0.1:29760
Reconnect on Server 127.0.0.1:29770
rbottoms
Posts: 27
Joined: Wed Jan 11, 2006 4:00 am

Post by rbottoms »

Making progress. This bit of code disconnects me from the server:

if(mapFlag == 0)
{
trap_DropClient(player->s.clientNum,"Teleport_29770");
mapFlag=1;
}

If I include an ERROR message the server shuts down. So I use "Teleport_29770" instead.

What next???
rbottoms
Posts: 27
Joined: Wed Jan 11, 2006 4:00 am

Post by rbottoms »

Well it's a hack based on the error message but I can teleport between server ports (maps). All I need now is the fade to black code.

Since it's just a proof of concept being ugly behind the scenes is not a problem.

Fade out anyone?
rbottoms
Posts: 27
Joined: Wed Jan 11, 2006 4:00 am

Post by rbottoms »

I can pay few dollars to get this finihsed. I shipped the demo off minus the fade in/out code but I really, really need it for version 0.02.

This combined with the fill dropdown box reqeust elsethread is the next bit of coding I need to advance the ball.

I am great believer in doing things for the community good, but people also need to make a living.

Besides, this is GPL so everyone will get to use it eventually.
Locked