halflife-thewastes-sdk/cl_dll/thewastes/hl_objects.cpp

152 lines
3.5 KiB
C++

/***
*
* Copyright (c) 1996-2001, 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.
*
****/
#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"
#include "twm.h"
#include "../twmmanager.h"
#include "../ParseBspEnt.h"
#include "../ParseBsp.h"
#include "../tri.h"
#include "../ParticleBase.h"
extern cvar_t *cl_enablefog;
int EnvFog_SetFog();
void HUD_GetLastOrg( float *org );
void UpdateBeams ( void )
{
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 );
VectorMA( vecSrc, 2048, forward, vecEnd );
gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true );
// Store off the old count
gEngfuncs.pEventAPI->EV_PushPMStates();
// Now add in all of the players.
gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 );
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr );
gEngfuncs.pEventAPI->EV_PopPMStates();
}
void Game_CrosshairInfo()
{
vec3_t angles,origin,forward,right,up,src,dest;
pmtrace_t tr;
cl_entity_t *pLocalPlayer = gEngfuncs.GetLocalPlayer();
int idx = pLocalPlayer->index;
// Get player's origin and angle
gEngfuncs.GetViewAngles((float*)&angles);
HUD_GetLastOrg((float*)&origin);
AngleVectors(angles,forward,right,up);
// Set up source and dest vectors
VectorCopy(origin,src);
VectorMA(src,128,forward,dest);
// Trace ahead to find a player
gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction(false,true);
// Store off the old count
gEngfuncs.pEventAPI->EV_PushPMStates();
// Now add in all of the players.
gEngfuncs.pEventAPI->EV_SetSolidPlayers(idx - 1);
gEngfuncs.pEventAPI->EV_SetTraceHull(2);
gEngfuncs.pEventAPI->EV_PlayerTrace(src,dest,PM_STUDIO_BOX,-1,&tr);
gEngfuncs.pEventAPI->EV_PopPMStates();
// We hit something
if(tr.fraction != 1.0f)
gHUD.m_CrosshairInfo.UpdateInfo(tr.ent);
}
/*
=====================
Game_AddObjects
Add game specific, client-side objects here
=====================
*/
void Game_AddObjects( void )
{
}
/*
=====================
Game_UpdateObjects
Update info needed
=====================
*/
void Game_UpdateObjects(double frametime)
{
// Update particles
g_ParticleSystemManager.Update( frametime );
// Update crosshair
Game_CrosshairInfo();
// Update 3d muzzleflashes
TWM_UPDATE_ARRAY(g_MuzzleflashModels,g_iNumMuzzleflashModels,frametime);
// Update fog
if(!EnvFog_SetFog())
{
R_SetFog(g_Worldspawn.flFogcolor_r,
g_Worldspawn.flFogcolor_g,
g_Worldspawn.flFogcolor_b,
g_Worldspawn.flFogcolor_start,
g_Worldspawn.flFogcolor_end,
cl_enablefog->value ? g_Worldspawn.iEnableFog : 0);
}
}