Exemplo n.º 1
0
        public void LoseLife(TakenDamages damages, int sourceid)
        {
            damages.EvaluateWithResistances(Fight.GetFighter(sourceid), this, Fight.PvP);

            if (damages.Delta <= 0)
            {
                return;
            }

            Fight.TryStartSequence(sourceid, 1);
            if (FighterStats.ShieldPoints > 0)
            {
                if (FighterStats.ShieldPoints - damages.Delta <= 0)
                {
                    ushort rest = (ushort)(damages.Delta - FighterStats.ShieldPoints);
                    Fight.Send(new GameActionFightLifeAndShieldPointsLostMessage((ushort)ActionsEnum.ACTION_CHARACTER_BOOST_SHIELD, sourceid, ContextualId, rest, 0, (ushort)FighterStats.ShieldPoints));
                    FighterStats.ShieldPoints = 0;
                    if (FighterStats.Stats.LifePoints - rest <= 0)
                    {
                        FighterStats.Stats.LifePoints = 0;
                        RefreshStats();
                        Die();
                    }
                    else
                    {
                        ShowFighter();
                        FighterStats.Stats.LifePoints -= (short)rest;
                    }
                    return;
                }
                else
                {
                    Fight.Send(new GameActionFightLifeAndShieldPointsLostMessage(0, sourceid, ContextualId, 0, 0, (ushort)damages.Delta));
                    FighterStats.ShieldPoints -= (int)damages.Delta;
                    ShowFighter();
                    return;
                }
            }
            if (FighterStats.Stats.LifePoints - damages.Delta <= 0)
            {
                Fight.Send(new GameActionFightLifePointsLostMessage(0, sourceid, ContextualId, (ushort)FighterStats.Stats.LifePoints, 0));
                FighterStats.Stats.LifePoints = 0;
                Die();
                return;
            }
            else
            {
                ushort erosionDelta = (ushort)CalculateErosionDamage(damages.Delta);
                FighterStats.RealStats.LifePoints -= (short)erosionDelta;
                FighterStats.ErodedLife           += erosionDelta;
                FighterStats.Stats.LifePoints     -= damages.Delta;

                Fight.Send(new GameActionFightLifePointsLostMessage(0, sourceid, ContextualId, (ushort)damages.Delta, erosionDelta));

                RefreshStats();
                ApplyFighterEvent(FighterEventType.AFTER_ATTACKED, sourceid, damages);
            }
            Fight.TryEndSequence(1, 103);
        }
        static void Steal(Fighter fighter, Fighter target, short jet, ElementType element, SpellLevelRecord level)
        {
            var takenDamages = new TakenDamages(jet, element);

            takenDamages.EvaluateWithResistances(fighter, target, fighter.Fight.PvP);
            short healJet    = (short)(takenDamages.Delta / 2);
            short targetLife = target.FighterStats.Stats.LifePoints;

            target.TakeDamages(new TakenDamages(jet, element), fighter.ContextualId);
            if (targetLife - jet < 0)
            {
                fighter.Heal((short)(targetLife / 2), fighter.ContextualId);
            }
            else
            {
                fighter.Heal(healJet, fighter.ContextualId);
            }
        }