Exemplo n.º 1
0
		public static idAngles ToAngles(this Matrix m)
		{
			float sp = m.M13;

			// cap off our sin value so that we don't get any NANs
			if(sp > 1.0f)
			{
				sp = 1.0f;
			}
			else if(sp < -1.0f)
			{
				sp = -1.0f;
			}

			double theta = -System.Math.Asin(sp);
			double cp = System.Math.Cos(theta);

			idAngles angles = new idAngles();

			if(cp > (8192.0f * idMath.Epsilon))
			{
				angles.Pitch = MathHelper.ToDegrees((float) theta);
				angles.Yaw = MathHelper.ToDegrees(idMath.Atan2(m.M12, m.M11));
				angles.Roll = MathHelper.ToDegrees(idMath.Atan2(m.M23, m.M33));
			}
			else
			{
				angles.Pitch = MathHelper.ToDegrees((float) theta);
				angles.Yaw = MathHelper.ToDegrees(-idMath.Atan2(m.M21, m.M22));
				angles.Roll = 0;
			}

			return angles;
		}
Exemplo n.º 2
0
		/// <summary>
		/// Called every time a client is placed fresh in the world: after the first ClientBegin, and after each respawn
		/// Initializes all non-persistant parts of playerState when called here with spectating set to true, just place yourself and init.
		/// </summary>
		/// <param name="origin"></param>
		/// <param name="angles"></param>
		public void SpawnToPoint(Vector3 origin, idAngles angles)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			Vector3 spectatorOrigin = Vector3.Zero;

			_respawning = true;

			Init();

			// TODO
			/*fl.noknockback = false;

			// stop any ragdolls being used
			StopRagdoll();*/

			// set back the player physics
			SetPhysics(_physicsObject);

			_physicsObject.SetClipModelAxis();
			_physicsObject.EnableClip();

			/*if ( !spectating ) {
				SetCombatContents( true );
			}*/

			_physicsObject.SetLinearVelocity(Vector3.Zero);

			// setup our initial view
			if(this.IsSpectating == false)
			{
				this.Origin = origin;
			}
			else
			{
				spectatorOrigin = origin;
				spectatorOrigin.Z += idR.CvarSystem.GetFloat("pm_normalheight");
				spectatorOrigin.Z += SpectateRaise;

				this.Origin = spectatorOrigin;
			}

			// if this is the first spawn of the map, we don't have a usercmd yet,
			// so the delta angles won't be correct.  This will be fixed on the first think.

			_viewAngles = idAngles.Zero;

			this.DeltaViewAngles = idAngles.Zero;
			this.ViewAngles = angles;

			_spawnAngles = angles;
			_spawnAnglesSet = false;

			/*legsForward = true;
			legsYaw = 0.0f;
			idealLegsYaw = 0.0f;
			oldViewYaw = viewAngles.yaw;*/
			
			if(this.IsSpectating == true)
			{
				Hide();
			}
			else
			{
				Show();
			}

			// TODO
			/*if ( gameLocal.isMultiplayer ) {
				if ( !spectating ) {
					// we may be called twice in a row in some situations. avoid a double fx and 'fly to the roof'
					if ( lastTeleFX < gameLocal.time - 1000 ) {
						idEntityFx::StartFx( spawnArgs.GetString( "fx_spawn" ), &spawn_origin, NULL, this, true );
						lastTeleFX = gameLocal.time;
					}
				}
				AI_TELEPORT = true;
			} else {
				AI_TELEPORT = false;
			}*/

			// TODO
			// kill anything at the new position
			if(this.IsSpectating == false)
			{
				_physicsObject.SetClipMask(ContentFlags.MaskPlayerSolid); // the clip mask is usually maintained in Move(), but KillBox requires it
				idConsole.Warning("TODO: gameLocal.KillBox( this );");
			}

			// don't allow full run speed for a bit
			//physicsObj.SetKnockBack( 100 );

			// set our respawn time and buttons so that if we're killed we don't respawn immediately
			/*minRespawnTime = gameLocal.time;
			maxRespawnTime = gameLocal.time;*/

			if(this.IsSpectating == false)
			{
				this.ForceRespawn = false;
			}

			// TODO: privateCameraView = NULL;

			BecomeActive(EntityThinkFlags.Think);

			// run a client frame to drop exactly to the floor,
			// initialize animations and other things
			Think();

			_respawning = false;

			/*lastManOver			= false;
			lastManPlayAgain	= false;
			isTelefragged		= false;*/
		}
Exemplo n.º 3
0
		/// <summary>
		/// Try to find a spawn point marked 'initial', otherwise use normal spawn selection.
		/// </summary>
		/// <param name="origin"></param>
		/// <param name="angles"></param>
		public void SelectInitialSpawnPoint(out Vector3 origin, out idAngles angles)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			idEntity spot = idR.Game.SelectInitialSpawnPoint(this);
			string skin = spot.SpawnArgs.GetString("skin", null);

			// set the player skin from the spawn location
			if(skin != null)
			{
				this.SpawnArgs.Set("spawn_skin", skin);
			}

			// activate the spawn locations targets
			idConsole.Warning("TODO: spot->PostEventMS(&EV_ActivateTargets, 0, this);");

			origin = spot.Physics.GetOrigin();
			origin.Z += 4.0f + idClipModel.BoxEpsilon; // move up to make sure the player is at least an epsilon above the floor

			angles = idHelper.AxisToAngles(spot.Physics.GetAxis());
		}
Exemplo n.º 4
0
		private void UpdateDeltaViewAngles(idAngles angles)
		{
			// set the delta angle
			idAngles delta = new idAngles();

			idConsole.Warning("TODO: delta.Pitch = angles.Pitch - idMath.ShortToAngle(_userCommand.Angles.Pitch);");
			idConsole.Warning("TODO: delta.Yaw = angles.Yaw - idMath.ShortToAngle(_userCommand.Angles.Yaw);");
			idConsole.Warning("TODO: delta.Pitch = angles.Roll - idMath.ShortToAngle(_userCommand.Angles.Roll);");

			this.DeltaViewAngles = delta;
		}
Exemplo n.º 5
0
		private void Init()
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			idConsole.Warning("TODO: idPlayer.Init");

			string value;
			// TODO
			// TODO: idKeyValue kv;
			/*
const idKeyValue	*kv;

noclip					= false;
godmode					= false;

oldButtons				= 0;
oldFlags				= 0;

currentWeapon			= -1;
idealWeapon				= -1;
previousWeapon			= -1;
weaponSwitchTime		= 0;
weaponEnabled			= true;
weapon_soulcube			= SlotForWeapon( "weapon_soulcube" );
weapon_pda				= SlotForWeapon( "weapon_pda" );
weapon_fists			= SlotForWeapon( "weapon_fists" );
showWeaponViewModel		= GetUserInfo()->GetBool( "ui_showGun" );


lastDmgTime				= 0;
lastArmorPulse			= -10000;
lastHeartAdjust			= 0;
lastHeartBeat			= 0;
heartInfo.Init( 0, 0, 0, 0 );

bobCycle				= 0;
bobFrac					= 0.0f;
landChange				= 0;
landTime				= 0;
zoomFov.Init( 0, 0, 0, 0 );
centerView.Init( 0, 0, 0, 0 );
fxFov					= false;

influenceFov			= 0;
influenceActive			= 0;
influenceRadius			= 0.0f;
influenceEntity			= NULL;
influenceMaterial		= NULL;
influenceSkin			= NULL;

currentLoggedAccel		= 0;

focusTime				= 0;
focusGUIent				= NULL;
focusUI					= NULL;
focusCharacter			= NULL;
talkCursor				= 0;
focusVehicle			= NULL;

// remove any damage effects
playerView.ClearEffects();

// damage values
fl.takedamage			= true;
ClearPain();

// restore persistent data
RestorePersistantInfo();

bobCycle		= 0;
stamina			= 0.0f;
healthPool		= 0.0f;
nextHealthPulse = 0;
healthPulse		= false;
nextHealthTake	= 0;
healthTake		= false;

SetupWeaponEntity();
currentWeapon = -1;
previousWeapon = -1;

heartRate = BASE_HEARTRATE;
AdjustHeartRate( BASE_HEARTRATE, 0.0f, 0.0f, true );

idealLegsYaw = 0.0f;
legsYaw = 0.0f;
legsForward	= true;
oldViewYaw = 0.0f;*/

			// set the pm_ cvars
			if((idR.Game.IsMultiplayer == false) || (idR.Game.IsServer == true))
			{
				foreach(KeyValuePair<string, string> kvp in this.SpawnArgs.MatchPrefix("pm_"))
				{
					idR.CvarSystem.SetString(kvp.Key, kvp.Value);
				}
			}

			// disable stamina on hell levels
			if((idR.Game.World != null) && (idR.Game.World.SpawnArgs.GetBool("no_stamina") == true))
			{
				idR.CvarSystem.SetFloat("pm_stamina", 0.0f);
			}

			// TODO
			// stamina always initialized to maximum
			/*stamina = pm_stamina.GetFloat();

			// air always initialized to maximum too
			airTics = pm_airTics.GetFloat();
			airless = false;

			gibDeath = false;
			gibsLaunched = false;
			gibsDir.Zero();*/

			// set the gravity
			_physicsObject.Gravity = idR.Game.Gravity;

			// start out standing
			/*SetEyeHeight(pm_normalviewheight.GetFloat());

			stepUpTime = 0;
			stepUpDelta = 0.0f;*/

			_viewBob = Vector3.Zero;
			_viewBobAngles = new idAngles();

			value = this.SpawnArgs.GetString("model", "");

			if(value != string.Empty)
			{
				SetModel(value);
			}

			if(_cursor != null)
			{
				_cursor.State.Set("talkcursor", 0);
				_cursor.State.Set("combatcursor", "1");
				_cursor.State.Set("itemcursor", "0");
				_cursor.State.Set("guicursor", "0");
			}

			if(((idR.Game.IsMultiplayer == true) || (idR.CvarSystem.GetBool("g_testDeath") == true)) && (_skin != null))
			{
				this.Skin = _skin;
				this.RenderEntity.MaterialParameters[6] = 0.0f;
			}
			else
			{
				string skin = this.SpawnArgs.GetString("spawn_skin", null);

				if(skin != null)
				{
					_skin = idR.DeclManager.FindSkin(skin);

					this.Skin = _skin;
					this.RenderEntity.MaterialParameters[6] = 0.0f;
				}
			}

			/* TODO: value = spawnArgs.GetString("bone_hips", "");
			hipJoint = animator.GetJointHandle(value);
			if(hipJoint == INVALID_JOINT)
			{
				gameLocal.Error("Joint '%s' not found for 'bone_hips' on '%s'", value, name.c_str());
			}

			value = spawnArgs.GetString("bone_chest", "");
			chestJoint = animator.GetJointHandle(value);
			if(chestJoint == INVALID_JOINT)
			{
				gameLocal.Error("Joint '%s' not found for 'bone_chest' on '%s'", value, name.c_str());
			}

			value = spawnArgs.GetString("bone_head", "");
			headJoint = animator.GetJointHandle(value);
			if(headJoint == INVALID_JOINT)
			{
				gameLocal.Error("Joint '%s' not found for 'bone_head' on '%s'", value, name.c_str());
			}

			// initialize the script variables
			AI_FORWARD = false;
			AI_BACKWARD = false;
			AI_STRAFE_LEFT = false;
			AI_STRAFE_RIGHT = false;
			AI_ATTACK_HELD = false;
			AI_WEAPON_FIRED = false;
			AI_JUMP = false;
			AI_DEAD = false;
			AI_CROUCH = false;
			AI_ONGROUND = true;
			AI_ONLADDER = false;
			AI_HARDLANDING = false;
			AI_SOFTLANDING = false;
			AI_RUN = false;
			AI_PAIN = false;
			AI_RELOAD = false;
			AI_TELEPORT = false;
			AI_TURN_LEFT = false;
			AI_TURN_RIGHT = false;

			// reset the script object*/
			ConstructScriptObject();

			// execute the script so the script object's constructor takes effect immediately
			/*scriptThread->Execute();*/

			// TODO: forceScoreBoard = false;
			this.ForceReady = false;


			/*privateCameraView = NULL;

			lastSpectateChange = 0;
			lastTeleFX = -9999;

			hiddenWeapon = false;
			tipUp = false;
			objectiveUp = false;
			teleportEntity = NULL;
			teleportKiller = -1;
			leader = false;

			SetPrivateCameraView(NULL);

			lastSnapshotSequence = 0;

			MPAim = -1;
			lastMPAim = -1;
			lastMPAimTime = 0;
			MPAimFadeTime = 0;
			MPAimHighlight = false;*/

			if(_hud != null)
			{
				_hud.HandleNamedEvent("aim_clear");
			}

			idR.CvarSystem.SetBool("ui_chat", false);
		}
Exemplo n.º 6
0
		/// <summary>
		/// 
		/// </summary>
		/// <remarks>
		/// Use exitEntityNum to specify a teleport with private camera view and delayed exit.
		/// </remarks>
		/// <param name="origin"></param>
		/// <param name="angles"></param>
		/// <param name="destination"></param>
		public override void Teleport(Vector3 origin, idAngles angles, idEntity destination)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			idConsole.Warning("TODO: idPlayer.Teleport");
		}
Exemplo n.º 7
0
		public override void GetViewPosition(out Vector3 origin, out Matrix axis)
		{
			idAngles angles = new idAngles();

			// if dead, fix the angle and don't add any kick
			if(this.Health <= 0)
			{
				angles.Yaw = _viewAngles.Yaw;
				angles.Roll = 40;
				angles.Pitch = -15;

				axis = angles.ToMatrix();
				origin = this.EyePosition;
			}
			else
			{
				origin = this.EyePosition + _viewBob;
				angles = _viewAngles + _viewBobAngles + _playerView.AngleOffset;
				axis = angles.ToMatrix() *_physicsObject.GravityAxis;

				// adjust the origin based on the camera nodal distance (eye distance from neck)
				float v = idR.CvarSystem.GetFloat("g_viewNodalZ");

				origin += _physicsObject.GravityNormal * v;
				origin += new Vector3(axis.M11, axis.M12, axis.M13) * v + new Vector3(axis.M31, axis.M32, axis.M33) * v;
			}
		}