// Allows cooking a custom item. public static Item Cook(Player player, string name) { int hash = StringHashHelper.HashItemName(name); ItemTable definition = Items[hash]; return(CookFromDefinition(player, definition)); }
public Scoundrel(World world, int snoId, TagMap tags) : base(world, snoId, tags) { Brain = new AI.Brains.HirelingBrain(this); mainSNO = 4644; hirelingSNO = 52694; proxySNO = 192941; skillKit = 0x8AFE; hirelingGBID = StringHashHelper.HashItemName("Scoundrel"); Attributes[GameAttribute.Hireling_Class] = 2; try { foreach (var player in world.Players) { Master = world.GetActorBySNO(player.Value.ActorSNO.Id); } }catch { } this.Attributes[GameAttribute.Attacks_Per_Second] = 1.0f; this.Attributes[GameAttribute.Damage_Weapon_Min, 0] = 5f; this.Attributes[GameAttribute.Damage_Weapon_Delta, 0] = 5f; //RandomDirection(player.Value.Position, 3f, 8f); //this.WalkSpeed = 0.3f * monsterData.Floats[129]; // TODO: this is probably multiplied by something erekose the 0.3 is because he is way too fast otherwise this.WalkSpeed = this.RunSpeed; }
private static void LoadHandlers() { foreach (var type in Assembly.GetExecutingAssembly().GetTypes()) { if (!type.IsSubclassOf(typeof(Item))) { continue; } var attributes = (HandledItemAttribute[])type.GetCustomAttributes(typeof(HandledItemAttribute), true); if (attributes.Length != 0) { foreach (var name in attributes.First().Names) { GBIDHandlers.Add(StringHashHelper.HashItemName(name), type); } } var typeAttributes = (HandledTypeAttribute[])type.GetCustomAttributes(typeof(HandledTypeAttribute), true); if (typeAttributes.Length != 0) { foreach (var typeName in typeAttributes.First().Types) { TypeHandlers.Add(StringHashHelper.HashItemName(typeName), type); } } } }
public LeahParty(World world, int snoId, TagMap tags) : base(world, snoId, tags) { Brain = new AI.Brains.HirelingBrain(this); mainSNO = 144681; hirelingSNO = 52694; proxySNO = 192941; skillKit = 0x8AFE; hirelingGBID = StringHashHelper.HashItemName("Leah_Party"); Attributes[GameAttribute.Hireling_Class] = 2; try { foreach (var player in world.Players) { Master = world.GetActorBySNO(player.Value.ActorSNO.Id); } } catch { } this.Attributes[GameAttribute.Attacks_Per_Second] = 1.0f; this.Attributes[GameAttribute.Damage_Weapon_Min, 0] = 5f; this.Attributes[GameAttribute.Damage_Weapon_Delta, 0] = 5f; this.WalkSpeed = this.RunSpeed; (Brain as AI.Brains.HirelingBrain).AddPresetPower(30252); //Range_instant }
private static ItemTable GetRandom(List <ItemTable> pool) { var found = false; ItemTable itemDefinition = null; while (!found) { itemDefinition = pool[RandomHelper.Next(0, pool.Count() - 1)]; if (itemDefinition.SNOActor == -1) { continue; } // if ((itemDefinition.ItemType1 == StringHashHelper.HashItemName("Book")) && (itemDefinition.BaseGoldValue != 0)) return itemDefinition; // testing books /xsochor // if (itemDefinition.ItemType1 != StringHashHelper.HashItemName("Book")) continue; // testing books /xsochor // if (!ItemGroup.SubTypesToHashList("SpellRune").Contains(itemDefinition.ItemType1)) continue; // testing spellrunes /xsochor // ignore gold and healthglobe, they should drop only when expect, not randomly if (itemDefinition.Name.ToLower().Contains("gold")) { continue; } if (itemDefinition.Name.ToLower().Contains("healthglobe")) { continue; } if (itemDefinition.Name.ToLower().Contains("pvp")) { continue; } if (itemDefinition.Name.ToLower().Contains("unique")) { continue; } if (itemDefinition.Name.ToLower().Contains("crafted")) { continue; } if (itemDefinition.Name.ToLower().Contains("debug")) { continue; } if ((itemDefinition.ItemType1 == StringHashHelper.HashItemName("Book")) && (itemDefinition.BaseGoldValue == 0)) { continue; // i hope it catches all lore with npc spawned /xsochor } if (!GBIDHandlers.ContainsKey(itemDefinition.Hash) && !AllowedItemTypes.Contains(itemDefinition.ItemType1)) { continue; } found = true; } return(itemDefinition); }
public string HashNormal(string[] @params, MooNetClient invokerClient) { if (@params.Count() < 1) { return("Invalid arguments. Type 'help hash show' to get help."); } return(StringHashHelper.HashNormal(@params[0]).ToString()); }
public Enchantress(World world, int snoId, TagMap tags) : base(world, snoId, tags) { mainSNO = 4062; hirelingSNO = -1; proxySNO = 192942; skillKit = 87094; hirelingGBID = StringHashHelper.HashItemName("Enchantress"); Attributes[Mooege.Net.GS.Message.GameAttribute.Hireling_Class] = 3; }
public Scoundrel(World world, int snoId, TagMap tags) : base(world, snoId, tags) { mainSNO = 4644; hirelingSNO = 52694; proxySNO = 192941; skillKit = 0x8AFE; hirelingGBID = StringHashHelper.HashItemName("Scoundrel"); Attributes[GameAttribute.Hireling_Class] = 2; }
public Templar(World world, int snoId, TagMap tags) : base(world, snoId, tags) { mainSNO = 4538; hirelingSNO = 0x0000CDD5; proxySNO = 0x0002F1AC; skillKit = 0x8AFB; hirelingGBID = StringHashHelper.HashItemName("Templar"); this.Attributes[GameAttribute.Hireling_Class] = 1; }
/// <summary> /// Happens only when a hero is created so a hashing of all values can be afforded /// </summary> /// <param name="classHash"></param> /// <returns></returns> private static int GetClassFromHash(int classHash) { foreach (ToonClass heroClass in Enum.GetValues(typeof(ToonClass))) { if (StringHashHelper.HashNormal(heroClass.ToString().ToLower()) == classHash) { return((int)(ToonClass)heroClass); } } return(0); }
// Allows cooking a custom item. public static Item Cook(Player player, string name) { int hash = StringHashHelper.HashItemName(name); ItemTable definition = Items[hash]; Type type = GetItemClass(definition); var item = (Item)Activator.CreateInstance(type, new object[] { player.World, definition }); //player.GroundItems[item.DynamicID] = item; return(item); }
public Account(string email, string password, string battleTagName, int hashCode, UserLevels userLevel) // Account with **newly generated** persistent ID : base(StringHashHelper.HashIdentity(battleTagName + "#" + hashCode.ToString("D4"))) { if (password.Length > 16) { password = password.Substring(0, 16); // make sure the password does not exceed 16 chars. } var salt = SRP6a.GetRandomBytes(32); var passwordVerifier = SRP6a.CalculatePasswordVerifierForAccount(email, password, salt); this.SetFields(email, salt, passwordVerifier, battleTagName, hashCode, userLevel); }
public override bool Reveal(Player player) { //Logger.Debug(" (Reveal) portal {0} has location {1}", this.ActorSNO, this._position); if (!base.Reveal(player) || this.Destination == null) { return(false); } player.InGameClient.SendMessage(new PortalSpecifierMessage() { ActorID = this.DynamicID, Destination = this.Destination }); // Show a minimap icon Mooege.Common.MPQ.Asset asset; string markerName = ""; if (Mooege.Common.MPQ.MPQStorage.Data.Assets[Common.Types.SNO.SNOGroup.LevelArea].TryGetValue(this.Destination.DestLevelAreaSNO, out asset)) { markerName = System.IO.Path.GetFileNameWithoutExtension(asset.FileName); } player.InGameClient.SendMessage(new MapMarkerInfoMessage() { Field0 = (int)World.NewSceneID, // TODO What is the correct id space for mapmarkers? Field1 = new WorldPlace() { Position = this.Position, WorldID = this.World.DynamicID }, Field2 = MinimapIcon, // 0x00018FB0, /* Marker_DungeonEntrance.tex */ // TODO Dont mark all portals as dungeon entrances... some may be exits too (although d3 does not necesarrily use the correct markers). Also i have found no hacky way to determine whether a portal is entrance or exit - farmy m_snoStringList = 0x0000CB2E, /* LevelAreaNames.stl */ // TODO Dont use hardcoded numbers Field3 = StringHashHelper.HashNormal(markerName), Field9 = 0, Field10 = 0, Field11 = 0, Field5 = 0, Field6 = true, Field7 = false, Field8 = true, Field12 = 0 }); return(true); }
/// <summary> /// Makes an RPC over remote client. /// </summary> /// <param name="method">The method to call.</param> /// <param name="controller">The rpc controller.</param> /// <param name="request">The request message.</param> /// <param name="responsePrototype">The response message.</param> /// <param name="done">Action to run when client responds RPC.</param> public void CallMethod(MethodDescriptor method, IRpcController controller, IMessage request, IMessage responsePrototype, Action <IMessage> done) { var serviceName = method.Service.FullName; var serviceHash = StringHashHelper.HashIdentity(serviceName); if (!this.Services.ContainsKey(serviceHash)) { Logger.Error("Not bound to client service {0} [0x{1}] yet.", serviceName, serviceHash.ToString("X8")); return; } var serviceId = this.Services[serviceHash]; var token = this._tokenCounter++; RPCCallbacks.Add(token, new RPCCallback(done, responsePrototype.WeakToBuilder())); var packet = new PacketOut((byte)serviceId, MooNetRouter.GetMethodId(method), (uint)token, this._listenerId, request); this.Connection.Send(packet); }
public void CallMethod(MethodDescriptor method, IMessage request, ulong localObjectId) { var serviceName = method.Service.FullName; var serviceHash = StringHashHelper.HashIdentity(serviceName); if (!this.Services.ContainsKey(serviceHash)) { Logger.Error("Not bound to client service {0} [0x{1}] yet.", serviceName, serviceHash.ToString("X8")); return; } var serviceId = this.Services[serviceHash]; var remoteObjectId = GetRemoteObjectID(localObjectId); Logger.Debug("Calling {0} localObjectId={1}, remoteObjectId={2}", method.FullName, localObjectId, remoteObjectId); var packet = new BNetPacket( new BNetHeader((byte)serviceId, (uint)(method.Index + 1), this._requestCounter++, (uint)request.SerializedSize, remoteObjectId), request.ToByteArray()); this.Connection.Send(packet); }
public Item generateRandomElement(ItemType itemType) { try { // select count of Items with correct Type // the itemname structure ITEMTYPE_NUMBER example: BOOTS_001 , BELT_004 String querypart = String.Format("from items where itemname like '{0}_%'", itemType.ToString()); String countQuery = String.Format("SELECT count(*) {0}", querypart); var cmd = new SQLiteCommand(countQuery, Storage.GameDataDBManager.Connection); var reader = cmd.ExecuteReader(); reader.Read(); int itemsCount = reader.GetInt32(0); // Now select random element int selectedElementNr = RandomHelper.Next(itemsCount); String selectRandom = String.Format("SELECT itemname {0} limit {1},1", querypart, selectedElementNr); cmd = new SQLiteCommand(selectRandom, Storage.GameDataDBManager.Connection); reader = cmd.ExecuteReader(); if (!reader.HasRows) { throw new Exception("Missing Data in DB"); } while (reader.Read()) { var itemName = (String)reader.GetString(0); var id = (int)StringHashHelper.HashItemName(itemName); var item = new Item(id, itemType); return(item); } } catch (Exception e) { Logger.ErrorException(e, "Error generating Item"); } return(null); }
/// <summary> /// Transforms from normal value to the notification send value whenever a notification is sent /// </summary> public int HeroClassFieldTransform(int value) { return(StringHashHelper.HashNormal(Enum.GetName(typeof(ToonClass), value).ToLower())); }
public static bool IsValidItem(string name) { return(Items.ContainsKey(StringHashHelper.HashItemName(name))); }
private static ItemTable GetRandom(List <ItemTable> pool, Player player) { var found = false; ItemTable itemDefinition = null; //if (player.Toon.Class == ToonClass.Monk) while (!found) { itemDefinition = pool[RandomHelper.Next(0, pool.Count() - 1)]; if (itemDefinition.SNOActor == -1) { continue; } // if ((itemDefinition.ItemType1 == StringHashHelper.HashItemName("Book")) && (itemDefinition.BaseGoldValue != 0)) return itemDefinition; // testing books /xsochor // if (itemDefinition.ItemType1 != StringHashHelper.HashItemName("Book")) continue; // testing books /xsochor // if (!ItemGroup.SubTypesToHashList("SpellRune").Contains(itemDefinition.ItemType1)) continue; // testing spellrunes /xsochor if (itemDefinition.Name.ToLower().Contains("gold")) { continue; } if (itemDefinition.Name.ToLower().Contains("healthglobe")) { continue; } if (itemDefinition.Name.ToLower().Contains("_104")) { continue; } if (itemDefinition.Name.ToLower().Contains("pvp")) { continue; } if (itemDefinition.Name.ToLower().Contains("unique")) { if (player != null) { if (player.Attributes[GameAttribute.Skill, 30476] == 1) { int Percent = RandomHelper.Next(0, 1000); if (Percent < 880) { continue; } } else { int Percent = RandomHelper.Next(0, 1000); if (Percent < 980) { continue; } } } else { continue; } } if (itemDefinition.Name.ToLower().Contains("dye")) { if (player != null) { if (player.Attributes[GameAttribute.Skill, 30476] == 1) { int Percent = RandomHelper.Next(0, 1000); if (Percent < 880) { continue; } } else { int Percent = RandomHelper.Next(0, 1000); if (Percent < 980) { continue; } } } else { continue; } } if (itemDefinition.Name.ToLower().Contains("crafted")) { continue; } if (itemDefinition.Name.ToLower().Contains("test")) { continue; } if (itemDefinition.Name.ToLower().Contains("debug")) { continue; } if (itemDefinition.Name.ToLower().Contains("missing")) { continue; //I believe I've seen a missing item before, may have been affix though. //Wetwlly } if ((itemDefinition.ItemType1 == StringHashHelper.HashItemName("Book")) && (itemDefinition.BaseGoldValue == 0)) { continue; // i hope it catches all lore with npc spawned /xsochor } //if (itemDefinition.Name.Contains("Debug")) continue; //if (itemDefinition.Quality == ItemTable.ItemQuality.Invalid) continue; if (itemDefinition.Name.Contains("StaffOfCow")) { continue; } if (itemDefinition.Name.Contains("NephalemCube")) { continue; } if (itemDefinition.Name.Contains("BladeoftheAncients")) { continue; } if (itemDefinition.Name.ToLower().Contains("book")) { continue; } if (itemDefinition.Name.ToLower().Contains("staffofcow")) { continue; } if (itemDefinition.Name.ToLower().Contains("angelwings")) { continue; } if (itemDefinition.Name.ToLower().Contains("journal")) { continue; } if (itemDefinition.Name.ToLower().Contains("lore")) { continue; } if (itemDefinition.Name.ToLower().Contains("craftingplan")) { continue; } if (itemDefinition.Name.ToLower().Contains("set")) { continue; } if (itemDefinition.Name.Contains("TalismanUnlock")) { continue; } if (itemDefinition.Name.Contains("StoneOfRecall")) { continue; } if (!GBIDHandlers.ContainsKey(itemDefinition.Hash) && !AllowedItemTypes.Contains(itemDefinition.ItemType1)) { continue; } if (player != null) { if (player.Toon.Level <= 60) { if (itemDefinition.RequiredLevel < player.Toon.Level - 3 || itemDefinition.RequiredLevel > player.Toon.Level + 1) { continue; } } if (AllowedArmorTypes.Contains(itemDefinition.Hash) || AllowedWeaponTypes.Contains(itemDefinition.Hash)) { ItemTypeTable Type = ItemGroup.FromHash(itemDefinition.ItemType1); switch (player.Toon.Class) { case LogNet.Toons.ToonClass.Barbarian: if (Type.Flags.HasFlag(ItemFlags.Barbarian) & RandomHelper.Next(0, 100) > 40) { break; } else { continue; } case LogNet.Toons.ToonClass.DemonHunter: if (Type.Flags.HasFlag(ItemFlags.DemonHunter) & RandomHelper.Next(0, 100) > 40) { break; } else { continue; } case LogNet.Toons.ToonClass.Monk: if (Type.Flags.HasFlag(ItemFlags.Monk) & RandomHelper.Next(0, 100) > 40) { break; } else { continue; } case LogNet.Toons.ToonClass.WitchDoctor: if (Type.Flags.HasFlag(ItemFlags.WitchDoctor) & RandomHelper.Next(0, 100) > 40) { break; } else { continue; } case LogNet.Toons.ToonClass.Wizard: if (Type.Flags.HasFlag(ItemFlags.Wizard) & RandomHelper.Next(0, 100) > 40) { break; } else { continue; } } } } found = true; } return(itemDefinition); }
public ServiceAttribute(uint serviceID, string serviceName) : this(serviceID, StringHashHelper.HashIdentity(serviceName)) { }
public static bool IsSubType(ItemTypeTable type, string rootTypeName) { return(IsSubType(type, StringHashHelper.HashItemName(rootTypeName))); }
public Toon(string name, int hashCode, int classHash, ToonFlags flags, byte level, GameAccount account) // Toon with **newly generated** persistent ID : base(StringHashHelper.HashIdentity(name + "#" + hashCode.ToString("D3"))) { this.HeroClassField.transformDelegate += HeroClassFieldTransform; this.SetFields(name, hashCode, Toon.GetClassFromHash(classHash), flags, level, account, 0, 0, new Dictionary <uint, Item>()); }
private static ItemTable GetRandomWeaponToVendor(List <ItemTable> pool, Player player) { var found = false; ItemTable itemDefinition = null; int MaxLevel = 0; while (!found) { itemDefinition = pool[RandomHelper.Next(0, pool.Count() - 1)]; if (itemDefinition.SNOActor == -1) { continue; } // if ((itemDefinition.ItemType1 == StringHashHelper.HashItemName("Book")) && (itemDefinition.BaseGoldValue != 0)) return itemDefinition; // testing books /xsochor // if (itemDefinition.ItemType1 != StringHashHelper.HashItemName("Book")) continue; // testing books /xsochor // if (!ItemGroup.SubTypesToHashList("SpellRune").Contains(itemDefinition.ItemType1)) continue; // testing spellrunes /xsochor // ignore gold and healthglobe, they should drop only when expect, not randomly if (itemDefinition.Name.ToLower().Contains("gold")) { continue; } if (itemDefinition.Name.ToLower().Contains("_104")) { continue; } if (itemDefinition.Name.ToLower().Contains("healthglobe")) { continue; } if (itemDefinition.Name.ToLower().Contains("pvp")) { continue; } if (itemDefinition.Name.ToLower().Contains("unique")) { continue; } if (itemDefinition.Name.ToLower().Contains("crafted")) { continue; } if (itemDefinition.Name.ToLower().Contains("test")) { continue; } if (itemDefinition.Name.ToLower().Contains("debug")) { continue; } if (itemDefinition.Name.ToLower().Contains("unique")) { continue; } if (itemDefinition.Name.ToLower().Contains("missing")) { continue; //I believe I've seen a missing item before, may have been affix though. //Wetwlly } if ((itemDefinition.ItemType1 == StringHashHelper.HashItemName("Book")) && (itemDefinition.BaseGoldValue == 0)) { continue; // i hope it catches all lore with npc spawned /xsochor } //if (itemDefinition.Name.Contains("Debug")) continue; //if (itemDefinition.Quality == ItemTable.ItemQuality.Invalid) continue; if (itemDefinition.Name.Contains("StaffOfCow")) { continue; } if (itemDefinition.Name.Contains("BladeoftheAncients")) { continue; } if (itemDefinition.Name.ToLower().Contains("book")) { continue; } if (itemDefinition.Name.ToLower().Contains("staffofcow")) { continue; } if (itemDefinition.Name.ToLower().Contains("angelwings")) { continue; } if (itemDefinition.Name.ToLower().Contains("journal")) { continue; } if (itemDefinition.Name.ToLower().Contains("lore")) { continue; } if (itemDefinition.Name.ToLower().Contains("craftingplan")) { continue; } if (itemDefinition.Name.ToLower().Contains("set")) { continue; } if (itemDefinition.Name.Contains("TalismanUnlock")) { continue; } if (itemDefinition.Name.Contains("StoneOfRecall")) { continue; } if (itemDefinition.Name.Contains("StoneOfWealth")) { continue; } if (!GBIDHandlers.ContainsKey(itemDefinition.Hash) && !AllowedWeaponTypes.Contains(itemDefinition.ItemType1)) { continue; } if (player != null) { if (itemDefinition.RequiredLevel > player.Toon.Level + 3 & itemDefinition.RequiredLevel < player.Toon.Level - 3 ) { continue; } } found = true; } return(itemDefinition); }
public static ItemTypeTable FromString(string name) { int hash = StringHashHelper.HashItemName(name); return(FromHash(hash)); }
public Toon(string name, int hashCode, int classId, ToonFlags flags, byte level, GameAccount account) // Toon with **newly generated** persistent ID : base(StringHashHelper.HashIdentity(name + "#" + hashCode.ToString("D3"))) { this.SetFields(name, hashCode, GetClassByID(classId), flags, level, account, 0); }
public Toon(string name, int classId, ToonFlags flags, byte level, Account account) // Toon with **newly generated** persistent ID : base(StringHashHelper.HashIdentity(name)) { this.SetFields(name, GetClassByID(classId), flags, level, account); }
public override bool Reveal(Player player) { //Logger.Debug(" (Reveal) portal {0} has location {1}", this.ActorSNO, this._position); if (!base.Reveal(player) || this.Destination == null) { return(false); } if (!Activated) { return(false); } player.InGameClient.SendMessage(new PortalSpecifierMessage() { ActorID = this.DynamicID, Destination = this.Destination }); // Show a minimap icon NullD.Common.MPQ.Asset asset; string markerName = ""; if (NullD.Common.MPQ.MPQStorage.Data.Assets[Common.Types.SNO.SNOGroup.LevelArea].TryGetValue(this.Destination.DestLevelAreaSNO, out asset)) { markerName = System.IO.Path.GetFileNameWithoutExtension(asset.FileName); } player.InGameClient.SendMessage(new MapMarkerInfoMessage() { Field0 = (int)World.NewSceneID, // TODO What is the correct id space for mapmarkers? Field1 = new WorldPlace() { Position = this.Position, WorldID = this.World.DynamicID }, Field2 = 0x00018FB0, /* Marker_DungeonEntrance.tex */ // TODO Dont mark all portals as dungeon entrances... some may be exits too (although d3 does not necesarrily use the correct markers). Also i have found no hacky way to determine whether a portal is entrance or exit - farmy m_snoStringList = 0x0000CB2E, /* LevelAreaNames.stl */ // TODO Dont use hardcoded numbers Field3 = StringHashHelper.HashNormal(markerName), Field9 = 0, Field10 = 0, Field11 = 0, Field5 = 0, Field6 = true, Field7 = false, Field8 = true, Field12 = 0 }); if (this.ActorSNO.Id != 5648 & this.ActorSNO.Id != 5660)// && this.ActorSNO.Id != 229013) { //this.World.SpawnMonster(4686, new Vector3D(Position.X, Position.Y, Position.Z - 1)); //uint Need = World.NewActorID - 2; var actors = this.GetActorsInRange(2f); foreach (var actor in actors) { if (actor.ActorSNO.Id == 4686) { if (this.ActorSNO.Id != 5648 && this.ActorSNO.Id != 229013) { actor.Attributes[GameAttribute.MinimapIconOverride] = this.ActorData.TagMap[ActorKeys.MinimapMarker].Id; } else { actor.Attributes[GameAttribute.MinimapIconOverride] = 102321; } actor.Attributes[GameAttribute.MinimapActive] = true; actor.Attributes.BroadcastChangedIfRevealed(); } } } return(true); }