Beispiel #1
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;
            }
        }
Beispiel #2
0
        private static void TradeInitiate(Session Session, ClientMessage Message)
        {
            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

            if (Instance == null || !Instance.Info.CanTrade)
            {
                return;
            }

            RoomActor TargetActor = Instance.GetActor(Message.PopWiredUInt32());
            RoomActor SelfActor   = Instance.GetActorByReferenceId(Session.CharacterId);

            if (TargetActor == null || TargetActor.Type != RoomActorType.UserCharacter || SelfActor == null ||
                TargetActor.ReferenceId == SelfActor.ReferenceId)
            {
                return;
            }

            Session TargetSession = SessionManager.GetSessionByCharacterId(TargetActor.ReferenceId);

            if (TargetSession == null)
            {
                return;
            }

            if (!Instance.TradeManager.InitiateTrade(Session.CharacterId, TargetSession.CharacterId))
            {
                Session.SendData(RoomTradeCannotInitiate.Compose());
                return;
            }

            ServerMessage TradeInitiatedMessage = TradeInitiatedComposer.Compose(Session.CharacterId, Session.HasRight("trade"),
                                                                                 TargetSession.CharacterId, TargetSession.HasRight("trade"));

            Session.SendData(TradeInitiatedMessage);
            TargetSession.SendData(TradeInitiatedMessage);

            SelfActor.SetStatus("trd");
            SelfActor.UpdateNeeded = true;

            TargetActor.SetStatus("trd");
            TargetActor.UpdateNeeded = true;
        }