コード例 #1
0
        /*
         * ===============
         * G_SetClientEffects
         * ===============
         */
        public static void G_SetClientEffects(edict_t ent)
        {
            int pa_type;
            int remaining;

            ent.s.effects  = 0;
            ent.s.renderfx = 0;

            if (ent.health <= 0 || GameBase.level.intermissiontime != 0)
            {
                return;
            }

            if (ent.powerarmor_time > GameBase.level.time)
            {
                pa_type = GameItems.PowerArmorType(ent);

                if (pa_type == Defines.POWER_ARMOR_SCREEN)
                {
                    ent.s.effects |= Defines.EF_POWERSCREEN;
                }
                else if (pa_type == Defines.POWER_ARMOR_SHIELD)
                {
                    ent.s.effects  |= Defines.EF_COLOR_SHELL;
                    ent.s.renderfx |= Defines.RF_SHELL_GREEN;
                }
            }

            if (ent.client.quad_framenum > GameBase.level.framenum)
            {
                remaining = (int)ent.client.quad_framenum - GameBase.level.framenum;

                if (remaining > 30 || 0 != (remaining & 4))
                {
                    ent.s.effects |= Defines.EF_QUAD;
                }
            }

            if (ent.client.invincible_framenum > GameBase.level.framenum)
            {
                remaining = (int)ent.client.invincible_framenum - GameBase.level.framenum;

                if (remaining > 30 || 0 != (remaining & 4))
                {
                    ent.s.effects |= Defines.EF_PENT;
                }
            }

            // show cheaters!!!
            if ((ent.flags & Defines.FL_GODMODE) != 0)
            {
                ent.s.effects  |= Defines.EF_COLOR_SHELL;
                ent.s.renderfx |= Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE;
            }
        }
コード例 #2
0
ファイル: PlayerHud.cs プロジェクト: optimus-code/Quake2Sharp
        //=======================================================================

        /*
         * ===============
         * 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;
        }
コード例 #3
0
        private static int CheckPowerArmor(edict_t ent, float[] point, float[] normal, int damage, int dflags)
        {
            gclient_t client;
            int       save;
            int       power_armor_type;
            var       index = 0;
            int       damagePerCell;
            int       pa_te_type;
            var       power = 0;
            int       power_used;

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

            client = ent.client;

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

            if (client != null)
            {
                power_armor_type = GameItems.PowerArmorType(ent);

                if (power_armor_type != Defines.POWER_ARMOR_NONE)
                {
                    index = GameItems.ITEM_INDEX(GameItems.FindItem("Cells"));
                    power = client.pers.inventory[index];
                }
            }
            else if ((ent.svflags & Defines.SVF_MONSTER) != 0)
            {
                power_armor_type = ent.monsterinfo.power_armor_type;
                power            = ent.monsterinfo.power_armor_power;
            }
            else
            {
                return(0);
            }

            if (power_armor_type == Defines.POWER_ARMOR_NONE)
            {
                return(0);
            }

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

            if (power_armor_type == Defines.POWER_ARMOR_SCREEN)
            {
                float[] vec = { 0, 0, 0 };
                float   dot;
                float[] forward = { 0, 0, 0 };

                // only works if damage point is in front
                Math3D.AngleVectors(ent.s.angles, forward, null, null);
                Math3D.VectorSubtract(point, ent.s.origin, vec);
                Math3D.VectorNormalize(vec);
                dot = Math3D.DotProduct(vec, forward);

                if (dot <= 0.3)
                {
                    return(0);
                }

                damagePerCell = 1;
                pa_te_type    = Defines.TE_SCREEN_SPARKS;
                damage        = damage / 3;
            }
            else
            {
                damagePerCell = 2;
                pa_te_type    = Defines.TE_SHIELD_SPARKS;
                damage        = 2 * damage / 3;
            }

            save = power * damagePerCell;

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

            if (save > damage)
            {
                save = damage;
            }

            GameCombat.SpawnDamage(pa_te_type, point, normal, save);
            ent.powerarmor_time = GameBase.level.time + 0.2f;

            power_used = save / damagePerCell;

            if (client != null)
            {
                client.pers.inventory[index] -= power_used;
            }
            else
            {
                ent.monsterinfo.power_armor_power -= power_used;
            }

            return(save);
        }