/// <summary> /// /// </summary> /// <param name="actor"></param> /// <param name="guid"></param> /// <param name="quantity"></param> public override void SellItem(AbstractEntity entity, long guid, int quantity, long price = -1) { if (quantity < 1) { Logger.Debug("ShopExchange unable to sell, quantity < 1 : " + entity.Name); entity.Dispatch(WorldMessage.EXCHANGE_SELL_ERROR()); return; } var item = entity.Inventory.Items.Find(entry => entry.Id == guid); if (item == null) { Logger.Debug("ShopExchange unable to sell null item : " + entity.Name); entity.Dispatch(WorldMessage.EXCHANGE_SELL_ERROR()); return; } if (quantity > item.Quantity) { quantity = item.Quantity; } var sellPrice = (item.Template.Price / 10) * quantity; entity.Inventory.RemoveItem(guid, quantity); entity.Inventory.AddKamas(sellPrice); }
/// <summary> /// /// </summary> /// <param name="entity"></param> public void SendMapFightInfos(AbstractEntity entity) { entity.Dispatch(WorldMessage.FIGHT_FLAG_UPDATE(OperatorEnum.OPERATOR_ADD, LeaderId, Fighters.ToArray())); foreach (var option in m_blockedOption) { entity.Dispatch(WorldMessage.FIGHT_OPTION(option.Key, option.Value, LeaderId)); } }
/// <summary> /// /// </summary> /// <param name="entity"></param> public void SendInformations(AbstractEntity entity) { var guildName = string.Empty; var guildEmblem = string.Empty; if (Guild != null) { guildName = Guild.Name; guildEmblem = Guild.Emblem; } // Map -2 to 0 var guildId = GuildId == -2 ? 0 : GuildId; entity.Dispatch(WorldMessage.PADDOCK_INFORMATIONS(guildId, Price, MountPlace, ItemPlace, guildName, guildEmblem)); }
/// <summary> /// /// </summary> /// <param name="entity"></param> public void SendAllInformations(AbstractEntity entity) { entity.CachedBuffer = true; // Before showing up we span all required base entities SendMapInformations(entity); SendInteractiveData(entity); SendPaddockInformations(entity); entity.Dispatch(WorldMessage.GAME_DATA_SUCCESS()); // Sub data that arent necessary to be instantly shown SendFightCount(entity); SendFightsInformations(entity); entity.CachedBuffer = false; }
/// <summary> /// /// </summary> /// <param name="entity"></param> /// <param name="guid"></param> /// <param name="quantity"></param> public override int AddItem(AbstractEntity entity, long guid, int quantity, long price = -1) { if (quantity < 1) { return(0); } UnValidateAll(); var item = entity.Inventory.GetItem(guid); if (item == null) { return(0); } if (quantity > item.Quantity) { quantity = item.Quantity; } if (item != null && item.Slot == ItemSlotEnum.SLOT_INVENTORY) { var alreadyExchangedQuantity = GetQuantity(entity, guid); if (alreadyExchangedQuantity > 0) { var realQuantity = item.Quantity - alreadyExchangedQuantity; if (quantity > realQuantity) { quantity = realQuantity; } } m_exchangedItems[entity.Id][guid] += quantity; if (entity.Id == m_local.Id) { if (m_local.Type == EntityTypeEnum.TYPE_CHARACTER) { m_local.Dispatch(WorldMessage.EXCHANGE_LOCAL_MOVEMENT(ExchangeMoveEnum.MOVE_OBJECT, OperatorEnum.OPERATOR_ADD, item.Id.ToString() + '|' + m_exchangedItems[entity.Id][guid])); } if (m_distant.Type == EntityTypeEnum.TYPE_CHARACTER) { m_distant.Dispatch(WorldMessage.EXCHANGE_DISTANT_MOVEMENT(ExchangeMoveEnum.MOVE_OBJECT, OperatorEnum.OPERATOR_ADD, item.Id.ToString() + '|' + m_exchangedItems[entity.Id][guid] + '|' + item.TemplateId + '|' + item.StringEffects)); } } else { if (m_local.Type == EntityTypeEnum.TYPE_CHARACTER) { m_local.Dispatch(WorldMessage.EXCHANGE_DISTANT_MOVEMENT(ExchangeMoveEnum.MOVE_OBJECT, OperatorEnum.OPERATOR_ADD, item.Id.ToString() + '|' + m_exchangedItems[entity.Id][guid] + '|' + item.TemplateId + '|' + item.StringEffects)); } if (m_distant.Type == EntityTypeEnum.TYPE_CHARACTER) { m_distant.Dispatch(WorldMessage.EXCHANGE_LOCAL_MOVEMENT(ExchangeMoveEnum.MOVE_OBJECT, OperatorEnum.OPERATOR_ADD, item.Id.ToString() + '|' + m_exchangedItems[entity.Id][guid])); } } return(quantity); } return(0); }
/// <summary> /// /// </summary> /// <param name="entity"></param> /// <param name="path"></param> /// <param name="cellId"></param> public void MovementFinish(AbstractEntity entity, MovementPath path, int cellId) { if (entity.Type == EntityTypeEnum.TYPE_CHARACTER) { var character = (CharacterEntity)entity; if (character.CanGameAction(GameActionTypeEnum.FIGHT)) { foreach (var monsterGroup in m_entityById.Values.OfType <MonsterGroupEntity>()) { if (CanBeAggro(character, cellId, monsterGroup)) { entity.CellId = cellId; if (monsterGroup.AlignmentId == -1) { if (FightManager.StartMonsterFight(character, monsterGroup)) { return; } } else { if (FightManager.StartAggression(monsterGroup, character)) { return; } } } } } } if (entity.CellId == cellId) { return; } entity.Orientation = path.GetDirection(path.LastStep); if (entity.Type == EntityTypeEnum.TYPE_CHARACTER) { var character = (CharacterEntity)entity; var cell = GetCell(cellId); if (cell != null) { if (cell.Trigger != null) { if (!cell.SatisfyConditions(character)) { entity.Dispatch(WorldMessage.IM_ERROR_MESSAGE(InformationEnum.ERROR_CONDITIONS_UNSATISFIED)); return; } entity.CellId = cellId; cell.ApplyActions(character); return; } } } entity.CellId = cellId; }
/// <summary> /// /// </summary> /// <param name="entity"></param> public void SendInteractiveData(AbstractEntity entity) => entity.Dispatch(WorldMessage.INTERACTIVE_DATA_FRAME(m_interactiveObjects));
/// <summary> /// /// </summary> /// <param name="entity"></param> public void SendMapInformations(AbstractEntity entity) => entity.Dispatch(WorldMessage.GAME_MAP_INFORMATIONS(OperatorEnum.OPERATOR_ADD, Entities.ToArray()));
/// <summary> /// /// </summary> /// <param name="entity"></param> public void SendFightCount(AbstractEntity entity) => entity.Dispatch(WorldMessage.FIGHT_COUNT(FightManager.FightCount));