public void ReadFromPacket(IPacketReader reader) { MobID = reader.ReadInt(); HitAction = reader.ReadByte(); var info = reader.ReadByte(); ForeAction = (byte)(info & 0x7F); IsMobFacingLeft = (info >> 7 & 1) > 0; FrameIdx = reader.ReadByte(); _ = reader.ReadByte(); // v258 & 0x7F | v25 _ = reader.ReadShort(); // dAx[5] _ = reader.ReadShort(); // dAx[4] _ = reader.ReadShort(); // dAx[3] _ = reader.ReadShort(); // dAx[2] Delay = reader.ReadShort(); for (var i = 0; i < Damage.Length; i++) { Damage[i] = reader.ReadInt(); } _ = reader.ReadInt(); // mob crc }
protected override void ReadData(IPacketReader reader) { _position = reader.ReadPoint2D(); _vPosition = reader.ReadPoint2D(); _footholdID = reader.ReadShort(); if (Attribute == MoveFragmentAttribute.FallDown) { _fallStartFootholdID = reader.ReadShort(); } _offset = reader.ReadPoint2D(); base.ReadData(reader); }
public async Task Process(TUser user, IPacketReader packet) { var operation = packet.ReadShort(); if (!_handlers.ContainsKey(operation)) { _logger.LogWarning($"Unhandled {typeof(TStage).Name} packet operation 0x{operation:X} ({Enum.GetName((PacketRecvOperations)operation)})"); return; } var handler = _handlers[operation]; try { if (await handler.Check(user)) { await handler.Handle(user, packet); if (ServerConstants.IsIgnoredLoggingPacket(operation) && !_logger.IsEnabled(LogLevel.Trace)) { return; } _logger.LogDebug($"Handled {typeof(TStage).Name} packet operation 0x{operation:X} ({Enum.GetName((PacketRecvOperations)operation)}) with {packet.Available} available bytes"); } } catch (Exception e) { await user.OnException(e); _logger.LogError(e, $"Caught exception when handling {typeof(TStage).Name} packet operation 0x{operation:X} ({Enum.GetName((PacketRecvOperations)operation)})"); } }
protected override void ReadData(IPacketReader reader) { _position = reader.ReadPoint2D(); _footholdID = reader.ReadShort(); base.ReadData(reader); }
protected override async Task Handle(GameStageUser stageUser, IFieldObjUser user, IPacketReader packet) { _ = packet.ReadInt(); var type = (ItemInventoryType)packet.ReadByte(); var from = packet.ReadShort(); var to = packet.ReadShort(); var number = packet.ReadShort(); if (to == 0) { await user.ModifyInventory(exclRequest : true); // TODO: drops return; } // TODO: checks await user.ModifyInventory(i => i[type].Move(from, to), true); }
public void ReadFromPacket(IPacketReader reader) { _ = reader.ReadByte(); // FieldKey _ = reader.ReadInt(); // dr0 _ = reader.ReadInt(); // dr1 var attackInfo = reader.ReadByte(); DamagePerMob = attackInfo >> 0 & 0xF; MobCount = attackInfo >> 4 & 0xF; _ = reader.ReadInt(); // dr2 _ = reader.ReadInt(); // dr3 SkillID = reader.ReadInt(); _ = reader.ReadBool(); // unk _ = reader.ReadInt(); // dr rand _ = reader.ReadInt(); // crc _ = reader.ReadInt(); // skillLevel crc _ = reader.ReadInt(); // skillLevel crc Keydown = 0; // TODO keydownskill check - int keydown var skillFlags = reader.ReadByte(); IsFinalAfterSlashBlast = (skillFlags & 0x0) > 0; IsShadowPartner = (skillFlags & 8) > 0; IsSerialAttack = (skillFlags & 32) > 0; var actionInfo = reader.ReadShort(); Action = actionInfo & 0x7FFF; IsFacingLeft = (actionInfo >> 15 & 1) > 0; _ = reader.ReadInt(); // action crc? ActionType = reader.ReadByte(); ActionSpeed = reader.ReadByte(); ActionTime = reader.ReadInt(); Phase = reader.ReadInt(); // BattleMage? for (var i = 0; i < MobCount; i++) { Mobs.Add(reader.Read(new ClientAttackMobInfo(DamagePerMob))); } _ = reader.ReadPoint2D(); // unk // TODO grenade readpoint2d }
public override async Task Handle(LoginStageUser user, IPacketReader packet) { var name = packet.ReadString(); var race = packet.ReadInt(); var subJob = packet.ReadShort(); var face = packet.ReadInt(); var hair = packet.ReadInt(); var hairColor = packet.ReadInt(); var skin = packet.ReadInt(); var coat = packet.ReadInt(); var pants = packet.ReadInt(); var shoes = packet.ReadInt(); var weapon = packet.ReadInt(); var gender = packet.ReadByte(); var result = LoginResultCode.Success; var response = new UnstructuredOutgoingPacket(PacketSendOperations.CreateNewCharacterResult); var world = await user.Stage.WorldTemplates.Retrieve((int)user.SelectedWorldID); if (world.BlockCharCreation) { result = LoginResultCode.NotConnectableWorld; } var serverRequest = new DescribeServerByMetadataRequest(); serverRequest.Metadata.Add("Type", Enum.GetName(ServerStageType.Game)); serverRequest.Metadata.Add("WorldID", user.SelectedWorldID.ToString()); serverRequest.Metadata.Add("ChannelID", user.SelectedChannelID.ToString()); var server = (await user.Stage.ServerRegistry.DescribeByMetadata(serverRequest)).Servers.FirstOrDefault(); if (server == null) { result = LoginResultCode.NotConnectableWorld; } response.WriteByte((byte)result); if (result == LoginResultCode.Success) { var character = new Character { AccountWorldID = user.AccountWorld.ID, Name = name, Job = 0, // TODO: race -> job Face = face, Hair = hair + hairColor, Skin = (byte)skin, Gender = gender, FieldID = 310000000, // TODO: start maps FieldPortal = 0, SubJob = 0 // TODO: race -> subjob }; var context = new ModifyMultiInventoryContext(character.Inventories, user.Stage.ItemTemplates); context.Set(BodyPart.Clothes, coat); context.Set(BodyPart.Shoes, shoes); context.Set(BodyPart.Weapon, weapon); if (pants > 0) { context.Set(BodyPart.Pants, pants); } await user.Stage.CharacterRepository.Insert(character); user.Character = character; user.Stage.Logger.LogDebug($"Created new {race} character: {name} (ID: {character.ID})"); response.WriteCharacterStats(character); response.WriteCharacterLook(character); response.WriteBool(false); response.WriteBool(false); } else { response.WriteInt(0); } await user.Dispatch(response); }
protected override async Task Handle( GameStageUser stageUser, IFieldObjUser controller, IFieldObjMob controlled, IPacketReader packet ) { if (controlled.HP <= 0) { return; } var mobCtrlSN = packet.ReadShort(); var v7 = packet.ReadByte(); //v85 = nDistance | 4 * (v184 | 2 * ((unsigned __int8)retaddr | 2 * v72)); [ CONFIRMED ] var oldSplit = (v7 & 0xF0) != 0; //this is a type of CFieldSplit var mobMoveStartResult = (v7 & 0xF) != 0; var curSplit = packet.ReadByte(); var illegalVelocity = packet.ReadInt(); var v8 = packet.ReadByte(); var cheatedRandom = (v8 & 0xF0) != 0; var cheatedCtrlMove = (v8 & 0xF) != 0; var multiTargetForBall = packet.ReadInt(); for (var i = 0; i < multiTargetForBall; i++) { packet.ReadLong(); // int, int } var randTimeForAreaAttack = packet.ReadInt(); for (var i = 0; i < randTimeForAreaAttack; i++) { packet.ReadInt(); } packet.ReadInt(); // HackedCode packet.ReadInt(); // idk packet.ReadInt(); // HackedCodeCrc packet.ReadInt(); // idk var path = packet.Read(new MovePath()); await controlled.Move(path); var response = new UnstructuredOutgoingPacket(PacketSendOperations.MobCtrlAck); response.WriteInt(controlled.ID); response.WriteShort(mobCtrlSN); response.WriteBool(mobMoveStartResult); response.WriteShort((short)controlled.MP); // nMP response.WriteByte(0); // SkillCommand response.WriteByte(0); // SLV await controller.Dispatch(response); var movement = new UnstructuredOutgoingPacket(PacketSendOperations.MobMove); movement.WriteInt(controlled.ID); movement.WriteBool(false); // NotForceLandingWhenDiscard movement.WriteBool(false); // NotChangeAction movement.WriteBool(false); // NextAttackPossible movement.WriteBool(false); // Left movement.WriteInt(illegalVelocity); movement.WriteInt(0); // MultiTargetForBall movement.WriteInt(0); // RandTimeForAreaAttack movement.Write(path); await controlled.Field.Dispatch(controller, movement); }
protected override void ReadData(IPacketReader reader) { _moveAction = (MoveActionType)reader.ReadByte(); _elapse = reader.ReadShort(); }