added more tomes
This commit is contained in:
@@ -8,7 +8,7 @@ enum LootType {
|
||||
BANANA,
|
||||
CHERRY,
|
||||
KEY,
|
||||
ITEM # Item instance (equipment, consumables, etc.)
|
||||
ITEM # Item instance (equipment, consumables, etc.)
|
||||
}
|
||||
|
||||
@export var loot_type: LootType = LootType.COIN
|
||||
@@ -41,7 +41,7 @@ var correction_smoothing: float = 0.3 # Lerp factor for smooth correction (0-1,
|
||||
var coin_value: int = 1
|
||||
var heal_amount: float = 20.0
|
||||
var collected: bool = false
|
||||
var item: Item = null # Item instance (for LootType.ITEM)
|
||||
var item: Item = null # Item instance (for LootType.ITEM)
|
||||
|
||||
@onready var sprite = $Sprite2D
|
||||
@onready var shadow = $Shadow
|
||||
@@ -152,6 +152,7 @@ func _setup_sprite():
|
||||
sprite.hframes = item.spriteFrames.x if item.spriteFrames.x > 0 else 20
|
||||
sprite.vframes = item.spriteFrames.y if item.spriteFrames.y > 0 else 14
|
||||
sprite.frame = item.spriteFrame
|
||||
ItemDatabase.apply_item_colors_to_sprite(sprite, item)
|
||||
print("Loot: Set up item sprite for ", item.item_name, " frame=", sprite.frame)
|
||||
|
||||
# Add quantity badge if quantity > 1
|
||||
@@ -194,8 +195,8 @@ func _create_quantity_badge(quantity: int):
|
||||
quantity_badge.add_theme_color_override("font_color", Color.WHITE)
|
||||
quantity_badge.add_theme_color_override("font_outline_color", Color.BLACK)
|
||||
quantity_badge.add_theme_constant_override("outline_size", 2)
|
||||
quantity_badge.z_index = 100 # Above the sprite
|
||||
quantity_badge.position = Vector2(6, -8) # Bottom right of sprite
|
||||
quantity_badge.z_index = 100 # Above the sprite
|
||||
quantity_badge.position = Vector2(6, -8) # Bottom right of sprite
|
||||
add_child(quantity_badge)
|
||||
|
||||
func _physics_process(delta):
|
||||
@@ -240,7 +241,7 @@ func _physics_process(delta):
|
||||
bounce_timer = 0.08 # Matches old code timing
|
||||
|
||||
# Simple bounce (matches old code)
|
||||
velocity_z = -velocity_z * bounce_restitution
|
||||
velocity_z = - velocity_z * bounce_restitution
|
||||
is_airborne = true # Still bouncing
|
||||
else:
|
||||
# Velocity too small or collected - stop bouncing
|
||||
@@ -267,9 +268,9 @@ func _physics_process(delta):
|
||||
if collider and not collider.is_in_group("player"):
|
||||
# Check if velocity is too small before bouncing (prevent infinite micro-bounces)
|
||||
var velocity_magnitude = velocity.length()
|
||||
if velocity_magnitude < 15.0: # If velocity is very small, stop bouncing
|
||||
if velocity_magnitude < 15.0: # If velocity is very small, stop bouncing
|
||||
velocity = Vector2.ZERO
|
||||
continue # Skip bounce and sound
|
||||
continue # Skip bounce and sound
|
||||
|
||||
# Bounce off walls (matches old code - no aggressive velocity reduction)
|
||||
var normal = collision.get_normal()
|
||||
@@ -329,7 +330,7 @@ func _physics_process(delta):
|
||||
sfx_coin_bounce.volume_db = -1.0 + (-10.0 - (abs(velocity_z) * 0.1))
|
||||
sfx_coin_bounce.play()
|
||||
bounce_timer = 0.08
|
||||
velocity_z = -velocity_z * bounce_restitution
|
||||
velocity_z = - velocity_z * bounce_restitution
|
||||
is_airborne = true
|
||||
else:
|
||||
velocity_z = 0.0
|
||||
@@ -405,7 +406,7 @@ func _on_pickup_area_body_entered(body):
|
||||
var dropped_by_peer_id = get_meta("dropped_by_peer_id")
|
||||
var drop_time = get_meta("drop_time")
|
||||
var current_time = Time.get_ticks_msec()
|
||||
var time_since_drop = (current_time - drop_time) / 1000.0 # Convert to seconds
|
||||
var time_since_drop = (current_time - drop_time) / 1000.0 # Convert to seconds
|
||||
|
||||
# Check if this player dropped the item and cooldown hasn't expired
|
||||
if body.has_method("get_multiplayer_authority"):
|
||||
@@ -465,7 +466,6 @@ func _pickup(player: Node):
|
||||
func _process_pickup_on_server(player: Node):
|
||||
# Internal function to process pickup on server (called from _request_pickup RPC)
|
||||
# This skips the authority check since we've already validated the request
|
||||
|
||||
# Mark as collected immediately to prevent duplicate pickups
|
||||
# (Note: This may already be set by _request_pickup, but set it here too for safety)
|
||||
if not collected:
|
||||
@@ -624,16 +624,30 @@ func _process_pickup_on_server(player: Node):
|
||||
player.character_stats.add_item(item)
|
||||
print(name, " picked up item: ", item.item_name, " (added to inventory)")
|
||||
|
||||
# Sync inventory+equipment to joiner (server added to their copy; joiner's client must apply)
|
||||
if multiplayer.has_multiplayer_peer() and multiplayer.is_server():
|
||||
var owner_id = player.get_multiplayer_authority()
|
||||
if owner_id != 1 and owner_id != multiplayer.get_unique_id():
|
||||
var inv_data: Array = []
|
||||
for inv_item in player.character_stats.inventory:
|
||||
inv_data.append(inv_item.save() if inv_item else null)
|
||||
var equip_data: Dictionary = {}
|
||||
for slot_name in player.character_stats.equipment.keys():
|
||||
var eq = player.character_stats.equipment[slot_name]
|
||||
equip_data[slot_name] = eq.save() if eq else null
|
||||
if player.has_method("_apply_inventory_and_equipment_from_server"):
|
||||
player._apply_inventory_and_equipment_from_server.rpc_id(owner_id, inv_data, equip_data)
|
||||
|
||||
# Show floating text with item name (uppercase)
|
||||
var items_texture = load(item.spritePath)
|
||||
var display_text = item.item_name.to_upper() # Always uppercase
|
||||
var display_text = item.item_name.to_upper() # Always uppercase
|
||||
var text_color = Color.WHITE
|
||||
|
||||
# Color code based on item type
|
||||
if item.item_type == Item.ItemType.Equippable:
|
||||
text_color = Color.CYAN # Cyan for equipment
|
||||
text_color = Color.CYAN # Cyan for equipment
|
||||
elif item.item_type == Item.ItemType.Restoration:
|
||||
text_color = Color.GREEN # Green for consumables
|
||||
text_color = Color.GREEN # Green for consumables
|
||||
|
||||
_show_floating_text(player, display_text, text_color, 0.5, 0.5, items_texture, item.spriteFrames.x, item.spriteFrames.y, item.spriteFrame)
|
||||
|
||||
@@ -650,7 +664,7 @@ func _process_pickup_on_server(player: Node):
|
||||
await sfx_loot_collect.finished
|
||||
queue_free()
|
||||
|
||||
var processing_pickup: bool = false # Mutex to prevent concurrent pickup processing
|
||||
var processing_pickup: bool = false # Mutex to prevent concurrent pickup processing
|
||||
|
||||
@rpc("any_peer", "reliable")
|
||||
func _request_pickup(player_peer_id: int):
|
||||
@@ -666,7 +680,7 @@ func _request_pickup(player_peer_id: int):
|
||||
var dropped_by_peer_id = get_meta("dropped_by_peer_id")
|
||||
var drop_time = get_meta("drop_time")
|
||||
var current_time = Time.get_ticks_msec()
|
||||
var time_since_drop = (current_time - drop_time) / 1000.0 # Convert to seconds
|
||||
var time_since_drop = (current_time - drop_time) / 1000.0 # Convert to seconds
|
||||
|
||||
if player_peer_id == dropped_by_peer_id and time_since_drop < 5.0:
|
||||
# Player can't pick up their own dropped item for 5 seconds
|
||||
@@ -719,7 +733,7 @@ func _sync_remove():
|
||||
# Clients remove loot when any player picks it up
|
||||
# Only process if we're not the authority (i.e., we're a client)
|
||||
if multiplayer.is_server():
|
||||
return # Server ignores its own updates
|
||||
return # Server ignores its own updates
|
||||
|
||||
print("Loot: Client received removal sync for loot at ", global_position)
|
||||
|
||||
@@ -760,7 +774,7 @@ func _sync_remove():
|
||||
func _sync_show_floating_text(loot_type_value: int, text: String, color_value: Color, _value: int, sprite_frame_value: int, player_peer_id: int):
|
||||
# Client receives floating text sync from server
|
||||
if multiplayer.is_server():
|
||||
return # Server ignores this (it's the sender)
|
||||
return # Server ignores this (it's the sender)
|
||||
|
||||
# Find player by peer ID
|
||||
var player = null
|
||||
@@ -771,7 +785,7 @@ func _sync_show_floating_text(loot_type_value: int, text: String, color_value: C
|
||||
break
|
||||
|
||||
if not player or not is_instance_valid(player):
|
||||
return # Can't find player
|
||||
return # Can't find player
|
||||
|
||||
# Determine texture and parameters based on loot type
|
||||
var item_texture: Texture2D = null
|
||||
|
||||
Reference in New Issue
Block a user