/// <summary> /// Sends BlacksmithingMiniGame to creature's client, which starts /// the Blacksmithing mini-game. /// </summary> /// <remarks> /// The position of the dots is relative to the upper left of the /// field. They land exactly on those spots after "wavering" for a /// moment. This wavering is randomized on the client side and /// doesn't affect anything. /// /// The time bar is always the same, but the time it takes to fill /// up changes based on the "time displacement". The lower the value, /// the longer it takes to fill up. Using values that are too high /// or too low mess up the calculations and cause confusing results. /// The official range seems to be between ~0.81 and ~0.98. /// </remarks> /// <param name="creature"></param> /// <param name="prop"></param> /// <param name="item"></param> /// <param name="dots"></param> /// <param name="deviation"></param> public static void BlacksmithingMiniGame(Creature creature, Prop prop, Item item, List<BlacksmithDot> dots, int deviation) { if (dots == null || dots.Count != 5) throw new ArgumentException("5 dots required."); var packet = new Packet(Op.BlacksmithingMiniGame, creature.EntityId); // Untested if this is actually the deviation/cursor size, // but Tailoring does something very similar. Just like with // Tailoring, wrong values cause failed games. packet.PutShort((short)deviation); foreach (var dot in dots) { packet.PutShort((short)dot.X); packet.PutShort((short)dot.Y); packet.PutFloat(dot.TimeDisplacement); packet.PutShort((short)dot.Deviation); } packet.PutLong(prop.EntityId); packet.PutInt(0); packet.PutLong(item.EntityId); packet.PutInt(0); creature.Client.Send(packet); }
/// <summary> /// Sends Disappear to creature's client. /// </summary> /// <remarks> /// Should this be broadcasted? What does it even do? TODO. /// </remarks> /// <param name="creature"></param> public static void Disappear(Creature creature) { var packet = new Packet(Op.Disappear, MabiId.Channel); packet.PutLong(creature.EntityId); creature.Client.Send(packet); }
/// <summary> /// Sends DestroyExpiredItemsR to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="success"></param> public static void DestroyExpiredItemsR(Creature creature, bool success) { var packet = new Packet(Op.DestroyExpiredItemsR, creature.EntityId); packet.PutByte(success); creature.Client.Send(packet); }
/// <summary> /// Sends TouchPropR to creature's client. /// </summary> /// <param name="creature"></param> public static void TouchPropR(Creature creature) { var packet = new Packet(Op.TouchPropR, creature.EntityId); packet.PutByte(true); creature.Client.Send(packet); }
/// <summary> /// Sends MailsRequestR to creature's client. /// </summary> /// <param name="creature"></param> public static void MailsRequestR(Creature creature) { var packet = new Packet(Op.MailsRequestR, creature.EntityId); // ... creature.Client.Send(packet); }
/// <summary> /// Sends RequestRebirthR to creature's client. /// </summary> /// <param name="vehicle"></param> public static void RequestRebirthR(Creature creature, bool success) { var packet = new Packet(Op.RequestRebirthR, MabiId.Login); packet.PutByte(success); creature.Client.Send(packet); }
/// <summary> /// Prepares skill, skips right to used. /// </summary> /// <remarks> /// Doesn't check anything, like what you can gather with what, /// because at this point there's no chance for abuse. /// </remarks> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="packet"></param> /// <returns></returns> public bool Prepare(Creature creature, Skill skill, Packet packet) { var entityId = packet.GetLong(); var collectId = packet.GetInt(); // You shall stop creature.StopMove(); var creaturePosition = creature.GetPosition(); // Get target (either prop or creature) var targetEntity = this.GetTargetEntity(creature.Region, entityId); if (targetEntity != null) creature.Temp.GatheringTargetPosition = targetEntity.GetPosition(); // Check distance if (!creaturePosition.InRange(creature.Temp.GatheringTargetPosition, MaxDistance)) { Send.Notice(creature, Localization.Get("Your arms are too short to reach that from here.")); return false; } // ? (sets creatures position on the client side) Send.CollectAnimation(creature, entityId, collectId, creaturePosition); // Use Send.SkillUse(creature, skill.Info.Id, entityId, collectId); skill.State = SkillState.Used; return true; }
/// <summary> /// Prepares skill, goes straight to use to skip readying and using it. /// </summary> /// <remarks> /// The client will take a moment to send the Complete packet, /// as if it would cast the skill first. /// </remarks> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="packet"></param> public bool Prepare(Creature creature, Skill skill, Packet packet) { Send.SkillUse(creature, skill.Info.Id, 0); skill.State = SkillState.Used; return true; }
/// <summary> /// Completes skill, dropping a cobweb. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="packet"></param> public void Complete(Creature creature, Skill skill, Packet packet) { var cobweb = new Item(ItemId); cobweb.Drop(creature.Region, creature.GetPosition(), 200, creature, true); Send.SkillComplete(creature, skill.Info.Id); }
/// <summary> /// Broadcasts CancelMotion in creature's region. /// </summary> /// <param name="creature"></param> public static void CancelMotion(Creature creature) { var cancelPacket = new Packet(Op.CancelMotion, creature.EntityId); cancelPacket.PutByte(0); creature.Region.Broadcast(cancelPacket, creature); }
/// <summary> /// Sends ChannelDisconnectR to client. /// </summary> /// <param name="client"></param> public static void ChannelDisconnectR(ChannelClient client) { var packet = new Packet(Op.DisconnectRequestR, MabiId.Channel); packet.PutByte(0); client.Send(packet); }
public void Complete(Creature creature, Skill skill, Packet packet) { var str = packet.GetString(); var dict = new MabiDictionary(str); var hwEntityId = dict.GetLong("ITEMID"); if (hwEntityId == 0) goto L_End; var hw = creature.Inventory.GetItemSafe(hwEntityId); if (!hw.HasTag("/large_blessing_potion/")) goto L_End; // TODO: Check loading time var items = creature.Inventory.GetEquipment(); foreach (var item in items) { var blessable = (item.HasTag("/equip/") && !item.HasTag("/not_bless/")); if (blessable) item.OptionInfo.Flags |= ItemFlags.Blessed; } creature.Inventory.Decrement(hw, 1); Send.ItemBlessed(creature, items); L_End: Send.UseMotion(creature, 14, 0); Send.SkillComplete(creature, skill.Info.Id, str); }
/// <summary> /// Completes skill, warping to destination. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="packet"></param> public void Complete(Creature creature, Skill skill, Packet packet) { var destination = (Continent)packet.GetByte(); int regionId, x, y; switch (destination) { case Continent.Uladh: if (creature.Keywords.Has("portal_dunbarton")) { regionId = 14; x = 41598; y = 36010; // Dun } else { regionId = 1; x = 12789; y = 38399; // Tir } break; case Continent.Iria: regionId = 3001; x = 164837; y = 170144; // Qilla break; case Continent.Belvast: regionId = 4005; x = 41760; y = 26924; // Belvast break; default: Send.Notice(creature, "Unknown destination."); Send.SkillCancel(creature); return; } creature.Warp(regionId, x, y); Send.SkillComplete(creature, skill.Info.Id, (byte)destination); }
protected override byte[] BuildPacket(Packet packet) { var packetSize = packet.GetSize(); // Calculate header size var headerSize = 3; int n = packetSize; do { headerSize++; n >>= 7; } while (n != 0); // Write header var result = new byte[headerSize + packetSize]; result[0] = 0x55; result[1] = 0x12; result[2] = 0x00; // Length var ptr = 3; n = packetSize; do { result[ptr++] = (byte)(n > 0x7F ? (0x80 | (n & 0xFF)) : n & 0xFF); n >>= 7; } while (n != 0); // Write packet packet.Build(ref result, ptr); return result; }
/// <summary> /// Sends NewQuest to creature's client. /// </summary> /// <param name="character"></param> /// <param name="quest"></param> public static void NewQuest(Creature character, Quest quest) { var packet = new Packet(Op.NewQuest, character.EntityId); packet.AddQuest(quest); character.Client.Send(packet); }
/// <summary> /// Sends PetUnregister to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="pet"></param> public static void PetUnregister(Creature creature, Creature pet) { var packet = new Packet(Op.PetUnregister, creature.EntityId); packet.PutLong(pet.EntityId); creature.Client.Send(packet); }
/// <summary> /// Broadcasts PartySetActiveQuest in party. /// </summary> /// <param name="party"></param> /// <param name="uniqueQuestId"></param> public static void PartySetActiveQuest(Party party, long uniqueQuestId) { var packet = new Packet(Op.PartySetActiveQuest, 0); packet.PutLong(uniqueQuestId); party.Broadcast(packet, true); }
/// <summary> /// Sends TelePetR to pet's client. /// </summary> /// <param name="pet"></param> /// <param name="success"></param> public static void TelePetR(Creature pet, bool success) { var packet = new Packet(Op.TelePetR, pet.EntityId); packet.PutByte(success); pet.Client.Send(packet); }
/// <summary> /// Sends EnterRebirthR to creature's client. /// </summary> /// <param name="creature"></param> public static void EnterRebirthR(Creature creature) { var packet = new Packet(Op.EnterRebirthR, creature.EntityId); packet.PutByte(0); creature.Client.Send(packet); }
/// <summary> /// Sends Internal.ServerIdentify to login server. /// </summary> public static void Internal_ServerIdentify() { var packet = new Packet(Op.Internal.ServerIdentify, 0); packet.PutString(Password.Hash(ChannelServer.Instance.Conf.Internal.Password)); ChannelServer.Instance.LoginServer.Send(packet); }
/// <summary> /// Readies the skill. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="packet"></param> /// <returns></returns> public override bool Ready(Creature creature, Skill skill, Packet packet) { Send.Effect(creature, 5, (byte)0); Send.SkillReady(creature, skill.Info.Id); return true; }
/// <summary> /// Sends PetUnmountR to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="success"></param> public static void PetUnmountR(Creature creature, bool success) { var packet = new Packet(Op.PetUnmountR, creature.EntityId); packet.PutByte(success); creature.Client.Send(packet); }
/// <summary> /// Broadcasts prop update in its region. /// </summary> /// <param name="prop"></param> public static void PropUpdate(Prop prop) { var packet = new Packet(Op.PropUpdate, prop.EntityId); packet.AddPropUpdateInfo(prop); prop.Region.Broadcast(packet); }
/// <summary> /// Broadcasts PropDisappears in prop's region. /// </summary> /// <param name="prop"></param> public static void PropDisappears(Prop prop) { var packet = new Packet(Op.PropDisappears, MabiId.Broadcast); packet.PutLong(prop.EntityId); prop.Region.Broadcast(packet, prop, false); }
/// <summary> /// Sends SosButtonRequestR to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="enabled"></param> public static void SosButtonRequestR(Creature creature, bool enabled) { var packet = new Packet(Op.SosButtonRequestR, creature.EntityId); packet.PutByte(enabled); creature.Client.Send(packet); }
/// <summary> /// Sends QuestClear to creature's client. /// </summary> /// <remarks> /// Removes quest from quest log. /// </remarks> /// <param name="creature"></param> /// <param name="questId"></param> public static void QuestClear(Creature creature, long questId) { var packet = new Packet(Op.QuestClear, creature.EntityId); packet.PutLong(questId); creature.Client.Send(packet); }
/// <summary> /// Sends BurnItemR to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="success"></param> public static void BurnItemR(Creature creature, bool success) { var packet = new Packet(Op.BurnItemR, creature.EntityId); packet.PutByte(success); creature.Client.Send(packet); }
/// <summary> /// Sends CompleteQuestR to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="success"></param> public static void GiveUpQuestR(Creature creature, bool success) { var packet = new Packet(Op.GiveUpQuestR, creature.EntityId); packet.PutByte(success); creature.Client.Send(packet); }
public bool Prepare(Creature creature, Skill skill, Packet packet) { Send.SkillFlashEffect(creature); Send.SkillPrepare(creature, skill.Info.Id, skill.GetCastTime()); return true; }
/// <summary> /// Sends GmcpInvisibilityR to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="success"></param> public static void GmcpInvisibilityR(Creature creature, bool success) { var packet = new Packet(Op.GmcpInvisibilityR, creature.EntityId); packet.PutByte(success); creature.Client.Send(packet); }