private void KILL_MONSTER_Packet(Socket s, string[] data) { Character thisclient = GetCharacter(s); Console.WriteLine("MSG_DEBUG", "IN: " + data[0] + " " + data[1] + " " + data[2] + " " + data[3]); int uniquemonid = int.Parse(data[1]); //unique mon id int monid = int.Parse(data[2]); // monster id (type) int mapid = int.Parse(data[3]); Monster m = Database.monsters.GetMonsterByID(monid); bool leveledUp = false; if (m.MonsterID > 0) { thisclient.EXP += m.EXP; while (thisclient.EXP >= EXPTable.GetExpNeededForLevel(thisclient.Level)) { // send level up packet thisclient.EXP = thisclient.EXP - EXPTable.GetExpNeededForLevel(thisclient.Level); thisclient.Level++; thisclient.StatPoints += 3; thisclient.SkillPoints += 3; thisclient.MaxHP += (uint)ExtraStaticFunctions.GetRandomNumber(20, 30); thisclient.MaxMP += (uint)ExtraStaticFunctions.GetRandomNumber(6, 15); thisclient.SaveStats(); // should remove later. SendData(s, "LEVELUP;" + thisclient.Packet()); Console.WriteLine("MSG_INFO", thisclient.Name + " Leveled up to " + thisclient.Level); leveledUp = true; } if (!leveledUp) { SendData(s, "GAINEXP;" + thisclient.EXP); } Console.WriteLine("MSG_INFO", thisclient.Name + " Killed monsterid = " + monid + " and gained " + m.EXP + "exp"); lock (Database.Maps.MapList) { for (int i = 0; i < Database.Maps.MapList.Count; i++) { for (int j = 0; j < Database.Maps.MapList[i].CharactersInMap.Count; j++) { Character charinmap = Database.Maps.MapList[i].CharactersInMap[j]; if (charinmap.Name == thisclient.Name && charinmap.Id == thisclient.Id) { //Console.WriteLine("MSG_DEBUG", "Found character " + thisclient.Name + " in map"); for (int k = 0; k < Database.Maps.MapList[i].MonstersInMap.Count; k++) { if (Database.Maps.MapList[i].MonstersInMap[k].MonsterID == monid && Database.Maps.MapList[i].MonstersInMap[k].ID == uniquemonid) { Console.WriteLine("MSG_DEBUG", "Found monster in map!!! YAY - now removing it."); Database.Maps.MapList[i].MonstersInMap.RemoveAt(k); } } } } } } } else { Console.WriteLine("MSG_FATAL", "Unknown monster found. monid = " + data[2]); } }
public void ImportItems() { if (this.File != "" && this.Database != null) { MySQLHandler MYSQL = Database.MYSQL; itemData = JsonMapper.ToObject(this.File); if (MYSQL.Connection.State != ConnectionState.Open) { try { MYSQL.Connection.Open(); } catch { // err } } MySqlCommand query = MYSQL.Connection.CreateCommand(); query.CommandText = "DELETE FROM `items_information`"; lock (MYSQL) { query.ExecuteNonQuery(); for (int i = 0; i < itemData.Count; i++) { if (itemData[i]["type"].ToString() == "Weapon") { query.CommandText = "INSERT INTO `items_information` (`id`, `type`,`title`,`power`,`defense`,`hp`,`stackable`,`rarity`,`lvl_req`) VALUES ( '" + int.Parse(itemData[i]["id"].ToString()) + "', '" + itemData[i]["type"].ToString() + "', '" + ExtraStaticFunctions.RemoveSpecialCharacters(itemData[i]["title"].ToString()) + "', '" + int.Parse(itemData[i]["weapon"]["attackpower"].ToString()) + "', '0', '0', '0','" + int.Parse(itemData[i]["rarity"].ToString()) + "', '" + int.Parse(itemData[i]["level"].ToString()) + "')"; } else { query.CommandText = "INSERT INTO `items_information` (`id`, `type`,`title`,`power`,`defense`,`hp`,`stackable`,`rarity`,`lvl_req`) VALUES ( '" + int.Parse(itemData[i]["id"].ToString()) + "', '" + itemData[i]["type"].ToString() + "', '" + itemData[i]["title"].ToString() + "', '" + int.Parse(itemData[i]["stats"]["attack"].ToString()) + "', '" + int.Parse(itemData[i]["stats"]["defence"].ToString()) + "', '" + int.Parse(itemData[i]["stats"]["vitality"].ToString()) + "', '" + (bool.Parse(itemData[i]["stackable"].ToString()) ? 1 : 0) + "','" + int.Parse(itemData[i]["rarity"].ToString()) + "', '" + int.Parse(itemData[i]["level"].ToString()) + "')"; } query.ExecuteNonQuery(); } } Console.WriteLine("MSG_STARTUP", "Successsfully Imported all Items!"); } }
public void ImportSkills() { if (this.File != "" && this.Database != null) { MySQLHandler MYSQL = Database.MYSQL; skillData = JsonMapper.ToObject(this.File); if (MYSQL.Connection.State != ConnectionState.Open) { try { MYSQL.Connection.Open(); } catch { // err } } MySqlCommand query = MYSQL.Connection.CreateCommand(); query.CommandText = "DELETE FROM `skills`"; lock (MYSQL) { query.ExecuteNonQuery(); for (int i = 0; i < skillData.Count; i++) { query.CommandText = "INSERT INTO `skills` (`id`,`name`,`attack`,`level`,`mana`) VALUES( '" + skillData[i]["id"] + "', '" + ExtraStaticFunctions.RemoveSpecialCharacters(skillData[i]["title"].ToString()) + "', '" + skillData[i]["attack"] + "', '" + skillData[i]["level"] + "', '" + skillData[i]["mana"] + "')"; query.ExecuteNonQuery(); } } Console.WriteLine("MSG_STARTUP", "Successsfully Imported all Skills!"); } }
public void ImportNPCs() { if (this.File != "" && this.Database != null) { MySQLHandler MYSQL = Database.MYSQL; npcData = JsonMapper.ToObject(this.File); if (MYSQL.Connection.State != ConnectionState.Open) { try { MYSQL.Connection.Open(); } catch { // err } } MySqlCommand query = MYSQL.Connection.CreateCommand(); query.CommandText = "DELETE FROM `npcs`"; lock (MYSQL) { query.ExecuteNonQuery(); for (int i = 0; i < npcData.Count; i++) { query.CommandText = "INSERT INTO `npcs` (`id`,`name`,`mapid`,`x`,`y`,`itemids`,`cost`) VALUES( '" + npcData[i]["id"] + "', '" + ExtraStaticFunctions.RemoveSpecialCharacters(npcData[i]["name"].ToString()) + "', '" + int.Parse(npcData[i]["mapid"].ToString()) + "', '" + npcData[i]["x"] + "', '" + npcData[i]["y"] + "', '" + npcData[i]["sellitems"]["itemids"] + "', '" + npcData[i]["sellitems"]["cost"] + "')"; query.ExecuteNonQuery(); } } Console.WriteLine("MSG_STARTUP", "Successsfully Imported all NPCs!"); } }