public Location(double x, double y, double z, int landblock, double headingInDegrees) { this.X = x; this.Y = y; this.Z = z; this.LandBlock = landblock; this.HeadingInDegrees = headingInDegrees; this._coords = Mag.Shared.Util.GetCoords(landblock, x, y); }
internal CapturedWorldObject(WorldObject wo) { this.Id = wo.Id; this.Name = wo.Name; this.ObjectClass = wo.ObjectClass; this.Behavior = wo.Behavior; this.Category = wo.Category; this.Container = wo.Container; this.GameDataFlags1 = wo.GameDataFlags1; this.Icon = wo.Icon; this.LastIdTime = wo.LastIdTime; this.PhysicsDataFlags = wo.PhysicsDataFlags; this.Type = wo.Type; this.HasIdData = wo.HasIdData; this._coordinates = wo.Coordinates(); this._orientation = wo.Orientation(); this._offset = wo.Offset(); this._rawCoordinates = wo.RawCoordinates(); var tmpIntList = new List<int>(); for (int i = 0; i < wo.ActiveSpellCount; i++) { tmpIntList.Add(wo.ActiveSpell(i)); } this._activeSpells = General.ListOperations.Capture(tmpIntList).AsReadOnly(); tmpIntList.Clear(); for (int i = 0; i < wo.SpellCount; i++) { tmpIntList.Add(wo.Spell(i)); } this._spells = General.ListOperations.Capture(tmpIntList).AsReadOnly(); foreach (var key in wo.BoolKeys) _boolValues.Add(key, wo.Values((BoolValueKey)key)); foreach (var key in wo.DoubleKeys) _doubleValues.Add(key, wo.Values((DoubleValueKey)key)); foreach (var key in wo.LongKeys) this._longValues.Add(key, wo.Values((LongValueKey)key)); foreach (var key in wo.StringKeys) _stringValues.Add(key, wo.Values((StringValueKey)key)); }
public static IAction Create(ICommand command) { if (command.Arguments.Count == 0) { throw new ArgumentException("At least 1 argument is required"); } // TODO : Support passing in the final heading CoordsObject coords; if (command.Arguments.Count == 1) { // goto is being used to go to an object. Locate the object var woId = int.Parse(command.Arguments[0]); var woObj = woId.ToWorldObject(); if (woObj == null) { command.GiveFeedback(FeedbackType.Ignored, "Could not locate object : {0}", woId); throw new DisplayToUserException(string.Format("Could not locate object : {0}", woId), command); } coords = woObj.Coordinates(); //x = woCoords.NorthSouth; //y = woCoords.EastWest; } else if (command.Arguments.Count == 2) { double ns = double.Parse(command.Arguments[0]); double ew = double.Parse(command.Arguments[1]); coords = new CoordsObject(ns, ew); } else { // Note : In the future maybe I support more complex goto abilities. throw new NotImplementedException("Support for more complicated goto operations has not been implemented"); } return Create(command, coords); }
public static double GetDistance(CoordsObject coords1, CoordsObject coords2) { return coords1.DistanceToCoords(coords2) * 240; }
public static void Face(CoordsObject coords) { if (coords == null) { throw new ArgumentNullException("coords"); } var selfCoords = Location.CaptureCurrent().Coords; var angle = selfCoords.AngleToCoords(coords); REPlugin.Instance.Actions.FaceHeading(angle, true); }
public static bool WithinRangeOfSelf(CoordsObject coords, int maxDistance) { var tmp = GetDistanceFromSelf(coords); var distanceFromSelf = Math.Abs(tmp); return distanceFromSelf < maxDistance; }
public static double GetDistanceFromSelf(CoordsObject point) { var selfLocation = Location.CaptureCurrent(); return GetDistance(selfLocation.Coords, point); }
public static IAction Create(ISupportFeedback requestor, CoordsObject coords, double headingInDegrees) { return new GoToNearbyLocation(requestor, coords, headingInDegrees); }
public GoToNearbyLocation(ISupportFeedback requestor, CoordsObject coords, double finalHeadingInDegrees) : base(requestor) { this._coords = coords; this._finalHeadingInDegrees = finalHeadingInDegrees; }
public static IAction Create(ISupportFeedback requestor, CoordsObject coords) { // This overload is always equivalent to use goto point return Internal.GoToNearbyLocation.Create(requestor, coords, REPlugin.Instance.CoreManager.Actions.Heading); }
private void UpdateRow(WorldObject obj, HudList.HudListRowAccessor row) { try { double distance = CoreManager.Current.WorldFilter.Distance(obj.Id, CoreManager.Current.CharacterFilter.Id) * 240.0; CoordsObject coordsObject = obj.Coordinates(); string text; if (coordsObject.NorthSouth >= 0.0) { text = string.Format("{0:N1}", coordsObject.NorthSouth) + "N, "; } else { text = string.Format("{0:N1}", coordsObject.NorthSouth * -1.0) + "S, "; } if (coordsObject.EastWest >= 0.0) { text = text + string.Format("{0:N1}", coordsObject.EastWest) + "E"; } else { text = text + string.Format("{0:N1}", coordsObject.EastWest * -1.0) + "W"; } if (obj.ObjectClass != ObjectClass.Corpse && obj.Id != lib.MyCore.CharacterFilter.Id) { foreach (WorldObject worldObject in lib.MyCore.WorldFilter.GetByOwner(obj.Id)) { if (worldObject.Name.IndexOf("arrow", 0) < 0) { string a = worldObject.ObjectClass.ToString().Trim(); if (a == "MeleeWeapon" || a == "WandStaffOrb" || a == "MissileWeapon") { ((HudPictureBox)row[0]).Image = worldObject.Icon; break; } } } } else if (obj.Id == lib.MyCore.CharacterFilter.Id) { ((HudPictureBox)row[0]).Image = 100689830; } if (obj.ObjectClass == ObjectClass.Player && obj.Id == lib.MyCore.CharacterFilter.Id) { if (obj.Id == lib.MyCore.CharacterFilter.Id) { ((HudPictureBox)row[0]).Image = 100689830; ((HudStaticText)row[1]).Text = obj.Name; ((HudStaticText)row[2]).Text = "My LOC"; ((HudStaticText)row[3]).Text = ""; ((HudPictureBox)row[4]).Image = 100667896; ((HudStaticText)row[5]).Text = obj.Id.ToString(); ((HudStaticText)row[5]).Visible = false; if (lib.MyCore.Actions.CurrentSelection == obj.Id) { ((HudStaticText)row[1]).TextColor = Color.HotPink; ((HudStaticText)row[2]).TextColor = Color.HotPink; ((HudStaticText)row[3]).TextColor = Color.HotPink; } else { ((HudStaticText)row[1]).TextColor = Color.LawnGreen; ((HudStaticText)row[2]).TextColor = Color.LawnGreen; ((HudStaticText)row[3]).TextColor = Color.LawnGreen; } } } if (obj.ObjectClass == ObjectClass.Player && obj.Id != lib.MyCore.CharacterFilter.Id) { ((HudStaticText)row[1]).Text = obj.Name; ((HudStaticText)row[2]).Text = string.Format("{0:N1}", distance); ((HudStaticText)row[3]).Text = text; ((HudPictureBox)row[4]).Image = 100667896; ((HudStaticText)row[5]).Text = obj.Id.ToString(); ((HudStaticText)row[5]).Visible = false; if (lib.MyCore.Actions.CurrentSelection == obj.Id) { ((HudStaticText)row[1]).TextColor = Color.HotPink; ((HudStaticText)row[2]).TextColor = Color.HotPink; ((HudStaticText)row[3]).TextColor = Color.HotPink; } else if (obj.Values(LongValueKey.Monarch) != lib.moncheck || IsEnemy(obj)) { if (distance < 63) { if (lib.OnDowntime.Contains(obj.Name)) { ((HudStaticText)row[1]).TextColor = Color.White; ((HudStaticText)row[2]).TextColor = Color.White; ((HudStaticText)row[3]).TextColor = Color.White; } else if (lib.OnDowntime2.Contains(obj.Name) && lib.Flicker == false) { ((HudStaticText)row[1]).TextColor = Color.Red; ((HudStaticText)row[2]).TextColor = Color.Red; ((HudStaticText)row[3]).TextColor = Color.Red; } else if (lib.OnDowntime2.Contains(obj.Name) && lib.Flicker == true) { ((HudStaticText)row[1]).TextColor = Color.White; ((HudStaticText)row[2]).TextColor = Color.White; ((HudStaticText)row[3]).TextColor = Color.White; } else if (!lib.OnDowntime2.Contains(obj.Name)) { ((HudStaticText)row[1]).TextColor = Color.Red; ((HudStaticText)row[2]).TextColor = Color.Red; ((HudStaticText)row[3]).TextColor = Color.Red; } } else if (distance >= 63 && distance <= 500) { if (lib.OnDowntime.Contains(obj.Name)) { ((HudStaticText)row[1]).TextColor = Color.White; ((HudStaticText)row[2]).TextColor = Color.White; ((HudStaticText)row[3]).TextColor = Color.White; } else if (lib.OnDowntime2.Contains(obj.Name) && lib.Flicker == false) { ((HudStaticText)row[1]).TextColor = Color.DarkRed; ((HudStaticText)row[2]).TextColor = Color.DarkRed; ((HudStaticText)row[3]).TextColor = Color.DarkRed; } else if (lib.OnDowntime2.Contains(obj.Name) && lib.Flicker == true) { ((HudStaticText)row[1]).TextColor = Color.White; ((HudStaticText)row[2]).TextColor = Color.White; ((HudStaticText)row[3]).TextColor = Color.White; } else if (!lib.OnDowntime2.Contains(obj.Name)) { ((HudStaticText)row[1]).TextColor = Color.DarkRed; ((HudStaticText)row[2]).TextColor = Color.DarkRed; ((HudStaticText)row[3]).TextColor = Color.DarkRed; } } else if (distance > 500) { ((HudStaticText)row[2]).Text = "LOCATE"; ((HudStaticText)row[1]).TextColor = Color.Gold; ((HudStaticText)row[2]).TextColor = Color.Gold; ((HudStaticText)row[3]).TextColor = Color.Gold; if (lib.DistanceCheck.Contains(obj.Id)) { lib.DistanceCheck.Remove(obj.Id); string key = obj.Values(LongValueKey.Landblock).ToString("X8").Substring(0, 4); List <string> Landblock = (from f in lib.LocKey.Split(new char[] { ',' }) select f.Trim()).ToList <string>(); if (lib.LocKey.Contains(key)) { foreach (string el in Landblock) { if (el.Contains(key)) { string elloc = el.Split(new string[] { "=" }, StringSplitOptions.None)[1]; Utility.AddChatText(obj.Name + " was last seen at " + text + " (" + elloc + ")", 6); if (lib.UseAlertLS == true) { Utility.InvokeTextA(obj.Name + " was last seen at " + text + " (" + elloc + ")"); } } } } else { Utility.AddChatText(obj.Name + " was last seen at " + text + " (" + key + " : Unset)", 6); if (lib.UseAlertLS == true) { Utility.InvokeTextA(obj.Name + " was last seen at " + text + " (" + key + " : Unset)"); } } } } } else if (obj.Values(LongValueKey.Monarch) == lib.moncheck || IsFriend(obj)) { if (distance < 63) { if (lib.OnDowntime.Contains(obj.Name)) { ((HudStaticText)row[1]).TextColor = Color.White; ((HudStaticText)row[2]).TextColor = Color.White; ((HudStaticText)row[3]).TextColor = Color.White; } else if (lib.OnDowntime2.Contains(obj.Name) && lib.Flicker == false) { ((HudStaticText)row[1]).TextColor = Color.LawnGreen; ((HudStaticText)row[2]).TextColor = Color.LawnGreen; ((HudStaticText)row[3]).TextColor = Color.LawnGreen; } else if (lib.OnDowntime2.Contains(obj.Name) && lib.Flicker == true) { ((HudStaticText)row[1]).TextColor = Color.White; ((HudStaticText)row[2]).TextColor = Color.White; ((HudStaticText)row[3]).TextColor = Color.White; } else if (!lib.OnDowntime2.Contains(obj.Name)) { ((HudStaticText)row[1]).TextColor = Color.LawnGreen; ((HudStaticText)row[2]).TextColor = Color.LawnGreen; ((HudStaticText)row[3]).TextColor = Color.LawnGreen; } } else if (distance >= 63 && distance <= 500) { if (lib.OnDowntime.Contains(obj.Name)) { ((HudStaticText)row[1]).TextColor = Color.White; ((HudStaticText)row[2]).TextColor = Color.White; ((HudStaticText)row[3]).TextColor = Color.White; } else if (lib.OnDowntime2.Contains(obj.Name) && lib.Flicker == false) { ((HudStaticText)row[1]).TextColor = Color.Green; ((HudStaticText)row[2]).TextColor = Color.Green; ((HudStaticText)row[3]).TextColor = Color.Green; } else if (lib.OnDowntime2.Contains(obj.Name) && lib.Flicker == true) { ((HudStaticText)row[1]).TextColor = Color.White; ((HudStaticText)row[2]).TextColor = Color.White; ((HudStaticText)row[3]).TextColor = Color.White; } else if (!lib.OnDowntime2.Contains(obj.Name)) { ((HudStaticText)row[1]).TextColor = Color.Green; ((HudStaticText)row[2]).TextColor = Color.Green; ((HudStaticText)row[3]).TextColor = Color.Green; } } else if (distance > 500) { ((HudStaticText)row[2]).Text = "LOCATE"; ((HudStaticText)row[1]).TextColor = Color.Gold; ((HudStaticText)row[2]).TextColor = Color.Gold; ((HudStaticText)row[3]).TextColor = Color.Gold; if (lib.DistanceCheck.Contains(obj.Id)) { lib.DistanceCheck.Remove(obj.Id); string key = obj.Values(LongValueKey.Landblock).ToString("X8").Substring(0, 4); List <string> Landblock = (from f in lib.LocKey.Split(new char[] { ',' }) select f.Trim()).ToList <string>(); if (lib.LocKey.Contains(key)) { foreach (string el in Landblock) { if (el.Contains(key)) { string elloc = el.Split(new string[] { "=" }, StringSplitOptions.None)[1]; Utility.AddChatText(obj.Name + " was last seen at " + text + " (" + elloc + ")", 6); } } } else { Utility.AddChatText(obj.Name + " was last seen at " + text + " (" + key + " : Unset)", 6); } } } } } if (obj.ObjectClass != ObjectClass.Player) { ((HudPictureBox)row[0]).Image = obj.Icon; ((HudStaticText)row[1]).Text = obj.Name; ((HudStaticText)row[2]).Text = string.Format("{0:N1}", distance); ((HudStaticText)row[3]).Text = text; ((HudPictureBox)row[4]).Image = 100667896; ((HudStaticText)row[5]).Text = obj.Id.ToString(); ((HudStaticText)row[5]).Visible = false; if (obj.Id == lib.MyCore.Actions.CurrentSelection) { ((HudStaticText)row[1]).TextColor = Color.HotPink; ((HudStaticText)row[2]).TextColor = Color.HotPink; ((HudStaticText)row[3]).TextColor = Color.HotPink; } else if (obj.Id != lib.MyCore.Actions.CurrentSelection) { if (distance <= 500) { ((HudStaticText)row[1]).TextColor = Color.White; ((HudStaticText)row[2]).TextColor = Color.White; ((HudStaticText)row[3]).TextColor = Color.White; } else if (distance > 500) { ((HudStaticText)row[2]).Text = "Too far!"; ((HudStaticText)row[1]).TextColor = Color.Gold; ((HudStaticText)row[2]).TextColor = Color.Gold; ((HudStaticText)row[3]).TextColor = Color.Gold; } } } } catch (Exception ex) { Repo.RecordException(ex); } }
private void AddWorldObject(WorldObject obj, HudList hl) { try { bool flag = false; for (int i = 0; i < hl.RowCount; i++) { HudList.HudListRowAccessor hudListRowAccessor = hl[i]; HudStaticText hudStaticText = (HudStaticText)hudListRowAccessor[5]; if (Convert.ToInt32(hudStaticText.Text) == obj.Id) { flag = true; break; } } if (flag) { UpdateWorldObject(obj, hl); } else { CoordsObject coordsObject = obj.Coordinates(); string text; if (coordsObject.NorthSouth >= 0.0) { text = string.Format("{0:N1}", coordsObject.NorthSouth) + "N, "; } else { text = string.Format("{0:N1}", coordsObject.NorthSouth * -1.0) + "S, "; } if (coordsObject.EastWest >= 0.0) { text = text + string.Format("{0:N1}", coordsObject.EastWest) + "E"; } else { text = text + string.Format("{0:N1}", coordsObject.EastWest * -1.0) + "W"; } double num = CoreManager.Current.WorldFilter.Distance(obj.Id, CoreManager.Current.CharacterFilter.Id) * 240.0; int num2 = 0; HudList.HudListRowAccessor hudListRowAccessor; if (hl.RowCount > 0) { num2 = hl.RowCount; for (int j = 0; j < hl.RowCount; j++) { hudListRowAccessor = hl[j]; HudStaticText hudStaticText2 = (HudStaticText)hudListRowAccessor[1]; if (hudStaticText2.Text.Trim().CompareTo(obj.Name.Trim()) > 0) { num2 = j; break; } } } hudListRowAccessor = hl.InsertRow(num2); ((HudPictureBox)hudListRowAccessor[0]).Image = obj.Icon; ((HudStaticText)hudListRowAccessor[1]).Text = obj.Name; ((HudStaticText)hudListRowAccessor[2]).Text = text; ((HudStaticText)hudListRowAccessor[3]).Text = string.Format("{0:N1}", num); ((HudPictureBox)hudListRowAccessor[4]).Image = 100667896; ((HudStaticText)hudListRowAccessor[5]).Text = obj.Id.ToString(); ((HudStaticText)hudListRowAccessor[5]).Visible = false; } } catch (Exception ex) { Repo.RecordException(ex); } }