public override void Run() { MovementManager.StopMoveNewThread(); MovementManager.StopMoveToNewThread(); FlightMaster flightmasterFrom = Main.from; FlightMaster flightmasterTo = Main.to; if (WFMMoveInteract.GoInteractwithFM(flightmasterFrom, true)) { if (FlightMasterDB.UpdateKnownFMs(flightmasterFrom)) { Logger.Log("Flightmaster list has changed. Trying to find a new path."); Main.to = null; Main.shouldTakeFlight = false; return; } List <string> reachableTaxis = new List <string>(); // Look for current To and record reachables in case we can't find it for (int i = 0; i < 120; i++) { string nodeStatus = Lua.LuaDoString <string>($"return TaxiNodeGetType({i})"); string nodeName = Lua.LuaDoString <string>($"return TaxiNodeName({i})"); if (nodeStatus == "REACHABLE") { if (nodeName == flightmasterTo.Name) { TakeTaxi(flightmasterFrom, nodeName); return; } reachableTaxis.Add(nodeName); } } // Find an alternative Logger.Log($"{flightmasterTo.Name} is unreachable, trying to find an alternative"); FlightMaster alternativeFm = Main.GetBestAlternativeTo(reachableTaxis); if (alternativeFm != null) { Logger.Log($"Found an alternative flight : {alternativeFm.Name}"); TakeTaxi(flightmasterFrom, alternativeFm.Name); return; } else { Main.shouldTakeFlight = false; ToolBox.PausePlugin("Couldn't find an alternative flight"); } } }
public override void Run() { MovementManager.StopMoveNewThread(); MovementManager.StopMoveToNewThread(); FlightMaster fmToDiscover = Main.flightMasterToDiscover; Logger.Log($"Discovering flight master {fmToDiscover.Name}"); // We go to the position if (WFMMoveInteract.GoInteractwithFM(fmToDiscover)) { FlightMasterDB.SetFlightMasterToKnown(fmToDiscover.NPCId); Main.flightMasterToDiscover = null; ToolBox.UnPausePlugin(); Main.shouldTakeFlight = false; FlightMasterDB.UpdateKnownFMs(fmToDiscover); MovementManager.StopMove(); // reset path } }
public static bool UpdateKnownFMs(FlightMaster FMWithMapOpen) { if ((ContinentId)Usefuls.ContinentId == ContinentId.Azeroth && !azerothNodesUpdated || (ContinentId)Usefuls.ContinentId == ContinentId.Kalimdor && !kalimdorNodesUpdated || (ContinentId)Usefuls.ContinentId == ContinentId.Expansion01 && !outlandNodesUpdated || (ContinentId)Usefuls.ContinentId == ContinentId.Northrend && !northrendNodesUpdated) { Logger.Log($"Updating known FlightMasters on {Usefuls.ContinentNameMpq} for this session"); bool allInvalid = true; bool latNodeWasInvalid = false; bool modificationWasMade = false; bool endOfListReached = false; // 3 attempts to discover flights for (int j = 1; j <= 3; j++) { if (endOfListReached) { if ((ContinentId)Usefuls.ContinentId == ContinentId.Azeroth) { azerothNodesUpdated = true; } else if ((ContinentId)Usefuls.ContinentId == ContinentId.Kalimdor) { kalimdorNodesUpdated = true; } else if ((ContinentId)Usefuls.ContinentId == ContinentId.Expansion01) { outlandNodesUpdated = true; } else if ((ContinentId)Usefuls.ContinentId == ContinentId.Northrend) { northrendNodesUpdated = true; } break; } WFMMoveInteract.GoInteractwithFM(FMWithMapOpen); // Loop through nodes for (int i = 0; i < 120; i++) { string nodeName = Lua.LuaDoString <string>($"return TaxiNodeName({i})"); if (nodeName != "INVALID") { allInvalid = false; latNodeWasInvalid = false; if (SetFlightMasterToKnown(nodeName) && modificationWasMade == false) { modificationWasMade = true; } } else { // we hit 2 invalids in a row - means this is the end of the list if (latNodeWasInvalid) { endOfListReached = true; break; } latNodeWasInvalid = true; if (SetFlightMasterToUnknown(nodeName) && modificationWasMade == false) { modificationWasMade = true; } } } if (allInvalid) { Lua.LuaDoString("CloseGossip()"); Logger.LogDebug($"All flight nodes are invalid, retrying ({j}/3)"); Thread.Sleep(500); } } if (allInvalid) { ToolBox.PausePlugin("Couldn't find a valid flight node"); } return(modificationWasMade); } return(false); }
private void TakeTaxi(FlightMaster fm, string taxiNodeName) { string clickNodeLua = "TakeTaxiNode(" + Lua.LuaDoString <int>("for i=0,120 do if string.find(TaxiNodeName(i),'" + taxiNodeName.Replace("'", "\\'") + "') then return i end end", "").ToString() + ")"; Logger.LogDebug(clickNodeLua); Lua.LuaDoString(clickNodeLua, false); Thread.Sleep(500); // 5 tries to click on node if it failed for (int i = 1; i <= 5; i++) { if (ObjectManager.Me.IsCast) { Usefuls.WaitIsCasting(); i = 1; Logger.Log("You're casting, wait"); continue; } if (ObjectManager.Me.IsOnTaxi || Main.inPause) { break; } else { Logger.Log($"Taking taxi failed. Retrying ({i}/5)"); Lua.LuaDoString($"CloseTaxiMap(); CloseGossip();"); Main.errorTooFarAwayFromTaxiStand = false; Thread.Sleep(500); if (WFMMoveInteract.GoInteractwithFM(fm)) { Thread.Sleep(500); } Usefuls.SelectGossipOption(GossipOptionsType.taxi); Thread.Sleep(500); Lua.LuaDoString(clickNodeLua, false); Thread.Sleep(500); } } if (Main.inPause) { return; } if (Main.errorTooFarAwayFromTaxiStand) { ToolBox.PausePlugin("Taking taxi failed (error clicking node)"); } else { Logger.Log($"Flying to {taxiNodeName}"); } Thread.Sleep(Usefuls.Latency + 500); Main.shouldTakeFlight = false; Main.errorTooFarAwayFromTaxiStand = false; Thread.Sleep(Usefuls.Latency + 500); if (!ObjectManager.Me.IsOnTaxi) { ToolBox.PausePlugin("Taking taxi failed"); } }