Esempio n. 1
0
        private static void PortalUsedEvent(bool isDeathGate)
        {
            Log.Info("Last World Id={0} LastWorldPosition={1}", LastWorldId, LastWorldPosition);

            var portal = Data.Portals.OrderByDescending(p => p.Distance).FirstOrDefault();

            if (portal != null)
            {
                var interactable = BotHistory.PortalHistory.FirstOrDefault(p => DateTime.UtcNow.Subtract(p.Value.LastTimeCloseTo).TotalSeconds < 15 && p.Value.WorldSnoId != ZetaDia.CurrentWorldSnoId);
                if (interactable.Value != null)
                {
                    Log.Info("Portal Used: {0} in WorldSnoId={1}", interactable.Value.InternalName, interactable.Value.WorldSnoId);
                    Player.LastEntryPortal = interactable.Value;
                    IsIdle = false;
                    EventManager.FireEvent(new EventData(EventType.UsedPortal, null, interactable.Value, true));
                }
                else
                {
                    Log.Debug("Unable to figure out which portal was interacted with.");
                }
            }
        }
Esempio n. 2
0
        public static void CheckForChanges()
        {
            var now = DateTime.UtcNow;

            if (!ZetaDia.IsInGame || ZetaDia.Me == null || DateTime.UtcNow.Subtract(LastChecked).TotalMilliseconds < 250)
            {
                return;
            }

            var me = ZetaDia.Me;

            if (!me.IsValid || me.CommonData == null)
            {
                return;
            }

            var commonData = ZetaDia.Me.CommonData;

            if (!commonData.IsValid || commonData.IsDisposed)
            {
                return;
            }

            var currentPosition = ZetaDia.Me.Position;

            if (currentPosition == Vector3.Zero)
            {
                return;
            }

            var distanceTravelled = _lastPosition.Distance(currentPosition);

            var isCastingTownPortal = CheckVisualEffectNoneForPower(commonData, SNOPower.UseStoneOfRecall);
            var isCastingTeleport   = CheckVisualEffectNoneForPower(commonData, SNOPower.TeleportToPlayer_Cast);
            var isCastingWaypoint   = CheckVisualEffectNoneForPower(commonData, SNOPower.TeleportToWaypoint_Cast);

            if (isCastingTownPortal)
            {
                LastCastWaypoint = now;
            }

            if (isCastingTeleport)
            {
                LastCastWaypoint = now;
            }

            if (isCastingWaypoint)
            {
                LastCastWaypoint = now;
            }

            if (isCastingTownPortal || isCastingTeleport || isCastingWaypoint)
            {
                LastCastPortalSpell = now;
            }

            CheckForDeathGateUsage(currentPosition, distanceTravelled);

            CheckForIdle();

            var isVendoring = BrainBehavior.IsVendoring;

            if (isVendoring != _isVendoring)
            {
                if (isVendoring)
                {
                    EventManager.FireEvent(new EventData(EventType.StartingTownRun));
                }
                _isVendoring = isVendoring;
            }

            var worldId = ZetaDia.CurrentWorldSnoId;

            if (ZetaDia.WorldInfo.IsValid && worldId != _worldId && worldId != 0)
            {
                EventManager.FireEvent(new EventData(EventType.WorldAreaChanged, _worldId, worldId));
                LastWorldId       = _worldId;
                LastWorldPosition = _lastPosition;
                _worldId          = worldId;
            }

            if (!AutoFollow.CurrentLeader.IsMe)
            {
                var leaderActor = Data.GetPlayerActor(AutoFollow.CurrentLeader);
                if (leaderActor != _leaderActor)
                {
                    if (leaderActor == null)
                    {
                        Log.Warn("Lost leader, he was right here");
                    }
                    else
                    {
                        Log.Warn("Found leader! ");
                        LastSeenLeaderPosition = leaderActor.Position;
                        LastSeenLeaderWorld    = _worldId;
                        LastSeenLeaderTime     = DateTime.UtcNow;
                    }
                    _leaderActor = leaderActor;
                }
            }
            else
            {
                _leaderActor = null;
            }

            var levelAreaId = Player.LevelAreaId;

            if (ZetaDia.WorldInfo.IsValid && levelAreaId != _levelAreaId && levelAreaId != 0)
            {
                EventManager.FireEvent(new EventData(EventType.LevelAreaChanged, _levelAreaId, levelAreaId));
                _levelAreaId = levelAreaId;
            }

            var isDead = ZetaDia.Me.IsDead;

            if (Data.IsValid(ZetaDia.Me) && isDead != _isDead)
            {
                EventManager.FireEvent(new EventData(EventType.Died));
                _isDead = isDead;
            }

            var inTrouble = ZetaDia.Me.HitpointsCurrentPct < 0.5;

            if (Data.IsValid(ZetaDia.Me) && isDead != _inTrouble)
            {
                EventManager.FireEvent(new EventData(EventType.InTrouble));
                _inTrouble = inTrouble;
            }

            _lastPosition = ZetaDia.Me.Position;
        }
Esempio n. 3
0
 private static void GameEvents_OnGameJoined(object sender, EventArgs e)
 {
     LastGameJoinedTime = DateTime.UtcNow;
     EventManager.FireEvent(new EventData(EventType.JoinedGame));
 }
Esempio n. 4
0
 private static void GameEvents_OnPlayerDied(object sender, EventArgs e)
 {
     LastPlayerDiedTime = DateTime.UtcNow;
     EventManager.FireEvent(new EventData(EventType.Died));
 }
        public static void CheckForChanges()
        {
            var now = DateTime.UtcNow;

            if (!ZetaDia.IsInGame || ZetaDia.Me == null || DateTime.UtcNow.Subtract(LastChecked).TotalMilliseconds < 250)
            {
                return;
            }

            var me = ZetaDia.Me;

            if (!me.IsValid || me.CommonData == null)
            {
                return;
            }

            var commonData = ZetaDia.Me.CommonData;

            if (!commonData.IsValid || commonData.IsDisposed)
            {
                return;
            }

            var currentPosition = ZetaDia.Me.Position;

            if (currentPosition == Vector3.Zero)
            {
                return;
            }

            var distanceTravelled = _lastPosition.Distance(currentPosition);

            var isCastingTownPortal = CheckVisualEffectNoneForPower(commonData, SNOPower.UseStoneOfRecall);
            var isCastingTeleport   = CheckVisualEffectNoneForPower(commonData, SNOPower.TeleportToPlayer_Cast);
            var isCastingWaypoint   = CheckVisualEffectNoneForPower(commonData, SNOPower.TeleportToWaypoint_Cast);

            if (isCastingTownPortal)
            {
                LastCastTownPortal = now;
            }

            if (isCastingTeleport)
            {
                LastCastWaypoint = now;
            }

            if (isCastingWaypoint)
            {
                LastCastWaypoint = now;
            }

            if (isCastingTownPortal || isCastingTeleport || isCastingWaypoint)
            {
                LastCastPortalSpell = now;
            }

            CheckForDeathGateUsage(currentPosition, distanceTravelled);

            CheckForIdle();

            var isVendoring = BrainBehavior.IsVendoring;

            if (isVendoring != _isVendoring)
            {
                if (isVendoring)
                {
                    EventManager.FireEvent(new EventData(EventType.StartingTownRun));
                }
                _isVendoring = isVendoring;
            }

            var worldId = ZetaDia.Globals.WorldSnoId;

            if (ZetaDia.WorldInfo.IsValid && worldId != _worldId && worldId != 0)
            {
                EventManager.FireEvent(new EventData(EventType.WorldAreaChanged, _worldId, worldId));
                LastWorldId       = _worldId;
                LastWorldPosition = _lastPosition;
                _worldId          = worldId;
            }

            if (!AutoFollow.CurrentLeader.IsMe)
            {
                var leaderActor = Data.GetPlayerActor(AutoFollow.CurrentLeader);
                if (leaderActor != _leaderActor)
                {
                    if (leaderActor == null)
                    {
                        Log.Warn("Lost leader, he was right here");
                    }
                    else
                    {
                        Log.Warn("Found leader! ");
                        LastSeenLeaderPosition = leaderActor.Position;
                        LastSeenLeaderWorld    = _worldId;
                        LastSeenLeaderTime     = DateTime.UtcNow;
                    }
                    _leaderActor = leaderActor;
                }
            }
            else
            {
                _leaderActor = null;
            }

            var levelAreaId = Player.LevelAreaId;

            if (ZetaDia.WorldInfo.IsValid && levelAreaId != _levelAreaId && levelAreaId != 0)
            {
                EventManager.FireEvent(new EventData(EventType.LevelAreaChanged, _levelAreaId, levelAreaId));
                _levelAreaId = levelAreaId;
            }

            var isDead = ZetaDia.Me.IsDead;

            if (Data.IsValid(ZetaDia.Me) && isDead != _isDead)
            {
                EventManager.FireEvent(new EventData(EventType.Died));
                _isDead = isDead;
            }

            var inTrouble = ZetaDia.Me.HitpointsCurrentPct < 0.5;

            if (Data.IsValid(ZetaDia.Me) && isDead != _inTrouble)
            {
                EventManager.FireEvent(new EventData(EventType.InTrouble));
                _inTrouble = inTrouble;
            }

            if (RiftHelper.RiftQuest != null)
            {
                var riftGaurdianKilled = RiftHelper.RiftQuest.Step == RiftQuest.RiftStep.Cleared || RiftHelper.RiftQuest.Step == RiftQuest.RiftStep.UrshiSpawned;
                if (riftGaurdianKilled != _riftGaurdianKilled)
                {
                    if (riftGaurdianKilled)
                    {
                        Log.Warn("So sad, that poor misunderstood greebly just wanted a hug.");
                        EventManager.FireEvent(new EventData(EventType.KilledRiftGaurdian));
                    }
                    _riftGaurdianKilled = riftGaurdianKilled;
                }
            }

            if (RiftHelper.Type != RiftType.None)
            {
                var riftGaurdianHiding = RiftHelper.IsStarted && !RiftHelper.HasGuardianSpawned;
                if (riftGaurdianHiding != _riftGaurdianHiding)
                {
                    if (!riftGaurdianHiding && RiftHelper.IsStarted)
                    {
                        Log.Warn("Whats this, there's something lurking nearby?");
                        EventManager.FireEvent(new EventData(EventType.SpawnedRiftGaurdian));
                    }
                    _riftGaurdianHiding = riftGaurdianHiding;
                }
            }

            _lastPosition = ZetaDia.Me.Position;
        }