Advertisement
Guest User

Untitled

a guest
Aug 19th, 2016
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.45 KB | None | 0 0
  1. /*
  2. ===============
  3. idPlayer::SpectateWinner
  4. ===============
  5. */
  6. void idPlayer::SpectateWinner( void ) {
  7.  
  8. idVec3 view, focusAngles, focusPoint, origin;
  9. trace_t trace;
  10. float focusDist, forwardScale, sideScale, endGameAngle, endGameRange, endGameHeight;
  11. idAngles angles;
  12. idMat3 axis;
  13. idBounds bounds;
  14. idEntity* vehicle = NULL;
  15. idEntity* ent = NULL;
  16. bool inVehicle = false;
  17. idPlayer* player;
  18.  
  19. if ( !gameLocal.IsSpectatingWinner() ) {
  20. return;
  21. }
  22.  
  23. fl.takedamage = false;
  24.  
  25. playerView.ClearEffects();
  26.  
  27. if ( pfl.hasInvisibility ) {
  28. Invisibility( false );
  29. }
  30.  
  31. ClearPowerUps();
  32.  
  33. ClearFocus();
  34.  
  35. if ( mphud ) {
  36. mphud->HandleNamedEvent( "spectateWinner" );
  37. }
  38.  
  39. winningEnt = gameLocal.mpGame.GetGameState()->winningEnt;
  40. winningTeam = gameLocal.mpGame.GetGameState()->winningTeam;
  41.  
  42. ent = winningEnt.GetEntity();
  43.  
  44. endGameAngle = GetLimitRandomFloat( 0, 1079 );
  45. endGameRange = GetLimitRandomFloat( 310, 530 );
  46. endGameHeight = GetLimitRandomFloat( 60, 180 );
  47.  
  48. //needed for mp inactive state->game review, dedicated server will crash if a player connects
  49. if ( !ent ) {
  50. ent = this;
  51. }
  52.  
  53. if ( ent->spawnArgs.GetFloat( "endViewHeight", "0" ) ) {
  54. endGameHeight -= ent->spawnArgs.GetFloat( "endViewHeight", "0" );
  55. }
  56.  
  57. if ( !ent->IsType( idPlayer::GetClassType() ) ) {
  58.  
  59. axis = ent->GetSpawnAxis();
  60. angles = ent->GetSpawnAxis().ToAngles();
  61. origin = ent->GetSpawnOrigin();
  62.  
  63. } else if ( ent->IsType( idPlayer::GetClassType() ) ) {
  64.  
  65. player = ent->GetStaticPlayer();
  66. inVehicle = player->IsInVehicle();
  67.  
  68. if ( !inVehicle ) {
  69.  
  70. angles = player->GetPhysics()->GetAxis().ToAngles();
  71. origin = player->GetPhysics()->GetOrigin();
  72. axis = player->GetPhysics()->GetAxis();
  73.  
  74. } else if ( inVehicle ) {
  75.  
  76. vehicle = GetEntityByNum( player->GetVehicleController().GetVehicle()->entityNumber );
  77. rvVehiclePosition * position = player->GetDriverPosition();
  78.  
  79. origin = position->GetOrigin();
  80. angles = position->GetAxis().ToAngles();
  81.  
  82. axis = position->GetAxis();
  83. }
  84.  
  85. }
  86.  
  87. focusPoint = origin + angles.ToForward() * THIRD_PERSON_FOCUS_DISTANCE;
  88. focusPoint.z += endGameHeight;
  89.  
  90. view = origin;
  91. view += physicsObj.GetGravityAxis()[2] * endGameHeight;
  92.  
  93. idMath::SinCos( DEG2RAD( endGameAngle ), sideScale, forwardScale );
  94. view -= endGameRange * forwardScale * axis[ 0 ];
  95. view += endGameRange * sideScale * axis[ 1 ];
  96.  
  97. if ( !inVehicle ) {
  98.  
  99. bounds = idBounds( idVec3( -4, -4, -4 ), idVec3( 4, 4, 4 ) );
  100. gameLocal.TraceBounds( ent, trace, origin, view, bounds, MASK_SOLID, ent );
  101.  
  102. if ( trace.fraction != 1.0f ) {
  103. view = trace.endpos;
  104. view += physicsObj.GetGravityAxis()[2] * ( 1.0f - trace.fraction ) * 32.0f;
  105.  
  106. gameLocal.TraceBounds( ent, trace, origin, view, bounds, MASK_SOLID, ent );
  107. view = trace.endpos;
  108. }
  109.  
  110. } else if ( inVehicle ) {
  111.  
  112. const idVec3 clip_mins( -4.0f, -4.0f, -4.0f );
  113. const idVec3 clip_maxs( 4.0f, 4.0f, 4.0f );
  114. const idBounds clip_bounds( clip_mins, clip_maxs );
  115. idClipModel clipBounds( clip_bounds );
  116. gameLocal.Translation( ent, trace, origin, view, &clipBounds, vehicle->GetPhysics()->GetAxis(), MASK_SOLID, vehicle, vehicle->GetBindMaster() );
  117.  
  118. if ( trace.fraction != 1.0 ) {
  119. view = trace.endpos;
  120. view += physicsObj.GetGravityAxis()[2] * ( 1.0f - trace.fraction ) * 32.0f;
  121. gameLocal.Translation( ent, trace, origin, view, &clipBounds, vehicle->GetPhysics()->GetAxis(), MASK_SOLID, vehicle, vehicle->GetBindMaster() );
  122. view = trace.endpos;
  123. }
  124.  
  125. }
  126.  
  127. focusPoint -= view;
  128. focusDist = idMath::Sqrt( focusPoint[0] * focusPoint[0] + focusPoint[1] * focusPoint[1] );
  129. if ( focusDist < 1.0f ) {
  130. focusDist = 1.0f;
  131. }
  132.  
  133. angles.pitch = RAD2DEG( idMath::ATan( focusPoint.z, focusDist ) );
  134. angles.yaw -= endGameAngle;
  135.  
  136. if ( !winnerCam ) {
  137. const idDict* modDict;
  138. idEntity* camEnt;
  139.  
  140. playerViewOrigin = firstPersonViewOrigin;
  141. playerViewAxis = firstPersonViewAxis;
  142.  
  143. modDict = gameLocal.FindEntityDefDict ( "func_cameraview", false );
  144. gameLocal.SpawnEntityDef( *modDict, &camEnt );
  145. winnerCam = static_cast<idCameraView*>(camEnt);
  146.  
  147. winnerCam->fl.networkSync = false;
  148. winnerCam->SetOrigin( view );
  149. winnerCam->SetAxis( angles.ToMat3() * physicsObj.GetGravityAxis() );
  150. winnerCam->GetRenderView()->viewID = 0;
  151.  
  152. } else {
  153.  
  154. DrawShadow( !head.IsValid() ? NULL : head.GetEntity()->GetRenderEntity() );
  155.  
  156. UpdateLiquidCamera( winnerCam->GetRenderView(), winnerCam );
  157.  
  158. }
  159.  
  160. UpdatePauseHud();
  161.  
  162. }
  163.  
  164. /*
  165. ===============
  166. idPlayer::ThirdPersonView
  167. ===============
  168. */
  169. void idPlayer::ThirdPersonView( float angle, float range, float height, bool clip, bool endGame, bool inVehicle ) {
  170. idVec3 view;
  171. idVec3 focusAngles;
  172. trace_t trace;
  173. idVec3 focusPoint;
  174. float focusDist;
  175. float forwardScale, sideScale;
  176. idVec3 origin;
  177. idAngles angles;
  178. idMat3 axis;
  179. idBounds bounds;
  180. idEntity* vehicle = NULL;
  181.  
  182. pfl.thirdpersonView = true;
  183.  
  184. angles = viewAngles;
  185. GetViewPos( origin, axis );
  186.  
  187. if ( inVehicle ) {
  188.  
  189. vehicle = vehicleController.GetVehicle();
  190. rvVehiclePosition * position = GetDriverPosition();
  191.  
  192. origin = position->GetEyeOrigin();
  193. angles = position->GetEyeAxis().ToAngles();
  194.  
  195. axis = position->GetAxis();
  196.  
  197. }
  198.  
  199. focusPoint = GetPhysics()->GetAbsBounds().GetCenter() + angles.ToForward() * THIRD_PERSON_FOCUS_DISTANCE;
  200. focusPoint.z += height;
  201.  
  202. view = origin;
  203. view += physicsObj.GetGravityAxis()[2] * (8.0f + height);
  204.  
  205. //if ( !inVehicle ) {
  206. idMath::SinCos( DEG2RAD( angle ), sideScale, forwardScale );
  207. view -= range * forwardScale * renderView->viewaxis[ 0 ];
  208. view += range * sideScale * renderView->viewaxis[ 1 ];
  209. //}
  210.  
  211. if ( clip && !inVehicle ) {
  212. bounds = idBounds( idVec3( -4, -4, -4 ), idVec3( 4, 4, 4 ) );
  213. gameLocal.TraceBounds( this, trace, origin, view, bounds, MASK_SOLID, this );
  214. if ( trace.fraction != 1.0f ) {
  215. view = trace.endpos;
  216. view += physicsObj.GetGravityAxis()[2] * ( 1.0f - trace.fraction ) * 32.0f;
  217.  
  218. gameLocal.TraceBounds( this, trace, origin, view, bounds, MASK_SOLID, this );
  219. view = trace.endpos;
  220. }
  221. } else if ( clip && inVehicle ) {
  222. const idVec3 clip_mins( -4.0f, -4.0f, -4.0f );
  223. const idVec3 clip_maxs( 4.0f, 4.0f, 4.0f );
  224. const idBounds clip_bounds( clip_mins, clip_maxs );
  225. idClipModel clipBounds( clip_bounds );
  226. gameLocal.Translation( this, trace, origin, view, &clipBounds, vehicle->GetPhysics()->GetAxis(), MASK_SOLID, vehicle, vehicle->GetBindMaster() );
  227. if ( trace.fraction != 1.0 )
  228. {
  229. view = trace.endpos;
  230. view += physicsObj.GetGravityAxis()[2] * ( 1.0f - trace.fraction ) * 32;
  231. gameLocal.Translation( this, trace, origin, view, &clipBounds, vehicle->GetPhysics()->GetAxis(), MASK_SOLID, vehicle, vehicle->GetBindMaster() );
  232. view = trace.endpos;
  233. }
  234. }
  235.  
  236. focusPoint -= view;
  237. focusDist = idMath::Sqrt( focusPoint[0] * focusPoint[0] + focusPoint[1] * focusPoint[1] );
  238. if ( focusDist < 1.0f ) {
  239. focusDist = 1.0f;
  240. }
  241.  
  242. angles.pitch = - RAD2DEG( idMath::ATan( focusPoint.z, focusDist ) );
  243. angles.yaw -= angle;
  244.  
  245. renderView->vieworg = view;
  246. renderView->viewaxis = angles.ToMat3() * physicsObj.GetGravityAxis();
  247. renderView->viewID = 0;
  248.  
  249. UpdateLiquidCamera( renderView, this );
  250.  
  251. }
  252.  
  253. void idPlayer::thirdPerson_zoomin( void ) {
  254.  
  255. int duration = 10;
  256.  
  257. rvVehicle * vehicle = NULL;
  258. if ( IsInVehicle ( ) ) {
  259. vehicle = vehicleController.GetVehicle();
  260.  
  261. //vehicle->thirdpersonRange;
  262. camera_zoom.Init( gameLocal.time, gameLocal.time + SEC2MS( pm_thirdPersonZoomTime.GetInteger() ), camera_zoom.GetCurrentValue( gameLocal.time ), ( camera_zoom.GetCurrentValue( gameLocal.time ) - 10 ) );
  263.  
  264. } else {
  265.  
  266. camera_zoom.Init( gameLocal.time, gameLocal.time + SEC2MS( pm_thirdPersonZoomTime.GetInteger() ), camera_zoom.GetCurrentValue( gameLocal.time ), ( camera_zoom.GetCurrentValue( gameLocal.time ) - 10 ) );
  267.  
  268. }
  269.  
  270. }
  271.  
  272. void idPlayer::thirdPerson_zoomout( void ) {
  273.  
  274. int duration = 10;
  275.  
  276. rvVehicle * vehicle = NULL;
  277. if ( IsInVehicle ( ) ) {
  278. vehicle = vehicleController.GetVehicle();
  279.  
  280. //vehicle->thirdpersonRange;
  281. camera_zoom.Init( gameLocal.time, gameLocal.time + SEC2MS( pm_thirdPersonZoomTime.GetInteger() ), camera_zoom.GetCurrentValue( gameLocal.time ), ( camera_zoom.GetCurrentValue( gameLocal.time ) + 10 ) );
  282.  
  283. } else {
  284.  
  285. camera_zoom.Init( gameLocal.time, gameLocal.time + SEC2MS( pm_thirdPersonZoomTime.GetInteger() ), camera_zoom.GetCurrentValue( gameLocal.time ), ( camera_zoom.GetCurrentValue( gameLocal.time ) + 10 ) );
  286.  
  287. }
  288.  
  289. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement