protected UsableEffectHandler(EffectBase effect, Character target, BasePlayerItem item) : base(effect) { Target = target; Item = item; NumberOfUses = 1; }
public override bool Drop(BasePlayerItem dropOnItem) { if (Owner.IsInFight()) { return(false); } if (dropOnItem.Template.TypeId != LivingObjectRecord.ItemType) { return(false); } if (dropOnItem.Effects.Any(x => x.EffectId == EffectsEnum.Effect_LivingObjectId || x.EffectId == EffectsEnum.Effect_Appearance || x.EffectId == EffectsEnum.Effect_Apparence_Wrapper)) { return(false); } // check type dropOnItem.Effects.Add(new EffectInteger(EffectsEnum.Effect_LivingObjectId, (short)Template.Id)); foreach (var effect in Effects.Where(x => x.EffectId != EffectsEnum.Effect_NonExchangeable_981 && x.EffectId != EffectsEnum.Effect_NonExchangeable_982)) { dropOnItem.Effects.RemoveAll(x => x.EffectId == effect.EffectId); dropOnItem.Effects.Add(effect); } var newInstance = Owner.Inventory.RefreshItemInstance(dropOnItem); newInstance.Invalidate(); newInstance.OnObjectModified(); Owner.UpdateLook(); return(true); }
public override bool Execute(Npc npc, Character character) { bool result; if (!base.Execute(npc, character)) { result = false; } else { BasePlayerItem basePlayerItem = character.Inventory.TryGetItem(this.Item); if (basePlayerItem == null) { result = false; } else { character.Inventory.RemoveItem(basePlayerItem, this.Amount, true); character.SendInformationMessage(TextInformationTypeEnum.TEXT_INFORMATION_MESSAGE, 22, new object[] { this.Amount, basePlayerItem.Template.Id }); result = true; } } return(result); }
public static void HandleExchangeObjectModifyPricedMessage(WorldClient client, ExchangeObjectModifyPricedMessage message) { if (!client.Character.IsBusy() && message.price > 0) { MerchantItem merchantItem = client.Character.MerchantBag.TryGetItem((int)message.objectUID); if (merchantItem != null) { merchantItem.Price = (uint)message.price; if ((long)message.quantity == (long)((ulong)merchantItem.Stack) || message.quantity == 0) { InventoryHandler.SendExchangeShopStockMovementUpdatedMessage(client, merchantItem); } else { if ((long)message.quantity < (long)((ulong)merchantItem.Stack)) { client.Character.MerchantBag.MoveToInventory(merchantItem, (uint)((ulong)merchantItem.Stack - (ulong)((long)message.quantity))); } else { BasePlayerItem basePlayerItem = client.Character.Inventory.TryGetItem(merchantItem.Template); if (basePlayerItem != null) { client.Character.Inventory.MoveToMerchantBag(basePlayerItem, (uint)((long)message.quantity - (long)((ulong)merchantItem.Stack)), (uint)message.price); } } } } } }
public virtual bool CanHavePlayerItem(BasePlayer pPlayer, BasePlayerItem pWeapon) { // only living players can have items if (pPlayer.DeadFlag != DeadFlag.No) { return(false); } if (pWeapon.pszAmmo1() != null) { if (!CanHaveAmmo(pPlayer, pWeapon.pszAmmo1(), pWeapon.iMaxAmmo1())) { // we can't carry anymore ammo for this gun. We can only // have the gun if we aren't already carrying one of this type if (pPlayer.HasPlayerItem(pWeapon)) { return(false); } } } else { // weapon doesn't use ammo, don't take another if you already have it. if (pPlayer.HasPlayerItem(pWeapon)) { return(false); } } // note: will fall through to here if GetItemInfo doesn't fill the struct! return(true); }
public bool BuyItem(int itemGuid, uint quantity) { MerchantItem merchantItem = this.Merchant.Bag.FirstOrDefault((MerchantItem x) => x.Guid == itemGuid); bool result; if (merchantItem == null || quantity == 0u || !this.CanBuy(merchantItem, quantity)) { this.Character.Client.Send(new ExchangeErrorMessage(8)); result = false; } else { this.Merchant.Bag.RemoveItem(merchantItem, quantity, true); BasePlayerItem item = Singleton <ItemManager> .Instance.CreatePlayerItem(this.Character, merchantItem.Template, quantity, merchantItem.Effects); this.Character.Inventory.AddItem(item); BasicHandler.SendTextInformationMessage(this.Character.Client, TextInformationTypeEnum.TEXT_INFORMATION_MESSAGE, 21, new object[] { quantity, merchantItem.Template.Id }); this.Character.Inventory.SubKamas((int)(merchantItem.Price * quantity)); BasicHandler.SendTextInformationMessage(this.Character.Client, TextInformationTypeEnum.TEXT_INFORMATION_MESSAGE, 46, new object[] { (int)(merchantItem.Price * quantity) }); this.Merchant.KamasEarned += merchantItem.Price * quantity; this.Character.Client.Send(new ExchangeBuyOkMessage()); result = true; } return(result); }
public static void HandleLivingObjectDissociateMessage(WorldClient client, LivingObjectDissociateMessage message) { BasePlayerItem basePlayerItem = client.Character.Inventory.TryGetItem((int)message.livingUID); if (basePlayerItem is BoundLivingObjectItem) { ((BoundLivingObjectItem)basePlayerItem).Dissociate(); } }
void EquippItem(int slot, BasePlayerItem item) { equippedItems[slot] = item; item.ResetItemUsageTimes(); if (OnEquippedItemChanged != null) { OnEquippedItemChanged(slot, item.Sprite); } }
public static void HandleObjectUseMultipleMessage(WorldClient client, ObjectUseMultipleMessage message) { BasePlayerItem basePlayerItem = client.Character.Inventory.TryGetItem((int)message.objectUID); if (basePlayerItem != null) { client.Character.Inventory.UseItem(basePlayerItem, (uint)message.quantity); } }
public static void HandleLivingObjectChangeSkinRequestMessage(WorldClient client, LivingObjectChangeSkinRequestMessage message) { BasePlayerItem basePlayerItem = client.Character.Inventory.TryGetItem((int)message.livingUID); if (basePlayerItem is CommonLivingObject) { ((CommonLivingObject)basePlayerItem).SelectedLevel = (short)message.skinId; } }
public override bool ShouldSwitchWeapon(BasePlayer pPlayer, BasePlayerItem pWeapon) { if (pPlayer.m_pActiveItem == null) { // player doesn't have an active item! return(true); } return(pPlayer.m_pActiveItem.CanHolster()); }
public GuildCreationResultEnum CreateGuild(Character character, string name, Stump.DofusProtocol.Types.GuildEmblem emblem) { GuildCreationResultEnum result; if (this.DoesNameExist(name)) { result = GuildCreationResultEnum.GUILD_CREATE_ERROR_NAME_ALREADY_EXISTS; } else { if (this.DoesEmblemExist(emblem)) { result = GuildCreationResultEnum.GUILD_CREATE_ERROR_EMBLEM_ALREADY_EXISTS; } else { BasePlayerItem basePlayerItem = character.Inventory.TryGetItem(Singleton <ItemManager> .Instance.TryGetTemplate(GuildManager.GUILDALOGEMME_ID)); if (basePlayerItem == null) { result = GuildCreationResultEnum.GUILD_CREATE_ERROR_REQUIREMENT_UNMET; } else { character.Inventory.RemoveItem(basePlayerItem, 1u, true); character.SendInformationMessage(TextInformationTypeEnum.TEXT_INFORMATION_MESSAGE, 22, new object[] { 1, basePlayerItem.Template.Id }); Guild guild = this.CreateGuild(name); if (guild == null) { result = GuildCreationResultEnum.GUILD_CREATE_ERROR_CANCEL; } else { guild.Emblem.ChangeEmblem(emblem); GuildMember guildMember; if (!guild.TryAddMember(character, out guildMember)) { this.DeleteGuild(guild); result = GuildCreationResultEnum.GUILD_CREATE_ERROR_CANCEL; } else { character.GuildMember = guildMember; character.RefreshActor(); result = GuildCreationResultEnum.GUILD_CREATE_OK; } } } } } return(result); }
public void AddItemShortcut(int slot, BasePlayerItem item) { if (!this.IsSlotFree(slot, ShortcutBarEnum.GENERAL_SHORTCUT_BAR)) { this.RemoveShortcut(ShortcutBarEnum.GENERAL_SHORTCUT_BAR, slot); } ItemShortcut itemShortcut = new ItemShortcut(this.Owner.Record, slot, item.Template.Id, item.Guid); this.m_itemShortcuts.Add(slot, itemShortcut); ShortcutHandler.SendShortcutBarRefreshMessage(this.Owner.Client, ShortcutBarEnum.GENERAL_SHORTCUT_BAR, itemShortcut); }
public override bool MoveItemToPanel(BasePlayerItem item, int amount) { var tradeItem = Items.SingleOrDefault(entry => entry.Guid == item.Guid); if (Items.Count >= MAX_ITEMS_COUNT && tradeItem == null) { return(false); } return(base.MoveItemToPanel(item, amount)); }
public static void HandleObjectSetPositionMessage(WorldClient client, ObjectSetPositionMessage message) { if (System.Enum.IsDefined(typeof(CharacterInventoryPositionEnum), (int)message.position)) { BasePlayerItem basePlayerItem = client.Character.Inventory.TryGetItem((int)message.objectUID); if (basePlayerItem != null) { client.Character.Inventory.MoveItem(basePlayerItem, (CharacterInventoryPositionEnum)message.position); } } }
protected override void Apply() { if (base.FirstTrader.Items.All(delegate(TradeItem x) { BasePlayerItem basePlayerItem = base.FirstTrader.Character.Inventory.TryGetItem(x.Guid); return(basePlayerItem != null && basePlayerItem.Stack >= x.Stack); })) { base.FirstTrader.Character.Inventory.SetKamas((int)((long)base.FirstTrader.Character.Inventory.Kamas + (long)((ulong)(base.SecondTrader.Kamas - base.FirstTrader.Kamas)))); foreach (TradeItem current in base.FirstTrader.Items) { BasePlayerItem item = base.FirstTrader.Character.Inventory.TryGetItem(current.Guid); base.FirstTrader.Character.Inventory.RemoveItem(item, current.Stack, true); } foreach (TradeItem current in base.SecondTrader.Items) { base.FirstTrader.Character.Inventory.AddItem(current.Template, current.Stack); } InventoryHandler.SendInventoryWeightMessage(base.FirstTrader.Character.Client); BsonDocument document = new BsonDocument { { "NpcId", base.SecondTrader.Npc.TemplateId }, { "PlayerId", base.FirstTrader.Id }, { "NpcKamas", (long)((ulong)base.SecondTrader.Kamas) }, { "PlayerItems", base.FirstTrader.ItemsString }, { "NpcItems", base.SecondTrader.ItemsString }, { "Date", System.DateTime.Now.ToString(System.Globalization.CultureInfo.InvariantCulture) } }; Singleton <MongoLogger> .Instance.Insert("NpcTrade", document); } }
public static void HandleExchangeObjectMovePricedMessage(WorldClient client, ExchangeObjectMovePricedMessage message) { if (message.quantity > 0 && message.price > 0) { BasePlayerItem basePlayerItem = client.Character.Inventory.TryGetItem((int)message.objectUID); if (basePlayerItem != null && !client.Character.IsBusy()) { client.Character.Inventory.MoveToMerchantBag(basePlayerItem, (uint)message.quantity, (uint)message.price); } } }
public static void HandleObjectUseOnCharacterMessage(WorldClient client, ObjectUseOnCharacterMessage message) { BasePlayerItem basePlayerItem = client.Character.Inventory.TryGetItem((int)message.objectUID); if (basePlayerItem != null) { Character actor = client.Character.Map.GetActor <Character>((int)message.characterId); if (actor != null) { client.Character.Inventory.UseItem(basePlayerItem, actor, 1u); } } }
public static void HandleObjectUseOnCellMessage(WorldClient client, ObjectUseOnCellMessage message) { BasePlayerItem basePlayerItem = client.Character.Inventory.TryGetItem((int)message.objectUID); if (basePlayerItem != null) { Cell cell = client.Character.Map.GetCell((int)message.cells); if (cell != null) { client.Character.Inventory.UseItem(basePlayerItem, cell, 1u); } } }
private void ApplyEffects(BasePlayerItem item, ItemEffectHandler.HandlerOperation operation) { foreach (var handler in item.Effects.Select(effect => EffectManager.Instance.GetItemEffectHandler(effect, Owner, this))) { handler.Operation = operation; if (Owner.Inventory.GetEquipedItems().Any(x => x != item && x.GetExoEffects().ToList().Exists(y => item.GetExoEffects().Any(z => z == y))) && item.GetExoEffects().Any(x => x == handler.Effect)) { handler.Operation = ItemEffectHandler.HandlerOperation.NONAPPLY; } handler.Apply(); } }
public override bool MoveItemToPanel(BasePlayerItem item, int quantity) { if (RuneCraftDialog.IsItemEditable(item) && quantity > 1) { quantity = 1; } if (RuneCraftDialog.IsItemEditable(item) && item.Stack > 1) { var newItem = item.Owner.Inventory.CutItem(item, 1); return(base.MoveItemToPanel(newItem, 1)); } return(base.MoveItemToPanel(item, quantity)); }
private void OnInventoryItemRemoved(ItemsCollection <BasePlayerItem> sender, BasePlayerItem item) { foreach (var idol in ActiveIdols.Where(x => x.Template.IdolItemId == item.Template.Id).ToArray()) { if (idol.Owner.Inventory.HasItem(idol.Template.IdolItem)) { continue; } Remove(idol); if (IsPartyIdols) { IdolHandler.SendIdolPartyLostMessage(Party.Clients, (short)idol.Id); } } }
public virtual bool BuyItem(int itemId, uint amount) { NpcItem npcItem = this.Items.FirstOrDefault((NpcItem entry) => entry.Item.Id == itemId); bool result; if (npcItem == null) { this.Character.Client.Send(new ExchangeErrorMessage(8)); result = false; } else { uint num = (uint)(npcItem.Price * amount); if (!this.CanBuy(npcItem, amount)) { this.Character.Client.Send(new ExchangeErrorMessage(8)); result = false; } else { BasicHandler.SendTextInformationMessage(this.Character.Client, TextInformationTypeEnum.TEXT_INFORMATION_MESSAGE, 21, new object[] { amount, itemId }); BasePlayerItem item = Singleton <ItemManager> .Instance.CreatePlayerItem(this.Character, itemId, amount, this.MaxStats || npcItem.MaxStats); this.Character.Inventory.AddItem(item); if (this.Token != null) { this.Character.Inventory.UnStackItem(this.Character.Inventory.TryGetItem(this.Token), num); } else { this.Character.Inventory.SubKamas((int)num); BasicHandler.SendTextInformationMessage(this.Character.Client, TextInformationTypeEnum.TEXT_INFORMATION_MESSAGE, 46, new object[] { num }); } this.Character.Client.Send(new ExchangeBuyOkMessage()); result = true; } } return(result); }
public override void Execute(TriggerBase trigger) { int num = trigger.Get <int>("typeid"); bool flag = trigger.Get <bool>("etheral"); Character target = base.GetTarget(trigger); System.Collections.Generic.IEnumerable <ItemTemplate> templates = Singleton <ItemManager> .Instance.GetTemplates(); foreach (ItemTemplate current in templates) { if ((ulong)current.TypeId == (ulong)((long)num) && (!current.IsWeapon() || current.Etheral == flag)) { BasePlayerItem basePlayerItem = Singleton <ItemManager> .Instance.CreatePlayerItem(target, current, 1u, false); target.Inventory.AddItem(basePlayerItem); if (basePlayerItem == null) { trigger.Reply("Item '{0}'({1}) can't be add for an unknown reason", new object[] { current.Name, current.Id }); } else { if (trigger is GameTrigger && (trigger as GameTrigger).Character.Id == target.Id) { trigger.Reply("Added '{0}'({1}) to your inventory.", new object[] { current.Name, current.Id }); } else { trigger.Reply("Added '{0}'({1}) to '{2}' inventory.", new object[] { current.Name, current.Id, target.Name }); } } } } }
public static void HandleObjectFeedMessage(WorldClient client, ObjectFeedMessage message) { BasePlayerItem basePlayerItem = client.Character.Inventory.TryGetItem((int)message.objectUID); BasePlayerItem basePlayerItem2 = client.Character.Inventory.TryGetItem((int)message.foodUID); if (basePlayerItem != null && basePlayerItem2 != null) { if ((ulong)basePlayerItem2.Stack < (ulong)((long)message.foodQuantity)) { message.foodQuantity = (uint)basePlayerItem2.Stack; } uint num = 0u; while ((ulong)num < (ulong)((long)message.foodQuantity) && basePlayerItem.Feed(basePlayerItem2)) { num += 1u; } client.Character.Inventory.RemoveItem(basePlayerItem2, num, true); } }
public override bool Feed(BasePlayerItem food) { bool result; if ((ulong)food.Template.TypeId != (ulong)((long)base.LivingObjectRecord.ItemType)) { result = false; } else { short num = (short)System.Math.Ceiling(food.Template.Level / 2.0); base.Experience += num; base.Mood = 1; base.LastMeal = new System.DateTime?(System.DateTime.Now); base.Owner.Inventory.RefreshItem(this); result = true; } return(result); }
public override bool Drop(BasePlayerItem dropOnItem) { var pet = dropOnItem as PetItem; if (pet == null) { return(false); } if (pet.LifePoints < pet.MaxLifePoints) { pet.LifePoints++; Owner.Inventory.RefreshItem(pet); return(true); } return(false); }
public override bool Feed(BasePlayerItem food) { if (food.Template.TypeId != LivingObjectRecord.ItemType) { return(false); } var xp = (short)Math.Ceiling(food.Template.Level / 2d); Experience += xp; // todo, manage it Mood = 1; LastMeal = DateTime.Now; Owner.Inventory.RefreshItem(this); return(true); }
public override void Execute(TriggerBase trigger) { ItemSetTemplate itemSetTemplate = trigger.Get <ItemSetTemplate>("template"); Character target = base.GetTarget(trigger); ItemTemplate[] items = itemSetTemplate.Items; for (int i = 0; i < items.Length; i++) { ItemTemplate itemTemplate = items[i]; BasePlayerItem basePlayerItem = Singleton <ItemManager> .Instance.CreatePlayerItem(target, itemTemplate, 1u, trigger.IsArgumentDefined("max")); target.Inventory.AddItem(basePlayerItem); if (basePlayerItem == null) { trigger.Reply("Item '{0}'({1}) can't be add for an unknown reason", new object[] { itemTemplate.Name, itemTemplate.Id }); } else { if (trigger is GameTrigger && (trigger as GameTrigger).Character.Id == target.Id) { trigger.Reply("Added '{0}'({1}) to your inventory.", new object[] { itemTemplate.Name, itemTemplate.Id }); } else { trigger.Reply("Added '{0}'({1}) to '{2}' inventory.", new object[] { itemTemplate.Name, itemTemplate.Id, target.Name }); } } } }
public override void Execute(TriggerBase trigger) { ItemTemplate itemTemplate = trigger.Get <ItemTemplate>("template"); Character[] targets = base.GetTargets(trigger); for (int i = 0; i < targets.Length; i++) { Character character = targets[i]; BasePlayerItem basePlayerItem = Singleton <ItemManager> .Instance.CreatePlayerItem(character, itemTemplate, trigger.Get <uint>("amount"), trigger.IsArgumentDefined("max")); character.Inventory.AddItem(basePlayerItem); if (basePlayerItem == null) { trigger.ReplyError("Item '{0}'({1}) can't be add for an unknown reason", new object[] { itemTemplate.Name, itemTemplate.Id }); } else { if (trigger is GameTrigger && (trigger as GameTrigger).Character.Id == character.Id) { trigger.Reply("Added '{0}'({1}) to your inventory.", new object[] { itemTemplate.Name, itemTemplate.Id }); } else { trigger.Reply("Added '{0}'({1}) to '{2}' inventory.", new object[] { itemTemplate.Name, itemTemplate.Id, character.Name }); } } } }