Exemplo n.º 1
0
        public override void Perform(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);

            GameLiving actor = Q != null ? Q : player;

            foreach (GamePlayer nearPlayer in actor.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
            {
                nearPlayer.Out.SendEmoteAnimation(actor, P);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Checks the trigger, this method is called whenever a event associated with this questparts quest
        /// or a manualy associated eventhandler is notified.
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public override bool Check(DOLEvent e, object sender, EventArgs args)
        {
            bool result = false;

            if (e == GamePlayerEvent.AbortQuest)
            {
                GamePlayer     player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);
                QuestEventArgs qArgs  = (QuestEventArgs)args;
                result = (qArgs.Player.ObjectID == player.ObjectID && QuestMgr.GetQuestTypeForID(qArgs.QuestID).Equals(I));
            }

            return(result);
        }
        /// <summary>
        /// Checks the trigger, this method is called whenever a event associated with this questparts quest
        /// or a manualy associated eventhandler is notified.
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public override bool Check(DOLEvent e, object sender, EventArgs args)
        {
            bool result = false;

            if (e == GameLivingEvent.Timer)
            {
                GamePlayer     player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);
                TimerEventArgs tArgs  = (TimerEventArgs)args;
                result = K == tArgs.TimerID && tArgs.Source == player;
            }

            return(result);
        }
        /// <summary>
        /// Checks the added requirement whenever a trigger associated with this defaultNPC fires.(returns true)
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public override bool Check(DOLEvent e, object sender, EventArgs args)
        {
            bool       result = true;
            GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);

            //Dinberg on Instances:
            //I've changed this to skin. This is so that instances can cause zone
            //requirements on quests to be triggered too! It's unlikely they will
            //ever get the right ID otherwise.
            result = (player.CurrentRegion.Skin == V && player.CurrentZone.ZoneSkinID == N);

            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Checks the trigger, this method is called whenever a event associated with this questparts quest
        /// or a manualy associated eventhandler is notified.
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public override bool Check(DOLEvent e, object sender, EventArgs args)
        {
            bool       result = false;
            GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);

            if (e == AreaEvent.PlayerLeave)
            {
                AreaEventArgs aArgs = (AreaEventArgs)args;
                result |= aArgs.GameObject == player && I == aArgs.Area;
            }

            return(result);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Checks the trigger, this method is called whenever a event associated with this questparts quest
        /// or a manualy associated eventhandler is notified.
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public override bool Check(DOLEvent e, object sender, EventArgs args)
        {
            bool result = false;

            if (e == GameLivingEvent.EnemyKilled && sender == I)
            {
                GamePlayer           player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);
                EnemyKilledEventArgs gArgs  = (EnemyKilledEventArgs)args;
                result = gArgs.Target == player;
            }

            return(result);
        }
        /// <summary>
        /// Checks the trigger, this method is called whenever a event associated with this questparts quest
        /// or a manualy associated eventhandler is notified.
        /// </summary>
        /// <param name="e">DolEvent of notify call</param>
        /// <param name="sender">Sender of notify call</param>
        /// <param name="args">EventArgs of notify call</param>
        /// <returns>true if QuestPart should be executes, else false</returns>
        public override bool Check(DOLEvent e, object sender, EventArgs args)
        {
            bool       result = false;
            GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);

            if (e == GamePlayerEvent.ReceiveItem)
            {
                ReceiveItemEventArgs gArgs = (ReceiveItemEventArgs)args;

                result = (gArgs.Source == player && gArgs.Item.Name == I.Name);
            }

            return(result);
        }
Exemplo n.º 8
0
        public override void Perform(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer   player   = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);
            GameLocation location = P;
            int          radius   = Q;

            if (location.Name != null)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Behaviour.TeleportAction.TeleportedToLoc", player, location.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }

            location.Position += new Vector3(Util.Random(-radius, radius), Util.Random(-radius, radius), 0);
            player.MoveTo(location);
        }
Exemplo n.º 9
0
        public override void Perform(DOLEvent e, object sender, EventArgs args)
        {
            GameLiving npc = Q;

            if (P is GameLocation location)
            {
                npc.MoveTo(location);
            }
            else
            {
                GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);
                npc.MoveTo(player.CurrentRegionID, player.Position, player.Heading);
            }
        }
Exemplo n.º 10
0
        public override void Perform(DOLEvent e, object sender, EventArgs args)
        {
            GameLiving npc = Q;

            if (P is GameLocation)
            {
                GameLocation location = (GameLocation)P;
                npc.MoveTo(location.RegionID, location.X, location.Y, location.Z, location.Heading);
            }
            else
            {
                GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);
                npc.MoveTo(player.CurrentRegionID, player.X, player.Y, player.Z, (ushort)player.Heading);
            }
        }
        /// <summary>
        /// Checks the added requirement whenever a trigger associated with this defaultNPC fires.(returns true)
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public override bool Check(DOLEvent e, object sender, EventArgs args)
        {
            bool       result = true;
            GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);

            Group group      = player.Group;
            int   groupcount = 0;

            if (group != null)
            {
                groupcount = group.MemberCount;
            }
            result = compare(groupcount, N, Comparator);

            return(result);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Checks the added requirement whenever a trigger associated with this questpart fires.(returns true)
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public override bool Check(DOLEvent e, object sender, EventArgs args)
        {
            bool       result = true;
            GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);

            if (Comparator == eComparator.Not)
            {
                result = QuestMgr.CanGiveQuest(N, player, V) <= 0;
            }
            else
            {
                result = QuestMgr.CanGiveQuest(N, player, V) > 0;
            }

            return(result);
        }
        /// <summary>
        /// Checks the added requirement whenever a trigger associated with this defaultNPC fires.(returns true)
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public override bool Check(DOLEvent e, object sender, EventArgs args)
        {
            bool       result = true;
            GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);

            if (Comparator == eComparator.Not)
            {
                result = player.Race != N;
            }
            else
            {
                result = player.Race == N;
            }

            return(result);
        }
        /// <summary>
        /// Checks the trigger, this method is called whenever a event associated with this questparts quest
        /// or a manualy associated eventhandler is notified.
        /// </summary>
        /// <param name="e">DolEvent of notify call</param>
        /// <param name="sender">Sender of notify call</param>
        /// <param name="args">EventArgs of notify call</param>
        /// <returns>true if QuestPart should be executes, else false</returns>
        public override bool Check(DOLEvent e, object sender, EventArgs args)
        {
            bool       result = false;
            GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);

            if (e == GamePlayerEvent.UseSlot)
            {
                UseSlotEventArgs uArgs = (UseSlotEventArgs)args;
                InventoryItem    item  = player.Inventory.GetItem((eInventorySlot)uArgs.Slot) as InventoryItem;
                if (item != null && I != null)
                {
                    result = I.Name == item.Name;
                }
            }

            return(result);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Checks the added requirement whenever a trigger associated with this questpart fires.(returns true)
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public override bool Check(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);

            bool result;

            if (Comparator == eComparator.Not)
            {
                result = player.IsDoingQuest(N) == null;
            }
            else
            {
                result = player.IsDoingQuest(N) != null;
            }

            return(result);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Checks the trigger, this method is called whenever a event associated with this questparts quest
        /// or a manualy associated eventhandler is notified.
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public override bool Check(DOLEvent e, object sender, EventArgs args)
        {
            bool result = false;

            if (e == GamePlayerEvent.AcceptQuest)
            {
                GamePlayer     player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);
                QuestEventArgs qArgs  = (QuestEventArgs)args;
                Type           type   = QuestMgr.GetQuestTypeForID(qArgs.QuestID);
                if (type != null)
                {
                    result = qArgs.Player.ObjectID == player.ObjectID && type == I;
                }
            }

            return(result);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Send a message to player.  You can use &lt;Player&gt;, &lt;Class&gt;, &lt;Race&gt;, &lt;Guild&gt;, &lt;RealmTitle&gt;, &lt;Title&gt; to have text replaced with actual player values.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="msg"></param>
        /// <param name="delay"></param>
        /// <param name="chatType"></param>
        /// <param name="chatLoc"></param>
        protected static void SendMessage(GamePlayer player, string msg, uint delay, eChatType chatType, eChatLoc chatLoc)
        {
            msg = BehaviourUtils.GetPersonalizedMessage(msg, player);

            if (delay == 0)
            {
                player.Out.SendMessage(msg, chatType, chatLoc);
            }
            else
            {
                m_sayMessageQueue.Enqueue(msg);
                m_sayObjectQueue.Enqueue(player);
                m_sayChatLocQueue.Enqueue(chatLoc);
                m_sayChatTypeQueue.Enqueue(chatType);
                m_sayTimerQueue.Enqueue(new RegionTimer(player, new RegionTimerCallback(MakeSaySequence), (int)delay * 100));
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Checks the added requirement whenever a trigger associated with this defaultNPC fires.(returns true)
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public override bool Check(DOLEvent e, object sender, EventArgs args)
        {
            bool result = true;

            GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);

            if (V)
            {
                result = (player.CharacterClass.ID != N);
            }
            else
            {
                result = (player.CharacterClass.ID == N);
            }

            return(result);
        }
Exemplo n.º 19
0
        public override void Perform(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);

            ItemTemplate oldItem = P;
            ItemTemplate newItem = Q;

            // TODO: what about stacked items???
            if (player.Inventory.RemoveTemplate(oldItem.Id_nb, 1, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
            {
                InventoryLogging.LogInventoryAction(player, NPC, eInventoryActionType.Quest, oldItem, 1);
                InventoryItem inventoryItem = GameInventoryItem.Create(newItem);
                if (player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, inventoryItem))
                {
                    InventoryLogging.LogInventoryAction(NPC, player, eInventoryActionType.Quest, newItem, 1);
                }
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Checks the added requirement whenever a trigger associated with this questpart fires.(returns true)
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public override bool Check(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer    player      = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);
            AbstractQuest playerQuest = player.IsDoingQuest(N);

            bool result = true;

            if (playerQuest != null)
            {
                result &= compare(playerQuest.Step, V, Comparator);
            }
            else
            {
                result = false;
            }

            return(result);
        }
Exemplo n.º 21
0
        public override void Perform(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer player  = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);
            string     message = BehaviourUtils.GetPersonalizedMessage(P, player);

            switch (Q)
            {
            case eTextType.Dialog:
                player.Out.SendCustomDialog(message, null);
                break;

            case eTextType.Emote:
                player.Out.SendMessage(message, eChatType.CT_Emote, eChatLoc.CL_ChatWindow);
                break;

            case eTextType.Say:
                player.Out.SendMessage(message, eChatType.CT_Say, eChatLoc.CL_ChatWindow);
                break;

            case eTextType.SayTo:
                player.Out.SendMessage(message, eChatType.CT_System, eChatLoc.CL_PopupWindow);
                break;

            case eTextType.Yell:
                player.Out.SendMessage(message, eChatType.CT_Help, eChatLoc.CL_ChatWindow);
                break;

            case eTextType.Broadcast:
                foreach (GameClient clientz in WorldMgr.GetAllPlayingClients())
                {
                    clientz.Player.Out.SendMessage(message, eChatType.CT_Broadcast, eChatLoc.CL_ChatWindow);
                }

                break;

            case eTextType.Read:
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Behaviour.MessageAction.ReadMessage", message), eChatType.CT_Emote, eChatLoc.CL_PopupWindow);
                break;

            case eTextType.None:
                // nohting
                break;
            }
        }
Exemplo n.º 22
0
        public override void Perform(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);

            int     aggroAmount = P.HasValue ? P.Value : player.Level << 1;
            GameNPC attacker    = Q;

            if (attacker.Brain is IOldAggressiveBrain)
            {
                IOldAggressiveBrain brain = (IOldAggressiveBrain)attacker.Brain;
                brain.AddToAggroList(player, aggroAmount);
            }
            else
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Non agressive mob " + attacker.Name + " was order to attack player. This goes against the first directive and will not happen");
                }
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Checks the trigger, this method is called whenever a event associated with this questparts quest
        /// or a manualy associated eventhandler is notified.
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public override bool Check(DOLEvent e, object sender, EventArgs args)
        {
            bool result = false;

            GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);

            if (e == GameLivingEvent.EnemyKilled && sender == player)
            {
                EnemyKilledEventArgs gArgs = (EnemyKilledEventArgs)args;
                if (K != null)
                {
                    result = gArgs.Target.Name == K;
                }
                else
                {
                    result = gArgs.Target == I;
                }
            }

            return(result);
        }
Exemplo n.º 24
0
        public override void Perform(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer    player        = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);
            InventoryItem inventoryItem = GameInventoryItem.Create <ItemTemplate>(P as ItemTemplate);

            if (Q == null)
            {
                if (!player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, inventoryItem))
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Behaviour.GiveItemAction.GiveButInventFull", inventoryItem.GetName(0, false)), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                }
                else
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Behaviour.GiveItemAction.YouReceiveItem", inventoryItem.GetName(0, false)), eChatType.CT_Loot, eChatLoc.CL_SystemWindow);
                    InventoryLogging.LogInventoryAction(Q, player, eInventoryActionType.Quest, inventoryItem.Template, inventoryItem.Count);
                }
            }
            else
            {
                player.ReceiveItem(Q, inventoryItem);
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Checks the added requirement whenever a trigger associated with this defaultNPC fires.(returns true)
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public override bool Check(DOLEvent e, object sender, EventArgs args)
        {
            bool       result = true;
            GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);

            Group group      = player.Group;
            int   grouplevel = 0;

            if (group != null)
            {
                foreach (GamePlayer member in group.GetPlayersInTheGroup())
                {
                    grouplevel += member.Level;
                }
            }
            else
            {
                grouplevel += player.Level;
            }
            result = compare(grouplevel, N, Comparator);

            return(result);
        }
Exemplo n.º 26
0
        const ushort MAX_STORY_LENGTH = 1000;   // Via trial and error, 1.108 client.
                                                // Often will cut off text around 990 but longer strings do not result in any errors. -Tolakram

        protected override void SendQuestWindow(GameNPC questNPC, GamePlayer player, DataQuest quest, bool offer)
        {
            using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.Dialog)))
            {
                ushort QuestID = quest.ClientQuestID;
                pak.WriteShort((offer) ? (byte)0x22 : (byte)0x21);                 // Dialog
                pak.WriteShort(QuestID);
                pak.WriteShort((ushort)questNPC.ObjectID);
                pak.WriteByte(0x00);                              // unknown
                pak.WriteByte(0x00);                              // unknown
                pak.WriteByte(0x00);                              // unknown
                pak.WriteByte(0x00);                              // unknown
                pak.WriteByte((offer) ? (byte)0x02 : (byte)0x01); // Accept/Decline or Finish/Not Yet
                pak.WriteByte(0x01);                              // Wrap
                pak.WritePascalString(quest.Name);

                String personalizedSummary = BehaviourUtils.GetPersonalizedMessage(quest.Description, player);
                if (personalizedSummary.Length > 255)
                {
                    pak.WritePascalString(personalizedSummary.Substring(0, 255));                     // Summary is max 255 bytes or client will crash !
                }
                else
                {
                    pak.WritePascalString(personalizedSummary);
                }

                if (offer)
                {
                    String personalizedStory = BehaviourUtils.GetPersonalizedMessage(quest.Story, player);

                    if (personalizedStory.Length > MAX_STORY_LENGTH)
                    {
                        pak.WriteShort(MAX_STORY_LENGTH);
                        pak.WriteStringBytes(personalizedStory.Substring(0, MAX_STORY_LENGTH));
                    }
                    else
                    {
                        pak.WriteShort((ushort)personalizedStory.Length);
                        pak.WriteStringBytes(personalizedStory);
                    }
                }
                else
                {
                    if (quest.FinishText.Length > MAX_STORY_LENGTH)
                    {
                        pak.WriteShort(MAX_STORY_LENGTH);
                        pak.WriteStringBytes(quest.FinishText.Substring(0, MAX_STORY_LENGTH));
                    }
                    else
                    {
                        pak.WriteShort((ushort)quest.FinishText.Length);
                        pak.WriteStringBytes(quest.FinishText);
                    }
                }

                pak.WriteShort(QuestID);
                pak.WriteByte((byte)quest.StepTexts.Count);                 // #goals count
                foreach (string text in quest.StepTexts)
                {
                    string t = text;

                    // Need to protect for any text length > 255.  It does not crash client but corrupts RewardQuest display -Tolakram
                    if (text.Length > 253)
                    {
                        t = text.Substring(0, 253);
                    }

                    pak.WritePascalString(String.Format("{0}\r", t));
                }
                pak.WriteInt((uint)(0));
                pak.WriteByte((byte)0);
                pak.WriteByte((byte)quest.FinalRewards.Count);
                foreach (ItemTemplate reward in quest.FinalRewards)
                {
                    WriteItemData(pak, GameInventoryItem.Create <ItemTemplate>(reward));
                }
                pak.WriteByte((byte)quest.NumOptionalRewardsChoice);
                pak.WriteByte((byte)quest.OptionalRewards.Count);
                foreach (ItemTemplate reward in quest.OptionalRewards)
                {
                    WriteItemData(pak, GameInventoryItem.Create <ItemTemplate>(reward));
                }
                SendTCP(pak);
            }
        }
Exemplo n.º 27
0
        protected override void SendQuestWindow(GameNPC questNPC, GamePlayer player, RewardQuest quest, bool offer)
        {
            using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.Dialog)))
            {
                ushort QuestID = QuestMgr.GetIDForQuestType(quest.GetType());
                pak.WriteShort((offer) ? (byte)0x22 : (byte)0x21);                 // Dialog
                pak.WriteShort(QuestID);
                pak.WriteShort((ushort)questNPC.ObjectID);
                pak.WriteByte(0x00);                              // unknown
                pak.WriteByte(0x00);                              // unknown
                pak.WriteByte(0x00);                              // unknown
                pak.WriteByte(0x00);                              // unknown
                pak.WriteByte((offer) ? (byte)0x02 : (byte)0x01); // Accept/Decline or Finish/Not Yet
                pak.WriteByte(0x01);                              // Wrap
                pak.WritePascalString(quest.Name);

                String personalizedSummary = BehaviourUtils.GetPersonalizedMessage(quest.Summary, player);
                if (personalizedSummary.Length > 255)
                {
                    pak.WritePascalString(personalizedSummary.Substring(0, 255));                     // Summary is max 255 bytes !
                }
                else
                {
                    pak.WritePascalString(personalizedSummary);
                }

                if (offer)
                {
                    String personalizedStory = BehaviourUtils.GetPersonalizedMessage(quest.Story, player);

                    if (personalizedStory.Length > ServerProperties.Properties.MAX_REWARDQUEST_DESCRIPTION_LENGTH)
                    {
                        pak.WriteShort((ushort)ServerProperties.Properties.MAX_REWARDQUEST_DESCRIPTION_LENGTH);
                        pak.WriteStringBytes(personalizedStory.Substring(0, ServerProperties.Properties.MAX_REWARDQUEST_DESCRIPTION_LENGTH));
                    }
                    else
                    {
                        pak.WriteShort((ushort)personalizedStory.Length);
                        pak.WriteStringBytes(personalizedStory);
                    }
                }
                else
                {
                    if (quest.Conclusion.Length > (ushort)ServerProperties.Properties.MAX_REWARDQUEST_DESCRIPTION_LENGTH)
                    {
                        pak.WriteShort((ushort)ServerProperties.Properties.MAX_REWARDQUEST_DESCRIPTION_LENGTH);
                        pak.WriteStringBytes(quest.Conclusion.Substring(0, (ushort)ServerProperties.Properties.MAX_REWARDQUEST_DESCRIPTION_LENGTH));
                    }
                    else
                    {
                        pak.WriteShort((ushort)quest.Conclusion.Length);
                        pak.WriteStringBytes(quest.Conclusion);
                    }
                }

                pak.WriteShort(QuestID);
                pak.WriteByte((byte)quest.Goals.Count);                 // #goals count
                foreach (RewardQuest.QuestGoal goal in quest.Goals)
                {
                    pak.WritePascalString(String.Format("{0}\r", goal.Description));
                }
                pak.WriteInt((uint)(quest.Rewards.Money));                 // unknown, new in 1.94
                pak.WriteByte((byte)quest.Rewards.ExperiencePercent(player));
                pak.WriteByte((byte)quest.Rewards.BasicItems.Count);
                foreach (ItemTemplate reward in quest.Rewards.BasicItems)
                {
                    WriteItemData(pak, GameInventoryItem.Create <ItemTemplate>(reward));
                }
                pak.WriteByte((byte)quest.Rewards.ChoiceOf);
                pak.WriteByte((byte)quest.Rewards.OptionalItems.Count);
                foreach (ItemTemplate reward in quest.Rewards.OptionalItems)
                {
                    WriteItemData(pak, GameInventoryItem.Create <ItemTemplate>(reward));
                }
                SendTCP(pak);
            }
        }
Exemplo n.º 28
0
        public override void Perform(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer   player        = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);
            int          count         = Q;
            ItemTemplate itemToDestroy = P;

            Dictionary <InventoryItem, int?> dataSlots = new Dictionary <InventoryItem, int?>(10);

            lock (player.Inventory)
            {
                var allBackpackItems = player.Inventory.GetItemRange(eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack);

                bool result = false;
                foreach (InventoryItem item in allBackpackItems)
                {
                    if (item.Name == itemToDestroy.Name)
                    {
                        if (item.IsStackable) // is the item is stackable
                        {
                            if (item.Count >= count)
                            {
                                if (item.Count == count)
                                {
                                    dataSlots.Add(item, null);
                                }
                                else
                                {
                                    dataSlots.Add(item, count);
                                }
                                result = true;
                                break;
                            }
                            else
                            {
                                dataSlots.Add(item, null);
                                count -= item.Count;
                            }
                        }
                        else
                        {
                            dataSlots.Add(item, null);
                            if (count <= 1)
                            {
                                result = true;
                                break;
                            }
                            else
                            {
                                count--;
                            }
                        }
                    }
                }
                if (result == false)
                {
                    return;
                }
            }

            GamePlayerInventory playerInventory = player.Inventory as GamePlayerInventory;

            playerInventory.BeginChanges();
            Dictionary <InventoryItem, int?> .Enumerator enumerator = dataSlots.GetEnumerator();
            while (enumerator.MoveNext())
            {
                KeyValuePair <InventoryItem, int?> de = enumerator.Current;
                if (!de.Value.HasValue)
                {
                    playerInventory.RemoveItem(de.Key);
                    InventoryLogging.LogInventoryAction(player, NPC, eInventoryActionType.Quest, de.Key.Template, de.Key.Count);
                }
                else
                {
                    playerInventory.RemoveCountFromStack(de.Key, de.Value.Value);
                    InventoryLogging.LogInventoryAction(player, NPC, eInventoryActionType.Quest, de.Key.Template, de.Value.Value);
                }
            }
            playerInventory.CommitChanges();


            player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Behaviour.DestroyItemAction.Destroyed", itemToDestroy.Name), eChatType.CT_Loot, eChatLoc.CL_SystemWindow);
        }
        public override void Perform(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);

            QuestMgr.GiveQuestToPlayer(P, player, Q);
        }
Exemplo n.º 30
0
        public override void Perform(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);

            player.GainExperience(GameLiving.eXPSource.NPC, P);
        }