PDA

View Full Version : Soundproof wall



Lonsofore
12th November 2017, 06:01
Hey Killtube. I don't want to hear steps and shots from the next room on my map.
Maybe anyone know, how to do something like soundproof wall? Or any way, how to avoid steps and shots sounds? (any!)
Thank you in advance.

kung foo man
12th November 2017, 09:30
Yo lonso, to get a little overview:

G_AddEvent: https://github.com/id-Software/Quake-III-Arena/blob/master/code/game/g_utils.c#L574
And PM_AddEvent: https://github.com/id-Software/Quake-III-Arena/blob/master/code/game/bg_pmove.c#L58

Interesting flags:




// TTimo
// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=551
#define SVF_CLIENTMASK 0x00000002

#define SVF_BOT 0x00000008 // set if the entity is a bot
#define SVF_BROADCAST 0x00000020 // send to all connected clients
#define SVF_PORTAL 0x00000040 // merge a second pvs at origin2 into snapshots
#define SVF_USE_CURRENT_ORIGIN 0x00000080 // entity->r.currentOrigin instead of entity->s.origin
// for link position (missiles and movers)
#define SVF_SINGLECLIENT 0x00000100 // only send to a single client (entityShared_t->singleClient)
#define SVF_NOSERVERINFO 0x00000200 // don't send CS_SERVERINFO updates to this client
// so that it can be updated for ping tools without
// lagging clients
#define SVF_CAPSULE 0x00000400 // use capsule for collision detection instead of bbox
#define SVF_NOTSINGLECLIENT 0x00000800 // send entity to everyone but one client
// (entityShared_t->singleClient)


Settable for:



void PM_AddEvent( int newEvent ) {
BG_AddPredictableEventToPlayerstate( newEvent, 0, pm->ps );
}

void SendPendingPredictableEvents( playerState_t *ps ) {
gentity_t *t;
int event, seq;
int extEvent, number;

// if there are still events pending
if ( ps->entityEventSequence < ps->eventSequence ) {
// create a temporary entity for this event which is sent to everyone
// except the client who generated the event
seq = ps->entityEventSequence & (MAX_PS_EVENTS-1);
event = ps->events[ seq ] | ( ( ps->entityEventSequence & 3 ) << 8 );
// set external event to zero before calling BG_PlayerStateToEntityState
extEvent = ps->externalEvent;
ps->externalEvent = 0;
// create temporary entity for event
t = G_TempEntity( ps->origin, event );
number = t->s.number;
BG_PlayerStateToEntityState( ps, &t->s, qtrue );
t->s.number = number;
t->s.eType = ET_EVENTS + event;
t->s.eFlags |= EF_PLAYER_EVENT;
t->s.otherEntityNum = ps->clientNum;
// send to everyone except the client who generated the event
t->r.svFlags |= SVF_NOTSINGLECLIENT; // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
t->r.singleClient = ps->clientNum;
// set back external event
ps->externalEvent = extEvent;
}
}


Those are kind the origins of the events, but that doesn't help much, since these functions are basically just "declaring" those events, so the engine makes them real later on by networking them to the clients.

The event funcs are called for all kinds of stuff, little overview from Quake 3... you can get the same for CoD2 with IDA, just right-click and "search xrefs" or something:

1377

1378

All the CoD2 events: https://github.com/voron00/libcod/blob/master/declarations.hpp#L275

The actual networking of those tempentities e.g. is done in the netcode, e.g. stuff like:

https://github.com/id-Software/Quake-III-Arena/blob/master/code/server/sv_snapshot.c#L283

Lots of aids code to reverse engineer, but the code is speaking about zones etc... I would try to mess around with portals inside the map first, before hacking into the code. But I never used map portals so far, but it seems quite legit that the engine culls away the events which are in different "zones" (like... over 4 steps away). Never messed with that so far.

CodRadiant BSP Portal tutorial: https://www.youtube.com/watch?v=E_yE56jP2tY

Lonsofore
12th November 2017, 10:25
We-ell, thank you a lot, kung, for a such detailed answer. As you said, I'll try portals first and write here about it.