Example #1
0
 public static IEnumerable <MapLocation> AccessibleMapLocations(
     AccessRequirement currentAccess,
     MapChange currentMapChanges,
     Dictionary <MapLocation, Tuple <List <MapChange>, AccessRequirement> > fullLocationRequirements)
 {
     return(fullLocationRequirements.Where(x => x.Value.Item1.Any(y => currentMapChanges.HasFlag(y) && currentAccess.HasFlag(x.Value.Item2))).Select(x => x.Key));
 }
    public bool referendum(Nation nation, Nation otherNation, Province prov)
    {
        int discontentLevel = prov.getDiscontentment();
        // Idea: Discontment Level of 12 warrents %50 chance of yes vote
        int yesStrength = discontentLevel * 4;
        int roll        = Random.Range(1, 100);

        if (roll < yesStrength)
        {
            // province votes to leave
            nation.decreasePrestige(2);

            prov.changeProvinceControl(nation, otherNation);
            MapChange        newMapChange = new MapChange(nation.getIndex(), otherNation.getIndex(), prov.getIndex());
            List <MapChange> mapChanges   = State.MapChanges;
            Debug.Log("Adding Map Change");
            mapChanges.Add(newMapChange);
            return(true);
        }
        else
        {
            nation.increasePrestige(1);
            prov.adjustDiscontentment(-1);
            return(false);
        }
    }
Example #3
0
        private void BuildInitialRequirements(IVictoryConditionFlags victoryConditions)
        {
            airShipLocationAccessible = false;

            requirements = AccessRequirement.None;
            if ((bool)victoryConditions.FreeLute)
            {
                requirements |= AccessRequirement.Lute;
            }

            changes = MapChange.None;
            if (victoryConditions.IsBridgeFree ?? false)
            {
                changes |= MapChange.Bridge;
            }
            if (victoryConditions.IsShipFree ?? false)
            {
                changes |= MapChange.Ship;
                SetShipDock(255);
            }
            if (victoryConditions.IsAirshipFree ?? false)
            {
                changes |= MapChange.Airship;
                airShipLocationAccessible = true;
            }
            if (victoryConditions.IsCanalFree ?? false)
            {
                changes |= MapChange.Canal;
            }
            if (victoryConditions.IsCanoeFree ?? false)
            {
                changes |= MapChange.Canoe;
            }
        }
Example #4
0
 internal static void StartTravelingHook(MapChange __instance)
 {
     if (!Enabled.Value || Instance == null)
     {
         return;
     }
     __instance.SafeProc(
         i => i.scenario.SafeProc(
             s => s.currentHeroine.SafeProc(h => Instance.TravelingStart(h))));
 }
Example #5
0
        /**
         * <summary>
         * Stores a change for later use
         * </summary>
         */
        public void AddChange(int x, int y, string woName, int type)
        {
            MapChange change = new MapChange();

            change.x      = x;
            change.y      = y;
            change.type   = type;
            change.woName = woName;
            changes.Add(change);
        }
Example #6
0
        public void AddChange(int x, int y, bool occupy)
        {
            MapChange change = new MapChange();

            change.x        = x;
            change.y        = y;
            change.type     = OCCUPIED;
            change.occupied = occupy;
            changes.Add(change);
        }
Example #7
0
        public void TestMapChange(string mapName)
        {
            var map      = Map.Parse(mapName);
            var expected = new MapChange(map).Compile();

            using var ns = PacketTestUtilities.CreateTestNetState();
            ns.SendMapChange(map);

            var result = ns.SendPipe.Reader.TryRead();

            AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
        }
Example #8
0
        public void TestMapChange()
        {
            var data = new MapChange(Map.Felucca).Compile();

            Span <byte> expectedData = stackalloc byte[]
            {
                0xBF,       // Packet ID
                0x00, 0x06, // Length
                0x00, 0x08, // Sub-packet
                0x00        // Felucca
            };

            AssertThat.Equal(data, expectedData);
        }
    }
Example #9
0
 public static MapChange Serdes(int i, MapChange u, AssetMapping mapping, ISerializer s)
 {
     if (s == null)
     {
         throw new ArgumentNullException(nameof(s));
     }
     u ??= new MapChange();
     s.Begin();
     u.X          = s.UInt8(nameof(X), u.X);
     u.Y          = s.UInt8(nameof(Y), u.Y);
     u.ChangeType = s.EnumU8(nameof(ChangeType), u.ChangeType);
     u.Unk3       = s.EnumU8(nameof(Unk3), u.Unk3);
     u.Value      = s.UInt16(nameof(Value), u.Value);
     u.MapId      = MapId.SerdesU16(nameof(MapId), u.MapId, mapping, s);
     s.End();
     return(u);
 }
Example #10
0
        public void AddChange(int x, int y, WorldObject wo, bool mobile)
        {
            MapChange change = new MapChange();

            change.x    = x;
            change.y    = y;
            change.type = mobile ? MOBILE : WO;
            if (wo != null)
            {
                change.woName = wo.Owner.Name;
            }
            else
            {
                change.woName = string.Empty;
            }
            changes.Add(change);
        }
            internal static void StartTravelingHook(MapChange __instance)
            {
                try
                {
                    if (!Enabled.Value || Instance == null)
                    {
                        return;
                    }
                    __instance.SafeProc(
                        i => i.scenario.SafeProc(
                            s => s.currentHeroine.SafeProc(Instance.TravelingStart)));
                }

                catch (Exception err)
                {
                    Logger.LogException(err, nameof(StartTravelingHook));
                }
            }
Example #12
0
 public override void WriteSyncData(OutgoingMessage writer)
 {
     writer.Write(changes.Count);
     for (int i = 0; i < changes.Count; i++)
     {
         MapChange change = changes[i];
         writer.Write(change.type);
         writer.Write(change.x);
         writer.Write(change.y);
         if (change.type == OCCUPIED)
         {
             writer.Write(change.occupied);
         }
         else
         {
             writer.Write(change.woName);
         }
     }
     changes.Clear();
 }
Example #13
0
 public EnMapChange(MapChange mc)
 {
     Position = new EnPoint(mc.Position);
     Value    = EnMapData.BuildTile(mc.Value).ToString();
 }
    public void endWar(War war, Nation attacker, Nation defender)
    {
        Debug.Log("End war");
        warPanel.SetActive(false);
        App           app         = UnityEngine.Object.FindObjectOfType <App>();
        int           playerIndex = app.GetHumanIndex();
        Nation        human       = State.getNations()[playerIndex];
        Province      prov        = State.getProvince(0);
        EventRegister eventLogic  = State.eventRegister;
        DecisionEvent newEvent    = new DecisionEvent();

        if (war.ProvIndex != -1)
        {
            prov = State.getProvince(war.ProvIndex);
        }

        if (war.AttackerForces == 0 || war.AttackerMorale == 0)
        {
            Debug.Log("Attack fails");
            // Attack fails and defender wins
            attacker.decreasePrestige(2);
            defender.increasePrestige(2);
            attacker.landForces.Morale -= 10;
            defender.landForces.Morale += 10;
            int payment = (int)(attacker.getGold() / 3);
            PlayerPayer.payAnotherPlayer(attacker, defender, payment);

            if (war.AttackerIndex == human.getIndex())
            {
                eventLogic.initializeFailedInvasionEvent(newEvent, currentEvent, war);
            }
            else
            {
                eventLogic.initializeSucessfulDefenseEvent(newEvent, currentEvent, war);
            }
            currentEvent = newEvent;
            showDecisionPanel(human);
        }

        else if (war.DefenderMorale == 0 || war.DefenderForces == 0)
        {
            // Attack succeeds
            Debug.Log("Attack succeeds");
            attacker.increasePrestige(2);
            defender.decreasePrestige(2);
            attacker.landForces.Morale += 10;
            defender.landForces.Morale -= 10;
            if (war.ProvIndex > -1)
            {
                prov.changeProvinceControl(defender, attacker);
                MapChange        newMapChange = new MapChange(defender.getIndex(), attacker.getIndex(), prov.getIndex());
                List <MapChange> mapChanges   = State.MapChanges;
                mapChanges.Add(newMapChange);
            }
            else
            {
                int payment = (int)(defender.getGold() / 3);
                PlayerPayer.payAnotherPlayer(defender, attacker, payment);
            }

            if (war.AttackerIndex == human.getIndex())
            {
                eventLogic.initializeSucessfulInvasionEvent(newEvent, currentEvent, war);
                currentEvent = newEvent;
                showDecisionPanel(human);
            }
            else
            {
                eventLogic.initializeFailedDefenseEvent(newEvent, currentEvent, war);
                currentEvent = newEvent;
                showDecisionPanel(human);
            }
        }
    }
 /**
  * Initiates a MapChooser map vote
  *
  * Note: If no input array is specified mapchooser will use its internal list. This includes
  * any nominations and excluded maps (as per mapchoosers convars).
  *
  * @param when          MapChange consant of when the resulting mapchange should occur.
  * @param inputarray    ADT array list of maps to add to the vote.
  */
 public static void InitiateMapChooserVote(MapChange when, ArrayList inputarray = null)
 {
     throw new NotImplementedException();
 }
Example #16
0
        public void Process(byte[] packet, Account a)
        {
            try
            {
                switch (packet[0])
                {
                case 0x80:
                    ServerList serverList = new ServerList();
                    serverList.Build();
                    a.NetworkStream.Write(serverList.Data, 0, serverList.PacketSize);
                    break;

                case 0xA0:

                    if (a.TcpClient.Client.LocalEndPoint != null)
                    {
                        IPAddress     addr          = ((IPEndPoint)a.TcpClient.Client.LocalEndPoint).Address;
                        Int16         port          = Int16.Parse(((IPEndPoint)a.TcpClient.Client.LocalEndPoint).Port.ToString());
                        ServerConnect serverConnect = new ServerConnect(addr, port, a.AccountID)
                        {
                            GameServerIp = IPAddress.Parse(((IPEndPoint)a.TcpClient.Client.RemoteEndPoint).Address.ToString())
                        };
                        serverConnect.Build();
                        a.NetworkStream.Write(serverConnect.Data, 0, serverConnect.PacketSize);
                    }
                    break;

                case 0x91:
                    a.LoadChars();
                    CharacterList characterList = new CharacterList(a.CharList);

                    characterList.Build();

                    a.NetworkStream.Write(characterList.Data, 0, characterList.PacketSize);
                    break;

                case 0x5D:
                    ClientVersion clientVersion = new ClientVersion();
                    clientVersion.Build();
                    clientVersion.Compress();
                    clientVersion.Send(a.NetworkStream);
                    break;

                case 0xBD:

                    UOPackets.ServerPackets.LoginConfirm loginConfirm = new UOPackets.ServerPackets.LoginConfirm();
                    loginConfirm.Body         = 400;
                    loginConfirm.Direction131 = Direction13.North;
                    loginConfirm.X            = 2520;
                    loginConfirm.Y            = 521;
                    loginConfirm.Z            = 0;
                    loginConfirm.MapHeight    = 4096;
                    loginConfirm.MapWidth     = 7168;
                    loginConfirm.Serial       = 2420;
                    loginConfirm.Build();
                    loginConfirm.Compress();

                    loginConfirm.Send(a.NetworkStream);

                    MapChange mapChange = new MapChange();
                    mapChange.MapId = Map102.felucca;
                    mapChange.Build();
                    mapChange.Compress();

                    mapChange.Send(a.NetworkStream);

                    MapPatches mapPatches = new MapPatches();
                    mapPatches.MapsCount = 4;
                    mapPatches.Build();
                    mapPatches.Compress();

                    mapPatches.Send(a.NetworkStream);

                    SeasonChange seasonChange = new SeasonChange();
                    seasonChange.Season750    = Season75.summer;
                    seasonChange.PlayMusic761 = PlayMusic76.yes;
                    seasonChange.Build();
                    seasonChange.Compress();

                    seasonChange.Send(a.NetworkStream);

                    Int16             feat = 0x00;
                    SupportedFeatures supportedFeatures = new SupportedFeatures();
                    feat  = (Int16)Flags73.enablethirddownfeatures;
                    feat += (Int16)Flags73.enableT2Afeatureschatbuttonregions;
                    feat += (Int16)Flags73.enableMLfeatureselvenracespellsskills;
                    feat += (Int16)Flags73.enableAOSfeaturesskillsspellsmapfightbook;
                    feat += (Int16)Flags73.enablerenaissancefeatures;
                    feat += (Int16)Flags73.enableLBRfeaturesskillsmap;
                    supportedFeatures.Flags730 = feat;
                    supportedFeatures.Build();
                    supportedFeatures.Compress();

                    supportedFeatures.Send(a.NetworkStream);

                    MobileUpdate mobileUpdate = new MobileUpdate();
                    mobileUpdate.Direction163 = Direction16.North;
                    mobileUpdate.Flags151     = Flags15.WarMode;
                    mobileUpdate.Hue          = 33770;
                    mobileUpdate.X            = 2520;
                    mobileUpdate.Y            = 521;
                    mobileUpdate.Z            = 0;
                    mobileUpdate.Serial       = 2420;
                    mobileUpdate.Body         = 400;
                    mobileUpdate.Build();
                    mobileUpdate.Compress();

                    mobileUpdate.Send(a.NetworkStream);
                    mobileUpdate.Send(a.NetworkStream);

                    GlobalLight globalLight = new GlobalLight();
                    globalLight.LightLevel240 = LightLevel24.Bright;
                    globalLight.Build();
                    globalLight.Compress();

                    globalLight.Send(a.NetworkStream);

                    Infravision infraVision = new Infravision();
                    infraVision.Active = 0x00;
                    infraVision.Serial = 2420;
                    infraVision.Build();
                    infraVision.Compress();

                    infraVision.Send(a.NetworkStream);

                    mobileUpdate.Send(a.NetworkStream);

                    //TODO: Pegar tudo do BD
                    MobileIncoming mobileIncoming = new MobileIncoming();
                    mobileIncoming.Body         = 400;
                    mobileIncoming.Direction490 = (Direction49)((short)(Direction49.Running) + (short)(Direction49.Up));
                    mobileIncoming.Flags501     = Flags50.Hidden;
                    mobileIncoming.Notoriety512 = Notoriety51.Canbeattacked;
                    mobileIncoming.Serial       = 2420;
                    mobileIncoming.X            = 2520;
                    mobileIncoming.Y            = 521;
                    mobileIncoming.Z            = 0;
                    mobileIncoming.Hue          = 0x83ea;
                    mobileIncoming.Items3.Add(new Item()
                    {
                        ItemSerial = 0x40000380, ItemID = 0x0e7c, ItemLayer = ItemLayer8.Bank, ItemHue = 0x00
                    });
                    mobileIncoming.Items3.Add(new Item()
                    {
                        ItemSerial = 0x7fffd62f, ItemID = 0xa03b, ItemLayer = ItemLayer8.Hair, ItemHue = 0x044e
                    });
                    mobileIncoming.Items3.Add(new Item()
                    {
                        ItemSerial = 0x66666666, ItemID = 0xa03b, ItemLayer = ItemLayer8.Hair, ItemHue = 0x044e
                    });
                    mobileIncoming.Items3.Add(new Item()
                    {
                        ItemSerial = 0x40000223, ItemID = 0xe75,
                        ItemLayer  = ItemLayer8.Backpack, ItemHue = 0x00
                    });
                    mobileIncoming.Build();
                    mobileIncoming.Compress();

                    mobileIncoming.Send(a.NetworkStream);

                    MobileStatus mobileStatus = new MobileStatus();
                    mobileStatus.Serial              = 2420;
                    mobileStatus.Name                = "lokis                         ".ToCharArray();
                    mobileStatus.HitPoints           = 0x50;
                    mobileStatus.MaximumHitPoints    = 0x50;
                    mobileStatus.AllowNameChange50   = AllowNameChange5.no;
                    mobileStatus.SupportedFeatures61 = SupportedFeatures6.MLattributes;
                    mobileStatus.Gender              = 0x00;
                    mobileStatus.Strength            = 0x3c;
                    mobileStatus.Dexterity           = 0x0a;
                    mobileStatus.Intelligence        = 0x0a;
                    mobileStatus.Stamina             = 0x0a;
                    mobileStatus.MaximumStamina      = 0x0a;
                    mobileStatus.Mana                = 0x0a;
                    mobileStatus.MaximumMana         = 0x0a;
                    mobileStatus.Gold                = 0;
                    mobileStatus.ArmorRating         = 0;
                    mobileStatus.Weight              = 0x0e;
                    mobileStatus.MaximumWeight       = 0x0136;
                    mobileStatus.Race72              = Race7.Human;
                    mobileStatus.StatCap             = 0xe1;
                    mobileStatus.Followers           = 0;
                    mobileStatus.MaximumFollowers    = 5;
                    mobileStatus.FireResistance      = 0;
                    mobileStatus.ColdResistance      = 0;
                    mobileStatus.PoisonResistance    = 0;
                    mobileStatus.EnergyResistance    = 0;
                    mobileStatus.Luck                = 0;
                    mobileStatus.MinimumWeaponDamage = 1;
                    mobileStatus.MaximumWeaponDamage = 5;
                    mobileStatus.TithingPoints       = 0;
                    mobileStatus.Build();
                    mobileStatus.Compress();

                    mobileStatus.Send(a.NetworkStream);

                    WarMode warMode = new WarMode();
                    warMode.Warmode = 0x00;
                    warMode.Build();
                    warMode.Compress();

                    warMode.Send(a.NetworkStream);

                    OPLInfo oplInfo2 = new OPLInfo();
                    oplInfo2.Serial = 2420;
                    oplInfo2.Hash   = 0x400f9705;
                    oplInfo2.Build();
                    oplInfo2.Compress();
                    oplInfo2.Send(a.NetworkStream);


                    //mobileIncoming.Send(a.TcpClient);

                    OPLInfo oplInfo = new OPLInfo();
                    //oplInfo.Serial = 2420;
                    oplInfo.Serial = 0x40013082;
                    //oplInfo.Hash = 0x4301baee;
                    oplInfo.Hash = 0x400f9705;
                    oplInfo.Build();
                    oplInfo.Compress();

                    oplInfo.Send(a.NetworkStream);
                    oplInfo2.Send(a.NetworkStream);

                    supportedFeatures.Send(a.NetworkStream);
                    mobileUpdate.Send(a.NetworkStream);
                    mobileStatus.Send(a.NetworkStream);
                    warMode.Send(a.NetworkStream);
                    mobileIncoming.Send(a.NetworkStream);

                    LoginConfirmed loginConfirmed = new LoginConfirmed();
                    loginConfirmed.Build();
                    loginConfirmed.Compress();

                    loginConfirmed.Send(a.NetworkStream);

                    GameTime gameTime = new GameTime();
                    gameTime.Hour   = Convert.ToByte(DateTime.Now.Hour);
                    gameTime.Minute = Convert.ToByte(DateTime.Now.Minute);
                    gameTime.Second = Convert.ToByte(DateTime.Now.Second);
                    gameTime.Build();
                    gameTime.Compress();

                    gameTime.Send(a.NetworkStream);

                    seasonChange.Send(a.NetworkStream);

                    mapChange.Send(a.NetworkStream);

                    DisplayPaperdoll displayPaperdoll = new DisplayPaperdoll();
                    displayPaperdoll.Flags550 = Flags55.CanLift;
                    displayPaperdoll.Serial   = 2420;
                    displayPaperdoll.Text     = "LoKiS, Apprentice smith";
                    displayPaperdoll.Build();
                    displayPaperdoll.Compress();

                    displayPaperdoll.Send(a.NetworkStream);

                    break;

                case 0x34:

                    SkillsUpdate skillsUpdate = new SkillsUpdate();
                    skillsUpdate.ListType220 = ListType22.capped;

                    Random rand = new Random();
                    for (int i = 0; i < 55; i++)
                    {
                        rand = new Random(new Random().Next() * rand.Next() * DateTime.Now.Millisecond);
                        Int16 skillBaseValue   = (short)rand.Next(1, 500);
                        Int16 skillCappedValue = (short)rand.Next(501, 1000);
                        Int16 skillValue       = (short)rand.Next(skillBaseValue, skillCappedValue);

                        //skillsUpdate.Skills.Add(new UOPackets.Skill() { SkillID = (SkillName)i+1, LockStatus = 0x00, SkillBaseValue = skillBaseValue, SkillCappedValue = skillCappedValue, SkillValue = skillValue });
                    }

                    skillsUpdate.Build();
                    skillsUpdate.Compress();
                    skillsUpdate.Send(a.NetworkStream);

                    break;

                case 0x02:
                    MovementAccepted movAccepted = new MovementAccepted();

                    movAccepted.Sequence = packet[2];
                    movAccepted.Status   = 0x03;
                    movAccepted.Build();
                    movAccepted.Compress();

                    movAccepted.Send(a.NetworkStream);

                    break;

                case 0x06:
                    //Ask the server if we can use an object (double click).
                    //5 bytes
                    //from client
                    //byte	ID (06)
                    //dword	Item Serial

                    UOPackets.ClientPackets.UseRequest useRequest = new UOPackets.ClientPackets.UseRequest();



                    //useRequest.

                    break;
                }
            }
            catch (Exception ex)
            {
            }
        }
Example #17
0
        public bool IsAccessible(AccessRequirement req, MapChange chg)
        {
            SCBitFlags v2req = SCBitFlags.None;

            if (req.HasFlag(AccessRequirement.Key))
            {
                v2req |= SCBitFlags.Key;
            }
            if (req.HasFlag(AccessRequirement.Rod))
            {
                v2req |= SCBitFlags.Rod;
            }
            if (req.HasFlag(AccessRequirement.Oxyale))
            {
                v2req |= SCBitFlags.Oxyale;
            }
            if (req.HasFlag(AccessRequirement.Cube))
            {
                v2req |= SCBitFlags.Cube;
            }
            if (req.HasFlag(AccessRequirement.Lute))
            {
                v2req |= SCBitFlags.Lute;
            }
            if (req.HasFlag(AccessRequirement.Crown))
            {
                v2req |= SCBitFlags.Crown;
            }
            if (req.HasFlag(AccessRequirement.Ruby))
            {
                v2req |= SCBitFlags.Ruby;
            }
            if (req.HasFlag(AccessRequirement.BlackOrb))
            {
                v2req |= SCBitFlags.Orbs;
            }
            if (req.HasFlag(AccessRequirement.Tnt))
            {
                v2req |= SCBitFlags.Tnt;
            }

            if (chg.HasFlag(MapChange.Chime))
            {
                v2req |= SCBitFlags.Chime;
            }
            if (chg.HasFlag(MapChange.Canoe))
            {
                v2req |= SCBitFlags.Canoe;
            }
            if (chg.HasFlag(MapChange.Airship))
            {
                v2req |= SCBitFlags.Floater;
            }

            foreach (var flag in this)
            {
                if (v2req.IsSupersetOf(flag))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #18
0
        private void ProcessItem(Item item, byte dungeonIndex)
        {
            switch (item)
            {
            case Item.Lute:
                requirements |= AccessRequirement.Lute;
                break;

            case Item.Crown:
                requirements |= AccessRequirement.Crown;
                break;

            case Item.Crystal:
                requirements |= AccessRequirement.Crystal;
                break;

            case Item.Herb:
                requirements |= AccessRequirement.Herb;
                break;

            case Item.Key:
                requirements |= AccessRequirement.Key;
                break;

            case Item.Tnt:
                requirements |= AccessRequirement.Tnt;
                break;

            case Item.Adamant:
                requirements |= AccessRequirement.Adamant;
                break;

            case Item.Slab:
                requirements |= AccessRequirement.Slab;
                break;

            case Item.Ruby:
                requirements |= AccessRequirement.Ruby;
                changes      |= MapChange.TitanFed;
                break;

            case Item.Rod:
                requirements |= AccessRequirement.Rod;
                break;

            case Item.Floater:
                changes |= MapChange.Airship;
                break;

            case Item.Chime:
                changes |= MapChange.Chime;
                break;

            case Item.Cube:
                requirements |= AccessRequirement.Cube;
                break;

            case Item.Bottle:
                requirements |= AccessRequirement.Bottle;
                break;

            case Item.Oxyale:
                requirements |= AccessRequirement.Oxyale;
                break;

            case Item.Ship:
                changes |= MapChange.Ship;
                SetShipDock(dungeonIndex);
                break;

            case Item.Bridge:
                changes |= MapChange.Bridge;
                break;

            case Item.Canal:
                changes |= MapChange.Canal;
                break;

            case Item.Canoe:
                changes |= MapChange.Canoe;
                break;
            }
        }
Example #19
0
 public List <MapLocation> AccessibleMapLocations(AccessRequirement currentAccess, MapChange currentMapChanges, Dictionary <MapLocation, Tuple <List <MapChange>, AccessRequirement> > fullLocationRequirements)
 {
     throw new NotSupportedException("not needed?");
 }
 private void Start()
 {
     score = GameObject.Find("Score").GetComponent <Score>();
     mc    = GameObject.Find("MapChanger").GetComponent <MapChange>();
 }
 private void Start()
 {
     mc = GameObject.Find("MapChanger").GetComponent <MapChange>();
 }
        public void Process(byte[] packet, Account a)
        {
            //a.TcpClient.NoDelay = true;
            //a.TcpClient.Client.DontFragment = true;
            //a.TcpClient.Client.NoDelay = false;
            //a.TcpClient.Client.SendBufferSize = 74;
            //a.TcpClient.LingerState = new LingerOption(false, 0);
            //a.TcpClient.SendTimeout = 0;
            //a.TcpClient.Client.SendTimeout = 0;
            //a.TcpClient.Client.LingerState = new LingerOption(false, 0);
            try
            {
                switch (packet[0])
                {
                case 0x80:
                    ServerList serverList = new ServerList();
                    serverList.Build();
                    //serverList.Send(a.TcpClient);
                    a.NetworkStream.Write(serverList.Data, 0, serverList.PacketSize);
                    break;

                case 0xA0:
                    if (a.TcpClient.Client.LocalEndPoint != null)
                    {
                        IPAddress     addr          = ((IPEndPoint)a.TcpClient.Client.LocalEndPoint).Address;
                        Int16         port          = Int16.Parse(((IPEndPoint)a.TcpClient.Client.LocalEndPoint).Port.ToString());
                        ServerConnect serverConnect = new ServerConnect(addr, port, a.AccountID)
                        {
                            GameServerIp =
                                IPAddress.Parse(
                                    ((IPEndPoint)a.TcpClient.Client.RemoteEndPoint).Address.ToString())
                        };
                        serverConnect.Build();
                        a.NetworkStream.Write(serverConnect.Data, 0, serverConnect.PacketSize);
                    }
                    break;

                case 0x91:
                    a.LoadChars();
                    CharacterList characterList = new CharacterList(a.CharList);

                    characterList.Build();

                    a.NetworkStream.Write(characterList.Data, 0, characterList.PacketSize);
                    break;

                case 0x5D:
                    ClientVersion clientVersion = new ClientVersion();
                    clientVersion.Build();
                    clientVersion.Compress();
                    clientVersion.Send(a.NetworkStream);
                    break;



                case 0xBD:

                    UOPackets.ServerPackets.LoginConfirm loginConfirm = new UOPackets.ServerPackets.LoginConfirm();
                    loginConfirm.Body         = 400;
                    loginConfirm.Direction131 = Direction13.North;
                    loginConfirm.X            = 2520;
                    loginConfirm.Y            = 521;
                    loginConfirm.Z            = 0;
                    loginConfirm.MapHeight    = 4096;
                    loginConfirm.MapWidth     = 7168;
                    loginConfirm.Serial       = 2420;
                    loginConfirm.Build();
                    loginConfirm.Compress();

                    loginConfirm.Send(a.NetworkStream);


                    MapChange mapChange = new MapChange();
                    mapChange.MapId = Map102.felucca;
                    mapChange.Build();
                    mapChange.Compress();

                    mapChange.Send(a.NetworkStream);


                    MapPatches mapPatches = new MapPatches();
                    mapPatches.MapsCount = 4;
                    mapPatches.Build();
                    mapPatches.Compress();

                    mapPatches.Send(a.NetworkStream);


                    SeasonChange seasonChange = new SeasonChange();
                    seasonChange.Season750    = Season75.summer;
                    seasonChange.PlayMusic761 = PlayMusic76.yes;
                    seasonChange.Build();
                    seasonChange.Compress();

                    seasonChange.Send(a.NetworkStream);


                    Int16             feat = 0x00;
                    SupportedFeatures supportedFeatures = new SupportedFeatures();
                    feat  = (Int16)Flags73.enablethirddownfeatures;
                    feat += (Int16)Flags73.enableT2Afeatureschatbuttonregions;
                    feat += (Int16)Flags73.enableMLfeatureselvenracespellsskills;
                    feat += (Int16)Flags73.enableAOSfeaturesskillsspellsmapfightbook;
                    feat += (Int16)Flags73.enablerenaissancefeatures;
                    feat += (Int16)Flags73.enableLBRfeaturesskillsmap;
                    supportedFeatures.Flags730 = feat;
                    supportedFeatures.Build();
                    supportedFeatures.Compress();

                    supportedFeatures.Send(a.NetworkStream);


                    MobileUpdate mobileUpdate = new MobileUpdate();
                    mobileUpdate.Direction163 = Direction16.North;
                    mobileUpdate.Flags151     = Flags15.WarMode;
                    mobileUpdate.Hue          = 33770;
                    mobileUpdate.X            = 2520;
                    mobileUpdate.Y            = 521;
                    mobileUpdate.Z            = 0;
                    mobileUpdate.Serial       = 2420;
                    mobileUpdate.Body         = 400;
                    mobileUpdate.Build();
                    mobileUpdate.Compress();

                    mobileUpdate.Send(a.NetworkStream);
                    mobileUpdate.Send(a.NetworkStream);


                    GlobalLight globalLight = new GlobalLight();
                    globalLight.LightLevel240 = LightLevel24.Bright;
                    globalLight.Build();
                    globalLight.Compress();

                    globalLight.Send(a.NetworkStream);


                    Infravision infraVision = new Infravision();
                    infraVision.Active = 0x00;
                    infraVision.Serial = 2420;
                    infraVision.Build();
                    infraVision.Compress();

                    infraVision.Send(a.NetworkStream);


                    mobileUpdate.Send(a.NetworkStream);



                    //TODO: Pegar tudo do BD
                    MobileIncoming mobileIncoming = new MobileIncoming();
                    mobileIncoming.Body         = 400;
                    mobileIncoming.Direction490 = (Direction49)((short)(Direction49.Running) + (short)(Direction49.Up));
                    mobileIncoming.Flags501     = Flags50.Hidden;
                    mobileIncoming.Notoriety512 = Notoriety51.Canbeattacked;
                    mobileIncoming.Serial       = 2420;
                    mobileIncoming.X            = 2520;
                    mobileIncoming.Y            = 521;
                    mobileIncoming.Z            = 0;
                    mobileIncoming.Hue          = 0x83ea;
                    mobileIncoming.Items3.Add(new Items()
                    {
                        ItemSerial = 0x40000380, ItemID = 0x0e7c, ItemLayer = ItemLayer8.Bank, ItemHue = 0x00
                    });
                    mobileIncoming.Items3.Add(new Items()
                    {
                        ItemSerial = 0x7fffd62f, ItemID = 0xa03b, ItemLayer = ItemLayer8.Hair, ItemHue = 0x044e
                    });
                    mobileIncoming.Items3.Add(new Items()
                    {
                        ItemSerial = 0x66666666, ItemID = 0xa03b, ItemLayer = ItemLayer8.Hair, ItemHue = 0x044e
                    });
                    mobileIncoming.Build();
                    mobileIncoming.Compress();

                    mobileIncoming.Send(a.NetworkStream);


                    MobileStatus mobileStatus = new MobileStatus();
                    mobileStatus.Serial              = 2420;
                    mobileStatus.Name                = "lokis                         ".ToCharArray();
                    mobileStatus.HitPoints           = 0x50;
                    mobileStatus.MaximumHitPoints    = 0x50;
                    mobileStatus.AllowNameChange50   = AllowNameChange5.no;
                    mobileStatus.SupportedFeatures61 = SupportedFeatures6.MLattributes;
                    mobileStatus.Gender              = 0x00;
                    mobileStatus.Strength            = 0x3c;
                    mobileStatus.Dexterity           = 0x0a;
                    mobileStatus.Intelligence        = 0x0a;
                    mobileStatus.Stamina             = 0x0a;
                    mobileStatus.MaximumStamina      = 0x0a;
                    mobileStatus.Mana                = 0x0a;
                    mobileStatus.MaximumMana         = 0x0a;
                    mobileStatus.Gold                = 0;
                    mobileStatus.ArmorRating         = 0;
                    mobileStatus.Weight              = 0x0e;
                    mobileStatus.MaximumWeight       = 0x0136;
                    mobileStatus.Race72              = Race7.Human;
                    mobileStatus.StatCap             = 0xe1;
                    mobileStatus.Followers           = 0;
                    mobileStatus.MaximumFollowers    = 5;
                    mobileStatus.FireResistance      = 0;
                    mobileStatus.ColdResistance      = 0;
                    mobileStatus.PoisonResistance    = 0;
                    mobileStatus.EnergyResistance    = 0;
                    mobileStatus.Luck                = 0;
                    mobileStatus.MinimumWeaponDamage = 1;
                    mobileStatus.MaximumWeaponDamage = 5;
                    mobileStatus.TithingPoints       = 0;
                    mobileStatus.Build();
                    mobileStatus.Compress();

                    mobileStatus.Send(a.NetworkStream);


                    WarMode warMode = new WarMode();
                    warMode.Warmode = 0x00;
                    warMode.Build();
                    warMode.Compress();

                    warMode.Send(a.NetworkStream);


                    OPLInfo oplInfo2 = new OPLInfo();
                    oplInfo2.Serial = 2420;
                    oplInfo2.Hash   = 0x400f9705;
                    oplInfo2.Build();
                    oplInfo2.Compress();
                    oplInfo2.Send(a.NetworkStream);


                    //mobileIncoming.Send(a.TcpClient);

                    OPLInfo oplInfo = new OPLInfo();
                    //oplInfo.Serial = 2420;
                    oplInfo.Serial = 0x40013082;
                    //oplInfo.Hash = 0x4301baee;
                    oplInfo.Hash = 0x400f9705;
                    oplInfo.Build();
                    oplInfo.Compress();

                    oplInfo.Send(a.NetworkStream);
                    oplInfo2.Send(a.NetworkStream);


                    supportedFeatures.Send(a.NetworkStream);
                    mobileUpdate.Send(a.NetworkStream);
                    mobileStatus.Send(a.NetworkStream);
                    warMode.Send(a.NetworkStream);
                    mobileIncoming.Send(a.NetworkStream);

                    //oplInfo2.Send(a.NetworkStream);

                    LoginConfirmed loginConfirmed = new LoginConfirmed();
                    loginConfirmed.Build();
                    loginConfirmed.Compress();

                    loginConfirmed.Send(a.NetworkStream);


                    GameTime gameTime = new GameTime();
                    gameTime.Hour   = Convert.ToByte(DateTime.Now.Hour);
                    gameTime.Minute = Convert.ToByte(DateTime.Now.Minute);
                    gameTime.Second = Convert.ToByte(DateTime.Now.Second);
                    gameTime.Build();
                    gameTime.Compress();

                    gameTime.Send(a.NetworkStream);


                    seasonChange.Send(a.NetworkStream);


                    mapChange.Send(a.NetworkStream);


                    /*globalLight.Send(a.NetworkStream);
                     * infraVision.Send(a.NetworkStream);
                     * gameTime.Send(a.NetworkStream);
                     *
                     * DisplayPaperdoll displayPaperdoll = new DisplayPaperdoll();
                     * displayPaperdoll.Flags550 = Flags55.CanLift;
                     * displayPaperdoll.Serial = 400;
                     * displayPaperdoll.Text = "lokis, Apprentice smith                                    ".ToCharArray();
                     * displayPaperdoll.Build();
                     * displayPaperdoll.Compress();
                     *
                     *
                     * displayPaperdoll.Send(a.NetworkStream);
                     *
                     * oplInfo.Send(a.NetworkStream);
                     *
                     * //break;
                     *
                     * //case 0xD6:
                     * globalLight = new GlobalLight();
                     * globalLight.LightLevel240 = LightLevel24.Bright;
                     * globalLight.Build();
                     * globalLight.Compress();
                     *
                     * infraVision = new Infravision();
                     * infraVision.Active = 0x00;
                     * infraVision.Serial = 2420;
                     * infraVision.Build();
                     * infraVision.Compress();
                     *
                     * mapChange = new MapChange();
                     * mapChange.MapId = Map102.felucca;
                     * mapChange.Build();
                     * mapChange.Compress();
                     *
                     * mapChange.Send(a.NetworkStream);
                     * infraVision.Send(a.NetworkStream);
                     * globalLight.Send(a.NetworkStream);
                     *
                     *
                     * mobileUpdate.Send(a.NetworkStream);
                     * mobileStatus.Send(a.NetworkStream);
                     *
                     * warMode.Send(a.NetworkStream);
                     * mobileIncoming.Send(a.NetworkStream);
                     * oplInfo.Send(a.NetworkStream);
                     *
                     * SkillsUpdate skillsUpdate = new SkillsUpdate();
                     * skillsUpdate.ListType220 = ListType22.capped;
                     *
                     *
                     * for (int i = 0; i < 55; i++)
                     * {
                     *  Random rand = new Random();
                     *  Int16 skillBaseValue = 100;
                     *  Int16 skillCappedValue = 100;
                     *  Int16 skillValue = 100;
                     *
                     *  skillsUpdate.Skills.Add(new Skills() { SkillID = (SkillName)i, LockStatus = 0x00, SkillBaseValue = skillBaseValue, SkillCappedValue = skillCappedValue, SkillValue = skillValue });
                     * }
                     *
                     * skillsUpdate.Build();
                     * skillsUpdate.Compress();
                     * skillsUpdate.Send(a.NetworkStream);*/


                    DisplayPaperdoll displayPaperdoll = new DisplayPaperdoll();
                    displayPaperdoll.Flags550 = Flags55.CanLift;
                    displayPaperdoll.Serial   = 2420;
                    displayPaperdoll.Text     = "LoKiS, Apprentice smith";
                    displayPaperdoll.Build();
                    displayPaperdoll.Compress();


                    displayPaperdoll.Send(a.NetworkStream);

                    break;

                case 0x34:

                    SkillsUpdate skillsUpdate = new SkillsUpdate();
                    skillsUpdate.ListType220 = ListType22.capped;


                    for (int i = 0; i < 55; i++)
                    {
                        Random rand             = new Random();
                        Int16  skillBaseValue   = 100;
                        Int16  skillCappedValue = 100;
                        Int16  skillValue       = 100;

                        skillsUpdate.Skills.Add(new Skills()
                        {
                            SkillID = (SkillName)i + 1, LockStatus = 0x00, SkillBaseValue = skillBaseValue, SkillCappedValue = skillCappedValue, SkillValue = skillValue
                        });
                    }

                    skillsUpdate.Build();
                    skillsUpdate.Compress();
                    skillsUpdate.Send(a.NetworkStream);

                    break;

                case 0x02:
                    MovementAccepted movAccepted = new MovementAccepted();

                    movAccepted.Sequence = packet[2];
                    movAccepted.Status   = 0x03;
                    movAccepted.Build();
                    movAccepted.Compress();

                    movAccepted.Send(a.NetworkStream);



                    /*AsciiMessage asciiMessage = new AsciiMessage();
                     * asciiMessage.Serial = 0xFFFFFFFF;
                     * asciiMessage.Hue = 0x3b2;
                     * asciiMessage.Graphic = 0xFFFF;
                     * asciiMessage.Font = 3;
                     * asciiMessage.Name = "PELUPELUPELUPELUPELUPELUPELUU".ToCharArray();
                     * asciiMessage.TextMessage = "PELUDO";
                     * asciiMessage.MessageType140 = MessageType14.System;
                     * asciiMessage.Build();
                     * asciiMessage.Compress();
                     * asciiMessage.Send(a.NetworkStream);*/



                    /* Pacotes
                     * 5D - PlayCharacter CS
                     * BD - ClientVersion SC
                     * BD - ClientVersion CS
                     * 1B - LoginConfirm SC
                     * 34 - MobileQuery CS
                     * BD - ClientVersion CS
                     * BF.05 - ScreenSize CS
                     * BF.0B - ClientLanguage CS
                     * BF.0F - ClientInfo CS
                     * BF.08 - MapChange SC
                     * BF.18 - MapPatches SC
                     * BC - SeasonChange SC
                     * B9 - SupportedFeatures SC
                     * 20 - MobileUpdate SC
                     * 20 - MobileUpdate SC
                     * 4F - GlobalBright SC
                     * 4E - Infravision SC
                     * 20 - MobileUpdate SC
                     * 78 - MobileIncoming SC
                     * 11 - MobileStatus SC
                     * 72 - Warmode SC
                     * 78 - MobileIncoming SC
                     * DC - OPLInfo SC
                     * B9 - SupportedFeatures SC
                     * 20 - MobileUpdate SC
                     * 11 - MobileStatus SC
                     * 72 - Warmode SC
                     * 78 - MobileIncoming SC
                     * 55 - LoginConfirmed SC
                     * 06 - DoubleClick CS
                     * 5B - GameTime SC
                     * BC - SeasonChange SC
                     * BF - MapChange SC
                     * 4F - GlobalBright SC
                     * 4E - Infravision SC
                     * AE - UnicodeMessage SC
                     * D6 - BatchQueryProperties CS
                     * 1C - AsciiMessage SC
                     * 3A - SkillsUpdate SC
                     * 88 - DisplayPaperdoll SC
                     * DC - OPLInfo SC
                     * D6 - BatchQueryProperties CS
                     * BF.24 - Unknown CS
                     */

                    /* Ordem da DoLogin():
                     * LoginConfirm -
                     * MapChange -
                     * SeasonChange -
                     * SupportedFeatures -
                     * MobileUpdate-
                     * MobileUpdate-
                     * MobileUpdate-
                     * MobileIncoming
                     * MobileStatus -
                     * SetWarMode -
                     * SupportedFeatures -
                     * MobileUpdate -
                     * MobileStatus -
                     * MobileIncoming
                     * LoginComplete -
                     * CurrentTime
                     * SeasonChange -
                     * MapChange-
                     * LoginEventArgs
                     */
                    /*
                     * LoginConfirm loginConfirm = new LoginConfirm( a.CharList[0] );
                     * loginConfirm.Build();
                     * loginConfirm.Send(a.TcpClient);
                     *
                     *
                     * UOPackets.ServerPackets.LoginConfirm loginConfirm = new UOPackets.ServerPackets.LoginConfirm();
                     * loginConfirm.Body = 0;
                     * loginConfirm.Direction131 = Direction13.North;
                     * loginConfirm.X = 2520;
                     * loginConfirm.Y = 521;
                     * loginConfirm.Z = 0;
                     *
                     *
                     *
                     * //a.TcpClient.Client.Send(loginConfirm.Data, 0, loginConfirm.PacketSize, SocketFlags.None);
                     *
                     * CharacterMapChange characterMapChange = new CharacterMapChange(0x01);
                     * characterMapChange.Build();
                     * Subcommands subCommands = new Subcommands(characterMapChange);
                     * subCommands.Build();
                     *
                     * characterMapChange.Send(a.TcpClient);
                     * //a.TcpClient.Client.Send(characterMapChange.Data, 0, characterMapChange.PacketSize, SocketFlags.None);
                     *
                     * UOPackets.ServerPackets.SeasonChange seasonChange = new UOPackets.ServerPackets.SeasonChange();
                     * seasonChange.PlayMusic761 = PlayMusic76.yes;
                     * seasonChange.Season750 = Season75.summer;
                     * seasonChange.Build();
                     * seasonChange.Compress();
                     * seasonChange.Send(a.TcpClient);
                     *
                     * UOPackets.ServerPackets.SupportedFeatures supportedFeatures = new UOPackets.ServerPackets.SupportedFeatures();
                     * supportedFeatures.Flags730 = Flags73.enableAOSfeaturesskillsspellsmapfightbook;
                     * supportedFeatures.Build();
                     * supportedFeatures.Compress();
                     * supportedFeatures.Send(a.TcpClient);
                     *
                     * UOPackets.ServerPackets.MobileUpdate mobileUpdate = new UOPackets.ServerPackets.MobileUpdate();
                     * mobileUpdate.Body = 0;
                     * mobileUpdate.Direction163 = Direction16.North;
                     * mobileUpdate.Flags151 = 0;
                     * mobileUpdate.Hue = 0;
                     * mobileUpdate.X = 2520;
                     * mobileUpdate.Y = 521;
                     * mobileUpdate.Z = 0;
                     * mobileUpdate.Serial = 0;
                     * mobileUpdate.Build();
                     * mobileUpdate.Compress();
                     * mobileUpdate.Send(a.TcpClient);
                     * mobileUpdate.Send(a.TcpClient);
                     * mobileUpdate.Send(a.TcpClient);
                     *
                     *
                     * UOPackets.ServerPackets.MobileStatus mobileStatus = new UOPackets.ServerPackets.MobileStatus();
                     * mobileStatus.Serial = 0;
                     * mobileStatus.Name = "teste".ToCharArray();
                     * mobileStatus.HitPoints = 100;
                     * mobileStatus.MaximumHitPoints = 100;
                     * mobileStatus.AllowNameChange50 = AllowNameChange5.yes;
                     * mobileStatus.SupportedFeatures61 = SupportedFeatures6.AOSattributes;
                     * mobileStatus.Gender = 0;
                     * mobileStatus.Strength = 100;
                     * mobileStatus.Dexterity = 100;
                     * mobileStatus.Intelligence = 100;
                     * mobileStatus.Stamina = 100;
                     * mobileStatus.MaximumStamina = 100;
                     * mobileStatus.Mana = 100;
                     * mobileStatus.MaximumMana = 100;
                     * mobileStatus.Gold = 500;
                     * mobileStatus.ArmorRating = 100;
                     * mobileStatus.Weight = 50;
                     * mobileStatus.StatCap = 300;
                     * mobileStatus.Followers = 0;
                     * mobileStatus.MaximumFollowers = 6;
                     * mobileStatus.FireResistance = 0;
                     * mobileStatus.ColdResistance = 0;
                     * mobileStatus.PoisonResistance = 0;
                     * mobileStatus.EnergyResistance = 0;
                     * mobileStatus.Luck = 0;
                     * mobileStatus.MinimumWeaponDamage = 0;
                     * mobileStatus.MaximumWeaponDamage = 100;
                     * mobileStatus.TithingPoints = 0;
                     * mobileStatus.Build();
                     * mobileStatus.Compress();
                     * mobileStatus.Send(a.TcpClient);
                     *
                     *
                     * UOPackets.ServerPackets.WarMode setWarMode = new UOPackets.ServerPackets.WarMode();
                     * setWarMode.Warmode = 0;
                     * setWarMode.Build();
                     * setWarMode.Compress();
                     * setWarMode.Send(a.TcpClient);
                     *
                     *
                     * supportedFeatures.Send(a.TcpClient);
                     * mobileUpdate.Send(a.TcpClient);
                     * mobileStatus.Send(a.TcpClient);
                     *
                     *
                     * UOPackets.LoginComplete loginComplete = new LoginComplete();
                     * loginComplete.Build();
                     * loginComplete.Send(a.TcpClient);
                     *
                     *
                     * seasonChange.Send(a.TcpClient);
                     * UOPackets.ServerPackets.MapChange mapChange = new UOPackets.ServerPackets.MapChange();
                     * mapChange.Build();
                     * mapChange.Send(a.TcpClient);
                     *
                     *
                     *
                     *
                     * //ClientFeatures clientFeatures = new ClientFeatures();
                     * //clientFeatures.Build();
                     *
                     * //a.TcpClient.Client.Send(clientFeatures.m_Data, 0, clientFeatures.PacketSize, SocketFlags.None);
                     * /*
                     * CharacterWarmode characterWarmode = new CharacterWarmode();
                     * characterWarmode.Build();
                     *
                     * a.TcpClient.Client.Send( characterWarmode.Data, 0, characterWarmode.PacketSize, SocketFlags.None );
                     *
                     *
                     *
                     * a.TcpClient.Client.Send(subCommands.Data, 0, subCommands.PacketSize, SocketFlags.None);
                     *
                     *
                     * CharacterSync characterSync = new CharacterSync(a.CharList[0]);
                     * characterSync.Build();
                     *
                     * a.TcpClient.Client.Send(characterSync.Data, 0, characterSync.PacketSize, SocketFlags.None);
                     *
                     * LoginComplete loginComplete = new LoginComplete();
                     * loginComplete.Build();
                     *
                     * a.TcpClient.Client.Send(loginComplete.Data, 0, loginComplete.PacketSize, SocketFlags.None);
                     *
                     */
                    break;
                }
            }
            catch (Exception ex)
            {
            }
        }