Exemplo n.º 1
0
        protected override void SendQuestPacket(AbstractQuest q, int index)
        {
            if (q == null || !(q is RewardQuest))
            {
                base.SendQuestPacket(q, index);
                return;
            }

            RewardQuest quest = q as RewardQuest;

            using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.QuestEntry)))
            {
                pak.WriteByte((byte)index);
                pak.WriteByte((byte)quest.Name.Length);
                pak.WriteShort(0x00);                 // unknown
                pak.WriteByte((byte)quest.Goals.Count);
                pak.WriteByte((byte)quest.Level);
                pak.WriteStringBytes(quest.Name);
                pak.WritePascalString(quest.Description);
                int goalindex = 0;
                foreach (RewardQuest.QuestGoal goal in quest.Goals)
                {
                    goalindex++;
                    String goalDesc = String.Format("{0}\r", goal.Description);
                    pak.WriteShortLowEndian((ushort)goalDesc.Length);
                    pak.WriteStringBytes(goalDesc);
                    pak.WriteShortLowEndian((ushort)goal.ZoneID2);
                    pak.WriteShortLowEndian((ushort)goal.XOffset2);
                    pak.WriteShortLowEndian((ushort)goal.YOffset2);
                    pak.WriteShortLowEndian(0x00);                      // unknown
                    pak.WriteShortLowEndian((ushort)goal.Type);
                    pak.WriteShortLowEndian(0x00);                      // unknown
                    pak.WriteShortLowEndian((ushort)goal.ZoneID1);
                    pak.WriteShortLowEndian((ushort)goal.XOffset1);
                    pak.WriteShortLowEndian((ushort)goal.YOffset1);
                    pak.WriteByte((byte)((goal.IsAchieved) ? 0x01 : 0x00));
                    if (goal.QuestItem == null)
                    {
                        pak.WriteByte(0x00);
                    }
                    else
                    {
                        pak.WriteByte((byte)goalindex);
                        WriteTemplateData(pak, goal.QuestItem, 1);
                    }
                }
                SendTCP(pak);
            }
        }
Exemplo n.º 2
0
        public override IEnumerable <Mistake> CheckMistake()
        {
            foreach (NPC.NPCDialogue dial in MainWindow.CurrentProject.data.dialogues)
            {
                for (int i = 0; i < dial.Responses.Count; i++)
                {
                    NPC.NPCResponse response = dial.Responses[i];

                    if (response.openQuestId > 0)
                    {
                        ConditionQuest questCondition = null;

                        foreach (Condition condition in response.conditions)
                        {
                            if (condition is ConditionQuest quest)
                            {
                                if (quest.ID == response.openQuestId)
                                {
                                    questCondition = quest;
                                    break;
                                }
                            }
                        }

                        if (questCondition != null && questCondition.Status == NPC.Quest_Status.None) // has quest condition
                        {
                            RewardQuest rewardQuest = null;

                            foreach (Reward reward in response.rewards)
                            {
                                if (reward is RewardQuest rq)
                                {
                                    if (rq.ID == questCondition.ID)
                                    {
                                        rewardQuest = rq;
                                        break;
                                    }
                                }
                            }

                            if (rewardQuest == null)
                            {
                                yield return(new NE_1004(i + 1, dial.ID));
                            }
                        }
                    }
                }
            }
        }
        public override IEnumerable <Mistake> CheckMistake()
        {
            foreach (NPC.NPCDialogue dial in MainWindow.CurrentProject.data.dialogues)
            {
                for (int i = 0; i < dial.Responses.Count; i++)
                {
                    NPC.NPCResponse response = dial.Responses[i];

                    if (response.openQuestId > 0)
                    {
                        ConditionQuest questCondition = null;
                        RewardQuest    questReward    = null;

                        foreach (Condition condition in response.conditions)
                        {
                            if (condition is ConditionQuest quest)
                            {
                                if (quest.ID == response.openQuestId)
                                {
                                    questCondition = quest;
                                    break;
                                }
                            }
                        }

                        foreach (Reward reward in response.rewards)
                        {
                            if (reward is RewardQuest quest)
                            {
                                if (quest.ID == response.openQuestId)
                                {
                                    questReward = quest;
                                    break;
                                }
                            }
                        }

                        if (questCondition == null && questReward == null) // no quest condition yet previewing quest
                        {
                            yield return(new NE_1004(i + 1, dial.ID));
                        }
                    }
                }
            }
        }
Exemplo n.º 4
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.º 5
0
 public override void SendQuestRewardWindow(GameNPC questNPC, GamePlayer player, RewardQuest quest)
 {
     SendQuestWindow(questNPC, player, quest, false);
 }
Exemplo n.º 6
0
 public override void SendQuestOfferWindow(GameNPC questNPC, GamePlayer player, RewardQuest quest)
 {
     SendQuestWindow(questNPC, player, quest, true);
 }
Exemplo n.º 7
0
 public void SendQuestRewardWindow(GameNPC questNPC, GamePlayer player, RewardQuest quest)
 {
 }
Exemplo n.º 8
0
        private Reward[] ParseRewards(string prefix, string postfix = "Reward_")
        {
            Reward[] r   = new Reward[asset.ReadByte($"{prefix}Rewards")];
            int      num = 0;
            string   text;

            while (true)
            {
                if (num >= r.Length)
                {
                    return(r);
                }

                text = $"{prefix}{postfix}{num}_Type";
                if (!asset.Has(text))
                {
                    break;
                }

                RewardType type = asset.ReadEnum <RewardType>(text);
                string     desc = local?.ReadString($"{prefix}{postfix}{num}");
                string     tp   = $"{prefix}{postfix}{num}_";
                switch (type)
                {
                case RewardType.Achievement:
                    r[num] = new RewardAchievement()
                    {
                        ID = asset.ReadString(tp + "ID")
                    };
                    break;

                case RewardType.Event:
                    r[num] = new RewardEvent()
                    {
                        ID = asset.ReadString(tp + "ID")
                    };
                    break;

                case RewardType.Experience:
                    r[num] = new RewardExperience()
                    {
                        Value = asset.ReadUInt32(tp + "Value")
                    };
                    break;

                case RewardType.Flag_Bool:
                    r[num] = new RewardFlagBool()
                    {
                        ID    = asset.ReadUInt16(tp + "ID"),
                        Value = asset.ReadBoolean(tp + "Value")
                    };
                    break;

                case RewardType.Flag_Math:
                    r[num] = new RewardFlagMath()
                    {
                        A_ID      = asset.ReadUInt16(tp + "A_ID"),
                        B_ID      = asset.ReadUInt16(tp + "B_ID"),
                        Operation = asset.ReadEnum <Operation_Type>(tp + "Operation")
                    };
                    break;

                case RewardType.Flag_Short:
                    r[num] = new RewardFlagShort()
                    {
                        ID           = asset.ReadUInt16(tp + "ID"),
                        Modification = asset.ReadEnum <Modification_Type>(tp + "Modification"),
                        Value        = asset.ReadInt16(tp + "Value")
                    };
                    break;

                case RewardType.Flag_Short_Random:
                    r[num] = new RewardFlagShortRandom()
                    {
                        ID           = asset.ReadUInt16(tp + "ID"),
                        Max_Value    = asset.ReadInt16(tp + "Max_Value"),
                        Min_Value    = asset.ReadInt16(tp + "Min_Value"),
                        Modification = asset.ReadEnum <Modification_Type>(tp + "Modification")
                    };
                    break;

                case RewardType.Item:
                    r[num] = new RewardItem()
                    {
                        Ammo       = asset.ReadByte(tp + "Ammo"),
                        Amount     = asset.ReadByte(tp + "Amount"),
                        Auto_Equip = asset.ReadBoolean(tp + "Auto_Equip"),
                        Barrel     = asset.ReadUInt16(tp + "Barrel"),
                        Grip       = asset.ReadUInt16(tp + "Grip"),
                        Magazine   = asset.ReadUInt16(tp + "Magazine"),
                        Sight      = asset.ReadUInt16(tp + "Sight"),
                        Tactical   = asset.ReadUInt16(tp + "Tactical"),
                        ID         = asset.ReadUInt16(tp + "ID")
                    };
                    break;

                case RewardType.Item_Random:
                    r[num] = new RewardItemRandom()
                    {
                        Amount = asset.ReadByte(tp + "Amount"),
                        ID     = asset.ReadUInt16(tp + "ID")
                    };
                    break;

                case RewardType.Quest:
                    r[num] = new RewardQuest()
                    {
                        ID = asset.ReadUInt16(tp + "ID")
                    };
                    break;

                case RewardType.Reputation:
                    r[num] = new RewardReputation()
                    {
                        Value = asset.ReadInt32(tp + "Value")
                    };
                    break;

                case RewardType.Teleport:
                    r[num] = new RewardTeleport()
                    {
                        Spawnpoint = asset.ReadString(tp + "Spawnpoint")
                    };
                    break;

                case RewardType.Vehicle:
                    r[num] = new RewardVehicle()
                    {
                        ID         = asset.ReadUInt16(tp + "ID"),
                        Spawnpoint = asset.ReadString(tp + "Spawnpoint")
                    };
                    break;

                case RewardType.Currency:
                    r[num] = new RewardCurrency()
                    {
                        GUID  = asset.ReadString(tp + "GUID"),
                        Value = asset.ReadUInt32(tp + "Value")
                    };
                    break;

                case RewardType.Hint:
                    r[num] = new RewardHint()
                    {
                        Duration = asset.ReadSingle(tp + "Duration", 2f)
                    };
                    break;
                }
                r[num].Localization = desc ?? "";
                num++;
            }
            return(r);
        }