54 lines
2.2 KiB
GDScript
54 lines
2.2 KiB
GDScript
extends Resource
|
|
class_name ItemAffixDefinition
|
|
|
|
@export var affix_id: String = ""
|
|
@export var display_name: String = ""
|
|
@export_multiline var description: String = ""
|
|
@export var stat_key: String = ""
|
|
@export_enum("%", "pkt", "/s", "px/s", "s") var unit: String = "%"
|
|
@export var enabled: bool = true
|
|
@export_range(0.0, 1000.0, 0.1) var selection_weight: float = 1.0
|
|
|
|
@export_group("Dozwolone przedmioty")
|
|
@export_flags("Weapon", "Shield", "Hull", "Generator", "Extension", "Active extension") var category_mask: int = 63
|
|
# Empty means every item in the allowed categories.
|
|
@export var allowed_item_ids: PackedStringArray = PackedStringArray()
|
|
@export var excluded_item_ids: PackedStringArray = PackedStringArray()
|
|
|
|
@export_group("Zakres i skalowanie")
|
|
@export_range(1, 1000) var minimum_level: int = 1
|
|
@export_range(1, 1000) var maximum_level: int = 1000
|
|
@export var minimum_value_level_1: float = 1.0
|
|
@export var maximum_value_level_1: float = 3.0
|
|
@export var minimum_value_level_1000: float = 25.0
|
|
@export var maximum_value_level_1000: float = 50.0
|
|
|
|
@export_group("Zasady łączenia")
|
|
# At most one affix from a nonempty group can appear on the same item.
|
|
@export var exclusive_group: String = ""
|
|
@export var incompatible_affix_ids: PackedStringArray = PackedStringArray()
|
|
|
|
func can_roll(item: ItemDefinition, level: int) -> bool:
|
|
return (
|
|
enabled and selection_weight > 0.0 and not affix_id.is_empty()
|
|
and not stat_key.is_empty() and item != null
|
|
and level >= minimum_level and level <= maximum_level
|
|
and (category_mask & (1 << item.category)) != 0
|
|
and (allowed_item_ids.is_empty() or item.item_id in allowed_item_ids)
|
|
and item.item_id not in excluded_item_ids
|
|
)
|
|
|
|
func can_combine(other: ItemAffixDefinition) -> bool:
|
|
return (
|
|
affix_id != other.affix_id
|
|
and (exclusive_group.is_empty() or exclusive_group != other.exclusive_group)
|
|
and other.affix_id not in incompatible_affix_ids
|
|
and affix_id not in other.incompatible_affix_ids
|
|
)
|
|
|
|
func roll_value(level: int) -> float:
|
|
var progression := float(clampi(level, 1, 1000) - 1) / 999.0
|
|
var lower := lerpf(minimum_value_level_1, minimum_value_level_1000, progression)
|
|
var upper := lerpf(maximum_value_level_1, maximum_value_level_1000, progression)
|
|
return randf_range(minf(lower, upper), maxf(lower, upper))
|