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; } }
public void openBox() { if (this.itemObj != null) { AbstractItemBase component = this.itemObj.GetComponent <AbstractItemBase>(); if (component.name.Contains(itemToReplaceName) && Enum.IsDefined(typeof(ItemDatabaseSystem.ItemNames), itemToInsertName)) { component.setItemParameter(itemToInsertName, 1); Sprite mapIconSprite = L2SystemCore.getMapIconSprite(L2SystemCore.getItemData((ItemDatabaseSystem.ItemNames)Enum.Parse(typeof(ItemDatabaseSystem.ItemNames), itemToInsertName))); this.itemObj.GetComponent <SpriteRenderer>().sprite = mapIconSprite; } } base.openBox(); }
private void ChangeEventItems() { foreach (EventItemScript item in FindObjectsOfType <EventItemScript>()) { ItemData oldItemData = GetItemDataFromName(item.name); if (oldItemData == null) { continue; } if (oldItemData != null && locationToItemMap.TryGetValue((LocationID)oldItemData.getItemName(), out ItemID newItemID)) { ItemInfo newItemInfo = ItemDB.GetItemInfo(newItemID); //Change the Event Items active flags to correspond to the new item //These flags are used to set the item inactive after you have got it foreach (L2FlagBoxParent flagBoxParent in item.itemActiveFlag) { foreach (L2FlagBox flagBox in flagBoxParent.BOX) { if (flagBox.seet_no1 == 2) { flagBox.flag_no1 = newItemInfo.itemFlag; 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; } } } } //Change the Event Items get flags to correspond to the new item //These are flags that are set when the item is gotten item.itemGetFlags = CreateGetFlags(newItemID, newItemInfo); //Change the name used when calling setitem to correspond to new item item.itemLabel = newItemInfo.boxName; //Change the sprite to correspond to new item Sprite sprite; //Mantras don't have an icon so use the Mantra software icon if (newItemID >= ItemID.Heaven && newItemID <= ItemID.Night) { sprite = L2SystemCore.getMapIconSprite(L2SystemCore.getItemData("Mantra")); } else { sprite = L2SystemCore.getMapIconSprite(L2SystemCore.getItemData(newItemInfo.boxName)); } item.gameObject.GetComponent <SpriteRenderer>().sprite = sprite; } } }
private IEnumerator ChangeTreasureBoxes() { List <TreasureBoxScript> oldboxes = new List <TreasureBoxScript>(); foreach (TreasureBoxScript box in FindObjectsOfType <TreasureBoxScript>()) { ItemData oldItemData = GetItemDataFromName(box.itemObj.name); if (oldItemData == null) { continue; } LocationID locationID = (LocationID)oldItemData.getItemName(); if (oldItemData != null && locationToItemMap.TryGetValue(locationID, out ItemID newItemID)) { ItemInfo newItemInfo = ItemDB.GetItemInfo(newItemID); TreasureBoxScript newBox; if (IsLocationCursed(locationID)) { GameObject obj = Instantiate(cursedChest, box.transform.position, box.transform.rotation); newBox = obj.GetComponent <TreasureBoxScript>(); newBox.curseMode = true; newBox.forceOpenFlags = box.forceOpenFlags; newBox.itemFlags = box.itemFlags; newBox.openActionFlags = box.openActionFlags; newBox.openFlags = box.openFlags; newBox.unlockFlags = box.unlockFlags; newBox.itemObj = box.itemObj; obj.SetActive(true); obj.transform.SetParent(box.transform.parent); oldboxes.Add(box); } else { newBox = box; newBox.curseMode = false; } //Change the Treasure Boxs open flags to correspond to the new item //These flags are used to so the chest stays open after you get the item foreach (L2FlagBoxParent flagBoxParent in newBox.openFlags) { foreach (L2FlagBox flagBox in flagBoxParent.BOX) { if (flagBox.seet_no1 == 2) { flagBox.flag_no1 = newItemInfo.itemFlag; flagBox.flag_no2 = 1; //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 = 2; } else if (newItemID == ItemID.FlailWhip || newItemID == ItemID.AngelShield) { flagBox.flag_no2 = 3; } } } } EventItemScript item = newBox.itemObj.GetComponent <EventItemScript>(); //Change the Event Items active flags to correspond to the new item //These flags are used to set the item inactive after you have got it foreach (L2FlagBoxParent flagBoxParent in item.itemActiveFlag) { foreach (L2FlagBox flagBox in flagBoxParent.BOX) { if (flagBox.seet_no1 == 2) { flagBox.flag_no1 = newItemInfo.itemFlag; 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; } } } } //Change the Event Items get flags to correspond to the new item //These are flags that are set when the item is gotten item.itemGetFlags = CreateGetFlags(newItemID, newItemInfo); //Change the name used when calling setitem to correspond to new item item.itemLabel = newItemInfo.boxName; //Change the sprite to correspond to new item Sprite sprite; //Mantras don't have an icon so use the Mantra software icon if (newItemID >= ItemID.Heaven && newItemID <= ItemID.Night) { sprite = L2SystemCore.getMapIconSprite(L2SystemCore.getItemData("Mantra")); } else { sprite = L2SystemCore.getMapIconSprite(L2SystemCore.getItemData(newItemInfo.boxName)); } item.gameObject.GetComponent <SpriteRenderer>().sprite = sprite; } } yield return(new WaitForEndOfFrame()); foreach (var box in oldboxes) { box.gameObject.SetActive(false); } }
public override bool itemCallBack(string tab, string name, int vale, int num) { string[] weapons = { "Whip2", "Whip3", "Knife", "Rapier", "Axe", "Katana", "Shuriken", "R-Shuriken", "E-Spear", "Flare Gun", "Bomb", "Chakram", "Caltrops", "Clay Doll", "Origin Seal", "Birth Seal", "Life Seal", "Death Seal" }; if (this.item_copunter > 2) { return(false); } this.true_name[this.item_copunter] = name; if (this.sys.isAnkJewel(name)) { name = "Ankh Jewel"; } else if (this.sys.isMap(name)) { name = "Map"; } this.item_id[this.item_copunter] = name; if (name.Contains("Mantra") && !name.Equals("Mantra")) { this.icon[this.item_copunter] = L2SystemCore.getShopIconSprite(L2SystemCore.getItemData("Mantra")); this.shop_item[this.item_copunter].sprite = this.icon[this.item_copunter]; string mojiName = name.Equals("Mantra10") ? "mantra1stM10" : "mantra1stM" + name.Substring(6, 1); this.item_name[this.item_copunter].text = this.sys.getMojiText(true, this.sys.mojiSheetNameToNo(tab, this.sys.getMojiScript(mojiScriptType.system)), this.sys.mojiIdToNo(tab, mojiName, this.sys.getMojiScript(mojiScriptType.system)), this.sys.getNowLangage(), this.sys.getMojiScript(mojiScriptType.system)); } else { if (name.Equals("Map")) { this.icon[this.item_copunter] = L2SystemCore.getMapIconSprite(L2SystemCore.getItemData("Map")); } else if (name.Equals("MSX")) { this.icon[this.item_copunter] = L2SystemCore.getShopIconSprite(L2SystemCore.getItemData("MSX3p")); } else if (name.Contains("Sacred Orb")) { this.icon[this.item_copunter] = L2SystemCore.getMenuIconSprite(L2SystemCore.getItemData("Sacred Orb")); name = "Sacred Orb"; } else if (name.Contains("Crystal S")) { this.icon[this.item_copunter] = L2SystemCore.getShopIconSprite(L2SystemCore.getItemData("Crystal S")); name = "Crystal S"; } else if (Array.IndexOf(weapons, name) > -1) { this.icon[this.item_copunter] = L2SystemCore.getMenuIconSprite(L2SystemCore.getItemData(name)); } else { this.icon[this.item_copunter] = ShopScript.Load("Textures/icons_shops", name); } this.shop_item[this.item_copunter].sprite = this.icon[this.item_copunter]; this.item_name[this.item_copunter].text = this.sys.getMojiText(true, this.sys.mojiSheetNameToNo(tab, this.sys.getMojiScript(mojiScriptType.item)), this.sys.mojiIdToNo(tab, name, this.sys.getMojiScript(mojiScriptType.item)), this.sys.getNowLangage(), this.sys.getMojiScript(mojiScriptType.item)); } this.item_value[this.item_copunter] = vale; if (vale > 999) { this.item_valu[this.item_copunter].text = L2Math.numToText(vale, 4); } else { this.item_valu[this.item_copunter].text = L2Math.numToText(vale, 3); } this.item_num[this.item_copunter] = num; this.item_copunter++; return(true); }
public void groundInit() { if (itemObj != null) { string targetItem = null; patch_AbstractItemBase itemBase = (patch_AbstractItemBase)itemObj.GetComponent <AbstractItemBase>(); if (itemBase.originalItemLabel.Length == 0) { itemBase.originalItemLabel = itemBase.itemLabel; } if (itemBase.originalItemLabel.Equals("Shell Horn")) { targetItem = "Lamp"; } else if (itemBase.originalItemLabel.Equals("Holy Grail")) { targetItem = "Feather"; } if (targetItem != null) { ItemData originalItemData = L2SystemCore.getItemData(itemBase.originalItemLabel); itemBase.setItemParameter(targetItem, 1); ItemData updatedItemData = L2SystemCore.getItemData(targetItem); Sprite targetSprite = L2SystemCore.getMapIconSprite(updatedItemData); SpriteRenderer spriteRenderer = itemObj.GetComponent <SpriteRenderer>(); spriteRenderer.sprite = targetSprite; foreach (L2Flag.L2FlagBoxEnd flag in itemBase.itemGetFlags) { if (flag.calcu == L2Flag.CALCU.EQR && flag.seet_no1 == 2 && flag.flag_no1 == (int)originalItemData.getItemName()) { flag.flag_no1 = (int)updatedItemData.getItemName(); } } foreach (L2Flag.L2FlagBoxParent flagBoxParent in itemBase.itemActiveFlag) { foreach (L2Flag.L2FlagBox origFlagBox in flagBoxParent.BOX) { patch_L2FlagBox flagBox = (patch_L2FlagBox)origFlagBox; if (flagBox.seet_no1 == 2 && flagBox.flag_no1 == (int)originalItemData.getItemName()) { flagBox.flag_no1 = (int)updatedItemData.getItemName(); } } } foreach (L2Flag.L2FlagBoxParent flagBoxParent in openFlags) { foreach (L2Flag.L2FlagBox origFlagBox in flagBoxParent.BOX) { patch_L2FlagBox flagBox = (patch_L2FlagBox)origFlagBox; if (flagBox.seet_no1 == 2 && flagBox.flag_no1 == (int)originalItemData.getItemName()) { if (flagBox.flgBaseL != null) { flagBox.flgBaseL.setFlagName(targetItem); } flagBox.flag_no1 = (int)updatedItemData.getItemName(); } } } } } orig_groundInit(); }