Example #1
0
		public double DistanceTo(Coordinates dest)
		{
			double x = dest.EW - EW;
			double y = dest.NS - NS;
			if (double.IsNaN(x + y))
				return double.PositiveInfinity;
			return Math.Sqrt(x * x + y * y);
		}
Example #2
0
		private void UpdateStartLocation(Coordinates coords, RouteStartType type, bool quiet)
		{
			if (!chkAutoUpdateRecalls.Checked)
				return;

			RouteStart startLoc = GetStartLocationByType(type);
			if (startLoc != null && startLoc.Coords != coords)
			{
				startLoc.Coords = coords;
				RefreshStartLocationListCoords();
				if (startLoc.Enabled && !quiet)
					Util.Message(startLoc.Name + " start location set to " + startLoc.Coords);
			}
		}
Example #3
0
		private void UpdateStartLocation(Coordinates coords, RouteStartType type)
		{
			UpdateStartLocation(coords, type, false);
		}
Example #4
0
		private void RecallChatTextHandler(object sender, ChatTextInterceptEventArgs e)
		{
			try
			{
				if (chkAutoUpdateRecalls.Checked)
				{
					string text = e.Text.Trim();

					// Spell Casting
					if (e.Color == 7)
					{
						if (text == "You successfully link with the portal!" || text == "You successfully link with the lifestone!")
						{
							WorldObject spellTarget = Core.WorldFilter[mLastSpellTarget];
							if (spellTarget != null)
							{
								if (mLastSpellId == Spells.PrimaryPortalTie)
								{
									if (spellTarget.HasIdData)
									{
										ProcessPortalTie(spellTarget, RouteStartType.PrimaryPortalTie);
									}
									else
									{
										Host.Actions.RequestId(mLastSpellTarget);
										mIdPrimaryTie = IdStep.Requested;
										if (mRecallTimeout.Enabled)
											RecallTimeout_Tick(null, null);
										mRecallTimeout.Interval = 10000; // 10 seconds
										mRecallTimeout.Start();
									}
								}
								else if (mLastSpellId == Spells.SecondaryPortalTie)
								{
									if (spellTarget.HasIdData)
									{
										ProcessPortalTie(spellTarget, RouteStartType.SecondaryPortalTie);
									}
									else
									{
										Host.Actions.RequestId(mLastSpellTarget);
										mIdSecondaryTie = IdStep.Requested;
										if (mRecallTimeout.Enabled)
											RecallTimeout_Tick(null, null);
										mRecallTimeout.Interval = 10000; // 10 seconds
										mRecallTimeout.Start();
									}
								}
								else if (mLastSpellId == Spells.LifestoneTie)
								{
									UpdateStartLocation(spellTarget, RouteStartType.LifestoneTie);
								}
							}
						}
						else if (e.Text.StartsWith("You have attuned your spirit to this Lifestone."))
						{
							WorldObject lifestone = Core.WorldFilter[Host.Actions.CurrentSelection];
							Coordinates coords;
							RouteStart startLoc = GetStartLocationByType(RouteStartType.LifestoneBind);
							if (lifestone == null || lifestone.ObjectClass != ObjectClass.Lifestone)
							{
								coords = PlayerCoords;
							}
							else
							{
								coords = new Coordinates(lifestone.Coordinates(), 1);
							}
							if (startLoc.Coords != coords)
							{
								startLoc.Coords = coords;
								RefreshStartLocationListCoords();
								if (startLoc.Enabled)
									Util.Message(startLoc.Name + " start location set to " + startLoc.Coords);
							}
						}
					}

					// Recall Text
					else if (e.Color == 23)
					{
						string name = Core.CharacterFilter.Name;
						if (text == name + " is going to the Allegiance hometown.")
						{
							mRecallingToBindstone = RecallStep.RecallStarted;
							if (mRecallTimeout.Enabled)
								RecallTimeout_Tick(null, null);
							mRecallTimeout.Interval = 40000; // 40 seconds
							mRecallTimeout.Start();
						}
						else if (text == name + " is recalling to the lifestone.")
						{
							mRecallingToLSBind = RecallStep.RecallStarted;
							if (mRecallTimeout.Enabled)
								RecallTimeout_Tick(null, null);
							mRecallTimeout.Interval = 40000; // 40 seconds
							mRecallTimeout.Start();
						}
					}
				}
			}
			catch (Exception ex) { Util.HandleException(ex); }
		}
Example #5
0
		private void FindCommand(string arg)
		{
			arg = arg.ToLower();
			bool matched = false;
			foreach (Decal.Adapter.Wrappers.WorldObject obj in Core.WorldFilter.GetLandscape())
			{
				if (obj.Name.ToLower().Contains(arg))
				{
					if (!matched)
					{
						Host.Actions.SelectItem(obj.Id);
					}

					Coordinates coords = new Coordinates(obj.Coordinates());

					Util.Message(obj.Name + " ("
						+ MakeAttachArrowChatLink(obj.Id, coords.ToString("0.0")) + ") | "
						+ MakeSelectItemChatLink(obj.Id, "Select"));

					matched = true;
				}
			}
			if (!matched)
			{
				Util.Message("No matches found for '" + arg + "'");
			}
		}
Example #6
0
		public static Coordinates Round(Coordinates coords, int precision)
		{
			return new Coordinates(Math.Round(coords.NS, precision), Math.Round(coords.EW, precision));
		}
Example #7
0
		public Coordinates RelativeTo(Coordinates dest)
		{
			return new Coordinates(dest.NS - NS, dest.EW - EW);
		}
Example #8
0
		internal void SetRouteEnd(Coordinates coords)
		{
			Location loc = mLocDb.GetLocationAt(coords);
			if (loc != null)
			{
				SetRouteEnd(loc);
			}
			else
			{
				choRouteTo.Selected = 0;
				chkRouteToHere.Checked = false;
				edtRouteToCoords.Text = coords.ToString();

				AddToRecentCoords(coords);

				nbkAtlas.ActiveTab = AtlasTab.Route;
				nbkMain.ActiveTab = MainTab.Atlas;
				DefaultView.Activated = true;
			}
		}
Example #9
0
		public double AngleTo(Coordinates dest)
		{
			return Math.Atan2(dest.EW - EW, dest.NS - NS);
		}
Example #10
0
		public static bool FromRegexMatch(Match m, out Coordinates coords)
		{
			coords = NO_COORDINATES;
			try
			{
				if (!m.Success)
					return false;

				coords.NS = double.Parse(m.Groups["NSval"].Value, System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
				if (m.Groups["NSchr"].Value.ToLower() == "s") { coords.NS = -coords.NS; }

				coords.EW = double.Parse(m.Groups["EWval"].Value);
				if (m.Groups["EWchr"].Value.ToLower() == "w") { coords.EW = -coords.EW; }
			}
			catch (Exception ex)
			{
				Util.HandleException(ex);
				return false;
			}
			return true;
		}
Example #11
0
		public static bool TryParse(string parseString, bool allowNoCoords, out Coordinates coords)
		{
			if (allowNoCoords && parseString == "" || parseString == NO_COORDINATES_STRING
				|| parseString == UNKNOWN_COORDINATES_STRING)
			{
				coords = NO_COORDINATES;
				return true;
			}
			return FromRegexMatch(FindCoords(parseString), out coords);
		}
Example #12
0
		public static bool TryParse(string parseString, out Coordinates coords)
		{
			if (parseString == null)
			{
				coords = Coordinates.NO_COORDINATES;
				return false;
			}
			return FromRegexMatch(FindCoords(parseString), out coords);
		}
Example #13
0
		private void AddStartLocation(string name, Coordinates coords, double runDist, bool enabled, int icon)
		{
			if (!mStartLocations.ContainsKey(name))
			{
				mStartLocations[name] = new RouteStart(name, RouteStartType.Regular, icon, runDist,
					coords, SavesPer.All, enabled);
			}
		}
Example #14
0
		private void AddToRecentCoords(int icon, string name, Coordinates coords)
		{
			for (int r = 0; r < lstRecentCoords.RowCount; r++)
			{
				if (r > MaxRecentLocations || name.Equals(lstRecentCoords[r][RecentCoordsList.Name][0]))
				{
					lstRecentCoords.Delete(r);
				}
			}
			ListRow row = lstRecentCoords.Insert(0);
			row[RecentCoordsList.Icon][1] = icon;
			row[RecentCoordsList.Name][0] = name;
			row[RecentCoordsList.Coords][0] = coords.ToString();
		}
Example #15
0
		private void AddToRecentCoords(Coordinates coords)
		{
			AddToRecentCoords(AcIcons.YellowTarget, coords.ToString(), coords);
		}
Example #16
0
		private void PluginCore_ServerDispatch(object sender, NetworkMessageEventArgs e)
		{
			try
			{
				// Game Event
				if (e.Message.Type == 0xF7B0)
				{
					int eventId;
					try { eventId = e.Message.Value<int>("event"); }
					catch (ArgumentOutOfRangeException) { return; }

					// Allegiance Info
					if (eventId == 0x0020)
					{
						MessageStruct records = e.Message.Struct("records");
						if (records.Count == 0)
						{
							MonarchId = 0;
							MonarchName = "";
						}
						else
						{
							// Monarch info is always the first record, whether this character 
							// is monarch, direct vassal to the monarch, or just a peon.
							MessageStruct monarch = records.Struct(0);
							MonarchId = monarch.Value<int>("character");
							MonarchName = monarch.Value<string>("name");
						}

						if (!mInitFinished)
						{
							FinishInitializing();
						}
					}

					// House Information for Owners
					else if (eventId == 0x0225)
					{
						MessageStruct position = e.Message.Struct("position");
						mHouseCoords = new Coordinates(position.Value<int>("landcell"),
							position.Value<float>("y"), position.Value<float>("x"), 1);

						if (mLoginCompleted && chkAutoUpdateRecalls.Checked)
						{
							// Don't notify if the user logged in less than 1 minute ago
							// If the user logged in more than 1 minute ago, chances are
							// they're purchasing a house.
							bool quiet = (DateTime.Now - mLoginTime) < TimeSpan.FromMinutes(1);
							UpdateStartLocation(mHouseCoords, RouteStartType.HouseRecall, quiet);
						}
					}
				}
			}
			catch (Exception ex) { Util.HandleException(ex); }
		}
Example #17
0
		public string MakeCoordsChatLink(Coordinates coords)
		{
			return MakeCoordsChatLink(coords.ToString());
		}
Example #18
0
		private void AddSetting(XmlDocument doc, string name, Coordinates value) { AddSetting(doc, name, value.ToString()); }