示例#1
0
        /*
         * ===============
         * G_SetSpectatorStats
         * ===============
         */
        public static void G_SetSpectatorStats(edict_t ent)
        {
            var cl = ent.client;

            if (null == cl.chase_target)
            {
                PlayerHud.G_SetStats(ent);
            }

            cl.ps.stats[Defines.STAT_SPECTATOR] = 1;

            // layouts are independant in spectator
            cl.ps.stats[Defines.STAT_LAYOUTS] = 0;

            if (cl.pers.health <= 0 || GameBase.level.intermissiontime != 0 || cl.showscores)
            {
                cl.ps.stats[Defines.STAT_LAYOUTS] |= 1;
            }

            if (cl.showinventory && cl.pers.health > 0)
            {
                cl.ps.stats[Defines.STAT_LAYOUTS] |= 2;
            }

            if (cl.chase_target != null && cl.chase_target.inuse)
            {
                //cl.ps.stats[STAT_CHASE] = (short) (CS_PLAYERSKINS +
                // (cl.chase_target - g_edicts) - 1);
                cl.ps.stats[Defines.STAT_CHASE] = (short)(Defines.CS_PLAYERSKINS + cl.chase_target.index - 1);
            }
            else
            {
                cl.ps.stats[Defines.STAT_CHASE] = 0;
            }
        }
示例#2
0
        /**
         * Called for each player at the end of the server frame and right after
         * spawning.
         */
        public static void ClientEndServerFrame(edict_t ent)
        {
            float bobtime;
            int   i;

            PlayerView.current_player = ent;
            PlayerView.current_client = ent.client;

            //
            // If the origin or velocity have changed since ClientThink(),
            // update the pmove values. This will happen when the client
            // is pushed by a bmodel or kicked by an explosion.
            //
            // If it wasn't updated here, the view position would lag a frame
            // behind the body position when pushed -- "sinking into plats"
            //
            for (i = 0; i < 3; i++)
            {
                PlayerView.current_client.ps.pmove.origin[i]   = (short)(ent.s.origin[i] * 8.0);
                PlayerView.current_client.ps.pmove.velocity[i] = (short)(ent.velocity[i] * 8.0);
            }

            //
            // If the end of unit layout is displayed, don't give
            // the player any normal movement attributes
            //
            if (GameBase.level.intermissiontime != 0)
            {
                // FIXME: add view drifting here?
                PlayerView.current_client.ps.blend[3] = 0;
                PlayerView.current_client.ps.fov      = 90;
                PlayerHud.G_SetStats(ent);

                return;
            }

            Math3D.AngleVectors(ent.client.v_angle, PlayerView.forward, PlayerView.right, PlayerView.up);

            // burn from lava, etc
            PlayerView.P_WorldEffects();

            //
            // set model angles from view angles so other things in
            // the world can tell which direction you are looking
            //
            if (ent.client.v_angle[Defines.PITCH] > 180)
            {
                ent.s.angles[Defines.PITCH] = (-360 + ent.client.v_angle[Defines.PITCH]) / 3;
            }
            else
            {
                ent.s.angles[Defines.PITCH] = ent.client.v_angle[Defines.PITCH] / 3;
            }

            ent.s.angles[Defines.YAW]  = ent.client.v_angle[Defines.YAW];
            ent.s.angles[Defines.ROLL] = 0;
            ent.s.angles[Defines.ROLL] = PlayerView.SV_CalcRoll(ent.s.angles, ent.velocity) * 4;

            //
            // calculate speed and cycle to be used for
            // all cyclic walking effects
            //
            PlayerView.xyspeed = (float)Math.Sqrt(ent.velocity[0] * ent.velocity[0] + ent.velocity[1] * ent.velocity[1]);

            if (PlayerView.xyspeed < 5)
            {
                PlayerView.bobmove = 0;
                PlayerView.current_client.bobtime = 0;                 // start at beginning of cycle again
            }
            else if (ent.groundentity != null)
            {
                // so bobbing only cycles when on
                // ground
                if (PlayerView.xyspeed > 210)
                {
                    PlayerView.bobmove = 0.25f;
                }
                else if (PlayerView.xyspeed > 100)
                {
                    PlayerView.bobmove = 0.125f;
                }
                else
                {
                    PlayerView.bobmove = 0.0625f;
                }
            }

            bobtime = PlayerView.current_client.bobtime += PlayerView.bobmove;

            if ((PlayerView.current_client.ps.pmove.pm_flags & pmove_t.PMF_DUCKED) != 0)
            {
                bobtime *= 4;
            }

            PlayerView.bobcycle   = (int)bobtime;
            PlayerView.bobfracsin = (float)Math.Abs(Math.Sin(bobtime * Math.PI));

            // detect hitting the floor
            PlayerView.P_FallingDamage(ent);

            // apply all the damage taken this frame
            PlayerView.P_DamageFeedback(ent);

            // determine the view offsets
            PlayerView.SV_CalcViewOffset(ent);

            // determine the gun offsets
            PlayerView.SV_CalcGunOffset(ent);

            // determine the full screen color blend
            // must be after viewoffset, so eye contents can be
            // accurately determined
            // FIXME: with client prediction, the contents
            // should be determined by the client
            PlayerView.SV_CalcBlend(ent);

            // chase cam stuff
            if (ent.client.resp.spectator)
            {
                PlayerHud.G_SetSpectatorStats(ent);
            }
            else
            {
                PlayerHud.G_SetStats(ent);
            }

            PlayerHud.G_CheckChaseStats(ent);

            PlayerView.G_SetClientEvent(ent);

            PlayerView.G_SetClientEffects(ent);

            PlayerView.G_SetClientSound(ent);

            PlayerView.G_SetClientFrame(ent);

            Math3D.VectorCopy(ent.velocity, ent.client.oldvelocity);
            Math3D.VectorCopy(ent.client.ps.viewangles, ent.client.oldviewangles);

            // clear weapon kicks
            Math3D.VectorClear(ent.client.kick_origin);
            Math3D.VectorClear(ent.client.kick_angles);

            // if the scoreboard is up, update it
            if (ent.client.showscores && 0 == (GameBase.level.framenum & 31))
            {
                PlayerHud.DeathmatchScoreboardMessage(ent, ent.enemy);
                GameBase.gi.unicast(ent, false);
            }
        }