Ok, I've looked through all your logic and the Interact() logic in Trinity... but it's a little hard to figure out since I don't have a necro to test.
Interact() itself has two different routines, one in TrinityActor that stops the player, does a case switch on Gizmo (which a Shrine should be), then uses a power to activate:
Code:
public bool Interact()
{
Navigator.PlayerMover.MoveStop();
switch (ActorType)
{
case ActorType.Monster:
return ZetaDia.Me.UsePower(SNOPower.Axe_Operate_NPC, Vector3.Zero, 0, AcdId);
case ActorType.Gizmo:
case ActorType.Item:
return ZetaDia.Me.UsePower(SNOPower.Axe_Operate_Gizmo, Vector3.Zero, 0, AcdId);
default:
return false;
}
}
For all intents and purposes, that part looks good.
There's a private method in MoveToAndInteract which is slightly different, but I don't think we need to worry about that.
If I look for an example of Interact() elsewhere, you can find this:
Code:
if (ZetaDia.IsInTown && !ZetaDia.Globals.IsLoadingWorld)
{
Core.Logger.Log("Trying again to use return portal.");
var gizmo = ZetaDia.Actors.GetActorsOfType<DiaGizmo>().FirstOrDefault(g => g.ActorInfo.GizmoType == GizmoType.HearthPortal);
if (gizmo != null)
{
await CommonCoroutines.MoveAndStop(gizmo.Position, 2f, "Portal Position");
await Coroutine.Sleep(1000);
gizmo.Interact();
gizmo.Interact();
}
}
Pretty straightforward, searches for HearthPortals in all DiaGizmo actors, picks the first, null tests it, moves and stops, then interacts twice. I'm guessing that's to make sure it actually interacts.
Here's a dump of a shrine I just found in game:
Code:
ActorId: 176074, Type: Gizmo, Name: Shrine_Global_Blessed-5166, Distance2d: 3087.256, CollisionRadius: 10.04086, MinimapActive: 1, MinimapIconOverride: -1, MinimapDisableArrow: 0
And finally, the experimental code you have:
Code:
private TrinityActor FindShrine(float range = 60f)
{
TrinityActor target = null;
target = TargetUtil.SafeList().Where(a => a?.Type == TrinityObjectType.Shrine && a.Distance < range).OrderBy(a => a.Distance).FirstOrDefault();
return target;
}
/*
shrineTarget = FindShrine();
if (shrineTarget != null)
{
if (shrineTarget.Position.Distance(closestTarget.Position) >= shrineTarget.Position.Distance(Player.Position) && !shrineTarget.IsAvoidanceOnPath)
{
if (shrineTarget.Position.Distance(Player.Position) <= 7f)
{
target.Interact();
return false;
}
else
{
destination = shrineTarget.Position;
return true;
}
}
}
*/
Based on that, I have a few suggestions to try. I would have tested them, but again I don't have a necro leveled up enough.
1. Add a bunch of logging statements throughout your logic to make sure it's working where it should and that something else isn't hanging up.
2. Try changing your FindShrine to something like the other interact code above if the logging statements show an issue with the logic itself.
3. Instead of interact, you can try clicking it directly:
Code:
ZetaDia.Me.UsePower(SNOPower.Axe_Operate_Gizmo, target.Position);