Update BetterAtHome.cs
teachs the bot to avoid a sim thats restarting
This commit is contained in:
parent
372dc80444
commit
5720c773b4
1 changed files with 63 additions and 9 deletions
|
|
@ -191,6 +191,7 @@ namespace BetterSecondbot.BetterAtHome
|
||||||
|
|
||||||
protected void StatusPing(object o, StatusMessageEvent e)
|
protected void StatusPing(object o, StatusMessageEvent e)
|
||||||
{
|
{
|
||||||
|
CleanAvoidSimList();
|
||||||
if (hasBasicBot() == false)
|
if (hasBasicBot() == false)
|
||||||
{
|
{
|
||||||
return; // no bot (cant do anything)
|
return; // no bot (cant do anything)
|
||||||
|
|
@ -221,12 +222,50 @@ namespace BetterSecondbot.BetterAtHome
|
||||||
|
|
||||||
protected void AlertMessage(object o, AlertMessageEventArgs e)
|
protected void AlertMessage(object o, AlertMessageEventArgs e)
|
||||||
{
|
{
|
||||||
if(e.Message.Contains("Restart") == true)
|
if(e.Message.Contains("restart") == true)
|
||||||
{
|
{
|
||||||
gotoNextHomeRegion(true);
|
AvoidSim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void CleanAvoidSimList()
|
||||||
|
{
|
||||||
|
List<string> clear = new List<string>();
|
||||||
|
foreach(string A in AvoidSimList.Keys)
|
||||||
|
{
|
||||||
|
long dif = helpers.UnixTimeNow() - AvoidSimList[A];
|
||||||
|
if(dif > 240)
|
||||||
|
{
|
||||||
|
clear.Add(A);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach(string A in clear)
|
||||||
|
{
|
||||||
|
AvoidSimList.Remove(A);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected bool SimInAvoid()
|
||||||
|
{
|
||||||
|
return AvoidSimList.ContainsKey(simname);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected bool IsInAvoidList(string slurl)
|
||||||
|
{
|
||||||
|
string[] bits = helpers.ParseSLurl(slurl);
|
||||||
|
return AvoidSimList.ContainsKey(bits[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, long> AvoidSimList = new Dictionary<string, long>();
|
||||||
|
protected void AvoidSim()
|
||||||
|
{
|
||||||
|
if(AvoidSimList.ContainsKey(simname) == false)
|
||||||
|
{
|
||||||
|
AvoidSimList.Add(simname, 1);
|
||||||
|
}
|
||||||
|
AvoidSimList[simname] = helpers.UnixTimeNow();
|
||||||
|
}
|
||||||
|
|
||||||
protected void LoggedOutActions()
|
protected void LoggedOutActions()
|
||||||
{
|
{
|
||||||
SetBetterAtHomeAction("Logged Out Actions");
|
SetBetterAtHomeAction("Logged Out Actions");
|
||||||
|
|
@ -320,9 +359,10 @@ namespace BetterSecondbot.BetterAtHome
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
void_counter = 0;
|
void_counter = 0;
|
||||||
if (homeRegions.Count == 0)
|
if (SimInAvoid() == true)
|
||||||
{
|
{
|
||||||
SetBetterAtHomeAction("No home regions");
|
SetBetterAtHomeAction("Attempting to avoid this sim");
|
||||||
|
gotoNextHomeRegion(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (controler.Bot.TeleportStatus() == true)
|
if (controler.Bot.TeleportStatus() == true)
|
||||||
|
|
@ -330,6 +370,11 @@ namespace BetterSecondbot.BetterAtHome
|
||||||
SetBetterAtHomeAction("Teleported");
|
SetBetterAtHomeAction("Teleported");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (homeRegions.Count == 0)
|
||||||
|
{
|
||||||
|
SetBetterAtHomeAction("No home regions");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (IsAtHome() == true)
|
if (IsAtHome() == true)
|
||||||
{
|
{
|
||||||
SetBetterAtHomeAction("AtHome");
|
SetBetterAtHomeAction("AtHome");
|
||||||
|
|
@ -359,6 +404,15 @@ namespace BetterSecondbot.BetterAtHome
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(IsInAvoidList(configfile.Basic_HomeRegions[homeregionIndexer]) == true)
|
||||||
|
{
|
||||||
|
if (force == true)
|
||||||
|
{
|
||||||
|
gotoNextHomeRegion(false);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SetBetterAtHomeAction("Teleporting to home region: " + homeRegions[homeregionIndexer] + "");
|
SetBetterAtHomeAction("Teleporting to home region: " + homeRegions[homeregionIndexer] + "");
|
||||||
LastTeleportEvent = helpers.UnixTimeNow();
|
LastTeleportEvent = helpers.UnixTimeNow();
|
||||||
controler.Bot.TeleportWithSLurl(configfile.Basic_HomeRegions[homeregionIndexer]);
|
controler.Bot.TeleportWithSLurl(configfile.Basic_HomeRegions[homeregionIndexer]);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue