Mob looting fix and dungeon closure.

This commit is contained in:
dingo
2026-01-25 18:04:47 -05:00
parent 85c95e9f6a
commit c1a97b219e
8 changed files with 157 additions and 65 deletions
+20 -6
View File
@@ -194,6 +194,8 @@ func _on_message_received(opcode: int, data: Dictionary):
_handle_projectile_expired(data)
OpCodes.EVENT_DAMAGE_NUMBER:
_handle_damage_number(data)
OpCodes.ERROR:
_handle_error(data)
_:
print("[GameState] Unhandled opcode: ", opcode)
@@ -361,12 +363,13 @@ func _handle_dungeon_state(data: Dictionary):
# Check dungeon phase first
var phase = data.get("phase", data.get("Phase", "active"))
if phase == "cleared":
print("[GameState] Dungeon cleared! Waiting for hub state...")
# Server should send HUB_STATE next, but show a message
set_state(STATE_DUNGEONCLEARED)
dungeon_cleared.emit()
return
# Only print once when transitioning to cleared state
if dungeon.phase != "cleared":
print("[GameState] Dungeon cleared! Use the portal to exit.")
dungeon_cleared.emit()
dungeon.phase = "cleared"
# Don't return - continue processing state so player can still move and loot
var ps = data.get("players", data.get("Players", []))
for p in ps:
var pid = int(p.get("id", p.get("Id", 0)))
@@ -549,6 +552,12 @@ func send_use_item(slot_index: int):
func send_stack_items(source_slot: int, target_slot: int):
Network.send_message(OpCodes.STACK_ITEMS, {"SourceSlot": source_slot, "TargetSlot": target_slot})
func send_move_item(source_slot: int, target_slot: int):
Network.send_message(OpCodes.MOVE_ITEM, {"SourceSlot": source_slot, "TargetSlot": target_slot})
func send_auto_stack_inventory():
Network.send_message(OpCodes.AUTO_STACK_INVENTORY, {})
func send_chat(message: String):
Network.send_message(OpCodes.CHAT_SEND, {"Message": message})
@@ -650,6 +659,11 @@ func take_mob_loot_item(mob_id: int, item_index: int):
func take_all_mob_loot(mob_id: int):
Network.send_message(OpCodes.MOB_LOOT_TAKE_ALL, {"mobId": mob_id})
func _handle_error(data: Dictionary):
var error_message = data.get("error", "Unknown error")
push_error("[Server Error] " + error_message)
print("[GameState] Server error: " + error_message)
# Dungeon list handler
func _handle_dungeon_list(data: Dictionary):
print("[GameState] Received dungeon list")