private void Evolve(Client client, Pet pet1, Pet pet2) { int l1 = pet1.FirstPetLevel.Level == 1 ? 1 : pet1.FirstPetLevel.Level / 2; int l2 = pet2.FirstPetLevel.Level == 1 ? 1 : pet2.FirstPetLevel.Level / 2; int level = l1 + l2 + 20; PetStruct s = null; pet1.EvolveResult(level, (int)pet1.PetRarity + 1, ref s); if (s == null) { return; } PetSkin skin = client.Manager.GameData.IdToPetSkin[s.DefaultSkin]; client.Manager.Database.DoActionAsync(db => { var cmd = db.CreateQuery(); cmd.CommandText = "UPDATE pets SET rarity=rarity+1, maxLevel=@level, skinName=@skinName, skin=@skinId, objType=@objType WHERE petId=@petId1 AND accId=@accId;"; cmd.Parameters.AddWithValue("@accId", client.Account.AccountId); cmd.Parameters.AddWithValue("@petId1", pet1.PetId); cmd.Parameters.AddWithValue("@level", level); cmd.Parameters.AddWithValue("@skinName", skin.DisplayId); cmd.Parameters.AddWithValue("@skinId", skin.ObjectType); cmd.Parameters.AddWithValue("@objType", s.ObjectType); cmd.ExecuteNonQuery(); cmd = db.CreateQuery(); cmd.CommandText = "DELETE FROM pets WHERE accId=@accId AND petId=@petId2;"; cmd.Parameters.AddWithValue("@accId", client.Account.AccountId); cmd.Parameters.AddWithValue("@petId2", pet2.PetId); cmd.ExecuteNonQuery(); }); }
public static void Create(RealmManager manager, Player player, Item egg) { manager.Database.AddDatabaseOperation(db => { PetStruct petStruct = GetPetStruct(manager, egg.Family, (Rarity)egg.Rarity); PetSkin skin = manager.GameData.IdToPetSkin[petStruct.DefaultSkin]; PetItem item = new PetItem { InstanceId = db.GetNextPetId(player.AccountId), Rarity = (int)egg.Rarity, SkinName = skin.DisplayId, Skin = skin.ObjectType, Type = petStruct.ObjectType, Abilities = GetPetAbilites(egg, petStruct), }; switch (item.Rarity) { case 1: item.MaxAbilityPower = 50; item.Abilities[0].Power = 30; item.Abilities[0].Points = 2080; item.Abilities[1].Power = 11; item.Abilities[1].Points = 290; item.Abilities[2].Power = 1; item.Abilities[2].Points = 0; break; case 2: item.MaxAbilityPower = 70; item.Abilities[0].Power = 50; item.Abilities[0].Points = 10607; item.Abilities[1].Power = 30; item.Abilities[1].Points = 2080; item.Abilities[2].Power = 1; item.Abilities[2].Points = 0; break; case 3: item.MaxAbilityPower = 90; item.Abilities[0].Power = 70; item.Abilities[0].Points = 50355; item.Abilities[1].Power = 50; item.Abilities[1].Points = 10607; item.Abilities[2].Power = 30; item.Abilities[2].Points = 2080; break; case 4: item.MaxAbilityPower = 100; item.Abilities[0].Power = 90; item.Abilities[0].Points = 235610; item.Abilities[1].Power = 70; item.Abilities[1].Points = 50354; item.Abilities[2].Power = 50; item.Abilities[2].Points = 10607; break; default: item.MaxAbilityPower = 30; item.Abilities[0].Power = 1; item.Abilities[0].Points = 0; item.Abilities[1].Power = 1; item.Abilities[1].Points = 0; item.Abilities[2].Power = 1; item.Abilities[2].Points = 0; break; } Pet pet = new Pet(manager, item, null); int x; int y; Random rand = new Random((int)DateTime.Now.Ticks); do { x = rand.Next(0, player.Owner.Map.Width); y = rand.Next(0, player.Owner.Map.Height); } while (player.Owner.Map[x, y].Region != TileRegion.Spawn); pet.Move(x + 0.5f, y + 0.5f); db.CreatePet(player.Client.Account, item); player.Owner.EnterWorld(pet); player.Client.SendPacket(new HatchPetMessagePacket { PetName = skin.DisplayId, PetSkin = skin.ObjectType }); player.Client.SendPacket(new UpdatePacket { Tiles = new UpdatePacket.TileData[0], NewObjects = new ObjectDef[1] { pet.ToDefinition() }, RemovedObjectIds = new int[0] }); }); }
public void AddObjects(XElement root) { foreach (XElement elem in root.XPathSelectElements("//Object")) { if (elem.Element("Class") == null) { continue; } string cls = elem.Element("Class").Value; string id = elem.Attribute("id").Value; ushort type; XAttribute typeAttr = elem.Attribute("type"); if (typeAttr == null) { continue; } type = (ushort)Utils.FromString(typeAttr.Value); if (cls == "PetBehavior" || cls == "PetAbility") { continue; } if (type2id_obj.ContainsKey(type)) { log.WarnFormat("'{0}' and '{1}' has the same ID of 0x{2:x4}!", id, type2id_obj[type], type); } if (id2type_obj.ContainsKey(id)) { log.WarnFormat("0x{0:x4} and 0x{1:x4} has the same name of {2}!", type, id2type_obj[id], id); } type2id_obj[type] = id; id2type_obj[id] = type; type2elem_obj[type] = elem; switch (cls) { case "Equipment": case "Dye": items[type] = new Item((short)type, elem); break; case "Portal": case "GuildHallPortal": try { portals[type] = new PortalDesc(type, elem); } catch { log.Error("Error for portal: " + type + " id: " + id); } break; case "Pet": type2pet[type] = new PetStruct(type, elem); break; case "PetSkin": id2pet_skin[id] = new PetSkin(type, elem); break; case "PetBehavior": case "PetAbility": break; default: objDescs[type] = new ObjectDesc(type, elem); break; } } }
public void AddObjects(XElement root) { foreach (XElement elem in root.XPathSelectElements("//Object")) { if (elem.Element("Class") == null) { continue; } string cls = elem.Element("Class").Value; string id = elem.Attribute("id").Value; ushort type; XAttribute typeAttr = elem.Attribute("type"); if (typeAttr == null) { type = (ushort)assign.Assign(id, elem); } else { type = (ushort)Utils.FromString(typeAttr.Value); } if (cls == "PetBehavior" || cls == "PetAbility") { continue; } if (type2id_obj.ContainsKey(type)) { log.WarnFormat("'{0}' and '{1}' has the same ID of 0x{2:x4}!", id, type2id_obj[type], type); } if (id2type_obj.ContainsKey(id)) { log.WarnFormat("0x{0:x4} and 0x{1:x4} has the same name of {2}!", type, id2type_obj[id], id); } type2id_obj[type] = id; id2type_obj[id] = type; type2elem_obj[type] = elem; switch (cls) { case "Equipment": case "Dye": items[type] = new Item(type, elem); break; case "Portal": case "GuildHallPortal": try { portals[type] = new PortalDesc(type, elem); } catch { Console.WriteLine("Error for portal: " + type + " id: " + id); /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?* * Tomb Portal of Cowardice, Dungeon Portal, Portal of Cowardice, Realm Portal, Glowing Portal of Cowardice, Glowing Realm Portal, Nexus Portal, Locked Wine Cellar Portal*/ } break; case "Pet": type2pet[type] = new PetStruct(type, elem); break; case "PetSkin": id2pet_skin[id] = new PetSkin(type, elem); break; case "PetBehavior": case "PetAbility": break; default: objDescs[type] = new ObjectDesc(type, elem); break; } XAttribute extAttr = elem.Attribute("ext"); bool ext; if (extAttr != null && bool.TryParse(extAttr.Value, out ext) && ext) { if (elem.Attribute("type") == null) { elem.Add(new XAttribute("type", type)); } addition.Add(elem); updateCount++; } } }
public void AddObjects(XElement root) { foreach (XElement elem in root.XPathSelectElements("//Object")) { if (elem.Element("Class") == null) continue; string cls = elem.Element("Class").Value; string id = elem.Attribute("id").Value; ushort type; XAttribute typeAttr = elem.Attribute("type"); if (typeAttr == null) type = (ushort)assign.Assign(id, elem); else type = (ushort)Utils.FromString(typeAttr.Value); if (cls == "PetBehavior" || cls == "PetAbility") continue; if (type2id_obj.ContainsKey(type)) log.WarnFormat("'{0}' and '{1}' has the same ID of 0x{2:x4}!", id, type2id_obj[type], type); if (id2type_obj.ContainsKey(id)) log.WarnFormat("0x{0:x4} and 0x{1:x4} has the same name of {2}!", type, id2type_obj[id], id); type2id_obj[type] = id; id2type_obj[id] = type; type2elem_obj[type] = elem; switch (cls) { case "Equipment": case "Dye": items[type] = new Item(type, elem); break; case "Portal": case "GuildHallPortal": try { portals[type] = new PortalDesc(type, elem); } catch { Console.WriteLine("Error for portal: " + type + " id: " + id); /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?* * Tomb Portal of Cowardice, Dungeon Portal, Portal of Cowardice, Realm Portal, Glowing Portal of Cowardice, Glowing Realm Portal, Nexus Portal, Locked Wine Cellar Portal*/ } break; case "Pet": type2pet[type] = new PetStruct(type, elem); break; case "PetSkin": id2pet_skin[id] = new PetSkin(type, elem); break; case "PetBehavior": case "PetAbility": break; default: objDescs[type] = new ObjectDesc(type, elem); break; } XAttribute extAttr = elem.Attribute("ext"); bool ext; if (extAttr != null && bool.TryParse(extAttr.Value, out ext) && ext) { if (elem.Attribute("type") == null) elem.Add(new XAttribute("type", type)); addition.Add(elem); updateCount++; } } }
public void CreateSkin(Transform parent, int roleType, string roleName, AnimatorState aniState, bool isplayer = true) { m_Skin = new PetSkin(); m_Skin.CreateSkin(parent, roleType, roleName, aniState, isplayer); }