core gameplay in! scavenging working!
This commit is contained in:
parent
c6a6171a81
commit
b773e224c0
5 changed files with 38 additions and 4 deletions
5
crafting/rollableLoot.gd
Normal file
5
crafting/rollableLoot.gd
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
extends Resource
|
||||||
|
class_name RollableLoot
|
||||||
|
|
||||||
|
@export var item : ItemData
|
||||||
|
@export var chance : int
|
||||||
1
crafting/rollableLoot.gd.uid
Normal file
1
crafting/rollableLoot.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://oa5rlx6ttwuj
|
||||||
|
|
@ -3,4 +3,17 @@ class_name ScavengeRecipe
|
||||||
|
|
||||||
@export var input : ItemData
|
@export var input : ItemData
|
||||||
@export var rolls : int = 3
|
@export var rolls : int = 3
|
||||||
@export var loot_pool : Dictionary[int, ItemData]
|
@export var loot_pool : Array[RollableLoot]
|
||||||
|
|
||||||
|
func roll() -> ItemData:
|
||||||
|
var selected : ItemData
|
||||||
|
var total_chance : int = 0
|
||||||
|
for loot in loot_pool:
|
||||||
|
total_chance += loot.chance
|
||||||
|
var sel_chance : int = randi() % total_chance
|
||||||
|
for loot in loot_pool:
|
||||||
|
if sel_chance >= 0:
|
||||||
|
selected = loot.item
|
||||||
|
sel_chance -= loot.chance
|
||||||
|
|
||||||
|
return selected
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,19 @@
|
||||||
[gd_resource type="Resource" script_class="ScavengeRecipe" load_steps=4 format=3 uid="uid://deohei5avmspt"]
|
[gd_resource type="Resource" script_class="ScavengeRecipe" load_steps=6 format=3 uid="uid://deohei5avmspt"]
|
||||||
|
|
||||||
[ext_resource type="Resource" uid="uid://88v5bcyrgpob" path="res://items/large_psu_item.tres" id="1_20hhf"]
|
[ext_resource type="Resource" uid="uid://88v5bcyrgpob" path="res://items/large_psu_item.tres" id="1_20hhf"]
|
||||||
[ext_resource type="Script" uid="uid://dccraom7a7e8d" path="res://inv_system/item_data.gd" id="1_o2l1m"]
|
|
||||||
[ext_resource type="Script" uid="uid://boqr1fowaqmt0" path="res://crafting/scavenge_recipe.gd" id="2_20hhf"]
|
[ext_resource type="Script" uid="uid://boqr1fowaqmt0" path="res://crafting/scavenge_recipe.gd" id="2_20hhf"]
|
||||||
|
[ext_resource type="Script" uid="uid://oa5rlx6ttwuj" path="res://crafting/rollableLoot.gd" id="2_i5wfm"]
|
||||||
|
[ext_resource type="Resource" uid="uid://swd1m0hvep4c" path="res://items/small_psu_item.tres" id="3_svciw"]
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_rhaxb"]
|
||||||
|
script = ExtResource("2_i5wfm")
|
||||||
|
item = ExtResource("3_svciw")
|
||||||
|
chance = 1
|
||||||
|
metadata/_custom_type_script = "uid://oa5rlx6ttwuj"
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("2_20hhf")
|
script = ExtResource("2_20hhf")
|
||||||
input = ExtResource("1_20hhf")
|
input = ExtResource("1_20hhf")
|
||||||
|
rolls = 2
|
||||||
|
loot_pool = Array[ExtResource("2_i5wfm")]([SubResource("Resource_rhaxb")])
|
||||||
metadata/_custom_type_script = "uid://boqr1fowaqmt0"
|
metadata/_custom_type_script = "uid://boqr1fowaqmt0"
|
||||||
|
|
|
||||||
|
|
@ -94,10 +94,16 @@ func style_none():
|
||||||
func _on_action_button_pressed() -> void:
|
func _on_action_button_pressed() -> void:
|
||||||
if not matched_recipe:
|
if not matched_recipe:
|
||||||
return
|
return
|
||||||
if matched_recipe is CraftRecipe:
|
elif matched_recipe is CraftRecipe:
|
||||||
var crafting : CraftRecipe = matched_recipe
|
var crafting : CraftRecipe = matched_recipe
|
||||||
empty_grid()
|
empty_grid()
|
||||||
add_item(crafting.output)
|
add_item(crafting.output)
|
||||||
|
check_recipes()
|
||||||
|
elif matched_recipe is ScavengeRecipe:
|
||||||
|
empty_grid()
|
||||||
|
for x in range(matched_recipe.rolls):
|
||||||
|
add_item(matched_recipe.roll())
|
||||||
|
check_recipes()
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
func empty_grid():
|
func empty_grid():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue