void PlayerPostThink_Post(edict_t *pEntity) { if(plinfo[ENTINDEX(pEntity)].pViewEnt) { edict_t *pCamEnt = plinfo[ENTINDEX(pEntity)].pViewEnt; MAKE_VECTORS(pEntity->v.v_angle + pEntity->v.punchangle); Vector vecSrc = pEntity->v.origin + pEntity->v.view_ofs; Vector vecAiming = gpGlobals->v_forward; TraceResult tr; switch(plinfo[ENTINDEX(pEntity)].iViewType) { case CAMERA_3RDPERSON: TRACE_LINE(vecSrc, vecSrc - (vecAiming * 128), ignore_monsters, ENT(pEntity), &tr); SET_VIEW(pEntity, pCamEnt); pCamEnt->v.origin = tr.vecEndPos; pCamEnt->v.angles = pEntity->v.v_angle; break; case CAMERA_UPLEFT: TRACE_LINE(vecSrc, vecSrc - ((vecAiming * 32) - ((gpGlobals->v_right * 15) + (gpGlobals->v_up * 15))), ignore_monsters, ENT(pEntity), &tr); SET_VIEW(pEntity, pCamEnt); pCamEnt->v.origin = tr.vecEndPos; pCamEnt->v.angles = pEntity->v.v_angle; break; case CAMERA_TOPDOWN: TRACE_LINE(vecSrc, vecSrc + Vector(0,0,2048), dont_ignore_monsters, ENT(pEntity), &tr); SET_VIEW(pEntity, pCamEnt); pCamEnt->v.origin = tr.vecEndPos; pCamEnt->v.origin.z -= 40; pCamEnt->v.angles = Vector(90,pEntity->v.v_angle.y,0); break; default: SET_VIEW(pEntity, pEntity); REMOVE_ENTITY(plinfo[ENTINDEX(pEntity)].pViewEnt); plinfo[ENTINDEX(pEntity)].iViewType = CAMERA_NONE; plinfo[ENTINDEX(pEntity)].pViewEnt = NULL; break; } } if (PlayerPostThinkForward != -1) { if (MF_ExecuteForward(PlayerPostThinkForward, (cell)ENTINDEX(pEntity))) RETURN_META(MRES_SUPERCEDE); } RETURN_META(MRES_IGNORED); }
// Attachview, this allows you to attach a player's view to an entity. // use AttachView(player, player) to reset view. //(vexd) static cell AMX_NATIVE_CALL attach_view(AMX *amx, cell *params) { int iIndex = params[1]; int iTargetIndex = params[2]; CHECK_ENTITY(iIndex); SET_VIEW(INDEXENT2(iIndex), INDEXENT2(iTargetIndex)); return 1; }
void CTriggerCamera :: UpdatePlayerView( void ) { int flags = 0; if( m_hActivator == NULL || !m_hActivator->edict() || !( m_hActivator->pev->flags & FL_CLIENT )) { ALERT( at_error, "Camera: No Client!\n" ); return; } if( pev->spawnflags & SF_CAMERA_PLAYER_TAKECONTROL ) { int state; if( GetState() == STATE_ON ) state = TRUE; else state = FALSE; // freeze player ((CBasePlayer *)((CBaseEntity *)m_hActivator))->EnableControl( state ); } #if 1 if( GetState() == STATE_OFF ) flags |= CAMERA_ON; else flags = 0; CBaseEntity *pCamera = UTIL_FindEntityByTargetname( NULL, STRING( pev->netname )); if( pCamera && !pCamera->IsBSPModel( )) UTIL_SetView( m_hActivator, pCamera, flags ); else UTIL_SetView( m_hActivator, this, flags ); #else // enchanced engine SET_VIEW (see code in client\global\view.cpp) if( GetState() == STATE_OFF ) SET_VIEW( m_hActivator->edict(), edict() ); else SET_VIEW( m_hActivator->edict(), m_hActivator->edict() ); #endif }
void CGrenade::Detonate( void ) { TraceResult tr; Vector vecSpot;// trace starts here! if(CVAR_GET_FLOAT(kvBulletCam)) { SET_VIEW(this->pev->owner, this->pev->owner); } vecSpot = pev->origin + Vector ( 0 , 0 , 8 ); UTIL_TraceLine ( vecSpot, vecSpot + Vector ( 0, 0, -40 ), ignore_monsters, ENT(pev), & tr); Explode( &tr, this->m_damageType); }
CGrenade * CGrenade:: ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time ) { CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL ); pGrenade->Spawn(); UTIL_SetOrigin( pGrenade->pev, vecStart ); pGrenade->pev->velocity = vecVelocity; pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity); pGrenade->pev->owner = ENT(pevOwner); pGrenade->SetTouch( &CGrenade::BounceTouch ); // Bounce if touched #ifdef DEBUG if(ns_cvar_float(&avh_bulletcam)) { SET_VIEW(ENT(pevOwner), ENT(pGrenade->pev)); } #endif // Take one second off of the desired detonation time and set the think to PreDetonate. PreDetonate // will insert a DANGER sound into the world sound list and delay detonation for one second so that // the grenade explodes after the exact amount of time specified in the call to ShootTimed(). pGrenade->pev->dmgtime = gpGlobals->time + time; pGrenade->SetThink( &CGrenade::TumbleThink ); pGrenade->pev->nextthink = gpGlobals->time + 0.1; if (time < 0.1) { pGrenade->pev->nextthink = gpGlobals->time; pGrenade->pev->velocity = Vector( 0, 0, 0 ); } pGrenade->pev->sequence = 0;//RANDOM_LONG( 3, 6 ); pGrenade->pev->framerate = 1.0; // Tumble through the air pGrenade->pev->avelocity.x = RANDOM_LONG(-800, -300); // Also explode on contact //pGrenade->SetTouch( ExplodeTouch ); pGrenade->pev->gravity = 0.5; pGrenade->pev->friction = 0.8; SET_MODEL(ENT(pGrenade->pev), "models/w_grenade.mdl"); return pGrenade; }
void CGrenade::Detonate( void ) { TraceResult tr; Vector vecSpot;// trace starts here! #ifdef DEBUG if(ns_cvar_float(&avh_bulletcam)) { SET_VIEW(this->pev->owner, this->pev->owner); } #endif vecSpot = pev->origin + Vector ( 0 , 0 , 8 ); UTIL_TraceLine ( vecSpot, vecSpot + Vector ( 0, 0, -40 ), ignore_monsters, ENT(pev), & tr); Explode( &tr, this->m_damageType); }
// SetView, this sets the view of a player. This is done by // Creating a camera entity, which follows the player. //(vexd) static cell AMX_NATIVE_CALL set_view(AMX *amx, cell *params) { int iIndex = params[1]; int iCameraType = params[2]; if (iIndex > gpGlobals->maxClients || !MF_IsPlayerIngame(iIndex)) { MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", iIndex); return 0; } edict_t *pPlayer = INDEXENT2(iIndex); edict_t *pNewCamera; switch(iCameraType) { case CAMERA_NONE: SET_VIEW(pPlayer, pPlayer); if(plinfo[ENTINDEX(pPlayer)].pViewEnt) { REMOVE_ENTITY(plinfo[ENTINDEX(pPlayer)].pViewEnt); } if (plinfo[ENTINDEX(pPlayer)].iViewType != CAMERA_NONE) // Verify that they were originally in a modified view { g_CameraCount--; if (g_CameraCount < 0) g_CameraCount=0; if (g_CameraCount==0) // Reset the AddToFullPack pointer if there's no more cameras in use... g_pFunctionTable->pfnAddToFullPack=NULL; } plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_NONE; plinfo[ENTINDEX(pPlayer)].pViewEnt = NULL; return 1; break; case CAMERA_3RDPERSON: if(plinfo[ENTINDEX(pPlayer)].iViewType != CAMERA_NONE) { plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_3RDPERSON; return 1; } g_CameraCount++; g_pFunctionTable_Post->pfnAddToFullPack=AddToFullPack_Post; g_pFunctionTable_Post->pfnPlayerPostThink=PlayerPostThink_Post; plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_3RDPERSON; pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target")); pNewCamera->v.classname = MAKE_STRING("VexdCam"); SET_MODEL(pNewCamera, "models/rpgrocket.mdl"); SET_SIZE(pNewCamera, Vector(0, 0, 0), Vector(0, 0, 0)); pNewCamera->v.movetype = MOVETYPE_NOCLIP; pNewCamera->v.solid = SOLID_NOT; pNewCamera->v.takedamage = DAMAGE_NO; pNewCamera->v.gravity = 0; pNewCamera->v.owner = pPlayer; pNewCamera->v.rendermode = kRenderTransColor; pNewCamera->v.renderamt = 0; pNewCamera->v.renderfx = kRenderFxNone; SET_VIEW(pPlayer, pNewCamera); plinfo[ENTINDEX(pPlayer)].pViewEnt = pNewCamera; break; case CAMERA_UPLEFT: if(plinfo[ENTINDEX(pPlayer)].iViewType != CAMERA_NONE) { plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_UPLEFT; return 1; } g_CameraCount++; g_pFunctionTable_Post->pfnAddToFullPack=AddToFullPack_Post; g_pFunctionTable_Post->pfnPlayerPostThink=PlayerPostThink_Post; plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_UPLEFT; pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target")); pNewCamera->v.classname = MAKE_STRING("VexdCam"); SET_MODEL(pNewCamera, "models/rpgrocket.mdl"); SET_SIZE(pNewCamera, Vector(0, 0, 0), Vector(0, 0, 0)); pNewCamera->v.movetype = MOVETYPE_NOCLIP; pNewCamera->v.solid = SOLID_NOT; pNewCamera->v.takedamage = DAMAGE_NO; pNewCamera->v.gravity = 0; pNewCamera->v.owner = pPlayer; pNewCamera->v.rendermode = kRenderTransColor; pNewCamera->v.renderamt = 0; pNewCamera->v.renderfx = kRenderFxNone; SET_VIEW(pPlayer, pNewCamera); plinfo[ENTINDEX(pPlayer)].pViewEnt = pNewCamera; break; case CAMERA_TOPDOWN: if(plinfo[ENTINDEX(pPlayer)].iViewType != CAMERA_NONE) { plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_TOPDOWN; return 1; } g_CameraCount++; g_pFunctionTable_Post->pfnAddToFullPack=AddToFullPack_Post; g_pFunctionTable_Post->pfnPlayerPostThink=PlayerPostThink_Post; plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_TOPDOWN; pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target")); pNewCamera->v.classname = MAKE_STRING("VexdCam"); SET_MODEL(pNewCamera, "models/rpgrocket.mdl"); SET_SIZE(pNewCamera, Vector(0, 0, 0), Vector(0, 0, 0)); pNewCamera->v.movetype = MOVETYPE_NOCLIP; pNewCamera->v.solid = SOLID_NOT; pNewCamera->v.takedamage = DAMAGE_NO; pNewCamera->v.gravity = 0; pNewCamera->v.owner = pPlayer; pNewCamera->v.rendermode = kRenderTransColor; pNewCamera->v.renderamt = 0; pNewCamera->v.renderfx = kRenderFxNone; SET_VIEW(pPlayer, pNewCamera); plinfo[ENTINDEX(pPlayer)].pViewEnt = pNewCamera; break; default: break; } return 1; }
/* <18afa5> ../cstrike/dlls/training_gamerules.cpp:195 */ void CHalfLifeTraining::__MAKE_VHOOK(PlayerKilled)(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) { SET_VIEW(pVictim->edict(), pVictim->edict()); FireTargets("game_playerdie", pVictim, pVictim, USE_TOGGLE, 0); }