public Item(GS.Map.World world, ItemTable definition) : base(world, definition.SNOActor) { SetInitialValues(definition); this.ItemHasChanges = true;//initial, this is set to true. // level requirement // Attributes[GameAttribute.Requirement, 38] = definition.RequiredLevel; Attributes[GameAttribute.Item_Quality_Level] = 1; if (Item.IsArmor(this.ItemType) || Item.IsWeapon(this.ItemType) || Item.IsOffhand(this.ItemType)) { Attributes[GameAttribute.Item_Quality_Level] = RandomHelper.Next(6); } if (this.ItemType.Flags.HasFlag(ItemFlags.AtLeastMagical) && Attributes[GameAttribute.Item_Quality_Level] < 3) { Attributes[GameAttribute.Item_Quality_Level] = 3; } Attributes[GameAttribute.ItemStackQuantityLo] = 1; Attributes[GameAttribute.Seed] = RandomHelper.Next(); //unchecked((int)2286800181); RandomGenerator = new ItemRandomHelper(Attributes[GameAttribute.Seed]); RandomGenerator.Next(); if (Item.IsArmor(this.ItemType)) { RandomGenerator.Next(); // next value is used but unknown if armor } RandomGenerator.ReinitSeed(); ApplyWeaponSpecificOptions(definition); ApplyArmorSpecificOptions(definition); ApplyDurability(definition); ApplySkills(definition); ApplyAttributeSpecifier(definition); int affixNumber = 1; if (Attributes[GameAttribute.Item_Quality_Level] >= 3) { affixNumber = Attributes[GameAttribute.Item_Quality_Level] - 2; } AffixGenerator.Generate(this, affixNumber); }
public static bool Evaluate(int[] script, ItemRandomHelper irh, out float result) { result = 0; Stack<float> stack = new Stack<float>(64); int pos = 0; float numb1, numb2, numb3; while (pos < script.Length) { switch ((byte)script[pos]) { case 0: if (stack.Count < 1) { Logger.Error("Stack underflow"); return false; } result = stack.Pop(); return true; case 1: ++pos; byte funcId = (byte)script[pos]; switch (funcId) { case 3: if (stack.Count < 2) { Logger.Error("Stack underflow"); return false; } numb2 = stack.Pop(); numb1 = stack.Pop(); stack.Push(irh.Next(numb1, numb1 + numb2)); break; case 4: if (stack.Count < 2) { Logger.Error("Stack underflow"); return false; } numb2 = stack.Pop(); numb1 = stack.Pop(); stack.Push(irh.Next(numb1, numb2)); break; default: Logger.Error("Unimplemented function"); return false; } break; case 6: ++pos; stack.Push(BinaryIntToFloat(script[pos])); break; case 11: if (stack.Count < 2) { Logger.Error("Stack underflow"); return false; } numb2 = stack.Pop(); numb1 = stack.Pop(); stack.Push(numb1 + numb2); break; case 12: if (stack.Count < 2) { Logger.Error("Stack underflow"); return false; } numb2 = stack.Pop(); numb1 = stack.Pop(); stack.Push(numb1 - numb2); break; case 13: if (stack.Count < 2) { Logger.Error("Stack underflow"); return false; } numb2 = stack.Pop(); numb1 = stack.Pop(); stack.Push(numb1 * numb2); break; case 14: if (stack.Count < 2) { Logger.Error("Stack underflow"); return false; } numb2 = stack.Pop(); numb1 = stack.Pop(); if (numb1 == 0f) { Logger.Error("Division by zero"); return false; } stack.Push(numb1 / numb2); break; default: Logger.Error("Unimplemented OpCode"); return false; } ++pos; } return false; }
public static bool Evaluate(int[] script, ItemRandomHelper irh, out float result) { result = 0; Stack <float> stack = new Stack <float>(64); int pos = 0; float numb1, numb2; //numb3; while (pos < script.Length) { switch ((byte)script[pos]) { case 0: if (stack.Count < 1) { Logger.Error("Stack underflow"); return(false); } result = stack.Pop(); return(true); case 1: ++pos; byte funcId = (byte)script[pos]; switch (funcId) { case 3: if (stack.Count < 2) { Logger.Error("Stack underflow"); return(false); } numb2 = stack.Pop(); numb1 = stack.Pop(); stack.Push(irh.Next(numb1, numb1 + numb2)); break; case 4: if (stack.Count < 2) { Logger.Error("Stack underflow"); return(false); } numb2 = stack.Pop(); numb1 = stack.Pop(); stack.Push(irh.Next(numb1, numb2)); break; default: Logger.Error("Unimplemented function"); return(false); } break; case 6: ++pos; stack.Push(BinaryIntToFloat(script[pos])); break; case 11: if (stack.Count < 2) { Logger.Error("Stack underflow"); return(false); } numb2 = stack.Pop(); numb1 = stack.Pop(); stack.Push(numb1 + numb2); break; case 12: if (stack.Count < 2) { Logger.Error("Stack underflow"); return(false); } numb2 = stack.Pop(); numb1 = stack.Pop(); stack.Push(numb1 - numb2); break; case 13: if (stack.Count < 2) { Logger.Error("Stack underflow"); return(false); } numb2 = stack.Pop(); numb1 = stack.Pop(); stack.Push(numb1 * numb2); break; case 14: if (stack.Count < 2) { Logger.Error("Stack underflow"); return(false); } numb2 = stack.Pop(); numb1 = stack.Pop(); if (numb1 == 0f) { Logger.Error("Division by zero"); return(false); } stack.Push(numb1 / numb2); break; default: Logger.Error("Unimplemented OpCode"); return(false); } ++pos; } return(false); }
public Item(GS.Map.World world, ItemTable definition) : base(world, definition.SNOActor) { this.ItemDefinition = definition; this.GBHandle.Type = (int)GBHandleType.Gizmo; this.GBHandle.GBID = definition.Hash; this.ItemType = ItemGroup.FromHash(definition.ItemType1); this.EquipmentSlot = 0; this.InventoryLocation = new Vector2D { X = 0, Y = 0 }; this.Scale = 1.0f; this.FacingAngle = 0.0f; this.RotationAxis.Set(0.0f, 0.0f, 1.0f); this.CurrentState = ItemState.Normal; this.Field2 = 0x00000000; this.Field7 = 0; this.NameSNOId = -1; // I think it is ignored anyways - farmy this.Field10 = 0x00; this.ItemLevel = definition.ItemLevel; // level requirement // Attributes[GameAttribute.Requirement, 38] = definition.RequiredLevel; Attributes[GameAttribute.Item_Quality_Level] = 1; if (Item.IsArmor(this.ItemType) || Item.IsWeapon(this.ItemType)|| Item.IsOffhand(this.ItemType)) Attributes[GameAttribute.Item_Quality_Level] = RandomHelper.Next(6); if(this.ItemType.Flags.HasFlag(ItemFlags.AtLeastMagical) && Attributes[GameAttribute.Item_Quality_Level] < 3) Attributes[GameAttribute.Item_Quality_Level] = 3; Attributes[GameAttribute.ItemStackQuantityLo] = 1; Attributes[GameAttribute.Seed] = RandomHelper.Next(); //unchecked((int)2286800181); RandomGenerator = new ItemRandomHelper(Attributes[GameAttribute.Seed]); RandomGenerator.Next(); if (Item.IsArmor(this.ItemType)) RandomGenerator.Next(); // next value is used but unknown if armor RandomGenerator.ReinitSeed(); ApplyWeaponSpecificOptions(definition); ApplyArmorSpecificOptions(definition); ApplyDurability(definition); ApplySkills(definition); ApplyAttributeSpecifier(definition); int affixNumber = 1; if (Attributes[GameAttribute.Item_Quality_Level] >= 3) affixNumber = Attributes[GameAttribute.Item_Quality_Level] - 2; AffixGenerator.Generate(this, affixNumber); }
public Item(GS.Map.World world, ItemTable definition) : base(world, definition.SNOActor) { this.ItemDefinition = definition; this.GBHandle.Type = (int)GBHandleType.Gizmo; this.GBHandle.GBID = definition.Hash; this.ItemType = ItemGroup.FromHash(definition.ItemType1); this.EquipmentSlot = 0; this.InventoryLocation = new Vector2D { X = 0, Y = 0 }; this.Scale = 1.0f; this.RotationAmount = 0.0f; this.RotationAxis.Set(0.0f, 0.0f, 1.0f); this.Field2 = 0x00000000; this.Field3 = 0x00000000; this.Field7 = 0; this.Field8 = 0; this.Field9 = 0x00000000; this.Field10 = 0x00; this.ItemLevel = definition.ItemLevel; // level requirement // Attributes[GameAttribute.Requirement, 38] = definition.RequiredLevel; Attributes[GameAttribute.Item_Quality_Level] = 1; if (Item.IsArmor(this.ItemType) || Item.IsWeapon(this.ItemType)|| Item.IsOffhand(this.ItemType)) Attributes[GameAttribute.Item_Quality_Level] = RandomHelper.Next(6); if(this.ItemType.Flags.HasFlag(ItemFlags.AtLeastMagical) && Attributes[GameAttribute.Item_Quality_Level] < 3) Attributes[GameAttribute.Item_Quality_Level] = 3; Attributes[GameAttribute.Seed] = RandomHelper.Next(); //unchecked((int)2286800181); /* List<IItemAttributeCreator> attributeCreators = new AttributeCreatorFactory().Create(this.ItemType); foreach (IItemAttributeCreator creator in attributeCreators) { creator.CreateAttributes(this); } */ RandomGenerator = new ItemRandomHelper(Attributes[GameAttribute.Seed]); RandomGenerator.Next(); if (Item.IsArmor(this.ItemType)) RandomGenerator.Next(); // next value is used but unknown if armor RandomGenerator.ReinitSeed(); ApplyWeaponSpecificOptions(definition); ApplyArmorSpecificOptions(definition); ApplyDurability(definition); ApplySkills(definition); ApplyAttributeSpecifier(definition); int affixNumber = 1; if (Attributes[GameAttribute.Item_Quality_Level] >= 3) affixNumber = Attributes[GameAttribute.Item_Quality_Level] - 2; AffixGenerator.Generate(this, affixNumber); }
public Item(GS.Map.World world, ItemTable definition) : base(world, definition.SNOActor) { this.ItemDefinition = definition; this.GBHandle.Type = (int)GBHandleType.Gizmo; this.GBHandle.GBID = definition.Hash; this.ItemType = ItemGroup.FromHash(definition.ItemType1); this.EquipmentSlot = 0; this.InventoryLocation = new Vector2D { X = 0, Y = 0 }; this.Scale = 1.0f; this.RotationW = 0.0f; this.RotationAxis.Set(0.0f, 0.0f, 1.0f); this.CurrentState = ItemState.Normal; this.Field2 = 0x00000000; this.Field7 = 0; this.NameSNOId = -1; // I think it is ignored anyways - farmy this.Field10 = 0x00; this.ItemLevel = definition.ItemLevel; // level requirement // Attributes[GameAttribute.Requirement, 38] = definition.RequiredLevel; Attributes[GameAttribute.Item_Quality_Level] = 1; if (Item.IsArmor(this.ItemType) || Item.IsWeapon(this.ItemType) || Item.IsOffhand(this.ItemType)) { Attributes[GameAttribute.Item_Quality_Level] = RandomHelper.Next(6); } if (this.ItemType.Flags.HasFlag(ItemFlags.AtLeastMagical) && Attributes[GameAttribute.Item_Quality_Level] < 3) { Attributes[GameAttribute.Item_Quality_Level] = 3; } Attributes[GameAttribute.ItemStackQuantityLo] = 1; Attributes[GameAttribute.Seed] = RandomHelper.Next(); //unchecked((int)2286800181); RandomGenerator = new ItemRandomHelper(Attributes[GameAttribute.Seed]); RandomGenerator.Next(); if (Item.IsArmor(this.ItemType)) { RandomGenerator.Next(); // next value is used but unknown if armor } RandomGenerator.ReinitSeed(); ApplyWeaponSpecificOptions(definition); ApplyArmorSpecificOptions(definition); ApplyDurability(definition); ApplySkills(definition); ApplyAttributeSpecifier(definition); int affixNumber = 1; if (Attributes[GameAttribute.Item_Quality_Level] >= 3) { affixNumber = Attributes[GameAttribute.Item_Quality_Level] - 2; } AffixGenerator.Generate(this, affixNumber); }
public Item(GS.Map.World world, ItemTable definition) : base(world, definition.SNOActor) { SetInitialValues(definition); this.ItemHasChanges = true;//initial, this is set to true. // level requirement // Attributes[GameAttribute.Requirement, 38] = definition.RequiredLevel; Attributes[GameAttribute.Item_Quality_Level] = 1; if (Item.IsArmor(this.ItemType) || Item.IsWeapon(this.ItemType) || Item.IsOffhand(this.ItemType)) Attributes[GameAttribute.Item_Quality_Level] = RandomHelper.Next(6); if (this.ItemType.Flags.HasFlag(ItemFlags.AtLeastMagical) && Attributes[GameAttribute.Item_Quality_Level] < 3) Attributes[GameAttribute.Item_Quality_Level] = 3; Attributes[GameAttribute.ItemStackQuantityLo] = 1; Attributes[GameAttribute.Seed] = RandomHelper.Next(); //unchecked((int)2286800181); RandomGenerator = new ItemRandomHelper(Attributes[GameAttribute.Seed]); RandomGenerator.Next(); if (Item.IsArmor(this.ItemType)) RandomGenerator.Next(); // next value is used but unknown if armor RandomGenerator.ReinitSeed(); ApplyWeaponSpecificOptions(definition); ApplyArmorSpecificOptions(definition); ApplyDurability(definition); ApplySkills(definition); ApplyAttributeSpecifier(definition); int affixNumber = 1; if (Attributes[GameAttribute.Item_Quality_Level] >= 3) affixNumber = Attributes[GameAttribute.Item_Quality_Level] - 2; AffixGenerator.Generate(this, affixNumber); }
public Item(GS.Map.World world, ItemTable definition, bool Craft = false) : base(world, definition.SNOActor) { //Attributes[GameAttribute.Requirement,38] = (ulong)definition.RequiredLevel; SetInitialValues(definition); this.ItemHasChanges = true;//initial, this is set to true. // level requirement //Attributes[GameAttribute.Requirement, 316] = 10f; //Attributes[GameAttribute.Requirements_Ease_Percent, 38] = definition.RequiredLevel - 1; string[] parts = definition.Name.Split(new char[] { '_' }); //Attributes[GameAttribute.Requirement,1] = definition.RequiredLevel; Attributes[GameAttribute.Item_Quality_Level] = 1; //Attributes[GameAttribute.Core_Attributes_From_Item_Bonus_Multiplier] = 1; this.Field2 = 0; this.Field11 = 0; Attributes[GameAttribute.IdentifyCost] = 1; //this.ItemType.Flags = this.ItemType.Flags | ItemFlags.Unknown | ItemFlags.Socketable; //this.Attributes[GameAttribute.Sockets] = 1; this.Attributes[GameAttribute.Sockets_Filled] = 0; if (Item.IsArmor(this.ItemType) || Item.IsWeapon(this.ItemType) || Item.IsOffhand(this.ItemType)) { Attributes[GameAttribute.Item_Quality_Level] = RandomHelper.Next(8); } if (Attributes[GameAttribute.Item_Quality_Level] > 5 & Attributes[GameAttribute.Item_Quality_Level] < 9) { if (RandomHelper.Next(0, 100) < 85) { Attributes[GameAttribute.Item_Quality_Level] -= 2; } } if (this.ItemType.Flags.HasFlag(ItemFlags.AtLeastMagical) && Attributes[GameAttribute.Item_Quality_Level] < 3) { Attributes[GameAttribute.Item_Quality_Level] = 3; } if (parts[0] == "Unique") { Logger.Debug("Геренация уникального предмета"); Attributes[GameAttribute.Item_Quality_Level] = 9; if ((Item.IsArmor(this.ItemType))) { Attributes[GameAttribute.Armor_Item] = definition.ItemLevel + RandomHelper.Next(0, 20); } if ((Item.IsWeapon(this.ItemType))) { Attributes[GameAttribute.Attacks_Per_Second_Item] = 1.1f; Attributes[GameAttribute.Damage_Weapon_Min, 0] = (definition.ItemLevel + definition.RequiredLevel + RandomHelper.Next(1, 4)) * 2; Attributes[GameAttribute.Damage_Weapon_Delta, 0] += RandomHelper.Next(1, 3); //scripted //Attributes[GameAttribute.Damage_Weapon_Max, 0] += Attributes[GameAttribute.Damage_Weapon_Min, 0] + Attributes[GameAttribute.Damage_Weapon_Delta, 0]; } if (definition.SNOSet != -1) { Attributes[GameAttribute.Item_Quality_Level] = 10; if ((Item.IsArmor(this.ItemType))) { Attributes[GameAttribute.Armor_Item] = definition.ItemLevel * RandomHelper.Next(2, 4); } if ((Item.IsWeapon(this.ItemType))) { Attributes[GameAttribute.Damage_Weapon_Min] = (definition.ItemLevel + definition.RequiredLevel + RandomHelper.Next(2, 6)) * 2; Attributes[GameAttribute.Damage_Weapon_Max] = (definition.ItemLevel + definition.RequiredLevel + RandomHelper.Next(7, 20)) * 2; } } } else { if ((Item.IsWeapon(this.ItemType))) { Attributes[GameAttribute.Damage_Weapon_Min, 0] += RandomHelper.Next(-2, 2); Attributes[GameAttribute.Damage_Weapon_Delta, 0] += RandomHelper.Next(0, 2); } if ((Item.IsArmor(this.ItemType))) { Attributes[GameAttribute.Armor_Item] += RandomHelper.Next(-1, 3); } } /* * Inferior, 0 * Normal, 1 * Superior, 2 * Magic1, 3 * Magic2, 4 * Magic3, 5 * Rare4, 6 * Rare5, 7 * Rare6, 8 * Legendary, 9 * Artifact, 10 */ Attributes[GameAttribute.ItemStackQuantityLo] = 1; Attributes[GameAttribute.Seed] = RandomHelper.Next(); //unchecked((int)2286800181); RandomGenerator = new ItemRandomHelper(Attributes[GameAttribute.Seed]); RandomGenerator.Next(); if (Item.IsArmor(this.ItemType)) { RandomGenerator.Next(); // next value is used but unknown if armor } RandomGenerator.ReinitSeed(); ApplyWeaponSpecificOptions(definition); ApplyArmorSpecificOptions(definition); ApplyDurability(definition); ApplySkills(definition); ApplyAttributeSpecifier(definition); int affixNumber = 1; #region if (Craft == true) { if (definition.Name == "ChestArmor_002" || definition.Name == "Boots_002" || definition.Name == "Crossbow_001" || definition.Name == "Wand_001" || definition.Name == "Axe_1h_002" || definition.Name == "Pants_003" || definition.Name == "Bracers_002" || definition.Name == "Gloves_003" || definition.Name == "Shield_003" || definition.Name == "Sword_2h_002" || definition.Name == "Helm_003" || definition.Name == "Belt_003" || definition.Name == "Shoulders_002" || definition.Name == "CombatStaff_2H_002" || definition.Name == "Shoulders_003" || definition.Name == "Boots_004" || definition.Name == "MightyWeapon1H_003" || definition.Name == "Mace_2H_004" || definition.Name == "ChestArmor_005" || definition.Name == "Gloves_005" || definition.Name == "Bow_005" || definition.Name == "Wand_006" || definition.Name == "FistWeapon_1H_004" || definition.Name == "Boots_006" || definition.Name == "Axe_2H_005" || definition.Name == "Axe_1H_007" || definition.Name == "Wand_004" ) { Attributes[GameAttribute.Item_Quality_Level] = 4; } if (definition.Name == "Quiver_004" || //Нужно добавить будет аффикс на +10% к скорости атаки. definition.Name == "Quiver_005" || definition.Name == "Axe_1H_004" || definition.Name == "Handxbow_004" || definition.Name == "CeremonialDagger_1H_003" || definition.Name == "Sword_2H_004" || definition.Name == "Shield_006" || definition.Name == "Mace_1H_006" || definition.Name == "HandXbow_008" || definition.Name == "Bracers_006" || definition.Name == "CombatStaff_2H_004" || definition.Name == "ChestArmor_006" || definition.Name == "Mojo_004" || //Нужно добавить аффикс на 3-5 дамага definition.Name == "Dagger_006" || definition.Name == "Orb_003") //Нужно добавить будет аффикс на 5-6 дамага. { Attributes[GameAttribute.Item_Quality_Level] = 5; } if (definition.Name == "Helm_004" || definition.Name == "Belt_006" || definition.Name == "Wand_007" || definition.Name == "Shoulders_006" || definition.Name == "Pants_006" || definition.Name == "Sword_1H_008") { Attributes[GameAttribute.Item_Quality_Level] = 6; } if (definition.Name == "Staff_006" || definition.Name == "-1") { Attributes[GameAttribute.Item_Quality_Level] = 7; } } #endregion if (Attributes[GameAttribute.Item_Quality_Level] >= 3) { affixNumber = Attributes[GameAttribute.Item_Quality_Level] - 2; } if (Attributes[GameAttribute.Item_Quality_Level] >= 3) { affixNumber = Attributes[GameAttribute.Item_Quality_Level] - 2; } AffixGenerator.Generate(this, affixNumber); // if (this.Quality > 5 & this.Quality < 9) { this.Field7 = 1; /*world..InGameClient.SendMessage(new GameSyncedDataMessage * { * Field0 = GameData * }); * RareItemNameMessage*/ this.World.BroadcastIfRevealed(new RareItemNameMessage { Field0 = (int)this.DynamicID, Field1 = new RareItemName { snoAffixStringList = this.ItemDefinition.SNORareNamePrefixStringList } }, this); } this.Attributes.BroadcastChangedIfRevealed(); //if (definition.Name == "Quiver_004") // AffixList.Add(new Affix(2044719016)); }