Inheritance: OpenNos.Data.NpcMonsterDTO
Exemplo n.º 1
0
        public void ApplyBCards(object session, object sender = null)
        {
            Type type = session.GetType();

            // int counterBuff = 0;
            if (type == null)
            {
                return;
            }
            switch ((BCardType.CardType)Type)
            {
            case BCardType.CardType.Buff:
            {
                if (type == typeof(Character) && session is Character character)
                {
                    Buff buff = null;
                    if (sender != null)
                    {
                        Type sType = sender.GetType();
                        if (sType != null)
                        {
                            if (sType == typeof(Character) && sender is Character sendingCharacter)
                            {
                                buff = new Buff((short)SecondData, sendingCharacter.Level);

                                //Todo: Get anti stats from BCard
                            }
                        }
                    }
                    else
                    {
                        buff = new Buff((short)SecondData, character.Level);
                    }
                    if (ServerManager.Instance.RandomNumber() < FirstData)
                    {
                        character.AddBuff(buff);
                    }
                }
                else if (type == typeof(MapMonster))
                {
                    if (ServerManager.Instance.RandomNumber() < FirstData && session is MapMonster mapMonster)
                    {
                        mapMonster.AddBuff(new Buff((short)SecondData, mapMonster.Monster.Level));
                    }
                }
                else if (type == typeof(MapNpc))
                {
                }
                else if (type == typeof(Mate))
                {
                }
                break;
            }

            case BCardType.CardType.Move:
            {
                if (type == typeof(Character) && session is Character character)
                {
                    character.LastSpeedChange = DateTime.Now;
                    character.Session.SendPacket(character.GenerateCond());
                }
            }
            break;

            case BCardType.CardType.Summons:
                if (type == typeof(Character))
                {
                }
                else if (type == typeof(MapMonster))
                {
                    if (session is MapMonster mapMonster)
                    {
                        List <MonsterToSummon> summonParameters = new List <MonsterToSummon>();
                        for (int i = 0; i < FirstData; i++)
                        {
                            short x = (short)(ServerManager.Instance.RandomNumber(-3, 3) + mapMonster.MapX);
                            short y = (short)(ServerManager.Instance.RandomNumber(-3, 3) + mapMonster.MapY);
                            summonParameters.Add(new MonsterToSummon((short)SecondData, new MapCell()
                            {
                                X = x, Y = y
                            }, -1, true));
                        }
                        if (ServerManager.Instance.RandomNumber() <= Math.Abs(ThirdData) || ThirdData == 0)
                        {
                            switch (SubType)
                            {
                            case 2:
                                EventHelper.Instance.RunEvent(new EventContainer(mapMonster.MapInstance, EventActionType.SPAWNMONSTERS, summonParameters));
                                break;

                            default:
                                if (!mapMonster.OnDeathEvents.Any(s => s.EventActionType == EventActionType.SPAWNMONSTERS))
                                {
                                    mapMonster.OnDeathEvents.Add(new EventContainer(mapMonster.MapInstance, EventActionType.SPAWNMONSTERS, summonParameters));
                                }
                                break;
                            }
                        }
                    }
                }
                else if (type == typeof(MapNpc))
                {
                }
                else if (type == typeof(Mate))
                {
                }
                break;

            case BCardType.CardType.SpecialAttack:
                break;

            case BCardType.CardType.SpecialDefence:
                break;

            case BCardType.CardType.AttackPower:
                break;

            case BCardType.CardType.Target:
                break;

            case BCardType.CardType.Critical:
                break;

            case BCardType.CardType.SpecialCritical:
                break;

            case BCardType.CardType.Element:
                break;

            case BCardType.CardType.IncreaseDamage:
                break;

            case BCardType.CardType.Defence:
                break;

            case BCardType.CardType.DodgeAndDefencePercent:
                break;

            case BCardType.CardType.Block:
                break;

            case BCardType.CardType.Absorption:
                break;

            case BCardType.CardType.ElementResistance:
                break;

            case BCardType.CardType.EnemyElementResistance:
                break;

            case BCardType.CardType.Damage:
                break;

            case BCardType.CardType.GuarantedDodgeRangedAttack:
                break;

            case BCardType.CardType.Morale:
                break;

            case BCardType.CardType.Casting:
                break;

            case BCardType.CardType.Reflection:
                break;

            case BCardType.CardType.DrainAndSteal:
                break;

            case BCardType.CardType.HealingBurningAndCasting:
                if (type == typeof(Character))
                {
                    if (session is Character character)
                    {
                        int bonus = 0;
                        if (SubType == (byte)AdditionalTypes.HealingBurningAndCasting.RestoreHP / 10)
                        {
                            if (IsLevelScaled)
                            {
                                bonus = character.Level * FirstData;
                            }
                            else
                            {
                                bonus = FirstData;
                            }
                            if (character.Hp + bonus <= character.HPLoad())
                            {
                                character.Hp += bonus;
                            }
                            else
                            {
                                bonus        = (int)character.HPLoad() - character.Hp;
                                character.Hp = (int)character.HPLoad();
                            }
                            character.Session.CurrentMapInstance?.Broadcast(character.Session, character.GenerateRc(bonus));
                        }
                        if (SubType == (byte)AdditionalTypes.HealingBurningAndCasting.RestoreMP / 10)
                        {
                            if (IsLevelScaled)
                            {
                                bonus = character.Level * FirstData;
                            }
                            else
                            {
                                bonus = FirstData;
                            }
                            if (character.Mp + bonus <= character.MPLoad())
                            {
                                character.Mp += bonus;
                            }
                            else
                            {
                                bonus        = (int)character.MPLoad() - character.Mp;
                                character.Mp = (int)character.MPLoad();
                            }
                        }
                        character.Session.SendPacket(character.GenerateStat());
                    }
                }
                else if (type == typeof(MapMonster))
                {
                    if (ServerManager.Instance.RandomNumber() < FirstData && session is MapMonster mapMonster)
                    {
                        mapMonster.AddBuff(new Buff((short)SecondData, mapMonster.Monster.Level));
                    }
                }
                else if (type == typeof(MapNpc))
                {
                }
                else if (type == typeof(Mate))
                {
                }
                break;

            case BCardType.CardType.HPMP:
                break;

            case BCardType.CardType.SpecialisationBuffResistance:
                break;

            case BCardType.CardType.SpecialEffects:
                break;

            case BCardType.CardType.Capture:
                if (type == typeof(MapMonster))
                {
                    if (session is MapMonster mapMonster && sender is ClientSession senderSession)
                    {
                        NpcMonster mateNpc = ServerManager.Instance.GetNpc(mapMonster.MonsterVNum);
                        if (mateNpc != null)
                        {
                            if (mapMonster.Monster.Catch)
                            {
                                if (mapMonster.IsAlive && mapMonster.CurrentHp <= (int)((double)mapMonster.MaxHp / 2))
                                {
                                    if (mapMonster.Monster.Level < senderSession.Character.Level)
                                    {
#warning find a new algorithm
                                        int[] chance = { 100, 80, 60, 40, 20, 0 };
                                        if (ServerManager.Instance.RandomNumber() < chance[ServerManager.Instance.RandomNumber(0, 5)])
                                        {
                                            Mate mate = new Mate(senderSession.Character, mateNpc, (byte)(mapMonster.Monster.Level - 15 > 0 ? mapMonster.Monster.Level - 15 : 1), MateType.Pet);
                                            if (senderSession.Character.CanAddMate(mate))
                                            {
                                                senderSession.Character.AddPetWithSkill(mate);
                                                senderSession.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("CATCH_SUCCESS"), 0));
                                                senderSession.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, senderSession.Character.CharacterId, 197));
                                                senderSession.CurrentMapInstance?.Broadcast(StaticPacketHelper.SkillUsed(UserType.Player, senderSession.Character.CharacterId, 3, mapMonster.MapMonsterId, -1, 0, 15, -1, -1, -1, true, (int)((float)mapMonster.CurrentHp / (float)mapMonster.MaxHp * 100), 0, -1, 0));
                                                mapMonster.SetDeathStatement();
                                                senderSession.CurrentMapInstance?.Broadcast(StaticPacketHelper.Out(UserType.Monster, mapMonster.MapMonsterId));
                                            }
                                            else
                                            {
                                                senderSession.SendPacket(senderSession.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_SLOT_FULL"), 10));
                                                senderSession.SendPacket(StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId));
                                            }
                                        }
                                        else
                                        {
                                            senderSession.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("CATCH_FAIL"), 0));
                                            senderSession.CurrentMapInstance?.Broadcast(StaticPacketHelper.SkillUsed(UserType.Player, senderSession.Character.CharacterId, 3, mapMonster.MapMonsterId, -1, 0, 15, -1, -1, -1, true, (int)((float)mapMonster.CurrentHp / (float)mapMonster.MaxHp * 100), 0, -1, 0));
                                        }
                                    }
                                    else
                                    {
                                        senderSession.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("LEVEL_LOWER_THAN_MONSTER"), 0));
                                        senderSession.SendPacket(StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId));
                                    }
                                }
                                else
                                {
                                    senderSession.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("CURRENT_HP_TOO_HIGH"), 0));
                                    senderSession.SendPacket(StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId));
                                }
                            }
                            else
                            {
                                senderSession.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("MONSTER_CANT_BE_CAPTURED"), 0));
                                senderSession.SendPacket(StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId));
                            }
                        }
                    }
                }
                break;

            case BCardType.CardType.SpecialDamageAndExplosions:
                break;

            case BCardType.CardType.SpecialEffects2:
                break;

            case BCardType.CardType.CalculatingLevel:
                break;

            case BCardType.CardType.Recovery:
                break;

            case BCardType.CardType.MaxHPMP:
                break;

            case BCardType.CardType.MultAttack:
                break;

            case BCardType.CardType.MultDefence:
                break;

            case BCardType.CardType.TimeCircleSkills:
                break;

            case BCardType.CardType.RecoveryAndDamagePercent:
                break;

            case BCardType.CardType.Count:
                break;

            case BCardType.CardType.NoDefeatAndNoDamage:
                break;

            case BCardType.CardType.SpecialActions:
                break;

            case BCardType.CardType.Mode:
                break;

            case BCardType.CardType.NoCharacteristicValue:
                break;

            case BCardType.CardType.LightAndShadow:
                break;

            case BCardType.CardType.Item:
                break;

            case BCardType.CardType.DebuffResistance:
                break;

            case BCardType.CardType.SpecialBehaviour:
                break;

            case BCardType.CardType.Quest:
                break;

            case BCardType.CardType.SecondSPCard:
                break;

            case BCardType.CardType.SPCardUpgrade:
                break;

            case BCardType.CardType.HugeSnowman:
                break;

            case BCardType.CardType.Drain:
                break;

            case BCardType.CardType.BossMonstersSkill:
                break;

            case BCardType.CardType.LordHatus:
                break;

            case BCardType.CardType.LordCalvinas:
                break;

            case BCardType.CardType.SESpecialist:
                break;

            case BCardType.CardType.FourthGlacernonFamilyRaid:
                break;

            case BCardType.CardType.SummonedMonsterAttack:
                break;

            case BCardType.CardType.BearSpirit:
                break;

            case BCardType.CardType.SummonSkill:
                break;

            case BCardType.CardType.InflictSkill:
                break;

            case BCardType.CardType.HideBarrelSkill:
                break;

            case BCardType.CardType.FocusEnemyAttentionSkill:
                break;

            case BCardType.CardType.TauntSkill:
                break;

            case BCardType.CardType.FireCannoneerRangeBuff:
                break;

            case BCardType.CardType.VulcanoElementBuff:
                break;

            case BCardType.CardType.DamageConvertingSkill:
                break;

            case BCardType.CardType.MeditationSkill:
            {
                if (type == typeof(Character) && session is Character character)
                {
                    if (SkillVNum.HasValue && SubType.Equals((byte)AdditionalTypes.MeditationSkill.CausingChance / 10) && ServerManager.Instance.RandomNumber() < FirstData)
                    {
                        Skill skill    = ServerManager.Instance.GetSkill(SkillVNum.Value);
                        Skill newSkill = ServerManager.Instance.GetSkill((short)SecondData);
                        Observable.Timer(TimeSpan.FromMilliseconds(100)).Subscribe(observer =>
                            {
                                foreach (QuicklistEntryDTO quicklistEntry in character.QuicklistEntries.Where(s => s.Pos.Equals(skill.CastId)))
                                {
                                    character.Session.SendPacket($"qset {quicklistEntry.Q1} {quicklistEntry.Q2} {quicklistEntry.Type}.{quicklistEntry.Slot}.{newSkill.CastId}.0");
                                }
                                character.Session.SendPacket($"mslot {newSkill.CastId} -1");
                            });
                        character.SkillComboCount++;
                        character.LastSkillComboUse = DateTime.Now;
                        if (skill.CastId > 10)
                        {
                            // HACK this way
                            Observable.Timer(TimeSpan.FromMilliseconds((skill.Cooldown * 100) + 500)).Subscribe(observer => character.Session.SendPacket(StaticPacketHelper.SkillReset(skill.CastId)));
                        }
                    }
                    switch (SubType)
                    {
                    case 2:
                        character.MeditationDictionary[(short)SecondData] = DateTime.Now.AddSeconds(4);
                        break;

                    case 3:
                        character.MeditationDictionary[(short)SecondData] = DateTime.Now.AddSeconds(8);
                        break;

                    case 4:
                        character.MeditationDictionary[(short)SecondData] = DateTime.Now.AddSeconds(12);
                        break;
                    }
                }
            }
            break;

            case BCardType.CardType.FalconSkill:
                break;

            case BCardType.CardType.AbsorptionAndPowerSkill:
                break;

            case BCardType.CardType.LeonaPassiveSkill:
                break;

            case BCardType.CardType.FearSkill:
                break;

            case BCardType.CardType.SniperAttack:
                break;

            case BCardType.CardType.FrozenDebuff:
                break;

            case BCardType.CardType.JumpBackPush:
                break;

            case BCardType.CardType.FairyXPIncrease:
                break;

            case BCardType.CardType.SummonAndRecoverHP:
                break;

            case BCardType.CardType.TeamArenaBuff:
                break;

            case BCardType.CardType.ArenaCamera:
                break;

            case BCardType.CardType.DarkCloneSummon:
                break;

            case BCardType.CardType.AbsorbedSpirit:
                break;

            case BCardType.CardType.AngerSkill:
                break;

            case BCardType.CardType.MeteoriteTeleport:
                break;

            case BCardType.CardType.StealBuff:
                break;

            case BCardType.CardType.Unknown:
                break;

            case BCardType.CardType.EffectSummon:
                break;

            default:
                Logger.Warn($"Card Type {Type} not defined!");
                break;
            }
        }
Exemplo n.º 2
0
 public override void Initialize()
 {
     _random = new Random(MapNpcId);
     Npc = ServerManager.GetNpc(this.NpcVNum);
     LastEffect = DateTime.Now;
     LastMove = DateTime.Now;
     FirstX = MapX;
     FirstY = MapY;
     _movetime = _random.Next(500, 3000);
     Path = new List<GridPos>();
     Recipes = ServerManager.Instance.GetReceipesByMapNpcId(MapNpcId);
     Target = -1;
     Teleporters = ServerManager.Instance.GetTeleportersByNpcVNum((short)MapNpcId);
     Shop shop = ServerManager.Instance.GetShopByMapNpcId(MapNpcId);
     if (shop != null)
     {
         shop.Initialize();
         Shop = shop;
     }
 }
Exemplo n.º 3
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            switch (Effect)
            {
            case 0:
                if (Option == 0)
                {
                    if (packetsplit.Length == 9)
                    {
                        ItemInstance box = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Equipment);
                        if (box != null)
                        {
                            if (box.Item.ItemSubType == 3)
                            {
                                session.SendPacket($"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_OPEN_BOX")}");
                            }
                            else if (box.HoldingVNum == 0)
                            {
                                session.SendPacket($"qna #guri^300^8023^{inv.Slot}^{packetsplit[3]} {Language.Instance.GetMessageFromKey("ASK_STORE_PET")}");
                            }
                            else
                            {
                                session.SendPacket($"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_RELEASE_PET")}");
                            }
                        }
                    }
                }
                else
                {
                    //u_i 2 2000000 0 21 0 0
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.Item.ItemSubType == 3)
                        {
                            List <RollGeneratedItemDTO> roll = box.Item.RollGeneratedItems.Where(s => s.MinimumOriginalItemRare <= box.Rare &&
                                                                                                 s.MaximumOriginalItemRare >= box.Rare &&
                                                                                                 s.OriginalItemDesign == box.Design).ToList();
                            int probabilities = roll.Sum(s => s.Probability);
                            int rnd           = ServerManager.Instance.RandomNumber(0, probabilities);
                            int currentrnd    = 0;
                            foreach (RollGeneratedItemDTO rollitem in roll)
                            {
                                currentrnd += rollitem.Probability;
                                if (currentrnd >= rnd)
                                {
                                    Item  i       = ServerManager.Instance.GetItem(rollitem.ItemGeneratedVNum);
                                    sbyte rare    = 0;
                                    byte  upgrade = 0;
                                    if (i.ItemType == ItemType.Armor || i.ItemType == ItemType.Weapon || i.ItemType == ItemType.Shell)
                                    {
                                        rare = box.Rare;
                                    }
                                    if (i.ItemType == ItemType.Shell)
                                    {
                                        upgrade = (byte)ServerManager.Instance.RandomNumber(50, 81);
                                    }
                                    session.Character.GiftAdd(rollitem.ItemGeneratedVNum, rollitem.ItemGeneratedAmount, (byte)rare, upgrade);
                                    session.SendPacket($"rdi {rollitem.ItemGeneratedVNum} {rollitem.ItemGeneratedAmount}");
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                    return;

                                    //newInv = session.Character.Inventory.AddNewToInventory(rollitem.ItemGeneratedVNum, amount: rollitem.ItemGeneratedAmount, Design: design, Rare: rare);
                                    //if (newInv.Count > 0)
                                    //{
                                    //    short Slot = inv.Slot;
                                    //    if (Slot != -1)
                                    //    {
                                    //        session.SendPacket(session.Character.GenerateSay(
                                    //            $"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {newInv.FirstOrDefault(s => s != null)?.Item?.Name} x {rollitem.ItemGeneratedAmount}",
                                    //            12));
                                    //        newInv.Where(s => s != null).ToList()
                                    //            .ForEach(s => session.SendPacket(s.GenerateInventoryAdd()));
                                    //        session.Character.Inventory
                                    //            .RemoveItemAmountFromInventory(box.Id);
                                    //    }
                                    //}
                                }
                            }
                        }
                        else if (box.HoldingVNum == 0)
                        {
                            if (packetsplit.Length == 1 && int.TryParse(packetsplit[0], out int PetId))
                            {
                                Mate mate = session.Character.Mates.Find(s => s.MateTransportId == PetId);
                                box.HoldingVNum = mate.NpcMonsterVNum;
                                box.SpLevel     = mate.Level;
                                box.SpDamage    = mate.Attack;
                                box.SpDefence   = mate.Defence;
                                session.Character.Mates.Remove(mate);
                                session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("PET_STORED")));
                                session.SendPacket(UserInterfaceHelper.Instance.GeneratePClear());
                                session.SendPackets(session.Character.GenerateScP());
                                session.SendPackets(session.Character.GenerateScN());
                                session.CurrentMapInstance?.Broadcast(mate.GenerateOut());
                            }
                        }
                        else
                        {
                            NpcMonster heldMonster = ServerManager.Instance.GetNpc(box.HoldingVNum);
                            if (heldMonster != null)
                            {
                                Mate mate = new Mate(session.Character, heldMonster, 1, MateType.Pet)
                                {
                                    Attack  = box.SpDamage,
                                    Defence = box.SpDefence
                                };
                                if (session.Character.AddPet(mate))
                                {
                                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                                    session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("PET_LEAVE_BEAD")));
                                }
                            }
                        }
                    }
                }
                break;

            case 1:
                if (Option == 0)
                {
                    session.SendPacket($"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_RELEASE_PET")}");
                }
                else
                {
                    NpcMonster heldMonster = ServerManager.Instance.GetNpc((short)EffectValue);
                    if (session.CurrentMapInstance == session.Character.Miniland && heldMonster != null)
                    {
                        Mate mate = new Mate(session.Character, heldMonster, LevelMinimum, ItemSubType == 1 ? MateType.Partner : MateType.Pet);
                        if (session.Character.AddPet(mate))
                        {
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("PET_LEAVE_BEAD")));
                        }
                    }
                    else
                    {
                        //TODO ADD MINILAND SENDPACKET
                    }
                }

                break;

            case 69:
                if (EffectValue == 1 || EffectValue == 2)
                {
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"wopen 44 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Count > 0)
                            {
                                ItemInstance itemInstance = newInv[0];
                                ItemInstance specialist   = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(itemInstance.Slot, itemInstance.Type);
                                if (specialist != null)
                                {
                                    specialist.SlDamage          = box.SlDamage;
                                    specialist.SlDefence         = box.SlDefence;
                                    specialist.SlElement         = box.SlElement;
                                    specialist.SlHP              = box.SlHP;
                                    specialist.SpDamage          = box.SpDamage;
                                    specialist.SpDark            = box.SpDark;
                                    specialist.SpDefence         = box.SpDefence;
                                    specialist.SpElement         = box.SpElement;
                                    specialist.SpFire            = box.SpFire;
                                    specialist.SpHP              = box.SpHP;
                                    specialist.SpLevel           = box.SpLevel;
                                    specialist.SpLight           = box.SpLight;
                                    specialist.SpStoneUpgrade    = box.SpStoneUpgrade;
                                    specialist.SpWater           = box.SpWater;
                                    specialist.Upgrade           = box.Upgrade;
                                    specialist.EquipmentSerialId = box.EquipmentSerialId;
                                    specialist.XP = box.XP;
                                }
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    if (specialist != null)
                                    {
                                        session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {specialist.Item.Name} + {specialist.Upgrade}", 12));
                                        newInv.ForEach(s => session.SendPacket(specialist.GenerateInventoryAdd()));
                                    }
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 3)
                {
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 26 0 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Count > 0)
                            {
                                ItemInstance itemInstance = newInv[0];
                                ItemInstance fairy        = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(itemInstance.Slot, itemInstance.Type);
                                if (fairy != null)
                                {
                                    fairy.ElementRate = box.ElementRate;
                                }
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    if (fairy != null)
                                    {
                                        session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {fairy.Item.Name} ({fairy.ElementRate}%)", 12));
                                        newInv.ForEach(s => session.SendPacket(fairy.GenerateInventoryAdd()));
                                    }
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 4)
                {
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 24 0 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Count > 0)
                            {
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {newInv[0].Item.Name} x 1)", 12));
                                    newInv.ForEach(s => session.SendPacket(s.GenerateInventoryAdd()));
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                break;

            default:
                Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()));
                break;
            }
        }
Exemplo n.º 4
0
        public string GenerateEff(short effect)
        {
            NpcMonster npc = ServerManager.GetNpc(NpcVNum);

            return(npc != null ? $"eff 2 {MapNpcId} {effect}" : string.Empty);
        }
Exemplo n.º 5
0
        private string GenerateEff()
        {
            NpcMonster npc = ServerManager.GetNpc(NpcVNum);

            return(npc != null ? $"eff 2 {MapNpcId} {Effect}" : string.Empty);
        }
Exemplo n.º 6
0
        public void ApplyBCards(object session, object caster = null)
        {
            switch ((BCardType.CardType)Type)
            {
            case BCardType.CardType.Buff:
                if (session.GetType() == typeof(Character))
                {
                    if (ServerManager.Instance.RandomNumber() < FirstData)
                    {
                        Character character = session as Character;
                        character?.AddBuff(new Buff(SecondData, character.Level));
                    }
                }
                else if (session.GetType() == typeof(MapMonster))
                {
                    if (ServerManager.Instance.RandomNumber() < FirstData)
                    {
                        if (session is MapMonster monster)
                        {
                            monster.AddBuff(!(caster is Character character) ? new Buff(SecondData, 1) : new Buff(SecondData, character.Level));
                        }
                    }
                }
                else if (session.GetType() == typeof(MapNpc))
                {
                }
                else if (session.GetType() == typeof(Mate))
                {
                }
                break;

            case BCardType.CardType.Move:
                if (session.GetType() == typeof(Character))
                {
                    if (session is Character character)
                    {
                        character.LastSpeedChange = DateTime.Now;
                    }
                    Character o = session as Character;
                    o?.Session.SendPacket(o.GenerateCond());
                }
                break;

            case BCardType.CardType.Summons:
                if (session.GetType() == typeof(Character))
                {
                }
                else if (session.GetType() == typeof(MapMonster))
                {
                    if (!(session is MapMonster monster))
                    {
                        return;
                    }
                    ConcurrentBag <MonsterToSummon> summonParameters = new ConcurrentBag <MonsterToSummon>();
                    for (int i = 0; i < FirstData; i++)
                    {
                        short x, y;
                        if (SubType == 11)
                        {
                            x = (short)(i + monster.MapX);
                            y = monster.MapY;
                        }
                        else
                        {
                            x = (short)(ServerManager.Instance.RandomNumber(-3, 3) + monster.MapX);
                            y = (short)(ServerManager.Instance.RandomNumber(-3, 3) + monster.MapY);
                        }
                        summonParameters.Add(new MonsterToSummon((short)SecondData, new MapCell {
                            X = x, Y = y
                        }, -1, true));
                    }
                    int rnd = ServerManager.Instance.RandomNumber();
                    if (rnd <= Math.Abs(ThirdData) || ThirdData == 0)
                    {
                        switch (SubType)
                        {
                        case 31:
                            EventHelper.Instance.RunEvent(new EventContainer(monster.MapInstance, EventActionType.SPAWNMONSTERS, summonParameters));
                            break;

                        default:
                            if (monster.OnDeathEvents.All(s => s.EventActionType != EventActionType.SPAWNMONSTERS))
                            {
                                monster.OnDeathEvents.Add(new EventContainer(monster.MapInstance, EventActionType.SPAWNMONSTERS, summonParameters));
                            }
                            break;
                        }
                    }
                }
                else if (session.GetType() == typeof(MapNpc))
                {
                }
                else if (session.GetType() == typeof(Mate))
                {
                }
                break;

            case BCardType.CardType.SpecialAttack:
                break;

            case BCardType.CardType.SpecialDefence:
                break;

            case BCardType.CardType.AttackPower:
                break;

            case BCardType.CardType.Target:
                break;

            case BCardType.CardType.Critical:
                break;

            case BCardType.CardType.SpecialCritical:
                break;

            case BCardType.CardType.Element:
                break;

            case BCardType.CardType.IncreaseDamage:
                break;

            case BCardType.CardType.Defence:
                break;

            case BCardType.CardType.DodgeAndDefencePercent:
                break;

            case BCardType.CardType.Block:
                break;

            case BCardType.CardType.Absorption:
                break;

            case BCardType.CardType.ElementResistance:
                break;

            case BCardType.CardType.EnemyElementResistance:
                break;

            case BCardType.CardType.Damage:
                break;

            case BCardType.CardType.GuarantedDodgeRangedAttack:
                break;

            case BCardType.CardType.Morale:
                break;

            case BCardType.CardType.Casting:
                break;

            case BCardType.CardType.Reflection:
                break;

            case BCardType.CardType.DrainAndSteal:
                break;

            case BCardType.CardType.HealingBurningAndCasting:
                AdditionalTypes.HealingBurningAndCasting subtype = (AdditionalTypes.HealingBurningAndCasting)SubType;
                switch (subtype)
                {
                case AdditionalTypes.HealingBurningAndCasting.RestoreHP:
                case AdditionalTypes.HealingBurningAndCasting.RestoreHPWhenCasting:
                    if (session is Character sess)
                    {
                        int  heal   = FirstData;
                        bool change = false;
                        if (IsLevelScaled)
                        {
                            if (IsLevelDivided)
                            {
                                heal /= sess.Level;
                            }
                            else
                            {
                                heal *= sess.Level;
                            }
                        }
                        sess.Session?.CurrentMapInstance?.Broadcast(sess.GenerateRc(heal));
                        if (sess.Hp + heal < sess.HPLoad())
                        {
                            sess.Hp += heal;
                            change   = true;
                        }
                        else
                        {
                            if (sess.Hp != (int)sess.HPLoad())
                            {
                                change = true;
                            }
                            sess.Hp = (int)sess.HPLoad();
                        }
                        if (change)
                        {
                            sess.Session?.SendPacket(sess.GenerateStat());
                        }
                    }
                    break;
                }
                break;

            case BCardType.CardType.HPMP:
                break;

            case BCardType.CardType.SpecialisationBuffResistance:
                break;

            case BCardType.CardType.SpecialEffects:
                break;

            case BCardType.CardType.Capture:
                if (session.GetType() == typeof(MapMonster))
                {
                    if (caster is Character)
                    {
                        MapMonster monster   = session as MapMonster;
                        Character  character = caster as Character;
                        if (monster != null && character != null)
                        {
                            if (monster.Monster.RaceType == 1 && (character.MapInstance.MapInstanceType == MapInstanceType.BaseMapInstance || character.MapInstance.MapInstanceType == MapInstanceType.TimeSpaceInstance))
                            {
                                if (monster.Monster.Level < character.Level)
                                {
                                    if (monster.CurrentHp < (monster.Monster.MaxHP / 2))
                                    {
                                        if (character.MaxMateCount == character.Mates.Count())
                                        {
                                            // Algo
                                            int capturerate = ((character.Level / monster.Monster.Level) / (monster.CurrentHp / monster.Monster.MaxHP) * 3);
                                            if (ServerManager.Instance.RandomNumber() <= capturerate)
                                            {
                                                Mate currentmate = character.Mates.FirstOrDefault(m => m.IsTeamMember == true);
                                                if (currentmate != null)
                                                {
                                                    currentmate.IsTeamMember = false;
                                                    character.Session.CurrentMapInstance.Broadcast(currentmate.GenerateOut());
                                                }
                                                monster.MapInstance.DespawnMonster(monster);
                                                NpcMonster mateNpc = ServerManager.Instance.GetNpc(monster.Monster.NpcMonsterVNum);
                                                byte       lvl     = 0;
                                                lvl += monster.Monster.Level;
                                                lvl -= 10;
                                                if (lvl <= 0)
                                                {
                                                    lvl = 1;
                                                }
                                                Mate mate = new Mate(character, mateNpc, lvl, MateType.Pet);
                                                character.Mates.Add(mate);
                                                mate.IsTeamMember = true;
                                                character.Session.SendPacket($"ctl 2 {mate.PetId} 3");
                                                character.MapInstance.Broadcast(mate.GenerateIn());
                                                character.Session.SendPacket(character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("YOU_GET_PET"), mate.Name), 0));
                                                character.Session.SendPacket(UserInterfaceHelper.Instance.GeneratePClear());
                                                character.Session.SendPackets(character.GenerateScP());
                                                character.Session.SendPackets(character.GenerateScN());
                                                character.Session.SendPacket(UserInterfaceHelper.Instance.GeneratePClear());
                                                character.Session.SendPackets(character.GenerateScP());
                                                character.Session.SendPackets(character.GenerateScN());
                                                character.Session.SendPacket(character.GeneratePinit());
                                                character.Session.SendPackets(character.GeneratePst());
                                            }
                                            else
                                            {
                                                character.Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("CAPTURE_FAILED"), 0));
                                            }
                                        }
                                        else
                                        {
                                            character.Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("MAX_MATES_COUNT"), 0));
                                        }
                                    }
                                    else
                                    {
                                        character.Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("MONSTER_MUST_BE_LOW_HP"), 0));
                                    }
                                }
                                else
                                {
                                    character.Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("MONSTER_LVL_MUST_BE_LESS"), 0));
                                }
                            }
                            else
                            {
                                character.Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("MONSTER_CANNOT_BE_CAPTURED"), 0));
                            }
                        }
                    }
                }
                break;

            case BCardType.CardType.SpecialDamageAndExplosions:
                break;

            case BCardType.CardType.SpecialEffects2:
                break;

            case BCardType.CardType.CalculatingLevel:
                break;

            case BCardType.CardType.Recovery:
                break;

            case BCardType.CardType.MaxHPMP:
                break;

            case BCardType.CardType.MultAttack:
                break;

            case BCardType.CardType.MultDefence:
                break;

            case BCardType.CardType.TimeCircleSkills:
                break;

            case BCardType.CardType.RecoveryAndDamagePercent:
                break;

            case BCardType.CardType.Count:
                break;

            case BCardType.CardType.NoDefeatAndNoDamage:
                break;

            case BCardType.CardType.SpecialActions:
                break;

            case BCardType.CardType.Mode:
                break;

            case BCardType.CardType.NoCharacteristicValue:
                break;

            case BCardType.CardType.LightAndShadow:
                break;

            case BCardType.CardType.Item:
                break;

            case BCardType.CardType.DebuffResistance:
                break;

            case BCardType.CardType.SpecialBehaviour:
                break;

            case BCardType.CardType.Quest:
                break;

            case BCardType.CardType.SecondSPCard:
                break;

            case BCardType.CardType.SPCardUpgrade:
                break;

            case BCardType.CardType.HugeSnowman:
                break;

            case BCardType.CardType.Drain:
                break;

            case BCardType.CardType.BossMonstersSkill:
                break;

            case BCardType.CardType.LordHatus:
                break;

            case BCardType.CardType.LordCalvinas:
                break;

            case BCardType.CardType.SESpecialist:
                break;

            case BCardType.CardType.FourthGlacernonFamilyRaid:
                break;

            case BCardType.CardType.SummonedMonsterAttack:
                break;

            case BCardType.CardType.BearSpirit:
                break;

            case BCardType.CardType.SummonSkill:
                break;

            case BCardType.CardType.InflictSkill:
                break;

            case BCardType.CardType.HideBarrelSkill:
                break;

            case BCardType.CardType.FocusEnemyAttentionSkill:
                break;

            case BCardType.CardType.TauntSkill:
                break;

            case BCardType.CardType.FireCannoneerRangeBuff:
                break;

            case BCardType.CardType.VulcanoElementBuff:
                break;

            case BCardType.CardType.DamageConvertingSkill:
                break;

            case BCardType.CardType.MeditationSkill:

                break;

            case BCardType.CardType.FalconSkill:
                break;

            case BCardType.CardType.AbsorptionAndPowerSkill:
                break;

            case BCardType.CardType.LeonaPassiveSkill:
                break;

            case BCardType.CardType.FearSkill:
                break;

            case BCardType.CardType.SniperAttack:
                break;

            case BCardType.CardType.FrozenDebuff:
                break;

            case BCardType.CardType.JumpBackPush:
                break;

            case BCardType.CardType.FairyXPIncrease:
                break;

            case BCardType.CardType.SummonAndRecoverHP:
                break;

            case BCardType.CardType.TeamArenaBuff:
                break;

            case BCardType.CardType.ArenaCamera:
                break;

            case BCardType.CardType.DarkCloneSummon:
                break;

            case BCardType.CardType.AbsorbedSpirit:
                break;

            case BCardType.CardType.AngerSkill:
                break;

            case BCardType.CardType.MeteoriteTeleport:
                break;

            case BCardType.CardType.StealBuff:
                break;

            default:
                Logger.Error(new ArgumentOutOfRangeException($"Card Type {Type} not defined!"));
                //throw new ArgumentOutOfRangeException();
                break;
            }
        }
Exemplo n.º 7
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            inv.Item.BCards.ForEach(c => c.ApplyBCards(session.Character));

            switch (Effect)
            {
            // Honour Medals
            case 69:
                session.Character.Reputation += ReputPrice;
                session.SendPacket(session.Character.GenerateFd());
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                break;

            // SP Potions
            case 150:
            case 151:
                session.Character.SpAdditionPoint += EffectValue;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDED"), EffectValue), 0));
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            // Specialist Medal
            case 204:
                session.Character.SpPoint         += EffectValue;
                session.Character.SpAdditionPoint += EffectValue * 3;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                if (session.Character.SpPoint > 10000)
                {
                    session.Character.SpPoint = 10000;
                }
                session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDEDBOTH"), EffectValue, EffectValue * 3), 0));
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            // Raid Seals
            case 301:
                if (ServerManager.Instance.IsCharacterMemberOfGroup(session.Character.CharacterId))
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RAID_OPEN_GROUP"), 12));
                    return;
                }
                ItemInstance raidSeal = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Main);
                session.Character.Inventory.RemoveItemFromInventory(raidSeal.Id);

                ScriptedInstance raid = ServerManager.Instance.Raids.FirstOrDefault(s => s.RequiredItems?.Any(obj => obj?.VNum == raidSeal.ItemVNum) == true)?.Copy();
                if (raid != null)
                {
                    Group group = new Group
                    {
                        GroupType = GroupType.BigTeam,
                        Raid      = raid
                    };
                    group.JoinGroup(session.Character.CharacterId);
                    ServerManager.Instance.AddGroup(group);
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("RAID_LEADER"), session.Character.Name), 0));
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("RAID_LEADER"), session.Character.Name), 10));
                    if (session.Character.Level > raid.LevelMaximum || session.Character.Level < raid.LevelMinimum)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RAID_LEVEL_INCORRECT"), 10));
                    }
                    session.SendPacket(session.Character.GenerateRaid(2));
                    session.SendPacket(session.Character.GenerateRaid(0));
                    session.SendPacket(session.Character.GenerateRaid(1));
                    session.SendPacket(group.GenerateRdlst());
                }
                break;

            // Partner Suits/Skins
            case 305:
                Mate mate = session.Character.Mates.Find(s => s.MateTransportId == int.Parse(packetsplit[3]));
                if (mate != null && EffectValue == mate.NpcMonsterVNum && mate.Skin == 0)
                {
                    mate.Skin = Morph;
                    session.SendPacket(mate.GenerateCMode(mate.Skin));
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            // Fairy Booster
            case 250:
                if (!session.Character.Buff.ContainsKey(131))
                {
                    session.Character.AddStaticBuff(new StaticBuffDTO {
                        CardId = 131
                    });
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0));
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3014), session.Character.MapX, session.Character.MapY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            // Rainbow Pearl/Magic Eraser
            case 666:
                if (EffectValue == 1 && byte.TryParse(packetsplit[9], out byte islot))
                {
                    ItemInstance wearInstance = session.Character.Inventory.LoadBySlotAndType(islot, InventoryType.Equipment);

                    if (wearInstance != null && (wearInstance.Item.ItemType == ItemType.Weapon || wearInstance.Item.ItemType == ItemType.Armor) && wearInstance.ShellEffects.Count != 0 && !wearInstance.Item.IsHeroic)
                    {
                        wearInstance.ShellEffects.Clear();
                        DAOFactory.ShellEffectDAO.DeleteByEquipmentSerialId(wearInstance.EquipmentSerialId);
                        if (wearInstance.EquipmentSerialId == Guid.Empty)
                        {
                            wearInstance.EquipmentSerialId = Guid.NewGuid();
                        }
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                        session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("OPTION_DELETE"), 0));
                    }
                }
                else
                {
                    session.SendPacket("guri 18 0");
                }
                break;

            // Atk/Def/HP/Exp potions
            case 6600:
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                break;

            // Ancelloan's Blessing
            case 208:
                if (!session.Character.Buff.ContainsKey(121))
                {
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.Character.AddStaticBuff(new StaticBuffDTO {
                        CardId = 121
                    });
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            case 2081:
                if (!session.Character.Buff.ContainsKey(146))
                {
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.Character.AddStaticBuff(new StaticBuffDTO {
                        CardId = 146
                    });
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            // Divorce letter
            case 6969:     // this is imaginary number I = √(-1)
                break;

            // Cupid's arrow
            case 34:     // this is imaginary number I = √(-1)
                break;

            case 100:
            {
            }
            break;

            // Faction Egg
            case 570:
                if (session.Character.Faction == (FactionType)EffectValue)
                {
                    return;
                }
                if (EffectValue < 3)
                {
                    session.SendPacket(session.Character.Family == null
                            ? $"qna #guri^750^{EffectValue} {Language.Instance.GetMessageFromKey($"ASK_CHANGE_FACTION{EffectValue}")}"
                            : UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("IN_FAMILY"),
                                                              0));
                }
                else
                {
                    session.SendPacket(session.Character.Family != null
                            ? $"qna #guri^750^{EffectValue} {Language.Instance.GetMessageFromKey($"ASK_CHANGE_FACTION{EffectValue}")}"
                            : UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NO_FAMILY"),
                                                              0));
                }

                break;

            // SP Wings
            case 650:
                ItemInstance specialistInstance = session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Sp, InventoryType.Wear);
                if (session.Character.UseSp && specialistInstance != null)
                {
                    if (Option == 0)
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_WINGS_CHANGE")}");
                    }
                    else
                    {
                        void disposeBuff(short vNum)
                        {
                            if (session.Character.BuffObservables.ContainsKey(vNum))
                            {
                                session.Character.BuffObservables[vNum].Dispose();
                                session.Character.BuffObservables.Remove(vNum);
                            }
                            session.Character.RemoveBuff(vNum);
                        }

                        disposeBuff(387);
                        disposeBuff(395);
                        disposeBuff(396);
                        disposeBuff(397);
                        disposeBuff(398);
                        disposeBuff(410);
                        disposeBuff(411);
                        disposeBuff(444);

                        specialistInstance.Design = (byte)EffectValue;

                        session.Character.MorphUpgrade2 = EffectValue;
                        session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode());
                        session.SendPacket(session.Character.GenerateStat());
                        session.SendPacket(session.Character.GenerateStatChar());
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0));
                }
                break;

            // Self-Introduction
            case 203:
                if (!session.Character.IsVehicled && Option == 0)
                {
                    session.SendPacket(UserInterfaceHelper.GenerateGuri(10, 2, session.Character.CharacterId, 1));
                }
                break;

            // Magic Lamp
            case 651:
                if (session.Character.Inventory.All(i => i.Type != InventoryType.Wear))
                {
                    if (Option == 0)
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE")}");
                    }
                    else
                    {
                        session.Character.ChangeSex();
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0));
                }
                break;

            // Vehicles
            case 1000:
                if (EffectValue != 0 || ServerManager.Instance.ChannelId == 51 || session.CurrentMapInstance?.MapInstanceType == MapInstanceType.EventGameInstance)
                {
                    return;
                }
                if (Morph > 0)
                {
                    if (Option == 0 && !session.Character.IsVehicled)
                    {
                        if (session.Character.IsSitting)
                        {
                            session.Character.IsSitting = false;
                            session.CurrentMapInstance?.Broadcast(session.Character.GenerateRest());
                        }
                        session.Character.LastDelay = DateTime.Now;
                        session.SendPacket(UserInterfaceHelper.GenerateDelay(3000, 3, $"#u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2"));
                    }
                    else
                    {
                        if (!session.Character.IsVehicled && Option != 0)
                        {
                            DateTime delay = DateTime.Now.AddSeconds(-4);
                            if (session.Character.LastDelay > delay && session.Character.LastDelay < delay.AddSeconds(2))
                            {
                                session.Character.Speed         = Speed;
                                session.Character.IsVehicled    = true;
                                session.Character.VehicleSpeed  = Speed;
                                session.Character.MorphUpgrade  = 0;
                                session.Character.MorphUpgrade2 = 0;
                                session.Character.Morph         = Morph + (byte)session.Character.Gender;
                                session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 196), session.Character.MapX, session.Character.MapY);
                                session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode());
                                session.SendPacket(session.Character.GenerateCond());
                                session.Character.LastSpeedChange = DateTime.Now;
                            }
                        }
                        else if (session.Character.IsVehicled)
                        {
                            session.Character.RemoveVehicle();
                        }
                    }
                }
                break;

            // Sealed Vessel
            case 1002:
                if (EffectValue == 69)
                {
                    int rnd = ServerManager.RandomNumber(0, 1000);
                    if (rnd < 5)
                    {
                        short[] vnums =
                        {
                            5560, 5591, 4099, 907, 1160, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714,
                            4715, 4716
                        };
                        byte[] counts = { 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
                        int    item   = ServerManager.RandomNumber(0, 17);
                        session.Character.GiftAdd(vnums[item], counts[item]);
                    }
                    else if (rnd < 30)
                    {
                        short[] vnums = { 361, 362, 363, 366, 367, 368, 371, 372, 373 };
                        session.Character.GiftAdd(vnums[ServerManager.RandomNumber(0, 9)], 1);
                    }
                    else
                    {
                        short[] vnums =
                        {
                            1161, 2282, 1030, 1244, 1218, 5369, 1012, 1363, 1364, 2160, 2173, 5959, 5983, 2514,
                            2515, 2516, 2517, 2518, 2519, 2520, 2521, 1685, 1686, 5087, 5203, 2418, 2310, 2303,
                            2169, 2280, 5892, 5893, 5894, 5895, 5896, 5897, 5898, 5899, 5332, 5105, 2161, 2162
                        };
                        byte[] counts =
                        {
                            10, 10, 20, 5, 1, 1, 99, 1, 1, 5, 5, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 5, 20,
                            20,  1,  1, 1, 1, 1,  1, 1, 1, 1, 1, 1, 1, 1, 1
                        };
                        int item = ServerManager.RandomNumber(0, 42);
                        session.Character.GiftAdd(vnums[item], counts[item]);
                    }
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else if (session.HasCurrentMapInstance && session.CurrentMapInstance.MapInstanceType == MapInstanceType.BaseMapInstance && (session.Character.LastVessel.AddSeconds(1) <= DateTime.Now || session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.FastVessels)))
                {
                    short[] vnums = { 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405 };
                    short   vnum  = vnums[ServerManager.RandomNumber(0, 20)];

                    NpcMonster npcmonster = ServerManager.GetNpc(vnum);
                    if (npcmonster == null)
                    {
                        return;
                    }
                    MapMonster monster = new MapMonster
                    {
                        MonsterVNum   = vnum,
                        MapY          = session.Character.MapY,
                        MapX          = session.Character.MapX,
                        MapId         = session.Character.MapInstance.Map.MapId,
                        Position      = session.Character.Direction,
                        IsMoving      = true,
                        MapMonsterId  = session.CurrentMapInstance.GetNextMonsterId(),
                        ShouldRespawn = false
                    };
                    monster.Initialize(session.CurrentMapInstance);
                    session.CurrentMapInstance.AddMonster(monster);
                    session.CurrentMapInstance.Broadcast(monster.GenerateIn());
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.Character.LastVessel = DateTime.Now;
                }
                break;

            // Golden Bazaar Medal
            case 1003:
                if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalSilver))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.BazaarMedalGold
                    });
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            // Silver Bazaar Medal
            case 1004:
                if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalGold))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.BazaarMedalSilver
                    });
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            // Pet Slot Expansion
            case 1006:
                if (Option == 0)
                {
                    session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2 {Language.Instance.GetMessageFromKey("ASK_PET_MAX")}");
                }
                else if (session.Character.MaxMateCount < 30)
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("GET_PET_PLACES"), 10));
                    session.SendPacket(session.Character.GenerateScpStc());
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            // Pet Basket
            case 1007:
                if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.PetBasket))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.PetBasket
                    });
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket("ib 1278 1");
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            // Partner's Backpack
            case 1008:
                if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.PetBackPack))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.PetBackPack
                    });
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            // Backpack Expansion
            case 1009:
                if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.BackPack))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.BackPack
                    });
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            // Sealed Tarot Card
            case 1005:
                session.Character.GiftAdd((short)(VNum - Effect), 1);
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                break;

            // Tarot Card Game
            case 1894:
                if (EffectValue == 0)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        session.Character.GiftAdd((short)(Effect + ServerManager.RandomNumber(0, 10)), 1);
                    }
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            // Sealed Tarot Card
            case 2152:
                session.Character.GiftAdd((short)(VNum + Effect), 1);
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                break;

            default:
                switch (VNum)
                {
                case 5841:
                    int     rnd   = ServerManager.RandomNumber(0, 1000);
                    short[] vnums = null;
                    if (rnd < 900)
                    {
                        vnums = new short[] { 4356, 4357, 4358, 4359 };
                    }
                    else
                    {
                        vnums = new short[] { 4360, 4361, 4362, 4363 };
                    }
                    session.Character.GiftAdd(vnums[ServerManager.RandomNumber(0, 4)], 1);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    break;

                default:
                    Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType(), VNum, Effect, EffectValue));
                    break;
                }
                break;
            }
        }
Exemplo n.º 8
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte option = 0,
                                 string[] packetsplit = null)
        {
            switch (Effect)
            {
            case 0:
                if (option == 0)
                {
                    if (packetsplit?.Length == 9)
                    {
                        ItemInstance box =
                            session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot,
                                                                                         InventoryType.Equipment);
                        if (box != null)
                        {
                            if (box.Item.ItemSubType == 3)
                            {
                                session.SendPacket(
                                    $"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_OPEN_BOX")}");
                            }
                            else if (box.HoldingVNum == 0)
                            {
                                session.SendPacket(
                                    $"qna #guri^300^8023^{inv.Slot}^{packetsplit[3]} {Language.Instance.GetMessageFromKey("ASK_STORE_PET")}");
                            }
                            else
                            {
                                session.SendPacket(
                                    $"qna #guri^300^8023^{inv.Slot}^{packetsplit[3]} {Language.Instance.GetMessageFromKey("ASK_RELEASE_PET")}");
                            }
                        }
                    }
                }
                else
                {
                    //u_i 2 2000000 0 21 0 0
                    if (inv.Item.ItemSubType == 3)
                    {
                        OpenBoxItem(session, inv);
                    }
                    else if (inv.HoldingVNum == 0)
                    {
                        if (packetsplit?.Length == 1 && int.TryParse(packetsplit[0], out int petId) &&
                            session.Character.Mates.Find(s => s.MateTransportId == petId) is Mate mate)
                        {
                            if (mate.IsTeamMember)
                            {
                                session.SendPacket(
                                    session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_STORE_YOUR_TEAMMEM"), 10));
                            }
                            else
                            {
                                inv.HoldingVNum = mate.NpcMonsterVNum;
                                inv.SpLevel     = mate.Level;
                                inv.SpDamage    = mate.Attack;
                                inv.SpDefence   = mate.Defence;
                                session.Character.Mates.Remove(mate);
                                session.SendPacket(
                                    UserInterfaceHelper.GenerateInfo(
                                        Language.Instance.GetMessageFromKey("PET_STORED")));
                                session.SendPacket(UserInterfaceHelper.GeneratePClear());
                                session.SendPackets(session.Character.GenerateScP());
                                session.SendPackets(session.Character.GenerateScN());
                                session.CurrentMapInstance?.Broadcast(mate.GenerateOut());
                            }
                        }
                    }
                    else
                    {
                        NpcMonster heldMonster = ServerManager.GetNpcMonster(inv.HoldingVNum);
                        if (heldMonster != null)
                        {
                            Mate mate = new Mate(session.Character, heldMonster, 1, MateType.Pet)
                            {
                                Attack  = inv.SpDamage,
                                Defence = inv.SpDefence
                            };
                            if (session.Character.AddPet(mate))
                            {
                                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                                session.SendPacket(
                                    UserInterfaceHelper.GenerateInfo(
                                        Language.Instance.GetMessageFromKey("PET_LEAVE_BEAD")));
                            }
                        }
                    }
                }

                break;

            case 1:
                if (option == 0)
                {
                    session.SendPacket(
                        $"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_RELEASE_PET")}");
                }
                else
                {
                    NpcMonster heldMonster = ServerManager.GetNpcMonster((short)EffectValue);
                    if (session.CurrentMapInstance == session.Character.Miniland && heldMonster != null)
                    {
                        Mate mate = new Mate(session.Character, heldMonster, LevelMinimum,
                                             ItemSubType == 1 ? MateType.Partner : MateType.Pet);
                        if (session.Character.AddPet(mate))
                        {
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                            session.SendPacket(
                                UserInterfaceHelper.GenerateInfo(
                                    Language.Instance.GetMessageFromKey("PET_LEAVE_BEAD")));
                        }
                    }
                    else
                    {
                        session.SendPacket(
                            session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_IN_MINILAND"),
                                                          12));
                    }
                }

                break;

            case 6969:
                if (EffectValue == 1 || EffectValue == 2)
                {
                    var box =
                        session.Character.Inventory.LoadBySlotAndType(inv.Slot,
                                                                      InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"wopen 44 {inv.Slot} 1");
                        }
                        else
                        {
                            List <ItemInstance> newInv =
                                session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Any())
                            {
                                ItemInstance itemInstance = newInv.First();
                                var          specialist   =
                                    session.Character.Inventory.LoadBySlotAndType(
                                        itemInstance.Slot, itemInstance.Type);
                                if (specialist != null)
                                {
                                    specialist.FirstPartnerSkillRank  = box.FirstPartnerSkillRank;
                                    specialist.SecondPartnerSkillRank = box.SecondPartnerSkillRank;
                                    specialist.ThirdPartnerSkillRank  = box.ThirdPartnerSkillRank;
                                    specialist.FirstPartnerSkill      = box.FirstPartnerSkill;
                                    specialist.SecondPartnerSkill     = box.SecondPartnerSkill;
                                    specialist.ThirdPartnerSkill      = box.ThirdPartnerSkill;
                                }

                                short slot = inv.Slot;
                                if (slot != -1)
                                {
                                    if (specialist != null)
                                    {
                                        session.SendPacket(session.Character.GenerateSay(
                                                               $"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {specialist.Item.Name}",
                                                               12));
                                        newInv.ForEach(s => session.SendPacket(specialist.GenerateInventoryAdd()));
                                    }

                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(
                                    UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                break;


            case 69:
                if (EffectValue == 1 || EffectValue == 2)
                {
                    ItemInstance box =
                        session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot,
                                                                                     InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"wopen 44 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv =
                                session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Count > 0)
                            {
                                ItemInstance itemInstance = newInv[0];
                                ItemInstance specialist   =
                                    session.Character.Inventory.LoadBySlotAndType <ItemInstance>(itemInstance.Slot,
                                                                                                 itemInstance.Type);
                                if (specialist != null)
                                {
                                    specialist.SlDamage          = box.SlDamage;
                                    specialist.SlDefence         = box.SlDefence;
                                    specialist.SlElement         = box.SlElement;
                                    specialist.SlHP              = box.SlHP;
                                    specialist.SpDamage          = box.SpDamage;
                                    specialist.SpDark            = box.SpDark;
                                    specialist.SpDefence         = box.SpDefence;
                                    specialist.SpElement         = box.SpElement;
                                    specialist.SpFire            = box.SpFire;
                                    specialist.SpHP              = box.SpHP;
                                    specialist.SpLevel           = box.SpLevel;
                                    specialist.SpLight           = box.SpLight;
                                    specialist.SpStoneUpgrade    = box.SpStoneUpgrade;
                                    specialist.SpWater           = box.SpWater;
                                    specialist.Upgrade           = box.Upgrade;
                                    specialist.EquipmentSerialId = box.EquipmentSerialId;
                                    specialist.XP = box.XP;
                                }

                                if (inv.Slot != -1)
                                {
                                    if (specialist != null)
                                    {
                                        session.SendPacket(session.Character.GenerateSay(
                                                               $"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {specialist.Item.Name} + {specialist.Upgrade}",
                                                               12));
                                        newInv.ForEach(s => session.SendPacket(specialist.GenerateInventoryAdd()));
                                    }

                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(
                                    UserInterfaceHelper.GenerateMsg(
                                        Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }

                if (EffectValue == 3)
                {
                    ItemInstance box =
                        session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot,
                                                                                     InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 26 0 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv =
                                session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Count > 0)
                            {
                                ItemInstance itemInstance = newInv[0];
                                ItemInstance fairy        =
                                    session.Character.Inventory.LoadBySlotAndType <ItemInstance>(itemInstance.Slot,
                                                                                                 itemInstance.Type);
                                if (fairy != null)
                                {
                                    fairy.ElementRate = box.ElementRate;
                                }

                                if (inv.Slot != -1)
                                {
                                    if (fairy != null)
                                    {
                                        session.SendPacket(session.Character.GenerateSay(
                                                               $"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {fairy.Item.Name} ({fairy.ElementRate}%)",
                                                               12));
                                        newInv.ForEach(s => session.SendPacket(fairy.GenerateInventoryAdd()));
                                    }

                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(
                                    UserInterfaceHelper.GenerateMsg(
                                        Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }

                if (EffectValue == 4)
                {
                    ItemInstance box =
                        session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot,
                                                                                     InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 24 0 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv =
                                session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Count > 0)
                            {
                                if (inv.Slot != -1)
                                {
                                    session.SendPacket(session.Character.GenerateSay(
                                                           $"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {newInv[0].Item.Name} x 1)",
                                                           12));
                                    newInv.ForEach(s => session.SendPacket(s.GenerateInventoryAdd()));
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(
                                    UserInterfaceHelper.GenerateMsg(
                                        Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }

                break;

            default:
                Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType(), VNum,
                                          Effect, EffectValue));
                break;
            }
        }
Exemplo n.º 9
0
        public int GetJXP(NpcMonster monster, Group group)
        {
            int partySize = 1;
            double partyPenalty = 1d;

            if (group != null)
            {
                int levelSum = group.Characters.Sum(g => g.Character.Level);
                partySize = group.CharacterCount;
                partyPenalty = 12 / partySize / (double)levelSum;
            }

            // monster jobxp / penalty * rate
            int jobxp = (int)Math.Round(monster.JobXP * CharacterHelper.ExperiencePenalty(Level, monster.Level) * ServerManager.XPRate);

            // divide jobexp by multiplication of partyPenalty with level e.g. 57 * 0,014...
            if (partySize > 1 && group != null)
            {
                jobxp = (int)Math.Round(jobxp / (Level * partyPenalty));
            }

            return jobxp;
        }
Exemplo n.º 10
0
        public long GetXP(NpcMonster monster, Group group)
        {
            int partySize = 1;
            double partyPenalty = 1d;
            int levelDifference = Level - monster.Level;

            if (group != null)
            {
                int levelSum = group.Characters.Sum(g => g.Character.Level);
                partySize = group.CharacterCount;
                partyPenalty = 12 / partySize / (double)levelSum;
            }

            // xp calculation dependant on level difference
            long xpcalculation = levelDifference < 5 ? monster.XP : monster.XP / 3 * 2;

            // xp calculation / penalty * rate
            long xp = (long)Math.Round(xpcalculation * CharacterHelper.ExperiencePenalty(Level, monster.Level) * ServerManager.XPRate);

            // bonus percentage calculation for level 1 - 5 and difference of levels bigger or equal
            // to 4
            if (Level <= 5 && levelDifference < -4)
            {
                xp += xp / 2;
            }
            if (monster.Level >= 75)
            {
                xp *= 2;
            }

            // divide exp by multiplication of partyPenalty with level e.g. 57 * 0,014...
            if (partySize > 1 && group != null)
            {
                xp = (long)Math.Round(xp / (Level * partyPenalty));
            }

            return xp;
        }
Exemplo n.º 11
0
        public void GenerateXp(NpcMonster monsterinfo, bool isMonsterOwner)
        {
            Group grp = ServerManager.Instance.Groups.FirstOrDefault(g => g.IsMemberOfGroup(CharacterId));
            SpecialistInstance specialist = null;
            if (Hp <= 0)
            {
                return;
            }
            if (grp != null)
            {
            }
            if ((int)(LevelXp / (XPLoad() / 10)) < (int)((LevelXp + monsterinfo.XP) / (XPLoad() / 10)))
            {
                Hp = (int)HPLoad();
                Mp = (int)MPLoad();
                Session.SendPacket(GenerateStat());
                Session.SendPacket(GenerateEff(5));
            }

            if (Inventory != null)
            {
                specialist = Inventory.LoadBySlotAndType<SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Wear);
            }

            if (Level < 99)
            {
                if (isMonsterOwner)
                {
                    LevelXp += GetXP(monsterinfo, grp);
                }
                else
                {
                    LevelXp += GetXP(monsterinfo, grp) / 3;
                }
            }
            if ((Class == 0 && JobLevel < 20) || (Class != 0 && JobLevel < 80))
            {
                if (specialist != null && UseSp && specialist.SpLevel < 99 && specialist.SpLevel > 19)
                {
                    JobLevelXp += GetJXP(monsterinfo, grp) / 2;
                }
                else
                {
                    JobLevelXp += GetJXP(monsterinfo, grp);
                }
            }
            if (specialist != null && UseSp && specialist.SpLevel < 99)
            {
                int multiplier = specialist.SpLevel < 10 ? 10 : specialist.SpLevel < 19 ? 5 : 1;
                specialist.XP += GetJXP(monsterinfo, grp) * multiplier;
            }
            double t = XPLoad();
            while (LevelXp >= t)
            {
                LevelXp -= (long)t;
                Level++;
                t = XPLoad();
                if (Level >= 99)
                {
                    Level = 99;
                    LevelXp = 0;
                }
                Hp = (int)HPLoad();
                Mp = (int)MPLoad();
                Session.SendPacket(GenerateStat());
                Session.SendPacket($"levelup {CharacterId}");
                Session.SendPacket(GenerateMsg(Language.Instance.GetMessageFromKey("LEVELUP"), 0));
                Session.CurrentMap?.Broadcast(GenerateEff(6), MapX, MapY);
                Session.CurrentMap?.Broadcast(GenerateEff(198), MapX, MapY);
                ServerManager.Instance.UpdateGroup(CharacterId);
            }

            WearableInstance fairy = Inventory?.LoadBySlotAndType<WearableInstance>((byte)EquipmentType.Fairy, InventoryType.Wear);
            if (fairy != null)
            {
                if ((fairy.ElementRate + fairy.Item.ElementRate) < fairy.Item.MaxElementRate && Level <= monsterinfo.Level + 15 && Level >= monsterinfo.Level - 15)
                {
                    fairy.XP += ServerManager.FairyXpRate;
                }
                t = CharacterHelper.LoadFairyXPData(fairy.ElementRate);
                while (fairy.XP >= t)
                {
                    fairy.XP -= (int)t;
                    fairy.ElementRate++;
                    if ((fairy.ElementRate + fairy.Item.ElementRate) == fairy.Item.MaxElementRate)
                    {
                        fairy.XP = 0;
                        Session.SendPacket(GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("FAIRYMAX"), fairy.Item.Name), 10));
                    }
                    else
                    {
                        Session.SendPacket(GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("FAIRY_LEVELUP"), fairy.Item.Name), 10));
                    }
                    Session.SendPacket(GeneratePairy());
                }
            }

            t = JobXPLoad();
            while (JobLevelXp >= t)
            {
                JobLevelXp -= (long)t;
                JobLevel++;
                t = JobXPLoad();
                if (JobLevel >= 20 && Class == 0)
                {
                    JobLevel = 20;
                    JobLevelXp = 0;
                }
                else if (JobLevel >= 80)
                {
                    JobLevel = 80;
                    JobLevelXp = 0;
                }
                Hp = (int)HPLoad();
                Mp = (int)MPLoad();
                Session.SendPacket(GenerateStat());
                Session.SendPacket($"levelup {CharacterId}");
                Session.SendPacket(GenerateMsg(Language.Instance.GetMessageFromKey("JOB_LEVELUP"), 0));
                LearnAdventurerSkill();
                Session.CurrentMap?.Broadcast(GenerateEff(6), MapX, MapY);
                Session.CurrentMap?.Broadcast(GenerateEff(198), MapX, MapY);
            }
            if (specialist != null)
            {
                t = SPXPLoad();

                while (UseSp && specialist.XP >= t)
                {
                    specialist.XP -= (long)t;
                    specialist.SpLevel++;
                    t = SPXPLoad();
                    Session.SendPacket(GenerateStat());
                    Session.SendPacket($"levelup {CharacterId}");
                    if (specialist.SpLevel >= 99)
                    {
                        specialist.SpLevel = 99;
                        specialist.XP = 0;
                    }
                    LearnSPSkill();

                    Session.SendPacket(GenerateMsg(Language.Instance.GetMessageFromKey("SP_LEVELUP"), 0));
                    Session.CurrentMap?.Broadcast(GenerateEff(6), MapX, MapY);
                    Session.CurrentMap?.Broadcast(GenerateEff(198), MapX, MapY);
                }
            }
            Session.SendPacket(GenerateLev());
        }
Exemplo n.º 12
0
 public void GenerateDignity(NpcMonster monsterinfo)
 {
     if (Level < monsterinfo.Level && Dignity < 100 && Level > 20)
     {
         Dignity += (float)0.5;
         if (Dignity == (int)Dignity)
         {
             Session.SendPacket(GenerateFd());
             Session.CurrentMap?.Broadcast(Session, GenerateIn(), ReceiverType.AllExceptMe);
             Session.SendPacket(GenerateSay(Language.Instance.GetMessageFromKey("RESTORE_DIGNITY"), 11));
         }
     }
 }
Exemplo n.º 13
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            inv.Item.BCards.ForEach(c => c.ApplyBCards(session.Character));

            switch (Effect)
            {
            // sp point potions
            case 150:
            case 151:
                session.Character.SpAdditionPoint += EffectValue;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDED"), EffectValue), 0));
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            case 204:
                session.Character.SpPoint         += EffectValue;
                session.Character.SpAdditionPoint += EffectValue * 3;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                if (session.Character.SpPoint > 10000)
                {
                    session.Character.SpPoint = 10000;
                }
                session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDEDBOTH"), EffectValue, EffectValue * 3), 0));
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            case 301:
                if (ServerManager.Instance.IsCharacterMemberOfGroup(session.Character.CharacterId))
                {
                    //TODO you are in group
                    return;
                }
                ItemInstance raidSeal = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Main);
                session.Character.Inventory.RemoveItemAmountFromInventory(1, raidSeal.Id);

                ScriptedInstance raid = ServerManager.Instance.Raids.FirstOrDefault(s => s.RequieredItems.Any(obj => obj.VNum == raidSeal.ItemVNum)).GetClone();
                if (raid != null)
                {
                    Group group = new Group(GroupType.Team);
                    group.Raid = raid;
                    group.JoinGroup(session.Character.CharacterId);
                    ServerManager.Instance.AddGroup(group);
                    session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("YOU_ARE_RAID_CHIEF"), session.Character.Name), 0));
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("YOU_ARE_RAID_CHIEF"), session.Character.Name), 10));
                    if (session.Character.Level > raid.LevelMaximum || session.Character.Level < raid.LevelMinimum)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RAID_LEVEL_INCORRECT"), 10));
                    }
                    session.SendPacket(session.Character.GenerateRaid(2, false));
                    session.SendPacket(session.Character.GenerateRaid(0, false));
                    session.SendPacket(session.Character.GenerateRaid(1, false));
                    session.SendPacket(group.GenerateRdlst());
                }
                break;

            case 305:
                Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == int.Parse(packetsplit[3]));
                if (mate != null && EffectValue == mate.NpcMonsterVNum && mate.Skin == 0)
                {
                    mate.Skin = Morph;
                    session.SendPacket(mate.GenerateCMode(mate.Skin));
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                }
                break;

            //Atk/Def/HP/Exp potions
            case 6600:
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                break;

            case 208:
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                session.Character.AddStaticBuff(new StaticBuffDTO()
                {
                    CardId = 121
                });
                break;

            // Divorce letter
            case 6969:     // this is imaginary number I = √(-1)
                break;

            // Cupid's arrow
            case 34:     // this is imaginary number I = √(-1)
                break;

            case 570:
                if (session.Character.Faction == EffectValue)
                {
                    return;
                }
                session.SendPacket(session.Character.Family == null
                        ? $"qna #guri^750^{EffectValue} {Language.Instance.GetMessageFromKey($"ASK_CHANGE_FACTION{EffectValue}")}"
                        : UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("IN_FAMILY"),
                                                                   0));
                break;

            // wings
            case 650:
                SpecialistInstance specialistInstance = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Wear);
                if (session.Character.UseSp && specialistInstance != null)
                {
                    if (Option == 0)
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_WINGS_CHANGE")}");
                    }
                    else
                    {
                        specialistInstance.Design       = (byte)EffectValue;
                        session.Character.MorphUpgrade2 = EffectValue;
                        session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode());
                        session.SendPacket(session.Character.GenerateStat());
                        session.SendPacket(session.Character.GenerateStatChar());
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(
                        UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0));
                }
                break;

            // presentation messages
            case 203:
                if (!session.Character.IsVehicled)
                {
                    if (Option == 0)
                    {
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(10, 2, session.Character.CharacterId, 1));
                    }
                }
                break;

            // magic lamps
            case 651:
                if (session.Character.Inventory.GetAllItems().All(i => i.Type != InventoryType.Wear))
                {
                    if (Option == 0)
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE")}");
                    }
                    else
                    {
                        session.Character.ChangeSex();
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0));
                }
                break;

            // vehicles
            case 1000:
                if (Morph > 0)
                {
                    if (Option == 0 && !session.Character.IsVehicled)
                    {
                        if (session.Character.IsSitting)
                        {
                            session.Character.IsSitting = false;
                            session.CurrentMapInstance?.Broadcast(session.Character.GenerateRest());
                        }
                        session.Character.LastDelay = DateTime.Now;
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateDelay(3000, 3, $"#u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2"));
                    }
                    else
                    {
                        if (!session.Character.IsVehicled && Option != 0)
                        {
                            DateTime delay = DateTime.Now.AddSeconds(-4);
                            if (session.Character.LastDelay > delay && session.Character.LastDelay < delay.AddSeconds(2))
                            {
                                session.Character.Speed         = Speed;
                                session.Character.IsVehicled    = true;
                                session.Character.VehicleSpeed  = Speed;
                                session.Character.MorphUpgrade  = 0;
                                session.Character.MorphUpgrade2 = 0;
                                session.Character.Morph         = Morph + (byte)session.Character.Gender;
                                session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(196), session.Character.MapX, session.Character.MapY);
                                session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode());
                                session.SendPacket(session.Character.GenerateCond());
                                session.Character.LastSpeedChange = DateTime.Now;
                            }
                        }
                        else if (session.Character.IsVehicled)
                        {
                            session.Character.RemoveVehicle();
                        }
                    }
                }
                break;

            case 1002:
                if (EffectValue == 69)
                {
                    int rnd = ServerManager.Instance.RandomNumber(0, 1000);
                    if (rnd < 5)
                    {
                        short[] vnums =
                        {
                            5560, 5591, 4099, 907, 1160, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714,
                            4715, 4716
                        };
                        byte[] counts = { 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
                        int    item   = ServerManager.Instance.RandomNumber(0, 17);

                        session.Character.GiftAdd(vnums[item], counts[item]);
                    }
                    else if (rnd < 30)
                    {
                        short[] vnums = { 361, 362, 363, 366, 367, 368, 371, 372, 373 };
                        session.Character.GiftAdd(vnums[ServerManager.Instance.RandomNumber(0, 9)], 1);
                    }
                    else
                    {
                        short[] vnums =
                        {
                            1161, 2282, 1030, 1244, 1218, 5369, 1012, 1363, 1364, 2160, 2173, 5959, 5983, 2514,
                            2515, 2516, 2517, 2518, 2519, 2520, 2521, 1685, 1686, 5087, 5203, 2418, 2310, 2303,
                            2169, 2280, 5892, 5893, 5894, 5895, 5896, 5897, 5898, 5899, 5332, 5105, 2161, 2162
                        };
                        byte[] counts =
                        {
                            10, 10, 20, 5, 1, 1, 99, 1, 1, 5, 5, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 5, 20,
                            20,  1,  1, 1, 1, 1,  1, 1, 1, 1, 1, 1, 1, 1, 1
                        };
                        int item = ServerManager.Instance.RandomNumber(0, 42);
                        session.Character.GiftAdd(vnums[item], counts[item]);
                    }
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                }
                else
                {
                    if (session.HasCurrentMapInstance)
                    {
                        if (session.CurrentMapInstance.Map.MapTypes.All(m => m.MapTypeId != (short)MapTypeEnum.Act4))
                        {
                            short[] vnums =
                            {
                                1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399,
                                1400, 1401, 1402, 1403, 1404, 1405
                            };
                            short vnum = vnums[ServerManager.Instance.RandomNumber(0, 20)];

                            NpcMonster npcmonster = ServerManager.Instance.GetNpc(vnum);
                            if (npcmonster == null)
                            {
                                return;
                            }
                            MapMonster monster = new MapMonster
                            {
                                MonsterVNum   = vnum,
                                MapY          = session.Character.MapY,
                                MapX          = session.Character.MapX,
                                MapId         = session.Character.MapInstance.Map.MapId,
                                Position      = (byte)session.Character.Direction,
                                IsMoving      = true,
                                MapMonsterId  = session.CurrentMapInstance.GetNextMonsterId(),
                                ShouldRespawn = false
                            };
                            monster.Initialize(session.CurrentMapInstance);
                            session.CurrentMapInstance.AddMonster(monster);
                            session.CurrentMapInstance.Broadcast(monster.GenerateIn());
                            session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                        }
                    }
                }
                break;

            case 69:
                session.Character.Reput += ReputPrice;
                session.SendPacket(session.Character.GenerateFd());
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                break;

            case 1003:
                if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalSilver))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.BazaarMedalGold
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            case 1004:
                if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalGold))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.BazaarMedalSilver
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            case 1005:
                if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.BackPack))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.BackPack
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            case 1006:
                if (Option == 0)
                {
                    session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2 {Language.Instance.GetMessageFromKey("ASK_PET_MAX")}");
                }
                else
                {
                    if (session.Character.MaxMateCount < 30)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("GET_PET_PLACES"), 10));
                        session.SendPacket(session.Character.GenerateScpStc());
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                }
                break;

            case 1007:
                if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.PetBasket))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.PetBasket
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket("ib 1278 1");
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            case 1008:
                if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.PetBackPack))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.PetBackPack
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            default:
                Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()));
                break;
            }
        }
Exemplo n.º 14
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            inv.Item.BCards.ForEach(c => c.ApplyBCards(session.Character));

            switch (Effect)
            {
            // Honour Medals
            case 69:
                session.Character.Reputation += ReputPrice;
                session.SendPacket(session.Character.GenerateFd());
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                break;

            // SP Potions
            case 150:
            case 151:
                session.Character.SpAdditionPoint += EffectValue;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDED"), EffectValue), 0));
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            // Specialist Medal
            case 204:
                session.Character.SpPoint         += EffectValue;
                session.Character.SpAdditionPoint += EffectValue * 3;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                if (session.Character.SpPoint > 10000)
                {
                    session.Character.SpPoint = 10000;
                }
                session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDEDBOTH"), EffectValue, EffectValue * 3), 0));
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            // Raid Seals
            case 301:
                if (ServerManager.Instance.IsCharacterMemberOfGroup(session.Character.CharacterId))
                {
                    //TODO you are in group
                    return;
                }
                ItemInstance raidSeal = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Main);
                session.Character.Inventory.RemoveItemFromInventory(raidSeal.Id);

                ScriptedInstance raid = ServerManager.Instance.Raids.FirstOrDefault(s => s.RequiredItems?.Any(obj => obj?.VNum == raidSeal.ItemVNum) == true)?.Copy();
                if (raid != null)
                {
                    Group group = new Group()
                    {
                        GroupType = GroupType.BigTeam,
                        Raid      = raid
                    };
                    group.JoinGroup(session.Character.CharacterId);
                    ServerManager.Instance.AddGroup(group);
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("RAID_LEADER"), session.Character.Name), 0));
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("RAID_LEADER"), session.Character.Name), 10));
                    if (session.Character.Level > raid.LevelMaximum || session.Character.Level < raid.LevelMinimum)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RAID_LEVEL_INCORRECT"), 10));
                    }
                    session.SendPacket(session.Character.GenerateRaid(2, false));
                    session.SendPacket(session.Character.GenerateRaid(0, false));
                    session.SendPacket(session.Character.GenerateRaid(1, false));
                    session.SendPacket(group.GenerateRdlst());
                }
                break;

            // Partner Suits/Skins
            case 305:
                Mate mate = session.Character.Mates.Find(s => s.MateTransportId == int.Parse(packetsplit[3]));
                if (mate != null && EffectValue == mate.NpcMonsterVNum && mate.Skin == 0)
                {
                    mate.Skin = Morph;
                    session.SendPacket(mate.GenerateCMode(mate.Skin));
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            // Fairy Booster
            case 250:
                if (!session.Character.Buff.ContainsKey(131))
                {
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 131
                    });
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0));
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3011), session.Character.MapX, session.Character.MapY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            // Fairy booster 2
            case 253:
                if (!session.Character.Buff.ContainsKey(131))
                {
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 131
                    });
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0));
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3011), session.Character.MapX, session.Character.MapY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            // exp/job booster
            case 251:
                if (!session.Character.Buff.ContainsKey(121))
                {
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 121
                    });
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0));
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3011), session.Character.MapX, session.Character.MapY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            //sp job booster
            case 146:
                if (!session.Character.Buff.ContainsKey(146))
                {
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 146
                    });
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0));
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3011), session.Character.MapX, session.Character.MapY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            // Ice oil
            case 252:
                if (!session.Character.Buff.ContainsKey(340))
                {
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 340
                    });
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0));
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 16), session.Character.MapX, session.Character.MapY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            // Valentin Buff
            case 254:
                if (!session.Character.Buff.ContainsKey(109))
                {
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 109
                    });
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0));
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3410), session.Character.MapX, session.Character.MapY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            // Buff exp 20%
            case 256:
                if (!session.Character.Buff.ContainsKey(119))
                {
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 119
                    });
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0));
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 4756), session.Character.MapX, session.Character.MapY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            // Ancella fate
            case 258:
                if (!session.Character.Buff.ContainsKey(393))
                {
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 393
                    });
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0));
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 4756), session.Character.MapX, session.Character.MapY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            // Speedbooster
            case 260:
                if (!session.Character.IsVehicled || session.Character.Buff.Any(s => s.Card.CardId == 336))
                {
                    return;
                }
                session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(885), session.Character.MapX, session.Character.MapY);

                session.Character.Speed += 5;
                switch (session.Character.Morph)
                {
                case 2517:         // Nossi M
                case 2518:         // Nossi F
                case 2522:         // Roller M
                case 2523:         // Roller F
                                   // Removes <= lv 4 debuffs
                    List <BuffType> bufftodisable = new List <BuffType> {
                        BuffType.Bad
                    };
                    session.Character.DisableBuffs(bufftodisable, 4);
                    break;
                }
                Observable.Timer(TimeSpan.FromSeconds(session.Character.BuffRandomTime * 0.1D)).Subscribe(o =>
                {
                    session.Character.Speed -= 5;
                    session.Character.LoadSpeed();
                    switch (session.Character.Morph)
                    {
                    case 2526:         // White male unicorn
                    case 2527:         // White female unicorn
                    case 2528:         // Pink male unicorn
                    case 2529:         // Pink female unicorn
                    case 2530:         // Black male unicorn
                    case 2531:         // Black Female Unicorn
                    case 2928:         // Male UFO
                    case 2929:         // Female UFO
                    case 3679:         // Male squelettic dragon
                    case 3680:         // Female squelettic dragon
                        ServerManager.Instance.TeleportOnRandomPlaceInMap(session, session.Character.MapInstanceId, true);
                        break;

                    case 2432:         // Magic broom
                    case 2433:         // Magic broom F
                    case 2520:         // VTT M
                    case 2521:         // VTT F
                        switch (session.Character.Direction)
                        {
                        case 0:
                            // -y
                            ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, session.Character.PositionX, (short)(session.Character.PositionY - 5));
                            break;

                        case 1:
                            // +x
                            ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, (short)(session.Character.PositionX + 5), session.Character.PositionY);
                            break;

                        case 2:
                            // +y
                            ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, session.Character.PositionX, (short)(session.Character.PositionY + 5));
                            break;

                        case 3:
                            // -x
                            ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, (short)(session.Character.PositionX - 5), session.Character.PositionY);
                            break;

                        case 4:
                            ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, (short)(session.Character.PositionX - 5), (short)(session.Character.PositionY - 5));
                            // -x -y
                            break;

                        case 5:
                            // +x +y
                            ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, (short)(session.Character.PositionX - 5), (short)(session.Character.PositionY - 5));
                            break;

                        case 6:
                            // +x -y
                            ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, (short)(session.Character.PositionX + 5), (short)(session.Character.PositionY + 5));
                            break;

                        case 7:
                            // -x +y
                            ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, (short)(session.Character.PositionX - 5), (short)(session.Character.PositionY + 5));
                            break;
                        }
                        break;
                    }
                });
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                break;



            // Rainbow Pearl/Magic Eraser
            case 666:
                if (EffectValue == 1 && byte.TryParse(packetsplit[9], out byte islot))
                {
                    ItemInstance wearInstance = session.Character.Inventory.LoadBySlotAndType(islot, InventoryType.Equipment);

                    if (wearInstance != null && (wearInstance.Item.ItemType == ItemType.Weapon || wearInstance.Item.ItemType == ItemType.Armor) && wearInstance.ShellEffects.Count != 0 && wearInstance.Item.IsHeroic)
                    {
                        wearInstance.ShellEffects.Clear();
                        DAOFactory.ShellEffectDAO.DeleteByEquipmentSerialId(wearInstance.EquipmentSerialId);
                        if (wearInstance.EquipmentSerialId == Guid.Empty)
                        {
                            wearInstance.EquipmentSerialId = Guid.NewGuid();
                        }
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                        session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("OPTION_DELETE"), 0));
                    }
                }
                else
                {
                    session.SendPacket("guri 18 0");
                }
                break;

            // Atk/Def/HP/Exp potions
            case 6600:
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                break;

            // Ancelloan's Blessing
            case 208:
                if (!session.Character.Buff.ContainsKey(121))
                {
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 121
                    });
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            case 2081:
                if (!session.Character.Buff.ContainsKey(146))
                {
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 146
                    });
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            // Divorce letter
            case 6969:     // this is imaginary number I = √(-1)
                var rel = session.Character.CharacterRelations.FirstOrDefault(s => s.RelationType == CharacterRelationType.Spouse);
                if (rel != null)
                {
                    session.Character.DeleteRelation(rel.CharacterId == session.Character.CharacterId ? rel.RelatedCharacterId : rel.CharacterId);
                    session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("DIVORCED")));

                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }

                break;

            // Cupid's arrow
            case 34:     // this is imaginary number I = √(-1)
                if (packetsplit != null && packetsplit.Length > 3)
                {
                    if (long.TryParse(packetsplit[3], out long characterId))
                    {
                        if (session.Character.CharacterRelations.Any(s => s.RelationType == CharacterRelationType.Spouse))
                        {
                            session.SendPacket($"info {Language.Instance.GetMessageFromKey("ALREADY_MARRIED")}");
                            return;
                        }

                        if (session.Character.IsFriendOfCharacter(characterId))
                        {
                            var otherSession = ServerManager.Instance.GetSessionByCharacterId(characterId);
                            if (otherSession != null)
                            {
                                otherSession.SendPacket(UserInterfaceHelper.GenerateDialog(
                                                            $"#fins^-34^{session.Character.CharacterId} #fins^-69^{session.Character.CharacterId} {string.Format(Language.Instance.GetMessageFromKey("MARRY_REQUEST"), session.Character.Name)}"));
                                session.Character.FriendRequestCharacters.Add(characterId);
                                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                            }
                        }
                        else
                        {
                            session.SendPacket($"info {Language.Instance.GetMessageFromKey("NOT_FRIEND")}");
                        }
                    }
                }

                break;

            case 100:
            {
            }
            break;

            case 5836:
            {
                session.SendPacket($"gb 0 {session.Account.BankGold / 1000} {session.Character.Gold} 0 0");
                session.SendPacket($"s_memo 6 [Account balance]: {session.Account.BankGold} gold; [Owned]: {session.Character.Gold} gold\nWe will do our best. Thank you for using the services of Cuarry Bank.");
            }
            break;

            // Faction Egg
            case 570:
                if (session.Character.Faction == (FactionType)EffectValue)
                {
                    return;
                }
                if (EffectValue < 3)
                {
                    session.SendPacket(session.Character.Family == null
                            ? $"qna #guri^750^{EffectValue} {Language.Instance.GetMessageFromKey($"ASK_CHANGE_FACTION{EffectValue}")}"
                            : UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("IN_FAMILY"),
                                                              0));
                }
                else
                {
                    session.SendPacket(session.Character.Family != null
                            ? $"qna #guri^750^{EffectValue} {Language.Instance.GetMessageFromKey($"ASK_CHANGE_FACTION{EffectValue}")}"
                            : UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NO_FAMILY"),
                                                              0));
                }

                break;

            // SP Wings
            case 650:
                ItemInstance specialistInstance = session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Sp, InventoryType.Wear);
                if (session.Character.UseSp && specialistInstance != null)
                {
                    if (Option == 0)
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_WINGS_CHANGE")}");
                    }
                    else
                    {
                        void disposeBuff(short vNum)
                        {
                            if (session.Character.BuffObservables.ContainsKey(vNum))
                            {
                                session.Character.BuffObservables[vNum].Dispose();
                                session.Character.BuffObservables.Remove(vNum);
                            }
                            session.Character.RemoveBuff(vNum);
                        }

                        disposeBuff(387);
                        disposeBuff(395);
                        disposeBuff(396);
                        disposeBuff(397);
                        disposeBuff(398);
                        disposeBuff(410);
                        disposeBuff(411);
                        disposeBuff(444);

                        specialistInstance.Design = (byte)EffectValue;

                        session.Character.MorphUpgrade2 = EffectValue;
                        session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode());
                        session.SendPacket(session.Character.GenerateStat());
                        session.SendPacket(session.Character.GenerateStatChar());
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0));
                }
                break;

            // Self-Introduction
            case 203:
                if (!session.Character.IsVehicled && Option == 0)
                {
                    session.SendPacket(UserInterfaceHelper.GenerateGuri(10, 2, session.Character.CharacterId, 1));
                }
                break;

            // Magic Lamp
            case 651:
                if (session.Character.Inventory.All(i => i.Type != InventoryType.Wear))
                {
                    if (Option == 0)
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE")}");
                    }
                    else
                    {
                        session.Character.ChangeSex();
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0));
                }
                break;

            // Vehicles
            case 1000:
                if (EffectValue != 0 || ServerManager.Instance.ChannelId == 51 || session.CurrentMapInstance?.MapInstanceType == MapInstanceType.EventGameInstance)
                {
                    return;
                }

                if (session.Character.HasShopOpened)
                {
                    return;
                }

                if (Morph > 0)
                {
                    if (Option == 0 && !session.Character.IsVehicled)
                    {
                        if (session.Character.IsSitting)
                        {
                            session.Character.IsSitting = false;
                            session.CurrentMapInstance?.Broadcast(session.Character.GenerateRest());
                        }
                        session.Character.LastDelay = DateTime.Now;
                        session.SendPacket(UserInterfaceHelper.GenerateDelay(3000, 3, $"#u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2"));
                    }
                    else
                    {
                        if (!session.Character.IsVehicled && Option != 0)
                        {
                            DateTime delay = DateTime.Now.AddSeconds(-4);
                            if (session.Character.LastDelay > delay && session.Character.LastDelay < delay.AddSeconds(2))
                            {
                                session.Character.Speed         = Speed;
                                session.Character.IsVehicled    = true;
                                session.Character.VehicleSpeed  = Speed;
                                session.Character.MorphUpgrade  = 0;
                                session.Character.MorphUpgrade2 = 0;
                                session.Character.Morph         = Morph + (byte)session.Character.Gender;
                                session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 4809), session.Character.MapX, session.Character.MapY);
                                session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode());
                                session.SendPacket(session.Character.GenerateCond());
                                session.Character.LastSpeedChange = DateTime.Now;
                            }
                        }
                        else if (session.Character.IsVehicled)
                        {
                            session.Character.Mates?.Where(s => s.IsTeamMember).ToList().ForEach(x =>
                            {
                                x.PositionX = session.Character.PositionX;
                                x.PositionY = session.Character.PositionY;
                                session.CurrentMapInstance?.Broadcast(x.GenerateIn());
                            });
                            session.Character.RemoveVehicle();
                        }
                    }
                }
                break;

            // Sealed Vessel
            case 1002:
                if (EffectValue == 69)
                {
                    int rnd = ServerManager.RandomNumber(0, 1000);
                    if (rnd < 5)
                    {
                        short[] vnums =
                        {
                            5560, 5591, 4099, 907, 1160, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714,
                            4715, 4716
                        };
                        byte[] counts = { 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
                        int    item   = ServerManager.RandomNumber(0, 17);
                        session.Character.GiftAdd(vnums[item], counts[item]);
                    }
                    else if (rnd < 30)
                    {
                        short[] vnums = { 361, 362, 363, 366, 367, 368, 371, 372, 373 };
                        session.Character.GiftAdd(vnums[ServerManager.RandomNumber(0, 9)], 1);
                    }
                    else
                    {
                        short[] vnums =
                        {
                            1161, 2282, 1030, 1244, 1218, 5369, 1012, 1363, 1364, 2160, 2173, 5959, 5983, 2514,
                            2515, 2516, 2517, 2518, 2519, 2520, 2521, 1685, 1686, 5087, 5203, 2418, 2310, 2303,
                            2169, 2280, 5892, 5893, 5894, 5895, 5896, 5897, 5898, 5899, 5332, 5105, 2161, 2162
                        };
                        byte[] counts =
                        {
                            10, 10, 20, 5, 1, 1, 99, 1, 1, 5, 5, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 5, 20,
                            20,  1,  1, 1, 1, 1,  1, 1, 1, 1, 1, 1, 1, 1, 1
                        };
                        int item = ServerManager.RandomNumber(0, 42);
                        session.Character.GiftAdd(vnums[item], counts[item]);
                    }
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else if (session.HasCurrentMapInstance && session.CurrentMapInstance.Map.MapTypes.All(m => m.MapTypeId != (short)MapTypeEnum.Act4))
                {
                    short[] vnums = { 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405 };
                    short   vnum  = vnums[ServerManager.RandomNumber(0, 20)];

                    NpcMonster npcmonster = ServerManager.GetNpc(vnum);
                    if (npcmonster == null)
                    {
                        return;
                    }
                    MapMonster monster = new MapMonster
                    {
                        MonsterVNum   = vnum,
                        MapY          = session.Character.MapY,
                        MapX          = session.Character.MapX,
                        MapId         = session.Character.MapInstance.Map.MapId,
                        Position      = session.Character.Direction,
                        IsMoving      = true,
                        MapMonsterId  = session.CurrentMapInstance.GetNextMonsterId(),
                        ShouldRespawn = false
                    };
                    monster.Initialize(session.CurrentMapInstance);
                    session.CurrentMapInstance.AddMonster(monster);
                    session.CurrentMapInstance.Broadcast(monster.GenerateIn());
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            // Golden Bazaar Medal
            case 1003:
                if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalSilver))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.BazaarMedalGold
                    });
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            // Silver Bazaar Medal
            case 1004:
                if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalGold))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.BazaarMedalSilver
                    });
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            // Pet Slot Expansion
            case 1006:
                if (Option == 0)
                {
                    session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2 {Language.Instance.GetMessageFromKey("ASK_PET_MAX")}");
                }
                else if (session.Character.MaxMateCount < 30)
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("GET_PET_PLACES"), 10));
                    session.SendPacket(session.Character.GenerateScpStc());
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            // Pet Basket
            case 1007:
                if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.PetBasket))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.PetBasket
                    });
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket("ib 1278 1");
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            // Partner's Backpack
            case 1008:
                if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.PetBackPack))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.PetBackPack
                    });
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            // Backpack Expansion
            case 1009:
                if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.BackPack))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.BackPack
                    });
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            // Sealed Tarot Card
            case 1005:
                session.Character.GiftAdd((short)(VNum - Effect), 1);
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                break;

            // Tarot Card Game
            case 1894:
                if (EffectValue == 0)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        session.Character.GiftAdd((short)(Effect + ServerManager.RandomNumber(0, 10)), 1);
                    }
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            // Sealed Tarot Card
            case 2152:
                session.Character.GiftAdd((short)(VNum + Effect), 1);
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                break;

            default:
                switch (VNum)
                {
                case 5841:
                    int     rnd   = ServerManager.RandomNumber(0, 1000);
                    short[] vnums = null;
                    if (rnd < 900)
                    {
                        vnums = new short[] { 4356, 4357, 4358, 4359 };
                    }
                    else
                    {
                        vnums = new short[] { 4360, 4361, 4362, 4363 };
                    }
                    session.Character.GiftAdd(vnums[ServerManager.RandomNumber(0, 4)], 1);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    break;

                default:
                    Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()) + $" ItemVNum: {VNum} Effect: {Effect} EffectValue: {EffectValue}");
                    break;
                }
                break;
            }
        }
Exemplo n.º 15
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte option = 0, string[] packetsplit = null)
        {
            inv.Item.BCards.ForEach(c => c.ApplyBCards(session.Character));

            switch (Effect)
            {
            case 0:
                switch (VNum)
                {
                case 1428:
                    session.SendPacket("guri 18 1");
                    break;

                case 1429:
                    session.SendPacket("guri 18 0");
                    break;

                case 1430:
                    if (packetsplit == null)
                    {
                        return;
                    }

                    if (packetsplit.Length < 9)
                    {
                        // MODIFIED PACKET
                        return;
                    }

                    if (!short.TryParse(packetsplit[9], out short eqSlot) || !Enum.TryParse(packetsplit[8], out InventoryType eqType))
                    {
                        return;
                    }
                    WearableInstance eq = session.Character.Inventory.LoadBySlotAndType <WearableInstance>(eqSlot, eqType);
                    if (eq == null)
                    {
                        // PACKET MODIFIED
                        return;
                    }
                    if (eq.Item.ItemType != ItemType.Armor && eq.Item.ItemType != ItemType.Weapon)
                    {
                        return;
                    }
                    eq.EquipmentOptions.Clear();
                    eq.ShellRarity = null;
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("SHELL_ERASED"), 0));
                    session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(17, 1, session.Character.CharacterId));
                    break;

                case 1904:
                    short[] items = { 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1972, 1973 };
                    for (int i = 0; i < 5; i++)
                    {
                        session.Character.GiftAdd(items[ServerManager.Instance.RandomNumber(0, items.Length)], 1);
                    }
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    break;

                case 5916:
                    session.Character.AddStaticBuff(new StaticBuffDTO
                    {
                        CardId        = 340,
                        CharacterId   = session.Character.CharacterId,
                        RemainingTime = 7200
                    });
                    session.Character.RemoveBuff(339);
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    break;

                case 5929:
                    session.Character.AddStaticBuff(new StaticBuffDTO
                    {
                        CardId        = 340,
                        CharacterId   = session.Character.CharacterId,
                        RemainingTime = 600
                    });
                    session.Character.RemoveBuff(339);
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    break;

                default:
                    IEnumerable <RollGeneratedItemDTO> roll = DAOFactory.RollGeneratedItemDAO.Where(s => s.OriginalItemVNum == VNum);
                    IEnumerable <RollGeneratedItemDTO> rollGeneratedItemDtos = roll as IList <RollGeneratedItemDTO> ?? roll.ToList();
                    if (!rollGeneratedItemDtos.Any())
                    {
                        return;
                    }
                    int probabilities = rollGeneratedItemDtos.Sum(s => s.Probability);
                    int rnd           = ServerManager.Instance.RandomNumber(0, probabilities);
                    int currentrnd    = 0;
                    foreach (RollGeneratedItemDTO rollitem in rollGeneratedItemDtos)
                    {
                        if (rollitem.Probability == 10000)
                        {
                            session.Character.GiftAdd(rollitem.ItemGeneratedVNum, rollitem.ItemGeneratedAmount);
                            continue;
                        }
                        currentrnd += rollitem.Probability;
                        if (currentrnd < rnd)
                        {
                            continue;
                        }
                        if (rollitem.IsSuperReward)
                        {
                            CommunicationServiceClient.Instance.SendMessageToCharacter(new SCSCharacterMessage
                            {
                                DestinationCharacterId = null,
                                SourceCharacterId      = session.Character.CharacterId,
                                SourceWorldId          = ServerManager.Instance.WorldId,
                                Message = Language.Instance.GetMessageFromKey("SUPER_REWARD"),
                                Type    = MessageType.Shout
                            });
                        }
                        session.Character.GiftAdd(rollitem.ItemGeneratedVNum, rollitem.ItemGeneratedAmount, 0, rollitem.ItemGeneratedUpgrade);
                        break;
                    }
                    session.Character.Inventory.RemoveItemAmount(VNum);
                    break;
                }
                break;

            // sp point potions
            case 150:
            case 151:
                session.Character.SpAdditionPoint += EffectValue;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDED"), EffectValue), 0));
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            case 204:
                session.Character.SpPoint         += EffectValue;
                session.Character.SpAdditionPoint += EffectValue * 3;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                if (session.Character.SpPoint > 10000)
                {
                    session.Character.SpPoint = 10000;
                }
                session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDEDBOTH"), EffectValue, EffectValue * 3), 0));
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            case 250:
                if (session.Character.Buff.Any(s => s.Card.CardId == 131))
                {
                    //TODO ADD MESSAGE ALREADY GOT BUFF
                    return;
                }
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                session.Character.AddStaticBuff(new StaticBuffDTO {
                    CardId = 131
                });
                session.CurrentMapInstance.Broadcast(session.Character.GeneratePairy());
                session.SendPacket(session.Character.GeneratePairy());
                break;

            case 208:
                if (session.Character.Buff.Any(s => s.Card.CardId == 121))
                {
                    //TODO ADD MESSAGE ALREADY GOT BUFF
                    return;
                }
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                session.Character.AddStaticBuff(new StaticBuffDTO {
                    CardId = 121, CharacterId = session.Character.CharacterId, RemainingTime = 3600
                });
                break;

            case 301:
                if (ServerManager.Instance.IsCharacterMemberOfGroup(session.Character.CharacterId))
                {
                    //TODO you are in group
                    return;
                }
                ItemInstance raidSeal = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Main);

                ScriptedInstance raid = ServerManager.Instance.Raids.FirstOrDefault(s => s.RequieredItems.Any(obj => obj.VNum == raidSeal.ItemVNum))?.GetClone();
                if (raid != null)
                {
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, raidSeal.Id);
                    Group group = new Group(GroupType.Team);
                    group.Raid = raid;
                    group.JoinGroup(session.Character.CharacterId);
                    ServerManager.Instance.AddGroup(group);
                    session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("YOU_ARE_RAID_CHIEF"), session.Character.Name), 0));
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("YOU_ARE_RAID_CHIEF"), session.Character.Name), 10));
                    if (session.Character.Level > raid.LevelMaximum || session.Character.Level < raid.LevelMinimum)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RAID_LEVEL_INCORRECT"), 10));
                    }
                    session.SendPacket(session.Character.GenerateRaid(2, false));
                    session.SendPacket(session.Character.GenerateRaid(0, false));
                    session.SendPacket(session.Character.GenerateRaid(1, false));
                    session.SendPacket(group.GenerateRdlst());
                }
                break;

            case 305:
                if (packetsplit == null || packetsplit.Length < 3)
                {
                    return;
                }
                Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == int.Parse(packetsplit[3]));
                if (mate != null && EffectValue == mate.NpcMonsterVNum && mate.Skin == 0)
                {
                    mate.Skin = Morph;
                    session.SendPacket(mate.GenerateCMode(mate.Skin));
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                }
                break;

            //Atk/Def/HP/Exp potions
            case 6600:
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                break;

            // Divorce letter
            case 6969:     // this is imaginary number I = √(-1)
                CharacterRelationDTO rel = session.Character.CharacterRelations.FirstOrDefault(s => s.RelationType == CharacterRelationType.Spouse);
                if (rel != null)
                {
                    session.Character.DeleteRelation(rel.CharacterId == session.Character.CharacterId ? rel.RelatedCharacterId : rel.CharacterId);
                    session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("DIVORCED")));
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                }
                break;

            // Cupid's arrow
            case 34:     // this is imaginary number I = √(-1)
                if (packetsplit != null && packetsplit.Length > 3)
                {
                    if (long.TryParse(packetsplit[3], out long characterId))
                    {
                        if (session.Character.CharacterRelations.Any(s => s.RelationType == CharacterRelationType.Spouse))
                        {
                            session.SendPacket($"info {Language.Instance.GetMessageFromKey("ALREADY_MARRIED")}");
                            return;
                        }
                        if (session.Character.IsFriendOfCharacter(characterId))
                        {
                            ClientSession otherSession = ServerManager.Instance.GetSessionByCharacterId(characterId);
                            if (otherSession != null)
                            {
                                otherSession.SendPacket(UserInterfaceHelper.Instance.GenerateDialog(
                                                            $"#fins^-34^{session.Character.CharacterId} #fins^-69^{session.Character.CharacterId} {string.Format(Language.Instance.GetMessageFromKey("MARRY_REQUEST"), session.Character.Name)}"));
                                session.Character.FriendRequestCharacters.Add(characterId);
                                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                            }
                        }
                        else
                        {
                            session.SendPacket($"info {Language.Instance.GetMessageFromKey("NOT_FRIEND")}");
                        }
                    }
                }
                break;

            case 570:
                if (session.Character.Faction == (FactionType)EffectValue)
                {
                    return;
                }
                session.SendPacket(session.Character.Family == null
                        ? $"qna #guri^750^{EffectValue} {Language.Instance.GetMessageFromKey($"ASK_CHANGE_FACTION{EffectValue}")}"
                        : UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("IN_FAMILY"), 0));
                break;

            // wings
            case 650:
                if (session.Character.UseSp && session.Character.SpInstance != null)
                {
                    if (option == 0)
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte) inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_WINGS_CHANGE")}");
                    }
                    else
                    {
                        session.Character.SpInstance.Design = (byte)EffectValue;
                        session.Character.MorphUpgrade2     = EffectValue;
                        session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode());
                        session.SendPacket(session.Character.GenerateStat());
                        session.SendPacket(session.Character.GenerateStatChar());
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0));
                }
                break;

            // presentation messages
            case 203:
                if (!session.Character.IsVehicled)
                {
                    if (option == 0)
                    {
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(10, 2, session.Character.CharacterId, 1));
                    }
                }
                break;

            // magic lamps
            case 651:
                if (session.Character.Inventory.All(i => i.Value.Type != InventoryType.Wear))
                {
                    if (option == 0)
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE")}");
                    }
                    else
                    {
                        session.Character.ChangeSex();
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0));
                }
                break;

            // vehicles
            case 1000:
                if (session.Character.HasShopOpened)
                {
                    return;
                }
                if (Morph > 0)
                {
                    if (option == 0 && !session.Character.IsVehicled)
                    {
                        if (session.Character.IsSitting)
                        {
                            session.Character.IsSitting = false;
                            session.CurrentMapInstance?.Broadcast(session.Character.GenerateRest());
                        }
                        session.Character.LastDelay = DateTime.Now;
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateDelay(3000, 3, $"#u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2"));
                    }
                    else
                    {
                        if (!session.Character.IsVehicled && option != 0)
                        {
                            DateTime delay = DateTime.Now.AddSeconds(-4);
                            if (session.Character.LastDelay > delay && session.Character.LastDelay < delay.AddSeconds(2))
                            {
                                session.Character.Speed         = Speed;
                                session.Character.IsVehicled    = true;
                                session.Character.VehicleSpeed  = Speed;
                                session.Character.MorphUpgrade  = 0;
                                session.Character.MorphUpgrade2 = 0;
                                session.Character.Morph         = Morph + (byte)session.Character.Gender;
                                session.Character.Mates?.ForEach(x => session.CurrentMapInstance?.Broadcast(x.GenerateOut()));
                                session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(196), session.Character.MapX, session.Character.MapY);
                                session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode());
                                session.SendPacket(session.Character.GenerateCond());
                                session.Character.LastSpeedChange = DateTime.Now;
                            }
                        }
                        else if (session.Character.IsVehicled)
                        {
                            session.Character.Mates?.ForEach(x =>
                            {
                                x.PositionX = session.Character.PositionX;
                                x.PositionY = session.Character.PositionY;
                                session.CurrentMapInstance?.Broadcast(x.GenerateIn());
                            });
                            session.Character.RemoveVehicle();
                        }
                    }
                }
                break;

            case 1002:
                // TODO REVIEW THIS

                /*
                 * if (EffectValue == 69)
                 * {
                 *  int rnd = ServerManager.Instance.RandomNumber(0, 1000);
                 *  if (rnd < 5)
                 *  {
                 *      short[] vnums =
                 *      {
                 *          5560, 5591, 4099, 907, 1160, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714,
                 *          4715, 4716
                 *      };
                 *      byte[] counts = {1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
                 *      int item = ServerManager.Instance.RandomNumber(0, 17);
                 *
                 *      session.Character.GiftAdd(vnums[item], counts[item]);
                 *  }
                 *  else if (rnd < 30)
                 *  {
                 *      short[] vnums = {361, 362, 363, 366, 367, 368, 371, 372, 373};
                 *      session.Character.GiftAdd(vnums[ServerManager.Instance.RandomNumber(0, 9)], 1);
                 *  }
                 *  else
                 *  {
                 *      short[] vnums =
                 *      {
                 *          1161, 2282, 1030, 1244, 1218, 5369, 1012, 1363, 1364, 2160, 2173, 5959, 5983, 2514,
                 *          2515, 2516, 2517, 2518, 2519, 2520, 2521, 1685, 1686, 5087, 5203, 2418, 2310, 2303,
                 *          2169, 2280, 5892, 5893, 5894, 5895, 5896, 5897, 5898, 5899, 5332, 5105, 2161, 2162
                 *      };
                 *      byte[] counts =
                 *      {
                 *          10, 10, 20, 5, 1, 1, 99, 1, 1, 5, 5, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 5, 20,
                 *          20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
                 *      };
                 *      int item = ServerManager.Instance.RandomNumber(0, 42);
                 *      session.Character.GiftAdd(vnums[item], counts[item]);
                 *  }
                 *  session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                 * }
                 */
                if (session.HasCurrentMapInstance)
                {
                    if (session.CurrentMapInstance.Map.MapTypes.All(m => m.MapTypeId != (short)MapTypeEnum.Act4))
                    {
                        short[] vnums =
                        {
                            1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399,
                            1400, 1401, 1402, 1403, 1404, 1405
                        };
                        short vnum = vnums[ServerManager.Instance.RandomNumber(0, 20)];

                        NpcMonster npcmonster = ServerManager.Instance.GetNpc(vnum);
                        if (npcmonster == null)
                        {
                            return;
                        }
                        MapMonster monster = new MapMonster
                        {
                            MonsterVNum   = vnum,
                            MapY          = session.Character.MapY,
                            MapX          = session.Character.MapX,
                            MapId         = session.Character.MapInstance.Map.MapId,
                            Position      = (byte)session.Character.Direction,
                            IsMoving      = true,
                            MapMonsterId  = session.CurrentMapInstance.GetNextMonsterId(),
                            ShouldRespawn = false
                        };
                        monster.Initialize(session.CurrentMapInstance);
                        session.CurrentMapInstance.AddMonster(monster);
                        session.CurrentMapInstance.Broadcast(monster.GenerateIn());
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                }
                break;

            case 69:
                session.Character.GetReput(ReputPrice);
                session.SendPacket(session.Character.GenerateFd());
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                break;

            case 789:
                session.Character.GiftAdd((short)inv.Item.EffectValue, 1);
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                break;

            case 790:
                break;

            case 1003:
                if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalSilver))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.BazaarMedalGold
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            case 1004:
                if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalGold))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.BazaarMedalSilver
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            case 1005:
                if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.BackPack))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.BackPack
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            case 1006:
                if (option == 0)
                {
                    session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2 {Language.Instance.GetMessageFromKey("ASK_PET_MAX")}");
                }
                else
                {
                    if (session.Character.MaxMateCount < 30)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("GET_PET_PLACES"), 10));
                        session.SendPacket(session.Character.GenerateScpStc());
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                }
                break;

            case 1007:
                if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.PetBasket))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.PetBasket
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket("ib 1278 1");
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            case 1008:
                if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.PetBackPack))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.PetBackPack
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            default:
                Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()));
                break;
            }
        }
Exemplo n.º 16
0
        internal void MonsterLife()
        {
            NpcMonster monster = ServerManager.GetNpc(this.MonsterVNum);

            if (monster == null)
            {
                return;
            }

            double time = (DateTime.Now - LastMove).TotalSeconds;

            if (Move && time > 2.2)
            {
                Random r     = new Random((int)DateTime.Now.Ticks & 0x0000FFFF);
                byte   point = (byte)r.Next(2, 6);

                byte xpoint = (byte)r.Next(0, point);
                byte ypoint = (byte)(point - xpoint);

                short MapX = (short)r.Next(-xpoint + firstX, xpoint + firstX);
                short MapY = (short)r.Next(-ypoint + firstY, ypoint + firstY);
                bool  ok   = true;
                if (MapX > firstX)
                {
                    for (int i = 0; i < MapX - firstX; i++)
                    {
                        if (ServerManager.GetMap(MapId).IsBlockedZone(firstX + i, firstY))
                        {
                            ok = false;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < firstX - MapX; i++)
                    {
                        if (ServerManager.GetMap(MapId).IsBlockedZone(MapX + i, MapY))
                        {
                            ok = false;
                        }
                    }
                }

                if (MapY > firstY)
                {
                    for (int i = 0; i < MapY - firstY; i++)
                    {
                        if (ServerManager.GetMap(MapId).IsBlockedZone(firstX, firstY + i))
                        {
                            ok = false;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < firstX - MapX; i++)
                    {
                        if (ServerManager.GetMap(MapId).IsBlockedZone(MapX, MapY + i))
                        {
                            ok = false;
                        }
                    }
                }
                if (ok)
                {
                    this.MapX = MapX;
                    this.MapY = MapY;
                    LastMove  = DateTime.Now;

                    string movepacket = $"mv 3 {this.MapMonsterId} {this.MapX} {this.MapY} {monster.Speed}";
                    ClientLinkManager.Instance.RequiereBroadcastFromMap(MapId, movepacket);
                }
            }
        }
Exemplo n.º 17
0
        public void Initialize()
        {
            if (MapInstance.MapInstanceType == MapInstanceType.BaseMapInstance && ServerManager.Instance.MapBossVNums.Contains(NpcVNum))
            {
                MapCell randomCell = MapInstance.Map.GetRandomPosition();
                if (randomCell != null)
                {
                    if (MapInstance.Portals.Any(s => Map.GetDistance(new MapCell {
                        X = s.SourceX, Y = s.SourceY
                    }, new MapCell {
                        X = randomCell.X, Y = randomCell.Y
                    }) < 5))
                    {
                        randomCell = MapInstance.Map.GetRandomPosition();
                    }
                    MapX = randomCell.X;
                    MapY = randomCell.Y;
                }
            }

            _random = new Random(MapNpcId);
            Npc     = ServerManager.GetNpcMonster(NpcVNum);
            MaxHp   = Npc.MaxHP;
            MaxMp   = Npc.MaxMP;

            if (MapInstance?.MapInstanceType == MapInstanceType.TimeSpaceInstance)
            {
                if (IsProtected)
                {
                    MaxHp *= 8;
                    MaxMp *= 8;
                }
            }
            LastSay             = DateTime.Now;
            EffectDelay         = (short)(EffectDelay == 0 ? 4750 : EffectDelay);
            Delay               = (short)(Delay == 0 ? 4750 : Delay);
            IsAlive             = true;
            CurrentHp           = MaxHp;
            CurrentMp           = MaxMp;
            LastEffect          = DateTime.Now;
            LastProtectedEffect = DateTime.Now;
            LastMove            = DateTime.Now;
            LastSkill           = DateTime.Now;
            IsHostile           = Npc.IsHostile;
            ShouldRespawn       = ShouldRespawn ?? true;
            FirstX              = MapX;
            FirstY              = MapY;
            EffectActivated     = true;
            _movetime           = ServerManager.RandomNumber(500, 3000);
            Path        = new List <Node>();
            Recipes     = ServerManager.Instance.GetRecipesByMapNpcId(MapNpcId);
            Target      = -1;
            Teleporters = ServerManager.Instance.GetTeleportersByNpcVNum(MapNpcId);
            Shop shop = ServerManager.Instance.GetShopByMapNpcId(MapNpcId);

            if (shop != null)
            {
                shop.Initialize();
                Shop = shop;
            }
            Skills = new List <NpcMonsterSkill>();
            foreach (NpcMonsterSkill ski in Npc.Skills)
            {
                Skills.Add(new NpcMonsterSkill {
                    SkillVNum = ski.SkillVNum, Rate = ski.Rate
                });
            }
            BattleEntity = new BattleEntity(this);

            if (AliveTime > 0)
            {
                Thread AliveTimeThread = new Thread(() => AliveTimeCheck());
                AliveTimeThread.Start();
            }

            if (NpcVNum == 1408)
            {
                OnDeathEvents.Add(new EventContainer(MapInstance, EventActionType.SPAWNMONSTER, new MonsterToSummon(621, new MapCell {
                    X = MapX, Y = MapY
                }, null, move: true)));
            }
            if (NpcVNum == 1409)
            {
                OnDeathEvents.Add(new EventContainer(MapInstance, EventActionType.SPAWNMONSTER, new MonsterToSummon(622, new MapCell {
                    X = MapX, Y = MapY
                }, null, move: true)));
            }
            if (NpcVNum == 1410)
            {
                OnDeathEvents.Add(new EventContainer(MapInstance, EventActionType.SPAWNMONSTER, new MonsterToSummon(623, new MapCell {
                    X = MapX, Y = MapY
                }, null, move: true)));
            }

            if (OnSpawnEvents.Any())
            {
                OnSpawnEvents.ToList().ForEach(e => { EventHelper.Instance.RunEvent(e, npc: this); });
                OnSpawnEvents.Clear();
            }
        }
Exemplo n.º 18
0
        public Map(short mapId, Guid uniqueIdentifier, byte[] data)
        {
            MapId             = mapId;
            _uniqueIdentifier = uniqueIdentifier;
            Data = data;
            LoadZone();
            IEnumerable <PortalDTO> portalsDTO = DAOFactory.PortalDAO.LoadByMap(MapId);

            _portals    = new List <Portal>();
            DroppedList = new Dictionary <long, MapItem>();

            UserShops = new Dictionary <long, MapShop>();
            foreach (PortalDTO portal in portalsDTO)
            {
                _portals.Add(new GameObject.Portal()
                {
                    DestinationMapId = portal.DestinationMapId,
                    SourceMapId      = portal.SourceMapId,
                    SourceX          = portal.SourceX,
                    SourceY          = portal.SourceY,
                    DestinationX     = portal.DestinationX,
                    DestinationY     = portal.DestinationY,
                    Type             = portal.Type,
                    PortalId         = portal.PortalId,
                    IsDisabled       = portal.IsDisabled
                });
            }

            _monsters = new List <MapMonster>();
            foreach (MapMonsterDTO monster in DAOFactory.MapMonsterDAO.LoadFromMap(MapId).ToList())
            {
                NpcMonster npcmonster = ServerManager.GetNpc(monster.MonsterVNum);
                _monsters.Add(new MapMonster(this)
                {
                    MapId        = monster.MapId,
                    MapX         = monster.MapX,
                    MapMonsterId = monster.MapMonsterId,
                    MapY         = monster.MapY,
                    MonsterVNum  = monster.MonsterVNum,
                    Position     = monster.Position,
                    firstX       = monster.MapX,
                    firstY       = monster.MapY,
                    IsMoving     = monster.IsMoving,
                    Alive        = true,
                    CurrentHp    = npcmonster.MaxHP,
                    CurrentMp    = npcmonster.MaxMP
                });
            }
            IEnumerable <MapNpcDTO> npcsDTO = DAOFactory.MapNpcDAO.LoadFromMap(MapId).ToList();

            _npcs = new List <MapNpc>();
            foreach (MapNpcDTO npc in npcsDTO)
            {
                _npcs.Add(new GameObject.MapNpc(npc.MapNpcId, this)
                {
                    MapId       = npc.MapId,
                    MapX        = npc.MapX,
                    MapY        = npc.MapY,
                    Position    = npc.Position,
                    NpcVNum     = npc.NpcVNum,
                    IsSitting   = npc.IsSitting,
                    IsMoving    = npc.IsMoving,
                    Effect      = npc.Effect,
                    EffectDelay = npc.EffectDelay,
                    Dialog      = npc.Dialog,
                    FirstX      = npc.MapX,
                    FirstY      = npc.MapY
                });
            }
        }
Exemplo n.º 19
0
        public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null)
        {
            switch (Effect)
            {
            // sp point potions
            case 150:
            case 151:
                session.Character.SpAdditionPoint += EffectValue;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                session.SendPacket(session.Character.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDED"), EffectValue), 0));
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            case 204:
                session.Character.SpPoint         += EffectValue;
                session.Character.SpAdditionPoint += EffectValue * 3;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                if (session.Character.SpPoint > 10000)
                {
                    session.Character.SpPoint = 10000;
                }
                session.SendPacket(session.Character.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDEDBOTH"), EffectValue, EffectValue * 3), 0));
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            //Atk/Def/HP/Exp potions
            case 6600:
                switch (EffectValue)
                {
                case 1:
                    IndicatorBase buff1 = new Buff.Indicators.Item.AttackPotion(session.Character.Level);
                    session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(203));
                    session.Character.Buff.Add(buff1);
                    break;

                case 2:
                    IndicatorBase buff2 = new Buff.Indicators.Item.DefensePotion(session.Character.Level);
                    session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(203));
                    session.Character.Buff.Add(buff2);
                    break;

                case 3:
                    IndicatorBase buff3 = new Buff.Indicators.Item.EnergyPotion(session.Character.Level);
                    session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(203));
                    session.Character.Buff.Add(buff3);
                    break;

                case 4:
                    IndicatorBase buff4 = new Buff.Indicators.Item.ExperiencePotion(session.Character.Level);
                    session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(203));
                    session.Character.Buff.Add(buff4);
                    break;
                }
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                break;

            // Divorce letter
            case 6969:     // this is imaginary number I = √(-1)
                break;

            // Cupid's arrow
            case 34:     // this is imaginary number I = √(-1)
                break;

            case 570:
                if (session.Character.Faction == EffectValue)
                {
                    return;
                }
                session.SendPacket(session.Character.Family == null
                        ? $"qna #guri^750^{EffectValue} {Language.Instance.GetMessageFromKey($"ASK_CHANGE_FACTION{EffectValue}")}"
                        : session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("IN_FAMILY"), 0));
                break;

            // wings
            case 650:
                SpecialistInstance specialistInstance = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Wear);
                if (session.Character.UseSp && specialistInstance != null)
                {
                    if (!delay)
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_WINGS_CHANGE")}");
                    }
                    else
                    {
                        specialistInstance.Design       = (byte)EffectValue;
                        session.Character.MorphUpgrade2 = EffectValue;
                        session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode());
                        session.SendPacket(session.Character.GenerateStat());
                        session.SendPacket(session.Character.GenerateStatChar());
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0));
                }
                break;

            // presentation messages
            case 203:
                if (!session.Character.IsVehicled)
                {
                    if (!delay)
                    {
                        session.SendPacket(session.Character.GenerateGuri(10, 2, 1));
                    }
                }
                break;

            // magic lamps
            case 651:
                if (session.Character.Inventory.GetAllItems().All(i => i.Type != InventoryType.Wear))
                {
                    if (!delay)
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE")}");
                    }
                    else
                    {
                        session.Character.ChangeSex();
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0));
                }
                break;

            // vehicles
            case 1000:
                if (Morph > 0)
                {
                    if (!delay && !session.Character.IsVehicled)
                    {
                        if (session.Character.IsSitting)
                        {
                            session.Character.IsSitting = false;
                            session.CurrentMapInstance?.Broadcast(session.Character.GenerateRest());
                        }
                        session.SendPacket(session.Character.GenerateDelay(3000, 3, $"#u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2"));
                    }
                    else
                    {
                        if (!session.Character.IsVehicled && delay)
                        {
                            session.Character.Speed         = Speed;
                            session.Character.IsVehicled    = true;
                            session.Character.VehicleSpeed  = Speed;
                            session.Character.MorphUpgrade  = 0;
                            session.Character.MorphUpgrade2 = 0;
                            session.Character.Morph         = Morph + (byte)session.Character.Gender;
                            session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(196), session.Character.MapX, session.Character.MapY);
                            session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode());
                            session.SendPacket(session.Character.GenerateCond());
                            session.Character.LastSpeedChange = DateTime.Now;
                        }
                        else if (session.Character.IsVehicled)
                        {
                            session.Character.RemoveVehicle();
                        }
                    }
                }
                break;

            case 1002:
                if (EffectValue == 69)
                {
                    int rnd = ServerManager.RandomNumber(0, 1000);
                    if (rnd < 5)
                    {
                        short[] vnums  = { 5560, 5591, 4099, 907, 1160, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714, 4715, 4716 };
                        byte[]  counts = { 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
                        int     item   = ServerManager.RandomNumber(0, 17);

                        session.Character.GiftAdd(vnums[item], counts[item]);
                    }
                    else if (rnd < 30)
                    {
                        short[] vnums = { 361, 362, 363, 366, 367, 368, 371, 372, 373 };
                        session.Character.GiftAdd(vnums[ServerManager.RandomNumber(0, 9)], 1);
                    }
                    else
                    {
                        short[] vnums  = { 1161, 2282, 1030, 1244, 1218, 5369, 1012, 1363, 1364, 2160, 2173, 5959, 5983, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 1685, 1686, 5087, 5203, 2418, 2310, 2303, 2169, 2280, 5892, 5893, 5894, 5895, 5896, 5897, 5898, 5899, 5332, 5105, 2161, 2162 };
                        byte[]  counts = { 10, 10, 20, 5, 1, 1, 99, 1, 1, 5, 5, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 5, 20, 20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
                        int     item   = ServerManager.RandomNumber(0, 42);
                        session.Character.GiftAdd(vnums[item], counts[item]);
                    }
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                }
                else
                {
                    if (session.HasCurrentMapInstance)
                    {
                        if (session.CurrentMapInstance.Map.MapTypes.All(m => m.MapTypeId != (short)MapTypeEnum.Act4))
                        {
                            short[] vnums = { 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405 };
                            short   vnum  = vnums[ServerManager.RandomNumber(0, 20)];

                            NpcMonster npcmonster = ServerManager.GetNpc(vnum);
                            if (npcmonster == null)
                            {
                                return;
                            }
                            // ReSharper disable once PossibleNullReferenceException HasCurrentMapInstance NullCheck
                            MapMonster monster = new MapMonster {
                                MonsterVNum = vnum, MapY = session.Character.MapY, MapX = session.Character.MapX, MapId = session.Character.MapInstance.Map.MapId, Position = (byte)session.Character.Direction, IsMoving = true, MapMonsterId = session.CurrentMapInstance.GetNextMonsterId(), ShouldRespawn = false
                            };
                            monster.Initialize(session.CurrentMapInstance);
                            monster.StartLife();
                            session.CurrentMapInstance.AddMonster(monster);
                            session.CurrentMapInstance.Broadcast(monster.GenerateIn3());
                            session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                        }
                    }
                }
                break;

            case 69:
                session.Character.Reput += ReputPrice;
                session.SendPacket(session.Character.GenerateFd());
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                break;

            case 1003:
                if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalSilver))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO {
                        CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.BazaarMedalGold
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            case 1004:
                if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalGold))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO {
                        CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.BazaarMedalSilver
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            case 1005:
                if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.BackPack))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO {
                        CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.BackPack
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            default:
                Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()));
                break;
            }
        }
Exemplo n.º 20
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            if (session.Character.IsVehicled && Effect != 888)
            {
                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_DO_VEHICLED"), 10));
                return;
            }

            if (inv.ItemVNum == 333 || inv.ItemVNum == 334) // Sealed Jajamaru Specialist Card & Sealed Princess Sakura Bead
            {
                return;
            }

            switch (Effect)
            {
            case 0:
                if (Option == 0)
                {
                    if (packetsplit?.Length == 9)
                    {
                        ItemInstance box = session.Character.Inventory.LoadBySlotAndType(inv.Slot, InventoryType.Equipment);
                        if (box != null)
                        {
                            if (box.Item.ItemSubType == 3)
                            {
                                session.SendPacket($"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_OPEN_BOX")}");
                            }
                            else if (box.HoldingVNum == 0)
                            {
                                session.SendPacket($"qna #guri^300^8023^{inv.Slot}^{packetsplit[3]} {Language.Instance.GetMessageFromKey("ASK_STORE_PET")}");
                            }
                            else
                            {
                                session.SendPacket($"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_RELEASE_PET")}");
                            }
                        }
                    }
                }
                else
                {
                    //u_i 2 2000000 0 21 0 0
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.Item.ItemSubType == 3)
                        {
                            List <RollGeneratedItemDTO> roll = box.Item.RollGeneratedItems.Where(s => s.MinimumOriginalItemRare <= box.Rare &&
                                                                                                 s.MaximumOriginalItemRare >= box.Rare &&
                                                                                                 s.OriginalItemDesign == box.Design).ToList();
                            int probabilities = roll.Sum(s => s.Probability);
                            int rnd           = ServerManager.RandomNumber(0, probabilities);
                            int currentrnd    = 0;
                            foreach (RollGeneratedItemDTO rollitem in roll.OrderBy(s => ServerManager.RandomNumber()))
                            {
                                currentrnd += rollitem.Probability;
                                if (currentrnd >= rnd)
                                {
                                    Item  i       = ServerManager.GetItem(rollitem.ItemGeneratedVNum);
                                    sbyte rare    = 0;
                                    byte  upgrade = 0;
                                    if (i.ItemType == ItemType.Armor || i.ItemType == ItemType.Weapon || i.ItemType == ItemType.Shell || i.ItemType == ItemType.Box)
                                    {
                                        rare = box.Rare;
                                    }
                                    if (i.ItemType == ItemType.Shell)
                                    {
                                        if (rare < 1)
                                        {
                                            rare = 1;
                                        }
                                        else if (rare > 7)
                                        {
                                            rare = 7;
                                        }
                                        upgrade = (byte)ServerManager.RandomNumber(50, 81);
                                    }
                                    if (rollitem.IsRareRandom)
                                    {
                                        rnd = ServerManager.RandomNumber(0, 100);

                                        for (int j = ItemHelper.RareRate.Length - 1; j >= 0; j--)
                                        {
                                            if (rnd < ItemHelper.RareRate[j])
                                            {
                                                rare = (sbyte)j;
                                                break;
                                            }
                                        }
                                        if (rare < 1)
                                        {
                                            rare = 1;
                                        }
                                    }
                                    session.Character.GiftAdd(rollitem.ItemGeneratedVNum, rollitem.ItemGeneratedAmount, (byte)rare, upgrade, rollitem.ItemGeneratedDesign);
                                    session.SendPacket($"rdi {rollitem.ItemGeneratedVNum} {rollitem.ItemGeneratedAmount}");
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                    return;
                                }
                            }
                        }
                        else if (box.HoldingVNum == 0)
                        {
                            if (packetsplit.Length == 1 && int.TryParse(packetsplit[0], out int PetId) && session.Character.Mates.Find(s => s.MateTransportId == PetId) is Mate mate)
                            {
                                if (ItemSubType == 0 && mate.MateType != MateType.Pet || ItemSubType == 1 && mate.MateType != MateType.Partner)
                                {
                                    return;
                                }
                                if (mate.MateType == MateType.Partner && mate.GetInventory().Count > 0)
                                {
                                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0));
                                    return;
                                }
                                box.HoldingVNum = mate.NpcMonsterVNum;
                                box.SpLevel     = mate.Level;
                                box.SpDamage    = mate.Attack;
                                box.SpDefence   = mate.Defence;
                                session.Character.Mates.Remove(mate);
                                if (mate.MateType == MateType.Partner)
                                {
                                    byte i = 0;
                                    session.Character.Mates.Where(s => s.MateType == MateType.Partner).ToList().ForEach(s =>
                                    {
                                        s.GetInventory().ForEach(item => item.Type = (InventoryType)(13 + i));
                                        s.PetId = i;
                                        i++;
                                    });
                                }
                                session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("PET_STORED")));
                                session.SendPacket(UserInterfaceHelper.GeneratePClear());
                                session.SendPackets(session.Character.GenerateScP());
                                session.SendPackets(session.Character.GenerateScN());
                                session.CurrentMapInstance?.Broadcast(mate.GenerateOut());
                            }
                        }
                        else
                        {
                            NpcMonster heldMonster = ServerManager.GetNpcMonster(box.HoldingVNum);
                            if (heldMonster != null)
                            {
                                Mate mate = new Mate(session.Character, heldMonster, box.SpLevel, ItemSubType == 0 ? MateType.Pet : MateType.Partner)
                                {
                                    Attack  = box.SpDamage,
                                    Defence = box.SpDefence
                                };
                                if (session.Character.AddPet(mate))
                                {
                                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                                    session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("PET_LEAVE_BEAD")));
                                }
                            }
                        }
                    }
                }
                break;

            case 1:
                if (Option == 0)
                {
                    session.SendPacket($"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_RELEASE_PET")}");
                }
                else
                {
                    NpcMonster heldMonster = ServerManager.GetNpcMonster((short)EffectValue);
                    if (session.CurrentMapInstance == session.Character.Miniland && heldMonster != null)
                    {
                        Mate mate = new Mate(session.Character, heldMonster, LevelMinimum, ItemSubType == 1 ? MateType.Partner : MateType.Pet);
                        if (session.Character.AddPet(mate))
                        {
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                            session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("PET_LEAVE_BEAD")));
                        }
                    }
                    else
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_IN_MINILAND"), 12));
                    }
                }

                break;

            case 69:
                if (EffectValue == 1 || EffectValue == 2)
                {
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"wopen 44 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Count > 0)
                            {
                                ItemInstance itemInstance = newInv[0];
                                ItemInstance specialist   = session.Character.Inventory.LoadBySlotAndType(itemInstance.Slot, itemInstance.Type);
                                if (specialist != null)
                                {
                                    specialist.SlDamage          = box.SlDamage;
                                    specialist.SlDefence         = box.SlDefence;
                                    specialist.SlElement         = box.SlElement;
                                    specialist.SlHP              = box.SlHP;
                                    specialist.SpDamage          = box.SpDamage;
                                    specialist.SpDark            = box.SpDark;
                                    specialist.SpDefence         = box.SpDefence;
                                    specialist.SpElement         = box.SpElement;
                                    specialist.SpFire            = box.SpFire;
                                    specialist.SpHP              = box.SpHP;
                                    specialist.SpLevel           = box.SpLevel;
                                    specialist.SpLight           = box.SpLight;
                                    specialist.SpStoneUpgrade    = box.SpStoneUpgrade;
                                    specialist.SpWater           = box.SpWater;
                                    specialist.Upgrade           = box.Upgrade;
                                    specialist.EquipmentSerialId = box.EquipmentSerialId;
                                    specialist.XP = box.XP;
                                }
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    if (specialist != null)
                                    {
                                        session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")} {specialist.Item.Name} + {specialist.Upgrade}", 12));
                                        newInv.ForEach(s => session.SendPacket(specialist.GenerateInventoryAdd()));
                                    }
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 3)
                {
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 26 0 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Count > 0)
                            {
                                ItemInstance itemInstance = newInv[0];
                                ItemInstance fairy        = session.Character.Inventory.LoadBySlotAndType(itemInstance.Slot, itemInstance.Type);
                                if (fairy != null)
                                {
                                    fairy.ElementRate = box.ElementRate;
                                }
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    if (fairy != null)
                                    {
                                        session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")} {fairy.Item.Name} ({fairy.ElementRate}%)", 12));
                                        newInv.ForEach(s => session.SendPacket(fairy.GenerateInventoryAdd()));
                                    }
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 4)
                {
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 24 0 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Count > 0)
                            {
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")} {newInv[0].Item.Name} x 1)", 12));
                                    newInv.ForEach(s => session.SendPacket(s.GenerateInventoryAdd()));
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 5)
                {
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 24 0 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Count > 0)
                            {
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")} {newInv[0].Item.Name} x 1)", 12));
                                    newInv.ForEach(s => session.SendPacket(s.GenerateInventoryAdd()));
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                break;

            case 888:
                if (session.Character.IsVehicled)
                {
                    if (!session.Character.Buff.Any(s => s.Card.CardId == 336))
                    {
                        if (inv.ItemDeleteTime == null)
                        {
                            inv.ItemDeleteTime = DateTime.Now.AddHours(LevelMinimum);
                        }
                        session.Character.VehicleItem.BCards.ForEach(s => s.ApplyBCards(session.Character.BattleEntity, session.Character.BattleEntity));
                        session.CurrentMapInstance.Broadcast($"eff 1 {session.Character.CharacterId} 885");
                    }
                }
                break;

            case 4801:

                break;

            default:
                Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType(), VNum, Effect, EffectValue));
                break;
            }
        }
Exemplo n.º 21
0
        public void ApplyBCards(object session, object sender = null)
        {
            //Console.WriteLine($"BCardId: {BCardId} Type: {(BCardType.CardType)Type} SubType: {SubType} CardId: {CardId?.ToString() ?? "null"} ItemVNum: {ItemVNum?.ToString() ?? "null"} SkillVNum: {SkillVNum?.ToString() ?? "null"} SessionType: {session?.GetType().ToString() ?? "null"} SenderType: {sender?.GetType().ToString() ?? "null"}");

            switch ((BCardType.CardType)Type)
            {
            case BCardType.CardType.Buff:
            {
                if (ServerManager.RandomNumber() < FirstData)
                {
                    Character senderCharacter = sender is ClientSession senderSession
                                ? senderSession.Character : sender as Character;

                    if (session is Character character)
                    {
                        short cardId = (short)SecondData;

                        // If either Berserk Spirit or Strong Berserk Spirit is active
                        // then don't add Weak Berserk Spirit

                        if (cardId == 601 &&
                            character.Buff?.Any(s => s?.Card?.CardId == 602 || s?.Card?.CardId == 603) == true)
                        {
                            break;
                        }

                        if (senderCharacter != null)
                        {
                            // TODO: Get anti stats from BCard

                            character.AddBuff(new Buff((short)SecondData, senderCharacter.Level, senderCharacter));
                        }
                        else
                        {
                            character.AddBuff(new Buff((short)SecondData, character.Level));
                        }
                    }
                    else if (session is MapMonster mapMonster)
                    {
                        if (senderCharacter != null)
                        {
                            mapMonster.AddBuff(new Buff((short)SecondData, senderCharacter.Level, senderCharacter));
                        }
                        else
                        {
                            mapMonster.AddBuff(new Buff((short)SecondData, mapMonster.Monster.Level));
                        }
                    }
                }
            }
            break;

            case BCardType.CardType.Move:
            {
                if (session is Character character)
                {
                    character.LastSpeedChange = DateTime.Now;
                    character.Session.SendPacket(character.GenerateCond());
                }
            }
            break;

            case BCardType.CardType.Summons:
            {
                if (session is Character character)
                {
                    if (character.MapInstance != null)
                    {
                        List <MonsterToSummon> monsterList = new List <MonsterToSummon>();

                        if (SubType == (byte)AdditionalTypes.Summons.Summons / 10)
                        {
                            int aliveTime = ServerManager.GetNpc((short)SecondData).RespawnTime;

                            for (int i = 0; i < FirstData; i++)
                            {
                                MapCell mapCell = new MapCell
                                {
                                    X = (short)(ServerManager.RandomNumber(-1, 2) + character.PositionX),
                                    Y = (short)(ServerManager.RandomNumber(-1, 2) + character.PositionY),
                                };

                                monsterList.Add(new MonsterToSummon((short)SecondData, mapCell, -1, true, false, false, true, false, -1, character, aliveTime, false));
                            }
                        }

                        if (monsterList.Any())
                        {
                            EventHelper.Instance.RunEvent(new EventContainer(character.MapInstance,
                                                                             EventActionType.SPAWNMONSTERS, monsterList));
                        }
                    }
                }
            }
            break;

            case BCardType.CardType.SpecialAttack:
                break;

            case BCardType.CardType.SpecialDefence:
                break;

            case BCardType.CardType.AttackPower:
                break;

            case BCardType.CardType.Target:
                break;

            case BCardType.CardType.Critical:
                break;

            case BCardType.CardType.SpecialCritical:
                break;

            case BCardType.CardType.Element:
                break;

            case BCardType.CardType.IncreaseDamage:
                break;

            case BCardType.CardType.Defence:
                break;

            case BCardType.CardType.DodgeAndDefencePercent:
                break;

            case BCardType.CardType.Block:
                break;

            case BCardType.CardType.Absorption:
                break;

            case BCardType.CardType.ElementResistance:
                break;

            case BCardType.CardType.EnemyElementResistance:
                break;

            case BCardType.CardType.Damage:
                break;

            case BCardType.CardType.GuarantedDodgeRangedAttack:
                break;

            case BCardType.CardType.Morale:
                break;

            case BCardType.CardType.Casting:
                break;

            case BCardType.CardType.Reflection:
                break;

            case BCardType.CardType.DrainAndSteal:
                break;

            case BCardType.CardType.HealingBurningAndCasting:
            {
                Character senderCharacter = sender is ClientSession senderSession
                            ? senderSession.Character : sender as Character;

                if (senderCharacter != null)
                {
                    #region Character

                    if (session is Character character)
                    {
                        void HealingBurningAndCastingAction()
                        {
                            if (!character.IsAlive ||
                                character.MapInstance == null ||
                                character.Session == null)
                            {
                                return;
                            }

                            int amount = 0;

                            if (SubType == (byte)AdditionalTypes.HealingBurningAndCasting.RestoreHP / 10 ||
                                SubType == (byte)AdditionalTypes.HealingBurningAndCasting.DecreaseHP / 10)
                            {
                                if (FirstData > 0)
                                {
                                    if (IsLevelScaled)
                                    {
                                        amount = senderCharacter.Level * FirstData;
                                    }
                                    else
                                    {
                                        amount = FirstData;
                                    }

                                    if (character.Hp + amount > character.HPMax)
                                    {
                                        amount = character.HPMax - character.Hp;
                                    }

                                    character.Hp += amount;

                                    character.MapInstance.Broadcast(character.GenerateRc(amount));
                                }
                                else
                                {
                                    if (IsLevelScaled)
                                    {
                                        amount = senderCharacter.Level * (FirstData - 1);
                                    }
                                    else
                                    {
                                        amount = FirstData;
                                    }

                                    amount *= -1;

                                    if (character.Hp - amount < 1)
                                    {
                                        amount = character.Hp - 1;
                                    }

                                    character.GetDamage(amount);

                                    character.MapInstance.Broadcast(character.GenerateDm(amount));
                                }

                                character.Session.SendPacket(character.GenerateStat());
                            }
                            else if (SubType == (byte)AdditionalTypes.HealingBurningAndCasting.RestoreMP / 10 ||
                                     SubType == (byte)AdditionalTypes.HealingBurningAndCasting.DecreaseMP / 10)
                            {
                                if (FirstData > 0)
                                {
                                    if (IsLevelScaled)
                                    {
                                        amount = senderCharacter.Level * FirstData;
                                    }
                                    else
                                    {
                                        amount = FirstData;
                                    }

                                    if (character.Mp + amount > character.MPMax)
                                    {
                                        amount = character.MPMax - character.Mp;
                                    }

                                    character.Mp += amount;
                                }
                                else
                                {
                                    if (IsLevelScaled)
                                    {
                                        amount = senderCharacter.Level * (FirstData - 1);
                                    }
                                    else
                                    {
                                        amount = FirstData;
                                    }

                                    amount *= -1;

                                    if (character.Mp - amount < 1)
                                    {
                                        amount = character.Mp - 1;
                                    }

                                    character.DecreaseMp(amount);
                                }

                                character.Session.SendPacket(character.GenerateStat());
                            }
                        }

                        HealingBurningAndCastingAction();

                        if (ThirdData > 0 &&
                            CardId != null)
                        {
                            IDisposable disposable = Observable.Interval(TimeSpan.FromSeconds(ThirdData * 2))
                                                     .Subscribe(s => HealingBurningAndCastingAction());

                            character.DisposeBCard(BCardId);
                            character.BCardDisposables[BCardId] = disposable;
                        }
                    }

                    #endregion

                    #region MapMonster

                    else if (session is MapMonster mapMonster)
                    {
                        void HealingBurningAndCastingAction()
                        {
                            if (!mapMonster.IsAlive ||
                                mapMonster.MapInstance == null)
                            {
                                return;
                            }

                            int amount = 0;

                            if (SubType == (byte)AdditionalTypes.HealingBurningAndCasting.RestoreHP / 10 ||
                                SubType == (byte)AdditionalTypes.HealingBurningAndCasting.DecreaseHP / 10)
                            {
                                if (FirstData > 0)
                                {
                                    if (IsLevelScaled)
                                    {
                                        amount = senderCharacter.Level * FirstData;
                                    }
                                    else
                                    {
                                        amount = FirstData;
                                    }

                                    if (mapMonster.CurrentHp + amount > mapMonster.MaxHp)
                                    {
                                        amount = mapMonster.MaxHp - mapMonster.CurrentHp;
                                    }

                                    mapMonster.CurrentHp += amount;

                                    mapMonster.MapInstance.Broadcast(mapMonster.GenerateRc(amount));
                                }
                                else
                                {
                                    if (IsLevelScaled)
                                    {
                                        amount = senderCharacter.Level * (FirstData - 1);
                                    }
                                    else
                                    {
                                        amount = FirstData;
                                    }

                                    amount *= -1;

                                    if (mapMonster.CurrentHp - amount < 1)
                                    {
                                        amount = mapMonster.CurrentHp - 1;
                                    }

                                    mapMonster.CurrentHp -= amount;

                                    mapMonster.MapInstance.Broadcast(mapMonster.GenerateDm(amount));
                                }
                            }

                            if (SubType == (byte)AdditionalTypes.HealingBurningAndCasting.RestoreMP / 10 ||
                                SubType == (byte)AdditionalTypes.HealingBurningAndCasting.DecreaseMP / 10)
                            {
                                if (FirstData > 0)
                                {
                                    if (IsLevelScaled)
                                    {
                                        amount = senderCharacter.Level * FirstData;
                                    }
                                    else
                                    {
                                        amount = FirstData;
                                    }

                                    if (mapMonster.CurrentMp + amount > mapMonster.MaxMp)
                                    {
                                        amount = mapMonster.MaxMp - mapMonster.CurrentMp;
                                    }

                                    mapMonster.CurrentMp += amount;
                                }
                                else
                                {
                                    if (IsLevelScaled)
                                    {
                                        amount = senderCharacter.Level * (FirstData - 1);
                                    }
                                    else
                                    {
                                        amount = FirstData;
                                    }

                                    amount *= -1;

                                    if (mapMonster.CurrentMp - amount < 1)
                                    {
                                        amount = mapMonster.CurrentMp - 1;
                                    }

                                    mapMonster.CurrentMp -= amount;
                                }
                            }
                        }

                        HealingBurningAndCastingAction();

                        if (ThirdData > 0 &&
                            CardId != null)
                        {
                            IDisposable disposable = Observable.Interval(TimeSpan.FromSeconds(ThirdData * 2))
                                                     .Subscribe(s => HealingBurningAndCastingAction());

                            mapMonster.DisposeBCard(BCardId);
                            mapMonster.BCardDisposables[BCardId] = disposable;
                        }
                    }

                    #endregion
                }
            }
            break;

            case BCardType.CardType.HPMP:
            {
                if (SubType == (byte)AdditionalTypes.HPMP.DecreaseRemainingMP / 10)
                {
                    if (FirstData < 0)
                    {
                        double multiplier = (FirstData * -1) / 100D;

                        if (session is Character character)
                        {
                            character.DecreaseMp((int)(character.Mp * multiplier));
                            character.Session?.SendPacket(character.GenerateStat());
                        }
                        else if (session is MapMonster mapMonster)
                        {
                            mapMonster.DecreaseMp((int)(mapMonster.CurrentMp * multiplier));
                        }
                    }
                }
            }
            break;

            case BCardType.CardType.SpecializationBuffResistance:
            {
                if (SubType == (byte)AdditionalTypes.SpecializationBuffResistance.RemoveGoodEffects / 10)
                {
                    if (session is Character character)
                    {
                        if (FirstData < 0)
                        {
                            if (ServerManager.RandomNumber() < (FirstData * -1))
                            {
                                character.Buff?.GetAllItems()?.Where(s => s?.Card?.BuffType == BuffType.Bad && s.Card.Level < SecondData)?
                                .ToList()?.ForEach(s => character.RemoveBuff(s.Card.CardId));
                            }
                        }
                        else
                        {
                            if (ServerManager.RandomNumber() < FirstData)
                            {
                                character.Buff?.GetAllItems()?.Where(s => s?.Card?.BuffType == BuffType.Good && s.Card.Level < SecondData)?
                                .ToList()?.ForEach(s => character.RemoveBuff(s.Card.CardId));
                            }
                        }
                    }
                }
            }
            break;

            case BCardType.CardType.SpecialEffects:
            {
                if (SubType == (byte)AdditionalTypes.SpecialEffects.ShadowAppears / 10)
                {
                    if (session is Character character)
                    {
                        character.NumberOfShadows = FirstData;
                        character.ShadowsDistance = SecondData;
                        character.MapInstance?.Broadcast(character.GenerateSpeed());
                    }
                }
            }
            break;

            case BCardType.CardType.Capture:
            {
                if (session is MapMonster mapMonster &&
                    sender is ClientSession senderSession)
                {
                    NpcMonster mateNpc = ServerManager.GetNpc(mapMonster.MonsterVNum);

                    if (mateNpc != null)
                    {
                        if (mapMonster.Monster.Catch)
                        {
                            if (mapMonster.IsAlive && mapMonster.CurrentHp <= (int)((double)mapMonster.MaxHp / 2))
                            {
                                if (mapMonster.Monster.Level < senderSession.Character.Level)
                                {
                                    // TODO: Find a new algorithm
                                    int[] chance = { 100, 80, 60, 40, 20, 0 };
                                    if (ServerManager.RandomNumber() < chance[ServerManager.RandomNumber(0, 5)])
                                    {
                                        Mate mate = new Mate(senderSession.Character, mateNpc, (byte)(mapMonster.Monster.Level - 15 > 0 ? mapMonster.Monster.Level - 15 : 1), MateType.Pet);
                                        if (senderSession.Character.CanAddMate(mate))
                                        {
                                            senderSession.Character.AddPetWithSkill(mate);
                                            senderSession.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("CATCH_SUCCESS"), 0));
                                            senderSession.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, senderSession.Character.CharacterId, 197));
                                            senderSession.CurrentMapInstance?.Broadcast(StaticPacketHelper.SkillUsed(UserType.Player, senderSession.Character.CharacterId, 3, mapMonster.MapMonsterId, -1, 0, 15, -1, -1, -1, true, (int)((float)mapMonster.CurrentHp / (float)mapMonster.MaxHp * 100), 0, -1, 0));
                                            mapMonster.SetDeathStatement();
                                            senderSession.CurrentMapInstance?.Broadcast(StaticPacketHelper.Out(UserType.Monster, mapMonster.MapMonsterId));
                                        }
                                        else
                                        {
                                            senderSession.SendPacket(senderSession.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_SLOT_FULL"), 10));
                                            senderSession.SendPacket(StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId));
                                        }
                                    }
                                    else
                                    {
                                        senderSession.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("CATCH_FAIL"), 0));
                                        senderSession.CurrentMapInstance?.Broadcast(StaticPacketHelper.SkillUsed(UserType.Player, senderSession.Character.CharacterId, 3, mapMonster.MapMonsterId, -1, 0, 15, -1, -1, -1, true, (int)((float)mapMonster.CurrentHp / (float)mapMonster.MaxHp * 100), 0, -1, 0));
                                    }
                                }
                                else
                                {
                                    senderSession.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("LEVEL_LOWER_THAN_MONSTER"), 0));
                                    senderSession.SendPacket(StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId));
                                }
                            }
                            else
                            {
                                senderSession.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("CURRENT_HP_TOO_HIGH"), 0));
                                senderSession.SendPacket(StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId));
                            }
                        }
                        else
                        {
                            senderSession.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("MONSTER_CANT_BE_CAPTURED"), 0));
                            senderSession.SendPacket(StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId));
                        }
                    }
                }
            }
            break;

            case BCardType.CardType.SpecialDamageAndExplosions:
                break;

            case BCardType.CardType.SpecialEffects2:
            {
                if (SubType == (byte)AdditionalTypes.SpecialEffects2.TeleportInRadius / 10)
                {
                    if (session is Character character)
                    {
                        character.Teleport((short)FirstData);
                    }
                }
            }
            break;

            case BCardType.CardType.CalculatingLevel:
                break;

            case BCardType.CardType.Recovery:
                break;

            case BCardType.CardType.MaxHPMP:
            {
                if (session is Character character)
                {
                    if (SubType == (byte)AdditionalTypes.MaxHPMP.IncreasesMaximumHP / 10)
                    {
                        character.HPLoad();
                        character.Session?.SendPacket(character.GenerateStat());
                    }
                    else if (SubType == (byte)AdditionalTypes.MaxHPMP.IncreasesMaximumMP / 10)
                    {
                        character.MPLoad();
                        character.Session?.SendPacket(character.GenerateStat());
                    }
                }
            }
            break;

            case BCardType.CardType.MultAttack:
                break;

            case BCardType.CardType.MultDefence:
                break;

            case BCardType.CardType.TimeCircleSkills:
                break;

            case BCardType.CardType.RecoveryAndDamagePercent:
                break;

            case BCardType.CardType.Count:
                break;

            case BCardType.CardType.NoDefeatAndNoDamage:
                break;

            case BCardType.CardType.SpecialActions:
            {
                Character senderCharacter = sender is ClientSession senderSession
                            ? senderSession.Character : sender as Character;

                if (SubType == (byte)AdditionalTypes.SpecialActions.PushBack / 10)
                {
                    if (senderCharacter != null)
                    {
                        if (session is Character character)
                        {
                            if (character.ResistForcedMovementChance <= 0 ||
                                ServerManager.RandomNumber() < character.ResistForcedMovementChance)
                            {
                                character.PushBack((short)FirstData, senderCharacter);
                            }
                        }
                        else if (session is MapMonster mapMonster)
                        {
                            mapMonster.PushBack((short)FirstData, senderCharacter);
                        }
                    }
                }
                else if (SubType == (byte)AdditionalTypes.SpecialActions.FocusEnemies / 10)
                {
                    if (senderCharacter != null)
                    {
                        if (session is Character character)
                        {
                            if (character.ResistForcedMovementChance <= 0 ||
                                ServerManager.RandomNumber() < character.ResistForcedMovementChance)
                            {
                                character.Focus((short)FirstData, senderCharacter);
                            }
                        }
                        else if (session is MapMonster mapMonster)
                        {
                            mapMonster.Focus((short)FirstData, senderCharacter);
                        }
                    }
                }
                else if (SubType == (byte)AdditionalTypes.SpecialActions.Hide / 10)
                {
                    if (session is Character character)
                    {
                        character.SetInvisible(true);
                    }
                }
            }
            break;

            case BCardType.CardType.Transform:
                break;

            case BCardType.CardType.Mode:
                break;

            case BCardType.CardType.NoCharacteristicValue:
                break;

            case BCardType.CardType.LightAndShadow:
            {
                if (SubType == (byte)AdditionalTypes.LightAndShadow.RemoveBadEffects / 10)
                {
                    if (session is Character character)
                    {
                        character.Buff?.GetAllItems()?.Where(s => s?.Card?.BuffType == BuffType.Bad && s.Card.Level < FirstData)?
                        .ToList()?.ForEach(s => character.RemoveBuff(s.Card.CardId));
                    }
                }
            }
            break;

            case BCardType.CardType.Item:
                break;

            case BCardType.CardType.DebuffResistance:
                break;

            case BCardType.CardType.SpecialBehaviour:
                break;

            case BCardType.CardType.Quest:
                break;

            case BCardType.CardType.SecondSPCard:
            {
                if (session is Character character)
                {
                    if (character.MapInstance != null)
                    {
                        List <MonsterToSummon> monsterList = new List <MonsterToSummon>();

                        if (SubType == (byte)AdditionalTypes.SecondSPCard.PlantBomb / 10)
                        {
                            MapMonster bomb = character.MapInstance.Monsters.FirstOrDefault(m => m?.Owner?.CharacterId == character.CharacterId &&
                                                                                            m.MonsterVNum == (short)SecondData);

                            if (bomb == null)
                            {
                                for (int i = 0; i < FirstData; i++)
                                {
                                    monsterList.Add(new MonsterToSummon((short)SecondData, new MapCell {
                                            X = character.PositionX, Y = character.PositionY
                                        },
                                                                        -1, false, false, false, false, false, -1, character, 0, false));
                                }
                            }
                            else
                            {
                                bomb.Explode();
                                break;
                            }
                        }
                        else if (SubType == (byte)AdditionalTypes.SecondSPCard.PlantSelfDestructionBomb / 10)
                        {
                            int aliveTime = ServerManager.GetNpc((short)SecondData).RespawnTime;

                            for (int i = 0; i < FirstData; i++)
                            {
                                MapCell mapCell = new MapCell
                                {
                                    X = (short)(ServerManager.RandomNumber(-1, 2) + character.PositionX),
                                    Y = (short)(ServerManager.RandomNumber(-1, 2) + character.PositionY),
                                };

                                monsterList.Add(new MonsterToSummon((short)SecondData, mapCell, -1, true, false, false, true, false, -1, character, aliveTime, true));
                            }
                        }

                        if (monsterList.Any())
                        {
                            EventHelper.Instance.RunEvent(new EventContainer(character.MapInstance,
                                                                             EventActionType.SPAWNMONSTERS, monsterList));
                        }
                    }
                }
            }
            break;

            case BCardType.CardType.SPCardUpgrade:
                break;

            case BCardType.CardType.HugeSnowman:
                break;

            case BCardType.CardType.Drain:
                break;

            case BCardType.CardType.BossMonstersSkill:
                break;

            case BCardType.CardType.LordHatus:
                break;

            case BCardType.CardType.LordCalvinas:
                break;

            case BCardType.CardType.SESpecialist:
            {
                if (SubType == (byte)AdditionalTypes.SESpecialist.LowerHPStrongerEffect / 10)
                {
                    Character senderCharacter = sender is ClientSession senderSession
                                ? senderSession.Character : sender as Character;

                    if (senderCharacter != null)
                    {
                        if (session is Character character)
                        {
                            double percentage = (character.Hp * 100) / character.HPMax;

                            if (percentage < 35)
                            {
                                character.AddBuff(new Buff(274, senderCharacter.Level, senderCharacter));
                            }
                            else if (percentage < 67)
                            {
                                character.AddBuff(new Buff(273, senderCharacter.Level, senderCharacter));
                            }
                            else
                            {
                                character.AddBuff(new Buff(272, senderCharacter.Level, senderCharacter));
                            }
                        }
                    }
                }
            }
            break;

            case BCardType.CardType.FourthGlacernonFamilyRaid:
                break;

            case BCardType.CardType.SummonedMonsterAttack:
                break;

            case BCardType.CardType.BearSpirit:
            {
                if (session is Character character)
                {
                    if (SubType == (byte)AdditionalTypes.BearSpirit.IncreaseMaximumHP / 10)
                    {
                        character.HPLoad();
                        character.Session?.SendPacket(character.GenerateStat());
                    }
                    else if (SubType == (byte)AdditionalTypes.BearSpirit.IncreaseMaximumMP / 10)
                    {
                        character.MPLoad();
                        character.Session?.SendPacket(character.GenerateStat());
                    }
                }
            }
            break;

            case BCardType.CardType.SummonSkill:
                break;

            case BCardType.CardType.InflictSkill:
                break;

            case BCardType.CardType.HideBarrelSkill:
                break;

            case BCardType.CardType.FocusEnemyAttentionSkill:
                break;

            case BCardType.CardType.TauntSkill:
                break;

            case BCardType.CardType.FireCannoneerRangeBuff:
                break;

            case BCardType.CardType.VulcanoElementBuff:
                break;

            case BCardType.CardType.DamageConvertingSkill:
                break;

            case BCardType.CardType.MeditationSkill:
            {
                if (session is Character character)
                {
                    if (SkillVNum.HasValue && SubType.Equals((byte)AdditionalTypes.MeditationSkill.CausingChance / 10) && ServerManager.RandomNumber() < FirstData)
                    {
                        Skill skill    = ServerManager.GetSkill(SkillVNum.Value);
                        Skill newSkill = ServerManager.GetSkill((short)SecondData);

                        Observable.Timer(TimeSpan.FromMilliseconds(100)).Subscribe(observer =>
                            {
                                foreach (QuicklistEntryDTO quicklistEntry in character.QuicklistEntries.Where(s => s.Pos.Equals(skill.CastId)))
                                {
                                    character.Session.SendPacket($"qset {quicklistEntry.Q1} {quicklistEntry.Q2} {quicklistEntry.Type}.{quicklistEntry.Slot}.{newSkill.CastId}.0");
                                }

                                character.Session.SendPacket($"mslot {newSkill.CastId} -1");
                            });

                        character.SkillComboCount++;
                        character.LastSkillComboUse = DateTime.Now;

                        if (skill.CastId > 10)
                        {
                            Observable.Timer(TimeSpan.FromMilliseconds((skill.GetCooldown(character) * 100) + 500)).Subscribe(observer => character.Session.SendPacket(StaticPacketHelper.SkillReset(skill.CastId)));
                        }
                    }

                    switch (SubType)
                    {
                    case 2:
                        character.MeditationDictionary[(short)SecondData] = DateTime.Now.AddSeconds(4);
                        break;

                    case 3:
                        character.MeditationDictionary[(short)SecondData] = DateTime.Now.AddSeconds(8);
                        break;

                    case 4:
                        character.MeditationDictionary[(short)SecondData] = DateTime.Now.AddSeconds(12);
                        break;
                    }
                }
            }
            break;

            case BCardType.CardType.FalconSkill:
                break;

            case BCardType.CardType.AbsorptionAndPowerSkill:
                break;

            case BCardType.CardType.LeonaPassiveSkill:
                break;

            case BCardType.CardType.FearSkill:
                break;

            case BCardType.CardType.SniperAttack:
                break;

            case BCardType.CardType.FrozenDebuff:
                break;

            case BCardType.CardType.JumpBackPush:
                break;

            case BCardType.CardType.FairyXPIncrease:
                break;

            case BCardType.CardType.SummonAndRecoverHP:
                break;

            case BCardType.CardType.TeamArenaBuff:
                break;

            case BCardType.CardType.ArenaCamera:
                break;

            case BCardType.CardType.DarkCloneSummon:
                break;

            case BCardType.CardType.AbsorbedSpirit:
                break;

            case BCardType.CardType.AngerSkill:
                break;

            case BCardType.CardType.MeteoriteTeleport:
                break;

            case BCardType.CardType.StealBuff:
                break;

            case BCardType.CardType.Unknown:
                break;

            case BCardType.CardType.EffectSummon:
                break;

            default:
                Logger.Warn($"Card Type {Type} Not Found!");
                break;
            }
        }
Exemplo n.º 22
0
        public MapNpc(MapNpcDTO npc)
        {
            _random = new Random(npc.MapNpcId);

            // Replace by MAPPING
            MapId       = npc.MapId;
            MapX        = npc.MapX;
            MapY        = npc.MapY;
            Position    = npc.Position;
            NpcVNum     = npc.NpcVNum;
            IsSitting   = npc.IsSitting;
            IsMoving    = npc.IsMoving;
            Effect      = npc.Effect;
            EffectDelay = npc.EffectDelay;
            Dialog      = npc.Dialog;
            FirstX      = npc.MapX;
            FirstY      = npc.MapY;
            MapNpcId    = npc.MapNpcId;
            ////////////////////////

            Npc        = ServerManager.GetNpc(this.NpcVNum);
            LastEffect = LastMove = DateTime.Now;
            _movetime  = _random.Next(300, 3000);
            IEnumerable <RecipeDTO> recipe = DAOFactory.RecipeDAO.LoadByNpc(MapNpcId).ToList();

            if (recipe != null)
            {
                Recipes = new List <Recipe>();
                foreach (RecipeDTO rec in recipe)
                {
                    // Replace by MAPPING
                    Recipes.Add(new Recipe(rec.RecipeId)
                    {
                        ItemVNum = rec.ItemVNum, MapNpcId = rec.MapNpcId, RecipeId = rec.RecipeId, Amount = rec.Amount
                    });
                    ///////////////////
                }
            }

            IEnumerable <TeleporterDTO> teleporters = DAOFactory.TeleporterDAO.LoadFromNpc(MapNpcId).ToList();

            if (teleporters != null)
            {
                Teleporters = new List <TeleporterDTO>();
                foreach (TeleporterDTO teleporter in teleporters)
                {
                    // Replace by MAPPING
                    Teleporters.Add(new TeleporterDTO()
                    {
                        MapId = teleporter.MapId, Index = teleporter.Index, MapNpcId = teleporter.MapNpcId, MapX = teleporter.MapX, MapY = teleporter.MapY, TeleporterId = teleporter.TeleporterId
                    });
                    ///////////////////
                }
            }

            ShopDTO shop = DAOFactory.ShopDAO.LoadByNpc(MapNpcId);

            if (shop != null)
            {
                // Replace by MAPPING
                Shop = new Shop(shop.ShopId)
                {
                    Name = shop.Name, MapNpcId = MapNpcId, MenuType = shop.MenuType, ShopType = shop.ShopType
                };
                ///////////////////
            }
        }
Exemplo n.º 23
0
        public static void Initialize()
        {
            foreach (ItemDTO itemDTO in DAOFactory.ItemDAO.LoadAll())
            {
                Item ItemGO = null;

                switch (itemDTO.ItemType)
                {
                case (byte)Domain.ItemType.Ammo:
                    ItemGO = Mapper.DynamicMap <NoFunctionItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Armor:
                    ItemGO = Mapper.DynamicMap <WearableItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Box:
                    ItemGO = Mapper.DynamicMap <BoxItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Event:
                    ItemGO = Mapper.DynamicMap <MagicalItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Fashion:
                    ItemGO = Mapper.DynamicMap <WearableItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Food:
                    ItemGO = Mapper.DynamicMap <FoodItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Jewelery:
                    ItemGO = Mapper.DynamicMap <WearableItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Magical:
                    ItemGO = Mapper.DynamicMap <MagicalItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Main:
                    ItemGO = Mapper.DynamicMap <NoFunctionItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Map:
                    ItemGO = Mapper.DynamicMap <NoFunctionItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Part:
                    ItemGO = Mapper.DynamicMap <NoFunctionItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Potion:
                    ItemGO = Mapper.DynamicMap <PotionItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Production:
                    ItemGO = Mapper.DynamicMap <ProduceItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Quest1:
                    ItemGO = Mapper.DynamicMap <NoFunctionItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Quest2:
                    ItemGO = Mapper.DynamicMap <NoFunctionItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Sell:
                    ItemGO = Mapper.DynamicMap <NoFunctionItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Shell:
                    ItemGO = Mapper.DynamicMap <MagicalItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Snack:
                    ItemGO = Mapper.DynamicMap <SnackItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Special:
                    ItemGO = Mapper.DynamicMap <SpecialItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Specialist:
                    ItemGO = Mapper.DynamicMap <WearableItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Teacher:
                    ItemGO = Mapper.DynamicMap <TeacherItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Upgrade:
                    ItemGO = Mapper.DynamicMap <UpgradeItem>(itemDTO);
                    break;

                case (byte)Domain.ItemType.Weapon:
                    ItemGO = Mapper.DynamicMap <WearableItem>(itemDTO);
                    break;

                default:
                    ItemGO = Mapper.DynamicMap <NoFunctionItem>(itemDTO);
                    break;
                }
                _items.Add(ItemGO);
            }

            Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("ITEM_LOADED"), _items.Count()));

            foreach (NpcMonsterDTO npcmonsterDTO in DAOFactory.NpcMonsterDAO.LoadAll())
            {
                NpcMonster npcmonster = new NpcMonster()
                {
                    AttackClass          = npcmonsterDTO.AttackClass,
                    DistanceDefenceDodge = npcmonsterDTO.DistanceDefenceDodge,
                    Level            = npcmonsterDTO.Level,
                    LightResistance  = npcmonsterDTO.LightResistance,
                    NpcMonsterVNum   = npcmonsterDTO.NpcMonsterVNum,
                    AttackUpgrade    = npcmonsterDTO.AttackUpgrade,
                    DistanceDefence  = npcmonsterDTO.DistanceDefence,
                    WaterResistance  = npcmonsterDTO.WaterResistance,
                    MagicDefence     = npcmonsterDTO.MagicDefence,
                    ElementRate      = npcmonsterDTO.ElementRate,
                    CloseDefence     = npcmonsterDTO.CloseDefence,
                    Concentrate      = npcmonsterDTO.Concentrate,
                    CriticalLuckRate = npcmonsterDTO.CriticalLuckRate,
                    CriticalRate     = npcmonsterDTO.CriticalRate,
                    DamageMaximum    = npcmonsterDTO.DamageMaximum,
                    DamageMinimum    = npcmonsterDTO.DamageMinimum,
                    DarkResistance   = npcmonsterDTO.DarkResistance,
                    DefenceDodge     = npcmonsterDTO.DefenceDodge,
                    DefenceUpgrade   = npcmonsterDTO.DefenceUpgrade,
                    Speed            = npcmonsterDTO.Speed,
                    FireResistance   = npcmonsterDTO.FireResistance,
                    Element          = npcmonsterDTO.Element,
                    Name             = npcmonsterDTO.Name
                };
                _npcs.Add(npcmonster);
            }
            Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("NPCMONSTERS_LOADED"), _npcs.Count()));
            try
            {
                int i            = 0;
                int npccount     = 0;
                int shopcount    = 0;
                int monstercount = 0;
                foreach (MapDTO map in DAOFactory.MapDAO.LoadAll())
                {
                    Guid guid   = Guid.NewGuid();
                    Map  newMap = new Map(Convert.ToInt16(map.MapId), guid, map.Data);
                    newMap.Music = map.Music;
                    //register for broadcast
                    _maps.TryAdd(guid, newMap);
                    i++;
                    npccount += newMap.Npcs.Count();
                    Monsters  = new List <MapMonster>();
                    foreach (MapMonster n in newMap.Monsters)
                    {
                        Monsters.Add(n);
                    }
                    monstercount += newMap.Monsters.Count();
                    foreach (MapNpc n in newMap.Npcs.Where(n => n.Shop != null))
                    {
                        shopcount++;
                    }
                }
                if (i != 0)
                {
                    Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("MAP_LOADED"), i));
                }
                else
                {
                    Logger.Log.Error(Language.Instance.GetMessageFromKey("NO_MAP"));
                }

                Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("MONSTERS_LOADED"), monstercount));
                Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("NPCS_LOADED"), npccount));
                Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("SHOPS_LOADED"), shopcount));
            }
            catch (Exception ex)
            {
                Logger.Log.Error(ex.Message);
            }
        }
Exemplo n.º 24
0
        internal int SummonMonster(MonsterToSummon summon)
        {
            NpcMonster npcMonster = ServerManager.GetNpcMonster(summon.VNum);

            if (npcMonster != null)
            {
                short mapX = summon.SpawnCell.X;
                short mapY = summon.SpawnCell.Y;

                if (mapX == 0 && mapY == 0)
                {
                    MapCell cell = Map.GetRandomPosition();

                    if (cell != null)
                    {
                        mapX = cell.X;
                        mapY = cell.Y;
                    }
                }

                MapMonster mapMonster = new MapMonster
                {
                    MonsterVNum      = npcMonster.NpcMonsterVNum,
                    MapX             = mapX,
                    MapY             = mapY,
                    Position         = 2,
                    MapId            = Map.MapId,
                    IsMoving         = summon.IsMoving,
                    MapMonsterId     = GetNextMonsterId(),
                    ShouldRespawn    = false,
                    OnNoticeEvents   = summon.NoticingEvents,
                    UseSkillOnDamage = summon.UseSkillOnDamage,
                    OnSpawnEvents    = summon.SpawnEvents,
                    IsTarget         = summon.IsTarget,
                    Target           = summon.Target,
                    IsBonus          = summon.IsBonus,
                    IsBoss           = summon.IsBoss,
                    NoticeRange      = summon.NoticeRange,
                    Owner            = summon.Owner,
                    AliveTime        = summon.AliveTime,
                    AliveTimeMp      = summon.AliveTimeMp,
                    BaseMaxHp        = summon.MaxHp,
                    BaseMaxMp        = summon.MaxMp
                };

                if (summon.HasDelay > 0)
                {
                    AddDelayedMonster(mapMonster);
                }

                Observable.Timer(TimeSpan.FromSeconds(summon.HasDelay))
                .Subscribe(o =>
                {
                    mapMonster.Initialize(this);
                    mapMonster.BattleEntity.OnDeathEvents.AddRange(summon.DeathEvents);
                    mapMonster.IsHostile = summon.IsHostile;

                    AddMonster(mapMonster);
                    Broadcast(mapMonster.GenerateIn());
                    RemoveDelayedMonster(mapMonster);

                    if (summon.AfterSpawnEvents.Any())
                    {
                        summon.AfterSpawnEvents.ForEach(e => EventHelper.Instance.RunEvent(e, monster: mapMonster));
                    }

                    if (summon.IsMeteorite)
                    {
                        OnMeteoriteEvents(summon, mapMonster);
                    }
                });

                return(mapMonster.MapMonsterId);
            }

            return(default);
Exemplo n.º 25
0
        public void ApplyBCards(object session, object sender = null, short buffLevel = 0)
        {
            Type type = session.GetType();

            // int counterBuff = 0;

            switch ((BCardType.CardType)Type)
            {
            case BCardType.CardType.Buff:
            {
                if (type == typeof(Character) && session is Character character)
                {
                    Buff buff = null;
                    if (sender != null)
                    {
                        Type sType = sender.GetType();
                        if (sType == typeof(Character) && sender is Character sendingCharacter)
                        {
                            buff = new Buff((short)((short)SecondData + buffLevel), sendingCharacter.Level);

                            //Todo: Get anti stats from BCard
                        }
                    }
                    else
                    {
                        buff = new Buff((short)((short)SecondData + buffLevel), character.Level);
                    }

                    int anti = 0;
                    if (buff?.Card.BuffType == BuffType.Bad)
                    {
                        anti += character.ShellEffectArmor?.FirstOrDefault(s =>
                                                                           s.Effect == (byte)ShellArmorEffectType.ReducedAllNegativeEffect)?.Value ??
                                0;
                        switch (SecondData)
                        {
                        case 1:
                            anti += character.ShellEffectArmor?.FirstOrDefault(s =>
                                                                               s.Effect == (byte)ShellArmorEffectType
                                                                               .ReducedBleedingAndMinorBleeding)
                                    ?.Value ?? 0;
                            anti += character.ShellEffectArmor?.FirstOrDefault(s =>
                                                                               s.Effect == (byte)ShellArmorEffectType.ReducedAllBleedingType)
                                    ?.Value ?? 0;
                            break;

                        case 7:
                            anti += character.ShellEffectArmor
                                    ?.FirstOrDefault(s =>
                                                     s.Effect == (byte)ShellArmorEffectType.ReducedStun)?.Value ?? 0;
                            anti += character.ShellEffectArmor?.FirstOrDefault(s =>
                                                                               s.Effect == (byte)ShellArmorEffectType.ReducedAllStun)?.Value ?? 0;
                            break;

                        case 21:
                            anti += character.ShellEffectArmor?.FirstOrDefault(s =>
                                                                               s.Effect == (byte)ShellArmorEffectType.ReducedMinorBleeding)?.Value ??
                                    0;
                            anti += character.ShellEffectArmor?.FirstOrDefault(s =>
                                                                               s.Effect == (byte)ShellArmorEffectType
                                                                               .ReducedBleedingAndMinorBleeding)
                                    ?.Value ?? 0;
                            anti += character.ShellEffectArmor?.FirstOrDefault(s =>
                                                                               s.Effect == (byte)ShellArmorEffectType.ReducedAllBleedingType)
                                    ?.Value ?? 0;
                            break;

                        case 27:
                            anti += character.ShellEffectArmor?.FirstOrDefault(s =>
                                                                               s.Effect == (byte)ShellArmorEffectType.ReducedFreeze)?.Value ?? 0;
                            break;

                        case 42:
                            anti += character.ShellEffectArmor?.FirstOrDefault(s =>
                                                                               s.Effect == (byte)ShellArmorEffectType.ReducedAllBleedingType)
                                    ?.Value ?? 0;
                            break;

                        case 66:
                            anti += character.ShellEffectArmor?.FirstOrDefault(s =>
                                                                               s.Effect == (byte)ShellArmorEffectType.ReducedAllStun)?.Value ?? 0;
                            break;
                        }
                    }

                    if (ServerManager.RandomNumber() < FirstData / 100D * (100 - anti))
                    {
                        character.AddBuff(buff);
                    }
                }
                else if (type == typeof(MapMonster))
                {
                    if (ServerManager.RandomNumber() < FirstData && session is MapMonster mapMonster)
                    {
                        mapMonster.AddBuff(new Buff((short)((short)SecondData + buffLevel), mapMonster.Monster.Level));
                    }
                }
                else if (type == typeof(MapNpc))
                {
                }
                else if (type == typeof(Mate))
                {
                }
            }
            break;

            case BCardType.CardType.Move:
            {
                if (type == typeof(Character) && session is Character character)
                {
                    character.LastSpeedChange = DateTime.UtcNow;
                    character.Session.SendPacket(character.GenerateCond());
                }
            }
            break;

            case BCardType.CardType.Summons:
            {
                if (type == typeof(Character))
                {
                    // jajamaru spawn
                    if (session is Character character && character.MapInstance != null)
                    {
                        List <MonsterToSummon> summonParameters = new List <MonsterToSummon>();
                        for (int i = 0; i < FirstData; i++)
                        {
                            short x, y;
                            byte  t = 0;
                            do
                            {
                                x = (short)(ServerManager.RandomNumber(-3, 3) + character.PositionX);
                                y = (short)(ServerManager.RandomNumber(-3, 3) + character.PositionY);
                                t++;
                            } while (!character.MapInstance.Map.IsBlockedZone(x, y) && t < byte.MaxValue);
                            summonParameters.Add(new MonsterToSummon((short)SecondData, new MapCell {
                                    X = x, Y = y
                                },
                                                                     -1, true));
                        }

                        if (ServerManager.RandomNumber() <= Math.Abs(ThirdData) || ThirdData == 0)
                        {
                            switch (SubType)
                            {
                            case 2:
                                EventHelper.Instance.RunEvent(new EventContainer(
                                                                  character.Session.CurrentMapInstance, EventActionType.SpawnMonsters,
                                                                  summonParameters));
                                break;
                            }
                        }
                    }
                }
                else if (type == typeof(MapMonster))
                {
                    if (session is MapMonster mapMonster && mapMonster.MapInstance != null)
                    {
                        List <MonsterToSummon> summonParameters = new List <MonsterToSummon>();
                        for (int i = 0; i < FirstData; i++)
                        {
                            short x, y;
                            byte  t = 0;
                            do
                            {
                                x = (short)(ServerManager.RandomNumber(-3, 3) + mapMonster.MapX);
                                y = (short)(ServerManager.RandomNumber(-3, 3) + mapMonster.MapY);
                                t++;
                            } while (!mapMonster.MapInstance.Map.IsBlockedZone(x, y) && t < byte.MaxValue);
                            summonParameters.Add(new MonsterToSummon((short)SecondData, new MapCell {
                                    X = x, Y = y
                                },
                                                                     -1, true));
                        }

                        if (ServerManager.RandomNumber() <= Math.Abs(ThirdData) || ThirdData == 0)
                        {
                            switch (SubType)
                            {
                            case 2:
                                EventHelper.Instance.RunEvent(new EventContainer(mapMonster.MapInstance,
                                                                                 EventActionType.SpawnMonsters, summonParameters));
                                break;

                            default:
                                if (mapMonster.OnDeathEvents.All(s =>
                                                                 s.EventActionType != EventActionType.SpawnMonsters))
                                {
                                    mapMonster.OnDeathEvents.Add(new EventContainer(mapMonster.MapInstance,
                                                                                    EventActionType.SpawnMonsters, summonParameters));
                                }

                                break;
                            }
                        }
                    }
                }
                else if (type == typeof(MapNpc))
                {
                }
                else if (type == typeof(Mate))
                {
                }
            }
            break;

            case BCardType.CardType.SpecialAttack:
                break;

            case BCardType.CardType.SpecialDefence:
                break;

            case BCardType.CardType.AttackPower:
                break;

            case BCardType.CardType.Target:
                break;

            case BCardType.CardType.Critical:
                break;

            case BCardType.CardType.SpecialCritical:
                break;

            case BCardType.CardType.Element:
                break;

            case BCardType.CardType.IncreaseDamage:
                break;

            case BCardType.CardType.Defence:
                break;

            case BCardType.CardType.DodgeAndDefencePercent:
                break;

            case BCardType.CardType.Block:
                break;

            case BCardType.CardType.Absorption:
                break;

            case BCardType.CardType.ElementResistance:
                break;

            case BCardType.CardType.EnemyElementResistance:
                break;

            case BCardType.CardType.Damage:
                break;

            case BCardType.CardType.GuarantedDodgeRangedAttack:
                break;

            case BCardType.CardType.Morale:
                break;

            case BCardType.CardType.Casting:
                break;

            case BCardType.CardType.Reflection:
                break;

            case BCardType.CardType.DrainAndSteal:
                break;

            case BCardType.CardType.HealingBurningAndCasting:
            {
                if (type == typeof(Character))
                {
                    if (session is Character character && character.Hp > 0)
                    {
                        int bonus;
                        if (SubType == (byte)AdditionalTypes.HealingBurningAndCasting.RestoreHP / 10)
                        {
                            if (IsLevelScaled)
                            {
                                bonus = character.Level * FirstData;
                            }
                            else
                            {
                                bonus = FirstData;
                            }

                            if (character.Hp + bonus <= character.HPLoad())
                            {
                                character.Hp += bonus;
                            }
                            else
                            {
                                bonus        = (int)character.HPLoad() - character.Hp;
                                character.Hp = (int)character.HPLoad();
                            }

                            character.Session.CurrentMapInstance?.Broadcast(character.Session,
                                                                            character.GenerateRc(bonus));
                        }

                        if (SubType == (byte)AdditionalTypes.HealingBurningAndCasting.RestoreMP / 10)
                        {
                            if (IsLevelScaled)
                            {
                                bonus = character.Level * FirstData;
                            }
                            else
                            {
                                bonus = FirstData;
                            }

                            if (character.Mp + bonus <= character.MPLoad())
                            {
                                character.Mp += bonus;
                            }
                            else
                            {
                                character.Mp = (int)character.MPLoad();
                            }
                        }

                        character.Session.SendPacket(character.GenerateStat());
                    }
                }
                else if (type == typeof(MapMonster))
                {
                    if (ServerManager.RandomNumber() < FirstData && session is MapMonster mapMonster)
                    {
                        mapMonster.AddBuff(new Buff((short)SecondData, mapMonster.Monster.Level));
                    }
                }
                else if (type == typeof(MapNpc))
                {
                }
                else if (type == typeof(Mate))
                {
                }
            }
            break;

            case BCardType.CardType.Hpmp:
                if (type == typeof(Character))
                {
                    if (session is Character c)
                    {
                        switch (SubType)
                        {
                        case (byte)AdditionalTypes.Hpmp.RestoreDecreasedMP / 10:
                        {
                            int bonus = (int)(FirstData * c.MPLoad() / 100);

                            c.Mp = c.Mp + bonus > 1 ? c.Mp + bonus : c.Mp = 1;
                        }
                        break;
                        }
                    }
                }

                break;

            case BCardType.CardType.SpecialisationBuffResistance:
            {
                switch (SubType)
                {
                case (byte)AdditionalTypes.SpecialisationBuffResistance.RemoveBadEffects / 10:
                {
                    if (session is Character c &&              /*&& sender is ClientSession senderSession*/
                        ServerManager.RandomNumber() < Math.Abs(FirstData))
                    {
                        c.DisableBuffs(FirstData > 0 ? BuffType.Good : BuffType.Bad, SecondData);
                    }
                }
                break;
                }
            }
            break;

            case BCardType.CardType.SpecialEffects:
                break;

            case BCardType.CardType.Capture:
            {
                if (type == typeof(MapMonster) && session is MapMonster mapMonster &&
                    sender is ClientSession senderSession)
                {
                    NpcMonster mateNpc = ServerManager.GetNpcMonster(mapMonster.MonsterVNum);
                    if (mateNpc != null)
                    {
                        if (mapMonster.Monster.Catch)
                        {
                            if (mapMonster.IsAlive &&
                                mapMonster.CurrentHp <= (int)((double)mapMonster.MaxHp / 2))
                            {
                                if (mapMonster.Monster.Level < senderSession.Character.Level)
                                {
                                    // TODO: find a new algorithm
                                    int[] chance = { 100, 80, 60, 40, 20, 0 };
                                    if (ServerManager.RandomNumber() < chance[ServerManager.RandomNumber(0, 5)])
                                    {
                                        Mate mate = new Mate(senderSession.Character, mateNpc,
                                                             (byte)(mapMonster.Monster.Level - 15 > 0
                                                        ? mapMonster.Monster.Level - 15
                                                        : 1), MateType.Pet);
                                        if (senderSession.Character.CanAddMate(mate))
                                        {
                                            senderSession.Character.AddPetWithSkill(mate);
                                            senderSession.SendPacket(
                                                UserInterfaceHelper.GenerateMsg(
                                                    Language.Instance.GetMessageFromKey("CATCH_SUCCESS"), 0));
                                            senderSession.CurrentMapInstance?.Broadcast(
                                                StaticPacketHelper.GenerateEff(UserType.Player,
                                                                               senderSession.Character.CharacterId, 197));
                                            senderSession.CurrentMapInstance?.Broadcast(
                                                StaticPacketHelper.SkillUsed(UserType.Player,
                                                                             senderSession.Character.CharacterId, 3,
                                                                             mapMonster.MapMonsterId, -1, 0, 15, -1, -1, -1, true,
                                                                             (int)(mapMonster.CurrentHp / (float)mapMonster.MaxHp * 100
                                                                                   ), 0, -1, 0));
                                            mapMonster.SetDeathStatement();
                                            senderSession.CurrentMapInstance?.Broadcast(
                                                StaticPacketHelper.Out(UserType.Monster,
                                                                       mapMonster.MapMonsterId));
                                        }
                                        else
                                        {
                                            senderSession.SendPacket(
                                                senderSession.Character.GenerateSay(
                                                    Language.Instance.GetMessageFromKey("PET_SLOT_FULL"), 10));
                                            senderSession.SendPacket(
                                                StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId));
                                        }
                                    }
                                    else
                                    {
                                        senderSession.SendPacket(
                                            UserInterfaceHelper.GenerateMsg(
                                                Language.Instance.GetMessageFromKey("CATCH_FAIL"), 0));
                                        senderSession.CurrentMapInstance?.Broadcast(
                                            StaticPacketHelper.SkillUsed(UserType.Player,
                                                                         senderSession.Character.CharacterId, 3, mapMonster.MapMonsterId,
                                                                         -1, 0, 15, -1, -1, -1, true,
                                                                         (int)(mapMonster.CurrentHp / (float)mapMonster.MaxHp * 100),
                                                                         0, -1, 0));
                                    }
                                }
                                else
                                {
                                    senderSession.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                                 Language.Instance.GetMessageFromKey("LEVEL_LOWER_THAN_MONSTER"), 0));
                                    senderSession.SendPacket(
                                        StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId));
                                }
                            }
                            else
                            {
                                senderSession.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                             Language.Instance.GetMessageFromKey("CURRENT_HP_TOO_HIGH"), 0));
                                senderSession.SendPacket(StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId));
                            }
                        }
                        else
                        {
                            senderSession.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                         Language.Instance.GetMessageFromKey("MONSTER_CANT_BE_CAPTURED"), 0));
                            senderSession.SendPacket(StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId));
                        }
                    }
                }
            }
            break;

            case BCardType.CardType.SpecialDamageAndExplosions:
                break;

            case BCardType.CardType.SpecialEffects2:
                if (type == typeof(Character))
                {
                    if (session is Character c)
                    {
                        short destinationX = c.PositionX;
                        short destinationY = c.PositionY;
                        switch (SubType)
                        {
                        case (byte)AdditionalTypes.SpecialEffects2.TeleportInRadius / 10:
                        {
                            switch (c.Direction)
                            {
                            case 0:
                                // -y
                                destinationY -= (short)FirstData;
                                break;

                            case 1:
                                // +x
                                destinationX += (short)FirstData;
                                break;

                            case 2:
                                // +y
                                destinationY += (short)FirstData;
                                break;

                            case 3:
                                // -x
                                destinationX -= (short)FirstData;
                                break;

                            case 4:
                                // -x -y
                                destinationX -= (short)FirstData;
                                destinationY -= (short)FirstData;
                                break;

                            case 5:
                                // +x +y
                                destinationX += (short)FirstData;
                                destinationY += (short)FirstData;
                                break;

                            case 6:
                                // +x -y
                                destinationX += (short)FirstData;
                                destinationY -= (short)FirstData;
                                break;

                            case 7:
                                // -x +y
                                destinationX -= (short)FirstData;
                                destinationY += (short)FirstData;
                                break;
                            }

                            ServerManager.Instance.TeleportForward(c.Session, c.MapInstanceId, destinationX,
                                                                   destinationY);
                        }
                        break;
                        }
                    }
                }

                break;

            case BCardType.CardType.CalculatingLevel:
                break;

            case BCardType.CardType.Recovery:
                break;

            case BCardType.CardType.MaxHpmp:
                break;

            case BCardType.CardType.MultAttack:
                break;

            case BCardType.CardType.MultDefence:
                break;

            case BCardType.CardType.TimeCircleSkills:
                break;

            case BCardType.CardType.RecoveryAndDamagePercent:
                break;

            case BCardType.CardType.Count:
                break;

            case BCardType.CardType.NoDefeatAndNoDamage:
                break;

            case BCardType.CardType.SpecialActions:
            {
                switch (SubType)
                {
                case (byte)AdditionalTypes.SpecialActions.RunAway / 10:
                    if (session is MapMonster m)
                    {
                        m.MapInstance.Broadcast(StaticPacketHelper.Say(UserType.Monster, m.MapMonsterId, 0, "!!!"));
                        m.RemoveTarget();
                        for (int i = 0; i < 10; i++)
                        {
                            Observable.Timer(TimeSpan.FromSeconds(i)).Subscribe(o =>
                                {
                                    m.MapX++;
                                    m.MapY++;
                                    m.IgnoreTargetsUntil = DateTime.UtcNow.AddSeconds(10);
                                    m.RemoveTarget();
                                });
                        }
                    }
                    break;
                }
            }
            break;

            case BCardType.CardType.Mode:
                break;

            case BCardType.CardType.NoCharacteristicValue:
                break;

            case BCardType.CardType.LightAndShadow:
            {
                switch (SubType)
                {
                case (byte)AdditionalTypes.LightAndShadow.RemoveBadEffects / 10:
                {
                    if (session is Character c /*&& sender is ClientSession senderSession*/)
                    {
                        c.DisableBuffs(BuffType.Bad, FirstData);
                    }
                }
                break;
                }
            }
            break;

            case BCardType.CardType.Item:
                break;

            case BCardType.CardType.DebuffResistance:
                break;

            case BCardType.CardType.SpecialBehaviour:
                break;

            case BCardType.CardType.Quest:
                break;

            case BCardType.CardType.SecondSpCard:
                break;

            case BCardType.CardType.SpCardUpgrade:
                break;

            case BCardType.CardType.HugeSnowman:
                break;

            case BCardType.CardType.Drain:
                break;

            case BCardType.CardType.BossMonstersSkill:
                break;

            case BCardType.CardType.LordHatus:
                break;

            case BCardType.CardType.LordCalvinas:
                break;

            case BCardType.CardType.SeSpecialist:
                break;

            case BCardType.CardType.FourthGlacernonFamilyRaid:
                break;

            case BCardType.CardType.SummonedMonsterAttack:
                break;

            case BCardType.CardType.BearSpirit:
                break;

            case BCardType.CardType.SummonSkill:
                break;

            case BCardType.CardType.InflictSkill:
                break;

            case BCardType.CardType.HideBarrelSkill:
                break;

            case BCardType.CardType.FocusEnemyAttentionSkill:
                break;

            case BCardType.CardType.TauntSkill:
                break;

            case BCardType.CardType.FireCannoneerRangeBuff:
                break;

            case BCardType.CardType.VulcanoElementBuff:
                break;

            case BCardType.CardType.DamageConvertingSkill:
                break;

            case BCardType.CardType.MeditationSkill:
            {
                if (type == typeof(Character) && session is Character character)
                {
                    if (SkillVNum.HasValue &&
                        SubType.Equals((byte)AdditionalTypes.MeditationSkill.CausingChance / 10) &&
                        ServerManager.RandomNumber() < FirstData)
                    {
                        Skill skill    = ServerManager.GetSkill(SkillVNum.Value);
                        Skill newSkill = ServerManager.GetSkill((short)SecondData);
                        Observable.Timer(TimeSpan.FromMilliseconds(100)).Subscribe(observer =>
                            {
                                foreach (QuicklistEntryDTO quicklistEntry in character.QuicklistEntries.Where(s =>
                                                                                                              s.Morph == character.Morph && s.Pos.Equals(skill.CastId)))
                                {
                                    character.Session.SendPacket(
                                        $"qset {quicklistEntry.Q1} {quicklistEntry.Q2} {quicklistEntry.Type}.{quicklistEntry.Slot}.{newSkill.CastId}.0");
                                }

                                character.Session.SendPacket($"mslot {newSkill.CastId} -1");
                            });
                        character.SkillComboCount++;
                        character.LastSkillComboUse = DateTime.UtcNow;
                        if (skill.CastId > 10)
                        {
                            // HACK this way
                            Observable.Timer(TimeSpan.FromMilliseconds((skill.Cooldown * 100) + 500))
                            .Subscribe(observer =>
                                       character.Session.SendPacket(StaticPacketHelper.SkillReset(skill.CastId)));
                        }
                    }

                    switch (SubType)
                    {
                    case 2:
                        character.MeditationDictionary[(short)SecondData] = DateTime.UtcNow.AddSeconds(4);
                        break;

                    case 3:
                        character.MeditationDictionary[(short)SecondData] = DateTime.UtcNow.AddSeconds(8);
                        break;

                    case 4:
                        character.MeditationDictionary[(short)SecondData] = DateTime.UtcNow.AddSeconds(12);
                        break;
                    }
                }
            }
            break;

            case BCardType.CardType.FalconSkill:
            {
                if (session is Character c)
                {
                    switch (SubType)
                    {
                    case (byte)AdditionalTypes.FalconSkill.Hide:
                        c.Invisible = true;
                        c.Mates.Where(s => s.IsTeamMember).ToList().ForEach(s =>
                                                                            c.Session.CurrentMapInstance?.Broadcast(s.GenerateOut()));
                        c.Session.CurrentMapInstance?.Broadcast(c.GenerateInvisible());
                        c.Session.SendPacket(c.GenerateEq());
                        break;
                    }
                }
            }
            break;

            case BCardType.CardType.AbsorptionAndPowerSkill:
                break;

            case BCardType.CardType.LeonaPassiveSkill:
                break;

            case BCardType.CardType.FearSkill:
                break;

            case BCardType.CardType.SniperAttack:
                break;

            case BCardType.CardType.FrozenDebuff:
                break;

            case BCardType.CardType.JumpBackPush:
                break;

            case BCardType.CardType.FairyXPIncrease:
                break;

            case BCardType.CardType.SummonAndRecoverHP:
                break;

            case BCardType.CardType.TeamArenaBuff:
                break;

            case BCardType.CardType.ArenaCamera:
                break;

            case BCardType.CardType.DarkCloneSummon:
                break;

            case BCardType.CardType.AbsorbedSpirit:
                break;

            case BCardType.CardType.AngerSkill:
                break;

            case BCardType.CardType.MeteoriteTeleport:
                if (type == typeof(Character))
                {
                    if (session is Character character)
                    {
                        switch (SubType)
                        {
                        case ((byte)AdditionalTypes.MeteoriteTeleport.TeleportYouAndGroupToSavedLocation / 10):
                            if (character.TeleportSet == false)
                            {
                                character.TeleportX   = character.PositionX;
                                character.TeleportY   = character.PositionY;
                                character.TeleportMap = character.MapId;
                                character.MapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, character.CharacterId, 4497));
                                character.TeleportSet = true;
                                Observable.Timer(TimeSpan.FromSeconds(40)).Subscribe(o => character.TeleportSet = false);
                            }
                            else
                            {
                                if (character.MapInstance.IsPvp)
                                {
                                    if (character.MapInstance.MapInstanceType != MapInstanceType.BaseMapInstance)
                                    {
                                        character.TeleportSet = false;
                                        return;
                                    }

                                    character.MapInstance.Broadcast($"tp 1 {character.CharacterId} {character.TeleportX} {character.TeleportY} 0");
                                    character.PositionX   = character.TeleportX;
                                    character.PositionY   = character.TeleportY;
                                    character.TeleportSet = false;
                                }
                                else
                                {
                                    if (character.MapId == character.TeleportMap)
                                    {
                                        if (character.MapInstance.MapInstanceType == MapInstanceType.CaligorInstance)
                                        {
                                            character.TeleportSet = false;
                                            return;
                                        }
                                        character.MapInstance.Broadcast($"tp 1 {character.CharacterId} {character.TeleportX} {character.TeleportY} 0");
                                        character.PositionX   = character.TeleportX;
                                        character.PositionY   = character.TeleportY;
                                        character.TeleportSet = false;
                                    }
                                    else
                                    {
                                        character.TeleportSet = false;
                                    }
                                }
                            }
                            break;

                        case (byte)AdditionalTypes.MeteoriteTeleport.CauseMeteoriteFall / 10:
                        {
                            int amount = 10 + (character.Level / FirstData);

                            for (int i = 0; i < amount; i++)
                            {
                                Observable.Timer(TimeSpan.FromMilliseconds(i * 500)).Subscribe(o => character.SpawnMeteorite());
                            }
                        }
                        break;
                        }
                    }
                }
                break;

            case BCardType.CardType.StealBuff:
                break;

            case BCardType.CardType.Unknown:
                break;

            case BCardType.CardType.EffectSummon:
                break;

            default:
                Logger.Warn($"Card Type {Type} not defined!");
                break;
            }
        }