Пример #1
0
        public static void Drop(YiObj attacker, Monster mob)
        {
            var rand = SafeRandom.Next(1, 1000);

            Item created = default(Item);

            switch (mob.Id)
            {
            case 3131:
            case 3135:
                created = ItemFactory.Create(ItemNames.ExpPotion); break;    //exp potion from titan and gano

            default:
            {
                if (!GenerateDrop(attacker, mob, rand, ref created))        //YOU FORGOT TO ADD THE ! SO NOTHING WAS DROPPING
                {
                    return;
                }
                break;
            }
            }

            if (created.Valid())
            {
                FloorItemSystem.Drop(attacker, mob, created);
            }

            if (YiCore.Success(5)) //5% chance to drop more than one item.
            {
                Drop(attacker, mob);
            }
        }
Пример #2
0
        private static void ACTION_RAND(YiObj target, YiObj attacker, cq_action cqaction, SquigglyContext db)
        {
            var amount     = float.Parse(cqaction.param.Trim().Split(' ')[0]);
            var afterKills = float.Parse(cqaction.param.Trim().Split(' ')[1]);

            if (YiCore.Success(afterKills / amount))
            {
                //Output.WriteLine($"{type}:{(int) type} -> Chance: {afterKills/amount}", ConsoleColor.Green);
                Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
            }
            else
            {
                //Output.WriteLine($"{type}:{(int) type} -> Chance: {afterKills / amount}", ConsoleColor.Red);
                Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
            }
        }
Пример #3
0
        public void RemoveDura(MsgItemPosition position, bool arrows = false)
        {
            if (!arrows && !YiCore.Success(25))
            {
                return;
            }

            if (!Items.TryGetValue(position, out var found))
            {
                return;
            }
            if (found.CurrentDurability > 0)
            {
                found.CurrentDurability -= 1;
            }

            if (found.CurrentDurability < 10 && !arrows)
            {
                Message.SendTo(_owner, "Your " + Enum.GetName(typeof(MsgItemPosition), position) + " is about to break. (" + found.CurrentDurability + " uses left)", MsgTextType.Center);
            }

            var packet = new MsgItemInformation(found, MsgItemInfoAction.Update);

            (_owner as Player)?.ForceSend(packet, packet.Size);

            if (found.CurrentDurability == 0)
            {
                if (position == MsgItemPosition.RightWeapon)
                {
                    Unequip(MsgItemPosition.LeftWeapon);
                    (_owner as Player)?.ForceSend(MsgItem.Create(found.UniqueId, 0, (int)MsgItemPosition.LeftWeapon, MsgItemType.RemoveEquipment), 24);
                }

                Unequip(position);
                (_owner as Player)?.ForceSend(MsgItem.Create(found.UniqueId, 0, (int)position, MsgItemType.RemoveEquipment), 24);
                (_owner as Player)?.Inventory.RemoveItem(found);
                if (!arrows)
                {
                    Message.SendTo(_owner, "Your " + Enum.GetName(typeof(MsgItemPosition), position) + " broke.", MsgTextType.Center);
                }
            }
        }
Пример #4
0
        private static void ACTION_MST_DROPITEM(YiObj target, YiObj attacker, cq_action cqaction, SquigglyContext db)
        {
            var condition = cqaction.param.Trim();
            var what      = condition.Split(' ')[0];

            switch (what)
            {
            case "dropmoney":
            {
                var maxAmount = int.Parse(condition.Split(' ')[1]);
                var chance    = int.Parse(condition.Split(' ')[2]) / 100;


                if (YiCore.Success(chance))
                {
                    //Output.WriteLine($"{type}:{(int) type} -> {maxAmount} {chance}", ConsoleColor.Green);
                    Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                    FloorItemSystem.DropMoney(attacker, target, maxAmount);
                }
                else
                {
                    //Output.WriteLine($"{type}:{(int) type} -> {maxAmount} {chance}", ConsoleColor.Red);
                    Process(target, attacker, db.cq_action.Find(cqaction.id_nextfail), db);
                }

                break;
            }

            case "dropitem":
            {
                var id = int.Parse(condition.Split(' ')[1]);
                //Output.WriteLine($"{type}:{(int) type} -> {id}", ConsoleColor.Green);
                Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                FloorItemSystem.Drop(attacker, target, ItemFactory.Create(id));
                Process(target, attacker, db.cq_action.Find(cqaction.id_next), db);
                break;
            }
            }
        }
Пример #5
0
        public static int GetDamage(YiObj attacker, YiObj target, MsgInteractType attackType)
        {
            if (!YiCore.Success(attacker.Dexterity))
            {
                return(0);
            }

            var damage = 1.0d;

            switch (attackType)
            {
            case MsgInteractType.Physical:
                damage = YiCore.Random.Next(attacker.MinimumPhsyicalAttack, attacker.MaximumPhsyicalAttack);
                if (attacker is Monster)
                {
                    damage = YiCore.Random.Next(attacker.MinimumPhsyicalAttack, attacker.MaximumPhsyicalAttack);
                }
                if (target is Monster monster)
                {
                    damage = AdjustPvE((float)damage, attacker, monster);
                }
                if (attacker is Monster monster1 && target != null)
                {
                    damage = AdjustEvP((float)damage, monster1, target);
                }
                if (target != null)
                {
                    damage -= target.Defense;
                }
                break;

            case MsgInteractType.Magic:
                damage = attacker.MagicAttack;
                //if (attacker is Monster)
                //    damage = (attacker as Monster).Base.MagicAttack;

                //if (attacker is YiObj && target is Monster)
                //    damage = AdjustPvE(damage, (YiObj)attacker, (Monster)target);
                //if (attacker is Monster && target is YiObj)
                //    damage = AdjustEvP(damage, (Monster)attacker, (YiObj)target);
                if (target != null)
                {
                    damage *= (float)(100 - Math.Min(target.MagicDefense, 95)) / 100;
                    damage -= target.MagicDefense;     //MagicBlock
                    damage *= 0.65;
                }
                else
                {
                    damage *= 0.75;
                }
                break;

            case MsgInteractType.Archer:
                if (attacker == null)
                {
                    return(0);
                }

                damage = YiCore.Random.Next(attacker.MinimumPhsyicalAttack, attacker.MaximumPhsyicalAttack);
                damage = AdjustPvE((float)damage, attacker, attacker.CurrentTarget as Monster);
                break;
            }

            if (target != null)
            {
                if (target.Reborn)
                {
                    damage *= 0.7;
                }

                damage *= Math.Max(target.Bless, 1);
            }
            if (damage > 0)
            {
                damage = YiCore.Random.Next((int)(damage / 1.2), (int)damage);
            }

            damage *= 0.75;

            damage = Math.Max(1, damage);

            if (attacker is Player aPlayer)
            {
                if (target == null)
                {
                    return((int)Math.Round(damage, 0));
                }

                if (attacker.HasFlag(StatusEffect.SuperMan))
                {
                    damage *= 10;
                }
            }

            if (target != null)
            {
                TeamSystem.ShareExp(attacker, target, (uint)Math.Round(target.MaximumHp * 0.05));
            }
            attacker.Experience += AdjustExp((int)Math.Round(damage, 0), attacker, target);

            return((int)Math.Round(damage, 0));
        }
Пример #6
0
        private static bool GenerateDrop(YiObj attacker, Monster mob, int rand, ref Item created)
        {
            if (YiCore.Success(50) && Drops.TryGetValue(mob.UniqueId, out var dropList))
            {
                foreach (var item in dropList.Items)
                {
                    if (attacker.Level < item.ReqLevel)
                    {
                        continue;
                    }

                    switch (WeatherSystem.CurrentWeatherType)
                    {
                    case WeatherType.Rain:
                    {
                        if (!YiCore.Success(item.RainChance))
                        {
                            break;
                        }

                        created = ItemFactory.Create(item.ItemId);
                        return(true);
                    }

                    case WeatherType.Snow:
                    {
                        if (!YiCore.Success(item.SnowChance))
                        {
                            break;
                        }

                        created = ItemFactory.Create(item.ItemId);
                        return(true);
                    }
                    }

                    if (DayNightSystem.IsDay() && YiCore.Success(item.DayChance))
                    {
                        created = ItemFactory.Create(item.ItemId);
                        return(true);
                    }
                    if (DayNightSystem.IsNight() && YiCore.Success(item.NightChance))
                    {
                        created = ItemFactory.Create(item.ItemId);
                        return(true);
                    }
                }
            }

            if (rand < 200)
            {
                FloorItemSystem.DropMoney(attacker, mob, mob.Drops.Money + mob.Level * SafeRandom.Next(1, 10));
            }
            else if (rand < 250)
            {
                created = ItemFactory.Create(mob.Drops.Hp); //HP POTS
            }
            else if (rand < 300)
            {
                created = ItemFactory.Create(mob.Drops.Mp); //MP POTS
            }
            else if (rand < 550)                            //REGULAR ITEMS
            {
                created = ItemFactory.Create(GenerateItemId(mob));

                if (!created.Valid())
                {
                    return(false);
                }

                var plus  = GeneratePurity(mob.Level);
                var bless = GenerateBless();

                if (plus == 0)
                {
                    created.Bless = bless;
                }
                if (bless == 0)
                {
                    created.Plus = plus;
                }

                var sockets = GenerateSocketCount(created.ItemId, mob.Level);

                if (sockets != 0)
                {
                    Output.WriteLine($"Dropped {sockets} item.");
                }

                switch (sockets)
                {
                case 1:
                    created.Gem1 = 255;
                    break;

                case 2:
                    created.Gem1 = 255;
                    created.Gem2 = 255;
                    break;
                }
            }
            return(created.Valid());
        }