diff --git a/project.godot b/project.godot index 5ab72a0..2d6d2ee 100644 --- a/project.godot +++ b/project.godot @@ -148,6 +148,11 @@ stash={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":70,"key_label":0,"unicode":102,"location":0,"echo":false,"script":null) ] } +crafting={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":67,"key_label":0,"unicode":99,"location":0,"echo":false,"script":null) +] +} [rendering] diff --git a/scenes/dungeon/player.tscn b/scenes/dungeon/player.tscn index 8939985..6bbfeed 100644 --- a/scenes/dungeon/player.tscn +++ b/scenes/dungeon/player.tscn @@ -9,7 +9,7 @@ radius = 14.0 script = ExtResource("1") [node name="AnimatedSprite" type="AnimatedSprite2D" parent="."] -scale = Vector2(1, 1) +scale = Vector2(2, 2) [node name="AimLine" type="Line2D" parent="."] width = 3.0 diff --git a/scenes/ui/hud.tscn b/scenes/ui/hud.tscn index 8a39066..3d4fb83 100644 --- a/scenes/ui/hud.tscn +++ b/scenes/ui/hud.tscn @@ -16,6 +16,7 @@ bg_color = Color(1, 0.77254903, 0.11764706, 1) [node name="Hud" type="CanvasLayer"] layer = 5 +visible = false script = ExtResource("1_hud") [node name="TopLeft" type="Control" parent="."] diff --git a/scripts/autoload/game_state.gd b/scripts/autoload/game_state.gd index d6160ea..afa3ecd 100644 --- a/scripts/autoload/game_state.gd +++ b/scripts/autoload/game_state.gd @@ -120,6 +120,10 @@ func get_state_name() -> String: return STATE_NAMES[current_state] if current_state < STATE_NAMES.size() else "UNKNOWN" func _on_message_received(opcode: int, data: Dictionary): + # Debug: log projectile-related opcodes + if opcode == 504 or opcode == 505 or opcode == 506: + print("[GameState] !!!!! Received projectile opcode: ", opcode, " !!!!!") + match opcode: OpCodes.AUTH_LOGIN_RESULT, OpCodes.AUTH_REGISTER_RESULT: _handle_auth_result(data) @@ -768,8 +772,17 @@ func _handle_tile_update(data: Dictionary): dungeon_tiles_updated.emit(tiles) func _handle_projectile_spawned(data: Dictionary): - print("[GameState] Projectile spawned: ", data.get("id", -1)) + print("[GameState] ===== PROJECTILE SPAWNED EVENT =====") + print("[GameState] Projectile ID: ", data.get("id", -1)) + print("[GameState] Position: (", data.get("x", 0), ", ", data.get("y", 0), ")") + print("[GameState] Velocity: (", data.get("vx", 0), ", ", data.get("vy", 0), ")") + print("[GameState] Sprite: ", data.get("sprite", "")) + print("[GameState] Linear: ", data.get("isLinear", false)) + print("[GameState] Full data: ", data) + print("[GameState] Emitting projectile_spawned signal") projectile_spawned.emit(data) + print("[GameState] ===== END PROJECTILE SPAWNED =====") + func _handle_projectile_hit(data: Dictionary): print("[GameState] Projectile hit: ", data) diff --git a/scripts/autoload/network.gd b/scripts/autoload/network.gd index d8c7c23..ec98f23 100644 --- a/scripts/autoload/network.gd +++ b/scripts/autoload/network.gd @@ -104,7 +104,7 @@ func disconnect_from_server(): ## @param opcode: Message type identifier (see opcodes.gd) ## @param data: Dictionary of message data to send func send_message(opcode: int, data: Dictionary = {}): - print("[Network] Send Message Called to send opCode: ", opcode) + #print("[Network] Send Message Called to send opCode: ", opcode) if not _is_connected: push_warning("[Network] Cannot send message - not connected") return @@ -188,7 +188,7 @@ func _handle_received_data(packet: PackedByteArray): var message = json.data var opcode: int = message.get("opCode", message.get("OpCode", 0)) - print("[Network] OpCode Recieved: ", opcode) + #print("[Network] OpCode Recieved: ", opcode) # Decode payload var payload_data = message.get("payload", message.get("Payload", null)) var decoded_data = {} diff --git a/scripts/dungeon/dungeon_manager.gd b/scripts/dungeon/dungeon_manager.gd index 889a5cc..72e3ff3 100644 --- a/scripts/dungeon/dungeon_manager.gd +++ b/scripts/dungeon/dungeon_manager.gd @@ -42,7 +42,7 @@ var damage_number_scene: PackedScene = null var projectiles: Dictionary = {} # id -> projectile node var aim_angle: float = 0.0 -var last_attack_time: float = 0.0 +var last_attack_time: float = -999.0 # Start far in the past so first attack always works var attack_cooldown: float = 0.5 # Default attack cooldown in seconds func _ready(): @@ -261,7 +261,12 @@ func _handle_input(): if Input.is_action_just_pressed("inventory"): if chat_panel.visible != true: _toggle_inventory() - + + # Crafting toggle (C key) + if Input.is_action_just_pressed("crafting"): + if chat_panel.visible != true: + _toggle_crafting() + # Escape handling - close UI panels, or show hint about portals if Input.is_action_just_pressed("escape_menu"): # Close UI first (in priority order) @@ -617,6 +622,9 @@ func _on_damage_number(data: Dictionary): if mob_id == target_id: target_pos = mob_node.position found_target = true + # Play hurt effect on mob + if mob_node.has_method("play_hurt_effect"): + mob_node.play_hurt_effect() break elif target_type == "player": # Check if it's the local player diff --git a/scripts/dungeon/mob_visual.gd b/scripts/dungeon/mob_visual.gd index c4cd069..d099e0b 100644 --- a/scripts/dungeon/mob_visual.gd +++ b/scripts/dungeon/mob_visual.gd @@ -483,8 +483,26 @@ func _update_fallback_state(state: String): func _apply_tint(tint_hex: String): var tint_color = Color.from_string(tint_hex, Color.WHITE) - + if _animated_sprite: _animated_sprite.modulate = tint_color elif fallback_sprite: fallback_sprite.modulate = tint_color + +func play_hurt_effect(): + """Flash mob red briefly to show damage""" + var sprite_to_flash = _animated_sprite if _animated_sprite and _animated_sprite.visible else fallback_sprite + + if not sprite_to_flash: + return + + # Store original color + var original_color = sprite_to_flash.modulate + + # Flash red + sprite_to_flash.modulate = Color(1.5, 0.5, 0.5, 1.0) # Bright red flash + + # Return to original color after 0.1 seconds + await get_tree().create_timer(0.1).timeout + if is_instance_valid(sprite_to_flash): + sprite_to_flash.modulate = original_color diff --git a/scripts/dungeon/player.gd b/scripts/dungeon/player.gd index e1c16b3..7a002cb 100644 --- a/scripts/dungeon/player.gd +++ b/scripts/dungeon/player.gd @@ -143,29 +143,41 @@ func _process(_delta): func set_aim_angle(angle: float): aim_angle = angle - - # Update facing direction based on aim angle - # Convert angle to direction (down, up, left, right) - var deg = rad_to_deg(angle) - if deg < 0: - deg += 360 - - if deg >= 315 or deg < 45: - current_direction = "right" - elif deg >= 45 and deg < 135: - current_direction = "down" - elif deg >= 135 and deg < 225: - current_direction = "left" - else: - current_direction = "up" + # Don't update direction from aim - only update from movement func _update_walk_animation(): if not animated_sprite or not animated_sprite.sprite_frames: return - var anim_name = "walk_" + current_direction - if animated_sprite.animation != anim_name: - animated_sprite.play(anim_name) + # Update direction based on movement vector + if move_direction.length() > 0.1: + # Player is moving, update direction based on movement + var angle = move_direction.angle() + var deg = rad_to_deg(angle) + if deg < 0: + deg += 360 + + if deg >= 315 or deg < 45: + current_direction = "right" + elif deg >= 45 and deg < 135: + current_direction = "down" + elif deg >= 135 and deg < 225: + current_direction = "left" + else: + current_direction = "up" + + # Play walk animation for current direction (will loop) + var anim_name = "walk_" + current_direction + if animated_sprite.animation != anim_name and not is_attacking: + animated_sprite.play(anim_name) + else: + # Player stopped moving - show idle frame (frame 0 of walk animation) + if not is_attacking: + var anim_name = "walk_" + current_direction + if animated_sprite.animation != anim_name or animated_sprite.is_playing(): + animated_sprite.play(anim_name) + animated_sprite.pause() + animated_sprite.frame = 0 # Show first frame as idle func play_attack_animation(weapon_type: String = "fist"): """ diff --git a/scripts/dungeon/projectile.gd b/scripts/dungeon/projectile.gd index 0ab564c..d399333 100644 --- a/scripts/dungeon/projectile.gd +++ b/scripts/dungeon/projectile.gd @@ -28,26 +28,29 @@ func _ready(): func _use_fallback_sprite(): if not sprite: + print("[Projectile] ERROR: No sprite node to apply fallback to!") return # Create a simple circular fallback sprite - if has_node("/root/SpriteGenerator"): - var sprite_gen = get_node("/root/SpriteGenerator") - sprite.texture = sprite_gen.get_circle() + if SpriteGenerator: + sprite.texture = SpriteGenerator.get_circle() sprite.modulate = Color(1.0, 0.8, 0.2) # Yellowish for projectiles - sprite.scale = Vector2(0.3, 0.3) + sprite.scale = Vector2(0.5, 0.5) # Make it bigger so it's visible + print("[Projectile] Using fallback sprite with SpriteGenerator") else: # If no SpriteGenerator, just leave it invisible for now print("[Projectile] Warning: No SpriteGenerator available for fallback") func _load_sprite(): if not sprite: + print("[Projectile] ERROR: No sprite node to load texture into!") return + print("[Projectile] Loading sprite with key: '%s'" % sprite_key) + # Try to load projectile sprite from CDN if UpdateManager exists - if sprite_key and not sprite_key.is_empty() and has_node("/root/UpdateManager"): - var update_manager = get_node("/root/UpdateManager") - var texture = update_manager.load_texture(sprite_key) + if sprite_key and not sprite_key.is_empty() and UpdateManager: + var texture = UpdateManager.load_texture(sprite_key) if texture: sprite.texture = texture sprite.modulate = Color.WHITE # Reset modulate