Exemplo n.º 1
0
        public override void OnUserChat(RoomInstance Instance, RoomActor Actor, string MessageText, bool Shout)
        {
            if (mSelfActor == null || Actor.Type == RoomActorType.AiBot || mServingItemId > 0 ||
                (Distance.Calculate(Actor.Position.GetVector2(), mSelfActor.Position.GetVector2()) > mSelfBot.ResponseDistance))
            {
                return;
            }

            BotResponse Response = mSelfBot.GetResponseForMessage(MessageText);

            if (Response != null)
            {
                mSelfActor.Chat(Response.GetResponse(), false);

                if (Response.ResponseServeId > 0)
                {
                    mMovingToServePos = true;
                    mServingItemId = Response.ResponseServeId;
                    mServingActorId = Actor.Id;
                    mActorServePos = new Vector2(mSelfActor.Position.X, mSelfActor.Position.Y);

                    mSelfActor.MoveTo(mSelfBot.ServePosition);

                    if (mNextMovementAttempt < 50)
                    {
                        mNextMovementAttempt = 50;
                    }
                }

                if (mNextSpeechAttempt < 50)
                {
                    mNextSpeechAttempt += 10;
                }
            }
        }
Exemplo n.º 2
0
        public override void OnSelfLeaveRoom(RoomInstance Instance)
        {
            if (mSelfActor == null)
            {
                return;
            }

            mSelfActor = null;
        }
Exemplo n.º 3
0
        public override void OnSelfLeaveRoom(RoomInstance Instance)
        {
            if (mSelfActor == null)
            {
                return;
            }

            //mSelfActor.Chat("*leaves*", false);
            mSelfActor = null;
        }
Exemplo n.º 4
0
 public static bool ExecuteTaxi(Session Session, RoomActor Actor, uint RoomID, System.Timers.Timer Timer)
 {
     Timer.Dispose();
             Timer.Stop();
             if (Session.CharacterInfo.Dead != 1 && Session.CharacterInfo.Jailed != 1)
             {
                 using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                 {
                     Session.CharacterInfo.SetHomeRoom(MySqlClient, RoomID);
                     RoomHandler.PrepareRoom(Session, RoomID, null, true);
                 }
             }
             return true;
 }
Exemplo n.º 5
0
        public override void OnSelfEnterRoom(RoomInstance Instance)
        {
            mSelfActor = Instance.GetActorByReferenceId(mSelfBot.Id, RoomActorType.AiBot);

            if (mSelfActor == null)
            {
                return;
            }

            mCurrentAction = PetBotAction.Idle;
            mActionStartedTimestamp = UnixTimestamp.GetCurrent();
            mGstTimestamp = UnixTimestamp.GetCurrent();

            RespondToEvent("SEE_OWNER");
        }
Exemplo n.º 6
0
        public override void OnUserChat(RoomInstance Instance, RoomActor Actor, string MessageText, bool Shout)
        {
            string Message = MessageText.ToLower().Trim();
            string PetName = mSelfBot.PetData.Name.ToLower();

            if (mSelfActor == null || mSelfBot.PetData.OwnerId != Actor.ReferenceId || Actor.Type !=
                RoomActorType.UserCharacter || !Message.StartsWith(PetName + " ") || Message.Length <= PetName.Length)
            {
                return;
            }

            if (mSelfBot.PetData.Energy < 20)
            {
                mSelfActor.SetStatus("gst", "hng");
                RespondToEvent("TIRED");
                return;
            }

            if (mSelfBot.PetData.Happiness < 20)
            {
                mSelfActor.SetStatus("gst", "sad");
                RespondToEvent("UNHAPPY");
                return;
            }

            int SkipLength = PetName.Length + 1;
            string Command = MessageText.Substring(SkipLength, MessageText.Length - SkipLength).ToLower().Trim();

            switch (Command)
            {
                case "free":

                    mSelfActor.ClearStatusses();
                    mSelfActor.Chat("All statusses cleared");
                    break;

                default:

                    mSelfActor.SetStatus(Command.ToLower());
                    mSelfActor.Chat("Effect applied: " + Command.ToLower());
                    mSelfActor.UpdateNeeded = true;
                    break;
            }
        }
Exemplo n.º 7
0
        public override void OnSelfEnterRoom(RoomInstance Instance)
        {
            mSelfActor = Instance.GetActorByReferenceId(mSelfBot.Id, RoomActorType.AiBot);

            if (mSelfActor == null)
            {
                return;
            }

            mNeedsRotation = false;
            mNextSpeechAttempt = RandomGenerator.GetNext(20, 255);
            mNextMovementAttempt = RandomGenerator.GetNext(20, 255);
            mServingItemId = 0;
            mServingActorId = 0;
            mMovingToServePos = false;
            mActorServePos = null;

            if (mSelfBot.Rotation >= 0)
            {
                mSelfActor.BodyRotation = mSelfBot.Rotation;
                mSelfActor.HeadRotation = mSelfBot.Rotation;
            }
        }
Exemplo n.º 8
0
        public void BroadcastChatMessage(RoomActor Actor, string MessageText, bool Shout, int EmotionId)
        {
            lock (mActorSyncRoot)
            {
                foreach (RoomActor _Actor in mActors.Values)
                {
                    ServerMessage Message = RoomChatComposer.Compose(Actor.Id, MessageText, EmotionId, Shout ? ChatType.Shout
                        : ChatType.Say);

                    if (_Actor.Type == RoomActorType.UserCharacter)
                    {
                        Session ActorSession = SessionManager.GetSessionByCharacterId(_Actor.ReferenceId);

                        if (ActorSession == null || (Actor.Type == RoomActorType.UserCharacter && ActorSession.IgnoreCache.UserIsIgnored(Actor.ReferenceId)))
                        {
                            continue;
                        }

                        ActorSession.SendData(Message);
                    }
                }

                foreach (RoomActor _Actor in mActors.Values)
                {
                    if (_Actor.Type == RoomActorType.AiBot)
                    {
                        if (Actor.Id == _Actor.Id)
                        {
                            continue;
                        }

                        ((Bot)_Actor.ReferenceObject).Brain.OnUserChat(this, Actor, MessageText, Shout);
                    }
                }
            }
        }
Exemplo n.º 9
0
        public bool HandleDeath(RoomActor Actor)
        {
            foreach (WiredData data in mWired.Values)
            {
                Item Item = mInstance.GetItem(data.ItemId);
                if (Item.Definition.Behavior == ItemBehavior.WiredTrigger && WiredTypesUtil.TriggerFromInt(Item.Definition.BehaviorData) == WiredTriggerTypes.on_death)
                {
                    Item.DisplayFlags = "1";
                    Item.BroadcastStateUpdate(mInstance);
                    Item.DisplayFlags = "";
                    Item.RequestUpdate(4);

                    ExecuteActions(Item, Actor);
                    return true;
                }
            }
            return false;
        }
Exemplo n.º 10
0
        public bool HandleChat(String Message, RoomActor Actor)
        {
            Boolean doneAction = false;
            foreach (WiredData data in mWired.Values)
            {
                Item Item = mInstance.GetItem(data.ItemId);
                if (Item.Definition.Behavior == ItemBehavior.WiredTrigger &&
                    WiredTypesUtil.TriggerFromInt(Item.Definition.BehaviorData) == WiredTriggerTypes.says_something &&
                    Message.ToLower().Contains(data.Data1.ToLower()) && (data.Data2 == 0 || data.Data2 == Actor.Id) && data.Data1 != ""
                    )
                {

                    Item.DisplayFlags = "1";
                    Item.BroadcastStateUpdate(mInstance);
                    Item.DisplayFlags = "2";
                    Item.RequestUpdate(4);

                    ExecuteActions(Item, Actor);
                    doneAction = true;
                }
            }
            return doneAction;
        }
Exemplo n.º 11
0
        public void ExecuteActions(Item Item, RoomActor Actor)
        {
            try
            {
                Random rnd = new Random();
                foreach (Item ActionItem in mInstance.GetItemsOnPosition(Item.RoomPosition.GetVector2()))
                {
                    if (ActionItem.Definition.Behavior == ItemBehavior.WiredEffect)
                    {
                        ActionItem.DisplayFlags = "1";
                        ActionItem.BroadcastStateUpdate(mInstance);
                        ActionItem.DisplayFlags = "2";
                        ActionItem.RequestUpdate(4);
                        Session Session = null;
                        if (Actor != null)
                        {
                            Session = SessionManager.GetSessionByCharacterId(Actor.ReferenceId);
                        }
                        RoomInstance Instance = mInstance;
                        if (Actor != null)
                        {
                            Instance = RoomManager.GetInstanceByRoomId(Actor.CurrentRoomId);
                        }

                        int time = 0;
                        if (mWired[ActionItem.Id].Time != 0)
                        {
                            time = mWired[ActionItem.Id].Time * 100;
                            time = time % 2;
                            time = time * 10;
                        }

                        switch (WiredTypesUtil.EffectFromInt(ActionItem.Definition.BehaviorData))
                        {
                            #region reset_timer
                            case WiredEffectTypes.reset_timer:
                                // for every item in the room...
                                foreach (Item nItem in Instance.GetFloorItems())
                                {
                                    // if the item is a wired trigger
                                    if (nItem.Definition.Behavior == ItemBehavior.WiredTrigger)
                                    {
                                        //if the item is Trigger: At Set Time
                                        if (nItem.Definition.BehaviorData == 3)
                                        {
                                            //reset the timer
                                            nItem.RequestUpdate(nItem.WiredData.Data2);
                                        }
                                    }
                                }
                                break;
                            #endregion
                            #region give_clothes
                            case WiredEffectTypes.give_clothes:
                                if (Actor != null)
                                {
                                    string figure = Actor.Figure.ToString();
                                    int colorcode = 70;
                                    int Color = mWired[ActionItem.Id].Data2;
                                    if (Color == 1)
                                    {
                                        colorcode = 70;
                                    }
                                    else if (Color == 2)
                                    {
                                        colorcode = 85;
                                    }
                                    else if (Color == 3)
                                    {
                                        colorcode = 82;
                                    }
                                    else if (Color == 4)
                                    {
                                        colorcode = 1321;
                                    }
                                    if (Actor.Gender == Characters.CharacterGender.Male)
                                    {
                                        figure = "sh-290-" + colorcode + ".ch-215-" + colorcode + ".lg-275-" + colorcode + "";
                                    }
                                    else if (Actor.Gender == Characters.CharacterGender.Female)
                                    {
                                        figure = "sh-725-" + colorcode + ".ch-635-" + colorcode + ".lg-700-" + colorcode + "";
                                    }
                                    Instance.BroadcastMessage(UserInfoUpdateComposer.Compose(Actor.Id, FigToUniFig(Actor.Figure) + figure, Session.CharacterInfo.Gender, Actor.Motto, Session.CharacterInfo.Score));
                                    Session.CharacterInfo.NewFigure = FigToUniFig(Actor.Figure) + figure;
                                    Actor.NewFigure = FigToUniFig(Actor.Figure) + figure;
                                }
                                break;
                            #endregion
                            #region give_clothes_back
                            case WiredEffectTypes.give_clothes_back:
                                if (Actor == null)
                                {
                                    continue;
                                }
                                using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                                {
                                    DataRow Row2 = MySqlClient.ExecuteQueryRow("SELECT * FROM characters WHERE id = '" + Actor.ReferenceId + "'");
                                    string figure = (string)Row2["figure"];
                                    Instance.BroadcastMessage(UserInfoUpdateComposer.Compose(Actor.Id, figure, Session.CharacterInfo.Gender, Actor.Motto, Session.CharacterInfo.Score));
                                    Session.CharacterInfo.NewFigure = figure;
                                    Actor.NewFigure = figure;
                                }
                                break;
                            #endregion
                            #region show_message
                            case WiredEffectTypes.show_message:
                                if (Actor == null)
                                {
                                    continue;
                                }
                                System.Threading.Thread.Sleep(time);
                                Actor.Whisper(mWired[ActionItem.Id].Data1, 0, true);
                                break;
                            #endregion
                            #region move_rotate
                            case WiredEffectTypes.move_rotate:
                                if (ActionItem.WiredData.Data2 == 0 && ActionItem.WiredData.Data3 == 0)
                                {
                                    continue;
                                }
                                System.Threading.Thread.Sleep(time);
                                String[] ItemsToMove = ActionItem.WiredData.Data1.Split('|');
                                foreach (String toMove in ItemsToMove)
                                {
                                    uint ItemId;
                                    uint.TryParse(toMove, out ItemId);
                                    Item Move = mInstance.GetItem(ItemId);
                                    if (Move == null)
                                    {
                                        continue;
                                    }
                                    Vector2 NewPosition = new Vector2(Move.RoomPosition.X, Move.RoomPosition.Y);
                                    Vector2 OldPosition = new Vector2(Move.RoomPosition.X, Move.RoomPosition.Y);

                                    switch (ActionItem.WiredData.Data2)
                                    {
                                        case 1:
                                            switch (rnd.Next(1, 5))
                                            {
                                                case 1:
                                                    NewPosition = new Vector2(Move.RoomPosition.X - 1, Move.RoomPosition.Y);
                                                    break;
                                                case 2:
                                                    NewPosition = new Vector2(Move.RoomPosition.X + 1, Move.RoomPosition.Y);
                                                    break;

                                                case 3:
                                                    NewPosition = new Vector2(Move.RoomPosition.X, Move.RoomPosition.Y + 1);
                                                    break;

                                                case 4:
                                                    NewPosition = new Vector2(Move.RoomPosition.X, Move.RoomPosition.Y - 1);
                                                    break;
                                            }
                                            break;
                                        case 2:
                                            if (rnd.Next(0, 2) == 1)
                                            {
                                                NewPosition = new Vector2(Move.RoomPosition.X - 1, Move.RoomPosition.Y);
                                            }
                                            else
                                            {
                                                NewPosition = new Vector2(Move.RoomPosition.X + 1, Move.RoomPosition.Y);
                                            }

                                            break;
                                        case 3:
                                            if (rnd.Next(0, 2) == 1)
                                            {
                                                NewPosition = new Vector2(Move.RoomPosition.X, Move.RoomPosition.Y - 1);
                                            }
                                            else
                                            {
                                                NewPosition = new Vector2(Move.RoomPosition.X, Move.RoomPosition.Y + 1);
                                            }

                                            break;
                                        case 4:
                                            NewPosition = new Vector2(Move.RoomPosition.X, Move.RoomPosition.Y - 1);
                                            break;
                                        case 5:
                                            NewPosition = new Vector2(Move.RoomPosition.X + 1, Move.RoomPosition.Y);
                                            break;
                                        case 6:
                                            NewPosition = new Vector2(Move.RoomPosition.X, Move.RoomPosition.Y + 1);
                                            break;
                                        case 7:
                                            NewPosition = new Vector2(Move.RoomPosition.X - 1, Move.RoomPosition.Y);
                                            break;
                                    }

                                    int NewRotation = Move.RoomRotation;

                                    switch (ActionItem.WiredData.Data3)
                                    {
                                        case 1:
                                            NewRotation = NewRotation + 2;
                                            if (NewRotation == 8)
                                            {
                                                NewRotation = 0;
                                            }
                                            break;

                                        case 2:
                                            NewRotation = (NewRotation - 2);
                                            if (NewRotation == -2)
                                            {
                                                NewRotation = 6;
                                            }
                                            break;
                                        case 3:
                                            if (rnd.Next(0, 2) == 1)
                                            {
                                                goto case 1;
                                            }
                                            else
                                            {
                                                goto case 2;
                                            }
                                    }

                                    bool IsRotationOnly = (ActionItem.WiredData.Data2 == 0);
                                    Vector3 FinalizedPosition = mInstance.SetFloorItem(null, Move, NewPosition, NewRotation);
                                    Vector3 FinalizedOld = mInstance.SetFloorItem(null, Move, OldPosition, NewRotation);

                                    if (FinalizedPosition != null)
                                    {
                                        Move.MoveToRoom(null, mInstance.RoomId, FinalizedPosition, NewRotation, "");
                                        RoomManager.MarkWriteback(Move, false);

                                        mInstance.RegenerateRelativeHeightmap();
                                        mInstance.BroadcastMessage(RoomItemUpdatedComposer.Compose(Move));
                                        mInstance.BroadcastMessage(RollerEventComposer.Compose(FinalizedOld, FinalizedPosition, Item.Id, 0, Move.Id));
                                        ItemEventDispatcher.InvokeItemEventHandler(null, Move, mInstance, ItemEventType.Moved, IsRotationOnly ? 1 : 0);

                                    }
                                }
                                break;
                            #endregion
                            #region match_to_sshot
                            case WiredEffectTypes.match_to_sshot:
                                String[] Selected = ActionItem.WiredData.Data5.Split('+');
                                foreach (String FullData in Selected)
                                {
                                    System.Threading.Thread.Sleep(time);
                                    if (!FullData.Contains('#'))
                                    {
                                        continue;
                                    }

                                    String[] Data = FullData.Split('#');
                                    if (Data.Length != 4)
                                    {
                                        continue;
                                    }

                                    uint Id = uint.Parse(Data[0]);
                                    String[] Position = Data[1].Split('|');
                                    int Rotation = int.Parse(Data[2]);
                                    String Flags = Data[3];

                                    int X = int.Parse(Position[0]);
                                    int Y = int.Parse(Position[1]);
                                    uint Z = uint.Parse(Position[2]);

                                    Item AffectedItem = mInstance.GetItem(Id);

                                    if (AffectedItem == null)
                                    {
                                        continue;
                                    }

                                    Boolean IsRotationOnly = (X == AffectedItem.RoomPosition.X && Y == AffectedItem.RoomPosition.Y && Z == AffectedItem.RoomPosition.Z);

                                    Vector2 NewPosition = new Vector2(X, Y);
                                    Vector2 OldPosition = new Vector2(AffectedItem.RoomPosition.X, AffectedItem.RoomPosition.Y);

                                    if (ActionItem.WiredData.Data2 == 1)
                                    {
                                        AffectedItem.Flags = Flags;
                                        AffectedItem.DisplayFlags = Item.Flags;
                                        AffectedItem.BroadcastStateUpdate(mInstance);
                                    }

                                    if (ActionItem.WiredData.Data3 == 0)
                                    {
                                        Rotation = AffectedItem.RoomRotation;
                                    }

                                    if (ActionItem.WiredData.Data4 == 0)
                                    {
                                        NewPosition = AffectedItem.RoomPosition.GetVector2();
                                    }

                                    if (ActionItem.WiredData.Data4 == 1 || ActionItem.WiredData.Data3 == 1)
                                    {
                                        Vector3 FinalizedPosition = mInstance.SetFloorItem(null, AffectedItem, NewPosition, Rotation);
                                        AffectedItem.MoveToRoom(null, mInstance.RoomId, FinalizedPosition, Rotation, "");

                                        RoomManager.MarkWriteback(AffectedItem, false);

                                        mInstance.RegenerateRelativeHeightmap();
                                        mInstance.BroadcastMessage(RoomItemUpdatedComposer.Compose(AffectedItem));

                                        ItemEventDispatcher.InvokeItemEventHandler(null, AffectedItem, mInstance, ItemEventType.Moved, IsRotationOnly ? 1 : 0);
                                    }
                                    else if (ActionItem.WiredData.Data2 == 1)
                                    {
                                        RoomManager.MarkWriteback(AffectedItem, true);
                                    }
                                }
                                break;
                            #endregion
                            #region teleport_to_furni
                            case WiredEffectTypes.teleport_to:
                                if (Actor == null)
                                {
                                    continue;
                                }
                                System.Threading.Thread.Sleep(time);
                                String[] Selected2 = ActionItem.WiredData.Data1.Split('|');
                                String ItemIdS = Actor.FurniOnId.ToString();

                                while (Actor.FurniOnId.ToString() == ItemIdS)
                                {
                                    ItemIdS = Selected2[rnd.Next(0, Selected2.Length)];
                                }

                                uint ItemId2;
                                uint.TryParse(ItemIdS, out ItemId2);
                                Item AffectedItem2 = mInstance.GetItem(ItemId2);
                                if (AffectedItem2 == null)
                                {
                                    continue;
                                }
                                Actor.BlockWalking();
                                int OldEffect = Actor.AvatarEffectId;
                                Actor.ApplyEffect(4);
                                Actor.PositionToSet = AffectedItem2.RoomPosition.GetVector2();
                                Actor.MoveToPos(AffectedItem2.RoomPosition.GetVector2(), true, false, true);
                                Actor.UpdateNeeded = true;
                                Actor.UnblockWalking();
                                System.Threading.Thread.Sleep(1000);
                                Actor.ApplyEffect(OldEffect);
                                break;
                            #endregion
                            #region toggle_furni_state
                            case WiredEffectTypes.toggle_state:
                                String[] Selected3 = ActionItem.WiredData.Data1.Split('|');

                                System.Threading.Thread.Sleep(time);
                                foreach (String ItemIdS2 in Selected3)
                                {
                                    uint ItemId3;
                                    uint.TryParse(ItemIdS2, out ItemId3);
                                    Item AffectedItem3 = mInstance.GetItem(ItemId3);
                                    if (AffectedItem3 == null)
                                    {
                                        continue;
                                    }

                                    int CurrentState = 0;
                                    int.TryParse(AffectedItem3.Flags, out CurrentState);

                                    int NewState = CurrentState + 1;

                                    if (CurrentState < 0 || CurrentState >= (AffectedItem3.Definition.BehaviorData - 1))
                                    {
                                        NewState = 0;
                                    }
                                    if (AffectedItem3.Definition.Behavior == ItemBehavior.Fireworks)
                                    {
                                        int CurrentCharges = 0;
                                        int.TryParse(AffectedItem3.Flags, out CurrentCharges);
                                        if (AffectedItem3.DisplayFlags == "2")
                                        {
                                        }
                                        else if (CurrentCharges > 0)
                                        {
                                            AffectedItem3.DisplayFlags = "2";
                                            AffectedItem3.BroadcastStateUpdate(mInstance);

                                            AffectedItem3.Flags = (--CurrentCharges).ToString();
                                            RoomManager.MarkWriteback(AffectedItem3, true);

                                            AffectedItem3.RequestUpdate(AffectedItem3.Definition.BehaviorData);
                                        }
                                    }
                                    else if (AffectedItem3.Definition.Behavior == ItemBehavior.HoloDice || AffectedItem3.Definition.Behavior == ItemBehavior.Dice)
                                    {
                                        AffectedItem3.Flags = "-1";
                                        AffectedItem3.DisplayFlags = "-1";

                                        AffectedItem3.BroadcastStateUpdate(mInstance);
                                        AffectedItem3.RequestUpdate(3);
                                    }
                                    else if (AffectedItem3.Definition.Behavior == ItemBehavior.TraxPlayer)
                                    {
                                        if (mInstance.MusicController.IsPlaying)
                                        {
                                            mInstance.MusicController.Stop();
                                            mInstance.MusicController.BroadcastCurrentSongData(mInstance);
                                            AffectedItem3.DisplayFlags = "0";
                                            AffectedItem3.BroadcastStateUpdate(mInstance);
                                        }
                                        else
                                        {
                                            if (mInstance.MusicController.PlaylistSize > 0)
                                            {
                                                mInstance.MusicController.Start();
                                                AffectedItem3.DisplayFlags = "1";
                                                AffectedItem3.BroadcastStateUpdate(mInstance);
                                            }
                                            else
                                            {
                                                AffectedItem3.DisplayFlags = "0";
                                                AffectedItem3.BroadcastStateUpdate(mInstance);
                                            }
                                        }
                                    }
                                    else if (CurrentState != NewState)
                                    {
                                        AffectedItem3.Flags = NewState.ToString();
                                        AffectedItem3.DisplayFlags = AffectedItem3.Flags;

                                        RoomManager.MarkWriteback(AffectedItem3, true);

                                        AffectedItem3.BroadcastStateUpdate(mInstance);
                                    }
                                    Instance.WiredManager.HandleToggleState(Actor, AffectedItem3);
                                }
                                break;
                            #endregion
                        }
                    }
                }
            }
            catch (StackOverflowException e)
            {
                string text = System.IO.File.ReadAllText(Environment.CurrentDirectory + "\\error-log.txt");
                Output.WriteLine("Error in Wired Action: " + e.Message);
                System.IO.StreamWriter file = new System.IO.StreamWriter(Environment.CurrentDirectory + "\\error-log.txt");
                file.WriteLine(text + "Error in Wired Action: " + e.Message + "\n\n" + e.StackTrace,
                    OutputLevel.Notification + "\n\n");
            }
        }
Exemplo n.º 12
0
        private bool AddActorToRoom(RoomActor Actor)
        {
            lock (mActorSyncRoot)
            {
                if (mActors.ContainsKey(Actor.Id))
                {
                    return false;
                }

                mActors.Add(Actor.Id, Actor);
                BroadcastMessage(RoomUserObjectListComposer.Compose(new List<RoomActor>() { Actor }));
                MarkActorCountSyncNeeded();

                foreach (RoomActor _Actor in mActors.Values)
                {
                    if (_Actor.Type == RoomActorType.AiBot)
                    {
                        if (_Actor.Id == Actor.Id)
                        {
                            ((Bot)_Actor.ReferenceObject).Brain.OnSelfEnterRoom(this);
                        }
                        else
                        {
                            ((Bot)_Actor.ReferenceObject).Brain.OnUserEnter(this, Actor);
                        }
                    }
                    else if (_Actor.Type != RoomActorType.AiBot)
                    {
                        BroadcastMessage(UserInfoUpdateComposer.Compose(_Actor.Id, _Actor.Figure, _Actor.Gender, _Actor.Motto, _Actor.Score));
                        if (_Actor.Jailed == 1)
                        {
                            string figure_update = FigToUniFig(_Actor.Figure) + "ch-220-94.lg-280-94.sh-290-62";
                            BroadcastMessage(UserInfoUpdateComposer.Compose(_Actor.Id, figure_update, _Actor.Gender, "[JAILED] " + _Actor.Motto, _Actor.Score));
                        }
                        if (_Actor.Dead == 1)
                        {
                            BroadcastMessage(UserInfoUpdateComposer.Compose(_Actor.Id, _Actor.Figure, _Actor.Gender, "[DEAD] " + _Actor.Motto, _Actor.Score));
                        }
                        if (_Actor.Working == 1)
                        {
                            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                            {
                                DataRow Row1 = MySqlClient.ExecuteQueryRow("SELECT * FROM groups_details WHERE id = '" + _Actor.GroupId + "'");
                                DataRow Row2 = MySqlClient.ExecuteQueryRow("SELECT * FROM characters WHERE id = '" + _Actor.ReferenceId + "'");
                                DataRow Row3 = MySqlClient.ExecuteQueryRow("SELECT * FROM jobranks WHERE jobid = '" + _Actor.GroupId + "' AND rankid = '" + Row2["jobrank"] + "'");
                                int room_id = (int)Row1["roomid"];
                                string jobname = (string)Row1["name"] + " " + (string)Row3["name"];
                                string jobfig = (string)Row3["figure_data_" + _Actor.Gender.ToString()];

                                if (room_id == RoomId || room_id == 0)
                                {
                                    string figure_update = FigToUniFig(_Actor.Figure) + jobfig;
                                    if (jobfig == "")
                                    {
                                        figure_update = _Actor.Figure;
                                    }
                                    BroadcastMessage(UserInfoUpdateComposer.Compose(_Actor.Id, figure_update, _Actor.Gender, "[WORKING] " + jobname, _Actor.Score));
                                }
                                else
                                {
                                    DataRow Row4 = MySqlClient.ExecuteQueryRow("SELECT * FROM characters WHERE id = '" + Actor.ReferenceId + "'");
                                    string figure = (string)Row4["figure"];
                                    BroadcastMessage(UserInfoUpdateComposer.Compose(_Actor.Id, figure, _Actor.Gender, _Actor.Motto, _Actor.Score));
                                    _Actor.UpdateWorking(MySqlClient, 0);
                                }
                            }
                        }
                        WiredManager.HandleEnterRoom(_Actor);
                    }
                    return true;
                }
            }
            return true;
        }
Exemplo n.º 13
0
 public abstract void OnUserLeave(RoomInstance Instance, RoomActor Actor);
Exemplo n.º 14
0
 public abstract void OnUserEnter(RoomInstance Instance, RoomActor Actor);
Exemplo n.º 15
0
        public override void OnUserEnter(RoomInstance Instance, RoomActor Actor)
        {
            if (mSelfActor == null || Actor.Type == RoomActorType.AiBot)
            {
                return;
            }

            if (mSelfBot.Effect > 0)
            {
                mSelfActor.ApplyEffect(mSelfBot.Effect);
            }
        }
Exemplo n.º 16
0
        public void HandleToggleState(RoomActor Actor, Item TheItemChanged)
        {
            foreach (WiredData data in mWired.Values)
            {
                Item Item = mInstance.GetItem(data.ItemId);
                if (Item.Definition.Behavior == ItemBehavior.WiredTrigger && WiredTypesUtil.TriggerFromInt(Item.Definition.BehaviorData) == WiredTriggerTypes.state_changed)
                {
                    String[] Selected3 = Item.WiredData.Data1.Split('|');

                    foreach (String ItemIdS2 in Selected3)
                    {
                        uint ItemId3;
                        uint.TryParse(ItemIdS2, out ItemId3);
                        Item AffectedItem3 = mInstance.GetItem(ItemId3);
                        if (AffectedItem3 == null)
                        {
                            continue;
                        }
                        if (AffectedItem3 == TheItemChanged)
                        {
                            Item.DisplayFlags = "1";
                            Item.BroadcastStateUpdate(mInstance);
                            Item.DisplayFlags = "";
                            Item.RequestUpdate(4);

                            ExecuteActions(Item, Actor);
                        }
                    }
                }
            }
        }
Exemplo n.º 17
0
        public void HandleEnterRoom(RoomActor Actor)
        {
            foreach (WiredData data in mWired.Values)
            {
                Item Item = mInstance.GetItem(data.ItemId);
                if (Item.Definition.Behavior == ItemBehavior.WiredTrigger && WiredTypesUtil.TriggerFromInt(Item.Definition.BehaviorData) == WiredTriggerTypes.enter_room)
                {
                    if (data.Data1 != "" && data.Data1 != Actor.Name)
                    {
                        continue;
                    }

                    Item.DisplayFlags = "1";
                    Item.BroadcastStateUpdate(mInstance);
                    Item.DisplayFlags = "";
                    Item.RequestUpdate(4);

                    ExecuteActions(Item, Actor);
                }
            }
        }
Exemplo n.º 18
0
 public override void OnUserLeave(RoomInstance Instance, RoomActor Actor)
 {
     if (mSelfActor == null || Actor.Type == RoomActorType.AiBot)
     {
         return;
     }
 }
Exemplo n.º 19
0
 public override void OnUserLeave(RoomInstance Instance, RoomActor Actor)
 {
 }
Exemplo n.º 20
0
        public override void OnUserEnter(RoomInstance Instance, RoomActor Actor)
        {
            if (mSelfActor == null || Actor.ReferenceId != mSelfBot.PetData.OwnerId || Actor.Type != RoomActorType.UserCharacter
                || (mCurrentAction != PetBotAction.Idle && mCurrentAction != PetBotAction.Roaming))
            {
                return;
            }

            if (RandomGenerator.GetNext(0, 1) == 1)
            {
                RespondToEvent("SEE_OWNER");
            }
        }
Exemplo n.º 21
0
 public bool HandlePeriodicly(Item Item, RoomActor Actor)
 {
     uint ItemID = Item.Id;
     int time = mWired[ItemID].Data2 * 100;
     time = time % 2;
     time = time * 10;
     if (time == 0)
     {
         time = 500;
     }
     System.Timers.Timer dispatcherTimer = new System.Timers.Timer(time);
     dispatcherTimer.Interval = time;
     dispatcherTimer.Elapsed += delegate { ExecuteActions(Item, Actor); };
     dispatcherTimer.Start();
     return true;
 }
Exemplo n.º 22
0
 public abstract void OnUserChat(RoomInstance Instance, RoomActor Actor, string MessageText, bool Shout);
Exemplo n.º 23
0
        public void UpdateActorStatus(RoomActor Actor)
        {
            try
            {
                Vector2 Redirection = mRedirectGrid[Actor.Position.X, Actor.Position.Y];

                if (Redirection != null)
                {
                    Actor.Position = new Vector3(Redirection.X, Redirection.Y, GetUserStepHeight(Redirection));
                }

                RoomTileEffect Effect = mTileEffects[Actor.Position.X, Actor.Position.Y];

                if (Effect == null)
                {
                    return;
                }

                Dictionary<string, string> CurrentStatusses = Actor.UserStatusses;

                if (Effect.Type == RoomTileEffectType.Sit && !CurrentStatusses.ContainsKey("mv"))
                {
                    string OldStatus = (CurrentStatusses.ContainsKey("sit") ? CurrentStatusses["sit"] : string.Empty);
                    string NewStatus = Math.Round(Effect.InteractionHeight, 1).ToString().Replace(',', '.');

                    if (Actor.BodyRotation != Effect.Rotation)
                    {
                        Actor.BodyRotation = Effect.Rotation;
                        Actor.HeadRotation = Effect.Rotation;
                        Actor.UpdateNeeded = true;
                    }

                    if (NewStatus != OldStatus)
                    {
                        Actor.SetStatus("sit", NewStatus);
                        Actor.UpdateNeeded = true;
                    }
                }
                else if (CurrentStatusses.ContainsKey("sit"))
                {
                    Actor.RemoveStatus("sit");
                    Actor.UpdateNeeded = true;
                }

                if (Effect.Type == RoomTileEffectType.Lay && !CurrentStatusses.ContainsKey("mv"))
                {
                    string OldStatus = (CurrentStatusses.ContainsKey("lay") ? CurrentStatusses["lay"] : string.Empty);
                    string NewStatus = Math.Round(Effect.InteractionHeight, 1).ToString().Replace(',', '.');

                    if (Actor.BodyRotation != Effect.Rotation)
                    {
                        Actor.BodyRotation = Effect.Rotation;
                        Actor.HeadRotation = Effect.Rotation;
                        Actor.UpdateNeeded = true;
                    }

                    if (OldStatus != NewStatus)
                    {
                        Actor.SetStatus("lay", NewStatus);
                        Actor.UpdateNeeded = true;
                    }
                }
                else if (CurrentStatusses.ContainsKey("lay"))
                {
                    Actor.RemoveStatus("lay");
                    Actor.UpdateNeeded = true;
                }

                if (Effect.Type == RoomTileEffectType.Effect)
                {
                    if ((Actor.AvatarEffectId != Effect.EffectId || !Actor.AvatarEffectByItem))
                    {
                        Actor.ApplyEffect(Effect.EffectId, true, true);
                    }
                }
                else if (Actor.AvatarEffectByItem)
                {
                    int ClearEffect = 0;

                    if (Actor.Type == RoomActorType.UserCharacter)
                    {
                        Session SessionObject = SessionManager.GetSessionByCharacterId(Actor.ReferenceId);

                        if (SessionObject != null)
                        {
                            ClearEffect = SessionObject.CurrentEffect;
                        }
                    }
                    else
                    {
                        Bot BotObject = (Bot)Actor.ReferenceObject;

                        if (BotObject != null)
                        {
                            ClearEffect = BotObject.Effect;
                        }
                    }

                    Actor.ApplyEffect(ClearEffect, true, true);
                }

                if (Actor.Type == RoomActorType.UserCharacter && Effect.QuestData > 0)
                {
                    Session SessionObject = SessionManager.GetSessionByCharacterId(Actor.ReferenceId);

                    if (SessionObject != null)
                    {
                        QuestManager.ProgressUserQuest(SessionObject, QuestType.EXPLORE_FIND_ITEM, Effect.QuestData);
                    }
                }
            }
            catch (StackOverflowException e)
            {
                string text = System.IO.File.ReadAllText(Environment.CurrentDirectory + "\\error-log.txt");
                Output.WriteLine("Error in Pathfinder: " + e.Message);
                System.IO.StreamWriter file = new System.IO.StreamWriter(Environment.CurrentDirectory + "\\error-log.txt");
                file.WriteLine(text + "Error in Pathfinder: " + e.Message + "\n\n" + e.StackTrace,
                    OutputLevel.Notification + "\n\n");
            }
        }
Exemplo n.º 24
0
 public static bool HandleTaxi(Session Session, RoomActor Actor, uint RoomID, bool instant = false)
 {
     int time = RandomGenerator.GetNext(6, 40);
             time = time * 1000;
             if (instant)
             {
                 time = 1;
             }
             else
             {
                 SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient();
                 int newcoins = Session.CharacterInfo.CreditsBalance - 10;
                 Session.SendData(CreditsBalanceComposer.Compose(newcoins));
                 Session.CharacterInfo.UpdateCreditsBalance(MySqlClient, -10);
             }
             System.Timers.Timer dispatcherTimer = new System.Timers.Timer(time);
             dispatcherTimer.Interval = time;
             dispatcherTimer.Elapsed += delegate { ExecuteTaxi(Session, Actor, RoomID, dispatcherTimer); };
             dispatcherTimer.Start();
             return true;
 }