示例#1
0
        private void UpdateFace()
        {
            var plyr = world.Players[world.Options.ConsolePlayer];

            if (priority < 10)
            {
                // dead
                if (plyr.Health == 0)
                {
                    priority     = 9;
                    st_faceindex = DoomInfo.FaceInfos.ST_DEADFACE;
                    st_facecount = 1;
                }
            }

            if (priority < 9)
            {
                if (plyr.BonusCount != 0)
                {
                    // picking up bonus
                    var doevilgrin = false;

                    for (var i = 0; i < DoomInfo.WeaponInfos.Length; i++)
                    {
                        if (oldweaponsowned[i] != plyr.WeaponOwned[i])
                        {
                            doevilgrin         = true;
                            oldweaponsowned[i] = plyr.WeaponOwned[i];
                        }
                    }
                    if (doevilgrin)
                    {
                        // evil grin if just picked up weapon
                        priority     = 8;
                        st_facecount = DoomInfo.FaceInfos.ST_EVILGRINCOUNT;
                        st_faceindex = ST_calcPainOffset() + DoomInfo.FaceInfos.ST_EVILGRINOFFSET;
                    }
                }
            }

            if (priority < 8)
            {
                if (plyr.DamageCount != 0 &&
                    plyr.Attacker != null &&
                    plyr.Attacker != plyr.Mobj)
                {
                    // being attacked
                    priority = 7;

                    if (plyr.Health - st_oldhealth > DoomInfo.FaceInfos.ST_MUCHPAIN)
                    {
                        st_facecount = DoomInfo.FaceInfos.ST_TURNCOUNT;
                        st_faceindex = ST_calcPainOffset() + DoomInfo.FaceInfos.ST_OUCHOFFSET;
                    }
                    else
                    {
                        var badguyangle = Geometry.PointToAngle(
                            plyr.Mobj.X, plyr.Mobj.Y,
                            plyr.Attacker.X, plyr.Attacker.Y);

                        Angle diffang;
                        bool  i;

                        if (badguyangle > plyr.Mobj.Angle)
                        {
                            // whether right or left
                            diffang = badguyangle - plyr.Mobj.Angle;
                            i       = diffang > Angle.Ang180;
                        }
                        else
                        {
                            // whether left or right
                            diffang = plyr.Mobj.Angle - badguyangle;
                            i       = diffang <= Angle.Ang180;
                        }                         // confusing, aint it?

                        st_facecount = DoomInfo.FaceInfos.ST_TURNCOUNT;
                        st_faceindex = ST_calcPainOffset();

                        if (diffang < Angle.Ang45)
                        {
                            // head-on
                            st_faceindex += DoomInfo.FaceInfos.ST_RAMPAGEOFFSET;
                        }
                        else if (i)
                        {
                            // turn face right
                            st_faceindex += DoomInfo.FaceInfos.ST_TURNOFFSET;
                        }
                        else
                        {
                            // turn face left
                            st_faceindex += DoomInfo.FaceInfos.ST_TURNOFFSET + 1;
                        }
                    }
                }
            }

            if (priority < 7)
            {
                // getting hurt because of your own damn stupidity
                if (plyr.DamageCount != 0)
                {
                    if (plyr.Health - st_oldhealth > DoomInfo.FaceInfos.ST_MUCHPAIN)
                    {
                        priority     = 7;
                        st_facecount = DoomInfo.FaceInfos.ST_TURNCOUNT;
                        st_faceindex = ST_calcPainOffset() + DoomInfo.FaceInfos.ST_OUCHOFFSET;
                    }
                    else
                    {
                        priority     = 6;
                        st_facecount = DoomInfo.FaceInfos.ST_TURNCOUNT;
                        st_faceindex = ST_calcPainOffset() + DoomInfo.FaceInfos.ST_RAMPAGEOFFSET;
                    }
                }
            }

            if (priority < 6)
            {
                // rapid firing
                if (plyr.AttackDown)
                {
                    if (lastattackdown == -1)
                    {
                        lastattackdown = DoomInfo.FaceInfos.ST_RAMPAGEDELAY;
                    }
                    else if (--lastattackdown == 0)
                    {
                        priority       = 5;
                        st_faceindex   = ST_calcPainOffset() + DoomInfo.FaceInfos.ST_RAMPAGEOFFSET;
                        st_facecount   = 1;
                        lastattackdown = 1;
                    }
                }
                else
                {
                    lastattackdown = -1;
                }
            }

            if (priority < 5)
            {
                // invulnerability
                if ((plyr.Cheats & CheatFlags.GodMode) != 0 ||
                    plyr.Powers[(int)PowerType.Invulnerability] != 0)
                {
                    priority = 4;

                    st_faceindex = DoomInfo.FaceInfos.ST_GODFACE;
                    st_facecount = 1;
                }
            }

            // look left or look right if the facecount has timed out
            if (st_facecount == 0)
            {
                st_faceindex = ST_calcPainOffset() + (st_randomnumber % 3);
                st_facecount = DoomInfo.FaceInfos.ST_STRAIGHTFACECOUNT;
                priority     = 0;
            }

            st_facecount--;
        }