2
0
mirror of https://github.com/FWGS/hlsdk-xash3d synced 2024-11-25 11:19:39 +01:00
hlsdk-xash3d/cl_dll/hl/hl_objects.cpp

115 lines
3.1 KiB
C++
Raw Normal View History

2016-06-04 15:24:23 +02:00
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
2016-07-03 15:39:55 +02:00
2016-06-04 15:24:23 +02:00
#include "../hud.h"
#include "../cl_util.h"
#include "../demo.h"
#include "demo_api.h"
#include "const.h"
#include "entity_state.h"
#include "cl_entity.h"
#include "pm_defs.h"
#include "event_api.h"
#include "entity_types.h"
#include "r_efx.h"
extern BEAM *pBeam;
extern BEAM *pBeam2;
extern TEMPENTITY *pFlare; // Vit_amiN: egon's energy flare
2016-06-04 15:24:23 +02:00
void HUD_GetLastOrg( float *org );
2016-07-03 15:39:55 +02:00
void UpdateBeams( void )
2016-06-04 15:24:23 +02:00
{
vec3_t forward, vecSrc, vecEnd, origin, angles, right, up;
vec3_t view_ofs;
pmtrace_t tr;
cl_entity_t *pthisplayer = gEngfuncs.GetLocalPlayer();
int idx = pthisplayer->index;
// Get our exact viewangles from engine
gEngfuncs.GetViewAngles( (float *)angles );
// Determine our last predicted origin
HUD_GetLastOrg( (float *)&origin );
AngleVectors( angles, forward, right, up );
VectorCopy( origin, vecSrc );
2016-07-03 15:39:55 +02:00
2016-06-04 15:24:23 +02:00
VectorMA( vecSrc, 2048, forward, vecEnd );
gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true );
2016-07-03 15:39:55 +02:00
2016-06-04 15:24:23 +02:00
// Store off the old count
gEngfuncs.pEventAPI->EV_PushPMStates();
2016-07-03 15:39:55 +02:00
2016-06-04 15:24:23 +02:00
// Now add in all of the players.
2016-07-03 15:39:55 +02:00
gEngfuncs.pEventAPI->EV_SetSolidPlayers( idx - 1 );
2016-06-04 15:24:23 +02:00
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr );
gEngfuncs.pEventAPI->EV_PopPMStates();
2016-07-03 15:39:55 +02:00
if( pBeam )
2016-06-04 15:24:23 +02:00
{
pBeam->target = tr.endpos;
2019-10-13 13:49:25 +02:00
pBeam->die = gEngfuncs.GetClientTime() + 0.1f; // We keep it alive just a little bit forward in the future, just in case.
2016-06-04 15:24:23 +02:00
}
2016-07-03 15:39:55 +02:00
if( pBeam2 )
2016-06-04 15:24:23 +02:00
{
pBeam2->target = tr.endpos;
2019-10-13 13:49:25 +02:00
pBeam2->die = gEngfuncs.GetClientTime() + 0.1f; // We keep it alive just a little bit forward in the future, just in case.
2016-06-04 15:24:23 +02:00
}
if( pFlare ) // Vit_amiN: beam flare
{
pFlare->entity.origin = tr.endpos;
2019-10-13 13:49:25 +02:00
pFlare->die = gEngfuncs.GetClientTime() + 0.1f; // We keep it alive just a little bit forward in the future, just in case.
if( gEngfuncs.GetMaxClients() != 1 ) // Singleplayer always draws the egon's energy beam flare
{
pFlare->flags |= FTENT_NOMODEL;
2019-10-13 13:49:25 +02:00
if( !( tr.allsolid || tr.ent <= 0 || tr.fraction == 1.0f ) ) // Beam hit some non-world entity
{
physent_t *pEntity = gEngfuncs.pEventAPI->EV_GetPhysent( tr.ent );
// Not the world, let's assume that we hit something organic ( dog, cat, uncle joe, etc )
if( pEntity && !( pEntity->solid == SOLID_BSP || pEntity->movetype == MOVETYPE_PUSHSTEP ) )
{
pFlare->flags &= ~FTENT_NOMODEL;
}
}
}
}
2016-06-04 15:24:23 +02:00
}
/*
=====================
Game_AddObjects
Add game specific, client-side objects here
=====================
*/
void Game_AddObjects( void )
{
if( pBeam || pBeam2 || pFlare ) // Vit_amiN: egon flare added
2016-06-04 15:24:23 +02:00
UpdateBeams();
}