public void SetRuneByOffer(int index, IRune rune) { int id_rune = -1; for (int i = 0; i < StaticValues.Items.Runes.Count; i++) { if (StaticValues.Items.Runes[i] == rune) { id_rune = i; break; } } if (id_rune >= 0) { switch (offer_item.Category) { case ItemCategory.Armor: IArmor armor = ((IArmor)offer_item); armor.Runes[index] = id_rune; break; case ItemCategory.Weapon: IWeapon weapon = ((IWeapon)offer_item); weapon.Runes[index] = id_rune; break; } } }
public IRune(IRune item) { Stats = item.Stats; Elements = item.Elements; Type = item.Type; Name = item.Name; Icon = item.Icon; Category = item.Category; Description = item.Description; Value = item.Value; Stack = item.Stack; }
Stats CalculateStats(Item item) { Stats stats = new Stats(); stats.AddStats(((IWeapon)item).Stats); for (int i = 0; i < ((IWeapon)item).Runes.Count; i++) { if (((IWeapon)item).Runes[i] >= 0) { IRune rune = StaticValues.Items.Runes[((IWeapon)item).Runes[i]]; stats.AddStats(rune.Stats); } } return(stats); }
public void ApplyEffects(NWCreature user, NWItem runeItem, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = NWPlayer.Wrap(user.Object); NWItem targetItem = NWItem.Wrap(target.Object); RuneSlots slots = _rune.GetRuneSlots(targetItem); CustomItemPropertyType runeType = _rune.GetRuneType(runeItem); int runeID = runeItem.GetLocalInt("RUNE_ID"); string[] runeArgs = runeItem.GetLocalString("RUNE_VALUE").Split(','); int runeLevel = runeItem.RecommendedLevel; int levelIncrease = runeItem.LevelIncrease; var dbRune = _db.Runes.Single(x => x.RuneID == runeID && x.IsActive); IRune rune = App.ResolveByInterface <IRune>("Rune." + dbRune.Script); rune.Apply(player, targetItem, runeArgs); string description = rune.Description(player, targetItem, runeArgs); bool usePrismatic = false; switch (runeType) { case CustomItemPropertyType.RedRune: if (slots.FilledRedSlots < slots.RedSlots) { targetItem.SetLocalInt("RUNIC_SLOT_RED_" + (slots.FilledRedSlots + 1), runeID); targetItem.SetLocalString("RUNIC_SLOT_RED_DESC_" + (slots.FilledRedSlots + 1), description); player.SendMessage("Rune installed into " + _color.Red("red") + " slot #" + (slots.FilledRedSlots + 1)); } else { usePrismatic = true; } break; case CustomItemPropertyType.BlueRune: if (slots.FilledBlueSlots < slots.BlueSlots) { targetItem.SetLocalInt("RUNIC_SLOT_BLUE_" + (slots.FilledBlueSlots + 1), runeID); targetItem.SetLocalString("RUNIC_SLOT_BLUE_DESC_" + (slots.FilledBlueSlots + 1), description); player.SendMessage("Rune installed into " + _color.Blue("blue") + " slot #" + (slots.FilledBlueSlots + 1)); } else { usePrismatic = true; } break; case CustomItemPropertyType.GreenRune: if (slots.FilledBlueSlots < slots.GreenSlots) { targetItem.SetLocalInt("RUNIC_SLOT_GREEN_" + (slots.FilledGreenSlots + 1), runeID); targetItem.SetLocalString("RUNIC_SLOT_GREEN_DESC_" + (slots.FilledGreenSlots + 1), description); player.SendMessage("Rune installed into " + _color.Green("green") + " slot #" + (slots.FilledGreenSlots + 1)); } else { usePrismatic = true; } break; case CustomItemPropertyType.YellowRune: if (slots.FilledBlueSlots < slots.YellowSlots) { targetItem.SetLocalInt("RUNIC_SLOT_YELLOW_" + (slots.FilledYellowSlots + 1), runeID); targetItem.SetLocalString("RUNIC_SLOT_YELLOW_DESC_" + (slots.FilledYellowSlots + 1), description); player.SendMessage("Rune installed into " + _color.Yellow("yellow") + " slot #" + (slots.FilledYellowSlots + 1)); } else { usePrismatic = true; } break; } if (usePrismatic) { string prismaticText = _rune.PrismaticString(); targetItem.SetLocalInt("RUNIC_SLOT_PRISMATIC_" + (slots.FilledPrismaticSlots + 1), runeID); targetItem.SetLocalString("RUNIC_SLOT_PRISMATIC_DESC_" + (slots.FilledPrismaticSlots + 1), description); player.SendMessage("Rune installed into " + prismaticText + " slot #" + (slots.FilledPrismaticSlots + 1)); } targetItem.RecommendedLevel += levelIncrease; runeItem.Destroy(); SkillType skillType; if (_item.ArmorBaseItemTypes.Contains(targetItem.BaseItemType)) { skillType = SkillType.Armorsmith; } else if (_item.WeaponBaseItemTypes.Contains(targetItem.BaseItemType)) { skillType = SkillType.Weaponsmith; } else { return; } PCSkill pcSkill = _skill.GetPCSkill(player, skillType); int xp = (int)_skill.CalculateRegisteredSkillLevelAdjustedXP(400, runeLevel, pcSkill.Rank); _skill.GiveSkillXP(player, skillType, xp); }
public string IsValidTarget(NWCreature user, NWItem rune, NWObject target, Location targetLocation) { if (target.ObjectType != OBJECT_TYPE_ITEM) { return("Only items may be targeted by Runes."); } if (!user.IsPlayer) { return("Only players may use runes."); } NWPlayer player = NWPlayer.Wrap(user.Object); NWItem targetItem = NWItem.Wrap(target.Object); int runeLevel = rune.RecommendedLevel; int itemLevel = targetItem.RecommendedLevel; int requiredPerkLevel = runeLevel / 5; if (requiredPerkLevel <= 0) { requiredPerkLevel = 1; } int perkLevel = 0; CustomItemPropertyType runeType = _rune.GetRuneType(rune); RuneSlots runeSlots = _rune.GetRuneSlots(targetItem); int runeID = rune.GetLocalInt("RUNE_ID"); string[] runeArgs = rune.GetLocalString("RUNE_VALUE").Split(','); // Check for a misconfigured rune item. if (runeType == CustomItemPropertyType.Unknown) { return("Rune color couldn't be found. Notify an admin that this rune item is not set up properly."); } if (runeID <= 0) { return("Rune ID couldn't be found. Notify an admin that this rune item is not set up properly."); } if (runeArgs.Length <= 0) { return("Rune value couldn't be found. Notify an admin that this rune item is not set up properly."); } // No available slots on target item if (runeType == CustomItemPropertyType.RedRune && !runeSlots.CanRedRuneBeAdded) { return("That item has no available red runic slots."); } if (runeType == CustomItemPropertyType.BlueRune && !runeSlots.CanBlueRuneBeAdded) { return("That item has no available blue runic slots."); } if (runeType == CustomItemPropertyType.GreenRune && !runeSlots.CanGreenRuneBeAdded) { return("That item has no available green runic slots."); } if (runeType == CustomItemPropertyType.YellowRune && !runeSlots.CanYellowRuneBeAdded) { return("That item has no available yellow runic slots."); } // Get the perk level based on target item type and rune type. if (_item.WeaponBaseItemTypes.Contains(targetItem.BaseItemType)) { switch (runeType) { case CustomItemPropertyType.RedRune: perkLevel = _perk.GetPCPerkLevel(player, PerkType.CombatRuneInstallationWeapons); break; case CustomItemPropertyType.BlueRune: perkLevel = _perk.GetPCPerkLevel(player, PerkType.MagicRuneInstallationWeapons); break; case CustomItemPropertyType.GreenRune: perkLevel = _perk.GetPCPerkLevel(player, PerkType.CraftingRuneInstallationWeapons); break; case CustomItemPropertyType.YellowRune: perkLevel = _perk.GetPCPerkLevel(player, PerkType.SpecialRuneInstallationWeapons); break; default: perkLevel = 0; break; } } else if (_item.ArmorBaseItemTypes.Contains(targetItem.BaseItemType)) { switch (runeType) { case CustomItemPropertyType.RedRune: perkLevel = _perk.GetPCPerkLevel(player, PerkType.CombatRuneInstallationArmors); break; case CustomItemPropertyType.BlueRune: perkLevel = _perk.GetPCPerkLevel(player, PerkType.MagicRuneInstallationArmors); break; case CustomItemPropertyType.GreenRune: perkLevel = _perk.GetPCPerkLevel(player, PerkType.CraftingRuneInstallationArmors); break; case CustomItemPropertyType.YellowRune: perkLevel = _perk.GetPCPerkLevel(player, PerkType.SpecialRuneInstallationArmors); break; default: perkLevel = 0; break; } } // Ensure item isn't equipped. for (int slot = 0; slot < NUM_INVENTORY_SLOTS; slot++) { if (_.GetItemInSlot(slot, user.Object) == targetItem.Object) { return("Targeted item must be unequipped before installing a rune."); } } // Check for perk level requirement if (perkLevel < requiredPerkLevel) { return("You do not have the necessary perk rank required. (Required: " + requiredPerkLevel + ")"); } // Can't modify items above perk level * 10 if (itemLevel > perkLevel * 10) { return("Your current perks allow you to add runes to items up to level " + perkLevel * 10 + ". This item is level " + itemLevel + " so you can't install a rune into it."); } // Item must be in the user's inventory. if (!targetItem.Possessor.Equals(player)) { return("Targeted item must be in your inventory."); } // Look for a database entry for this rune type. var dbRune = _db.Runes.SingleOrDefault(x => x.RuneID == runeID && x.IsActive); if (dbRune == null) { return("Couldn't find a matching rune ID in the database. Inform an admin of this issue."); } // Run the individual rune's rules for application. Will return the error message or a null. IRune runeRules = App.ResolveByInterface <IRune>("Rune." + dbRune.Script); return(runeRules.CanApply(player, targetItem, runeArgs)); }
public void CreatePanel(Item item, int amount) { PartHead(item); PartSecond(item); switch (item.Category) { case ItemCategory.Weapon: Stats S_Weapon = CalculateStats(item); List <AttackElementRate> Elements = new List <AttackElementRate>(); CalculateElements(Elements, ((IWeapon)item).OtherAttackElement); for (int i = 0; i < ((IWeapon)item).Runes.Count; i++) { if (((IWeapon)item).Runes[i] >= 0) { IRune rune = StaticValues.Items.Runes[((IWeapon)item).Runes[i]]; CalculateElements(Elements, rune.Elements); } } PartDamage((IWeapon)item, S_Weapon, Elements); if (S_Weapon.Battle.armor_phisical > 0 || S_Weapon.Battle.armor_magicial > 0) { PartDefense(S_Weapon); } PartEffects(S_Weapon); PartRunes(((IWeapon)item).Runes); PartRequires(((IWeapon)item).Requires); PartOther(item, S_Weapon); PartAmmunition((IWeapon)item); break; case ItemCategory.Armor: Stats S_Armor = CalculateStats(item); if (S_Armor.Battle.armor_phisical > 0 || S_Armor.Battle.armor_magicial > 0) { PartDefense(S_Armor); } PartEffects(S_Armor); PartRunes(((IArmor)item).Runes); PartRequires(((IArmor)item).Requires); PartOther(item, S_Armor); break; case ItemCategory.Rune: PartEffects(((IRune)item).Stats); PartElements(((IRune)item).Elements); PartOther(item, ((IRune)item).Stats); break; case ItemCategory.Consume: PartRecover(((IConsume)item).Recover); PartEffects(((IConsume)item).Stats); PartState(((IConsume)item).AddState, "Add Effects"); PartState(((IConsume)item).RemoveState, "Remove Effects"); PartTrait(((IConsume)item).AddTrait, "Add Traits"); PartTrait(((IConsume)item).RemoveTrait, "Remove Traits"); break; case ItemCategory.Accessories: PartEffects(((IAccessories)item).Stats); PartOther(item, ((IAccessories)item).Stats); break; case ItemCategory.Throw: PartDamage((IThrow)item, ((IThrow)item).Battle); PartAttackThrow((IThrow)item); PartState(((IThrow)item).RemoveState, "Remove Effects"); break; } PartDescription(item); PartFooter(item, amount); StartCoroutine(timeToShow()); }
void ActionMenu() { GUILayout.BeginHorizontal("box", GUILayout.ExpandWidth(true)); if (GUILayout.Button("Add", GUILayout.Width(100))) { //my.States.Add(new State()); switch (ICategory) { case ItemCategory.Weapon: IWeapon weapon = new IWeapon(); weapon.Category = ItemCategory.Weapon; my.Weapons.Add(weapon); break; case ItemCategory.Armor: IArmor armor = new IArmor(); armor.Category = ItemCategory.Armor; my.Armors.Add(armor); break; case ItemCategory.Consume: IConsume consume = new IConsume(); consume.Category = ItemCategory.Consume; my.Consumes.Add(consume); break; case ItemCategory.Throw: IThrow itemThrow = new IThrow(); itemThrow.Category = ItemCategory.Throw; my.Throws.Add(itemThrow); break; case ItemCategory.Component: IComponent component = new IComponent(); component.Category = ItemCategory.Component; my.Components.Add(component); break; case ItemCategory.Recipe: IRecipe recipe = new IRecipe(); recipe.Category = ItemCategory.Recipe; my.Recipes.Add(recipe); break; case ItemCategory.KeyItem: IKey key = new IKey(); key.Category = ItemCategory.KeyItem; my.KeyItems.Add(key); break; case ItemCategory.Rune: IRune rune = new IRune(); rune.Category = ItemCategory.Rune; my.Runes.Add(rune); break; case ItemCategory.Accessories: IAccessories accessories = new IAccessories(); accessories.Category = ItemCategory.Accessories; my.Accessories.Add(accessories); break; } } if (GUILayout.Button("Remove", GUILayout.Width(100))) { switch (ICategory) { case ItemCategory.Weapon: if (my.Weapons.Count > 0) { selected = null; index = 0; my.Weapons.RemoveAt(my.Weapons.Count - 1); } break; case ItemCategory.Armor: if (my.Armors.Count > 0) { selected = null; index = 0; my.Armors.RemoveAt(my.Armors.Count - 1); } break; case ItemCategory.Consume: if (my.Consumes.Count > 0) { selected = null; index = 0; my.Consumes.RemoveAt(my.Consumes.Count - 1); } break; case ItemCategory.Throw: if (my.Throws.Count > 0) { selected = null; index = 0; my.Throws.RemoveAt(my.Throws.Count - 1); } break; case ItemCategory.Component: if (my.Components.Count > 0) { selected = null; index = 0; my.Components.RemoveAt(my.Components.Count - 1); } break; case ItemCategory.Recipe: if (my.Recipes.Count > 0) { selected = null; index = 0; my.Recipes.RemoveAt(my.Recipes.Count - 1); } break; case ItemCategory.KeyItem: if (my.KeyItems.Count > 0) { selected = null; index = 0; my.KeyItems.RemoveAt(my.KeyItems.Count - 1); } break; case ItemCategory.Rune: if (my.Runes.Count > 0) { selected = null; index = 0; my.Runes.RemoveAt(my.Runes.Count - 1); } break; case ItemCategory.Accessories: if (my.Accessories.Count > 0) { selected = null; index = 0; my.Accessories.RemoveAt(my.Accessories.Count - 1); } break; } } GUILayout.EndHorizontal(); }
void RuneSwitch() { IRune rune = (IRune)selected; rune.Type = (IRune.TypeRune)EditorGUILayout.EnumPopup("Type", rune.Type); GUILayout.Space(20); GUILayout.BeginHorizontal(); rune.Category = ItemCategory.Rune; Buttons(); switch (rune.Type) { case IRune.TypeRune.Weapon: if (GUILayout.Button("Elements")) { typeEdit = 8; } if (GUILayout.Button("Atk state")) { typeEdit = 6; } break; case IRune.TypeRune.Armor: rune.Elements = new List <AttackElementRate>(); if (typeEdit == 8) { typeEdit = 0; } if (GUILayout.Button("Resist state")) { typeEdit = 9; } break; } GUILayout.EndHorizontal(); switch (typeEdit) { case 1: EditorFunctions.ViewBase(rune.Stats.Base); break; case 2: EditorFunctions.ViewBattle(rune.Stats.Battle); break; case 3: EditorFunctions.ViewAbility(rune.Stats.Ability); break; case 4: EditorFunctions.ViewResist(rune.Stats.Resistance); break; case 5: EditorFunctions.ViewOther(rune.Stats.Other); break; case 6: GUILayout.BeginVertical("box"); EditorFunctions.ViewState(rune.Stats.AtkState, "Attack State"); GUILayout.EndVertical(); break; case 7: EditorFunctions.ViewSkills(); break; case 8: ElementsPanel(rune.Elements); break; case 9: GUILayout.BeginVertical("box"); EditorFunctions.ViewState(rune.Stats.ResistState, "Resist State"); GUILayout.EndVertical(); break; } }