private static void ACTION_USER_EFFECT(YiObj target, YiObj invoker, cq_action cqaction, SquigglyContext db) { var nextIds = cqaction.param.Trim().Split(' '); (invoker as Player)?.Send(LegacyPackets.Effect(invoker, nextIds[1])); Process(target, invoker, db.cq_action.Find(cqaction.id_next), db); }
public NpcDialog Text(string text) { for (var i = 0; i < text.Length; i += 255) { _packets.Add(LegacyPackets.NpcSay(text.Substring(i, Math.Min(255, text.Length - i)))); } return(this); }
public static void Add(YiObj obj, YiObj target) { if (!Entities.ContainsKey(obj.UniqueId)) { Create(obj); } if (target.UniqueId == obj.UniqueId || Entities[obj.UniqueId].Contains(target.UniqueId)) { return; } Entities[obj.UniqueId].Add(target.UniqueId); Add(target, obj); switch (target) { case Bot botTarget: //(obj as Player)?.Send(MsgSpawn.Create(botTarget)); break; case Player playerTarget: (obj as Player)?.Send(MsgSpawn.Create(playerTarget)); break; case Monster monsterTarget: monsterTarget.Brain.PlayersInSight++; (obj as Player)?.Send(MsgSpawn.Create(monsterTarget)); break; case Npc npcTarget: (obj as Player)?.Send(MsgNpcSpawn.Create(npcTarget)); if (npcTarget.BoothId != 0) { (obj as Player)?.Send(LegacyPackets.SpawnCarpet(npcTarget, npcTarget.BoothId)); } break; case DynamicNpc dynNpcTarget: (obj as Player)?.Send(MsgDynNpcSpawn.Create(dynNpcTarget)); break; case FloorItem floorItemTarget: (obj as Player)?.Send(MsgFloorItem.Create(floorItemTarget, MsgFloorItemType.Create)); break; case Portal portal: break; case null: Debugger.Break(); break; default: Debugger.Break(); break; } }
public static void ShowStock(YiObj owner) { if (StoragePool[owner.UniqueId].TryGetValue(owner.CurrentStorageId, out var storage)) { if (storage.Members[owner.UniqueId].HasFlag(StorageAccess.ItemSee)) { (owner as Player)?.Send(LegacyPackets.WarehouseItems(storage.StorageId, storage.Contents)); } if (storage.Members[owner.UniqueId].HasFlag(StorageAccess.MoneySee)) { (owner as Player)?.Send(MsgItem.Create(storage.StorageId, 0, storage.Money, MsgItemType.ShowWarehouseMoney)); } } else { Output.WriteLine("Storage not found."); } }
public static void CreateFor(YiObj owner) { if (owner is Npc npc) { npc.Type = 2; owner.BoothId = 10000000 + owner.UniqueId; BoothPool.AddOrUpdate(owner.BoothId, new ConcurrentDictionary <int, Product>()); foreach (var item in owner.Inventory) { var product = new Product(owner.UniqueId, item.Value.PriceBaseline, owner.BoothId, item.Value); Add(owner, item.Key, product.Price); } } else { owner.BoothId = owner.BoothId; BoothPool.AddOrUpdate(owner.BoothId, new ConcurrentDictionary <int, Product>()); (owner as Player)?.Send(MsgStatus.Create(owner.MapId, 0x0010)); (owner as Player)?.Send(LegacyPackets.SpawnCarpet((Player)owner, owner.BoothId)); } }
public NpcDialog Link(string link, byte control) { _packets.Add(LegacyPackets.NpcLink(link, control)); return(this); }
public NpcDialog Input(string link, byte control) { _packets.Add(LegacyPackets.NpcInputBox(link, control)); return(this); }
public NpcDialog Finish() { _packets.Add(LegacyPackets.NpcFinish()); return(this); }
public NpcDialog(ushort face) { _packets = new List <byte[]> { LegacyPackets.NpcFace(face) }; }
public void Countdown(int number) => ScreenSystem.Send(this, LegacyPackets.Effect(this, "downnumber" + number));
private static void Process(YiObj target, YiObj invoker, cq_action cqaction, SquigglyContext db) { if (cqaction == null || cqaction.id == 0) { return; } invoker.CurrentAction = cqaction; var type = (Cq_ActionId)cqaction.type; //Output.WriteLine($"Mob Action -> Type: {type}:{(int) type} Data: {cqaction.data} Param: {cqaction.param.Trim()}"); switch (type) { default: { Output.WriteLine($"Unknown Cq_ActionId -> {cqaction}", ConsoleColor.Blue); break; } case Cq_ActionId.ACTION_MENUTEXT: { if (invoker is Player player) { player.Send(LegacyPackets.NpcSay(cqaction.param.Trim().Replace("~", " "))); if (cqaction.id_next == 0) { player.Send(LegacyPackets.NpcFinish()); } else { Process(target, invoker, db.cq_action.Find(cqaction.id_next), db); } } break; } case Cq_ActionId.ACTION_MENULINK: { if (invoker is Player player) { var option = cqaction.param.Trim().Split(' ')[0]; var sControl = cqaction.param.Split(' ', StringSplitOptions.RemoveEmptyEntries); var control = int.Parse(sControl[1]); player.NpcTasks.Add((byte)player.NpcTasks.Count, (int)control); player.Send(LegacyPackets.NpcLink(option.Replace("~", " "), (byte)(player.NpcTasks.Count - 1))); if (cqaction.id_next == 0) { player.Send(LegacyPackets.NpcFinish()); } else { Process(target, invoker, db.cq_action.Find(cqaction.id_next), db); } } break; } case Cq_ActionId.ACTION_MENUPIC: { if (invoker is Player player) { var faceId = byte.Parse(cqaction.param.Trim().Split(' ')[2]); player.Send(LegacyPackets.NpcFace(faceId)); if (cqaction.id_next == 0) { player.Send(LegacyPackets.NpcFinish()); } else { Process(target, invoker, db.cq_action.Find(cqaction.id_next), db); } } break; } case Cq_ActionId.ACTION_MENUCREATE: { if (invoker is Player player) { player.Send(LegacyPackets.NpcFinish()); } break; } case Cq_ActionId.ACTION_USER_SEX: { if (cqaction.id_nextfail == 0 && cqaction.id_next == 0) { return; } //If male next_id else nextid_fail break; } case Cq_ActionId.ACTION_ITEM_CHECK: { ACTION_ITEM_CHECK(target, invoker, cqaction, db); break; } case Cq_ActionId.ACTION_MST_DROPITEM: { ACTION_MST_DROPITEM(target, invoker, cqaction, db); break; } case Cq_ActionId.ACTION_RAND: { ACTION_RAND(target, invoker, cqaction, db); break; } case Cq_ActionId.ACTION_USER_ATTR: { ACTION_USER_ATTR(target, invoker, cqaction, db); break; } case Cq_ActionId.ACTION_RANDACTION: { ACTION_RANDACTION(target, invoker, cqaction, db); break; } case Cq_ActionId.ACTION_USER_TALK: { invoker.GetMessage("SYSTEM", invoker.Name.Trim(), cqaction.param.Trim().Replace("~", ""), (MsgTextType)cqaction.data); break; } case Cq_ActionId.ACTION_USER_HAIR: { ACTION_USER_HAIR(target, invoker, cqaction, db); break; } case Cq_ActionId.ACTION_USER_MEDIAPLAY: { ACTION_USER_MEDIAPLAY(target, invoker, cqaction, db); break; } case Cq_ActionId.ACTION_USER_EFFECT: { ACTION_USER_EFFECT(target, invoker, cqaction, db); break; } case Cq_ActionId.ACTION_USER_CHGMAP: { ACTION_USER_CHGMAP(target, invoker, cqaction, db); break; } case Cq_ActionId.ACTION_ITEM_LEAVESPACE: ACTION_ITEM_LEAVESPACE(target, invoker, cqaction, db); break; case Cq_ActionId.ACTION_ITEM_ADD: ACTION_ITEM_ADD(target, invoker, cqaction, db); break; case Cq_ActionId.ACTION_ITEM_MULTICHK: ACTION_ITEM_MULTICHK(target, invoker, cqaction, db); break; case Cq_ActionId.ACTION_ITEM_MULTIDEL: ACTION_ITEM_MULTIDEL(target, invoker, cqaction, db); break; case Cq_ActionId.ACTION_CHKTIME: ACTION_CHKTIME(target, invoker, cqaction, db); break; case Cq_ActionId.ACTION_USER_MAGIC: ACTION_USER_MAGIC(target, invoker, cqaction, db); break; } }