Exemplo n.º 1
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(28);
            EnterMessage.AppendInt32(1);
            BotUser.Serialize(EnterMessage, room.GetGameMap().gotPublicPool);
            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;
        }
Exemplo n.º 2
0
        internal RoomUser DeployBot(RoomBot Bot, Pet PetData)
        {
            DynamicRoomModel Model = room.GetGameMap().Model;

            RoomUser BotUser = new RoomUser(0, string.Empty, room.RoomId, primaryPrivateUserID++, room, false);
            BotUser.InternalRoomID = ++secondaryPrivateUserID;
            //this.UserList[PersonalID] = BotUser;
            userlist.Add(BotUser.InternalRoomID, BotUser);

            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(Bot.ownerID > 0 ? (int)Bot.BotId : -1, BotUser.VirtualId, room.RoomId, BotUser, room);
            }

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

            ServerMessage EnterMessage = PacketHandelingManager.GetRecycledItem(OutputCode.UsersMessageEvent);
            EnterMessage.AddInt32(1);
            BotUser.Serialize(EnterMessage);
            room.SendMessage(EnterMessage);

            BotUser.BotAI.OnSelfEnterRoom();

            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;
        }