Exemplo n.º 1
0
        private static int CheckArmor(edict_t ent, float[] point, float[] normal, int damage, int te_sparks, int dflags)
        {
            gclient_t client;
            int       save;
            int       index;
            gitem_t   armor;

            if (damage == 0)
            {
                return(0);
            }

            client = ent.client;

            if (client == null)
            {
                return(0);
            }

            if ((dflags & Defines.DAMAGE_NO_ARMOR) != 0)
            {
                return(0);
            }

            index = GameItems.ArmorIndex(ent);

            if (index == 0)
            {
                return(0);
            }

            armor = GameItems.GetItemByIndex(index);
            var garmor = (gitem_armor_t)armor.info;

            if (0 != (dflags & Defines.DAMAGE_ENERGY))
            {
                save = (int)Math.Ceiling(garmor.energy_protection * damage);
            }
            else
            {
                save = (int)Math.Ceiling(garmor.normal_protection * damage);
            }

            if (save >= client.pers.inventory[index])
            {
                save = client.pers.inventory[index];
            }

            if (save == 0)
            {
                return(0);
            }

            client.pers.inventory[index] -= save;
            GameCombat.SpawnDamage(te_sparks, point, normal, save);

            return(save);
        }
Exemplo n.º 2
0
        //=======================================================================

        /*
         * ===============
         * G_SetStats
         * ===============
         */
        public static void G_SetStats(edict_t ent)
        {
            gitem_t item;
            int     index, cells = 0;
            int     power_armor_type;

            //
            // health
            //
            ent.client.ps.stats[Defines.STAT_HEALTH_ICON] = (short)GameBase.level.pic_health;
            ent.client.ps.stats[Defines.STAT_HEALTH]      = (short)ent.health;

            //
            // ammo
            //
            if (0 == ent.client.ammo_index             /*
                                                        * ||
                                                        * !ent.client.pers.inventory[ent.client.ammo_index]
                                                        */
                )
            {
                ent.client.ps.stats[Defines.STAT_AMMO_ICON] = 0;
                ent.client.ps.stats[Defines.STAT_AMMO]      = 0;
            }
            else
            {
                item = GameItemList.itemlist[ent.client.ammo_index];
                ent.client.ps.stats[Defines.STAT_AMMO_ICON] = (short)GameBase.gi.imageindex(item.icon);
                ent.client.ps.stats[Defines.STAT_AMMO]      = (short)ent.client.pers.inventory[ent.client.ammo_index];
            }

            //
            // armor
            //
            power_armor_type = GameItems.PowerArmorType(ent);

            if (power_armor_type != 0)
            {
                cells = ent.client.pers.inventory[GameItems.ITEM_INDEX(GameItems.FindItem("cells"))];

                if (cells == 0)
                {
                    // ran out of cells for power armor
                    ent.flags &= ~Defines.FL_POWER_ARMOR;
                    GameBase.gi.sound(ent, Defines.CHAN_ITEM, GameBase.gi.soundindex("misc/power2.wav"), 1, Defines.ATTN_NORM, 0);
                    power_armor_type = 0;
                    ;
                }
            }

            index = GameItems.ArmorIndex(ent);

            if (power_armor_type != 0 && (0 == index || 0 != (GameBase.level.framenum & 8)))
            {
                // flash
                // between
                // power
                // armor
                // and
                // other
                // armor
                // icon
                ent.client.ps.stats[Defines.STAT_ARMOR_ICON] = (short)GameBase.gi.imageindex("i_powershield");
                ent.client.ps.stats[Defines.STAT_ARMOR]      = (short)cells;
            }
            else if (index != 0)
            {
                item = GameItems.GetItemByIndex(index);
                ent.client.ps.stats[Defines.STAT_ARMOR_ICON] = (short)GameBase.gi.imageindex(item.icon);
                ent.client.ps.stats[Defines.STAT_ARMOR]      = (short)ent.client.pers.inventory[index];
            }
            else
            {
                ent.client.ps.stats[Defines.STAT_ARMOR_ICON] = 0;
                ent.client.ps.stats[Defines.STAT_ARMOR]      = 0;
            }

            //
            // pickup message
            //
            if (GameBase.level.time > ent.client.pickup_msg_time)
            {
                ent.client.ps.stats[Defines.STAT_PICKUP_ICON]   = 0;
                ent.client.ps.stats[Defines.STAT_PICKUP_STRING] = 0;
            }

            //
            // timers
            //
            if (ent.client.quad_framenum > GameBase.level.framenum)
            {
                ent.client.ps.stats[Defines.STAT_TIMER_ICON] = (short)GameBase.gi.imageindex("p_quad");
                ent.client.ps.stats[Defines.STAT_TIMER]      = (short)((ent.client.quad_framenum - GameBase.level.framenum) / 10);
            }
            else if (ent.client.invincible_framenum > GameBase.level.framenum)
            {
                ent.client.ps.stats[Defines.STAT_TIMER_ICON] = (short)GameBase.gi.imageindex("p_invulnerability");
                ent.client.ps.stats[Defines.STAT_TIMER]      = (short)((ent.client.invincible_framenum - GameBase.level.framenum) / 10);
            }
            else if (ent.client.enviro_framenum > GameBase.level.framenum)
            {
                ent.client.ps.stats[Defines.STAT_TIMER_ICON] = (short)GameBase.gi.imageindex("p_envirosuit");
                ent.client.ps.stats[Defines.STAT_TIMER]      = (short)((ent.client.enviro_framenum - GameBase.level.framenum) / 10);
            }
            else if (ent.client.breather_framenum > GameBase.level.framenum)
            {
                ent.client.ps.stats[Defines.STAT_TIMER_ICON] = (short)GameBase.gi.imageindex("p_rebreather");
                ent.client.ps.stats[Defines.STAT_TIMER]      = (short)((ent.client.breather_framenum - GameBase.level.framenum) / 10);
            }
            else
            {
                ent.client.ps.stats[Defines.STAT_TIMER_ICON] = 0;
                ent.client.ps.stats[Defines.STAT_TIMER]      = 0;
            }

            //
            // selected item
            //
            // bugfix rst
            if (ent.client.pers.selected_item <= 0)
            {
                ent.client.ps.stats[Defines.STAT_SELECTED_ICON] = 0;
            }
            else
            {
                ent.client.ps.stats[Defines.STAT_SELECTED_ICON] = (short)GameBase.gi.imageindex(GameItemList.itemlist[ent.client.pers.selected_item].icon);
            }

            ent.client.ps.stats[Defines.STAT_SELECTED_ITEM] = (short)ent.client.pers.selected_item;

            //
            // layouts
            //
            ent.client.ps.stats[Defines.STAT_LAYOUTS] = 0;

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

                if (ent.client.showinventory && ent.client.pers.health > 0)
                {
                    ent.client.ps.stats[Defines.STAT_LAYOUTS] |= 2;
                }
            }
            else
            {
                if (ent.client.showscores || ent.client.showhelp)
                {
                    ent.client.ps.stats[Defines.STAT_LAYOUTS] |= 1;
                }

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

            //
            // frags
            //
            ent.client.ps.stats[Defines.STAT_FRAGS] = (short)ent.client.resp.score;

            //
            // help icon / current weapon if not shown
            //
            if (ent.client.pers.helpchanged != 0 && (GameBase.level.framenum & 8) != 0)
            {
                ent.client.ps.stats[Defines.STAT_HELPICON] = (short)GameBase.gi.imageindex("i_help");
            }
            else if ((ent.client.pers.hand == Defines.CENTER_HANDED || ent.client.ps.fov > 91) && ent.client.pers.weapon != null)
            {
                ent.client.ps.stats[Defines.STAT_HELPICON] = (short)GameBase.gi.imageindex(ent.client.pers.weapon.icon);
            }
            else
            {
                ent.client.ps.stats[Defines.STAT_HELPICON] = 0;
            }

            ent.client.ps.stats[Defines.STAT_SPECTATOR] = 0;
        }