Restricted Petal Spawns to unique items

This commit is contained in:
RealMelwei 2025-10-17 12:57:41 +02:00
parent 07b5114f23
commit 8f2a1146f0
2 changed files with 7 additions and 5 deletions

View file

@ -10,26 +10,25 @@ static var item_pool = ResourceLoader.load("res://items/generic/item_pool.tres",
@export var unique_bonus_multiplier = .05
@export var rare_bonus_multiplier = 0
@export var spawn_petal = true
@export var spawn_petal = false
@export var petal_scene : PackedScene = ResourceLoader.load("res://petal.tscn")
var remove_after_spawn = false
# Choose the item pool this spawn location draws from
func choose_pool() -> Array[PackedScene]:
#spawn_petal = false
var unique_chance = unique_base_chance + unique_bonus_multiplier * rarity_bonus
var rare_chance = rare_base_chance + rare_bonus_multiplier * rarity_bonus
var random = randf()
if random < unique_chance && item_pool.unique.size() > 0:
# Unique items are removed from the pool when picked
# Unique items are removed from the pool when picked and spawn a petal
remove_after_spawn = true
spawn_petal = true
return item_pool.unique
elif random < unique_chance + rare_chance || guarantee_rare:
return item_pool.rare
# If an item is common, no petal spawns
spawn_petal = false
return item_pool.common
# Places a petal holding this item

View file

@ -3,6 +3,7 @@ signal opened
var img_path
@export var depth : int
# Triggers when a bud is hit. Spreads the vine, then removes the bud
func _on_opened():
$AnimatedSprite2D.play("open")
opened.emit()
@ -10,11 +11,13 @@ func _on_opened():
await $AnimatedSprite2D.animation_finished
queue_free()
# Spread in all directions where the given vine is not yet present
func spread():
for dir in [Vector2.UP, Vector2.DOWN, Vector2.RIGHT, Vector2.LEFT]:
if not vine.vine_locations.has(Global.vec_mod(location + dir, Grid.num_collumns)):
grow_to_next_bud(dir)
# Grow a vine
func grow_to_next_bud(dir):
var target_offset = vine.random_offset()
var target = Global.vec_mod(location + dir, Grid.num_collumns)