Files
dungeon-divers/scripts/autoload/opcodes.gd
T
2026-01-20 16:23:00 -05:00

297 lines
7.4 KiB
GDScript

extends Node
## Network OpCodes - Message Type Identifiers
##
## This file defines all message types (opcodes) used for client-server communication.
## Each opcode represents a specific type of message or action.
# ===== Keepalive / Connection Management (1-9) =====
## Echo test message - server echoes back the received payload
const ECHO = 1
## Server -> Client: Keepalive ping to prevent idle timeout
## Client should automatically respond with PONG
const PING = 2
## Client -> Server: Response to PING message
## Handled automatically by network.gd
const PONG = 3
# ===== Authentication (100-119) =====
## Client -> Server: Register new account
const AUTH_REGISTER = 100
## Server -> Client: Registration result
const AUTH_REGISTER_RESULT = 101
## Client -> Server: Login with username and password
const AUTH_LOGIN = 110
## Server -> Client: Login result
const AUTH_LOGIN_RESULT = 111
## Client -> Server: Authenticate using stored session token
const AUTH_WITH_TOKEN = 112
## Server -> Client: Token authentication result
const AUTH_WITH_TOKEN_RESULT = 113
# ===== Hub / Character Selection (200-249) =====
## Server -> Client: Hub state with character info
const HUB_STATE = 200
## Client -> Server: Allocate stat points
const STAT_ALLOCATE = 201
## Client -> Server: Create new character
const CHAR_CREATE = 202
## Server -> Client: Character creation result
const CHAR_CREATE_RESULT = 203
## Client -> Server: Select character to play
const CHAR_SELECT = 204
## Server -> Client: Character selection result
const CHAR_SELECT_RESULT = 205
# ===== Inventory Management (250-259) =====
## Client -> Server: Request current inventory state
const INVENTORY_REQUEST = 250
## Server -> Client: Current inventory state
const INVENTORY_STATE = 251
## Client -> Server: Equip an item
const EQUIP_ITEM = 252
## Client -> Server: Unequip an item
const UNEQUIP_ITEM = 253
## Client -> Server: Use a consumable item
const USE_ITEM = 254
## Client -> Server: Drop an item from inventory
const DROP_ITEM = 255
## Client -> Server: Assign item to hotbar slot
const HOTBAR_ASSIGN = 256
## Client -> Server: Stack two consumable items together
const STACK_ITEMS = 257
# ===== Chat (260-269) =====
## Client -> Server: Send chat message
const CHAT_SEND = 260
## Server -> Client: Chat message from player
const CHAT_MESSAGE = 261
# ===== Loot Chests (270-279) =====
## Client -> Server: Open a loot chest
const LOOT_CHEST_OPEN = 270
## Server -> Client: Loot chest contents
const LOOT_CHEST_STATE = 271
## Client -> Server: Take specific item from chest
const LOOT_CHEST_TAKE_ITEM = 272
## Client -> Server: Take all items from chest
const LOOT_CHEST_TAKE_ALL = 273
## Client -> Server: Close loot chest UI
const LOOT_CHEST_CLOSE = 274
## Server -> Client: New loot chest spawned in dungeon
const LOOT_CHEST_SPAWNED = 275
## Server -> Client: Loot chest removed/destroyed
const LOOT_CHEST_REMOVED = 276
# ===== Player Death (280-289) =====
## Server -> Client: Notify player what loot they lost on death
const PLAYER_DEATH_LOOT_LOST = 280
# ===== Mob Loot (290-299) =====
## Client -> Server: Request loot from a dead mob
const MOB_LOOT_REQUEST = 290
## Server -> Client: Mob loot contents response
const MOB_LOOT_STATE = 291
## Client -> Server: Take specific item from mob
const MOB_LOOT_TAKE_ITEM = 292
## Client -> Server: Take all items from mob
const MOB_LOOT_TAKE_ALL = 293
# ===== Dungeon Core (300-309) =====
## Client -> Server: Request to enter a dungeon
const DUNGEON_ENTER = 300
## Server -> Client: Dungeon entry result
const DUNGEON_ENTER_RESULT = 301
## Server -> Client: Current dungeon state snapshot
const DUNGEON_STATE = 302
## Client -> Server: Leave current dungeon
const DUNGEON_LEAVE = 303
## Server -> Client: Dungeon has been cleared (boss defeated)
const DUNGEON_CLEARED = 304
## Server -> Client: Tile update (door opened, destructible destroyed, etc.)
const DUNGEON_TILE_UPDATE = 305
# ===== Dungeon Browser (310-319) =====
## Client -> Server: Request list of available dungeons
const DUNGEON_LIST_REQUEST = 310
## Server -> Client: List of dungeons
const DUNGEON_LIST_RESPONSE = 311
## Client -> Server: Create a new dungeon instance
const DUNGEON_CREATE = 312
## Client -> Server: Join an existing dungeon
const DUNGEON_JOIN = 313
# ===== Asset Management (320-329) =====
## Client -> Server: Request asset manifest (sprites, tilesets, etc.)
const ASSET_MANIFEST_REQUEST = 320
## Server -> Client: Asset manifest response
const ASSET_MANIFEST_RESPONSE = 321
# ===== Crafting System (330-349) =====
## Client -> Server: Request crafting skills state
const CRAFTING_SKILLS_REQUEST = 330
## Server -> Client: Crafting skills state
const CRAFTING_SKILLS_STATE = 331
## Client -> Server: Request known crafting recipes
const CRAFTING_RECIPES_REQUEST = 332
## Server -> Client: Crafting recipes state
const CRAFTING_RECIPES_STATE = 333
## Client -> Server: Attempt to craft an item
const CRAFTING_ATTEMPT = 334
## Server -> Client: Crafting attempt result
const CRAFTING_RESULT = 335
## Server -> Client: Crafting skill leveled up
const CRAFTING_SKILL_LEVELUP = 336
## Server -> Client: New recipe discovered
const RECIPE_DISCOVERED = 337
## Client -> Server: Use a recipe scroll to learn recipe
const RECIPE_SCROLL_USE = 338
# ===== Dungeon Input / Actions (400-449) =====
## Client -> Server: Movement input
const INPUT_MOVE = 400
## Client -> Server: Attack action
const INPUT_ATTACK = 401
## Client -> Server: Pickup item from ground
const INPUT_PICKUP = 402
## Client -> Server: Interact with chest
const INPUT_CHEST = 403
## Client -> Server: Use portal
const INPUT_PORTAL = 404
## Client -> Server: Fire projectile (bow, crossbow, throwable)
const INPUT_FIRE_PROJECTILE = 405
# ===== Escape / Portal (450-459) =====
## Client -> Server: Start escape channel (return to hub)
const ESCAPE_START = 450
## Client -> Server: Cancel escape channel
const ESCAPE_CANCEL = 451
## Server -> Client: Escape interrupted (took damage)
const ESCAPE_INTERRUPTED = 452
## Server -> Client: Escape successful, returning to hub
const ESCAPE_SUCCESS = 453
## Server -> Client: Portal successfully used
const PORTAL_USED = 454
# ===== Game Events (500-599) =====
## Server -> Client: Damage event occurred
const EVENT_DAMAGE = 500
## Server -> Client: Entity died
const EVENT_DEATH = 501
## Server -> Client: Player leveled up
const EVENT_LEVELUP = 502
## Server -> Client: Loot obtained
const EVENT_LOOT = 503
## Server -> Client: Projectile spawned in dungeon
const EVENT_PROJECTILE_SPAWNED = 504
## Server -> Client: Projectile hit target (mob/player)
const EVENT_PROJECTILE_HIT = 505
## Server -> Client: Projectile expired (max range or wall collision)
const EVENT_PROJECTILE_EXPIRED = 506
## Server -> Client: Damage number for floating text
const EVENT_DAMAGE_NUMBER = 507
# ===== Server Broadcasts (600-609) =====
## Server -> All Clients: Server-wide broadcast message
const SERVER_BROADCAST = 600
# ===== Stash System - VIP Feature (610-619) =====
## Client -> Server: Request stash contents
const STASH_REQUEST = 610
## Server -> Client: Stash contents
const STASH_STATE = 611
## Client -> Server: Deposit item from inventory to stash
const STASH_DEPOSIT = 612
## Client -> Server: Withdraw item from stash to inventory
const STASH_WITHDRAW = 613
## Server -> Client: Stash operation result
const STASH_RESULT = 614
# ===== Legacy / Deprecated =====
## Legacy loot notification (consider consolidating with EVENT_LOOT)
const LOOT_RECEIVED = 160