public RespectPetNotificationMessageComposer(Pet Pet) : base(ServerPacketHeader.RespectPetNotificationMessageComposer) { //TODO: Structure base.WriteInteger(Pet.VirtualId); base.WriteInteger(Pet.VirtualId); base.WriteInteger(Pet.PetId);//Pet Id, 100% base.WriteString(Pet.Name); base.WriteInteger(0); base.WriteInteger(0); base.WriteString(Pet.Color); base.WriteInteger(0); base.WriteInteger(0);//Count - 3 ints. base.WriteInteger(1); }
public static Pet CreatePet(int UserId, string Name, int Type, string Race, string Color) { Pet pet = new Pet(0, UserId, 0, Name, Type, Race, Color, 0, 100, 100, 0, PlusEnvironment.GetUnixTimestamp(), 0, 0, 0.0, 0, 0, 0, -1, "-1"); using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("INSERT INTO bots (user_id,name, ai_type) VALUES (" + pet.OwnerId + ",@" + pet.PetId + "name, 'pet')"); dbClient.AddParameter(pet.PetId + "name", pet.Name); pet.PetId = Convert.ToInt32(dbClient.InsertQuery()); dbClient.SetQuery("INSERT INTO bots_petdata (id,type,race,color,experience,energy,createstamp) VALUES (" + pet.PetId + ", " + pet.Type + ",@" + pet.PetId + "race,@" + pet.PetId + "color,0,100,UNIX_TIMESTAMP())"); dbClient.AddParameter(pet.PetId + "race", pet.Race); dbClient.AddParameter(pet.PetId + "color", pet.Color); dbClient.RunQuery(); } return pet; }
public PetInformationComposer(Pet Pet) : base(ServerPacketHeader.PetInformationMessageComposer) { Room Room; if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Pet.RoomId, out Room)) return; base.WriteInteger(Pet.PetId); base.WriteString(Pet.Name); base.WriteInteger(Pet.Level); base.WriteInteger(Pet.MaxLevel); base.WriteInteger(Pet.experience); base.WriteInteger(Pet.experienceGoal); base.WriteInteger(Pet.Energy); base.WriteInteger(Pet.MaxEnergy); base.WriteInteger(Pet.Nutrition); base.WriteInteger(Pet.MaxNutrition); base.WriteInteger(Pet.Respect); base.WriteInteger(Pet.OwnerId); base.WriteInteger(Pet.Age); base.WriteString(Pet.OwnerName); base.WriteInteger(1);//3 on hab base.WriteBoolean(Pet.Saddle > 0); base.WriteBoolean(false); base.WriteInteger(0);//5 on hab base.WriteInteger(Pet.AnyoneCanRide); // Anyone can ride horse base.WriteInteger(0); base.WriteInteger(0);//512 on hab base.WriteInteger(0);//1536 base.WriteInteger(0);//2560 base.WriteInteger(0);//3584 base.WriteInteger(0); base.WriteString(""); base.WriteBoolean(false); base.WriteInteger(-1);//255 on hab base.WriteInteger(-1); base.WriteInteger(-1); base.WriteBoolean(false); }
public void InitPets() { using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `id`,`user_id`,`room_id`,`name`,`x`,`y`,`z` FROM `bots` WHERE `room_id` = '" + RoomId + "' AND `ai_type` = 'pet'"); DataTable Data = dbClient.getTable(); if (Data == null) return; foreach (DataRow Row in Data.Rows) { dbClient.SetQuery("SELECT `type`,`race`,`color`,`experience`,`energy`,`nutrition`,`respect`,`createstamp`,`have_saddle`,`anyone_ride`,`hairdye`,`pethair`,`gnome_clothing` FROM `bots_petdata` WHERE `id` = '" + Row[0] + "' LIMIT 1"); DataRow mRow = dbClient.getRow(); if (mRow == null) continue; Pet Pet = new Pet(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["user_id"]), Convert.ToInt32(Row["room_id"]), Convert.ToString(Row["name"]), Convert.ToInt32(mRow["type"]), Convert.ToString(mRow["race"]), Convert.ToString(mRow["color"]), Convert.ToInt32(mRow["experience"]), Convert.ToInt32(mRow["energy"]), Convert.ToInt32(mRow["nutrition"]), Convert.ToInt32(mRow["respect"]), Convert.ToDouble(mRow["createstamp"]), Convert.ToInt32(Row["x"]), Convert.ToInt32(Row["y"]), Convert.ToDouble(Row["z"]), Convert.ToInt32(mRow["have_saddle"]), Convert.ToInt32(mRow["anyone_ride"]), Convert.ToInt32(mRow["hairdye"]), Convert.ToInt32(mRow["pethair"]), Convert.ToString(mRow["gnome_clothing"])); var RndSpeechList = new List<RandomSpeech>(); _roomUserManager.DeployBot(new RoomBot(Pet.PetId, RoomId, "pet", "freeroam", Pet.Name, "", Pet.Look, Pet.X, Pet.Y, Convert.ToInt32(Pet.Z), 0, 0, 0, 0, 0, ref RndSpeechList, "", 0, Pet.OwnerId, false, 0, false, 0), Pet); } } }
public bool TryRemovePet(int PetId, out Pet PetItem) { if (this._petsItems.ContainsKey(PetId)) return this._petsItems.TryRemove(PetId, out PetItem); else { PetItem = null; return false; } }
public bool TryGetPet(int PetId, out Pet Pet) { if (this._petsItems.ContainsKey(PetId)) return this._petsItems.TryGetValue(PetId, out Pet); else { Pet = null; return false; } }
public bool TryAddPet(Pet Pet) { //TODO: Sort this mess. Pet.RoomId = 0; Pet.PlacedInRoom = false; return this._petsItems.TryAdd(Pet.PetId, Pet); }
public RoomUser DeployBot(RoomBot Bot, Pet PetData) { var BotUser = new RoomUser(0, _room.RoomId, primaryPrivateUserID++, _room); Bot.VirtualId = primaryPrivateUserID; int PersonalID = secondaryPrivateUserID++; BotUser.InternalRoomID = PersonalID; _users.TryAdd(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(Bot.BotId, BotUser.VirtualId, _room.RoomId, BotUser, _room); BotUser.PetData = PetData; BotUser.PetData.VirtualId = BotUser.VirtualId; } else BotUser.BotAI.Init(Bot.BotId, BotUser.VirtualId, _room.RoomId, BotUser, _room); //UpdateUserStatus(BotUser, false); BotUser.UpdateNeeded = true; _room.SendMessage(new UsersComposer(BotUser)); if (BotUser.IsPet) { if (_pets.ContainsKey(BotUser.PetData.PetId)) //Pet allready placed _pets[BotUser.PetData.PetId] = BotUser; else _pets.TryAdd(BotUser.PetData.PetId, BotUser); petCount++; } else if (BotUser.IsBot) { if (_bots.ContainsKey(BotUser.BotData.BotId)) _bots[BotUser.BotData.BotId] = BotUser; else _bots.TryAdd(BotUser.BotData.Id, BotUser); _room.SendMessage(new DanceComposer(BotUser, BotUser.BotData.DanceId)); } return BotUser; }