From 68b7c1a298d112d3002e6b94fa07f9d7de2b22d1 Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 17 Sep 2025 12:17:32 +0200 Subject: [PATCH] Added ItemSpawn --- buildings/Building 1x2 fixed.png.import | 6 ++++ buildings/Building 2x1 downside.png.import | 6 ++++ buildings/Building 2x1 fixed.png.import | 6 ++++ items/item_spawn.gd | 34 ++++++++++++++++++++++ items/item_spawn.gd.uid | 1 + items/item_spawn.tscn | 7 +++++ player/Player_Walk/Walk 1.png.import | 6 ++++ player/Player_Walk/Walk 2.png.import | 6 ++++ player/Player_Walk/Walk 3.png.import | 6 ++++ player/Player_Walk/Walk 4.png.import | 6 ++++ player/Player_Walk/Walk 5.png.import | 6 ++++ player/Player_Walk/Walk 6.png.import | 6 ++++ project.godot | 2 +- 13 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 items/item_spawn.gd create mode 100644 items/item_spawn.gd.uid create mode 100644 items/item_spawn.tscn diff --git a/buildings/Building 1x2 fixed.png.import b/buildings/Building 1x2 fixed.png.import index 0ac93ca..39a81c9 100644 --- a/buildings/Building 1x2 fixed.png.import +++ b/buildings/Building 1x2 fixed.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Building 1x2 fixed.png-e90afc0d25a8919ada5700 compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false diff --git a/buildings/Building 2x1 downside.png.import b/buildings/Building 2x1 downside.png.import index 52d9ce5..0e57d53 100644 --- a/buildings/Building 2x1 downside.png.import +++ b/buildings/Building 2x1 downside.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Building 2x1 downside.png-4b432eb4152bab7dd59 compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false diff --git a/buildings/Building 2x1 fixed.png.import b/buildings/Building 2x1 fixed.png.import index a78eae3..e7fdbe6 100644 --- a/buildings/Building 2x1 fixed.png.import +++ b/buildings/Building 2x1 fixed.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Building 2x1 fixed.png-b02748fa52aebae62f987c compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false diff --git a/items/item_spawn.gd b/items/item_spawn.gd new file mode 100644 index 0000000..fb093b8 --- /dev/null +++ b/items/item_spawn.gd @@ -0,0 +1,34 @@ +class_name ItemSpawn extends Node2D + +@export var common_items : Array[PackedScene] +@export var rare_items : Array[PackedScene] +@export var unique_items : Array[PackedScene] + +@export var rarity_bonus = 0 +@export var guarantee_rare : bool = false + +@export var unique_base_chance = .05 +@export var rare_base_chance = .2 +@export var unique_bonus_multiplier = .025 +@export var rare_bonus_multiplier = .1 + +var remove_after_spawn = false + +func choose_pool(): + var unique_chance = unique_base_chance + unique_bonus_multiplier * rarity_bonus + var rare_chance = unique_base_chance + unique_bonus_multiplier * rarity_bonus + + var random = randf() + if random < unique_chance: + remove_after_spawn = true + return unique_items + elif random < unique_chance + rare_chance || guarantee_rare: + return rare_items + +func _ready(): + var pool = choose_pool() + var index = randi_range(0, pool.size() - 1) + var packed_scene : PackedScene = pool[index] + pool.remove_at(index) + add_sibling(packed_scene.instantiate()) + diff --git a/items/item_spawn.gd.uid b/items/item_spawn.gd.uid new file mode 100644 index 0000000..fbdc0ee --- /dev/null +++ b/items/item_spawn.gd.uid @@ -0,0 +1 @@ +uid://b8em61mqgdi58 diff --git a/items/item_spawn.tscn b/items/item_spawn.tscn new file mode 100644 index 0000000..2951808 --- /dev/null +++ b/items/item_spawn.tscn @@ -0,0 +1,7 @@ +[gd_scene load_steps=2 format=3 uid="uid://xj0of571aur1"] + +[ext_resource type="Script" uid="uid://b8em61mqgdi58" path="res://items/item_spawn.gd" id="1_ms6tn"] + +[node name="ItemSpawn" type="Node2D"] +script = ExtResource("1_ms6tn") +metadata/_custom_type_script = "uid://b8em61mqgdi58" diff --git a/player/Player_Walk/Walk 1.png.import b/player/Player_Walk/Walk 1.png.import index 97cf918..7803358 100644 --- a/player/Player_Walk/Walk 1.png.import +++ b/player/Player_Walk/Walk 1.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Walk 1.png-47c623e9d3540b4a00d2bddf52ae0b2a.c compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false diff --git a/player/Player_Walk/Walk 2.png.import b/player/Player_Walk/Walk 2.png.import index 48f18ef..3fac54f 100644 --- a/player/Player_Walk/Walk 2.png.import +++ b/player/Player_Walk/Walk 2.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Walk 2.png-5dea4fdec55fa43e26680e08090fd654.c compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false diff --git a/player/Player_Walk/Walk 3.png.import b/player/Player_Walk/Walk 3.png.import index 285ace3..c65053d 100644 --- a/player/Player_Walk/Walk 3.png.import +++ b/player/Player_Walk/Walk 3.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Walk 3.png-27890c0cb512383b8ecbd848c73efee1.c compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false diff --git a/player/Player_Walk/Walk 4.png.import b/player/Player_Walk/Walk 4.png.import index 03aa90d..c12f6b8 100644 --- a/player/Player_Walk/Walk 4.png.import +++ b/player/Player_Walk/Walk 4.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Walk 4.png-232b1eae2acf3ad82130431014262cde.c compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false diff --git a/player/Player_Walk/Walk 5.png.import b/player/Player_Walk/Walk 5.png.import index fe3ebef..47122be 100644 --- a/player/Player_Walk/Walk 5.png.import +++ b/player/Player_Walk/Walk 5.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Walk 5.png-cfb8eb15ace876127c083283fe74cdc0.c compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false diff --git a/player/Player_Walk/Walk 6.png.import b/player/Player_Walk/Walk 6.png.import index 22d7868..5b2bdef 100644 --- a/player/Player_Walk/Walk 6.png.import +++ b/player/Player_Walk/Walk 6.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Walk 6.png-f243f98e182be67eb8681a11d34ee554.c compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false diff --git a/project.godot b/project.godot index 4184826..035e24c 100644 --- a/project.godot +++ b/project.godot @@ -12,7 +12,7 @@ config_version=5 config/name="The Dark Side of Earth" run/main_scene="uid://cxo6bq26huau7" -config/features=PackedStringArray("4.4", "Forward Plus") +config/features=PackedStringArray("4.5", "Forward Plus") config/icon="res://icon.svg" [display]