public List <MonsterDrop> GetAllMonsterDrops() { List <MonsterDrop> monsterDrops = new List <MonsterDrop>(); SqlDataReader reader = null; using (SqlConnection _conn = new SqlConnection(connectionString)) { _conn.Open(); SqlCommand cmd = new SqlCommand("GetAllMonsterDrops", _conn); cmd.CommandType = CommandType.StoredProcedure; reader = cmd.ExecuteReader(); while (reader.Read()) { int id = Convert.ToInt32(reader["MonsterDropID"]); int monsterID = Convert.ToInt32(reader["MonsterID"]); int dropID = Convert.ToInt32(reader["DropID"]); int chance = Convert.ToInt32(reader["Chance"]); MonsterDrop monsterdrop = new MonsterDrop(id, monsterID, dropID, chance); monsterDrops.Add(monsterdrop); } } return(monsterDrops); }
public EnemyDropFile(string inFilename, byte[] rawData, byte[] subHeader, int[] ptrs, int baseAddr) { filename = inFilename; header = subHeader; calculatedPointers = (int[])ptrs.Clone(); byte[] rawTemp = new byte[rawData.Length]; Array.Copy(rawData, rawTemp, rawData.Length); for (int i = 0; i < ptrs.Length; i++) { calculatedPointers[i] -= baseAddr; int ptr = BitConverter.ToInt32(rawData, calculatedPointers[i]); ptr -= baseAddr; Array.Copy(BitConverter.GetBytes(ptr), 0, rawTemp, calculatedPointers[i], 4); } MemoryStream inStream = new MemoryStream(rawTemp); BinaryReader inReader = new BinaryReader(inStream); inStream.Seek(8, SeekOrigin.Begin); int mainPointer = inReader.ReadInt32(); inStream.Seek(mainPointer, SeekOrigin.Begin); int specialDropCount = inReader.ReadInt16(); int levelDropCount = inReader.ReadInt16(); int specialDropLoc = inReader.ReadInt32(); int levelDropLoc = inReader.ReadInt32(); inStream.Seek(specialDropLoc, SeekOrigin.Begin); byte[] specialDrops = inReader.ReadBytes(specialDropCount * 16); inStream.Seek(levelDropLoc, SeekOrigin.Begin); monsterDrops = new MonsterDrop[levelDropCount]; for (int i = 0; i < levelDropCount; i++) { MonsterDrop temp = new MonsterDrop(); temp.EnemyNum = inReader.ReadUInt16(); temp.SpecialNum = inReader.ReadUInt16(); temp.DropNothing = inReader.ReadUInt16(); temp.MesetaProb = inReader.ReadUInt16(); temp.AreaProb = inReader.ReadUInt16(); temp.Tier1Prob = inReader.ReadUInt16(); temp.Tier2Prob = inReader.ReadUInt16(); temp.Tier3Prob = inReader.ReadUInt16(); temp.Tier4Prob = inReader.ReadUInt16(); temp.Tier5Prob = inReader.ReadUInt16(); temp.MesetaMin = inReader.ReadUInt16(); temp.MesetaMax = inReader.ReadUInt16(); temp.Tier1Drop = inReader.ReadByte() << 24 | inReader.ReadByte() << 16 | inReader.ReadByte() << 8 | inReader.ReadByte(); temp.Tier2Drop = inReader.ReadByte() << 24 | inReader.ReadByte() << 16 | inReader.ReadByte() << 8 | inReader.ReadByte(); temp.Tier3Drop = inReader.ReadByte() << 24 | inReader.ReadByte() << 16 | inReader.ReadByte() << 8 | inReader.ReadByte(); temp.Tier4Drop = inReader.ReadByte() << 24 | inReader.ReadByte() << 16 | inReader.ReadByte() << 8 | inReader.ReadByte(); temp.Tier5Drop = inReader.ReadByte() << 24 | inReader.ReadByte() << 16 | inReader.ReadByte() << 8 | inReader.ReadByte(); temp.SpecDrop1 = specialDrops[temp.SpecialNum * 16 + 0] << 24 | specialDrops[temp.SpecialNum * 16 + 1] << 16 | specialDrops[temp.SpecialNum * 16 + 2] << 8 | specialDrops[temp.SpecialNum * 16 + 3]; temp.SpecDrop2 = specialDrops[temp.SpecialNum * 16 + 4] << 24 | specialDrops[temp.SpecialNum * 16 + 5] << 16 | specialDrops[temp.SpecialNum * 16 + 6] << 8 | specialDrops[temp.SpecialNum * 16 + 7]; temp.SpecDrop3 = specialDrops[temp.SpecialNum * 16 + 8] << 24 | specialDrops[temp.SpecialNum * 16 + 9] << 16 | specialDrops[temp.SpecialNum * 16 + 10] << 8 | specialDrops[temp.SpecialNum * 16 + 11]; temp.SpecProb1 = BitConverter.ToUInt16(specialDrops, temp.SpecialNum * 16 + 12); temp.SpecProb2 = BitConverter.ToUInt16(specialDrops, temp.SpecialNum * 16 + 14); monsterDrops[i] = temp; } }
public double AdjustDropChance(IFightResult looter, MonsterDrop item, sbyte dropperGradeId, int monsterAgeBonus, int dropBonusPercent) { dropBonusPercent = dropBonusPercent == 0 ? 1 : dropBonusPercent; var dropRate = item.GetDropRate((int)dropperGradeId); var prospecting = ((double)looter.Prospecting / 100.0); int result = (int)(dropRate * (double)prospecting * ((double)monsterAgeBonus / (double)100.0 + (double)1.0) * (double)WorldConfiguration.Instance.DropsRate); result += result.GetPercentageOf(dropBonusPercent); return(result / 5d); }
public double AdjustDropChance(int teamPp, MonsterDrop item, sbyte dropperGradeId, int monsterAgeBonus, int dropBonusPercent) { dropBonusPercent = dropBonusPercent == 0 ? 1 : dropBonusPercent; var dropRate = item.GetDropRate(dropperGradeId); var prospecting = teamPp / 100.0; int result = (int)(dropRate * prospecting * (monsterAgeBonus / 100.0 + 1.0)); result += result.GetPercentageOf(dropBonusPercent); return(result / 5d * WorldConfiguration.Instance.DropsRate); }
public void createDrops(List <int> drops, Vector3 pos) { foreach (int dropNum in drops) { GameObject o = GameObject.Instantiate(dropPrefab, mapPanel); o.transform.position = pos; MonsterDrop drop = o.GetComponent <MonsterDrop> (); drop.dropManager = this; monsterDroppings.Add(drop); drop.unpickableTime = 0.5f;; drop.moveToRandomNearby(); } }
private static void RemoveDrop(WorldClient client, string[] args) { if (args.Length < 2) { client.Character.Reply("Remove a drop from a monster"); client.Character.Reply("» .drops rmdrop|rm|rd $ItemId $MonsterId"); client.Character.Reply("- <b>$ItemId</b> ⇒ The ID of the item."); client.Character.Reply("- <b>$MonsterId</b> ⇒ The ID of the monster."); return; } ushort itemId = ushort.Parse(args[1]); ItemRecord item = ItemRecord.GetItem(itemId); if (args.Length != 3) { int count = 0; foreach (MonsterRecord monster in MonsterRecord.Monsters) { MonsterDrop drop = monster.Drops.Find(d => d.ItemId == itemId); if (drop != null) { monster.Drops.Remove(drop); count++; client.Character.Reply($" - Removed drop from monster {monster.Name} ({monster.Id})."); monster.UpdateInstantElement(); } } client.Character.Reply($"Removed drop '{item.Name}' ({item.Id}) from {count} monsters."); } else { ushort monsterId = ushort.Parse(args[2]); MonsterRecord monsterRecord = MonsterRecord.GetMonster(monsterId); monsterRecord.Drops.RemoveAll(d => d.ItemId == itemId); monsterRecord.UpdateInstantElement(); client.Character.Reply($"Successfully removed drop '{item.Name}' ({item.Id}) from monster '{monsterRecord.Name}' {monsterId}"); } }
static void AddDrop(ushort monsterId, ushort itemId, int dropPercent) { var monster = MonsterRecord.GetMonster(monsterId); var drop = new MonsterDrop() { ItemId = itemId, Count = 1, DropId = 0, DropLimit = 1, HasCriteria = false, PercentDropForGrade1 = (short)(dropPercent), PercentDropForGrade2 = (short)(dropPercent + 2), PercentDropForGrade3 = (short)(dropPercent + 4), PercentDropForGrade4 = (short)(dropPercent + 6), PercentDropForGrade5 = (short)(dropPercent + 8), ProspectingLock = 100 }; monster.Drops.Add(drop); }
private static void UpdateDrop(WorldClient client, string[] args) { if (args.Length < 6) { client.Character.Reply("Add a drop to a set of monsters"); client.Character.Reply("» .drops updatedrop|ud $ItemId $MonsterId $DropRate $MinPP $MinCount $MaxCount"); client.Character.Reply(" - <b>$ItemId</b> ⇒ The ID of the item."); client.Character.Reply(" - <b>$MonsterId</b> ⇒ The ID of the item."); client.Character.Reply(" - <b>$DropRate</b> ⇒ The drop percent [0, 100]."); client.Character.Reply(" - <b>$MinPP</b> ⇒ The min PP value0."); client.Character.Reply(" - <b>$MinCount</b> ⇒ Minimum number of dropped items."); client.Character.Reply(" - <b>$MaxCount</b> ⇒ Maximum number of dropped items."); return; } ushort itemId = ushort.Parse(args[1]); ushort monsterId = ushort.Parse(args[2]); short dropRate = short.Parse(args[3]); int pp = int.Parse(args[4]); int minCount = int.Parse(args[5]); int maxCount = int.Parse(args[6]); ItemRecord item = ItemRecord.GetItem(itemId); MonsterRecord monsterRecord = MonsterRecord.GetMonster(monsterId); MonsterDrop monsterDrop = monsterRecord.Drops.Find(d => d.ItemId == itemId); monsterDrop.PercentDropForGrade1 = dropRate; monsterDrop.PercentDropForGrade2 = (short)(dropRate + 2); monsterDrop.PercentDropForGrade3 = (short)(dropRate + 4); monsterDrop.PercentDropForGrade4 = (short)(dropRate + 6); monsterDrop.PercentDropForGrade5 = (short)(dropRate + 8); monsterDrop.Count = minCount; monsterDrop.DropLimit = maxCount; monsterDrop.ProspectingLock = pp; monsterRecord.UpdateInstantElement(); client.Character.Reply($"Successfully removed drop '{item.Name}' ({item.Id}) from monster '{monsterRecord.Name}' {monsterId}"); }
public static void Load() { if (Loaded == true || Loading == true) { return; } Loading = true; // Trigger events for scripts Events.InvokeWorldLoadStart(); // Our object manager for databsae objects Database = new DatabaseObjectManager(); // Our object manager for world objects (spawned objects) Objects = new WorldObjectManager(); // Delegate for Send() Method mForeachInRangeCallback = new ForeachInRangeVoidDelegate(SendSub); mAddQueue = new Queue <DatabaseObject>(); mDelQueue = new Queue <DatabaseObject>(); // Load globals from config, initialize packets ect ServerConsole.InfoLine("Initialize game symantics..."); Global.Initialize(); WorldObjectStatus.Initialize(); ChatHelper.Initialize(); PlayerCommandHelper.Initialize(); PathHelper.Initialize(); SkillTree.Initialize(); FameListHelper.Initialize(); CharacterJobBonus.Initialize(); CharacterJobModifer.Initialize(); // Real database loading ServerConsole.InfoLine("Begin World loading..."); DataTable table = null; Stopwatch watchAll = Stopwatch.StartNew(); Stopwatch watch = Stopwatch.StartNew(); //------------- loading start ------------- #region Mapcache ServerConsole.Info("\t# loading Maps from mapcache..."); watch.Reset(); watch.Start(); Mapcache.Initialize(); watch.Stop(); ServerConsole.WriteLine(EConsoleColor.Status, " done (" + Mapcache.Maps.Count + " Maps in " + watch.ElapsedMilliseconds + "ms)"); #endregion #region Items ServerConsole.Info("\t# loading Items..."); watch.Reset(); watch.Start(); table = Core.Database.Query("SELECT * FROM dbitem"); table.TableName = "ItemDB Table"; if (table == null || table.Rows.Count == 0) { if (Core.Database.LastError != null) { ServerConsole.ErrorLine("failed to load Item Database!"); ServerConsole.WriteLine(Core.Database.LastError.ToString()); } } else { ItemDatabaseData item; for (int i = 0; i < table.Rows.Count; i++) { item = ItemDatabaseData.Load(table.Rows[i]); if (item == null) { ServerConsole.WarningLine("Failed to load item {0}: #{1} {2}", i, table.Rows[i].Field <int>("itemID"), table.Rows[i].Field <string>("nameEnglish")); continue; } Database.Add(item); //ServerConsole.DebugLine("\tLoad: #{0} {1}", item.NameID.ToString().PadLeft(5), item.Name); } } watch.Stop(); ServerConsole.WriteLine(EConsoleColor.Status, " done (" + Database.Items.Count + " Items in " + watch.ElapsedMilliseconds + "ms)"); #endregion #region Monster ServerConsole.Info("\t# loading Mobs..."); watch.Reset(); watch.Start(); table = Core.Database.Query("SELECT * FROM dbmob"); table.TableName = "MobDB Table"; if (table == null || table.Rows.Count == 0) { if (Core.Database.LastError != null) { ServerConsole.ErrorLine("failed to load Monster Database!"); ServerConsole.WriteLine(Core.Database.LastError.ToString()); } } else { MonsterDatabaseData mob; for (int i = 0; i < table.Rows.Count; i++) { mob = MonsterDatabaseData.Load(table.Rows[i]); if (mob == null) { ServerConsole.WarningLine("Failed to load mob {0}: #{1} {2}", i, table.Rows[i].Field <int>("mobID"), table.Rows[i].Field <string>("nameInter")); continue; } Database.Add(mob); //ServerConsole.DebugLine("\tLoad: #{0} {1} ({2} drops, {3} skills)", mob.ID.ToString().PadLeft(5), mob.NameInter, mob.Drops.Count, mob.Skills.Count); } } watch.Stop(); ServerConsole.WriteLine(EConsoleColor.Status, " done (" + Database.Monster.Count + " Mobs in " + watch.ElapsedMilliseconds + "ms)"); ServerConsole.Info("\t# loading Mob Skills..."); watch.Reset(); watch.Start(); table = Core.Database.Query("SELECT * FROM dbmob_skill ORDER BY mobID ASC"); table.TableName = "MobDB Skill Table"; if (table == null || table.Rows.Count == 0) { if (Core.Database.LastError != null) { ServerConsole.ErrorLine("failed to load Mob Skill Database!"); ServerConsole.WriteLine(Core.Database.LastError.ToString()); } } else { MonsterSkill mobSkill; for (int i = 0; i < table.Rows.Count; i++) { mobSkill = MonsterSkill.Load(table.Rows[i]); if (mobSkill == null) { throw new Exception(string.Format("Failed to load mob skill #{0}: {1}", table.Rows[i].Field <int>("mobID"), table.Rows[i].Field <string>("info"))); } (Database[EDatabaseType.Mob, mobSkill.MobID] as MonsterDatabaseData).Skills.Add(mobSkill); //ServerConsole.DebugLine("\tLoad: #{0} {1} ({2} level)", skill.ID.ToString().PadLeft(5), skill.Name, skill.Level.Count); } } watch.Stop(); ServerConsole.WriteLine(EConsoleColor.Status, " done in " + watch.ElapsedMilliseconds + "ms"); ServerConsole.Info("\t# loading Mob Drops..."); watch.Reset(); watch.Start(); table = Core.Database.Query("SELECT * FROM dbmob_drop ORDER BY mobID ASC"); table.TableName = "MobDB Drop Table"; if (table == null || table.Rows.Count == 0) { if (Core.Database.LastError != null) { ServerConsole.ErrorLine("failed to load Mob Drop Database!"); ServerConsole.WriteLine(Core.Database.LastError.ToString()); } } else { MonsterDrop drop; for (int i = 0; i < table.Rows.Count; i++) { drop = MonsterDrop.Load(table.Rows[i]); (Database[EDatabaseType.Mob, drop.MobID] as MonsterDatabaseData).Drops.Add(drop); //ServerConsole.DebugLine("\tLoad: #{0} {1} ({2} level)", skill.ID.ToString().PadLeft(5), skill.Name, skill.Level.Count); } } watch.Stop(); ServerConsole.WriteLine(EConsoleColor.Status, " done in " + watch.ElapsedMilliseconds + "ms"); #endregion #region General Skills ServerConsole.Info("\t# loading Skills..."); watch.Reset(); watch.Start(); table = Core.Database.Query("SELECT * FROM dbskill"); table.TableName = "SkillDB Table"; if (table == null || table.Rows.Count == 0) { if (Core.Database.LastError != null) { ServerConsole.ErrorLine("failed to load Skill Database!"); ServerConsole.WriteLine(Core.Database.LastError.ToString()); } } else { SkillDatabaseData skill; for (int i = 0; i < table.Rows.Count; i++) { skill = SkillDatabaseData.Load(table.Rows[i]); if (skill == null) { ServerConsole.WarningLine("Failed to load skill {0}: #{1} {2}", i, table.Rows[i].Field <int>("skillID"), table.Rows[i].Field <string>("name")); continue; } Database.Add(skill.Index, skill); //ServerConsole.DebugLine("\tLoad: #{0} {1} ({2} level)", skill.ID.ToString().PadLeft(5), skill.Name, skill.Level.Count); } } watch.Stop(); ServerConsole.WriteLine(EConsoleColor.Status, " done (" + Database.Skill.Count + " Skills in " + watch.ElapsedMilliseconds + "ms)"); #endregion // Loading other shit // o.o //------------- loading end ------------- // Trigger event for scripts Events.InvokeWorldLoadFinish(); Loading = false; Loaded = true; ProcessSafetyQueues(); // TODO: Initialize save timer ServerConsole.InfoLine("Finished World loading! Needed {0:F2} sec", watchAll.Elapsed.TotalSeconds); watch.Stop(); watch = null; watchAll.Stop(); watchAll = null; }
// public void addDrop(List<MonsterDrop> newDrops){ // monsterDroppings.AddRange(newDrops); // } public void removeDrop(MonsterDrop toRemove) { monsterDroppings.Remove(toRemove); }
private static void AddDrop(WorldClient client, string[] args) { if (args.Length < 4) { client.Character.Reply("Add a drop to a set of monsters"); client.Character.Reply("» .drops adddrop|ad $ItemId $DropRateG1[,$G2,$G3,G4,G5] $MinPP $MinCount $MaxCount [$MonsterId ...]"); client.Character.Reply(" - <b>$ItemId</b> ⇒ The ID of the item."); client.Character.Reply(" - <b>$DropRateG1</b> ⇒ The drop percent [0, 100]. "); client.Character.Reply(" - <b>$G2,3,4,5</b> ⇒ The drop percent [0, 100] for each grade. "); client.Character.Reply(" - <b>$MinPP</b> ⇒ The min PP value0."); client.Character.Reply(" - <b>$MinCount</b> ⇒ Minimum number of dropped items."); client.Character.Reply(" - <b>$MaxCount</b> ⇒ Maximum number of dropped items."); client.Character.Reply(" - <b>$MonsterId</b> ⇒ The ID of the monster."); return; } ushort itemId = ushort.Parse(args[1]); string rates = args[2]; int pp = int.Parse(args[3]); int minCount = int.Parse(args[4]); int maxCount = int.Parse(args[5]); string[] ratesSplit = rates.Split(','); short g1 = short.Parse(ratesSplit[0]); short g2 = (short)(g1 + 2); short g3 = (short)(g1 + 4); short g4 = (short)(g1 + 6); short g5 = (short)(g1 + 8); if (ratesSplit.Length == 5) { g2 = short.Parse(ratesSplit[1]); g3 = short.Parse(ratesSplit[2]); g4 = short.Parse(ratesSplit[3]); g5 = short.Parse(ratesSplit[4]); } ItemRecord item = ItemRecord.GetItem(itemId); int nextDropId = MonsterRecord.GetNextDropId(); for (int i = 6; i < args.Length; i++) { ushort monsterId = ushort.Parse(args[i]); MonsterRecord monster = MonsterRecord.GetMonster(monsterId); MonsterDrop drop = new MonsterDrop() { ItemId = itemId, Count = minCount, DropId = nextDropId, DropLimit = maxCount, HasCriteria = false, PercentDropForGrade1 = g1, PercentDropForGrade2 = g2, PercentDropForGrade3 = g3, PercentDropForGrade4 = g4, PercentDropForGrade5 = g5, ProspectingLock = pp }; monster.Drops.Add(drop); // TODO: check if necessary. monster.UpdateInstantElement(); client.Character.Reply($"Added drop '{item.Name}' ({itemId}) to monster '{monster.Name}' ({monsterId}) with drop rates {g1},{g2},{g3},{g4},{g5} (DropId={nextDropId})."); nextDropId++; } }