Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="character"></param>
        /// <param name="message"></param>
        private void GuildJoinAccept(CharacterEntity character, string message)
        {
            WorldService.Instance.AddMessage(() =>
            {
                // not being invited ?
                if (character.GuildInviterPlayerId == -1)
                {
                    character.SafeDispatch(WorldMessage.BASIC_NO_OPERATION());
                    return;
                }

                var distantCharacter = EntityManager.Instance.GetCharacterById(character.GuildInviterPlayerId);

                character.GuildInvitedPlayerId = -1;
                character.GuildInviterPlayerId = -1;

                // should never happend
                if (distantCharacter == null)
                {
                    character.SafeDispatch(WorldMessage.BASIC_NO_OPERATION());
                    return;
                }

                distantCharacter.GuildInvitedPlayerId = -1;
                distantCharacter.GuildInviterPlayerId = -1;
                distantCharacter.SafeDispatch(WorldMessage.GUILD_JOIN_ACCEPTED_DISTANT(character.Name));

                distantCharacter.GuildMember.Guild.MemberJoin(character);

                character.SafeDispatch(WorldMessage.GUILD_JOIN_ACCEPTED_LOCAL());
                character.SafeDispatch(WorldMessage.GUILD_JOIN_CLOSE());
            });
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="CastInfos"></param>
        /// <returns></returns>
        public override FightActionResultEnum ApplyEffect(CastInfos CastInfos)
        {
            var infos = CastInfos.Caster.StateManager.FindState(FighterStateEnum.STATE_CARRIER);

            if (infos != null)
            {
                var target = infos.Target;

                if (target.StateManager.HasState(FighterStateEnum.STATE_CARRIED))
                {
                    var cell = target.Fight.GetCell(CastInfos.CellId);
                    if (cell.CanWalk)
                    {
                        var sleepTime = 1 + (WorldConfig.FIGHT_PANDA_LAUNCH_CELL_TIME * Pathfinding.GoalDistance(target.Fight.Map, target.Cell.Id, CastInfos.CellId));

                        target.Fight.Dispatch(WorldMessage.GAME_ACTION(EffectEnum.PandaLaunch, CastInfos.Caster.Id, CastInfos.CellId.ToString()));

                        target.Fight.SetSubAction(() =>
                        {
                            return(target.SetCell(cell));
                        }, sleepTime);
                    }
                }
            }

            return(FightActionResultEnum.RESULT_NOTHING);
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="actionType"></param>
        public override void StartAction(GameActionTypeEnum actionType)
        {
            switch (actionType)
            {
            case GameActionTypeEnum.FIGHT:
                StopAction(GameActionTypeEnum.MAP);
                break;

            case GameActionTypeEnum.FIGHT_WEAPON_USE:
            case GameActionTypeEnum.FIGHT_SPELL_LAUNCH:
                Fight.Dispatch(WorldMessage.GAME_ACTION(CurrentAction.Type, Id, CurrentAction.SerializeAs_GameAction()));
                break;

            case GameActionTypeEnum.MAP_MOVEMENT:
                if (HasGameAction(GameActionTypeEnum.FIGHT))
                {
                    if (StateManager.HasState(FighterStateEnum.STATE_STEALTH))
                    {
                        Team.Dispatch(WorldMessage.GAME_ACTION(actionType, Id, CurrentAction.SerializeAs_GameAction()));
                        return;
                    }
                }
                break;
            }

            base.StartAction(actionType);
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="character"></param>
        /// <param name="message"></param>
        private void ObjectDelete(CharacterEntity character, string message)
        {
            var data = message.Substring(2).Split('|');

            long itemId = -1;

            if (!long.TryParse(data[0], out itemId))
            {
                character.SafeDispatch(WorldMessage.BASIC_NO_OPERATION());
                return;
            }

            int quantity = 1;

            if (data.Length > 1)
            {
                if (!int.TryParse(data[1], out quantity))
                {
                    character.SafeDispatch(WorldMessage.BASIC_NO_OPERATION());
                    return;
                }
            }

            character.AddMessage(() =>
            {
                character.Inventory.RemoveItem(itemId, quantity);
            });
        }
Exemple #5
0
        /// <summary>
        ///
        /// </summary>
        public override void Create()
        {
            base.Create();
            base.Dispatch(WorldMessage.EXCHANGE_SHOP_LIST(Npc));

            Npc.OnBeginTrade(Character);
        }
Exemple #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="actor"></param>
        /// <param name="message"></param>
        private void FightTurnPass(CharacterEntity character, string message)
        {
            character.AddMessage(() =>
            {
                if (!character.HasGameAction(GameActionTypeEnum.FIGHT))
                {
                    character.Dispatch(WorldMessage.BASIC_NO_OPERATION());
                    return;
                }

                if (character.IsSpectating)
                {
                    Logger.Debug("GameFight::TurnPass spectator player cant pass turn : " + character.Name);
                    character.Dispatch(WorldMessage.BASIC_NO_OPERATION());
                    return;
                }

                if (character.Fight.CurrentFighter != character)
                {
                    Logger.Debug("GameFight::TurnPass not the turn of this player : " + character.Name);
                    character.Dispatch(WorldMessage.BASIC_NO_OPERATION());
                    return;
                }

                character.TurnPass = true;
            });
        }
Exemple #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="client"></param>
        /// <param name="message"></param>
        private void HandleCharacterSelect(WorldClient client, string message)
        {
            if (client.Characters == null)
            {
                return;
            }

            var characterId = long.Parse(message.Substring(2));
            var character   = client.Characters.Find(entry => entry.Id == characterId);

            // unknow id
            if (character == null)
            {
                client.Send(WorldMessage.CHARACTER_SELECTION_ERROR());
                return;
            }

            // dead ?
            if (character.Dead)
            {
                client.Send(WorldMessage.CHARACTER_SELECTION_ERROR());
                return;
            }

            WorldService.Instance.AddMessage(() =>
            {
                CharacterSelectExecute(client, character);
            });
        }
Exemple #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="character"></param>
        /// <param name="message"></param>
        private void GuildTaxCollectorRemove(CharacterEntity character, string message)
        {
            long taxCollectorId = -1;

            if (!long.TryParse(message.Substring(2), out taxCollectorId))
            {
                character.SafeDispatch(WorldMessage.BASIC_NO_OPERATION());
                return;
            }

            character.AddMessage(() =>
            {
                if (!character.HasGameAction(GameActionTypeEnum.MAP))
                {
                    character.Dispatch(WorldMessage.BASIC_NO_OPERATION());
                    return;
                }

                var taxCollector = character.Map.GetEntity(taxCollectorId) as TaxCollectorEntity;
                if (taxCollector == null)
                {
                    character.Dispatch(WorldMessage.BASIC_NO_OPERATION());
                    return;
                }

                if (character.GuildMember == null)
                {
                    character.SafeDispatch(WorldMessage.BASIC_NO_OPERATION());
                    return;
                }

                character.GuildMember.RemoveTaxCollector(taxCollector);
            });
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="character"></param>
        /// <param name="message"></param>
        private void DialogCreate(CharacterEntity character, string message)
        {
            long npcId = -1;

            if (!long.TryParse(message.Substring(2), out npcId))
            {
                character.SafeDispatch(WorldMessage.BASIC_NO_OPERATION());
                return;
            }

            character.AddMessage(() =>
            {
                var target = character.Map.GetEntity(npcId);
                if (target == null || target.Type != EntityTypeEnum.TYPE_NPC)
                {
                    character.Dispatch(WorldMessage.BASIC_NO_OPERATION());
                    return;
                }

                var npc = (NonPlayerCharacterEntity)target;
                if (npc.InitialQuestion == null)
                {
                    character.Dispatch(WorldMessage.BASIC_NO_OPERATION());
                    return;
                }

                if (!character.CanGameAction(GameActionTypeEnum.NPC_DIALOG))
                {
                    character.Dispatch(WorldMessage.INFORMATION_MESSAGE(InformationTypeEnum.ERROR, InformationEnum.ERROR_YOU_ARE_AWAY));
                    return;
                }

                character.NpcDialogStart(npc);
            });
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="buff"></param>
        public void RemoveState(AbstractSpellBuff buff)
        {
            if (buff.Caster.Fight.State == FightStateEnum.STATE_FIGHTING)
            {
                switch (buff.CastInfos.EffectType)
                {
                case EffectEnum.Stealth:

                    m_fighter.Fight.Dispatch(WorldMessage.GAME_ACTION(EffectEnum.Stealth, m_fighter.Id, m_fighter.Id.ToString()));
                    m_fighter.Fight.Dispatch(WorldMessage.GAME_ACTION(GameActionTypeEnum.MAP_TELEPORT, m_fighter.Id, m_fighter.Id + "," + m_fighter.Cell.Id));

                    m_states.Remove(FighterStateEnum.STATE_STEALTH);

                    return;

                default:

                    m_fighter.Fight.Dispatch(WorldMessage.GAME_ACTION(EffectEnum.AddState, m_fighter.Id, m_fighter.Id + "," + buff.CastInfos.Value3 + ",0"));

                    break;
                }
            }

            m_states.Remove((FighterStateEnum)buff.CastInfos.Value3);
        }
Exemple #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="castInfos"></param>
        /// <returns></returns>
        public override FightActionResultEnum ApplyEffect(CastInfos castInfos)
        {
            int direction         = Pathfinding.GetDirection(castInfos.Map, castInfos.Caster.Cell.Id, castInfos.CellId);
            var targetFighterCell = Pathfinding.NextCell(castInfos.Map, castInfos.Caster.Cell.Id, direction);

            var target = castInfos.Fight.GetFighterOnCell(targetFighterCell);

            if (target == null)
            {
                return(FightActionResultEnum.RESULT_NOTHING);
            }

            var distance    = Pathfinding.GoalDistance(castInfos.Map, target.Cell.Id, castInfos.CellId);
            var currentCell = target.Cell;

            for (int i = 0; i < distance; i++)
            {
                var nextCell = castInfos.Fight.GetCell(Pathfinding.NextCell(castInfos.Map, currentCell.Id, direction));

                if (nextCell != null && nextCell.CanWalk)
                {
                    if (nextCell.HasObject(FightObstacleTypeEnum.TYPE_TRAP))
                    {
                        castInfos.Fight.Dispatch(WorldMessage.GAME_ACTION(GameActionTypeEnum.MAP_PUSHBACK, target.Id, target.Id + "," + nextCell.Id));

                        castInfos.Fight.SetSubAction(() =>
                        {
                            return(target.SetCell(nextCell));
                        }, 1 + ++i * WorldConfig.FIGHT_PUSH_CELL_TIME);

                        return(FightActionResultEnum.RESULT_NOTHING);
                    }
                }
                else
                {
                    if (i != 0)
                    {
                        castInfos.Fight.Dispatch(WorldMessage.GAME_ACTION(GameActionTypeEnum.MAP_PUSHBACK, target.Id, target.Id + "," + currentCell.Id));
                    }

                    castInfos.Fight.SetSubAction(() =>
                    {
                        return(target.SetCell(currentCell));
                    }, 1 + (i * WorldConfig.FIGHT_PUSH_CELL_TIME));

                    return(FightActionResultEnum.RESULT_NOTHING);
                }

                currentCell = nextCell;
            }

            castInfos.Fight.Dispatch(WorldMessage.GAME_ACTION(GameActionTypeEnum.MAP_PUSHBACK, target.Id, target.Id + "," + currentCell.Id));

            castInfos.Fight.SetSubAction(() =>
            {
                return(target.SetCell(currentCell));
            }, 1 + distance * WorldConfig.FIGHT_PUSH_CELL_TIME);

            return(FightActionResultEnum.RESULT_NOTHING);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="result"></param>
        private void Finish(GameActionTypeEnum result)
        {
            var message = WorldMessage.GAME_ACTION(result, Attacker.Id, Defender.Id.ToString());

            Attacker.Dispatch(message);
            Defender.Dispatch(message);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="castInfos"></param>
        /// <param name="target"></param>
        public PandaCarrierBuff(CastInfos castInfos, AbstractFighter target)
            : base(castInfos, target, ActiveType.ACTIVE_ENDMOVE, DecrementType.TYPE_ENDMOVE)
        {
            Caster.StateManager.AddState(this);

            castInfos.Caster.Fight.Dispatch(WorldMessage.GAME_ACTION(EffectEnum.PandaCarrier, castInfos.Caster.Id, target.Id.ToString()));
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="attacker"></param>
 /// <param name="defender"></param>
 public GameChallengeRequestAction(CharacterEntity attacker, CharacterEntity defender)
     : base(GameActionTypeEnum.CHALLENGE_REQUEST, attacker)
 {
     Attacker = attacker;
     Defender = defender;
     Attacker.Map.Dispatch(WorldMessage.GAME_ACTION(GameActionTypeEnum.CHALLENGE_REQUEST, Attacker.Id, SerializeAs_GameAction()));
 }
Exemple #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="actor"></param>
        /// <param name="message"></param>
        private void FightPlacement(CharacterEntity character, string message)
        {
            character.AddMessage(() =>
            {
                if (!character.HasGameAction(GameActionTypeEnum.FIGHT))
                {
                    character.Dispatch(WorldMessage.BASIC_NO_OPERATION());
                    return;
                }

                if (character.TurnReady)
                {
                    Logger.Debug("GameFightPlacement::Placement turn ready, unable to move anymore : " + character.Name);
                    character.Dispatch(WorldMessage.BASIC_NO_OPERATION());
                    return;
                }

                int cellId = -1;
                if (!int.TryParse(message.Substring(2), out cellId))
                {
                    Logger.Debug("GameFightPlacement::Placement unable to parse cell id : " + character.Name);
                    character.Dispatch(WorldMessage.BASIC_NO_OPERATION());
                    return;
                }

                character.Fight.FighterPlacementChange(character, cellId);
            });
        }
Exemple #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="actor"></param>
        /// <param name="guid"></param>
        /// <param name="quantity"></param>
        /// <param name="price"></param>
        public override int AddItem(AbstractEntity actor, long guid, int quantity, long price = -1)
        {
            switch (Npc.AuctionHouse.TryAdd(Character, guid, quantity, price))
            {
            case AuctionAddResultEnum.INVALID_PRICE:
                Character.Dispatch(WorldMessage.INFORMATION_MESSAGE(InformationTypeEnum.ERROR, InformationEnum.ERROR_INVALID_PRICE));
                break;

            case AuctionAddResultEnum.INVALID_TYPE:
                Character.Dispatch(WorldMessage.INFORMATION_MESSAGE(InformationTypeEnum.INFO, InformationEnum.INFO_AUCTION_ADD_INVALID_TYPE));
                break;

            case AuctionAddResultEnum.ERROR:
            case AuctionAddResultEnum.INVALID_FLOOR:
            case AuctionAddResultEnum.INVALID_ITEM:
            case AuctionAddResultEnum.INVALID_QUANTITY:
            case AuctionAddResultEnum.TOO_HIGH_LEVEL:
                Character.Dispatch(WorldMessage.OBJECT_MOVE_ERROR());
                break;

            case AuctionAddResultEnum.TOO_MANY_ENTRIES:
                Character.Dispatch(WorldMessage.INFORMATION_MESSAGE(InformationTypeEnum.ERROR, InformationEnum.ERROR_AUCTION_HOUSE_TOO_MANY_ITEMS));
                break;

            case AuctionAddResultEnum.NOT_ENOUGH_KAMAS_FOR_TAXE:
                Character.Dispatch(WorldMessage.INFORMATION_MESSAGE(InformationTypeEnum.ERROR, InformationEnum.ERROR_NOT_ENOUGH_KAMAS_FOR_TAXE));
                break;
            }

            return(0);
        }
Exemple #17
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="character"></param>
 /// <param name="message"></param>
 private void GameCreation(CharacterEntity character, string message)
 {
     character.AddMessage(() =>
     {
         character.FrameManager.RemoveFrame(GameCreationFrame.Instance);
         character.FrameManager.AddFrame(GameInformationFrame.Instance);
         var map = character.Map;
         if (map == null)
         {
             character.MapId  = WorldConfig.GetStartMap(character.Breed);
             character.CellId = WorldConfig.GetStartCell(character.Breed);
             map = character.Map;
         }
         character.CachedBuffer = true;
         character.Dispatch(WorldMessage.GAME_CREATION_SUCCESS());
         if (character.HasGameAction(Game.Action.GameActionTypeEnum.FIGHT))
         {
             character.Dispatch(WorldMessage.GAME_DATA_MAP(character.Fight.Map.Id, character.Fight.Map.CreateTime, character.Fight.Map.DataKey));
         }
         else
         {
             character.Dispatch(WorldMessage.GAME_DATA_MAP(map.Id, map.CreateTime, map.DataKey));
         }
         character.Dispatch(WorldMessage.ACCOUNT_STATS((CharacterEntity)character));
         character.CachedBuffer = false;
     });
 }
Exemple #18
0
        /// <summary>
        ///
        /// </summary>
        private void EndLoop(int reason)
        {
            Character.Dispatch(WorldMessage.CRAFT_LOOP_END(reason));

            base.RemoveTimer(m_loopTimer);
            m_loopTimer = null;
        }
Exemple #19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="character"></param>
        /// <param name="message"></param>
        private void ChatChannelEnable(CharacterEntity character, string message)
        {
            var enabled = message[2] == '+';
            var channel = (ChatChannelEnum)message[3];

            character.SafeDispatch(WorldMessage.CHAT_CHANNEL(enabled, channel));
        }
Exemple #20
0
        /// <summary>
        ///
        /// </summary>
        private void Loop()
        {
            Character.CachedBuffer = true;

            Character.Dispatch(WorldMessage.CRAFT_LOOP_COUNT(m_loopCount - 1));

            foreach (var ingredient in m_lastCaseItems)
            {
                var item = Character.Inventory.GetItem(ingredient.Key);
                if (item == null || item.Quantity < ingredient.Value)
                {
                    EndLoop(LOOP_ERROR);
                    Character.CachedBuffer = false;
                    return;
                }
                AddItem(Character, ingredient.Key, ingredient.Value);
            }

            Validate(null);

            m_loopCount--;

            if (m_loopCount == 0)
            {
                EndLoop(LOOP_OK);

                m_caseItems = new Dictionary <long, int>();
            }

            Character.CachedBuffer = false;
        }
Exemple #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="guid"></param>
        /// <param name="quantity"></param>
        public override int RemoveItem(AbstractEntity entity, long guid, int quantity)
        {
            if (m_caseItems.ContainsKey(guid))
            {
                var item = entity.Inventory.Items.Find(entry => entry.Id == guid);
                if (quantity >= m_caseItems[guid])
                {
                    quantity = m_caseItems[guid];
                    m_caseItems.Remove(guid);
                }
                else
                {
                    m_caseItems[guid] -= quantity;
                }
                m_templateQuantity[item.TemplateId] -= quantity;
                if (m_templateQuantity[item.TemplateId] == 0)
                {
                    m_templateQuantity.Remove(item.TemplateId);
                }

                CheckCraftable();

                var exists = m_caseItems.ContainsKey(guid);
                Character.Dispatch(WorldMessage.EXCHANGE_LOCAL_MOVEMENT(ExchangeMoveEnum.MOVE_OBJECT, OperatorEnum.OPERATOR_REMOVE, item.Id.ToString()));
                if (exists)
                {
                    Character.Dispatch(WorldMessage.EXCHANGE_LOCAL_MOVEMENT(ExchangeMoveEnum.MOVE_OBJECT, OperatorEnum.OPERATOR_ADD, item.Id.ToString() + '|' + m_caseItems[guid]));
                }

                return(quantity);
            }
            return(0);
        }
Exemple #22
0
            protected override void Process(WorldCommandContext context)
            {
                var characterName = context.TextCommandArgument.NextWord();
                var reason        = context.TextCommandArgument.NextWord();

                WorldService.Instance.AddMessage(() =>
                {
                    var character = EntityManager.Instance.GetCharacterByName(characterName);
                    if (character == null)
                    {
                        context.Character.SafeDispatch(WorldMessage.BASIC_CONSOLE_MESSAGE("Player not found."));
                        return;
                    }

                    if (character.Account.Power >= context.Character.Account.Power)
                    {
                        context.Character.SafeDispatch(WorldMessage.BASIC_CONSOLE_MESSAGE("This player is a god, god cannot be kicked. In addition, he will be noticed."));
                        character.SafeDispatch(WorldMessage.SERVER_ERROR_MESSAGE("Player " + context.Character.Name + " tried to kick you."));
                        return;
                    }

                    character.SafeKick(context.Character.Name, reason);
                    context.Character.SafeDispatch(WorldMessage.BASIC_CONSOLE_MESSAGE("Player kicked successfully."));
                });
            }
Exemple #23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="character"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public override bool Process(CharacterEntity character, Dictionary <string, string> parameters)
        {
            if (!character.CanGameAction(Action.GameActionTypeEnum.EXCHANGE))
            {
                character.Dispatch(WorldMessage.INFORMATION_MESSAGE(InformationTypeEnum.ERROR, InformationEnum.ERROR_YOU_ARE_AWAY));
                return(false);
            }

            var taxe = character.Bank.Items.GroupBy(item => item.TemplateId).Count();

            if (character.Inventory.Kamas < taxe)
            {
                if (character.Bank.Kamas < taxe)
                {
                    character.Dispatch(WorldMessage.INFORMATION_MESSAGE(InformationTypeEnum.ERROR, InformationEnum.ERROR_NOT_ENOUGH_KAMAS, taxe));
                    return(false);
                }

                character.Bank.SubKamas(taxe);
            }
            else
            {
                character.Inventory.SubKamas(taxe);
            }

            character.CachedBuffer = true;
            character.ExchangeStorage(character.Bank);
            character.Dispatch(WorldMessage.IM_INFO_MESSAGE(InformationEnum.INFO_KAMAS_LOST, taxe));
            character.CachedBuffer = false;

            return(true);
        }
Exemple #24
0
            protected override void Process(WorldCommandContext context)
            {
                string characterName = context.TextCommandArgument.NextWord();

                WorldService.Instance.AddMessage(() =>
                {
                    var character = EntityManager.Instance.GetCharacterByName(characterName);
                    if (character == null)
                    {
                        context.Character.SafeDispatch(WorldMessage.BASIC_CONSOLE_MESSAGE("Player not found."));
                        return;
                    }

                    var mapId  = character.MapId;
                    var cellId = character.CellId;

                    context.Character.AddMessage(() =>
                    {
                        if (!context.Character.CanGameAction(Game.Action.GameActionTypeEnum.MAP_TELEPORT))
                        {
                            context.Character.Dispatch(WorldMessage.BASIC_CONSOLE_MESSAGE("Unable to teleport yourself in your actual state."));
                            return;
                        }

                        context.Character.Teleport(mapId, cellId);
                    });
                });
            }
Exemple #25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="client"></param>
        /// <param name="character"></param>
        private void CharacterDeletionExecute(WorldClient client, CharacterDAO character)
        {
            if (!CharacterRepository.Instance.Delete(character))
            {
                client.Send(WorldMessage.CHARACTER_DELETION_ERROR());
                return;
            }

            if (character.Guild.GuildId != -1)
            {
                var guild = GuildManager.Instance.GetGuild(character.Guild.GuildId);
                guild.MemberKick(GuildManager.Instance.GetMember(character.Guild.GuildId, character.Id), character.Name);
            }

            InventoryItemRepository.Instance.EntityRemoved((int)EntityTypeEnum.TYPE_CHARACTER, character.Id);
            InventoryItemRepository.Instance.EntityRemoved((int)EntityTypeEnum.TYPE_MERCHANT, character.Id);
            CharacterWaypointRepository.Instance.RemoveAll(character.Id);

            CharacterGuildRepository.Instance.ImplicitDeletion(character.Guild);
            CharacterAlignmentRepository.Instance.ImplicitDeletion(character.Alignment);
            foreach (var job in CharacterJobRepository.Instance.GetByCharacterId(character.Id))
            {
                CharacterJobRepository.Instance.ImplicitDeletion(job);
            }

            client.Characters.Remove(character);

            client.Send(WorldMessage.CHARACTER_LIST(client.Characters));
        }
Exemple #26
0
            protected override void Process(WorldCommandContext context)
            {
                int level;

                if (Int32.TryParse(context.TextCommandArgument.NextWord(), out level))
                {
                    if (level > context.Character.Level)
                    {
                        while (level > context.Character.Level)
                        {
                            context.Character.LevelUp();
                        }

                        context.Character.Dispatch(WorldMessage.CHARACTER_NEW_LEVEL(context.Character.Level));
                        context.Character.Dispatch(WorldMessage.SPELLS_LIST(context.Character.SpellBook));
                        context.Character.Dispatch(WorldMessage.ACCOUNT_STATS(context.Character));
                        context.Character.Dispatch(WorldMessage.BASIC_CONSOLE_MESSAGE("You are now level " + level));
                    }
                    else
                    {
                        context.Character.Dispatch(WorldMessage.BASIC_CONSOLE_MESSAGE("New level should be higher than yours"));
                    }
                }
                else
                {
                    context.Character.Dispatch(WorldMessage.BASIC_CONSOLE_MESSAGE("Command format : character levelup %level%"));
                }
            }
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public virtual bool Validate(AbstractEntity entity)
        {
            m_validated[entity.Id] = m_validated[entity.Id] == false; // inverse de la valeur actuelle

            base.Dispatch(WorldMessage.EXCHANGE_VALIDATE(entity.Id, m_validated[entity.Id]));

            if (m_validated.All(entry => entry.Value))
            {
                foreach (var kv in m_exchangedItems[m_local.Id])
                {
                    m_distant.Inventory.AddItem(m_local.Inventory.RemoveItem(kv.Key, kv.Value));
                }
                foreach (var kv in m_exchangedItems[m_distant.Id])
                {
                    m_local.Inventory.AddItem(m_distant.Inventory.RemoveItem(kv.Key, kv.Value));
                }

                m_local.Inventory.SubKamas(m_exchangedKamas[m_local.Id]);
                m_distant.Inventory.SubKamas(m_exchangedKamas[m_distant.Id]);
                m_local.Inventory.AddKamas(m_exchangedKamas[m_distant.Id]);
                m_distant.Inventory.AddKamas(m_exchangedKamas[m_local.Id]);

                return(true);
            }

            return(false);
        }
Exemple #28
0
            protected override void Process(WorldCommandContext context)
            {
                int templateId;

                if (Int32.TryParse(context.TextCommandArgument.NextWord(), out templateId))
                {
                    var itemTemplate = ItemTemplateRepository.Instance.GetById(templateId);
                    if (itemTemplate != null)
                    {
                        int quantity = 1;
                        if (!int.TryParse(context.TextCommandArgument.NextWord(), out quantity) || quantity == templateId)
                        {
                            quantity = 1;
                        }

                        var instance = itemTemplate.Create(quantity, ItemSlotEnum.SLOT_INVENTORY, true);
                        if (instance != null)
                        {
                            context.Character.Inventory.AddItem(instance);
                            context.Character.Dispatch(WorldMessage.BASIC_CONSOLE_MESSAGE(
                                                           String.Format("Item {0} added in your inventory", itemTemplate.Name)
                                                           ));
                        }
                    }
                    else
                    {
                        context.Character.Dispatch(WorldMessage.BASIC_CONSOLE_MESSAGE("Unknow templateId"));
                    }
                }
                else
                {
                    context.Character.Dispatch(WorldMessage.BASIC_CONSOLE_MESSAGE("Command format : character item %templateId%"));
                }
            }
Exemple #29
0
        /// <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);
        }
Exemple #30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="actionType"></param>
        public virtual void StartAction(GameActionTypeEnum actionType)
        {
            if (CurrentAction != null && CurrentAction.Type == actionType)
            {
                CurrentAction.Start();
            }

            switch (actionType)
            {
            case GameActionTypeEnum.MAP:
                Map.SpawnEntity(this);
                break;

            case GameActionTypeEnum.SKILL_HARVEST:
            case GameActionTypeEnum.MAP_MOVEMENT:
                MovementHandler.Dispatch(WorldMessage.GAME_ACTION(actionType, Id, CurrentAction.SerializeAs_GameAction()));
                break;

            case GameActionTypeEnum.MAP_TELEPORT:
                StopAction(GameActionTypeEnum.MAP);
                StopAction(GameActionTypeEnum.MAP_TELEPORT);
                // Switch back to world context
                WorldService.Instance.AddUpdatable(this);
                break;
            }
        }
Exemple #31
0
		static WorldMessage()
		{
			Turn = new WorldMessage(EType.TURN);
			MicroTurn = new WorldMessage(EType.MICRO_TURN);
			JustRedraw = new WorldMessage(EType.JUST_REDRAW);
			AvatarBeginsTurn = new WorldMessage(EType.AVATAR_BEGINS_TURN);
			AvatarMove = new WorldMessage(EType.AVATAR_MOVE);
			AvatarChangeLayer = new WorldMessage(EType.AVATAR_CHANGE_LAYER);
		}
 public void receiveMessage(WorldMessage message)
 {
     switch (message.type) {
     case WorldMessage.MessageType.USE_ABILITY:
         usingAbility.Add((Ability) message.content);
         break;
     default:
         break;
     }
 }
		public static void SendMessage(object _sender, WorldMessage _message)
		{
			var mess = NewWorldMessage;
			if (mess != null) mess(_sender, _message);
		}
Exemple #34
0
 public void OnMsgSystemEvent(MemoryStream stream)
 {
     MS2C_SystemEvent mS2C_SystemEvent = Serializer.NonGeneric.Deserialize(typeof(MS2C_SystemEvent), stream) as MS2C_SystemEvent;
     if (0 < mS2C_SystemEvent.EventType && mS2C_SystemEvent.EventType < 14)
     {
         if (this.SysEventMsgs.Count >= 20)
         {
             this.SysEventMsgs.RemoveAt(0);
         }
         WorldMessage worldMessage = new WorldMessage();
         worldMessage.SysEvent = mS2C_SystemEvent;
         this.SysEventMsgs.Add(worldMessage);
         this.OnSysMessageEvent(worldMessage);
         if (this.SysEventMessageEvent != null)
         {
             this.SysEventMessageEvent(worldMessage);
         }
     }
 }
Exemple #35
0
 public void PushGuildMessage(ChatMessage chatMsg)
 {
     if (this.WorldMsgs.Count >= 50)
     {
         this.WorldMsgs.RemoveAt(0);
     }
     WorldMessage worldMessage = new WorldMessage();
     worldMessage.Msg = chatMsg;
     this.WorldMsgs.Add(new WorldMessageExtend(worldMessage, true));
     if (!this.ShowChatWorldNewMark && chatMsg.PlayerID != this.Data.ID && chatMsg.TimeStamp > GameCache.Data.HasReadedWorldMsgTimeStamp)
     {
         this.ShowChatWorldNewMark = true;
     }
     if (this.OldWorldMessageEvent != null)
     {
         this.OldWorldMessageEvent(new WorldMessageExtend(worldMessage, false));
     }
 }
Exemple #36
0
 private void ParseWorldMessage(WorldMessage worldMsg, bool isSelf)
 {
     if (worldMsg.Msg != null)
     {
         this.ParseChatMessage(worldMsg.Msg, isSelf);
     }
 }
 public void TranslateMessage(WorldMessage message)
 {
 }
 public void ReceiveMessage(WorldMessage message)
 {
 }
Exemple #39
0
 private void OnSysMessageEvent(WorldMessage worldMsg)
 {
     if (worldMsg.SysEvent != null)
     {
         if (worldMsg.SysEvent.EventType == 1)
         {
             List<string> list = new List<string>();
             string item = this.mSb.Remove(0, this.mSb.Length).Append("[ce9f00]").Append(Singleton<StringManager>.Instance.GetString("chatTxt15")).Append("[-]").ToString();
             list.Add(item);
             list.Add(item);
             list.Add(item);
             GameUIManager.mInstance.ShowGameNewsMsg(list, worldMsg.SysEvent.Priority, 110, true);
             base.Invoke("QuitGame", 35f);
         }
         else if (worldMsg.SysEvent.EventType == 5)
         {
             string @string = Singleton<StringManager>.Instance.GetString("chatTxt18", new object[]
             {
                 worldMsg.SysEvent.StrValue,
                 worldMsg.SysEvent.IntValue[0]
             });
             GameUIManager.mInstance.ShowGameNew(@string, worldMsg.SysEvent.Priority, 110, true);
         }
         else if (worldMsg.SysEvent.EventType == 4)
         {
             string string2 = Singleton<StringManager>.Instance.GetString("chatTxt19", new object[]
             {
                 worldMsg.SysEvent.StrValue,
                 worldMsg.SysEvent.IntValue[0]
             });
             GameUIManager.mInstance.ShowGameNew(string2, worldMsg.SysEvent.Priority, 110, true);
         }
         else if (worldMsg.SysEvent.EventType == 2)
         {
             PetInfo info = Globals.Instance.AttDB.PetDict.GetInfo(worldMsg.SysEvent.IntValue[0]);
             if (info != null)
             {
                 string itemQualityColorHex = Tools.GetItemQualityColorHex(LocalPlayer.GetQuality(worldMsg.SysEvent.IntValue[2]));
                 string itemQualityColorHex2 = Tools.GetItemQualityColorHex(info.Quality);
                 string string3 = Singleton<StringManager>.Instance.GetString("chatTxt21", new object[]
                 {
                     worldMsg.SysEvent.StrValue,
                     itemQualityColorHex2,
                     Tools.GetPetName(info),
                     worldMsg.SysEvent.IntValue[1],
                     itemQualityColorHex
                 });
                 GameUIManager.mInstance.ShowGameNew(string3, worldMsg.SysEvent.Priority, 110, true);
             }
         }
         else if (worldMsg.SysEvent.EventType == 3)
         {
             PetInfo info2 = Globals.Instance.AttDB.PetDict.GetInfo(worldMsg.SysEvent.IntValue[0]);
             if (info2 != null)
             {
                 string itemQualityColorHex3 = Tools.GetItemQualityColorHex(LocalPlayer.GetQuality(worldMsg.SysEvent.IntValue[1]));
                 string itemQualityColorHex4 = Tools.GetItemQualityColorHex(info2.Quality);
                 string string4 = Singleton<StringManager>.Instance.GetString("chatTxt20", new object[]
                 {
                     worldMsg.SysEvent.StrValue,
                     itemQualityColorHex4,
                     Tools.GetPetName(info2),
                     itemQualityColorHex3
                 });
                 if (!worldMsg.SysEvent.StrValue.Equals(Globals.Instance.Player.Data.Name))
                 {
                     GameUIManager.mInstance.ShowGameNew(string4, worldMsg.SysEvent.Priority, 110, true);
                 }
             }
         }
         else if (worldMsg.SysEvent.EventType == 7)
         {
             PetInfo info3 = Globals.Instance.AttDB.PetDict.GetInfo(worldMsg.SysEvent.IntValue[0]);
             if (info3 != null)
             {
                 string itemQualityColorHex5 = Tools.GetItemQualityColorHex(LocalPlayer.GetQuality(worldMsg.SysEvent.IntValue[1]));
                 string itemQualityColorHex6 = Tools.GetItemQualityColorHex(info3.Quality);
                 string string5 = Singleton<StringManager>.Instance.GetString("chatTxt23", new object[]
                 {
                     worldMsg.SysEvent.StrValue,
                     itemQualityColorHex6,
                     Tools.GetPetName(info3),
                     itemQualityColorHex5
                 });
                 if (!worldMsg.SysEvent.StrValue.Equals(Globals.Instance.Player.Data.Name))
                 {
                     GameUIManager.mInstance.ShowGameNew(string5, worldMsg.SysEvent.Priority, 110, true);
                 }
             }
         }
         else if (worldMsg.SysEvent.EventType == 8)
         {
             PetInfo info4 = Globals.Instance.AttDB.PetDict.GetInfo(worldMsg.SysEvent.IntValue[0]);
             if (info4 != null)
             {
                 string itemQualityColorHex7 = Tools.GetItemQualityColorHex(LocalPlayer.GetQuality(worldMsg.SysEvent.IntValue[1]));
                 string itemQualityColorHex8 = Tools.GetItemQualityColorHex(info4.Quality);
                 string string6 = Singleton<StringManager>.Instance.GetString("chatTxt22", new object[]
                 {
                     worldMsg.SysEvent.StrValue,
                     itemQualityColorHex8,
                     Tools.GetPetName(info4),
                     itemQualityColorHex7
                 });
                 if (!worldMsg.SysEvent.StrValue.Equals(Globals.Instance.Player.Data.Name))
                 {
                     GameUIManager.mInstance.ShowGameNew(string6, worldMsg.SysEvent.Priority, 110, true);
                 }
             }
         }
         else if (worldMsg.SysEvent.EventType == 11)
         {
             LopetInfo info5 = Globals.Instance.AttDB.LopetDict.GetInfo(worldMsg.SysEvent.IntValue[0]);
             if (info5 != null)
             {
                 string itemQualityColorHex9 = Tools.GetItemQualityColorHex(LocalPlayer.GetQuality(worldMsg.SysEvent.IntValue[1]));
                 string itemQualityColorHex10 = Tools.GetItemQualityColorHex(info5.Quality);
                 string string7 = Singleton<StringManager>.Instance.GetString("chatTxt37", new object[]
                 {
                     worldMsg.SysEvent.StrValue,
                     itemQualityColorHex10,
                     info5.Name,
                     itemQualityColorHex9
                 });
                 GameUIManager.mInstance.ShowGameNew(string7, worldMsg.SysEvent.Priority, 110, true);
             }
         }
         else if (worldMsg.SysEvent.EventType == 12)
         {
             LopetInfo info6 = Globals.Instance.AttDB.LopetDict.GetInfo(worldMsg.SysEvent.IntValue[0]);
             if (info6 != null)
             {
                 string itemQualityColorHex11 = Tools.GetItemQualityColorHex(LocalPlayer.GetQuality(worldMsg.SysEvent.IntValue[2]));
                 string itemQualityColorHex12 = Tools.GetItemQualityColorHex(info6.Quality);
                 string string8 = Singleton<StringManager>.Instance.GetString("chatTxt38", new object[]
                 {
                     worldMsg.SysEvent.StrValue,
                     itemQualityColorHex12,
                     info6.Name,
                     worldMsg.SysEvent.IntValue[1],
                     itemQualityColorHex11
                 });
                 GameUIManager.mInstance.ShowGameNew(string8, worldMsg.SysEvent.Priority, 110, true);
             }
         }
         else if (worldMsg.SysEvent.EventType == 6)
         {
             if (worldMsg.SysEvent.IntValue[0] == 0)
             {
                 string string9 = Singleton<StringManager>.Instance.GetString("worldBossTxt23");
                 GameUIManager.mInstance.ShowGameNew(string9, worldMsg.SysEvent.Priority, 110, true);
             }
             else
             {
                 MonsterInfo info7 = Globals.Instance.AttDB.MonsterDict.GetInfo(worldMsg.SysEvent.IntValue[0]);
                 if (info7 != null)
                 {
                     string string10 = Singleton<StringManager>.Instance.GetString("worldBossTxt24", new object[]
                     {
                         info7.Name
                     });
                     GameUIManager.mInstance.ShowGameNew(string10, worldMsg.SysEvent.Priority, 110, true);
                 }
             }
         }
         else if (worldMsg.SysEvent.EventType == 9)
         {
             ItemInfo info8 = Globals.Instance.AttDB.ItemDict.GetInfo(worldMsg.SysEvent.IntValue[0]);
             if (info8 != null)
             {
                 string itemQualityColorHex13 = Tools.GetItemQualityColorHex(LocalPlayer.GetQuality(worldMsg.SysEvent.IntValue[1]));
                 string itemQualityColorHex14 = Tools.GetItemQualityColorHex(info8.Quality);
                 string string11 = Singleton<StringManager>.Instance.GetString("chatTxt29", new object[]
                 {
                     worldMsg.SysEvent.StrValue,
                     itemQualityColorHex14,
                     info8.Name,
                     itemQualityColorHex13
                 });
                 GameUIManager.mInstance.ShowGameNew(string11, worldMsg.SysEvent.Priority, 110, true);
             }
         }
     }
 }
Exemple #40
0
 private void PushChatMessage(ChatMessage chatMsg)
 {
     switch (chatMsg.Channel)
     {
     case 0:
     {
         if (this.WorldMsgs.Count >= 50)
         {
             this.WorldMsgs.RemoveAt(0);
         }
         WorldMessage worldMessage = new WorldMessage();
         worldMessage.Msg = chatMsg;
         this.WorldMsgs.Add(new WorldMessageExtend(worldMessage, false));
         if (!this.ShowChatWorldNewMark && chatMsg.PlayerID != this.Data.ID && chatMsg.TimeStamp > GameCache.Data.HasReadedWorldMsgTimeStamp)
         {
             this.ShowChatWorldNewMark = true;
         }
         if (this.WorldMessageEvent != null)
         {
             this.WorldMessageEvent(worldMessage);
         }
         break;
     }
     case 1:
         if (this.GuildMsgs.Count >= 50)
         {
             this.GuildMsgs.RemoveAt(0);
         }
         this.GuildMsgs.Add(chatMsg);
         if (this.GuildSystem != null && this.GuildSystem.HasGuild() && !this.ShowChatGuildNewMark && chatMsg.PlayerID != this.Data.ID && chatMsg.TimeStamp > GameCache.Data.HasReadedGuildMsgTimeStamp)
         {
             this.ShowChatGuildNewMark = true;
             if (!chatMsg.Voice && !this.IsAllEmotion(chatMsg))
             {
                 this.ShowGuildWarNewMark = true;
             }
         }
         if (this.ChatMessageEvent != null)
         {
             this.ChatMessageEvent(chatMsg);
         }
         break;
     case 2:
         if (this.WhisperMsgs.Count >= 50)
         {
             this.WhisperMsgs.RemoveAt(0);
         }
         this.WhisperMsgs.Add(chatMsg);
         if (!this.ShowChatWisperNewMark && chatMsg.PlayerID != this.Data.ID && chatMsg.TimeStamp > GameCache.Data.HasReadedSiLiaoMsgTimeStamp)
         {
             this.ShowChatWisperNewMark = true;
         }
         if (this.ChatMessageEvent != null)
         {
             this.ChatMessageEvent(chatMsg);
         }
         break;
     case 3:
         if (this.CostumePartyMsgs.Count >= 50)
         {
             this.CostumePartyMsgs.RemoveAt(0);
         }
         this.CostumePartyMsgs.Add(chatMsg);
         if (!this.ShowChatPartyNewMark && chatMsg.PlayerID != this.Data.ID && (!GameSetting.Data.ShieldPartyInvite || chatMsg.Type != 1u) && (!GameSetting.Data.ShieldPartyInteraction || chatMsg.Type != 2u) && chatMsg.TimeStamp > GameCache.Data.HasReadedWuHuiMsgTimeStamp)
         {
             this.ShowChatPartyNewMark = true;
         }
         if (this.ChatMessageEvent != null)
         {
             this.ChatMessageEvent(chatMsg);
         }
         break;
     default:
         global::Debug.LogError(new object[]
         {
             "chat message channel error!"
         });
         break;
     }
 }
 public WorldMessageExtend(WorldMessage wM, bool issystem)
 {
     this.mWM = wM;
     this.mIsSystem = issystem;
 }
Exemple #42
0
 private void OnWorldMessageEvent(WorldMessage worldMsg)
 {
     if (worldMsg.Msg != null)
     {
         this.mGUIChatMessageLayer.AddWorldMsg(new WorldMessageExtend(worldMsg, false), false);
         this.mGUIChatMessageLayer.Refresh();
         this.RefreshTabNewMarks();
     }
 }