Expand fish catalog and add bait system

This commit is contained in:
Alexander Sellite 2026-08-06 01:00:52 -04:00
parent 43f57e56a0
commit 954042fd1d
134 changed files with 3134 additions and 127 deletions

View file

@ -69,6 +69,8 @@ var _reel_input_held: bool = false
var _reel_speed: float = 0.0
var _click_power: int = 1
var _fish_quality: int = FishQualityType.Tier.BORING
var _fish_rarity: int = 0
var _fish_weight_percentile: float = 0.0
var _chase_delay_remaining: float = 0.0
var _failure_epsilon: float = 0.0001
var _auto_click_accumulator: float = 0.0
@ -111,6 +113,8 @@ func start_encounter(
reel_speed: float,
click_power: int,
fish_quality: int = FishQualityType.Tier.BORING,
fish_rarity: int = 0,
fish_weight_percentile: float = 0.0,
) -> void:
reset()
if profile == null:
@ -124,6 +128,8 @@ func start_encounter(
if FishQualityType.is_valid(fish_quality)
else FishQualityType.Tier.BORING
)
_fish_rarity = clampi(fish_rarity, 0, 4)
_fish_weight_percentile = clampf(fish_weight_percentile, 0.0, 1.0)
_chase_delay_remaining = CHASE_START_DELAY
chase_progress = -CHASE_START_OFFSET
_seed_encounter_rng()
@ -139,12 +145,21 @@ func start_authoritative_encounter(
click_power: int,
seed: int,
fish_quality: int = FishQualityType.Tier.BORING,
fish_rarity: int = 0,
fish_weight_percentile: float = 0.0,
) -> void:
var previous_test_mode: bool = use_deterministic_test_seed
var previous_seed: int = deterministic_test_seed
use_deterministic_test_seed = true
deterministic_test_seed = seed
start_encounter(profile, reel_speed, click_power, fish_quality)
start_encounter(
profile,
reel_speed,
click_power,
fish_quality,
fish_rarity,
fish_weight_percentile,
)
use_deterministic_test_seed = previous_test_mode
deterministic_test_seed = previous_seed
@ -289,7 +304,6 @@ func _seed_encounter_rng() -> void:
func _generate_barriers(profile: CatchDifficultyProfileType) -> void:
var count_range: Vector2i = profile.get_barrier_count_range()
var health_range: Vector2i = profile.get_barrier_health_range()
var interval: Vector2 = profile.get_generation_interval()
var spacing: float = maxf(profile.minimum_barrier_spacing, 0.01)
var available_distance: float = maxf(interval.y - interval.x, 0.0)
@ -313,13 +327,11 @@ func _generate_barriers(profile: CatchDifficultyProfileType) -> void:
+ spacing * float(barrier_index)
+ random_offsets[barrier_index] * random_slack
)
var base_health: int = _rng.randi_range(
health_range.x,
health_range.y,
)
var health: int = FishQualityType.apply_barrier_health(
base_health,
var health: int = FishQualityType.barrier_health_for_catch(
_fish_quality,
_fish_rarity,
_fish_weight_percentile,
_rng.randf_range(0.9, 1.1),
)
_barriers.append(Barrier.new(position, health))

View file

@ -95,7 +95,7 @@ enum FishingState {
@export_range(0.01, 0.5, 0.01) var solid_bobber_clearance: float = 0.13
@export_category("Withdrawal")
@export_range(0.1, 20.0, 0.1) var withdrawal_rate: float = 4.9
@export_range(0.1, 20.0, 0.1) var withdrawal_rate: float = 2.45
@export_range(0.1, 10.0, 0.1) var withdrawal_cancel_distance: float = 1.0
@export_range(0.0, 1.0, 0.01) var withdrawal_surface_clearance: float = 0.4
@ -787,6 +787,7 @@ func _on_cast_completed() -> void:
if _selected_fish == null:
_cleanup_attempt("nothing is biting here.", &"invalid")
return
_consume_active_bait()
state = FishingState.WAITING_FOR_BITE
_state_time_remaining = roll_bite_wait_time() * (
@ -808,6 +809,13 @@ func _on_cast_completed() -> void:
status_changed.emit("waiting for a bite...")
func _consume_active_bait() -> void:
if _active_player == null or _active_player.active_bait_id.is_empty():
return
if _local_bag == null or not _local_bag.remove_item(_active_player.active_bait_id, 1):
_active_player.unequip_bait()
func roll_bite_wait_time() -> float:
var bucket: float = _bite_rng.randf()
if bucket < BITE_QUICK_PROBABILITY:
@ -960,6 +968,8 @@ func _activate_bite() -> void:
_get_effective_reel_speed(),
_get_effective_barrier_damage(),
_pending_catch.quality,
int(_pending_catch.fish.rarity),
_pending_catch.fish.get_weight_percentile(_pending_catch.weight_lb),
)
_catch_controller.set_reel_input(
Input.is_action_pressed("fish_primary")
@ -1368,7 +1378,7 @@ func _build_fishing_context(
context.location_tags = region.location_tags.duplicate()
context.water_type = region.water_type
context.active_event_tags = context_event_tags.duplicate()
context.active_bait_tags = context_bait_tags.duplicate()
context.active_bait_tags = _get_active_bait_tags()
if _world_time != null:
context.is_night = _world_time.is_night_period()
context.is_day_night_transition = _world_time.is_transition()
@ -1384,6 +1394,16 @@ func build_network_context(
return _build_fishing_context(region)
func _get_active_bait_tags() -> Array[StringName]:
if _local_player == null or _item_catalog == null:
return []
var bait_id: StringName = _local_player.active_bait_id
if bait_id.is_empty() or _local_bag == null or not _local_bag.owns_item(bait_id):
return []
var item: ItemDataType = _item_catalog.get_item_by_id(bait_id)
return item.bait_tags.duplicate() if item != null and item.is_bait() else []
func _build_network_evidence() -> Dictionary:
var rarity_multipliers: Array[float] = []
for rarity: int in range(FishDataType.Rarity.size()):
@ -1394,6 +1414,7 @@ func _build_network_evidence() -> Dictionary:
discovered_ids.append(str(fish_id))
var item: ItemDataType = _get_active_item()
return {
"bait_id": str(_active_player.active_bait_id),
"rod_id": str(item.item_id) if item != null else "",
"reel_speed": _active_player.reel_speed * (
_fishing_upgrades.get_reel_speed_multiplier()