Ejemplo n.º 1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MoplaBreed" /> class.
 /// </summary>
 /// <param name="pet">The pet.</param>
 /// <param name="petId">The pet identifier.</param>
 /// <param name="rarity">The rarity.</param>
 /// <param name="moplaName">Name of the mopla.</param>
 /// <param name="breedData">The breed data.</param>
 /// <param name="liveState">State of the live.</param>
 /// <param name="growingStatus">The growing status.</param>
 internal MoplaBreed(Pet pet, uint petId, int rarity, string moplaName, string breedData, int liveState, int growingStatus)
 {
     _pet = pet;
     _petId = petId;
     _rarity = rarity;
     Name = moplaName;
     PlantData = breedData;
     LiveState = (MoplaState) liveState;
     GrowingStatus = growingStatus;
 }
Ejemplo n.º 2
0
        /// <summary>
        ///     Gets the random breeding terrier.
        /// </summary>
        /// <param name="pet">The pet.</param>
        /// <returns>Point.</returns>
        internal Point GetRandomBreedingTerrier(Pet pet)
        {
            if (!BreedingTerrier.Any())
                return new Point();
            var keys = new List<uint>(BreedingTerrier.Keys);
            var size = BreedingTerrier.Count;
            var rand = new Random();
            var randomKey = keys[rand.Next(size)];

            BreedingTerrier[randomKey].PetsList.Add(pet);
            pet.WaitingForBreading = BreedingTerrier[randomKey].Id;
            pet.BreadingTile = BreedingTerrier[randomKey].Coordinate;

            return BreedingTerrier[randomKey].Coordinate;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the pet commands.
        /// </summary>
        /// <param name="pet">The pet.</param>
        /// <returns>Dictionary&lt;System.Int16, System.Boolean&gt;.</returns>
        internal static Dictionary<short, bool> GetPetCommands(Pet pet)
        {
            var output = new Dictionary<short, bool>();
            var qLevel = (short)pet.Level;

            switch (pet.Type)
            {
                default:
                    /*
                    case 0: //Dog
                    case 1: //Cat
                    case 2: // croco
                    case 3: // terrier dog
                    case 4: // bear
                    case 5: // pig
                    case 6: // lion
                    case 7: // rhino
                    */
                    {
                        output.Add(0, true); // SIÉNTATE sit
                        output.Add(1, true); // DESCANSA free
                        output.Add(13, true); // A CASA
                        output.Add(2, qLevel >= 2); // TÚMBATE lay
                        output.Add(4, qLevel >= 3); // PIDE beg
                        output.Add(3, qLevel >= 4); // VEN AQUÍ comehere
                        output.Add(5, qLevel >= 4); // HAZ EL MUERTO play dead
                        output.Add(43, qLevel >= 5); // COMER
                        output.Add(14, qLevel >= 5); // BEBE
                        output.Add(6, qLevel >= 6); // QUIETO
                        output.Add(17, qLevel >= 6); // FÚTBOL
                        output.Add(8, qLevel >= 8); // LEVANTA
                        output.Add(7, qLevel >= 9); // SÍGUEME
                        output.Add(9, qLevel >= 11); // SALTA
                        output.Add(11, qLevel >= 11); // JUEGA
                        output.Add(12, qLevel >= 12); // CALLA
                        output.Add(10, qLevel >= 12); // HABLA
                        output.Add(15, qLevel >= 16); // IZQUIERDA
                        output.Add(16, qLevel >= 16); // DERECHA
                        output.Add(24, qLevel >= 17); // ADELANTE

                        if (pet.Type == 3 || pet.Type == 4)
                        {
                            output.Add(46, true);//Breed
                        }
                    }
                    break;

                case 8: // Spider
                    output.Add(1, true); // DESCANSA
                    output.Add(2, true); // TÚMBATE
                    output.Add(3, qLevel >= 2); // VEN AQUÍ
                    output.Add(17, qLevel >= 3); // FÚTBOL
                    output.Add(6, qLevel >= 4); // QUIETO
                    output.Add(5, qLevel >= 4); // HAZ EL MUERTO
                    output.Add(7, qLevel >= 5); // SÍGUEME
                    output.Add(23, qLevel >= 6); // ENCIENDE TV
                    output.Add(9, qLevel >= 7); // SALTA
                    output.Add(10, qLevel >= 8); // HABLA
                    output.Add(11, qLevel >= 8); // JUEGA
                    output.Add(24, qLevel >= 9); // ADELANTE
                    output.Add(15, qLevel >= 10); // IZQUIERDA
                    output.Add(16, qLevel >= 10); // DERECHA
                    output.Add(13, qLevel >= 12); // A CASA
                    output.Add(14, qLevel >= 13); // BEBE
                    output.Add(19, qLevel >= 14); // BOTA
                    output.Add(20, qLevel >= 14); // ESTATUA
                    output.Add(22, qLevel >= 15); // GIRA
                    output.Add(21, qLevel >= 16); // BAILA
                    break;

                case 16:
                    break;
            }

            return output;
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Gets the message.
        /// </summary>
        /// <param name="furniId">The furni identifier.</param>
        /// <param name="pet1">The pet1.</param>
        /// <param name="pet2">The pet2.</param>
        /// <returns>ServerMessage.</returns>
        internal static ServerMessage GetMessage(uint furniId, Pet pet1, Pet pet2)
        {
            var message = new ServerMessage(LibraryParser.OutgoingRequest("PetBreedMessageComposer"));

            message.AppendInteger(furniId);
            message.AppendInteger(pet1.PetId);
            message.AppendString(pet1.Name);
            message.AppendInteger(pet1.Level);
            message.AppendString(pet1.Look);
            message.AppendString(pet1.OwnerName);
            message.AppendInteger(pet2.PetId);
            message.AppendString(pet2.Name);
            message.AppendInteger(pet2.Level);
            message.AppendString(pet2.Look);
            message.AppendString(pet2.OwnerName);
            message.AppendInteger(4);

            message.AppendInteger(1);

            switch (pet1.Type)
            {
                case 3:
                    message.AppendInteger(TerrierEpicRace.Length);

                    foreach (var value in TerrierEpicRace)
                        message.AppendInteger(value);

                    break;

                case 4:
                    message.AppendInteger(BearEpicRace.Length);

                    foreach (var value in BearEpicRace)
                        message.AppendInteger(value);

                    break;
            }

            message.AppendInteger(2);

            switch (pet1.Type)
            {
                case 3:
                    message.AppendInteger(TerrierRareRace.Length);

                    foreach (var value in TerrierRareRace)
                        message.AppendInteger(value);

                    break;

                case 4:
                    message.AppendInteger(BearRareRace.Length);

                    foreach (var value in BearRareRace)
                        message.AppendInteger(value);

                    break;
            }

            message.AppendInteger(3);

            switch (pet1.Type)
            {
                case 3:
                    message.AppendInteger(TerrierNoRareRace.Length);

                    foreach (var value in TerrierNoRareRace)
                        message.AppendInteger(value);

                    break;

                case 4:
                    message.AppendInteger(BearNoRareRace.Length);

                    foreach (var value in BearNoRareRace)
                        message.AppendInteger(value);

                    break;
            }

            message.AppendInteger(94);

            switch (pet1.Type)
            {
                case 3:
                    message.AppendInteger(TerrierNormalRace.Length);

                    foreach (var value in TerrierNormalRace)
                        message.AppendInteger(value);

                    break;

                case 4:
                    message.AppendInteger(BearNormalRace.Length);

                    foreach (var value in BearNormalRace)
                        message.AppendInteger(value);

                    break;
            }

            message.AppendInteger((pet1.Type == 3) ? 25 : 24);

            return message;
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Gets the pet commands.
        /// </summary>
        /// <param name="pet">The pet.</param>
        /// <returns>Dictionary&lt;System.Int16, System.Boolean&gt;.</returns>
        internal static Dictionary<short, bool> GetPetCommands(Pet pet)
        {
            var output = new Dictionary<short, bool>();
            var qLevel = (short) pet.Level;

            switch (pet.Type)
            {
                case 0: // Cachorro
                case 1: // Gato
                case 2: // Crocodilo
                case 3: // Terrier
                case 4: // Urso
                case 5: // Porco
                case 6: // Leão
                case 7: // Rinoceronte
                    output.Add(0, true); // Sentar
                    output.Add(1, true); // Descansar
                    output.Add(13, true); // Deitar
                    output.Add(2, qLevel >= 2); // Deitar
                    output.Add(4, qLevel >= 3); // Pedir
                    output.Add(3, qLevel >= 4); // Seguir
                    output.Add(5, qLevel >= 4); // Fingir de Morto
                    output.Add(43, qLevel >= 5); // Comer
                    output.Add(14, qLevel >= 5); // Beber
                    output.Add(6, qLevel >= 6); // Silêncio
                    output.Add(17, qLevel >= 6); // Futebol
                    output.Add(8, qLevel >= 8); // Em pé
                    output.Add(7, qLevel >= 9); // Seguir
                    output.Add(9, qLevel >= 11); // Pular
                    output.Add(11, qLevel >= 11); // Brincar
                    output.Add(12, qLevel >= 12); // Quieto
                    output.Add(10, qLevel >= 12); // Falar
                    output.Add(15, qLevel >= 16); // Ir para Esquerda
                    output.Add(16, qLevel >= 16); // Ir para Direita
                    output.Add(24, qLevel >= 17); // Ir para Frente

                    if (pet.Type == 3 || pet.Type == 4)
                        output.Add(46, true); // Breed
                    break;

                case 8: // Aranha
                    output.Add(1, true); // Descansar
                    output.Add(2, true); // Teia
                    output.Add(3, qLevel >= 2); // Seguir
                    output.Add(17, qLevel >= 3); // Futebol
                    output.Add(6, qLevel >= 4); // Silêncio
                    output.Add(5, qLevel >= 4); // Fingir de Morto
                    output.Add(7, qLevel >= 5); // Seguir
                    output.Add(23, qLevel >= 6); // Botar Fogo
                    output.Add(9, qLevel >= 7); // Saltar
                    output.Add(10, qLevel >= 8); // Falar
                    output.Add(11, qLevel >= 8); // Jogar
                    output.Add(24, qLevel >= 9); // Ir para frente
                    output.Add(15, qLevel >= 10); // Ir para Esquerda
                    output.Add(16, qLevel >= 10); // Ir para Direita
                    output.Add(13, qLevel >= 12); // Ir para Casa
                    output.Add(14, qLevel >= 13); // Beber
                    output.Add(19, qLevel >= 14); // Botar
                    output.Add(20, qLevel >= 14); // Estátua
                    output.Add(22, qLevel >= 15); // Girar
                    output.Add(21, qLevel >= 16); // Dançar
                    break;

                case 16: // Que tipo é?
                    break;
            }

            return output;
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     Creates the pet.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="type">The type.</param>
        /// <param name="race">The race.</param>
        /// <param name="color">The color.</param>
        /// <param name="rarity">The rarity.</param>
        /// <returns>Pet.</returns>
        internal static Pet CreatePet(uint userId, string name, int type, string race, string color, int rarity = 0)
        {
            var pet = new Pet(404u, userId, 0u, name, (uint)type, race, color, 0, 100, 150, 0, Azure.GetUnixTimeStamp(),
                0, 0, 0.0, false, 0, 0, -1, rarity, DateTime.Now.AddHours(36.0), DateTime.Now.AddHours(48.0), null)
            {
                DbState = DatabaseUpdateState.NeedsUpdate
            };

            using (var queryReactor = Azure.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery(string.Concat("INSERT INTO bots (user_id,name, ai_type) VALUES (", pet.OwnerId,
                    ",@", pet.PetId, "name, 'pet')"));

                queryReactor.AddParameter($"{pet.PetId}name", pet.Name);

                pet.PetId = (uint)queryReactor.InsertQuery();

                queryReactor.SetQuery(
                    string.Concat(
                        "INSERT INTO pets_data (id,type,race,color,experience,energy,createstamp,rarity,lasthealth_stamp,untilgrown_stamp) VALUES (",
                        pet.PetId, ", ", pet.Type, ",@", pet.PetId, "race,@", pet.PetId,
                        "color,0,100,UNIX_TIMESTAMP(), ", rarity,
                        ", UNIX_TIMESTAMP(now() + INTERVAL 36 HOUR), UNIX_TIMESTAMP(now() + INTERVAL 48 HOUR))"));

                queryReactor.AddParameter($"{pet.PetId}race", pet.Race);
                queryReactor.AddParameter($"{pet.PetId}color", pet.Color);
                queryReactor.RunQuery();
            }

            if (pet.Type == 16u)
            {
                pet.MoplaBreed = MoplaBreed.CreateMonsterplantBreed(pet);
                pet.Name = pet.MoplaBreed.Name;
                pet.DbState = DatabaseUpdateState.NeedsUpdate;
            }

            var clientByUserId = Azure.GetGame().GetClientManager().GetClientByUserId(userId);

            if (clientByUserId != null)
                Azure.GetGame().GetAchievementManager().ProgressUserAchievement(clientByUserId, "ACH_PetLover", 1);

            return pet;
        }
Ejemplo n.º 7
0
        internal void AddPets(Pet bot)
        {
            _isUpdated = false;

            if (bot == null || _inventoryPets.Contains(bot.PetId))
                return;

            bot.RoomId = 0u;

            _inventoryPets.Add(bot.PetId, bot);
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     Adds the pet.
        /// </summary>
        /// <param name="pet">The pet.</param>
        internal void AddPet(Pet pet)
        {
            _isUpdated = false;

            if (pet == null || _inventoryPets.Contains(pet.PetId))
                return;

            pet.PlacedInRoom = false;
            pet.RoomId = 0u;

            _inventoryPets.Add(pet.PetId, pet);

            SerializePetInventory();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Deploys the bot.
        /// </summary>
        /// <param name="bot">The bot.</param>
        /// <param name="petData">The pet data.</param>
        /// <returns>RoomUser.</returns>
        internal RoomUser DeployBot(RoomBot bot, Pet petData)
        {
            var virtualId = _primaryPrivateUserId++;
            var roomUser = new RoomUser(0u, UserRoom.RoomId, virtualId, UserRoom, false);
            var num = _secondaryPrivateUserId++;
            roomUser.InternalRoomId = num;
            UserList.TryAdd(num, roomUser);
            OnUserAdd(roomUser);

            var model = UserRoom.GetGameMap().Model;
            var coord = new Point(bot.X, bot.Y);
            if ((bot.X > 0) && (bot.Y >= 0) && (bot.X < model.MapSizeX) && (bot.Y < model.MapSizeY))
            {
                UserRoom.GetGameMap().AddUserToMap(roomUser, coord);
                roomUser.SetPos(bot.X, bot.Y, bot.Z);
                roomUser.SetRot(bot.Rot, false);
            }
            else
            {
                bot.X = model.DoorX;
                bot.Y = model.DoorY;
                roomUser.SetPos(model.DoorX, model.DoorY, model.DoorZ);
                roomUser.SetRot(model.DoorOrientation, false);
            }

            bot.RoomUser = roomUser;
            roomUser.BotData = bot;

            roomUser.BotAI = bot.GenerateBotAI(roomUser.VirtualId, (int)bot.BotId);
            if (roomUser.IsPet)
            {
                roomUser.BotAI.Init(bot.BotId, roomUser.VirtualId, UserRoom.RoomId, roomUser, UserRoom);
                roomUser.PetData = petData;
                roomUser.PetData.VirtualId = roomUser.VirtualId;
            }
            else
            {
                roomUser.BotAI.Init(bot.BotId, roomUser.VirtualId, UserRoom.RoomId, roomUser, UserRoom);
            }

            UpdateUserStatus(roomUser, false);
            roomUser.UpdateNeeded = true;

            var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("SetRoomUserMessageComposer"));
            serverMessage.AppendInteger(1);
            roomUser.Serialize(serverMessage, UserRoom.GetGameMap().GotPublicPool);
            UserRoom.SendMessage(serverMessage);
            roomUser.BotAI.OnSelfEnterRoom();
            if (roomUser.IsPet)
            {
                if (_pets.Contains(roomUser.PetData.PetId))
                    _pets[roomUser.PetData.PetId] = roomUser;
                else
                    _pets.Add(roomUser.PetData.PetId, roomUser);

                PetCount++;
            }

            roomUser.BotAI.Modified();

            if (roomUser.BotData.AiType != AIType.Generic)
                return roomUser;

            if (_bots.Contains(roomUser.BotData.BotId))
                _bots[roomUser.BotData.BotId] = roomUser;
            else
                _bots.Add(roomUser.BotData.BotId, roomUser);

            serverMessage.Init(LibraryParser.OutgoingRequest("DanceStatusMessageComposer"));
            serverMessage.AppendInteger(roomUser.VirtualId);
            serverMessage.AppendInteger(roomUser.BotData.DanceId);
            UserRoom.SendMessage(serverMessage);
            PetCount++;

            return roomUser;
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Creates the monsterplant breed.
 /// </summary>
 /// <param name="pet">The pet.</param>
 /// <returns>MoplaBreed.</returns>
 internal static MoplaBreed CreateMonsterplantBreed(Pet pet)
 {
     if (pet.Type != 16)
         return null;
     Tuple<string, string> tuple = GeneratePlantData(pet.Rarity);
     var breed = new MoplaBreed(pet, pet.PetId, pet.Rarity, tuple.Item1, tuple.Item2, 0, 1);
     using (var adapter = AzureEmulator.GetDatabaseManager().GetQueryReactor())
     {
         adapter.SetQuery(
             "INSERT INTO pets_plants (pet_id, rarity, plant_name, plant_data) VALUES (@petid , @rarity , @plantname , @plantdata)");
         adapter.AddParameter("petid", pet.PetId);
         adapter.AddParameter("rarity", pet.Rarity);
         adapter.AddParameter("plantname", tuple.Item1);
         adapter.AddParameter("plantdata", tuple.Item2);
         adapter.RunQuery();
     }
     return breed;
 }