예제 #1
0
        private void ChangeEventItem(EventItemScript eventItem)
        {
            ItemData oldItemData = GetItemDataFromName(eventItem.name);

            if (oldItemData != null && locationToItemMap.TryGetValue((int)oldItemData.getItemName(), out int id))
            {
                ItemID newItemID = (ItemID)id;

                //get the item data for the new item, only really need the names here
                ItemInfo newItemInfo = ItemFlags.GetItemInfo(newItemID);
                ItemData newItemData = GetNewItemData(newItemInfo);

                //flags the item uses to check to see if it should be active and visible to the user, important that these are
                //changed because if you only change the label the it will use the original items flags to check. This means that
                //if you change another item to what was this items original is and collect it when it comes to collecting the item
                //this has been changed too if won't be active as it thinks you already have it
                foreach (var flagBoxParent in eventItem.itemActiveFlag)
                {
                    foreach (var flagBox in flagBoxParent.BOX)
                    {
                        if (flagBox.seet_no1 == 2)
                        {
                            flagBox.flag_no1 = (int)newItemData.getItemName();
                            flagBox.comp     = COMPARISON.Equal;
                            flagBox.flag_no2 = 0;

                            //the whips and shields use the same flag just increment higher with each upgrade cant just use the same as other items
                            if (newItemID == ItemID.ChainWhip || newItemID == ItemID.SilverShield || newItemID == ItemID.MobileSuperx3P)
                            {
                                flagBox.flag_no2 = 1;
                                flagBox.comp     = COMPARISON.LessEq;
                            }
                            else if (newItemID == ItemID.FlailWhip || newItemID == ItemID.AngelShield)
                            {
                                flagBox.flag_no2 = 2;
                                flagBox.comp     = COMPARISON.LessEq;
                            }
                            else if (newItemID == ItemID.Buckler)
                            {
                                flagBox.comp = COMPARISON.LessEq;
                            }
                        }
                    }
                }

                //flags that the item sets when you collect it, important to change otherwise the original item will also be collected
                //when you pick up the item because by default it sets the original items flags again, also other flags can be set here
                //usually items that add to flags that are used as a type of counter eg.Sacred Orbs orb count
                eventItem.itemGetFlags = ItemFlags.GetItemGetFlags(newItemID);

                //name used when calling setitem
                eventItem.itemLabel = newItemInfo.boxName;

                //change the sprite to match the new item
                Sprite sprite = L2SystemCore.getMapIconSprite(L2SystemCore.getItemData(newItemInfo.boxName));
                eventItem.gameObject.GetComponent <SpriteRenderer>().sprite = sprite;
            }
        }
예제 #2
0
        private string ChangeTalkStringAndFlagCheck(LocationID locationID, string original)
        {
            int id;

            if (locationToItemMap.TryGetValue((int)locationID, out id))
            {
                ItemID   newItemID   = (ItemID)id;
                ItemInfo newItemInfo = ItemFlags.GetItemInfo(newItemID);
                ItemData newItemData = GetNewItemData(newItemInfo);

                int flagValue = 0;

                if (newItemID == ItemID.ChainWhip || newItemID == ItemID.SilverShield || newItemID == ItemID.MobileSuperx3P)
                {
                    flagValue = 1;
                }
                else if (newItemID == ItemID.FlailWhip || newItemID == ItemID.AngelShield)
                {
                    flagValue = 2;
                }

                //TODO:put this is into a method to remove redundancy
                string takeString;
                if (newItemInfo.boxName.Equals("Crystal S") || newItemInfo.boxName.Equals("Sacred Orb") || newItemInfo.boxName.Equals("MSX3p"))
                {
                    takeString = String.Format("[@take,{0},02item,1]\n", newItemInfo.boxName);
                }
                else
                {
                    takeString = String.Format("[@take,{0},02item,1]\n", newItemInfo.shopName);
                }

                //if the item has more than just its set flags add the flags to the mojiscript string
                L2FlagBoxEnd[] getFLags = ItemFlags.GetItemGetFlags(newItemID);
                if (getFLags != null)
                {
                    for (int i = 0; i < getFLags.Length; i++)
                    {
                        L2FlagBoxEnd flag = getFLags[i];
                        if (flag.calcu == CALCU.ADD)
                        {
                            takeString += String.Format("[@setf,{0},{1},+,{2}]\n", flag.seet_no1, flag.flag_no1, flag.data);
                        }
                        else if (flag.calcu == CALCU.EQR)
                        {
                            takeString += String.Format("[@setf,{0},{1},=,{2}]\n", flag.seet_no1, flag.flag_no1, flag.data);
                        }
                    }
                }

                return(String.Format(original, (int)newItemData.getItemName(), flagValue, takeString));
            }

            return(original);
        }
예제 #3
0
        private string ChangeTalkString(LocationID locationID, string original)
        {
            if (locationToItemMap.TryGetValue((int)locationID, out int id))
            {
                ItemID newItemID = (ItemID)id;

                //get the item data for the new item
                ItemInfo newItemInfo = ItemFlags.GetItemInfo(newItemID);

                //Sacred orbs might require some special work here if setting the orbcount flag doesnt give you the level up
                string take;
                if (newItemInfo.boxName.Equals("Crystal S") || newItemInfo.boxName.Equals("Sacred Orb") || newItemInfo.boxName.Equals("MSX3p"))
                {
                    take = String.Format("[@take,{0},02item,1]\n", newItemInfo.boxName);
                }
                else
                {
                    take = String.Format("[@take,{0},02item,1]\n", newItemInfo.shopName);
                }

                //if the item has more than just its set flags add the flags to the mojiscript string
                L2FlagBoxEnd[] getFLags = ItemFlags.GetItemGetFlags(newItemID);
                if (getFLags != null)
                {
                    for (int i = 0; i < getFLags.Length; i++)
                    {
                        L2FlagBoxEnd flag = getFLags[i];
                        if (flag.calcu == CALCU.ADD)
                        {
                            take += String.Format("[@setf,{0},{1},+,{2}]\n", flag.seet_no1, flag.flag_no1, flag.data);
                        }
                        else if (flag.calcu == CALCU.EQR)
                        {
                            take += String.Format("[@setf,{0},{1},=,{2}]\n", flag.seet_no1, flag.flag_no1, flag.data);
                        }
                    }
                }

                return(String.Format(original, take));
            }
            //should never get to here this will break this characters dialogue
            return(String.Empty);
        }
예제 #4
0
        private string CreateGetFlagString(LocationID locationID)
        {
            string flagString = String.Empty;

            int id;

            if (locationToItemMap.TryGetValue((int)locationID, out id))
            {
                ItemID newItemID = (ItemID)id;

                ItemInfo newItemData = ItemFlags.GetItemInfo(newItemID);

                if (newItemData.boxName.Equals("Crystal S"))
                {
                    flagString = "\n[@take,Crystal S,02item,1]";
                }

                L2FlagBoxEnd[] getFLags = ItemFlags.GetItemGetFlags(newItemID);
                if (getFLags != null)
                {
                    for (int i = 0; i < getFLags.Length; i++)
                    {
                        L2FlagBoxEnd flag = getFLags[i];
                        if (flag.calcu == CALCU.ADD)
                        {
                            flagString += String.Format("\n[@setf,{0},{1},+,{2}]", flag.seet_no1, flag.flag_no1, flag.data);
                        }
                        else if (flag.calcu == CALCU.EQR)
                        {
                            flagString += String.Format("\n[@setf,{0},{1},=,{2}]", flag.seet_no1, flag.flag_no1, flag.data);
                        }
                    }
                }
            }

            return(flagString);
        }