From 3f710b57ad1dec6c2b42959035de44d453574b48 Mon Sep 17 00:00:00 2001 From: Sceat Date: Sun, 5 May 2024 18:39:36 +0200 Subject: [PATCH] feat: support health packet --- generated/ares_pb.js | 266 ++++++++++++++++++++++++++----------------- proto/ares.proto | 23 +++- src/types.d.ts | 1 + 3 files changed, 179 insertions(+), 111 deletions(-) diff --git a/generated/ares_pb.js b/generated/ares_pb.js index e9f40e4..110e775 100644 --- a/generated/ares_pb.js +++ b/generated/ares_pb.js @@ -1,4 +1,4 @@ -// @generated by protoc-gen-es v1.4.2 with parameter "target=js" +// @generated by protoc-gen-es v1.9.0 with parameter "target=js" // @generated from file ares.proto (package ares, syntax proto3) /* eslint-disable */ // @ts-nocheck @@ -8,7 +8,7 @@ import { proto3 } from '@bufbuild/protobuf' /** * @generated from enum ares.EntityType */ -export const EntityType = proto3.makeEnum('ares.EntityType', [ +export const EntityType = /*@__PURE__*/ proto3.makeEnum('ares.EntityType', [ { no: 0, name: 'MOB' }, { no: 1, name: 'NPC' }, ]) @@ -16,7 +16,7 @@ export const EntityType = proto3.makeEnum('ares.EntityType', [ /** * @generated from enum ares.Classe */ -export const Classe = proto3.makeEnum('ares.Classe', [ +export const Classe = /*@__PURE__*/ proto3.makeEnum('ares.Classe', [ { no: 0, name: 'IOP' }, { no: 1, name: 'SRAM' }, ]) @@ -24,82 +24,105 @@ export const Classe = proto3.makeEnum('ares.Classe', [ /** * @generated from enum ares.ErrorCode */ -export const ErrorCode = proto3.makeEnum('ares.ErrorCode', [ +export const ErrorCode = /*@__PURE__*/ proto3.makeEnum('ares.ErrorCode', [ { no: 0, name: 'NO_BETA_ACCESS' }, ]) /** * @generated from enum ares.Action */ -export const Action = proto3.makeEnum('ares.Action', [ - { no: 0, name: 'JUMP' }, - { no: 1, name: 'DANCE' }, - { no: 2, name: 'WALK' }, - { no: 3, name: 'RUN' }, - { no: 4, name: 'SIT' }, +export const Action = /*@__PURE__*/ proto3.makeEnum('ares.Action', [ + { no: 0, name: 'IDLE' }, + { no: 1, name: 'RUN' }, + { no: 2, name: 'JUMP' }, + { no: 3, name: 'JUMP_RUN' }, + { no: 4, name: 'FALL' }, + { no: 5, name: 'DEATH' }, + { no: 6, name: 'ATTACK_CAC' }, + { no: 7, name: 'SPELL_BUFF' }, + { no: 8, name: 'SPELL_TARGET' }, + { no: 9, name: 'DANCE' }, + { no: 10, name: 'SIT' }, + { no: 11, name: 'WALK' }, ]) /** * @generated from message ares.Packet */ -export const Packet = proto3.makeMessageType('ares.Packet', () => [ - { - no: 1, - name: 'signatureRequest', - kind: 'message', - T: SignatureRequest, - oneof: 'type', - }, - { no: 2, name: 'error', kind: 'message', T: Error, oneof: 'type' }, - { - no: 3, - name: 'signatureResponse', - kind: 'message', - T: SignatureResponse, - oneof: 'type', - }, - { - no: 4, - name: 'characterAction', - kind: 'message', - T: CharacterAction, - oneof: 'type', - }, - { - no: 5, - name: 'characterPosition', - kind: 'message', - T: CharacterPosition, - oneof: 'type', - }, - { - no: 6, - name: 'entitySpawn', - kind: 'message', - T: EntitySpawn, - oneof: 'type', - }, - { - no: 7, - name: 'entityDespawn', - kind: 'message', - T: EntityDespawn, - oneof: 'type', - }, - { no: 8, name: 'serverInfo', kind: 'message', T: ServerInfo, oneof: 'type' }, - { - no: 9, - name: 'chatMessage', - kind: 'message', - T: ChatMessage, - oneof: 'type', - }, -]) +export const Packet = /*@__PURE__*/ proto3.makeMessageType( + 'ares.Packet', + () => [ + { + no: 1, + name: 'signatureRequest', + kind: 'message', + T: SignatureRequest, + oneof: 'type', + }, + { no: 2, name: 'error', kind: 'message', T: Error, oneof: 'type' }, + { + no: 3, + name: 'signatureResponse', + kind: 'message', + T: SignatureResponse, + oneof: 'type', + }, + { + no: 4, + name: 'characterAction', + kind: 'message', + T: CharacterAction, + oneof: 'type', + }, + { + no: 5, + name: 'characterPosition', + kind: 'message', + T: CharacterPosition, + oneof: 'type', + }, + { + no: 6, + name: 'entitySpawn', + kind: 'message', + T: EntitySpawn, + oneof: 'type', + }, + { + no: 7, + name: 'entityDespawn', + kind: 'message', + T: EntityDespawn, + oneof: 'type', + }, + { + no: 8, + name: 'serverInfo', + kind: 'message', + T: ServerInfo, + oneof: 'type', + }, + { + no: 9, + name: 'chatMessage', + kind: 'message', + T: ChatMessage, + oneof: 'type', + }, + { + no: 10, + name: 'characterHealth', + kind: 'message', + T: CharacterHealth, + oneof: 'type', + }, + ], +) /** * @generated from message ares.SignatureRequest */ -export const SignatureRequest = proto3.makeMessageType( +export const SignatureRequest = /*@__PURE__*/ proto3.makeMessageType( 'ares.SignatureRequest', () => [ { no: 1, name: 'payload', kind: 'scalar', T: 9 /* ScalarType.STRING */ }, @@ -109,21 +132,24 @@ export const SignatureRequest = proto3.makeMessageType( /** * @generated from message ares.Error */ -export const Error = proto3.makeMessageType('ares.Error', () => [ +export const Error = /*@__PURE__*/ proto3.makeMessageType('ares.Error', () => [ { no: 1, name: 'code', kind: 'enum', T: proto3.getEnumType(ErrorCode) }, ]) /** * @generated from message ares.EntitySpawn */ -export const EntitySpawn = proto3.makeMessageType('ares.EntitySpawn', () => [ - { no: 1, name: 'entities', kind: 'message', T: Entity, repeated: true }, -]) +export const EntitySpawn = /*@__PURE__*/ proto3.makeMessageType( + 'ares.EntitySpawn', + () => [ + { no: 1, name: 'entities', kind: 'message', T: Entity, repeated: true }, + ], +) /** * @generated from message ares.EntityDespawn */ -export const EntityDespawn = proto3.makeMessageType( +export const EntityDespawn = /*@__PURE__*/ proto3.makeMessageType( 'ares.EntityDespawn', () => [ { @@ -139,20 +165,39 @@ export const EntityDespawn = proto3.makeMessageType( /** * @generated from message ares.ServerInfo */ -export const ServerInfo = proto3.makeMessageType('ares.ServerInfo', () => [ - { - no: 1, - name: 'player_count', - kind: 'scalar', - T: 13 /* ScalarType.UINT32 */, - }, - { no: 2, name: 'max_players', kind: 'scalar', T: 13 /* ScalarType.UINT32 */ }, -]) +export const ServerInfo = /*@__PURE__*/ proto3.makeMessageType( + 'ares.ServerInfo', + () => [ + { + no: 1, + name: 'player_count', + kind: 'scalar', + T: 13 /* ScalarType.UINT32 */, + }, + { + no: 2, + name: 'max_players', + kind: 'scalar', + T: 13 /* ScalarType.UINT32 */, + }, + ], +) + +/** + * @generated from message ares.CharacterHealth + */ +export const CharacterHealth = /*@__PURE__*/ proto3.makeMessageType( + 'ares.CharacterHealth', + () => [ + { no: 1, name: 'id', kind: 'scalar', T: 9 /* ScalarType.STRING */ }, + { no: 2, name: 'health', kind: 'scalar', T: 13 /* ScalarType.UINT32 */ }, + ], +) /** * @generated from message ares.SignatureResponse */ -export const SignatureResponse = proto3.makeMessageType( +export const SignatureResponse = /*@__PURE__*/ proto3.makeMessageType( 'ares.SignatureResponse', () => [ { no: 1, name: 'bytes', kind: 'scalar', T: 9 /* ScalarType.STRING */ }, @@ -163,7 +208,7 @@ export const SignatureResponse = proto3.makeMessageType( /** * @generated from message ares.CharacterAction */ -export const CharacterAction = proto3.makeMessageType( +export const CharacterAction = /*@__PURE__*/ proto3.makeMessageType( 'ares.CharacterAction', () => [ { no: 1, name: 'id', kind: 'scalar', T: 9 /* ScalarType.STRING */ }, @@ -174,7 +219,7 @@ export const CharacterAction = proto3.makeMessageType( /** * @generated from message ares.CharacterPosition */ -export const CharacterPosition = proto3.makeMessageType( +export const CharacterPosition = /*@__PURE__*/ proto3.makeMessageType( 'ares.CharacterPosition', () => [ { no: 1, name: 'id', kind: 'scalar', T: 9 /* ScalarType.STRING */ }, @@ -185,25 +230,31 @@ export const CharacterPosition = proto3.makeMessageType( /** * @generated from message ares.ChatMessage */ -export const ChatMessage = proto3.makeMessageType('ares.ChatMessage', () => [ - { no: 1, name: 'id', kind: 'scalar', T: 9 /* ScalarType.STRING */ }, - { no: 2, name: 'message', kind: 'scalar', T: 9 /* ScalarType.STRING */ }, - { no: 3, name: 'address', kind: 'scalar', T: 9 /* ScalarType.STRING */ }, -]) +export const ChatMessage = /*@__PURE__*/ proto3.makeMessageType( + 'ares.ChatMessage', + () => [ + { no: 1, name: 'id', kind: 'scalar', T: 9 /* ScalarType.STRING */ }, + { no: 2, name: 'message', kind: 'scalar', T: 9 /* ScalarType.STRING */ }, + { no: 3, name: 'address', kind: 'scalar', T: 9 /* ScalarType.STRING */ }, + ], +) /** * @generated from message ares.Position */ -export const Position = proto3.makeMessageType('ares.Position', () => [ - { no: 1, name: 'x', kind: 'scalar', T: 2 /* ScalarType.FLOAT */ }, - { no: 2, name: 'y', kind: 'scalar', T: 2 /* ScalarType.FLOAT */ }, - { no: 3, name: 'z', kind: 'scalar', T: 2 /* ScalarType.FLOAT */ }, -]) +export const Position = /*@__PURE__*/ proto3.makeMessageType( + 'ares.Position', + () => [ + { no: 1, name: 'x', kind: 'scalar', T: 2 /* ScalarType.FLOAT */ }, + { no: 2, name: 'y', kind: 'scalar', T: 2 /* ScalarType.FLOAT */ }, + { no: 3, name: 'z', kind: 'scalar', T: 2 /* ScalarType.FLOAT */ }, + ], +) /** * @generated from message ares.SiblingEntity */ -export const SiblingEntity = proto3.makeMessageType( +export const SiblingEntity = /*@__PURE__*/ proto3.makeMessageType( 'ares.SiblingEntity', () => [ { no: 1, name: 'name', kind: 'scalar', T: 9 /* ScalarType.STRING */ }, @@ -214,17 +265,20 @@ export const SiblingEntity = proto3.makeMessageType( /** * @generated from message ares.Entity */ -export const Entity = proto3.makeMessageType('ares.Entity', () => [ - { no: 1, name: 'id', kind: 'scalar', T: 9 /* ScalarType.STRING */ }, - { no: 2, name: 'name', kind: 'scalar', T: 9 /* ScalarType.STRING */ }, - { no: 3, name: 'position', kind: 'message', T: Position }, - { no: 4, name: 'type', kind: 'enum', T: proto3.getEnumType(EntityType) }, - { no: 5, name: 'level', kind: 'scalar', T: 13 /* ScalarType.UINT32 */ }, - { - no: 8, - name: 'siblings', - kind: 'message', - T: SiblingEntity, - repeated: true, - }, -]) +export const Entity = /*@__PURE__*/ proto3.makeMessageType( + 'ares.Entity', + () => [ + { no: 1, name: 'id', kind: 'scalar', T: 9 /* ScalarType.STRING */ }, + { no: 2, name: 'name', kind: 'scalar', T: 9 /* ScalarType.STRING */ }, + { no: 3, name: 'position', kind: 'message', T: Position }, + { no: 4, name: 'type', kind: 'enum', T: proto3.getEnumType(EntityType) }, + { no: 5, name: 'level', kind: 'scalar', T: 13 /* ScalarType.UINT32 */ }, + { + no: 8, + name: 'siblings', + kind: 'message', + T: SiblingEntity, + repeated: true, + }, + ], +) diff --git a/proto/ares.proto b/proto/ares.proto index 2bd97c9..42daa2a 100644 --- a/proto/ares.proto +++ b/proto/ares.proto @@ -12,6 +12,7 @@ message Packet { EntityDespawn entityDespawn = 7; ServerInfo serverInfo = 8; ChatMessage chatMessage = 9; + CharacterHealth characterHealth = 10; } } @@ -39,6 +40,11 @@ message ServerInfo { uint32 max_players = 2; } +message CharacterHealth { + string id = 1; + uint32 health = 2; +} + // ======================================== [CLIENT -> SERVER] // Packets sent from the client to the server @@ -104,9 +110,16 @@ enum ErrorCode { } enum Action { - JUMP = 0; - DANCE = 1; - WALK = 2; - RUN = 3; - SIT = 4; + IDLE = 0; + RUN = 1; + JUMP = 2; + JUMP_RUN = 3; + FALL = 4; + DEATH = 5; + ATTACK_CAC = 6; + SPELL_BUFF = 7; + SPELL_TARGET = 8; + DANCE = 9; + SIT = 10; + WALK = 11; } \ No newline at end of file diff --git a/src/types.d.ts b/src/types.d.ts index 012262b..8f1e7f1 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -105,6 +105,7 @@ type Packets = { max_players: number } // server -> client 'packet/chatMessage': { id: string; message: string; address: string } // both ways + 'packet/characterHealth': { id: string; health: number } // server -> client } type Packet = {