/// <summary> /// Sends EnterDynamicRegion to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="warpFromRegionId"></param> /// <param name="warpToRegion"></param> public static void EnterDynamicRegion(Creature creature, int warpFromRegionId, Region warpToRegion, int x, int y) { var warpTo = warpToRegion as DynamicRegion; if (warpTo == null) throw new ArgumentException("EnterDynamicRegion requires a dynamic region."); var pos = creature.GetPosition(); var packet = new Packet(Op.EnterDynamicRegion, MabiId.Broadcast); packet.PutLong(creature.EntityId); packet.PutInt(warpFromRegionId); // creature's current region or 0? packet.PutInt(warpToRegion.Id); packet.PutString(warpToRegion.Name); // dynamic region name packet.PutUInt(0x80000000); // bitmask? (|1 = time difference?) packet.PutInt(warpTo.BaseId); packet.PutString(warpTo.BaseName); packet.PutInt(200); // 100|200 (100 changes the lighting?) packet.PutByte(0); // 1 = next is empty? packet.PutString("data/world/{0}/{1}", warpTo.BaseName, warpTo.Variation); packet.PutByte(0); //if (^ true) //{ // pp.PutByte(1); // pp.PutInt(3100); // some region id? //} packet.PutInt(x); // target x pos packet.PutInt(y); // target y pos creature.Client.Send(packet); }
/// <summary> /// Broadcasts Notice in region. /// </summary> /// <param name="region"></param> /// <param name="type"></param> /// <param name="duration"></param> /// <param name="format"></param> /// <param name="args"></param> public static void Notice(Region region, NoticeType type, int duration, string format, params object[] args) { var packet = new Packet(Op.Notice, MabiId.Broadcast); packet.PutByte((byte)type); packet.PutString(string.Format(format, args)); if (duration > 0) packet.PutInt(duration); region.Broadcast(packet); }
/// <summary> /// Broadcasts Notice in region. /// </summary> /// <param name="region"></param> /// <param name="type"></param> /// <param name="format"></param> /// <param name="args"></param> public static void Notice(Region region, string format, params object[] args) { Notice(region, NoticeType.Middle, 0, format, args); }
/// <summary> /// Returns true if a campfire can be built at the given position. /// </summary> /// <param name="creature"></param> /// <param name="pos"></param> /// <returns></returns> public static bool IsValidRegion(Region region) { if (region.IsIndoor) return false; return true; }
/// <summary> /// Returns entity by id or null. /// </summary> /// <param name="entityId"></param> /// <returns></returns> private Entity GetTargetEntity(Region region, long entityId) { var isProp = (entityId >= MabiId.ClientProps && entityId < MabiId.AreaEvents); var targetEntity = (isProp ? (Entity)region.GetProp(entityId) : (Entity)region.GetCreature(entityId)); return targetEntity; }
/// <summary> /// Sends EnterDynamicRegionExtended to creature's client. /// </summary> /// <remarks> /// From the looks of it this basically does the same as EnterDynamicRegion, /// but it supports the creation of multiple regions before warping to one. /// </remarks> /// <param name="creature"></param> /// <param name="warpFromRegionId"></param> /// <param name="warpToRegion"></param> public static void EnterDynamicRegionExtended(Creature creature, int warpFromRegionId, Region warpToRegion) { var warpTo = warpToRegion as DynamicRegion; if (warpTo == null) throw new ArgumentException("EnterDynamicRegionExtended requires a dynamic region."); var pos = creature.GetPosition(); var packet = new Packet(Op.EnterDynamicRegionExtended, MabiId.Broadcast); packet.PutLong(creature.EntityId); packet.PutInt(warpFromRegionId); // creature's current region or 0? packet.PutInt(warpToRegion.Id); // target region id packet.PutInt(pos.X); // target x pos packet.PutInt(pos.Y); // target y pos packet.PutInt(0); // 0|4|8|16 packet.PutInt(1); // count of dynamic regions v packet.PutInt(warpToRegion.Id); packet.PutString(warpToRegion.Name); // dynamic region name packet.PutUInt(0x80000000); // bitmask? (|1 = time difference?) packet.PutInt(warpTo.BaseId); packet.PutString(warpTo.BaseName); packet.PutInt(200); // 100|200 packet.PutByte(0); // 1 = next is empty? packet.PutString("data/world/{0}/{1}", warpTo.BaseName, warpTo.Variation); creature.Client.Send(packet); }
/// <summary> /// Adds region to world. /// </summary> /// <param name="region"></param> public void AddRegion(Region region) { lock (_regions) { if (_regions.ContainsKey(region.Id)) { Log.Warning("Region '{0}' already exists.", region.Id); return; } _regions.Add(region.Id, region); } }
/// <summary> /// Broadcasts Weather in region. /// </summary> public static void Weather(Region region, IWeatherProvider provider) { Send.Weather(region.Broadcast, provider); }
/// <summary> /// Adds dynamic region to internal list of dynamic regions, which is /// used to determine which ids are available. This is done automatically /// when you create a new instance of DynamicRegion. /// </summary> /// <param name="dynamicRegion"></param> public void Add(Region dynamicRegion) { lock (_regions) _regions.Add(dynamicRegion.Id, dynamicRegion); }