public static void CreateInstances() { UpdateLogger updateLogger = new UpdateLogger(); int num = 0; foreach (var record in Maps) { record.InteractiveElements = InteractiveElementRecord.GetActiveElementsOnMap(record.Id); record.Position = MapPositionRecord.GetMapPosition(record.Id); record.MonsterSpawnsSubArea = MonsterSpawnRecord.GetSpawns(record.SubAreaId).ToArray(); record.NpcsRecord = NpcSpawnRecord.GetMapNpcs(record.Id).ToArray(); record.Instance = new MapInstance(record); NpcSpawnsManager.Instance.SpawnAtStartup(record); if (record.AbleToSpawn) { MonsterSpawnManager.Instance.SpawnMonsters(record); } updateLogger.Update(num.Percentage(Maps.Count)); num++; } }
public static void ShowPreSelect(WorldClient client, string[] args) { if (client.Character.Map.Id != PreSelectionMapId) { client.Character.Reply($"You are not on the map of your pre-selection... ({PreSelectionMapId})"); return; } if (!PreSelectionElementsIds.Any()) { client.Character.Reply("No Element on Map..."); return; } if (PreSelectionElementsIds.Count > Colors.Length) { client.Character.ReplyError($"WARNING: This command will display more elements ({PreSelectionElementsIds.Count}) while there are {Colors.Length} different colors.. Be careful."); } client.Send(new DebugClearHighlightCellsMessage()); for (int i = 0; i < PreSelectionElementsIds.Count; i++) { InteractiveElementRecord ele = PreSelectionElementsIds[i]; Color color = Colors[i % Colors.Length]; client.Send(new DebugHighlightCellsMessage(color.ToArgb(), new[] { ele.CellId })); client.Character.Reply("Element > " + ele.ElementId + " CellId > " + ele.CellId + " GfxLookId > " + ele.GfxBonesId, color); } }
public MapInteractiveElement(AbstractMapInstance mapInstance, InteractiveElementRecord record) { this.Record = record; this.MapInstance = mapInstance; this.EnabledSkills = record.Skills.ConvertAll(x => new MapInteractiveElementSkill(this, x)); this.DisabledSkills = new List <MapInteractiveElementSkill>(); }
public static void SynchronizeElements() { foreach (var skill in SkillRecord.Skills) { if (skill.GfxLookId != -1) { List <InteractiveElementRecord> elements = InteractiveElementRecord.GetElementByGfxLookId(skill.GfxLookId); foreach (var element in elements) { if (element.ElementType == -1) { element.ElementType = skill.InteractiveId; if (!InteractiveSkillRecord.OneExist(element.ElementId)) { int uid = InteractiveSkillRecord.InteractiveSkills.DynamicPop(w => w.UID); InteractiveSkillRecord record = new InteractiveSkillRecord(uid, "Collect", string.Empty, string.Empty, element.ElementId, skill.Id); record.AddInstantElement(); } element.UpdateInstantElement(); logger.Gray("Element fixed: " + element.ElementId + " with skill " + skill.Name); } } } } }
public static void SunCommand(string value, WorldClient client) { var split = value.Split(null); int elementId = int.Parse(split[0]); int mapId = int.Parse(split[1]); short cellId = short.Parse(split[2]); InteractiveElementRecord element = InteractiveElementRecord.GetElement(elementId, client.Character.Map.Id); element.ChangeType(0); element.AddSmartSkill("Teleport", mapId.ToString(), cellId.ToString()); client.Character.Map.Instance.Reload(); client.Character.Reply("Soleil Ajouté"); // return; // 2nd mode /* var split = value.Split(null); // split[0] = EleId, split[1] = destMapId, split[2] = destCellId * * var element = InteractiveElementRecord.GetElement(int.Parse(split[0]), client.Character.Map.Id); * * element.ChangeType(0); * * element.AddSmartSkill("Teleport", split[1], split[2]); * * client.Character.Map.Instance.ReloadInteractives(); * client.Character.Reply("Soleil Ajouté"); */ }
public static void ShowElements(WorldClient client, string[] args) { Color[] colors = { Color.Blue, Color.Cyan, Color.Yellow, Color.Pink, Color.Goldenrod, Color.Green, Color.Red, Color.Purple, Color.Silver, Color.SkyBlue, Color.Black, Color.Brown, Color.Chartreuse, Color.Chocolate, Color.Indigo, Color.DarkOliveGreen, Color.LightSlateGray, Color.Navy }; InteractiveElementRecord[] elements = InteractiveElementRecord.GetAllElements(client.Character.Map.Id).ToArray(); if (!elements.Any()) { client.Character.Reply("No Element on Map..."); return; } if (elements.Length > colors.Length) { client.Character.ReplyError($"WARNING: This command will display more elements ({elements.Length}) while there are {colors.Length} different colors.. Be careful."); } client.Send(new DebugClearHighlightCellsMessage()); for (int i = 0; i < elements.Count(); i++) { InteractiveElementRecord ele = elements[i]; Color color = colors[i % colors.Length]; client.Send(new DebugHighlightCellsMessage(color.ToArgb(), new[] { ele.CellId })); client.Character.Reply("Element > " + ele.ElementId + " CellId > " + ele.CellId + " GfxId > " + ele.GfxId + " GfxLookId > " + ele.GfxBonesId, color); } }
public static ushort GetTeleporterCell(MapRecord map, InteractiveElementRecord ele) { ushort cellId = (ushort)ele.Point.GetCellInDirection(DirectionsEnum.DIRECTION_SOUTH_WEST, 1).CellId; if (!map.Walkable(cellId)) { ushort[] array = map.CloseCells(ele.CellId); cellId = array.Length == 0 ? map.RandomWalkableCell() : array[0]; } return(cellId); }
public static void Build(WorldClient client, string[] args) { if (Mine == null) { client.Character.ReplyError("Unable to create mine, none has been initialized."); return; } if (!Mine.Maps.Any()) { client.Character.ReplyError("You have not registered any map. See cmds <i>.mine addmap</i> and <i>.mine ps</i>."); return; } int idx = 0; List <int> oreSequence = BuildRandomInteractivesSequence(); if (!oreSequence.Any()) { client.Character.ReplyError("You have not registered any ore. See cmd <i>.mine addore</i>."); return; } int nextSkillUid = InteractiveSkillRecord.InteractiveSkills.DynamicPop(x => x.UID); foreach (MineMap mineMap in Mine.Maps) { foreach (int elementId in mineMap.ElementIds) { int elementType = oreSequence[idx]; // InteractiveElements InteractiveElementRecord interactiveElementRecord = InteractiveElementRecord.InteractiveElements.Find(rec => rec.MapId == mineMap.MapId && rec.ElementId == elementId); interactiveElementRecord.ElementType = elementType; // interactiveElementRecord.UpdateInstantElement(); // InteractiveSkills InteractiveSkillRecord interactiveSkillRecord = new InteractiveSkillRecord(nextSkillUid, "Collect", "", "", elementId, (int)JobsTypeEnum.Mineur); InteractiveSkillRecord.InteractiveSkills.Add(interactiveSkillRecord); // interactiveSkillRecord.AddInstantElement(); idx++; nextSkillUid++; } MapRecord mapRecord = MapRecord.GetMap(mineMap.MapId); mapRecord.Instance.Reload(); client.Character.Reply($"Processed and reloaded map {mineMap.MapId}."); } // Mine = null; client.Character.Reply("Successfully built mine."); }
public void Reload() { this.Record.InteractiveElements = InteractiveElementRecord.GetActiveElementsOnMap(Record.Id); this.m_interactiveElements = Record.InteractiveElements.ConvertAll(x => x.GetMapInteractiveElement(this)); this.OnElementsUpdated(); foreach (var character in GetEntities <Character>()) { character.Client.Send(GetMapComplementaryInformationsDataMessage(character)); } }
public static void Zaap(string value, WorldClient client) { var element = InteractiveElementRecord.GetElement(int.Parse(value), client.Character.Map.Id); element.ElementType = 16; InteractiveSkillRecord skill = new InteractiveSkillRecord(InteractiveSkillRecord.InteractiveSkills.DynamicPop(x => x.UID), "Zaap", "Global", "", element.UId, 114); element.UpdateInstantElement(); skill.AddInstantElement(); client.Character.Map.Instance.Reload(); }
public static void PreSelect(WorldClient client, string[] args) { if (Mine == null) { client.Character.Reply("No initialized mine."); return; } PreSelectionMapId = client.Character.Map.Id; PreSelectionElementsIds = InteractiveElementRecord.GetAllElements(client.Character.Map.Id); ShowPreSelect(client, args); client.Character.Reply(""); client.Character.Reply("You can now use cmds: "); client.Character.Reply(" - <i>.mine exclude</i> to exclude any elements."); client.Character.Reply(" - <i>.mine savemap</i> to save all pre-selected elements on your map."); }
public static void ElementsCommand(string value, WorldClient client) { Color[] Colors = new Color[] { Color.Blue, Color.Cyan, Color.Yellow, Color.Pink, Color.Goldenrod, Color.Green, Color.Red, Color.Purple, Color.Silver, Color.SkyBlue, Color.Black }; InteractiveElementRecord[] elements = InteractiveElementRecord.GetAllElements(client.Character.Map.Id).ToArray(); if (elements.Count() == 0) { client.Character.Reply("No Elements on Map..."); return; } client.Send(new DebugClearHighlightCellsMessage()); for (int i = 0; i < elements.Count(); i++) { var ele = elements[i]; client.Send(new DebugHighlightCellsMessage(Colors[i].ToArgb(), new ushort[] { ele.CellId })); client.Character.Reply("Element > " + ele.ElementId + " CellId > " + ele.CellId + " GfxId > " + ele.GfxId + " GfxLookId > " + ele.GfxBonesId, Colors[i]); } }
public TeleporterDialog(Character character, MapInteractiveElementSkill skill) : base(character) { var zaapElements = InteractiveElementRecord.GetByElementType(skill.Element.Record.ElementType).ToArray(); zaapElements = zaapElements.Where(x => x.GetSkillByActionType(skill.ActionType).Value1 == skill.Record.Value1).ToArray(); this.Maps = new int[zaapElements.Length]; this.SubAreaIds = new ushort[zaapElements.Length]; this.Costs = new ushort[zaapElements.Length]; this.DestTeleporterType = new TeleporterTypeEnum[zaapElements.Length]; for (int i = 0; i < zaapElements.Length; i++) { var element = zaapElements[i]; this.Maps[i] = element.MapId; this.SubAreaIds[i] = MapRecord.GetSubAreaId(element.MapId); this.Costs[i] = GetCost(skill.Element.Record.MapId, element.MapId); this.DestTeleporterType[i] = TeleporterType; } }
public static void ExcludeElements(WorldClient client, string[] args) { if (args.Length < 2) { client.Character.Reply("Exclude elements from the pre selection"); client.Character.Reply(".mine exclude [$ElementId ...]"); client.Character.Reply(".mine <b>$ElementId</b> ⇒ The ElementId. to exclude"); return; } if (PreSelectionMapId == -1) { client.Character.ReplyError("Create a pre-selection first using <i>.mine preselect</i>."); return; } if (client.Character.Map.Id != PreSelectionMapId) { client.Character.ReplyError($"Cannot exclude Elements, you must be on the map of your pre-selection ({PreSelectionMapId}). Or create a new preselection using cmd <i>.mine preselect</i>."); return; } for (var i = 1; i < args.Length; i++) { var toExclude = int.Parse(args[i]); InteractiveElementRecord toRemove = PreSelectionElementsIds.Find(element => element.ElementId == toExclude); if (toRemove != null) { PreSelectionElementsIds.Remove(toRemove); client.Character.Reply($"Successfully unselected element {toRemove.ElementId}"); } else { client.Character.ReplyError($"No element {toExclude} in the pre-selection."); } } ShowPreSelect(client, null); }
public MapStatedElement(AbstractMapInstance mapInstance, InteractiveElementRecord record) : base(mapInstance, record) { }
private static void AddAllInteractivesOfGfx(WorldClient client, string[] args) { if (args.Length < 4) { if (args.Length != 1) { client.Character.ReplyError("Invalid command."); } client.Character.Reply("Add an all interactive elements of specific GfxLookId."); client.Character.Reply("» .elements addall|aa $GfxLookId $ElementType $SkillId"); client.Character.Reply("» Example: .elements addall 685 108 154 "); client.Character.Reply(" - <b>$GfxLookId</b> ⇒ The element GxfLookId (see <i>.elements show</i>)"); client.Character.Reply(" - <b>$ElementType</b> ⇒ ElementType (id in interactives table) of the resource."); client.Character.Reply(" - <b>$SkillId</b> ⇒ The ID of the skill."); return; } int gfxLookId = int.Parse(args[1]); int elementType = int.Parse(args[2]); ushort skillId = ushort.Parse(args[3]); const string actionType = "Collect"; int nextUid = InteractiveSkillRecord.InteractiveSkills.DynamicPop(x => x.UID); client.Character.Reply($"Retrieving element records with GfxLookId={gfxLookId}..."); List <InteractiveElementRecord> elementRecords = InteractiveElementRecord.GetElementByGfxLookId(gfxLookId); int counter = 1; int total = elementRecords.Count; HashSet <int> impactedMapIds = new HashSet <int>(); client.Character.Reply($"Updating {elementRecords.Count} element records..."); foreach (InteractiveElementRecord record in elementRecords) { // Update InteractiveElement if (record.ElementType != elementType) { record.ElementType = elementType; record.UpdateInstantElement(); } client.Character.Reply($"Updated {counter}/{total} InteractiveElement."); // Insert InteractiveSkill if not exists if (!InteractiveSkillRecord.InteractiveSkills.Exists(isk => isk.ElementId == record.ElementId && isk.SkillId == skillId && isk.ActionType.Equals(actionType))) { InteractiveSkillRecord newRecord = new InteractiveSkillRecord(nextUid, actionType, "", "", record.ElementId, skillId); // InteractiveSkillRecord.InteractiveSkills.Add(newRecord); newRecord.AddInstantElement(); nextUid++; client.Character.Reply($"Created {counter}/{total} InteractiveSKill."); } else { client.Character.Reply($"InteractiveSKill {counter}/{total} Already exists."); } impactedMapIds.Add(record.MapId); counter++; } client.Character.Reply("Database updated."); counter = 1; total = impactedMapIds.Count; client.Character.Reply($"Reloading {impactedMapIds.Count} maps..."); foreach (int mapId in impactedMapIds) { MapRecord.GetMap(mapId).Instance.Reload(); client.Character.Reply($"Map {counter}/{total} reloaded: {mapId}"); counter++; } client.Character.Reply("All maps have been reloaded."); client.Character.Reply("Done!"); }