コード例 #1
0
ファイル: Team.cs プロジェクト: kenlacoste843/ProjectXV3
        public static void Create(Entities.GameClient client, Packets.TeamActionPacket packet)
        {
            if (packet.EntityUID != client.EntityUID)
                return;
            if (client.Team != null)
                return;

            client.Team = new Team();
            client.Team.Leader = client.EntityUID;
            if (client.Team.Members.TryAdd(client.EntityUID, client))
            {
                using (var create = new Packets.TeamActionPacket())
                {
                    create.EntityUID = client.EntityUID;
                    create.Action = Enums.TeamAction.Leader;
                    client.Send(create);
                    create.Action = Enums.TeamAction.Create;
                    client.Send(create);
                }
                client.AddStatusEffect1(Enums.Effect1.TeamLeader, 0);
            }
            else
            {
                client.Team = null;
            }
        }
コード例 #2
0
        public static bool Handle(Entities.GameClient client, UseSpellPacket usespell)
        {
            if (!client.Equipments.Contains(Enums.ItemLocation.Steed))
                return false;

            if (client.ContainsFlag1(Enums.Effect1.Riding))
                client.RemoveFlag1(Enums.Effect1.Riding);
            else if (client.Stamina < 100)
                return false;
            else
                client.AddStatusEffect1(Enums.Effect1.Riding);

            using (var vigor = new Packets.SteedVigorPacket())
            {
                vigor.Type = 2;
                vigor.Amount = 9001;
                client.Send(vigor);
            }

            usespell.AddTarget(client.EntityUID, 0);
            return true;
        }
コード例 #3
0
        public bool Attack(Entities.BattlePet opponent, Entities.BattlePet target, bool ForceDamage = false, double FDamage = 0)
        {
            if (ForceDamage)
            {
                if (FDamage < 1)
                    FDamage = 1;
                target.HP -= (int)FDamage;

                opponent.Battle.UpdateScreen();
                Send(target, (uint)FDamage);

                if (target.HP < 0)
                {
                    opponent.Battle.Finish(opponent);
                    return false;
                }
                return true;
            }

            double Evolve = (double)(opponent.EvolveState + 1);
            double SkillPower = (double)this.Power;
            double Power = (double)opponent.Power;
            double Level = (double)opponent.Level;
            double Damage = (Evolve * (Power + (SkillPower + ((SkillPower / 100) * Level))));

            double TEvolve = (double)(target.EvolveState + 1);
            double TPower = (double)target.Power;
            double TLevel = (double)target.Level;
            double Defense = (TEvolve * (TPower + ((TPower / 100) * TLevel)));

            if (State == Enums.PetState.ChanceDoubleDamage ||
                State == Enums.PetState.TurnAttack ||
                State == Enums.PetState.TurnDoubleAttack ||
                State != Enums.PetState.ChanceDoubleDamage &&
                State != Enums.PetState.TurnAttack &&
                State != Enums.PetState.TurnDoubleAttack &&
                State != Enums.PetState.None &&
                Calculations.BasicCalculations.ChanceSuccess(StateChance))
            {
                switch (State)
                {
                    case Enums.PetState.Absorb:
                        {
                            Defense = 0;
                            Damage = ((target.HP / 100) * SkillPower);
                            opponent.HP += (int)Damage;
                            break;
                        }
                    case Enums.PetState.ChanceDoubleDamage:
                        {
                            byte HitCount = 0;
                            int Chance = (int)StateChance;
                                Damage -= Defense;
                                if (Damage < 1)
                                    Damage = 1;
                            while (Calculations.BasicCalculations.ChanceSuccess(Chance) && HitCount < 2)
                            {
                                target.HP -= (int)Damage;

                                opponent.Battle.UpdateScreen();
                                Send(target, (uint)Damage);

                                if (target.HP < 0)
                                {
                                    opponent.Battle.Finish(opponent);
                                    return false;
                                }
                                HitCount++;
                                Chance /= 2;
                            }
                            return true;
                        }
                    case Enums.PetState.Sleep:
                        {
                            if (target.State != Enums.PetState.None)
                                return false;
                            target.State = State;
                            target.AddStatusEffect1(Enums.Effect1.PartiallyInvisible);
                            opponent.Battle.UpdateScreen();
                            return false;
                        }
                    case Enums.PetState.Reflect:
                        {
                            double ReturnDamage = ((Damage / 100) * SkillPower);
                            if (!Attack(target, opponent, true, ReturnDamage))
                                return false;
                            break;
                        }
                    case Enums.PetState.Confuse:
                        {
                            if (target.State != Enums.PetState.None)
                                return false;
                            target.State = State;
                            target.AddStatusEffect1(Enums.Effect1.Confused);
                            opponent.Battle.UpdateScreen();
                            break;
                        }
                    case Enums.PetState.Freezing:
                        {
                            if (target.State != Enums.PetState.None)
                                return false;
                            target.State = State;
                            target.AddStatusEffect1(Enums.Effect1.IceBlock);
                            opponent.Battle.UpdateScreen();
                            break;
                        }
                    case Enums.PetState.Paralyzis:
                        {
                            if (target.State != Enums.PetState.None)
                                return false;
                            target.State = State;
                            target.AddStatusEffect1(Enums.Effect1.Dazed);
                            opponent.Battle.UpdateScreen();
                            break;
                        }
                    case Enums.PetState.Rest:
                        {
                            if (opponent.State != Enums.PetState.None)
                                return false;
                            opponent.State = State;
                            opponent.AddStatusEffect1(Enums.Effect1.PartiallyInvisible);

                            double RestoreHP = ((opponent.MaxHP / 100) * SkillPower);
                            opponent.HP += (int)RestoreHP;

                            opponent.Battle.UpdateScreen();
                            return false;
                        }
                    case Enums.PetState.Restore:
                        {
                            double RestoreHP = ((opponent.MaxHP / 100) * SkillPower);
                            opponent.HP += (int)RestoreHP;

                            opponent.Battle.UpdateScreen();
                            return false;
                        }
                    case Enums.PetState.TurnAttack:
                        {
                            byte HitCount = 0;
                            int Chance = (int)StateChance;
                                Damage -= Defense;
                                if (Damage < 1)
                                    Damage = 1;
                            while (Calculations.BasicCalculations.ChanceSuccess(Chance) && HitCount < 5)
                            {
                                target.HP -= (int)Damage;

                                opponent.Battle.UpdateScreen();
                                Send(target, (uint)Damage);

                                if (target.HP < 0)
                                {
                                    opponent.Battle.Finish(opponent);
                                    return false;
                                }
                                HitCount++;
                                Chance /= 2;
                            }
                            return true;
                        }
                    case Enums.PetState.TurnDoubleAttack:
                        {
                            byte HitCount = 0;
                            int Chance = (int)StateChance;
                            Damage -= Defense;
                            if (Damage < 1)
                                Damage = 1;
                            while (Calculations.BasicCalculations.ChanceSuccess(Chance) && HitCount < 5)
                            {
                                for (int i = 0; i < 2; i++)
                                {
                                    target.HP -= (int)Damage;

                                    opponent.Battle.UpdateScreen();
                                    Send(target, (uint)Damage);

                                    if (target.HP < 0)
                                    {
                                        opponent.Battle.Finish(opponent);
                                        return false;
                                    }
                                }
                                HitCount++;
                                Chance /= 2;
                            }
                            return true;
                        }
                }
            }

            Damage -= Defense;
            if (Damage < 1)
                Damage = 1;
            target.HP -= (int)Damage;

            opponent.Battle.UpdateScreen();
            Send(target, (uint)Damage);

            if (target.HP < 0)
            {
                opponent.Battle.Finish(opponent);
                return false;
            }
            return true;
        }
コード例 #4
0
        public void Use2(Entities.BossMonster boss, Entities.GameClient target)
        {
            if (!target.Alive)
                return;

            #region SkillAnimation + Power
            if (RealSkill != -1)
            {
                var usespell = new Packets.UseSpellPacket();

                usespell.EntityUID = boss.EntityUID;
                usespell.SpellID = (ushort)RealSkill;
                usespell.SpellX = boss.X;
                usespell.SpellY = boss.Y;
                usespell.SpellLevel = RealSkilllevel;

                if (PercentTageEffect != -1)
                {
                    int damage = (target.HP / PercentTageEffect);
                    usespell.AddTarget(target.EntityUID, (uint)damage);
                    target.HP -= damage;
                    if (target.HP <= 0)
                    {
                        Packets.Interaction.Battle.Combat.Kill(boss, target, (uint)damage);
                    }
                }
                else if (DamageEffect > 0)
                {
                    int damage = ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(DamageEffect / 2, DamageEffect);
                    usespell.AddTarget(target.EntityUID, (uint)damage);
                    target.HP -= damage;
                    if (target.HP <= 0)
                    {
                        Packets.Interaction.Battle.Combat.Kill(boss, target, (uint)damage);
                    }
                }
                else
                    usespell.AddTarget(target.EntityUID, 0);

                boss.Screen.UpdateScreen(usespell);
            }
            else
            {
                using (var interact = new Packets.InteractionPacket())
                {
                    interact.Action = Enums.InteractAction.Attack;
                    interact.EntityUID = boss.EntityUID;
                    interact.TargetUID = target.EntityUID;
                    interact.UnPacked = true;
                    interact.X = target.X;
                    interact.Y = target.Y;
                    if (PercentTageEffect != -1)
                    {
                        int damage = (target.HP / PercentTageEffect);
                        interact.Data = (uint)damage;

                        target.HP -= damage;
                        if (target.HP <= 0)
                        {
                            Packets.Interaction.Battle.Combat.Kill(boss, target, (uint)damage);
                        }
                    }
                    else if (DamageEffect > 0)
                    {
                        int damage = ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(DamageEffect / 2, DamageEffect);
                        interact.Data = (uint)damage;

                        target.HP -= damage;
                        if (target.HP <= 0)
                        {
                            Packets.Interaction.Battle.Combat.Kill(boss, target, (uint)damage);
                        }
                    }
                    else
                        interact.Data = 0;
                    boss.Screen.UpdateScreen(interact);
                }
            }
            #endregion

            #region Freeze
            if (Freeze)
            {
                target.AddStatusEffect1(Enums.Effect1.IceBlock, FreezeTime);
            }
            #endregion

            #region Paralyze
            if (Paralyzed)
            {
                target.ParalyzeClient(ParalyzeTime);
            }
            #endregion
        }