Ejemplo n.º 1
0
        public PetBot(int virtualID, Pet petData, Room room)
            : base(virtualID, room)
        {
            this.PetData = petData;
            this.RarityLevel = 0;
            this.HaveSaddle = false;
            this.IsMounted = false;

            // Initialize AI
            this.BaseAI = new PetAI(this);

            // Load data
            LoadFromPetData();
        }
Ejemplo n.º 2
0
        internal static Pet CreatePet(uint UserId, string Name, int Type, string Race, string Color)
        {
            Pet pet = new Pet(404, UserId, 0, Name, (uint)Type, Race, Color, 0, 100, 100, 0, FirewindEnvironment.GetUnixTimestamp(), 0, 0, 0.0, false);
            pet.DBState = DatabaseUpdateState.NeedsUpdate;

            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("INSERT INTO user_pets (user_id,name,type,race,color,expirience,energy,createstamp) VALUES (" + pet.OwnerId + ",@" + pet.PetId + "name," + pet.Type + ",@" + pet.PetId + "race,@" + pet.PetId + "color,0,100,'" + pet.CreationStamp + "')");
                dbClient.addParameter(pet.PetId + "name", pet.Name);
                dbClient.addParameter(pet.PetId + "race", pet.Race);
                dbClient.addParameter(pet.PetId + "color", pet.Color);
                pet.PetId = (uint)dbClient.insertQuery();
            }
            return pet;
        }
Ejemplo n.º 3
0
        internal void AddPet(Pet Pet)
        {
            isUpdated = false;
            if (Pet == null || InventoryPets.ContainsKey(Pet.PetId))
                return;

            Pet.PlacedInRoom = false;
            Pet.RoomId = 0;

            InventoryPets.Add(Pet.PetId, Pet);

            //using (DatabaseClient dbClient = FirewindEnvironment.GetDatabase().GetClient())
            //{
            //    dbClient.addParameter("botid", Pet.PetId);
            //    dbClient.runFastQuery("UPDATE user_pets SET room_id = 0, x = 0, y = 0, z = 0 WHERE id = @botid LIMIT 1");
            //}

            ServerMessage AddMessage = new ServerMessage(Outgoing.PetAddedToInventory);
            Pet.SerializeInventory(AddMessage);
            AddMessage.AppendBoolean(true); // ???
            GetClient().SendMessage(AddMessage);
            //UpdatePets(false);
        }
Ejemplo n.º 4
0
        internal RoomUser DeployBot(RoomBot Bot, Pet PetData)
        {
            RoomUser BotUser = new RoomUser(0, room.RoomId, primaryPrivateUserID++, room, false);
            int PersonalID = secondaryPrivateUserID++;
            BotUser.InternalRoomID = PersonalID;
            //this.UserList[PersonalID] = BotUser;
            userlist.Add(PersonalID, BotUser);
            DynamicRoomModel Model = room.GetGameMap().Model;

            if ((Bot.X > 0 && Bot.Y > 0) && Bot.X < Model.MapSizeX && Bot.Y < Model.MapSizeY)
            {
                BotUser.SetPos(Bot.X, Bot.Y, Bot.Z);
                BotUser.SetRot(Bot.Rot, false);
            }
            else
            {
                Bot.X = Model.DoorX;
                Bot.Y = Model.DoorY;

                BotUser.SetPos(Model.DoorX, Model.DoorY, Model.DoorZ);
                BotUser.SetRot(Model.DoorOrientation, false);
            }

            BotUser.BotData = Bot;
            BotUser.BotAI = Bot.GenerateBotAI(BotUser.VirtualId);

            if (BotUser.IsPet)
            {

                BotUser.BotAI.Init((int)Bot.BotId, BotUser.VirtualId, room.RoomId, BotUser, room);
                BotUser.PetData = PetData;
                BotUser.PetData.VirtualId = BotUser.VirtualId;
            }
            else
            {
                BotUser.BotAI.Init(-1, BotUser.VirtualId, room.RoomId, BotUser, room);
            }

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

            ServerMessage EnterMessage = new ServerMessage(Outgoing.PlaceBot);
            EnterMessage.AppendInt32(1);
            BotUser.Serialize(EnterMessage);
            room.SendMessage(EnterMessage);

            BotUser.BotAI.OnSelfEnterRoom();

            if (BotUser.BotData.AiType == AIType.Guide)
                room.guideBotIsCalled = true;
            if (BotUser.IsPet)
            {
                if (pets.ContainsKey(BotUser.PetData.PetId)) //Pet allready placed
                    pets[BotUser.PetData.PetId] = BotUser;
                else
                    pets.Add(BotUser.PetData.PetId, BotUser);

                petCount++;
            }

            return BotUser;
        }
Ejemplo n.º 5
0
 internal PetBot DeployPet(Pet pet)
 {
     PetBot bot = new PetBot(primaryPrivateUserID++, pet, room);
     UnitList.Add(bot.VirtualID, bot);
     return bot;
 }