ClientPutInServer(edict_t *pEntity)
. A connecting proxy has set the new FL_PROXY
flag in pEntitiy->v.flags
. Make sure to keep this flag while spawning the new player. The proxy sends a client command "spectate" after it is fully connected. Then the proxy should be assigned to some kind of spectator team (as used in TFC or CS). In SetupVisibility()
for all clients with FL_PROXY
flag set, a NULL PVS
& PAS
is returned. That way all entities and events are transmitted to spectator proxies.CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor )
MESSAGE_BEGIN( MSG_SPEC, SVC_DIRECTOR );
WRITE_BYTE ( DRC_EVENT );
WRITE_SHORT( ENTINDEX(pVictim->edict()) );
WRITE_SHORT( ENTINDEX(ENT(pKiller)) );
WRITE_LONG( 7 | DRC_FLAG_DRAMATIC);
MESSAGE_END();
MSG_SPEC
ensures that only proxies get these messages. SVC_SPECTATOR
is a new server command used for all proxy-related functions. All director event messages start with the DRC_EVENT
byte. The first short Integer is the entity number of the primary object. The second short Integer is the number of another involved entity, but it could also be null, in which case the director module chooses the closest player as the secondary camera target, if possible. The last long Integer contains the priority (7 in this example) and some additional information about the type of the event. In this case it's a dramatic event, so the camera position and angle is chosen lower and nearer to emphasize this.
IsSpectateOnly()
returns true if the client is connected to a HLTV proxy or retrieves data from a multicast stream. LoadMapSprite(char *filename)
loads a TGA file (or 256 color BMP in software mode), cuts it into small tiles of 128x128 pixel, and stores it in the frames of a sprite structure. This way you can load a large map image and draw it within HUD_DrawNormalTriangles()
.CHudSpectator
. Some of the code may look unusual because the logic in multicast mode is a bit different. The client must do everything on its own, especially handling keyboard events in HudSpectator::HandleButtons()
, since there is no real game DLL that the client is connected to. There is also a callback function, HUD_DirectorEvent()
, which is executed by the engine if a SVC_DIRECTOR
message is received. Each time a client enters a level as spectator, the DRC_ACTIVE
event is fired so the client can reset all settings, parse the overview description file for the level, and load the overview map image. During the game, the proxy sends a DRC_CAMERA
event at certain time intervals that tells the client which targets it should follow in "Directed Mode."V_CalcRefdef()
about the current viewpoint and view direction. Then it drew the world, and the client could add some extra objects in HUD_DrawNormalTriangles()
. Now, you can draw more than one view per frame. All you have to do is set pparams->nextFrame to something other than null. Also, each time you can change the size and position of the next viewport by filling the pparams->viewport
structure. Finally, if you set pparams->onlyClientDraw
, the engine won't draw anything except objects in HUD_DrawNormalTriangles()
or HUD_DrawTransparentTriangles()
. If you leave all these new fields untouched, the engine will behave exactly as it used to. All these new features are used in V_CalcSpectatorRefdef()
, but they could also be used for normal clients (for example, you could do a rearview mirror for players ). Note that all of these features are only available in OpenGL/DirectX Mode, not Software Mode (except pparams->onlyClientDraw
).CHudSpectator::DrawOverviewLayer()
. By default, a map image is divided into 8*6 tiles, which are stored in the frames of one sprite. If no map image is present, a green grid will be drawn instead. The entity icons are stored in a list m_OverviewEntities[]
. This list is updated each frame in HUD_AddEntity()
for every entity by calling CHudSpectator::AddOverviewEntity()
. AddOverviewEntity()
determines for each entity if an icon should be drawn for that entity and which icon to draw. Entities that should be drawn make it into the list and get a duration, how long they should be drawn (at least 1 frame). The entities are drawn by DrawOverviewEntities()
, and old ones are removed from this list in CheckOverviewEntities()
.dev_overview
" to create new map images. If set to "1", the engine draws the level from above, looking down, but using orthographic projection instead of the normal perspective projection. This is done to avoid perspective distortions in overview mode. The engine will write the current parameters to the console (make sure to set developer 1 also) like so:// overview description file for de_vegas.bsp
global
{
ZOOM 1.63
ORIGIN 1903 -1283 -1088
ROTATED 0
}
layer
{
IMAGE "overviews/de_vegas.tga"
HEIGHT -1088
}
The global section describes zoom, the origin point the map is rotated around, and a boolean to indicate if the map image is rotated or not. The layer section describes the map image filename and at which height (z-axis) the map should be shown. The overview mode uses the some coordinate space as the game world and all icons are drawn at the same position as their corresponding entities (you could even combine map and world mode. For example real players and items moving over a map blueprint). In software mode, map images should be BMP files with 512x384x8 resolution.LoadMapSprite()
functions. It's not really needed for HLTV support.You must log in to post a comment. You can login or register a new account.