Exemplo n.º 1
0
        public List <Actor> Actors = new List <Actor>(); //list to keep all actors which are currentl in this zone.

        public Zone(uint regionId, uint zoneId, byte locationNameId, byte musicSetId, int classNameId = -1, bool isMountAllowed = false, ZoneType zoneType = ZoneType.Default, string mapName = null)
        {
            Id           = zoneId;
            Name         = Encoding.ASCII.GetBytes("_areaMaster");
            RegionId     = regionId;
            MapName      = mapName;
            PlaceName    = ZoneList.LocationName[locationNameId];
            ClassName    = classNameId < 0 ? null : "ZoneMaster" + ZoneList.ClassName[classNameId];
            MusicSet     = MusicSet.Get(musicSetId);
            MountAllowed = isMountAllowed;

            LuaParameters = new LuaParameters
            {
                ActorName = "_areaMaster" + "@0" + LuaParameters.SwapEndian(zoneId).ToString("X").Substring(0, 4),
                ClassName = ClassName,
                ClassCode = 0x30400000
            };

            LuaParameters.Add("/Area/Zone/" + ClassName);
            LuaParameters.Add(false);
            LuaParameters.Add(true);
            LuaParameters.Add(MapName);
            LuaParameters.Add("");
            LuaParameters.Add(-1);
            LuaParameters.Add(Convert.ToByte(isMountAllowed));

            for (int i = 7; i > -1; i--)
            {
                LuaParameters.Add(((byte)zoneType & (1 << i)) != 0);
            }
        }
Exemplo n.º 2
0
        public virtual void Prepare(ushort actorIndex = 0)
        {
            Zone zone = World.Instance.Zones.Find(x => x.Id == Position.ZoneId);

            Id = 4 << 28 | zone.Id << 19 | (uint)actorIndex; // 0x46700087;

            LuaParameters = new LuaParameters
            {
                ActorName = GenerateActorName(actorIndex),
                ClassName = ClassName,
                ClassCode = ClassCode
            };

            LuaParameters.Add(ClassPath + ClassName);
            LuaParameters.Add(false);
            LuaParameters.Add(false);
            LuaParameters.Add(false);
            LuaParameters.Add(false);
            LuaParameters.Add(false);
            LuaParameters.Add(ClassId);
            LuaParameters.Add(false);
            LuaParameters.Add(false);
            LuaParameters.Add((uint)0);
            LuaParameters.Add((uint)0);
            //LuaParameters.Add("TEST");
        }
        public override void Prepare(ushort actorIndex = 0)
        {
            //TODO:remove this
            string debugNameNumber = "01";

            if (Id == 0x66080000)
            {
                debugNameNumber = "00";
            }

            LuaParameters = new LuaParameters
            {
                ActorName = "openingDire_ocn0Btl02_" + debugNameNumber + "@0" + LuaParameters.SwapEndian(User.Instance.Character.Position.ZoneId).ToString("X").Substring(0, 4),
                ClassName = ClassName,
                ClassCode = ClassCode
            };

            LuaParameters.Add("/Director/" + ClassName);
            LuaParameters.Add(false);
            LuaParameters.Add(false);
            LuaParameters.Add(false);
            LuaParameters.Add(false);
            LuaParameters.Add(false);

            EventConditions = new List <EventCondition>();
            EventConditions.Add(new EventCondition {
                Opcode = ServerOpcode.NoticeEvent, EventName = "noticeEvent", Priority = 0x0e
            });
            EventConditions.Add(new EventCondition {
                Opcode = ServerOpcode.NoticeEvent, EventName = "noticeRequest", IsDisabled = 0x01
            });
            EventConditions.Add(new EventCondition {
                Opcode = ServerOpcode.NoticeEvent, EventName = "reqForChild", IsDisabled = 0x01
            });
        }
Exemplo n.º 4
0
        public virtual void LoadActorScript(Socket sender)
        {
            byte[] data = new byte[0x108];

            Buffer.BlockCopy(BitConverter.GetBytes(LuaParameters.ClassCode), 0, data, 0, sizeof(uint));
            Buffer.BlockCopy(Encoding.ASCII.GetBytes(LuaParameters.ActorName), 0, data, 0x04, LuaParameters.ActorName.Length);
            Buffer.BlockCopy(Encoding.ASCII.GetBytes(LuaParameters.ClassName), 0, data, 0x24, LuaParameters.ClassName.Length);

            LuaParameters.WriteParameters(ref data, LuaParameters);

            SendPacket(sender, ServerOpcode.LoadClassScript, data);
        }
Exemplo n.º 5
0
 public override void Prepare(ushort actorIndex = 0)
 {
     LuaParameters = new LuaParameters {
         ActorName = "worldMaster", ClassName = "WorldMaster", ClassCode = 0x30400000
     };
     LuaParameters.Add("/World/WorldMaster_event");
     LuaParameters.Add(false);
     LuaParameters.Add(false);
     LuaParameters.Add(false);
     LuaParameters.Add(false);
     LuaParameters.Add(false);
     LuaParameters.Add(null);
 }
        public void StartClientOrderEvent(Socket sender)
        {
            byte[] data        = new byte[0x70];
            uint   characterId = User.Instance.Character.Id;

            Buffer.BlockCopy(BitConverter.GetBytes(characterId), 0, data, 0, 4);
            Buffer.BlockCopy(BitConverter.GetBytes(Id), 0, data, 0x04, 4);
            Buffer.BlockCopy(BitConverter.GetBytes(0x75dc1705), 0, data, 0x08, 4); //the last byte is the event type (05). the other bytes are unknown.
            Buffer.BlockCopy(BitConverter.GetBytes(ClassCode), 0, data, 0x0c, 4);

            LuaParameters parameters = new LuaParameters();

            parameters.Add(Encoding.ASCII.GetBytes("noticeEvent"));
            parameters.Add(true);

            LuaParameters.WriteParameters(ref data, parameters, 0x10);
            SendPacket(sender, ServerOpcode.StartEvent, data, sourceId: characterId);
        }
Exemplo n.º 7
0
        public override void Prepare(ushort actorIndex = 0)
        {
            LuaParameters = new LuaParameters
            {
                ActorName = "debug",
                ClassName = "Debug",
                ClassCode = 0x30400000
            };

            LuaParameters.Add("/System/Debug.prog");
            LuaParameters.Add(false);
            LuaParameters.Add(false);
            LuaParameters.Add(false);
            LuaParameters.Add(false);
            LuaParameters.Add(true);
            LuaParameters.Add((uint)0xc51f); //???
            LuaParameters.Add(true);
            LuaParameters.Add(true);
        }
        private void NoticeEvent(Socket sender, ClientEventRequest eventRequest)
        {
            byte[] data = new byte[0x298];
            Buffer.BlockCopy(BitConverter.GetBytes(User.Instance.Character.Id), 0, data, 0, 4);
            Buffer.BlockCopy(BitConverter.GetBytes(Id), 0, data, 0x04, 4);
            data[0x08] = eventRequest.Code;

            LuaParameters parameters = new LuaParameters();

            parameters.Add(Encoding.ASCII.GetBytes("noticeEvent"));
            parameters.Add(Encoding.ASCII.GetBytes("delegateEvent"));
            parameters.Add((Command)eventRequest.CallerId);
            parameters.Add(unchecked ((Command)0xa0f1adb1));
            parameters.Add("processTtrNomal001withHQ");
            parameters.Add(null);
            parameters.Add(null);
            parameters.Add(null);

            LuaParameters.WriteParameters(ref data, parameters, 0x09);
            SendPacket(sender, ServerOpcode.StartEventRequest, data);
        }
Exemplo n.º 9
0
        public virtual void RequestResponsePacket(Socket sender, Command command, List <object> additionalparameters)
        {
            byte[] data          = new byte[0x90];
            uint   parsedCommand = (0xA0F00000 | (ushort)command);

            Buffer.BlockCopy(BitConverter.GetBytes(User.Instance.Character.Id), 0, data, 0, 4);
            Buffer.BlockCopy(BitConverter.GetBytes(parsedCommand), 0, data, 0x04, 4);

            LuaParameters parameters = new LuaParameters();

            parameters.Add(Encoding.ASCII.GetBytes("commandContent"));
            parameters.Add(Encoding.ASCII.GetBytes("delegateCommand"));
            parameters.Add((Command)parsedCommand);

            foreach (object i in additionalparameters)
            {
                parameters.Add(i);
            }

            LuaParameters.WriteParameters(ref data, parameters, 0x08);
            Buffer.BlockCopy(BitConverter.GetBytes(0x0000004053b47a00), 0, data, 0x88, 8);

            SendPacket(sender, ServerOpcode.StartEventRequest, data);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Writes all parameters in the instanced obj parameter list to the packet to be sent.
        /// </summary>
        /// <param name="data">A pointer to the packet buffer. </param>
        /// <param name="luaParameters">The list of parameters to be witten.</param>
        public static void WriteParameters(ref byte[] data, LuaParameters luaParameters, byte startIndex = 0x44)
        {
            //Write Params - using binary writer bc sizes, types, #items can vary.
            using (MemoryStream stream = new MemoryStream(data))
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Seek(startIndex, SeekOrigin.Begin); //points to the right position

                    foreach (var parameter in luaParameters.List)
                    {
                        if (parameter.Key == 0x01)
                        {
                            writer.Write((byte)0);
                        }
                        else if (parameter.Key != 0x98 && parameter.Key != 0x99)
                        {
                            writer.Write(parameter.Key);
                        }

                        switch (parameter.Key)
                        {
                        case 0:
                            writer.Write(SwapEndian((int)parameter.Value));
                            break;

                        case 0x01:
                            writer.Write(SwapEndian((uint)parameter.Value));
                            break;

                        case 0x02:
                            string str = (string)parameter.Value;
                            writer.Write(Encoding.ASCII.GetBytes(str), 0, Encoding.ASCII.GetByteCount(str));
                            writer.Write((byte)0);
                            break;

                        case 0x05:     //null
                            break;

                        case 0x06:
                            writer.Write(SwapEndian((uint)(Command)parameter.Value));
                            break;

                        case 0x07:
                            break;

                        case 0x09:
                            break;

                        case 0x0c:
                            writer.Write((byte)parameter.Value);
                            break;

                        case 0x1b:
                            break;

                        case 0x98:
                            writer.Write((byte)0x06);
                            writer.Write((uint)(DirectorCode)parameter.Value);
                            break;

                        case 0x99:
                            byte[] strArr = new byte[0x20];
                            byte[] value  = (byte[])parameter.Value;
                            Buffer.BlockCopy(value, 0, strArr, 0, value.Length);
                            writer.Write(strArr, 0, strArr.Length);
                            break;

                        case 0x0f:
                            continue;
                        }
                    }

                    writer.Write((byte)0x0f);
                }
            }
        }
        public void Setup(byte[] data)
        {
            //Character ID
            Id    = NewId();
            IsNew = true;

            ClassPath = "/Chara/Player/Player_work";

            State.Type = MainStateType.Player;

            //speeds
            Speeds.Walking = ActorSpeed.Walking; //Walking speed
            Speeds.Running = ActorSpeed.Running; // 0x40a00000;  //Running speed
            Speeds.Active  = ActorSpeed.Active;  //Acive

            //prepare packet info for decoding
            byte[] info = new byte[0x90];
            Buffer.BlockCopy(data, 0x30, info, 0, info.Length);
            string tmp = Encoding.ASCII.GetString(info).Trim(new[] { '\0' }).Replace('-', '+').Replace('_', '/');

            //decoded packet info
            data = Convert.FromBase64String(tmp);

            //General
            Appearance.Size  = data[0x09];
            Appearance.Voice = data[0x26];
            SkinColor        = (ushort)(data[0x23] >> 8 | data[0x22]);

            //Head
            HairStyle          = (ushort)(data[0x0b] >> 8 | data[0x0a]);
            HairColor          = (ushort)(data[0x1d] >> 8 | data[0x1c]);
            HairHighlightColor = data[0x0c];
            HairVariation      = data[0x0d];
            EyeColor           = (ushort)(data[0x25] >> 8 | data[0x24]);

            //Face
            Face = new Face
            {
                Characteristics      = data[0x0f],
                CharacteristicsColor = data[0x10],
                Type     = data[0x0e],
                Ears     = data[0x1b],
                Mouth    = data[0x1a],
                Features = data[0x19],
                Nose     = data[0x18],
                EyeShape = data[0x17],
                IrisSize = data[0x16],
                EyeBrows = data[0x15],
                Unknown  = 0
            };

            //Background
            Guardian    = data[0x27];
            BirthMonth  = data[0x28];
            BirthDay    = data[0x29];
            InitialTown = data[0x48];
            Tribe       = data[0x08];
            GetBaseModel(Tribe);
            GeneralParameters = GeneralParameter.Get(Tribe);

            //Starting class
            CurrentClassId                 = data[0x2a];
            Jobs[CurrentClassId].Level     = 1;    //having a class level > 0 makes it active.
            Jobs[CurrentClassId].IsCurrent = true; //current class the player will start with.
            LoadInitialEquipment();

            Position = Position.GetInitialPosition(InitialTown);

            //Lua
            LuaParameters = new LuaParameters
            {
                ActorName = string.Format("_pc{0:00000000}", Id),
                ClassName = "Player"
            };

            //Actor Lua parameters
            LuaParameters.Add(ClassPath);
            LuaParameters.Add(true);
            LuaParameters.Add(false);
            LuaParameters.Add(false);
            LuaParameters.Add(true);
            LuaParameters.Add(0);
            LuaParameters.Add(false);

            //add timer placeholders
            for (int i = 0; i < 20; i++)
            {
                LuaParameters.Add(0);
            }

            LuaParameters.Add(true);

            PartyGroup    = new PartyGroup();
            RetainerGroup = new RetainerGroup();
        }
        public override void Spawn(Socket sender, ushort spawnType = 0x01, ushort isZoning = 0, int changingZone = 0, ushort actorIndex = 0)
        {
            PacketQueue = null;

            //For packet creation
            TargetId = Id;

            //SendGroupPackets(sender);



            //opening director goes here
            CreateActor(sender, 0x08);
            CommandSequence(sender);
            SetSpeeds(sender);
            SetPosition(sender, spawnType, isZoning, changingZone);
            SetAppearance(sender);
            SetName(sender, -1, Name); //-1 = it's a custom name.
            SendUnknown(sender);
            SetMainState(sender);
            SetSubState(sender);
            SetAllStatus(sender);
            SetIcon(sender);
            SetIsZoning(sender, false);// (isZoning == 0 ? false : true));


            /* Grand Company packets here */
            //SendPacket(sender, ServerOpcode.SetGrandCompany, new byte[] { 0x02, 0x7F, 0x0B, 0x7F, 0x00, 0x00, 0x00, 0x00 });

            //Set Player title
            // SendPacket(sender, ServerOpcode.SetTitle, new byte[] { 0x8f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });

            //current job
            //SendCurrentJob(sender);

            SetSpecialEventWork(sender);


            /* Chocobo mounts packet here */
            //SendPacket(sender, ServerOpcode.SetChocoboName, new byte[] { 0x42, 0x6f, 0x6b, 0x6f, 0x00, 0x00, 0x00, 0x00 });
            //SendPacket(sender, ServerOpcode.SetHasChocobo, new byte[] { 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
            //SendPacket(sender, ServerOpcode.SetHasGobbue, new byte[] { 0x1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });

            GetAchievementPoints(sender);
            GetAchievementsLatest(sender);
            GetAchievementsCompleted(sender);

            ///* Set mounts packets */



            //Actor Lua parameters
            LuaParameters = new LuaParameters
            {
                ActorName = string.Format("_pc{0:00000000}", Id),
                ClassName = "Player",
                ClassCode = 0x30400000
            };
            LuaParameters.Add("/Chara/Player/Player_work");

            //notpening
            //LuaParameters.Add(true);
            //LuaParameters.Add(false);
            //LuaParameters.Add(false);

            //opning
            LuaParameters.Add(false);
            LuaParameters.Add(false);
            LuaParameters.Add(true);
            LuaParameters.Add(DirectorCode.Opening);

            LuaParameters.Add(true);
            LuaParameters.Add(0);
            LuaParameters.Add(false);

            //add timer placeholders
            for (int i = 0; i < 20; i++)
            {
                LuaParameters.Add(0);
            }

            LuaParameters.Add(true);
            LoadActorScript(sender);

            //Send inventory
            Inventory.SendInventories(sender);

            //Send properties
            GetWork(sender);

            //UpdateExp(sender);
        }