private void PopulateGladiatorList(int numberToBuild)
        {
            var factory = new GladiatorFactory();

            for (var i = 0; i < numberToBuild; i++)
            {
                Combatants.Add(factory.BuildGladiator());
            }
        }
 private void FateOf(Gladiator gladiator)
 {
     if (gladiator.IsAlive())
     {
         Combatants.Add(gladiator);
     }
     else
     {
         Graveyard.Add(gladiator);
     }
 }
Пример #3
0
        private void Load()
        {
            Combatants.Clear();
            var eventArgs = new SaveEventArgs();

            LoadTriggered?.Invoke(this, eventArgs);
            foreach (Combatant combatant in eventArgs.SaveData)
            {
                Combatants.Add(combatant);
            }
            Combatants.Sort();
        }
 private void AddCombatant(DD4ECombatant combatant)
 {
     if (Combatants.Any(c => c.Name.Equals(combatant.Name) && c.IsPlayer == false))
     {
         int id = Combatants.Count(c => c.Name.Equals(combatant.Name) && c.IsPlayer == false);
         combatant.ID = id;
     }
     else
     {
         if (Combatants.Any(c => c.Name.Equals(combatant.Name)))
         {
             MessageBox.Show("You cannot add the same player character twice.", "Warning");
             return;
         }
     }
     Combatants.Add(combatant);
 }
Пример #5
0
        private void Add()
        {
            int initiative;

            if (!int.TryParse(Initiative, out initiative))
            {
                throw new Exception($"{Initiative} is not a valid value.");
            }

            bool initiativeTied = Combatants.Any(c => c.Initiative == initiative);
            var  newCombatant   = new Combatant(Name, initiative, Combatants.Count == 0);

            Combatants.Add(newCombatant);
            if (initiativeTied && InitiativeTied != null)
            {
                newCombatant.TieBreaker = Combatants.Max(c => c.TieBreaker) + 1;
                InitiativeTied?.Invoke(this, new TieInitiativeEventArgs(Combatants.Where(c => c.Initiative == initiative)));
            }
            Combatants.Sort();
            Name       = null;
            Initiative = null;
        }
Пример #6
0
        public Task AddCombatantAsync(GridEntity entity, ICombatant combatant, string factionKey = "")
        {
            List <IEntity> faction;

            if (entity.IsPlayer())
            {
                Dead.RemoveAll(d => d.Id == entity.Id);
            }

            // some default behaviour will be to find the faction with the matching isPlayer
            if (string.IsNullOrEmpty(factionKey))
            {
                var testFaction = Factions.FirstOrDefault(o => o.Value.Any(e => e.IsPlayer() == entity.IsPlayer()));
                if (testFaction.Value == null)
                {
                    testFaction = Factions.FirstOrDefault(o => o.Value.Count == 0);
                }
                if (testFaction.Value == null)
                {
                    testFaction = Factions.FirstOrDefault();
                }

                faction = testFaction.Value;
            }
            else
            {
                faction = Factions[factionKey];
            }
            if (faction != null)
            {
                faction.Add(entity);
            }

            Combatants.Add(entity, combatant);


            entity.Died += Combatant_Death;
            return(Task.CompletedTask);
        }
Пример #7
0
        /// <summary>
        /// Resolves the battle.
        /// </summary>
        public void Resolve()
        {
            // update memories
            foreach (var sobj in StarSystem.SpaceObjects.Where(x => !x.IsMemory).ToArray())
            {
                sobj.UpdateEmpireMemories();
            }

            Current.Add(this);
            var reloads = new SafeDictionary <Component, double>();
            var seekers = new Dictionary <Seeker, int>();

            // let all combatants scan each other
            foreach (var c in Combatants)
            {
                c.UpdateEmpireMemories();
            }

            for (int i = 0; i < Mod.Current.Settings.SpaceCombatTurns; i++)
            {
                LogRound(i + 1);
                // TODO - real 2D combat mechanics
                foreach (var seeker in seekers.Keys.ToArray())
                {
                    seekers[seeker]--;
                    if (seekers[seeker] <= 0)
                    {
                        seekers.Remove(seeker);
                        var minrng = seeker.LaunchingComponent.Template.WeaponMinRange;
                        var maxrng = seeker.LaunchingComponent.Template.WeaponMinRange;
                        var range  = Dice.Next(maxrng - minrng) + minrng;                        // just pick a random valid range
                        var shot   = new Shot(seeker.LaunchingCombatant, seeker.LaunchingComponent, seeker.Target, range);
                        Log.Add(seeker.CreateLogMessage(seeker + " detonates! " + seeker.Target + " takes " + shot.FullDamage + " damage."));
                        seeker.Target.TakeDamage(new Hit(shot, seeker.Target, seeker.Damage.Value));
                    }
                    else
                    {
                        Log.Add(seeker.CreateLogMessage(seeker + " moves closer to " + seeker.Target + " (" + seekers[seeker] + " rounds to detonation)"));
                    }
                }
                foreach (var launcher in Combatants.ToArray())
                {
                    // find launchable units
                    var unitsToLaunch = new List <SpaceVehicle>();
                    if (launcher is Planet)
                    {
                        // planets can launch infinite units per turn
                        var p = (Planet)launcher;
                        if (p.Cargo != null && p.Cargo.Units != null)
                        {
                            unitsToLaunch.AddRange(p.Cargo.Units.OfType <SpaceVehicle>());
                        }
                    }
                    else if (launcher is ICargoTransferrer)
                    {
                        // ships, etc. can launch units based on abilities
                        var ct = (ICargoTransferrer)launcher;
                        foreach (var vt in Enum.GetValues(typeof(VehicleTypes)).Cast <VehicleTypes>().Distinct())
                        {
                            var rate = ct.GetAbilityValue("Launch/Recover " + vt.ToSpacedString() + "s").ToInt();
                            unitsToLaunch.AddRange(ct.Cargo.Units.Where(u => u.Design.VehicleType == vt).OfType <SpaceVehicle>().Take(rate));
                        }
                    }

                    // launch them temporarily for combat
                    foreach (var unit in unitsToLaunch)
                    {
                        Combatants.Add(unit);
                    }
                }
                foreach (var attacker in Combatants.Shuffle(Dice).Where(sobj => sobj.Weapons.Any()).ToArray())
                {
                    if (!attacker.IsAlive)
                    {
                        continue;
                    }

                    var defenders = Combatants.Where(sobj => attacker.CanTarget(sobj) && sobj.IsAlive);
                    if (!defenders.Any())
                    {
                        continue;                         // no one to shoot at
                    }
                    var defender = defenders.PickRandom(Dice);

                    int dmg = 0;
                    foreach (var weapon in attacker.Weapons.Where(w => w.CanTarget(defender)))
                    {
                        while (reloads[weapon] <= 0)
                        {
                            // fire
                            var winfo = weapon.Template.ComponentTemplate.WeaponInfo;
                            if (winfo is SeekingWeaponInfo)
                            {
                                // launch a seeker
                                var swinfo = (SeekingWeaponInfo)winfo;
                                var seeker = new Seeker(this, attacker.Owner, attacker, weapon, defender);
                                seekers.Add(seeker, 20 / swinfo.SeekerSpeed);
                                LogLaunch(seeker);
                            }
                            else
                            {
                                // direct fire
                                var minrng = weapon.Template.WeaponMinRange;
                                var maxrng = weapon.Template.WeaponMinRange;
                                var range  = Dice.Next(maxrng - minrng) + minrng;                                // just pick a random valid range
                                var shot   = new Shot(attacker, weapon, defender, range);
                                dmg += shot.FullDamage;
                                defender.TakeDamage(new Hit(shot, defender, weapon.Template.GetWeaponDamage(range)));
                            }
                            // TODO - mounts that affect reload rate?
                            reloads[weapon] += weapon.Template.ComponentTemplate.WeaponInfo.ReloadRate;
                        }

                        // reload
                        reloads[weapon] -= 1;
                    }
                    LogSalvo(attacker, defender, dmg);
                }
            }

            // validate fleets since some ships might have died
            foreach (var fleet in Sector.SpaceObjects.OfType <Fleet>())
            {
                fleet.Validate();
            }

            // replenish combatants' shields
            foreach (var combatant in Sector.SpaceObjects.OfType <ICombatant>())
            {
                combatant.ReplenishShields();
            }

            // mark battle complete
            Current.Remove(this);
            Previous.Add(this);

            // update memories
            foreach (var sobj in Combatants.OfType <ISpaceObject>().Where(x => !x.IsMemory).ToArray())
            {
                foreach (var emp in Empires)
                {
                    emp.UpdateMemory(sobj);;
                }
            }
        }
Пример #8
0
        /// <summary>
        /// Resolves the battle.
        /// </summary>
        public void Resolve()
        {
            // update memories
            foreach (var sobj in StarSystem.SpaceObjects.Where(x => !x.IsMemory).ToArray())
            {
                sobj.UpdateEmpireMemories();
            }

            Current.Add(this);

            var reloads   = new SafeDictionary <Component, double>();
            var locations = new SafeDictionary <ICombatant, IntVector2>();

            PlaceCombatants(locations);

            Events = new List <IList <IBattleEvent> >();

            UpdateBounds(0, locations.Values);

            // let all combatants scan each other
            foreach (var c in Combatants)
            {
                c.UpdateEmpireMemories();
            }

            // make a query so we can check who's alive
            var alives = Combatants.Where(q => q.IsAlive);

            for (int i = 0; i < MaxRounds; i++)
            {
                var combatSpeeds = new SafeDictionary <ICombatant, double>();
                var multiplex    = new SafeDictionary <ICombatant, HashSet <ICombatant> >(true);
                foreach (var c in Combatants)
                {
                    combatSpeeds[c] = c.CombatSpeed;
                }

                int GetCombatSpeedThisRound(ICombatant c)
                {
                    return((int)(combatSpeeds[c] + CombatSpeedBuffer[c]));
                }

                Events.Add(new List <IBattleEvent>());

                if (i == 0)
                {
                    // first round, all combatants appear
                    foreach (var c in Combatants)
                    {
                        Events.Last().Add(new CombatantAppearsEvent(this, c, locations[c]));
                    }
                }

                var turnorder = alives.OrderBy(x => x is Seeker ? 1 : 0).ThenBy(x => combatSpeeds[x]).ThenShuffle(Dice).ToArray();

                // phase 0: reload weapons
                foreach (var w in turnorder.SelectMany(q => q.Weapons))
                {
                    reloads[w]--;
                    if (reloads[w] < 0)
                    {
                        reloads[w] = 0;
                    }
                }

                // phase 1: combatants move starting with the slowest (so the faster ships get to react to their moves) - but seekers go last so they get a chance to hit
                foreach (var c in turnorder)
                {
                    var oldpos = locations[c];
                    if (c is Seeker s)
                    {
                        if (locations[s] == null)
                        {
                            continue;                             // HACK - seeker is destroyed but still showing up in turn order
                        }
                        if (locations[s.Target] == null)
                        {
                            s.Hitpoints = 0;                             // seekers self destruct when their target is destroyed
                            Events.Last().Add(new CombatantDestroyedEvent(this, s, locations[s]));
                            continue;
                        }
                        s.DistanceTraveled += Math.Min(GetCombatSpeedThisRound(c), locations[s].DistanceToEightWay(locations[s.Target]));
                        locations[s]        = IntVector2.InterpolateEightWay(locations[s], locations[s.Target], GetCombatSpeedThisRound(c));
                        if (s.DistanceTraveled > s.WeaponInfo.MaxRange)
                        {
                            s.Hitpoints = 0;
                            Events.Last().Add(new CombatantDestroyedEvent(this, s, locations[s]));
                        }
                    }
                    else
                    {
                        // TODO - both pursue target and evade scary enemies at the same time using heatmap
                        // find out how good each target is
                        var targetiness = new SafeDictionary <ICombatant, double>();
                        foreach (var target in alives.Where(x =>
                                                            c.IsHostileTo(x.Owner) &&
                                                            (c.CanTarget(x) || (x is Planet && c is ICargoContainer cc && cc.Cargo.Units.OfType <Troop>().Any()))))
                        {
                            targetiness[target] = 1d / (locations[target] - locations[c]).LengthEightWay;
                        }

                        if (!targetiness.Any())
                        {
                            // evade enemies
                            var heatmap = new HeatMap();
                            foreach (var e in alives.Where(x => x.IsHostileTo(c.Owner) && x.CanTarget(c)))
                            {
                                int threat;
                                if (e.Weapons.Any())
                                {
                                    threat = GetCombatSpeedThisRound(e) + e.Weapons.Where(w => w.CanTarget(c)).Max(w => w.Template.WeaponMaxRange);
                                }
                                else
                                {
                                    threat = 0;
                                }
                                heatmap.AddLinearGradientEightWay(locations[e], threat, threat, -1);
                            }
                            if (c.FillsCombatTile)
                            {
                                // only one ship/base/planet per tile
                                foreach (var tile in heatmap.ToArray())
                                {
                                    if (locations.Any(q => q.Key.FillsCombatTile && q.Value == tile.Key))
                                    {
                                        heatmap.Remove(tile.Key);
                                    }
                                }
                            }
                            if (heatmap.Any())
                            {
                                locations[c] = heatmap.FindMin(locations[c], GetCombatSpeedThisRound(c));
                            }
                        }
                        else
                        {
                            // move to max range that we can inflict max damage on best target
                            var        goodTargets = targetiness.Where(x => !IgnoredTargets[c].Contains(x.Key)).WithMax(x => x.Value);
                            ICombatant bestTarget  = null;
                            if (goodTargets.Any())
                            {
                                bestTarget = goodTargets.First().Key;
                            }
                            if (bestTarget == null)
                            {
                                // try previously ignored targets
                                IgnoredTargets[c].Clear();
                                goodTargets = targetiness.Where(x => !IgnoredTargets[c].Contains(x.Key)).WithMax(x => x.Value);
                                if (goodTargets.Any())
                                {
                                    bestTarget = goodTargets.First().Key;
                                }
                            }
                            if (bestTarget != null)
                            {
gotosAreEvil:
                                var maxdmg = 0;
                                var maxdmgrange = 0;
                                if (c.Weapons.Any())
                                {
                                    for (var range = 0; range < c.Weapons.Max(w => w.Template.WeaponMaxRange); range++)
                                    {
                                        var dmg = c.Weapons.Where(w => w.CanTarget(bestTarget)).Sum(w => w.Template.GetWeaponDamage(range));
                                        if (dmg >= maxdmg)
                                        {
                                            maxdmg      = dmg;
                                            maxdmgrange = range;
                                        }
                                    }
                                }
                                if (c.Weapons.Any(w => w.Template.ComponentTemplate.WeaponInfo.IsSeeker) &&
                                    locations[c].DistanceToEightWay(locations[bestTarget]) > DistancesToTargets[c])
                                {
                                    // adjust desired range due to seeker speed and target speed if retreating
                                    var roundsToClose = c.Weapons.Where(w => w.Template.ComponentTemplate.WeaponInfo.IsSeeker).Max(w =>
                                                                                                                                   (int)Math.Ceiling((double)w.Template.WeaponMaxRange / (double)(w.Template.ComponentTemplate.WeaponInfo as SeekingWeaponInfo).SeekerSpeed));
                                    var distanceAdjustment = (int)Ceiling(combatSpeeds[bestTarget] * roundsToClose);
                                    maxdmgrange -= distanceAdjustment;
                                    if (maxdmgrange < 0)
                                    {
                                        maxdmgrange = 0;
                                    }
                                }
                                var targetPos = locations[bestTarget];
                                var tiles     = new HashSet <IntVector2>();
                                for (var x = targetPos.X - maxdmgrange; x <= targetPos.X + maxdmgrange; x++)
                                {
                                    tiles.Add(new IntVector2(x, targetPos.Y - maxdmgrange));
                                    tiles.Add(new IntVector2(x, targetPos.Y + maxdmgrange));
                                }
                                for (var y = targetPos.Y - maxdmgrange; y <= targetPos.Y + maxdmgrange; y++)
                                {
                                    tiles.Add(new IntVector2(targetPos.X - maxdmgrange, y));
                                    tiles.Add(new IntVector2(targetPos.X + maxdmgrange, y));
                                }
                                if (c.FillsCombatTile)
                                {
                                    foreach (var tile in tiles.ToArray())
                                    {
                                        if (locations.Any(q => q.Key.FillsCombatTile && q.Value == tile))
                                        {
                                            tiles.Remove(tile);
                                        }
                                    }
                                }
                                if (tiles.Any())
                                {
                                    var closest = tiles.WithMin(t => t.DistanceToEightWay(locations[c])).First();
                                    locations[c] = IntVector2.InterpolateEightWay(locations[c], closest, GetCombatSpeedThisRound(c), vec => locations.Values.Contains(vec));
                                    var newdist = locations[c].DistanceToEightWay(locations[bestTarget]);
                                    if (DistancesToTargets.ContainsKey(c) && newdist >= DistancesToTargets[c] && combatSpeeds[c] <= combatSpeeds[bestTarget] && !c.Weapons.Any(w => w.Template.WeaponMaxRange >= newdist))
                                    {
                                        DistancesToTargets.Remove(c);
                                        IgnoredTargets[c].Add(bestTarget);                                         // can't catch it, might as well find a new target
                                        goodTargets = targetiness.Where(x => !IgnoredTargets[c].Contains(x.Key)).WithMax(x => x.Value);
                                        bestTarget  = null;
                                        if (goodTargets.Any())
                                        {
                                            bestTarget = goodTargets.First().Key;
                                        }
                                        if (bestTarget == null)
                                        {
                                            goto gotosAreVeryEvil;
                                        }
                                        goto gotosAreEvil;
                                    }
                                    else
                                    {
                                        DistancesToTargets[c] = newdist;
                                    }
                                }
                            }
                            else
                            {
                                DistancesToTargets.Remove(c);
                            }
                        }
                    }
gotosAreVeryEvil:
                    if (locations[c] != oldpos)
                    {
                        Events.Last().Add(new CombatantMovesEvent(this, c, oldpos, locations[c]));
                    }
                }

                UpdateBounds(i, locations.Values);

                // phase 2: combatants launch units
                foreach (var c in turnorder)
                {
                    // find launchable units
                    var unitsToLaunch = new List <(ICombatant Launcher, SpaceVehicle Launchee)>();
                    if (c is Planet)
                    {
                        // planets can launch infinite units per turn
                        var p = (Planet)c;
                        if (p.Cargo != null && p.Cargo.Units != null)
                        {
                            foreach (var u in p.Cargo.Units.OfType <SpaceVehicle>())
                            {
                                unitsToLaunch.Add((p, u));
                            }
                        }
                    }
                    else if (c is ICargoTransferrer)
                    {
                        // ships, etc. can launch units based on abilities
                        var ct = (ICargoTransferrer)c;
                        foreach (var vt in Enum.GetValues(typeof(VehicleTypes)).Cast <VehicleTypes>().Distinct())
                        {
                            var rate = ct.GetAbilityValue("Launch/Recover " + vt.ToSpacedString() + "s").ToInt();
                            foreach (var u in ct.Cargo.Units.Where(u => u.Design.VehicleType == vt).OfType <SpaceVehicle>().Take(rate))
                            {
                                unitsToLaunch.Add((c, u));
                            }
                        }
                    }

                    // launch them temporarily for combat
                    foreach (var info in unitsToLaunch)
                    {
                        Launchers[info.Launchee] = info.Launcher;
                        if (info.Launcher is ICargoTransferrer ct && info.Launchee is IUnit u)
                        {
                            ct.RemoveUnit(u);
                        }

                        Combatants.Add(info.Item2);
                        StartCombatants[info.Item2.ID] = info.Item2.Copy();
                        for (var ix = 0; ix < info.Item2.Weapons.Count(); ix++)
                        {
                            var w  = info.Item2.Weapons.ElementAt(ix);
                            var wc = StartCombatants[info.Item2.ID].Weapons.ElementAt(ix);
                        }
                        locations[info.Launchee] = new IntVector2(locations[info.Launcher]);
                        Events.Last().Add(new CombatantLaunchedEvent(this, info.Launcher, info.Launchee, locations[info.Launchee]));
                    }
                }

                turnorder = alives.OrderBy(x => x.CombatSpeed).ThenShuffle(Dice).ToArray();

                // phase 3: combatants fire point defense non-warhead weapons starting with the fastest (so the faster ships get to inflict damage first and possibly KO enemies preventing them from firing back)
                foreach (var c in turnorder.Reverse())
                {
                    foreach (var w in c.Weapons.Where(w => w.Template.ComponentTemplate.WeaponInfo.IsPointDefense && !w.Template.ComponentTemplate.WeaponInfo.IsWarhead))
                    {
                        TryFireWeapon(c, w, reloads, locations, multiplex);
                    }
                }

                turnorder = alives.OrderBy(x => x.CombatSpeed).ThenShuffle(Dice).ToArray();

                // phase 4: point defense seekers detonate
                foreach (var s in turnorder.Reverse().OfType <Seeker>().Where(s => s.WeaponInfo.IsPointDefense))
                {
                    CheckSeekerDetonation(s, locations);
                }

                turnorder = alives.OrderBy(x => x.CombatSpeed).ThenShuffle(Dice).ToArray();

                // phase 5: ships fire non-PD non-warhead weapons starting with the fastest (so the faster ships get to inflict damage first and possibly KO enemies preventing them from firing back)
                foreach (var c in turnorder.Reverse())
                {
                    foreach (var w in c.Weapons.Where(w => !w.Template.ComponentTemplate.WeaponInfo.IsPointDefense && !w.Template.ComponentTemplate.WeaponInfo.IsWarhead))
                    {
                        TryFireWeapon(c, w, reloads, locations, multiplex);
                    }
                }

                turnorder = alives.OrderBy(x => x.CombatSpeed).ThenShuffle(Dice).ToArray();

                // phase 6: non-PD seekers detonate
                foreach (var s in turnorder.Reverse().OfType <Seeker>().Where(s => !s.WeaponInfo.IsPointDefense))
                {
                    CheckSeekerDetonation(s, locations);
                }

                turnorder = alives.OrderBy(x => x.CombatSpeed).ThenShuffle(Dice).ToArray();

                // phase 7: ramming! only activates if ship has no other weapons
                foreach (var c in turnorder.Reverse())
                {
                    if (!c.Weapons.Any(w => !w.Template.ComponentTemplate.WeaponInfo.IsWarhead))
                    {
                        // TODO - add damage from ship HP on both sides
                        foreach (var w in c.Weapons.Where(w => w.Template.ComponentTemplate.WeaponInfo.IsWarhead))
                        {
                            TryFireWeapon(c, w, reloads, locations, multiplex);
                        }
                    }
                }

                turnorder = alives.OrderBy(x => x.CombatSpeed).ThenShuffle(Dice).ToArray();

                // TODO - boarding

                // phase 8: drop troops
                foreach (var c in turnorder.Reverse())
                {
                    if (c is ICargoTransferrer cc && cc.AllUnits.OfType <Troop>().Any())
                    {
                        // find enemy planets in the same square
                        var dropTargets = locations.Where(q => q.Key != c && q.Value == locations[c] && q.Key is Planet p && c.IsHostileTo(p.Owner)).Select(q => q.Key).Cast <Planet>();
                        var dropTarget  = dropTargets.PickRandom(Dice);
                        if (dropTarget != null)
                        {
                            var cd = new CargoDelta();
                            cd.UnitTypeTonnage.Add(VehicleTypes.Troop, null);
                            cc.TransferCargo(cd, dropTarget, cc.Owner, true);
                            var groundBattle = new GroundBattle(dropTarget);
                            groundBattle.Resolve();
                        }
                    }
                }

                // clear used combat speed buffer speed
                foreach (var x in Combatants)
                {
                    CombatSpeedBuffer[x] += x.CombatSpeed - Floor(x.CombatSpeed);
                    CombatSpeedBuffer[x] -= Floor(CombatSpeedBuffer[x]);
                }

                UpdateBounds(i, locations.Values);

                bool hostile = false;
                foreach (var a in alives)
                {
                    foreach (var b in alives)
                    {
                        // TODO - check if ships want to ram even if they have no weapons
                        if (a.IsHostileTo(b.Owner) && a.Weapons.Any())
                        {
                            hostile = true;
                            break;
                        }
                    }
                    if (hostile)
                    {
                        break;
                    }
                }
                if (!hostile)
                {
                    break;
                }
            }

            // recover units
            var orphans = new List <IUnit>();

            foreach (var u in Combatants.OfType <IUnit>())
            {
                if (Launchers[u] is ICargoTransferrer cc && cc.CargoStorageFree() >= u.Design.Hull.Size && u.Owner == cc.Owner)
                {
                    cc.Cargo.Units.Add(u);
                }
Пример #9
0
        private void ACTExtension(bool isImport, LogLineEventArgs e)
        {
            string[]    data        = e.logLine.Split('|');
            MessageType messageType = (MessageType)Convert.ToInt32(data[0]);

            switch (messageType)
            {
            case MessageType.LogLine:
                if (Convert.ToInt32(data[2], 16) == 56)
                {
                    ReadFFxivEcho(data[4]);
                }
                break;

            case MessageType.ChangeZone:
                ChangeZoneEvent(data);
                break;

            case MessageType.ChangePrimaryPlayer:
                DetectMyName(data);
                break;

            case MessageType.AddCombatant:
                if (!Combatants.ContainsKey(data[2]))
                {
                    CombatData cd = new CombatData();
                    cd.PlayerID   = Convert.ToUInt32(data[2], 16);
                    cd.PlayerJob  = Convert.ToUInt32(data[4], 16);
                    cd.PlayerName = data[3];
                    cd.MaxHP      = cd.CurrentHP = Convert.ToInt64(data[5], 16);
                    cd.MaxMP      = cd.CurrentMP = Convert.ToInt64(data[6], 16);
                    if (data[8] != "0")
                    {
                        cd.IsPet   = true;
                        cd.OwnerID = Convert.ToUInt32(data[8]);
                    }
                    Combatants.Add(data[2], cd);
                    SendCombatantList();
                }
                break;

            case MessageType.RemoveCombatant:
                if (Combatants.ContainsKey(data[2]))
                {
                    Combatants.Remove(data[2]);
                    SendCombatantList();
                }
                break;

            case MessageType.PartyList:
                UpdatePartyList(data);
                break;

            case MessageType.NetworkStartsCasting:
            case MessageType.NetworkCancelAbility:
            case MessageType.NetworkDoT:
            case MessageType.NetworkDeath:
            case MessageType.NetworkBuff:
            case MessageType.NetworkTargetIcon:
            case MessageType.NetworkRaidMarker:
            case MessageType.NetworkTargetMarker:
            case MessageType.NetworkBuffRemove:
                break;

            case MessageType.NetworkAbility:
            case MessageType.NetworkAOEAbility:
                Ability(messageType, data);
                break;
            }
        }