Zmiany
This commit is contained in:
parent
8e90447486
commit
f4a6efe74f
@ -47,7 +47,11 @@ func can_combine(other: ItemAffixDefinition) -> bool:
|
||||
)
|
||||
|
||||
func roll_value(level: int) -> float:
|
||||
var bounds := get_value_range(level)
|
||||
return randf_range(bounds.x, bounds.y)
|
||||
|
||||
func get_value_range(level: int) -> Vector2:
|
||||
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))
|
||||
return Vector2(minf(lower, upper), maxf(lower, upper))
|
||||
|
||||
@ -5,6 +5,18 @@ class_name ItemStatModifier
|
||||
@export var value: float = 0.0
|
||||
@export var affix: ItemAffixDefinition
|
||||
|
||||
# Fixed-value affixes and legacy modifiers have no roll quality to highlight.
|
||||
func get_roll_quality(level: int) -> int:
|
||||
if affix == null:
|
||||
return 0
|
||||
var bounds := affix.get_value_range(level)
|
||||
if is_equal_approx(bounds.x, bounds.y):
|
||||
return 0
|
||||
var fraction := clampf((value - bounds.x) / (bounds.y - bounds.x), 0.0, 1.0)
|
||||
if fraction >= 0.9 - 0.000001:
|
||||
return 2
|
||||
return 1 if fraction >= 0.75 - 0.000001 else 0
|
||||
|
||||
func get_display_text() -> String:
|
||||
var label := affix.display_name if affix else ItemInstance.stat_name(stat_key)
|
||||
var suffix := affix.unit if affix else ("%" if stat_key.ends_with("_percent") else "/s")
|
||||
|
||||
@ -8,7 +8,7 @@ const CARGO_SIZE := 20
|
||||
const WEAPON_SLOT_COUNT := 3
|
||||
const MISSILE_SLOT := 2
|
||||
const STARTING_MISSILE_AMMUNITION := 2
|
||||
const MISSILE_CRAFT_PARTS_COST := 50.0
|
||||
const MISSILE_CRAFT_PARTS_COST := 20.0
|
||||
const MISSILE_BUY_BASE_COST := 10
|
||||
const MISSILE_DEFINITIONS := [preload("res://resources/items/missile_launcher.tres"), preload("res://resources/items/unguided_missile.tres")]
|
||||
const MODULE_SLOT_COUNT := 6
|
||||
|
||||
@ -124,16 +124,30 @@ func _make_custom_tooltip(for_text: String) -> Object:
|
||||
background.set_border_width_all(1)
|
||||
background.set_content_margin_all(12)
|
||||
panel.add_theme_stylebox_override("panel", background)
|
||||
var label := Label.new()
|
||||
label.text = for_text
|
||||
var label := RichTextLabel.new()
|
||||
label.fit_content = true
|
||||
label.scroll_active = false
|
||||
label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
label.custom_minimum_size.x = 330
|
||||
label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
label.add_theme_font_size_override("font_size", 13)
|
||||
label.add_theme_font_size_override("normal_font_size", 13)
|
||||
var item := _inventory.get_item(slot_kind, slot_index)
|
||||
if item:
|
||||
background.bg_color = item.get_background_color()
|
||||
background.border_color = item.get_type_color()
|
||||
label.add_theme_color_override("font_color", Color("f1f4f8"))
|
||||
label.add_theme_color_override("default_color", Color("f1f4f8"))
|
||||
for line in for_text.split("\n"):
|
||||
var quality := 0
|
||||
if item:
|
||||
for modifier in item.additional_modifiers:
|
||||
if modifier != null and line == modifier.get_display_text():
|
||||
quality = modifier.get_roll_quality(item.item_level)
|
||||
break
|
||||
if quality > 0:
|
||||
label.push_color(Color("ffd166") if quality == 2 else Color("79e6a0"))
|
||||
label.add_text(("★ " if quality == 2 else "") + line + "\n")
|
||||
if quality > 0:
|
||||
label.pop()
|
||||
panel.add_child(label)
|
||||
return panel
|
||||
|
||||
|
||||
@ -47,9 +47,9 @@ func _ready() -> void:
|
||||
weapons.set("missile_cooldown_remaining", 0.0)
|
||||
assert(not weapons.call("try_fire_missile"))
|
||||
assert(inventory.weapon_slots[2] == missile and ship.get("energy") == energy_before)
|
||||
GameState.captain.parts = 49.0
|
||||
GameState.captain.parts = 19.0
|
||||
assert(not inventory.craft_missile())
|
||||
GameState.captain.parts = 50.0
|
||||
GameState.captain.parts = 20.0
|
||||
assert(inventory.craft_missile() and GameState.captain.parts == 0.0)
|
||||
var unguided := ItemInstance.new()
|
||||
unguided.definition = ShipInventory.MISSILE_DEFINITIONS[1]
|
||||
@ -86,7 +86,7 @@ func _ready() -> void:
|
||||
if inventory.cargo[index] == null:
|
||||
inventory.cargo[index] = missile
|
||||
var ammo_before := inventory.missile_ammunition
|
||||
assert(inventory.craft_missile() and GameState.captain.parts == 50.0)
|
||||
assert(inventory.craft_missile() and GameState.captain.parts == 80.0)
|
||||
assert(inventory.buy_missile() and GameState.captain.credits == 70)
|
||||
assert(inventory.missile_ammunition == ammo_before + 2)
|
||||
addon.value = 100.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user