improve homebound
This commit is contained in:
parent
c34a3bd8dc
commit
26976280d2
3 changed files with 35 additions and 5 deletions
|
|
@ -73,6 +73,7 @@ ENV basic_Username='' \
|
||||||
homebound_AtHomeSeekLocation='false' \
|
homebound_AtHomeSeekLocation='false' \
|
||||||
homebound_AtBackupSeekLocation='false' \
|
homebound_AtBackupSeekLocation='false' \
|
||||||
homebound_AtHomeAutoSitUuid='00000000-0000-0000-0000-000000000000' \
|
homebound_AtHomeAutoSitUuid='00000000-0000-0000-0000-000000000000' \
|
||||||
|
homebound_ReturnToHomeSimAfterMins=5 \
|
||||||
http_Enabled='false' \
|
http_Enabled='false' \
|
||||||
http_Port=80 \
|
http_Port=80 \
|
||||||
interaction_Enabled='true' \
|
interaction_Enabled='true' \
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ namespace SecondBotEvents.Config
|
||||||
settings.Add("Enabled");
|
settings.Add("Enabled");
|
||||||
settings.Add("HomeSimSlUrl");
|
settings.Add("HomeSimSlUrl");
|
||||||
settings.Add("BackupSimSLUrl");
|
settings.Add("BackupSimSLUrl");
|
||||||
|
settings.Add("ReturnToHomeSimAfterMins");
|
||||||
settings.Add("AtHomeSeekLocation");
|
settings.Add("AtHomeSeekLocation");
|
||||||
settings.Add("AtBackupSeekLocation");
|
settings.Add("AtBackupSeekLocation");
|
||||||
settings.Add("AtHomeAutoSitUuid");
|
settings.Add("AtHomeAutoSitUuid");
|
||||||
|
|
@ -25,6 +26,11 @@ namespace SecondBotEvents.Config
|
||||||
return ReadSettingAsString("AtHomeAutoSitUuid", UUID.Zero.ToString());
|
return ReadSettingAsString("AtHomeAutoSitUuid", UUID.Zero.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetReturnToHomeSimAfterMins()
|
||||||
|
{
|
||||||
|
return ReadSettingAsInt("ReturnToHomeSimAfterMins", 1);
|
||||||
|
}
|
||||||
|
|
||||||
public bool GetAtHomeSeekLocation()
|
public bool GetAtHomeSeekLocation()
|
||||||
{
|
{
|
||||||
return ReadSettingAsBool("AtHomeSeekLocation", true);
|
return ReadSettingAsBool("AtHomeSeekLocation", true);
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,11 @@ namespace SecondBotEvents.Services
|
||||||
protected UUID sitTarget = UUID.Zero;
|
protected UUID sitTarget = UUID.Zero;
|
||||||
protected long lastAlertTeleport = 0;
|
protected long lastAlertTeleport = 0;
|
||||||
protected bool evacWanted = false;
|
protected bool evacWanted = false;
|
||||||
|
protected bool evacTeleport = false;
|
||||||
protected bool gotoPosAttemptedTp = false;
|
protected bool gotoPosAttemptedTp = false;
|
||||||
protected bool gotoPosAttemptedWalk = false;
|
protected bool gotoPosAttemptedWalk = false;
|
||||||
protected long lastGotoAction = 0;
|
protected long lastGotoAction = 0;
|
||||||
|
protected long lastTeleportHomeAttempt = 0;
|
||||||
protected bool softDisable = false;
|
protected bool softDisable = false;
|
||||||
protected bool closeToHome = false;
|
protected bool closeToHome = false;
|
||||||
protected bool softDisableSit = false;
|
protected bool softDisableSit = false;
|
||||||
|
|
@ -67,11 +69,13 @@ namespace SecondBotEvents.Services
|
||||||
public bool GoHome()
|
public bool GoHome()
|
||||||
{
|
{
|
||||||
attemptedTeleportHome = true;
|
attemptedTeleportHome = true;
|
||||||
|
lastTeleportHomeAttempt = SecondbotHelpers.UnixTimeNow();
|
||||||
LogFormater.Info("Teleporting to home sim");
|
LogFormater.Info("Teleporting to home sim");
|
||||||
return GetClient().Self.Teleport(home.name, new Vector3(home.x, home.y, home.z), new Vector3(0, 0, 0));
|
return GetClient().Self.Teleport(home.name, new Vector3(home.x, home.y, home.z), new Vector3(0, 0, 0));
|
||||||
}
|
}
|
||||||
protected void Tick()
|
protected void Tick()
|
||||||
{
|
{
|
||||||
|
long dif = 0;
|
||||||
if (evacWanted == true)
|
if (evacWanted == true)
|
||||||
{
|
{
|
||||||
BotAlertMessage(null, new AlertMessageEventArgs("restart", "999", new OpenMetaverse.StructuredData.OSDMap()));
|
BotAlertMessage(null, new AlertMessageEventArgs("restart", "999", new OpenMetaverse.StructuredData.OSDMap()));
|
||||||
|
|
@ -79,6 +83,7 @@ namespace SecondBotEvents.Services
|
||||||
if (GetClient().Network.CurrentSim.Name == home.name)
|
if (GetClient().Network.CurrentSim.Name == home.name)
|
||||||
{
|
{
|
||||||
simNickname = "Home # ";
|
simNickname = "Home # ";
|
||||||
|
evacTeleport = false;
|
||||||
if (sitTarget != UUID.Zero)
|
if (sitTarget != UUID.Zero)
|
||||||
{
|
{
|
||||||
if (GetClient().Self.SittingOn == 0)
|
if (GetClient().Self.SittingOn == 0)
|
||||||
|
|
@ -102,6 +107,7 @@ namespace SecondBotEvents.Services
|
||||||
{
|
{
|
||||||
GetToPos(backup);
|
GetToPos(backup);
|
||||||
}
|
}
|
||||||
|
TryGoHome();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (simNickname == "")
|
if (simNickname == "")
|
||||||
|
|
@ -115,26 +121,38 @@ namespace SecondBotEvents.Services
|
||||||
simNickname = "Someplace # ";
|
simNickname = "Someplace # ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
TryGoHome();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void TryGoHome()
|
||||||
|
{
|
||||||
long dif = SecondbotHelpers.UnixTimeNow() - teleportActionLockout;
|
long dif = SecondbotHelpers.UnixTimeNow() - teleportActionLockout;
|
||||||
if(dif < 30)
|
if (dif < 30)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
teleportActionLockout = SecondbotHelpers.UnixTimeNow();
|
teleportActionLockout = SecondbotHelpers.UnixTimeNow();
|
||||||
if (attemptedTeleportHome == false)
|
if (attemptedTeleportHome == false)
|
||||||
{
|
{
|
||||||
if(GoHome() == false)
|
dif = SecondbotHelpers.UnixTimeNow() - lastTeleportHomeAttempt;
|
||||||
|
if ((dif / 60) >= myConfig.GetReturnToHomeSimAfterMins())
|
||||||
{
|
{
|
||||||
LogFormater.Warn("Unable to teleport to home sim");
|
attemptedTeleportHome = false;
|
||||||
|
evacTeleport = false;
|
||||||
|
LogFormater.Info("trying to return to home sim");
|
||||||
|
if (GoHome() == false)
|
||||||
|
{
|
||||||
|
LogFormater.Warn("Unable to teleport to home sim");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(attemptedTeleportBackup == false)
|
else if (attemptedTeleportBackup == false)
|
||||||
{
|
{
|
||||||
attemptedTeleportBackup = true;
|
attemptedTeleportBackup = true;
|
||||||
LogFormater.Info("Teleporting to backup sim");
|
LogFormater.Info("Teleporting to backup sim");
|
||||||
teleportActionLockout = SecondbotHelpers.UnixTimeNow();
|
teleportActionLockout = SecondbotHelpers.UnixTimeNow();
|
||||||
if(GetClient().Self.Teleport(backup.name, new Vector3(backup.x, backup.y, backup.z), new Vector3(0, 0, 0)) == false)
|
if (GetClient().Self.Teleport(backup.name, new Vector3(backup.x, backup.y, backup.z), new Vector3(0, 0, 0)) == false)
|
||||||
{
|
{
|
||||||
LogFormater.Warn("Unable to teleport to backup sim");
|
LogFormater.Warn("Unable to teleport to backup sim");
|
||||||
}
|
}
|
||||||
|
|
@ -170,6 +188,10 @@ namespace SecondBotEvents.Services
|
||||||
{
|
{
|
||||||
return simNickname + "Sitting on a thing";
|
return simNickname + "Sitting on a thing";
|
||||||
}
|
}
|
||||||
|
else if(evacTeleport == true)
|
||||||
|
{
|
||||||
|
return simNickname + "Evac teleport";
|
||||||
|
}
|
||||||
else if(closeToHome == true)
|
else if(closeToHome == true)
|
||||||
{
|
{
|
||||||
return simNickname + "In a safe space";
|
return simNickname + "In a safe space";
|
||||||
|
|
@ -258,6 +280,7 @@ namespace SecondBotEvents.Services
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
evacWanted = false;
|
evacWanted = false;
|
||||||
|
evacTeleport = true;
|
||||||
if (GetClient().Network.CurrentSim.Name == home.name)
|
if (GetClient().Network.CurrentSim.Name == home.name)
|
||||||
{
|
{
|
||||||
LogFormater.Info("Teleporting to backup sim to avoid restart");
|
LogFormater.Info("Teleporting to backup sim to avoid restart");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue