Added rpg system for combat
added lots of loot to find added level up system
This commit is contained in:
@@ -279,6 +279,19 @@ func _break_into_pieces():
|
||||
$Shadow.visible = false
|
||||
$Sprite2DAbove.visible = false
|
||||
$Sprite2D.visible = false
|
||||
|
||||
# Spawn item loot when breaking (30% chance)
|
||||
if is_multiplayer_authority():
|
||||
var drop_chance = randf()
|
||||
if drop_chance < 0.3: # 30% chance to drop item
|
||||
var item = ItemDatabase.get_random_container_item()
|
||||
if item:
|
||||
var entities_node = get_parent()
|
||||
var game_world = get_tree().get_first_node_in_group("game_world")
|
||||
if entities_node and game_world:
|
||||
ItemLootHelper.spawn_item_loot(item, global_position, entities_node, game_world)
|
||||
print(name, " dropped item: ", item.item_name, " when broken")
|
||||
|
||||
if ($SfxShatter.playing):
|
||||
await $SfxShatter.finished
|
||||
if ($SfxBreakCrate.playing):
|
||||
@@ -562,13 +575,13 @@ func _open_chest(by_player: Node = null):
|
||||
$SfxChestOpen.play()
|
||||
|
||||
print(name, " opened by ", by_player.name, "! Item given: ", selected_loot.name)
|
||||
|
||||
# Sync chest opening visual to all clients (item already given on server)
|
||||
if multiplayer.has_multiplayer_peer():
|
||||
var player_peer_id = by_player.get_multiplayer_authority() if by_player else 0
|
||||
_sync_chest_open.rpc(selected_loot.type if by_player else "coin", player_peer_id)
|
||||
else:
|
||||
push_error("Chest: ERROR - No valid player to give item to!")
|
||||
|
||||
# Sync chest opening visual to all clients (item already given on server)
|
||||
if multiplayer.has_multiplayer_peer():
|
||||
var player_peer_id = by_player.get_multiplayer_authority() if by_player else 0
|
||||
_sync_chest_open.rpc(selected_loot.type if by_player else "coin", player_peer_id)
|
||||
|
||||
@rpc("any_peer", "reliable")
|
||||
func _request_chest_open(player_peer_id: int):
|
||||
|
||||
Reference in New Issue
Block a user