Exemplo n.º 1
0
        /// <summary>
        /// Create a new item.
        /// </summary>
        /// <param name="player">Player entity</param>
        /// <param name="e"></param>
        private void CreateItem(IPlayerEntity player, InventoryCreateItemEventArgs e)
        {
            ItemData itemData = e.ItemData;

            if (itemData.IsStackable)
            {
                // TODO: stackable items
            }
            else
            {
                for (var i = 0; i < e.Quantity; i++)
                {
                    int availableSlot = player.Inventory.GetAvailableSlot();

                    if (availableSlot < 0)
                    {
                        WorldPacketFactory.SendDefinedText(player, DefineText.TID_GAME_LACKSPACE);
                        break;
                    }

                    Logger.Debug("Available slot: {0}", availableSlot);

                    var newItem = new Item(e.ItemId, 1, e.CreatorId)
                    {
                        Slot     = availableSlot,
                        UniqueId = availableSlot,
                    };

                    player.Inventory.Items[availableSlot] = newItem;
                    WorldPacketFactory.SendItemCreation(player, newItem);
                }
            }
        }
Exemplo n.º 2
0
        public static GInfoPacket GenerateGInfoPacket(this IPlayerEntity player)
        {
            if (!player.HasFamily)
            {
                return(null);
            }

            return(new GInfoPacket
            {
                FamilyName = player.Family.Name,
                CharacterName = player.Character.Name,
                FamilyLevel = player.Family.FamilyLevel,
                FamilyManagerAuthorityType = player.Family.ManagerAuthorityType,
                FamilyMemberAuthorityType = player.Family.MemberAuthorityType,
                CharacterFamilyAuthority = player.FamilyCharacter.Authority,
                FamilyHeadGenderType = player.Character.Gender,
                FamilyManagerCanGetHistory = player.Family.ManagerCanGetHistory,
                FamilyManagerCanInvit = player.Family.ManagerCanInvite,
                FamilyManagerCanShout = player.Family.ManagerCanShout,
                FamilyManagerCanNotice = player.Family.ManagerCanNotice,
                FamilyMemberCanGetHistory = player.Family.MemberCanGetHistory,
                FamilyMessage = "",
                FamilyXp = player.Family.FamilyExperience,
                MaxFamilyXp = 100000, // todo algorithm
                MembersCapacity = 50, // todo level capacity
                MembersCount = 1      // todo
            });
        }
Exemplo n.º 3
0
 public void Broadcast <T>(IPlayerEntity sender, T packet) where T : IPacket
 {
     foreach (IPlayerEntity session in PlayersBySessionId.Values)
     {
         session.SendPacket(packet);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Decreases an item from player's inventory.
        /// </summary>
        /// <param name="player">Player.</param>
        /// <param name="item">Item to decrease.</param>
        private void DecreaseItem(IPlayerEntity player, Item item, bool noFollowSfx = false)
        {
            var itemUpdateType = UpdateItemType.UI_NUM;

            if (player.Inventory.ItemHasCoolTime(item))
            {
                itemUpdateType = UpdateItemType.UI_COOLTIME;
                player.Inventory.SetCoolTime(item, item.Data.CoolTime);
            }

            if (!item.Data.IsPermanant)
            {
                item.Quantity--;
            }

            _inventoryPacketFactory.SendItemUpdate(player, itemUpdateType, item.UniqueId, item.Quantity);

            if (item.Data.SfxObject3 != 0)
            {
                _specialEffectSystem.StartSpecialEffect(player, (DefineSpecialEffects)item.Data.SfxObject3, noFollowSfx);
            }

            if (item.Quantity <= 0)
            {
                item.Reset();
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Gets the player's max origin HP.
 /// </summary>
 /// <param name="player">Player.</param>
 /// <returns>Max Origin HP.</returns>
 public static int GetMaxOriginHp(IPlayerEntity player)
 {
     return(HealthFormulas.GetMaxOriginHp(
                player.Object.Level,
                player.Attributes[DefineAttributes.STA],
                player.PlayerData.JobData.MaxHpFactor));
 }
Exemplo n.º 6
0
        private void EquipItem(IPlayerEntity player, Item item)
        {
            this.Logger.LogTrace($"{player.Object.Name} want to equip {item.Data.Name}.");

            if (!this._itemUsage.IsItemEquipable(player, item))
            {
                this.Logger.LogTrace($"{player.Object.Name} can not equip {item.Data.Name}.");
                return;
            }

            int  sourceSlot      = item.Slot;
            int  equipedItemSlot = item.Data.Parts + EquipOffset;
            Item equipedItem     = player.Inventory[equipedItemSlot];

            if (equipedItem != null && equipedItem.Slot != -1)
            {
                this.UnequipItem(player, equipedItem);
            }

            // Move item
            item.Slot = equipedItemSlot;
            player.Inventory.Items.Swap(sourceSlot, equipedItemSlot);

            WorldPacketFactory.SendItemEquip(player, item, item.Data.Parts, true);
        }
Exemplo n.º 7
0
        private void OnChangeFace(IPlayerEntity player, ChangeFaceEventArgs e)
        {
            var worldConfiguration = DependencyContainer.Instance.Resolve <WorldConfiguration>();

            if (!e.UseCoupon)
            {
                if (player.PlayerData.Gold < worldConfiguration.Customization.ChangeFaceCost)
                {
                    WorldPacketFactory.SendDefinedText(player, DefineText.TID_GAME_LACKMONEY);
                }
                else
                {
                    player.PlayerData.Gold        -= (int)worldConfiguration.Customization.ChangeFaceCost;
                    player.VisualAppearance.FaceId = (int)e.FaceId;

                    WorldPacketFactory.SendUpdateAttributes(player, DefineAttributes.GOLD, player.PlayerData.Gold);
                    WorldPacketFactory.SendChangeFace(player, e.FaceId);
                }
            }
            else
            {
                var couponItem = player.Inventory.GetItemById(DefineItem.II_SYS_SYS_SCR_FACEOFFFREE);
                if (couponItem == null)
                {
                    WorldPacketFactory.SendDefinedText(player, DefineText.TID_GAME_WARNNING_COUPON);
                    return;
                }

                player.Inventory.RemoveItems(couponItem.Data.Id);
                WorldPacketFactory.SendItemUpdate(player, UpdateItemType.UI_NUM, couponItem.UniqueId, couponItem.Quantity);
                WorldPacketFactory.SendChangeFace(player, e.FaceId);
            }
        }
        protected override async Task Handle(GroupInvitationSendEvent e, CancellationToken cancellation)
        {
            if (!(e.Sender is IPlayerEntity player))
            {
                return;
            }

            IPlayerEntity sender = _playerManager.GetPlayerByCharacterId(e.Sender.Id);
            IPlayerEntity target = _playerManager.GetPlayerByCharacterId(e.Target.Character.Id);

            if (target == null || sender == null)
            {
                return;
            }

            _groupManager.CreateInvitation(sender, target);

            await player.SendChatMessageAsync(PlayerMessages.GROUP_PLAYER_X_INVITED_TO_YOUR_GROUP, SayColorType.Yellow);

            PacketBase acceptPacket = new PJoinPacket {
                CharacterId = target.Id, RequestType = PJoinPacketType.Accepted
            };
            PacketBase refusePacket = new PJoinPacket {
                CharacterId = target.Id, RequestType = PJoinPacketType.Declined
            };
            string question = target.GetLanguageFormat(PlayerMessages.GROUP_PLAYER_X_INVITED_YOU_TO_JOIN_HIS_GROUP, sender.Character.Name);
            await target.SendDialog(acceptPacket, refusePacket, question);
        }
Exemplo n.º 9
0
        /// <inheritdoc />
        public void ChangeFace(IPlayerEntity player, uint objectId, uint faceId, bool useCoupon)
        {
            if (!useCoupon)
            {
                if (player.PlayerData.Gold < _worldServerConfiguration.Customization.ChangeFaceCost)
                {
                    _textPacketFactory.SendDefinedText(player, DefineText.TID_GAME_LACKMONEY);
                }
                else
                {
                    player.VisualAppearance.FaceId = (int)faceId;
                    _playerDataSystem.DecreaseGold(player, (int)_worldServerConfiguration.Customization.ChangeFaceCost);
                    _customizationPacketFactory.SendChangeFace(player, faceId);
                }
            }
            else
            {
                Item couponItem = player.Inventory.GetItemById(DefineItem.II_SYS_SYS_SCR_FACEOFFFREE);

                if (couponItem == null)
                {
                    _textPacketFactory.SendDefinedText(player, DefineText.TID_GAME_WARNNING_COUPON);
                    return;
                }

                _inventorySystem.DeleteItem(player, couponItem, 1);

                _customizationPacketFactory.SendChangeFace(player, faceId);
            }
        }
Exemplo n.º 10
0
        private void GetMailItem(IPlayerEntity player, QueryGetMailItemEventArgs e)
        {
            var database = DependencyContainer.Instance.Resolve <IDatabase>();
            var mail     = database.Mails.Get(x => x.Id == e.MailId && x.ReceiverId == player.PlayerData.Id);

            if (mail is null)
            {
                return;
            }

            if (mail.HasReceivedItem)
            {
                return;
            }

            if (!player.Inventory.HasAvailableSlots())
            {
                WorldPacketFactory.SendDefinedText(player, DefineText.TID_GAME_LACKSPACE);
                return;
            }

            mail.HasReceivedItem = true;
            int availableSlot = player.Inventory.GetAvailableSlot();

            player.Inventory.Items[availableSlot] = new Item(mail.Item);
            database.Complete();
            WorldPacketFactory.SendRemoveMail(player, mail, RemovedFromMail.Item);
        }
Exemplo n.º 11
0
        private void GetMailGold(IPlayerEntity player, QueryGetMailGoldEventArgs e)
        {
            var database = DependencyContainer.Instance.Resolve <IDatabase>();
            var mail     = database.Mails.Get(x => x.Id == e.MailId && x.ReceiverId == player.PlayerData.Id);

            if (mail is null)
            {
                return;
            }

            if (mail.HasReceivedGold)
            {
                return;
            }

            checked
            {
                try
                {
                    player.PlayerData.Gold += (int)mail.Gold;
                    mail.HasReceivedGold    = true;
                }
                catch (OverflowException)
                {
                    Logger.LogError($"{player.Object.Name} caused an OverflowException by taking {mail.Gold} out of mail {mail.Id}.");
                    return;
                }
            }
            database.Complete();
            WorldPacketFactory.SendUpdateAttributes(player, DefineAttributes.GOLD, player.PlayerData.Gold);
            WorldPacketFactory.SendRemoveMail(player, mail, RemovedFromMail.Gold);
        }
Exemplo n.º 12
0
        /// <inheritdoc />
        public void Execute(IPlayerEntity player, object[] parameters)
        {
            int destinationMapId    = player.Object.MapId;
            var destinationPosition = new Vector3();

            switch (parameters.Length)
            {
            case 2:
                destinationPosition.X = Convert.ToSingle(parameters[0]);
                destinationPosition.Z = Convert.ToSingle(parameters[1]);
                break;

            case 3:
                destinationMapId      = Convert.ToInt32(parameters[0]);
                destinationPosition.X = Convert.ToSingle(parameters[1]);
                destinationPosition.Z = Convert.ToSingle(parameters[2]);
                break;

            case 4:
                destinationMapId      = Convert.ToInt32(parameters[0]);
                destinationPosition.X = Convert.ToSingle(parameters[1]);
                destinationPosition.Y = Convert.ToSingle(parameters[2]);
                destinationPosition.Z = Convert.ToSingle(parameters[3]);
                break;

            default: throw new ArgumentException("Too many or not enough arguments.");
            }

            _teleportSystem.Teleport(player, destinationMapId, destinationPosition.X, destinationPosition.Y, destinationPosition.Z, player.Object.Angle);
        }
Exemplo n.º 13
0
        /// <inheritdoc />
        public void ChangeJob(IPlayerEntity player, DefineJob.Job newJob)
        {
            if (!_gameResources.Jobs.TryGetValue(newJob, out JobData jobData))
            {
                throw new KeyNotFoundException($"Cannot find job '{newJob}'.");
            }

            IEnumerable <SkillInfo> jobSkills = _skillSystem.GetSkillsByJob(newJob);

            var skillTree = new List <SkillInfo>();

            foreach (SkillInfo skill in jobSkills)
            {
                SkillInfo playerSkill = player.SkillTree.GetSkill(skill.SkillId);

                if (playerSkill != null)
                {
                    skillTree.Add(playerSkill);
                }
                else
                {
                    skillTree.Add(new SkillInfo(skill.SkillId, player.PlayerData.Id, skill.Data));
                }
            }

            player.PlayerData.JobData = jobData;
            player.SkillTree.Skills   = skillTree.ToList();

            _playerPacketFactory.SendPlayerJobUpdate(player);
            _specialEffectPacketFactory.SendSpecialEffect(player, DefineSpecialEffects.XI_GEN_LEVEL_UP01, false);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Initialize the player's inventory.
        /// </summary>
        /// <param name="player">Current player</param>
        /// <param name="e"></param>
        private void InitializeInventory(IPlayerEntity player, InventoryInitializeEventArgs e)
        {
            player.Inventory = new ItemContainerComponent(MaxItems, InventorySize);
            var inventory = player.Inventory;

            if (e.Items != null)
            {
                foreach (Database.Entities.DbItem item in e.Items)
                {
                    int uniqueId = inventory.Items[item.ItemSlot].UniqueId;

                    inventory.Items[item.ItemSlot] = new Item(item)
                    {
                        UniqueId = uniqueId,
                    };
                }
            }

            for (int i = EquipOffset; i < MaxItems; ++i)
            {
                if (inventory.Items[i].Id == -1)
                {
                    inventory.Items[i].UniqueId = -1;
                }
            }
        }
Exemplo n.º 15
0
        /// <inheritdoc />
        public void SellItem(IPlayerEntity player, int playerItemUniqueId, int quantity)
        {
            Item itemToSell = player.Inventory.GetItemAtIndex(playerItemUniqueId);

            if (itemToSell == null)
            {
                throw new ArgumentNullException(nameof(itemToSell), $"Cannot find item with unique id: '{playerItemUniqueId}' in '{player.Object.Name}''s inventory.");
            }

            if (itemToSell.Data == null)
            {
                throw new ArgumentNullException($"Cannot find item data for item '{itemToSell.Id}'.");
            }

            if (quantity > itemToSell.Data.PackMax)
            {
                throw new InvalidOperationException($"Cannot sell more items than the pack max value. {quantity} > {itemToSell.Data.PackMax}");
            }

            // TODO: make more checks:
            // is a quest item
            // is sealed to character
            // ect...

            int sellPrice = itemToSell.Data.Cost / 4; // TODO: make this configurable

            _logger.LogDebug("Selling item: '{0}' for {1}", itemToSell.Data.Name, sellPrice);

            int deletedQuantity = _inventorySystem.DeleteItem(player, playerItemUniqueId, quantity);

            if (deletedQuantity > 0)
            {
                _playerDataSystem.IncreaseGold(player, sellPrice * deletedQuantity);
            }
        }
Exemplo n.º 16
0
 public static SdPacket GenerateSdPacket(this IPlayerEntity player, int cooldown)
 {
     return(new SdPacket
     {
         CoolDown = cooldown
     });
 }
Exemplo n.º 17
0
 public GroundedState(IPlayerEntity playerEntity, IStateMachine stateMachine) : base(playerEntity, stateMachine)
 {
     _rigidBody      = _playerController.RigidBody;
     _animator       = _playerController.Animator;
     _groundCollider = _playerController.GroundCollider;
     _headCollider   = _playerController.HeadCollider;
 }
Exemplo n.º 18
0
        /// <summary>
        /// Sends a NPC dialog to a player.
        /// </summary>
        /// <param name="player">Player</param>
        /// <param name="text">Npc dialog text</param>
        /// <param name="dialogLinks">Npc dialog links</param>
        public static void SendDialog(IPlayerEntity player, string text, IEnumerable <DialogLink> dialogLinks)
        {
            using (var packet = new FFPacket())
            {
                packet.StartNewMergedPacket(player.Id, SnapshotType.RUNSCRIPTFUNC);
                packet.Write((short)DialogOptions.FUNCTYPE_REMOVEALLKEY);

                packet.StartNewMergedPacket(player.Id, SnapshotType.RUNSCRIPTFUNC);
                packet.Write((short)DialogOptions.FUNCTYPE_SAY);
                packet.Write(text);
                packet.Write(0); // quest id

                foreach (DialogLink link in dialogLinks)
                {
                    packet.StartNewMergedPacket(player.Id, SnapshotType.RUNSCRIPTFUNC);
                    packet.Write((short)DialogOptions.FUNCTYPE_ADDKEY);
                    packet.Write(link.Title);
                    packet.Write(link.Id);
                    packet.Write(0);
                    packet.Write(0);
                }

                player.Connection.Send(packet);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Use an item from the player's inventory.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="e"></param>
        private void ProcessUseItem(IPlayerEntity player, InventoryUseItemEventArgs e)
        {
            Item inventoryItem = player.Inventory.GetItem(e.UniqueItemId);

            if (inventoryItem == null)
            {
                this.Logger.LogWarning($"Cannot find item with unique Id: {e.UniqueItemId}");
                return;
            }

            if (e.Part >= MaxHumanParts)
            {
                this.Logger.LogWarning($"Parts cannot be grather than {MaxHumanParts}.");
                return;
            }

            if (e.Part != -1)
            {
                if (!player.Battle.IsFighting)
                {
                    this.EquipItem(player, inventoryItem);
                }
            }
            else
            {
                if (inventoryItem.Data.IsUseable && inventoryItem.Quantity > 0)
                {
                    this._itemUsage.UseItem(player, inventoryItem);
                }
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Tries to add the specified player to the party.
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public bool AddMember(IPlayerEntity player, bool isPartyLeader = false)
        {
            if (player.Party.IsInParty)
            {
                return(false);
            }

            if (Members.Contains(player))
            {
                return(false);
            }

            if (Members.Count == Members.Capacity)
            {
                return(false);
            }

            Members.Add(player);
            if (isPartyLeader)
            {
                PartyLeaderId = player.PlayerData.Id;
            }

            player.Party.Party = this;

            return(true);
        }
Exemplo n.º 21
0
 public static Task TeleportTo(this IPlayerEntity player, short x, short y)
 {
     // improve that
     player.Position.X = x;
     player.Position.Y = y;
     return(player.BroadcastAsync(player.GenerateTpPacket(x, y)));
 }
Exemplo n.º 22
0
        /// <summary>
        /// Start a new trade / accepting the trade
        /// </summary>
        /// <param name="player"></param>
        /// <param name="e"></param>
        private static void Trade(IPlayerEntity player, TradeBeginEventArgs e)
        {
            if (e.TargetId == player.Id)
            {
                throw new RhisisSystemException($"Can't start a Trade with ourselve ({player.Object.Name})");
            }

            if (IsTrading(player))
            {
                throw new RhisisSystemException($"Can't start a Trade when one is already in progress ({player.Object.Name})");
            }

            var target = GetEntityFromContextOf(player, e.TargetId);

            if (IsTrading(target))
            {
                throw new RhisisSystemException($"Can't start a Trade when one is already in progress ({target.Object.Name})");
            }

            player.Trade.TargetId = target.Id;
            target.Trade.TargetId = player.Id;

            WorldPacketFactory.SendTrade(player, target, player.Id);
            WorldPacketFactory.SendTrade(target, player, player.Id);
        }
Exemplo n.º 23
0
 protected override Task Handle(EquipmentInfoPacket packet, IPlayerEntity player) =>
 player.EmitEventAsync(new InventoryEqInfoEvent
 {
     Type        = packet.Type,
     Slot        = packet.Slot,
     ShopOwnerId = packet.ShopOwnerId
 });
Exemplo n.º 24
0
        /// <summary>
        /// Put gold to the current trade
        /// </summary>
        /// <param name="player"></param>
        /// <param name="e"></param>
        private static void PutGold(IPlayerEntity player, TradePutGoldEventArgs e)
        {
            Logger.Debug("PutGold");

            if (IsNotTrading(player))
            {
                throw new RhisisSystemException($"No trade target {player.Object.Name}");
            }

            var target = GetEntityFromContextOf(player, player.Trade.TargetId);

            if (IsNotTrading(target))
            {
                CancelTrade(player);
                throw new RhisisSystemException($"Target is not trading {target.Object.Name}");
            }

            if (IsNotTradeState(player, TradeComponent.TradeState.Item) ||
                IsNotTradeState(target, TradeComponent.TradeState.Item))
            {
                throw new RhisisSystemException($"Not the right trade state {player.Object.Name}");
            }

            player.PlayerData.Gold -= e.Gold;
            player.Trade.Gold      += e.Gold;

            WorldPacketFactory.SendTradePutGold(player, player.Id, player.Trade.Gold);
            WorldPacketFactory.SendTradePutGold(target, player.Id, player.Trade.Gold);
        }
        private static bool PreMovementChecks(IPlayerEntity player, PlayerMovementRequestEvent e)
        {
            // check for player' diseases
            if (player.Character.Hp == 0)
            {
                return(false);
            }

            if (!player.CanMove(e.X, e.Y))
            {
                return(false);
            }

            if (player.Position.X == e.X || player.Position.Y == e.Y)
            {
                return(false);
            }

            if (player.Speed < e.Speed)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 26
0
        private static void TradeConfirm(IPlayerEntity player, TradeConfirmEventArgs e)
        {
            Logger.Debug("Trade confirm");

            if (IsNotTrading(player))
            {
                throw new RhisisSystemException($"No trade target {player.Object.Name}");
            }

            var target = GetEntityFromContextOf(player, player.Trade.TargetId);

            if (IsNotTrading(target))
            {
                CancelTrade(player);
                throw new RhisisSystemException($"Target is not trading {target.Object.Name}");
            }

            if (IsNotTradeState(player, TradeComponent.TradeState.Ok))
            {
                return;
            }

            if (IsTradeState(target, TradeComponent.TradeState.Ok))
            {
                player.Trade.State = TradeComponent.TradeState.Confirm;

                WorldPacketFactory.SendTradeLastConfirmOk(player, player.Id);
                WorldPacketFactory.SendTradeLastConfirmOk(target, player.Id);
            }
            else if (IsTradeState(target, TradeComponent.TradeState.Confirm))
            {
                FinalizeTrade(player, target);
            }
        }
Exemplo n.º 27
0
 public KeyboardUseCase(IInfoEntity infoEntity,
                        IKeyboardDeleteButtonHandler keyboardDeleteButtonHandler,
                        IKeyboardEntity keyboardEntity,
                        IKeyboardFormRenderer keyboardFormRenderer,
                        IKeyboardListRenderer keyboardListRenderer,
                        IKeyboardSendButtonHandler keyboardSendButtonHandler,
                        IMainStateEntity mainStateEntity,
                        IPhotonChatPrcRequester photonChatPrcRequester,
                        IPlayerEntity playerEntity,
                        IReadOnlyList <IKeyboardKeyHandler> keyboardKeyHandlerList,
                        IReadOnlyList <IKeyboardKeyRenderer> keyboardKeyRendererList,
                        ITimerEntity timerEntity,
                        UnlockKeyList unlockKeyList)
 {
     InfoEntity = infoEntity;
     KeyboardDeleteButtonHandler = keyboardDeleteButtonHandler;
     KeyboardEntity            = keyboardEntity;
     KeyboardFormRenderer      = keyboardFormRenderer;
     KeyboardListRenderer      = keyboardListRenderer;
     KeyboardSendButtonHandler = keyboardSendButtonHandler;
     MainStateEntity           = mainStateEntity;
     PhotonChatPrcRequester    = photonChatPrcRequester;
     PlayerEntity            = playerEntity;
     KeyboardKeyHandlerList  = keyboardKeyHandlerList;
     KeyboardKeyRendererList = keyboardKeyRendererList;
     TimerEntity             = timerEntity;
     UnlockKeyList           = unlockKeyList;
 }
Exemplo n.º 28
0
        private void ModifyStatus(IPlayerEntity player, StatisticsModifyEventArgs e)
        {
            Logger.Debug("Modify sttus");

            var total = e.Strenght + e.Stamina + e.Dexterity + e.Intelligence;

            var statsPoints = player.Statistics.StatPoints;

            if (statsPoints <= 0 || total > statsPoints)
            {
                Logger.Error("No statspoints available, but trying to upgrade {0}.", player.Object.Name);
                return;
            }

            if (e.Strenght > statsPoints || e.Stamina > statsPoints ||
                e.Dexterity > statsPoints || e.Intelligence > statsPoints || total <= 0 ||
                total > ushort.MaxValue)
            {
                Logger.Error("Invalid upgrade request due to bad total calculation (trying to dupe) {0}.",
                             player.Object.Name);
                return;
            }

            player.Statistics.Strength     += e.Strenght;
            player.Statistics.Stamina      += e.Stamina;
            player.Statistics.Dexterity    += e.Dexterity;
            player.Statistics.Intelligence += e.Intelligence;
            player.Statistics.StatPoints   -= (ushort)total;
        }
Exemplo n.º 29
0
        public static void UpgradeNpc(IPlayerEntity player, ItemUpgradeEvent e)
        {
            if (e.Item.Upgrade >= Configuration.UpgradeItem.MaximumUpgrade)
            {
                return;
            }

            if (e.Item.Item.EquipmentSlot != EquipmentType.Armor && e.Item.Item.EquipmentSlot != EquipmentType.MainWeapon &&
                e.Item.Item.EquipmentSlot != EquipmentType.SecondaryWeapon)
            {
                return;
            }

            var             hasAmulet = FixedUpMode.None;
            ItemInstanceDto amulet    = player.Inventory.GetWeared(EquipmentType.Amulet);

            if (amulet?.Item.Effect == 793)
            {
                hasAmulet = FixedUpMode.HasAmulet;
            }

            player.EmitEvent(new UpgradeEquipmentEvent
            {
                Item       = e.Item,
                Mode       = e.Type == UpgradePacketType.UpgradeItemGoldScroll ? UpgradeMode.Reduced : UpgradeMode.Normal,
                Protection = e.Type == UpgradePacketType.UpgradeItem ? UpgradeProtection.None : UpgradeProtection.Protected,
                HasAmulet  = hasAmulet,
                IsCommand  = false
            });
        }
Exemplo n.º 30
0
        public static void UpgradeFamilySize2(IPlayerEntity player, NpcDialogEvent args)
        {
            if (player.Family.MaxSize > 100 && player.Family.FamilyLevel <= 9)
            {
                return;
            }
            if (player.FamilyCharacter.Authority != FamilyAuthority.Head)
            {
                /* await session.SendPacketAsync(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ONLY_HEAD_CAN_BUY"), 10));
                 *  await session.SendPacketAsync(UserInterfaceHelper.GenerateModal(Language.Instance.GetMessageFromKey("ONLY_HEAD_CAN_BUY"), 1));
                 */
                return;
            }

            if (5000000 >= player.Character.Gold)
            {
                //await session.SendPacketAsync(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                return;
            }
            player.GoldLess(10000000);
            player.Family.MaxSize = 100;

            /*FamilyDTO fam = Session.Character.Family;
             * DAOFactory.FamilyDAO.InsertOrUpdate(ref fam);
             * ServerManager.Instance.FamilyRefresh(Session.Character.Family.FamilyId);*/
        }