Skip to content

Commit

Permalink
charselect, enterworld, system messages
Browse files Browse the repository at this point in the history
  • Loading branch information
shnok committed Oct 27, 2024
1 parent 65486ab commit 96e9b9b
Show file tree
Hide file tree
Showing 21 changed files with 204 additions and 175 deletions.
4 changes: 2 additions & 2 deletions l2-unity/Assets/Scripts/Datatable/Json/SkillEffectTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public void CacheEffects()
{
SkillEffects.TryAdd(kvp.Value.EffectId, skillEffect);
kvp.Value.SkillEffect = skillEffect;
skillEffect.CastingActions?.ForEach((e) => Debug.LogWarning(e.EffectClass));
skillEffect.ShotActions?.ForEach((e) => Debug.LogWarning(e.EffectClass));
// skillEffect.CastingActions?.ForEach((e) => Debug.LogWarning(e.EffectClass));
// skillEffect.ShotActions?.ForEach((e) => Debug.LogWarning(e.EffectClass));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion l2-unity/Assets/Scripts/Datatable/SkillTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void CacheSkills()
Skill skill = new Skill(kvp.Key, skillNameArray, skillgrpArray, skillSoundgrp);
Skills.Add(kvp.Key, skill);

Debug.LogWarning($"ID:{skill.SkillNameDatas[0].Id} Name:{skill.SkillNameDatas[0].Name} Effect:{skill.EffectId}");
// Debug.LogWarning($"ID:{skill.SkillNameDatas[0].Id} Name:{skill.SkillNameDatas[0].Name} Effect:{skill.EffectId}");
}
}

Expand Down
2 changes: 1 addition & 1 deletion l2-unity/Assets/Scripts/Game/Manager/GameManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using static PlayerInfoPacket;
using static CharSelectedPacket;
using static ServerListPacket;

public class GameManager : MonoBehaviour
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ public void StartReceiving()
lengthHi = stream.ReadByte();
length = (lengthHi * 256) + lengthLo;

Debug.LogWarning(length);

if (lengthHi == -1 || !_connected)
{
Debug.Log("Server terminated the connection.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ protected void WriteS(String s)
if (s != null)
{
byte[] d = Encoding.GetEncoding("UTF-16LE").GetBytes(s);
UnityEngine.Debug.Log(StringUtils.ByteArrayToString(d));
_buffer.AddRange(d);
WriteB((byte)0);
WriteB((byte)0);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class EnterWorldPacket : ClientPacket
{
public EnterWorldPacket() : base((byte)GameClientPacketType.EnterWorld)
{
BuildPacket();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
public class RequestCharSelectPacket : ClientPacket {
public RequestCharSelectPacket(int slot) : base((byte)GameClientPacketType.RequestCharSelect) {
public class RequestCharSelectPacket : ClientPacket
{
public RequestCharSelectPacket(int slot) : base((byte)GameClientPacketType.RequestCharSelect)
{
WriteB((byte)slot);
WriteB(0);
WriteB(0);
WriteI(0);
WriteI(0);
WriteI(0);
WriteI(0);
BuildPacket();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
public enum GameClientPacketType : byte
{
ProtocolVersion = 0x00,
LoadWorld = 0x03,
EnterWorld = 0x03,
AuthRequest = 0x08,
Disconnect = 0x09,
RequestAttack = 0x0a,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
public enum GameServerPacketType : byte
public enum GameServerPacketType : int
{
VersionCheck = 0x00,
CharSelectionInfo = 0x13,
LoginFail = 0x14,
CharSelected = 0x15,
CharCreateOk = 0x19,
CharCreateFail = 0x1a,
SystemMessage = 0x64,



Expand All @@ -23,36 +25,34 @@ public enum GameServerPacketType : byte



MessagePacket = 0xF4,
SystemMessage = 0xF5,
PlayerInfo = 0xF6,
ObjectPosition = 0xF7,
RemoveObject = 0xF8,
ObjectRotation = 0xF9,
ObjectAnimation = 0xFA,
ApplyDamage = 0xFB,
NpcInfo = 0xFC,
ObjectMoveTo = 0xFD,
UserInfo = 0xFE,
ObjectMoveDirection = 0xFF,
GameTime = 0xD0,
EntitySetTarget = 0xD1,
AutoAttackStart = 0xD2,
AutoAttackStop = 0xD3,
ActionFailed = 0xD4,
ServerClose = 0xD5,
StatusUpdate = 0xD6,
ActionAllowed = 0xD7,
InventoryItemList = 0xD8,
InventoryUpdate = 0xD9,
LeaveWorld = 0xDA,
RestartReponse = 0xDB,
ShortcutInit = 0xDC,
ShortcutRegister = 0xDD,
SocialAction = 0xDE,
ChangeWaitType = 0xDF,
ChangeMoveType = 0xE0,
MessagePacket = 0xFF4,
ObjectPosition = 0xFF7,
RemoveObject = 0xFF8,
ObjectRotation = 0xFF9,
ObjectAnimation = 0xFFA,
ApplyDamage = 0xFFB,
NpcInfo = 0xFFC,
ObjectMoveTo = 0xFFD,
UserInfo = 0xFFE,
ObjectMoveDirection = 0xFFF,
GameTime = 0xFD0,
EntitySetTarget = 0xFD1,
AutoAttackStart = 0xFD2,
AutoAttackStop = 0xFD3,
ActionFailed = 0xFD4,
ServerClose = 0xFD5,
StatusUpdate = 0xFD6,
ActionAllowed = 0xFD7,
InventoryItemList = 0xFD8,
InventoryUpdate = 0xFD9,
LeaveWorld = 0xFDA,
RestartReponse = 0xFDB,
ShortcutInit = 0xFDC,
ShortcutRegister = 0xFDD,
SocialAction = 0xFDE,
ChangeWaitType = 0xFDF,
ChangeMoveType = 0xFE0,

Ping = 0xE1,
Ping = 0xFE1,

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
using UnityEngine;
using System;

public class CharSelectedPacket : ServerPacket
{
public struct PlayerInfo
{
public NetworkIdentity Identity { get; set; }
public PlayerStatus Status { get; set; }
public PlayerStats Stats { get; set; }
public PlayerAppearance Appearance { get; set; }
public bool Running { get; set; }
}

private PlayerInfo _info;
public PlayerInfo PacketPlayerInfo { get { return _info; } }


public CharSelectedPacket(byte[] d) : base(d)
{
_info = new PlayerInfo();
_info.Identity = new NetworkIdentity();
_info.Status = new PlayerStatus();
_info.Stats = new PlayerStats();
_info.Appearance = new PlayerAppearance();
_info.Appearance = new PlayerAppearance();
Parse();
}

public override void Parse()
{
try
{
_info.Identity.Name = ReadS();
_info.Identity.Id = ReadI();
_info.Identity.Title = ReadS();
ReadI(); //sessionId
ReadI(); //clanId

ReadI();

_info.Appearance.Sex = (byte)ReadI();
_info.Appearance.Race = (byte)ReadI();
_info.Identity.PlayerClass = (byte)ReadI();

ReadI();

_info.Identity.SetPosZ(ReadI() / 52.5f);
_info.Identity.SetPosX(ReadI() / 52.5f);
_info.Identity.SetPosY(ReadI() / 52.5f);
_info.Status.Hp = (int)ReadD();
_info.Status.Mp = (int)ReadD();
_info.Stats.Sp = ReadI();
_info.Stats.Exp = (int)ReadL();
_info.Stats.Level = ReadI();
_info.Stats.Karma = ReadI();
_info.Stats.PkKills = ReadI();
_info.Stats.Int = ReadB();
_info.Stats.Str = ReadB();
_info.Stats.Con = ReadB();
_info.Stats.Men = ReadB();
_info.Stats.Dex = ReadB();
_info.Stats.Wit = ReadB();

for (int i = 0; i < 30; i++)
{
ReadI();
}

ReadI();
ReadI();

ReadI(); //Game time

ReadI();

_info.Identity.PlayerClass = (byte)ReadI();
_info.Identity.IsMage = CharacterClassParser.IsMage((CharacterClass)_info.Identity.PlayerClass);
// _info.Identity.Heading = ReadF();
_info.Identity.Owned = true;

ReadI();
ReadI();
ReadI();
ReadI();


// // Status
// _info.Stats.MaxHp = ReadI();
// _info.Stats.MaxMp = ReadI();
// _info.Status.Cp = ReadI();
// _info.Stats.MaxCp = ReadI();
// // Combat
// _info.Stats.RunSpeed = ReadI();
// _info.Stats.WalkSpeed = ReadI();
// _info.Stats.PAtkSpd = ReadI();
// _info.Stats.MAtkSpd = ReadI();
// _info.Stats.AttackRange = ReadF();
// _info.Stats.PAtk = ReadI();
// _info.Stats.PDef = ReadI();
// _info.Stats.PEvasion = ReadI();
// _info.Stats.PAccuracy = ReadI();
// _info.Stats.MEvasion = ReadI();
// _info.Stats.MAccuracy = ReadI();
// _info.Stats.PCritical = ReadI();
// _info.Stats.MCritical = ReadI();
// _info.Stats.MAtk = ReadI();
// _info.Stats.MDef = ReadI();
// // Stats
// _info.Stats.MaxExp = ReadI();
// _info.Stats.CurrWeight = ReadI();
// _info.Stats.MaxWeight = ReadI();
// // Social
// _info.Stats.PvpKills = ReadI();
// _info.Status.PvpFlag = ReadL();
// // Appearance
// _info.Appearance.CollisionHeight = ReadF();
// _info.Appearance.CollisionRadius = ReadF();
// _info.Appearance.Face = ReadB();
// _info.Appearance.HairStyle = ReadB();
// _info.Appearance.HairColor = ReadB();
// // Gear
// _info.Appearance.LHand = ReadI();
// _info.Appearance.RHand = ReadI();
// _info.Appearance.Chest = ReadI();
// _info.Appearance.Legs = ReadI();
// _info.Appearance.Gloves = ReadI();
// _info.Appearance.Feet = ReadI();

// _info.Running = ReadI() == 1;
}
catch (Exception e)
{
Debug.LogError(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public override void Parse()

ReadI();

float y = ReadI() / 52.5f;
float z = ReadI() / 52.5f;
float x = ReadI() / 52.5f;
float y = ReadI() / 52.5f;

character.Position = new Vector3(x, y, z);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,5 @@ public override void Parse()
BlowFishKey = ReadB(8);
UseBlowfishCipher = ReadI() == 1;
AuthAllowed = ReadI() == 1;

UnityEngine.Debug.Log($"Blowfish key: [{8}]: {StringUtils.ByteArrayToString(BlowFishKey)}");
UnityEngine.Debug.Log($"UseBlowfishCipher: [{AuthAllowed}]");
UnityEngine.Debug.Log($"AuthAllowed: [{AuthAllowed}]");
}
}
Loading

0 comments on commit 96e9b9b

Please sign in to comment.