Example #1
0
 public EntityChangedEvent(FFXIVProcess.EntityData e)
 {
     if (e != null)
     {
         id        = e.id;
         level     = e.level;
         name      = e.name;
         job       = e.job.ToString();
         currentHP = e.hp;
         maxHP     = e.max_hp;
         currentMP = e.mp;
         maxMP     = e.max_mp;
         pos       = new Point3F(e.pos_x, e.pos_y, e.pos_z);
         distance  = e.distance;
     }
 }
Example #2
0
 public PlayerChangedEvent(FFXIVProcess.EntityData e)
 {
     id            = e.id;
     level         = e.level;
     name          = e.name;
     job           = e.job.ToString();
     currentHP     = e.hp;
     maxHP         = e.max_hp;
     currentMP     = e.mp;
     maxMP         = e.max_mp;
     maxTP         = 1000;
     currentGP     = e.gp;
     maxGP         = e.max_gp;
     currentCP     = e.cp;
     maxCP         = e.max_cp;
     pos           = new Point3F(e.pos_x, e.pos_y, e.pos_z);
     rotation      = e.rotation;
     jobDetail     = null;
     bait          = e.bait;
     debugJob      = e.debug_job;
     currentShield = e.shield_value;
 }
Example #3
0
        // Events that we want to update as soon as possible.  Return next time this should be called.
        private int SendFastRateEvents()
        {
            if (reset_notify_state_)
            {
                notify_state_ = new NotifyState();
            }
            reset_notify_state_ = false;

            bool game_exists = ffxiv_.FindProcess();

            if (game_exists != notify_state_.game_exists)
            {
                notify_state_.game_exists = game_exists;
                DispatchToJS(new JSEvents.GameExistsEvent(game_exists));
            }

            bool game_active = game_active = ffxiv_.IsActive();

            if (game_active != notify_state_.game_active)
            {
                notify_state_.game_active = game_active;
                DispatchToJS(new JSEvents.GameActiveChangedEvent(game_active));
            }

            // Silently stop sending other messages if the ffxiv process isn't around.
            if (!game_exists)
            {
                return(kUberSlowTimerMilli);
            }

            // onInCombatChangedEvent: Fires when entering or leaving combat.
            bool in_act_combat  = ActGlobals.oFormActMain.InCombat;
            bool in_game_combat = ffxiv_.GetInGameCombat();

            if (!notify_state_.in_act_combat.HasValue || in_act_combat != notify_state_.in_act_combat ||
                !notify_state_.in_game_combat.HasValue || in_game_combat != notify_state_.in_game_combat)
            {
                notify_state_.in_act_combat  = in_act_combat;
                notify_state_.in_game_combat = in_game_combat;
                DispatchToJS(new JSEvents.InCombatChangedEvent(in_act_combat, in_game_combat));
            }

            // onZoneChangedEvent: Fires when the player changes their current zone.
            string zone_name = ActGlobals.oFormActMain.CurrentZone;

            if (notify_state_.zone_name == null || !zone_name.Equals(notify_state_.zone_name))
            {
                notify_state_.zone_name = zone_name;
                DispatchToJS(new JSEvents.ZoneChangedEvent(zone_name));
                ClearFateWatcherDictionaries();
            }

            DateTime now = DateTime.Now;

            // The |player| can be null, such as during a zone change.
            FFXIVProcess.EntityData player = ffxiv_.GetSelfData();

            // onPlayerDiedEvent: Fires when the player dies. All buffs/debuffs are
            // lost.
            if (player != null)
            {
                bool dead = player.hp == 0;
                if (dead != notify_state_.dead)
                {
                    notify_state_.dead = dead;
                    if (dead)
                    {
                        DispatchToJS(new JSEvents.PlayerDiedEvent());
                    }
                }
            }

            // onPlayerChangedEvent: Fires when current player data changes.
            if (player != null)
            {
                bool send = false;
                if (!player.Equals(notify_state_.player))
                {
                    // Clear the FATE dictionary if we switched characters
                    if (notify_state_.player != null && !player.name.Equals(notify_state_.player.name))
                    {
                        ClearFateWatcherDictionaries();
                    }
                    notify_state_.player = player;
                    send = true;
                }
                var job = ffxiv_.GetJobSpecificData(player.job);
                if (job != null)
                {
                    if (send || !JObject.DeepEquals(job, notify_state_.job_data))
                    {
                        notify_state_.job_data = job;
                        var ev = new JSEvents.PlayerChangedEvent(player);
                        ev.jobDetail = job;
                        DispatchToJS(ev);
                    }
                }
                else if (send)
                {
                    // No job-specific data.
                    DispatchToJS(new JSEvents.PlayerChangedEvent(player));
                }
            }

            // onLogEvent: Fires when new combat log events from FFXIV are available. This fires after any
            // more specific events, some of which may involve parsing the logs as well.
            List <string> logs;
            List <string> import_logs;

            log_lines_semaphore_.Wait();
            logs              = log_lines_;
            log_lines_        = last_log_lines_;
            import_logs       = import_log_lines_;
            import_log_lines_ = last_import_log_lines_;

            log_lines_semaphore_.Release();

            if (logs.Count > 0)
            {
                DispatchToJS(new JSEvents.LogEvent(logs));
                logs.Clear();
            }

            last_log_lines_        = logs;
            last_import_log_lines_ = import_logs;

            return(game_active ? kFastTimerMilli : kSlowTimerMilli);
        }