Exemple #1
0
        public void Teleport(RealmTime time, int objId)
        {
            if (!TPCooledDown())
            {
                SendError("Too soon to teleport again!");
                return;
            }
            SetTPDisabledPeriod();
            Entity obj = Owner.GetEntity(objId);

            if (obj == null)
            {
                return;
            }
            Move(obj.X, obj.Y);
            fames.Teleport();
            SetNewbiePeriod();
            UpdateCount++;
            Owner.BroadcastPacket(new GotoPacket
            {
                ObjectId = Id,
                Position = new Position
                {
                    X = X,
                    Y = Y
                }
            }, null);
            if (!isNotVisible)
            {
                Owner.BroadcastPacket(new ShowEffectPacket
                {
                    EffectType = EffectType.Teleport,
                    TargetId   = Id,
                    PosA       = new Position
                    {
                        X = X,
                        Y = Y
                    },
                    Color = new ARGB(0xFFFFFFFF)
                }, null);
            }
            if (Pet != null)
            {
                Pet.Move(X, Y);
                Pet.UpdateCount++;
                Pet.Owner.BroadcastPacket(new GotoPacket
                {
                    ObjectId = Pet.Id,
                    Position = new Position
                    {
                        X = Pet.X,
                        Y = Pet.Y
                    }
                }, null);
            }
        }
Exemple #2
0
 public void GivePet(ushort petId)
 {
     if (Pet != null)
     {
         Owner.LeaveWorld(Pet);
     }
     Pet             = Resolve(Manager, petId);
     Pet.playerOwner = this;
     Pet.Move(X, Y);
     Pet.isPet = true;
     Owner.EnterWorld(Pet);
 }
Exemple #3
0
 public void GivePet(short petId)
 {
     if (Pet != null)
     {
         Owner.LeaveWorld(Pet);
     }
     Pet             = Entity.Resolve(petId);
     Pet.PlayerOwner = this;
     Pet.Move(X, Y);
     Pet.isPet = true;
     Owner.EnterWorld(Pet);
 }
Exemple #4
0
        public void GivePet(ushort petId)
        {
            if (Pet != null)
            {
                Owner.LeaveWorld(Pet);
            }

            Pet             = Resolve(Manager, petId);
            Pet.playerOwner = this;
            Pet.Move(X, Y);
            Pet.isPet = true;
            Owner.Timers.Add(new WorldTimer(2000, (world, RealmTime) =>
            {
                Owner.EnterWorld(Pet);
            }));
        }
Exemple #5
0
        private void SpawnPetIfAttached(World owner)
        {
            // despawn old pet if found
            Pet?.Owner?.LeaveWorld(Pet);

            // create new pet
            var petId = PetId;

            if (petId != 0)
            {
                var pet = new Pet(Manager, this, (ushort)petId);
                pet.Move(X, Y);
                owner.EnterWorld(pet);
                pet.SetDefaultSize(pet.ObjectDesc.Size);
                Pet = pet;
            }
        }
Exemple #6
0
        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 static async void Create(RealmManager manager, Player player, Item egg)
        {
            await manager.Database.DoActionAsync(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,
                    Family = egg.Family.ToString(),
                    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 = 0;
                        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 = 0;
                        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 = 0;
                        item.Abilities[1].Points = 0;
                        item.Abilities[2].Power = 0;
                        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 HatchEggPacket
                {
                    PetName = skin.DisplayId,
                    PetSkinId = skin.ObjectType
                });
                player.Client.SendPacket(new UpdatePacket
                {
                    Tiles = new UpdatePacket.TileData[0],
                    NewObjects = new ObjectDef[1] { pet.ToDefinition() },
                    RemovedObjectIds = new int[0]
                });
            });
        }
        private void LoadPetYardData(Player player)
        {
            Manager.Database.DoActionAsync(db =>
            {
                MySqlCommand cmd = db.CreateQuery();
                cmd.CommandText = "SELECT petId, objType FROM pets WHERE accId=@accId AND NOT petId=@petId;";
                cmd.Parameters.AddWithValue("@accId", player.AccountId);
                cmd.Parameters.AddWithValue("@petId", player.Pet is Pet ? player.Pet.PetId : -1);

                List<PetItem> petData = new List<PetItem>();

                using (MySqlDataReader rdr = cmd.ExecuteReader())
                {
                    while (rdr.Read())
                    {
                        int petId = rdr.GetInt32("petId");
                        if (player.Pet != null && player.Pet.PetId == petId) continue;
                        petData.Add(db.GetPet(petId, player.Client.Account));
                    }
                }

                foreach (PetItem i in petData)
                {
                    Pet obj = new Pet(player.Manager, i, null);
                    int x, y;
                    do
                    {
                        x = player.Random.Next(0, this.Map.Width);
                        y = player.Random.Next(0, this.Map.Height);
                    } while (this.Map[x, y].Region != TileRegion.PetRegion || this.Map[x, y].ObjType != 0);
                    obj.Move(x + 0.5f, y + 0.5f);
                    EnterWorld(obj);
                }
            });
        }
        public override void Init(World owner)
        {
            var x            = 0;
            var y            = 0;
            var spawnRegions = owner.GetSpawnPoints();

            if (spawnRegions.Any())
            {
                var rand    = new System.Random();
                var sRegion = spawnRegions.ElementAt(rand.Next(0, spawnRegions.Length));
                x = sRegion.Key.X;
                y = sRegion.Key.Y;
            }
            Move(x + 0.5f, y + 0.5f);
            tiles = new byte[owner.Map.Width, owner.Map.Height];

            // spawn pet if player has one attached
            var petId = _client.Character.PetId;

            if (petId > 0 && Manager.Config.serverSettings.enablePets)
            {
                var dbPet = new DbPet(Client.Account, petId);
                if (dbPet.ObjectType != 0)
                {
                    var pet = new Pet(Manager, this, dbPet);
                    pet.Move(X, Y);
                    owner.EnterWorld(pet);
                    Pet = pet;
                }
            }

            FameCounter    = new FameCounter(this);
            FameGoal       = GetFameGoal(FameCounter.ClassStats[ObjectType].BestFame);
            ExperienceGoal = GetExpGoal(_client.Character.Level);
            Stars          = GetStars();

            if (owner.Name.Equals("OceanTrench"))
            {
                OxygenBar = 100;
            }

            SetNewbiePeriod();

            if (owner.IsNotCombatMapArea)
            {
                Client.SendPacket(new GlobalNotification
                {
                    Text = Client.Account.Gifts.Length > 0 ? "giftChestOccupied" : "giftChestEmpty"
                });

                if (DeathArena.Instance?.CurrentState != DeathArena.ArenaState.NotStarted && DeathArena.Instance?.CurrentState != DeathArena.ArenaState.Ended)
                {
                    Client.SendPacket(new GlobalNotification
                    {
                        Type = GlobalNotification.ADD_ARENA,
                        Text = $"{{\"name\":\"Oryx Arena\",\"open\":{DeathArena.Instance?.CurrentState == DeathArena.ArenaState.CountDown}}}"
                    });
                }

                if (worlds.logic.Arena.Instance?.CurrentState != worlds.logic.Arena.ArenaState.NotStarted)
                {
                    Client.SendPacket(new GlobalNotification
                    {
                        Type = GlobalNotification.ADD_ARENA,
                        Text = $"{{\"name\":\"Public Arena\",\"open\":{worlds.logic.Arena.Instance?.CurrentState == worlds.logic.Arena.ArenaState.CountDown}}}"
                    });
                }
            }

            base.Init(owner);
        }