Exemple #1
0
        public static void G_SetSpectatorStats(edict_t ent)
        {
            gclient_t cl = ent.client;

            if (null == cl.chase_target)
            {
                G_SetStats(ent);
            }
            cl.ps.stats[Defines.STAT_SPECTATOR] = 1;
            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[Defines.STAT_CHASE] = (short)(Defines.CS_PLAYERSKINS + cl.chase_target.index - 1);
            }
            else
            {
                cl.ps.stats[Defines.STAT_CHASE] = 0;
            }
        }
Exemple #2
0
        public static void ValidateSelectedItem(edict_t ent)
        {
            gclient_t cl = ent.client;

            if (cl.pers.inventory[cl.pers.selected_item] != 0)
            {
                return;
            }
            GameItems.SelectNextItem(ent, -1);
        }
Exemple #3
0
        public virtual void Read(QuakeFile f)
        {
            s.Read(f);
            inuse        = f.ReadBoolean();
            linkcount    = f.ReadInt32();
            num_clusters = f.ReadInt32();
            if (f.ReadInt32() != 9999)
            {
                new Exception("wrong read pos!").PrintStackTrace();
            }
            var len = f.ReadInt32();

            if (len == -1)
            {
                clusternums = null;
            }
            else
            {
                clusternums = new Int32[Defines.MAX_ENT_CLUSTERS];
                for (var n = 0; n < Defines.MAX_ENT_CLUSTERS; n++)
                {
                    clusternums[n] = f.ReadInt32();
                }
            }

            headnode                = f.ReadInt32();
            areanum                 = f.ReadInt32();
            areanum2                = f.ReadInt32();
            svflags                 = f.ReadInt32();
            mins                    = f.ReadVector();
            maxs                    = f.ReadVector();
            absmin                  = f.ReadVector();
            absmax                  = f.ReadVector();
            size                    = f.ReadVector();
            solid                   = f.ReadInt32();
            clipmask                = f.ReadInt32();
            movetype                = f.ReadInt32();
            flags                   = f.ReadInt32();
            model                   = f.ReadString();
            freetime                = f.ReadSingle();
            message                 = f.ReadString();
            classname               = f.ReadString();
            spawnflags              = f.ReadInt32();
            timestamp               = f.ReadSingle();
            angle                   = f.ReadSingle();
            target                  = f.ReadString();
            targetname              = f.ReadString();
            killtarget              = f.ReadString();
            team                    = f.ReadString();
            pathtarget              = f.ReadString();
            deathtarget             = f.ReadString();
            combattarget            = f.ReadString();
            target_ent              = f.ReadEdictRef();
            speed                   = f.ReadSingle();
            accel                   = f.ReadSingle();
            decel                   = f.ReadSingle();
            movedir                 = f.ReadVector();
            pos1                    = f.ReadVector();
            pos2                    = f.ReadVector();
            velocity                = f.ReadVector();
            avelocity               = f.ReadVector();
            mass                    = f.ReadInt32();
            air_finished            = f.ReadSingle();
            gravity                 = f.ReadSingle();
            goalentity              = f.ReadEdictRef();
            movetarget              = f.ReadEdictRef();
            yaw_speed               = f.ReadSingle();
            ideal_yaw               = f.ReadSingle();
            nextthink               = f.ReadSingle();
            prethink                = ( EntThinkAdapter )f.ReadAdapter();
            think                   = ( EntThinkAdapter )f.ReadAdapter();
            blocked                 = ( EntBlockedAdapter )f.ReadAdapter();
            touch                   = ( EntTouchAdapter )f.ReadAdapter();
            use                     = ( EntUseAdapter )f.ReadAdapter();
            pain                    = ( EntPainAdapter )f.ReadAdapter();
            die                     = ( EntDieAdapter )f.ReadAdapter();
            touch_debounce_time     = f.ReadSingle();
            pain_debounce_time      = f.ReadSingle();
            damage_debounce_time    = f.ReadSingle();
            fly_sound_debounce_time = f.ReadSingle();
            last_move_time          = f.ReadSingle();
            health                  = f.ReadInt32();
            max_health              = f.ReadInt32();
            gib_health              = f.ReadInt32();
            deadflag                = f.ReadInt32();
            show_hostile            = f.ReadInt32();
            powerarmor_time         = f.ReadSingle();
            map                     = f.ReadString();
            viewheight              = f.ReadInt32();
            takedamage              = f.ReadInt32();
            dmg                     = f.ReadInt32();
            radius_dmg              = f.ReadInt32();
            dmg_radius              = f.ReadSingle();
            sounds                  = f.ReadInt32();
            count                   = f.ReadInt32();
            chain                   = f.ReadEdictRef();
            enemy                   = f.ReadEdictRef();
            oldenemy                = f.ReadEdictRef();
            activator               = f.ReadEdictRef();
            groundentity            = f.ReadEdictRef();
            groundentity_linkcount  = f.ReadInt32();
            teamchain               = f.ReadEdictRef();
            teammaster              = f.ReadEdictRef();
            mynoise                 = f.ReadEdictRef();
            mynoise2                = f.ReadEdictRef();
            noise_index             = f.ReadInt32();
            noise_index2            = f.ReadInt32();
            volume                  = f.ReadSingle();
            attenuation             = f.ReadSingle();
            wait                    = f.ReadSingle();
            delay                   = f.ReadSingle();
            random                  = f.ReadSingle();
            teleport_time           = f.ReadSingle();
            watertype               = f.ReadInt32();
            waterlevel              = f.ReadInt32();
            move_origin             = f.ReadVector();
            move_angles             = f.ReadVector();
            light_level             = f.ReadInt32();
            style                   = f.ReadInt32();
            item                    = f.ReadItem();
            moveinfo.Read(f);
            monsterinfo.Read(f);
            var ndx = f.ReadInt32();

            if (ndx == -1)
            {
                client = null;
            }
            else
            {
                client = GameBase.game.clients[ndx];
            }
            owner = f.ReadEdictRef();
            if (f.ReadInt32() != 9876)
            {
                System.Diagnostics.Debug.WriteLine("ent load check failed for num " + index);
            }
        }
Exemple #4
0
        public static void ClientEndServerFrame(edict_t ent)
        {
            float bobtime;
            int   i;

            current_player = ent;
            current_client = ent.client;
            for (i = 0; i < 3; i++)
            {
                current_client.ps.pmove.origin[i]   = (short)(ent.s.origin[i] * 8);
                current_client.ps.pmove.velocity[i] = (short)(ent.velocity[i] * 8);
            }

            if (GameBase.level.intermissiontime != 0)
            {
                current_client.ps.blend[3] = 0;
                current_client.ps.fov      = 90;
                PlayerHud.G_SetStats(ent);
                return;
            }

            Math3D.AngleVectors(ent.client.v_angle, forward, right, up);
            P_WorldEffects();
            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] = SV_CalcRoll(ent.s.angles, ent.velocity) * 4;
            xyspeed = (float)Math.Sqrt(ent.velocity[0] * ent.velocity[0] + ent.velocity[1] * ent.velocity[1]);
            if (xyspeed < 5)
            {
                bobmove = 0;
                current_client.bobtime = 0;
            }
            else if (ent.groundentity != null)
            {
                if (xyspeed > 210)
                {
                    bobmove = 0.25F;
                }
                else if (xyspeed > 100)
                {
                    bobmove = 0.125F;
                }
                else
                {
                    bobmove = 0.0625F;
                }
            }

            bobtime = (current_client.bobtime += bobmove);
            if ((current_client.ps.pmove.pm_flags & pmove_t.PMF_DUCKED) != 0)
            {
                bobtime *= 4;
            }
            bobcycle   = (int)bobtime;
            bobfracsin = (float)Math.Abs(Math.Sin(bobtime * Math.PI));
            P_FallingDamage(ent);
            P_DamageFeedback(ent);
            SV_CalcViewOffset(ent);
            SV_CalcGunOffset(ent);
            SV_CalcBlend(ent);
            if (ent.client.resp.spectator)
            {
                PlayerHud.G_SetSpectatorStats(ent);
            }
            else
            {
                PlayerHud.G_SetStats(ent);
            }
            PlayerHud.G_CheckChaseStats(ent);
            G_SetClientEvent(ent);
            G_SetClientEffects(ent);
            G_SetClientSound(ent);
            G_SetClientFrame(ent);
            Math3D.VectorCopy(ent.velocity, ent.client.oldvelocity);
            Math3D.VectorCopy(ent.client.ps.viewangles, ent.client.oldviewangles);
            Math3D.VectorClear(ent.client.kick_origin);
            Math3D.VectorClear(ent.client.kick_angles);
            if (ent.client.showscores && 0 == (GameBase.level.framenum & 31))
            {
                PlayerHud.DeathmatchScoreboardMessage(ent, ent.enemy);
                GameBase.gi.Unicast(ent, false);
            }
        }