Exemple #1
0
        public override int DefenseProc(Character enemy, int damage)
        {
            var thorns = Buff <RingOfThorns.Thorns>();

            if (thorns != null)
            {
                var dmg = Random.IntRange(0, damage);
                if (dmg > 0)
                {
                    enemy.Damage(dmg, thorns);
                }
            }

            var armor = Buff <Earthroot.Armor>();

            if (armor != null)
            {
                damage = armor.Absorb(damage);
            }

            if (Belongings.Armor != null)
            {
                damage = Belongings.Armor.Proc(enemy, this, damage);
            }

            return(damage);
        }
Exemple #2
0
        public override int DamageRoll()
        {
            var wep = RangedWeapon ?? Belongings.Weapon;
            int dmg;

            if (wep != null)
            {
                dmg = wep.DamageRoll(this);
            }
            else
            {
                dmg = STR > 10 ? Random.IntRange(1, STR - 9) : 1;
            }

            return(Buff <Fury>() != null ? (int)(dmg * 1.5f) : dmg);
        }
Exemple #3
0
        public virtual void Damage(int dmg, object src)
        {
            if (HP <= 0)
            {
                return;
            }

            buffs.Buff.Detach <Frost>(this);

            var srcClass = src.GetType();

            if (Immunities().Contains(srcClass))
            {
                dmg = 0;
            }
            else
            if (Resistances().Contains(srcClass))
            {
                dmg = Random.IntRange(0, dmg);
            }

            if (Buff <Paralysis>() != null)
            {
                if (Random.Int(dmg) >= Random.Int(HP))
                {
                    buffs.Buff.Detach <Paralysis>(this);
                    if (Dungeon.Visible[pos])
                    {
                        GLog.Information(TxtOutOfParalysis, Name);
                    }
                }
            }

            HP -= dmg;

            if (dmg > 0 || src is Character)
            {
                Sprite.ShowStatus(HP > HT / 2 ? CharSprite.Warning : CharSprite.Negative, dmg.ToString());
            }

            if (HP <= 0)
            {
                Die(src);
            }
        }
Exemple #4
0
        public static void Init()
        {
#if !Console
            Challenges = PixelDungeon.Challenges();
#endif

            Actor.Clear();

            PathFinder.SetMapSize(Level.Width, Level.Height);

            Scroll.InitLabels();
            Potion.InitColors();
            Wand.InitWoods();
            Ring.InitGems();

            Statistics.Reset();
            Journal.Reset();

            Depth = 0;
            Gold  = 0;

            PotionOfStrength = 0;
            ScrollsOfUpgrade = 0;
            ArcaneStyli      = 0;
            DewVial          = true;
            Transmutation    = Random.IntRange(6, 14);

            Chapters = new HashSet <int?>();

            Ghost.Quest.reset();
            Wandmaker.Quest.Reset();
            Blacksmith.Quest.Reset();
            Imp.Quest.Reset();

            Room.ShuffleTypes();

            Hero = new Hero();
            Hero.Live();

            Badge.Reset();

            StartScene.curClass.InitHero(Hero);
        }
Exemple #5
0
        public virtual bool Attack(Character enemy)
        {
            var visibleFight = Dungeon.Visible[pos] || Dungeon.Visible[enemy.pos];

            if (Hit(this, enemy, false))
            {
                if (visibleFight)
                {
                    GLog.Information(TxtHit, Name, enemy.Name);
                }

                // FIXME
                var dr = this is Hero && ((Hero)this).RangedWeapon != null && ((Hero)this).subClass == HeroSubClass.SNIPER ? 0 : Random.IntRange(0, enemy.Dr());

                var dmg             = DamageRoll();
                var effectiveDamage = Math.Max(dmg - dr, 0);

                effectiveDamage = AttackProc(enemy, effectiveDamage);
                effectiveDamage = enemy.DefenseProc(this, effectiveDamage);
                enemy.Damage(effectiveDamage, this);

                if (visibleFight)
                {
                    Sample.Instance.Play(Assets.SND_HIT, 1, 1, Random.Float(0.8f, 1.25f));
                }

                if (enemy == Dungeon.Hero)
                {
                    Dungeon.Hero.Interrupt();
                }

                enemy.Sprite.BloodBurstA(Sprite.Center(), effectiveDamage);
                enemy.Sprite.Flash();

                if (!enemy.IsAlive && visibleFight)
                {
                    if (enemy == Dungeon.Hero)
                    {
                        if (Dungeon.Hero.KillerGlyph != null)
                        {
                            Dungeon.Fail(Utils.Format(ResultDescriptions.GLYPH, Dungeon.Hero.KillerGlyph.Name(), Dungeon.Depth));
                            GLog.Negative(TxtKill, Dungeon.Hero.KillerGlyph.Name());
                        }
                        else
                        {
                            if (Bestiary.IsUnique(this))
                            {
                                Dungeon.Fail(Utils.Format(ResultDescriptions.BOSS, Name, Dungeon.Depth));
                            }
                            else
                            {
                                Dungeon.Fail(Utils.Format(ResultDescriptions.MOB, Utils.Indefinite(Name), Dungeon.Depth));
                            }

                            GLog.Negative(TxtKill, Name);
                        }
                    }
                    else
                    {
                        GLog.Information(TxtDefeat, Name, enemy.Name);
                    }
                }

                return(true);
            }

            if (!visibleFight)
            {
                return(false);
            }

            var defense = enemy.DefenseVerb();

            enemy.Sprite.ShowStatus(CharSprite.Neutral, defense);
            if (this == Dungeon.Hero)
            {
                GLog.Information(TxtYouMissed, enemy.Name, defense);
            }
            else
            {
                GLog.Information(TxtSmbMissed, enemy.Name, defense, Name);
            }

            Sample.Instance.Play(Assets.SND_MISS);

            return(false);
        }