// Use this for initialization void Start() { if (isServer) { id = objectNum; objectNum++; GameObject tmp = getLocalInstance(lot); if (tmp != null) { localLot = tmp.GetComponent <Lot> (); } else if (localLot != null) { lot = localLot.netId; // the lot was set in the inspector, assign the netid localLot.addObject(this.netId); } GameObject tmpRegion = getLocalInstance(region); if (tmpRegion != null) { localRegion = tmpRegion.GetComponent <Region> (); } else if (localRegion != null) { region = localRegion.netId; localRegion.AddItem(this.netId); } } }
/// <summary> /// Drops item at location. /// </summary> /// <param name="region">Region to drop the item in.</param> /// <param name="pos"> /// Center point of the drop, which is slightly randomized in this method. /// </param> /// <param name="owner"> /// The only entity that is allowed to pick up the item for a /// certain period of time. Set to null to not protect item from /// being picked up. /// </param> /// <param name="playerDrop"> /// Whether the item is being dropped by a player, the owner. /// If it is, normal items aren't protected. /// </param> public void Drop(Region region, Position pos, Creature owner, bool playerDrop) { var rnd = RandomProvider.Get(); // Get random drop position var x = rnd.Next(pos.X - DropRadius, pos.X + DropRadius + 1); var y = rnd.Next(pos.Y - DropRadius, pos.Y + DropRadius + 1); //this.SetNewEntityId(); this.Move(region.Id, x, y); // Keys don't disappear (?) if (!this.HasTag("/key/")) { this.DisappearTime = DateTime.Now.AddSeconds(Math.Max(60, (this.OptionInfo.Price / 100) * 60)); } // Specify who can pick up the item when if (owner != null) { this.OwnerId = owner.EntityId; // Personal items can never be picked up by anyone else var isPersonal = (this.Data.Action == ItemAction.StaticItem || this.Data.Action == ItemAction.AccountPersonalItem || this.Data.Action == ItemAction.CharacterPersonalItem) || this.Is(ItemFlags.Personalized); // Set protection if item wasn't dropped by a player // and it's not a dungeon room key var standardProtection = (!isPersonal && !playerDrop && !this.IsDungeonRoomKey); if (isPersonal) { this.ProtectionLimit = DateTime.MaxValue; } else if (standardProtection) { var seconds = ChannelServer.Instance.Conf.World.LootStealProtection; if (seconds > 0) { this.ProtectionLimit = DateTime.Now.AddSeconds(seconds); } else { this.ProtectionLimit = null; } } } else { this.OwnerId = 0; this.ProtectionLimit = null; } // Add item to region region.AddItem(this); }
/// <summary> /// Drops item in location with a new entity id. /// </summary> /// <param name="region"></param> /// <param name="pos"></param> public void Drop(Region region, Position pos) { var rnd = RandomProvider.Get(); // Get random drop position var x = rnd.Next(pos.X - DropRadius, pos.X + DropRadius + 1); var y = rnd.Next(pos.Y - DropRadius, pos.Y + DropRadius + 1); //this.SetNewEntityId(); this.Move(region.Id, x, y); this.DisappearTime = DateTime.Now.AddSeconds(Math.Max(60, (this.OptionInfo.Price / 100) * 60)); region.AddItem(this); }
/// <summary> /// Drops item at location. /// </summary> /// <param name="region">Region to drop the item in.</param> /// <param name="pos"> /// Center point of the drop, which is slightly randomized in this method. /// </param> /// <param name="radius"> /// Radius around position where the item may drop. /// </param> /// <param name="owner"> /// The only entity that is allowed to pick up the item for a /// certain period of time. Set to null to not protect item from /// being picked up. /// </param> /// <param name="playerDrop"> /// Whether the item is being dropped by a player, the owner. /// If it is, normal items aren't protected. /// </param> public void Drop(Region region, Position pos, int radius, Creature owner, bool playerDrop) { var rnd = RandomProvider.Get(); // Randomize position if radius was specified if (radius > 0) pos = pos.GetRandomInRange(radius, rnd); var x = pos.X; var y = pos.Y; //this.SetNewEntityId(); this.Move(region.Id, x, y); // Keys don't disappear (?) if (!this.HasTag("/key/")) this.DisappearTime = DateTime.Now.AddSeconds(Math.Max(60, (this.OptionInfo.Price / 100) * 60)); // Specify who can pick up the item when if (owner != null) { this.OwnerId = owner.EntityId; // Personal items can never be picked up by anyone else var isPersonal = (this.Data.Action == ItemAction.StaticItem || this.Data.Action == ItemAction.AccountPersonalItem || this.Data.Action == ItemAction.CharacterPersonalItem) || this.Is(ItemFlags.Personalized); // Set protection if item wasn't dropped by a player // and it's not a dungeon room key var standardProtection = (!isPersonal && !playerDrop && !this.IsDungeonRoomKey); if (isPersonal) { this.ProtectionLimit = DateTime.MaxValue; } else if (standardProtection) { var seconds = ChannelServer.Instance.Conf.World.LootStealProtection; if (seconds > 0) this.ProtectionLimit = DateTime.Now.AddSeconds(seconds); else this.ProtectionLimit = null; } } else { this.OwnerId = 0; this.ProtectionLimit = null; } // Random direction this.Info.FigureC = (byte)rnd.Next(256); // Add item to region region.AddItem(this); }
/// <summary> /// Drops item in location with a new entity id. /// </summary> /// <param name="region"></param> /// <param name="pos"></param> public void Drop(Region region, Position pos) { var rnd = RandomProvider.Get(); // Get random drop position var x = rnd.Next(pos.X - DropRadius, pos.X + DropRadius + 1); var y = rnd.Next(pos.Y - DropRadius, pos.Y + DropRadius + 1); //this.SetNewEntityId(); this.Move(region.Id, x, y); // Keys don't disappear (?) if (!this.HasTag("/key/")) this.DisappearTime = DateTime.Now.AddSeconds(Math.Max(60, (this.OptionInfo.Price / 100) * 60)); region.AddItem(this); }