-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
De-couple the "core" functionality from the "Dimensionfall" mod #506
Comments
Here's the details on "athletics": The "athletics" skill in this script primarily influences movement and stamina-related functionalities. Its level affects the player's ability to run faster, lose less stamina while running, and regenerate stamina more efficiently when stationary. Here's a breakdown of its functions within the script: 1. Stamina Management
2. Run Speed
3. XP Gain
4. Skill Level Integration
Summary of Role in the ScriptThe "athletics" skill dynamically enhances the player's performance by:
This functionality makes "athletics" a critical skill for gameplay elements involving movement, stamina management, and player endurance during exploration or combat. |
I'd like to separate the functionality from the skill. If we have:
If we had these variables, we could then allow a modder to tie those to a skill called "athletics" or any other skill, even items maybe. However, then there's still the "stamina" component. If possible, I'd like to break it down even further. |
The suggestion from Chatgpt: To achieve a modular and extensible system that separates functionality from the "athletics" skill, we can introduce a framework for modifiers and attributes that can be dynamically tied to skills, items, or other gameplay elements. Here's a breakdown of how this could be implemented: Proposed Breakdown
Implementation Steps1. Define ModifiersAdd new variables to manage the modifiers independently: var run_speed_modifier = 1.0
var stamina_regeneration_modifier = 1.0
var stamina_loss_modifier = 1.0 2. Create StaminaManagerEncapsulate stamina logic in a separate class. This class will handle all stamina-related calculations and apply the modifiers: class_name StaminaManager
extends Object
signal stamina_changed(new_stamina)
var max_stamina = 100
var current_stamina = max_stamina
var regeneration_rate = 3.0 # Base regeneration rate
var loss_rate = 15.0 # Base loss rate
func modify_stamina(amount: float) -> void:
current_stamina = clamp(current_stamina + amount, 0, max_stamina)
emit_signal("stamina_changed", current_stamina)
func regenerate_stamina(delta: float, modifier: float) -> void:
modify_stamina(delta * regeneration_rate * modifier)
func deplete_stamina(delta: float, modifier: float) -> void:
modify_stamina(-delta * loss_rate * modifier) 3. Integrate Modifiers into MovementUpdate func _physics_process(delta):
# Movement direction
var input_dir = Input.get_vector("left", "right", "up", "down")
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if is_running and stamina_manager.current_stamina > 0:
velocity = direction * speed * run_speed_modifier
stamina_manager.deplete_stamina(delta, stamina_loss_modifier)
else:
velocity = direction * speed
if velocity.length() < 0.1:
stamina_manager.regenerate_stamina(delta, stamina_regeneration_modifier)
move_and_slide() 4. Dynamic Modifier SourcesIntroduce a generic modifier system that can dynamically adjust the modifiers: var modifiers = {
"run_speed": [],
"stamina_regeneration": [],
"stamina_loss": []
}
# Add a new modifier
func add_modifier(modifier_type: String, value: float) -> void:
if modifiers.has(modifier_type):
modifiers[modifier_type].append(value)
_recalculate_modifier(modifier_type)
# Remove a modifier
func remove_modifier(modifier_type: String, value: float) -> void:
if modifiers.has(modifier_type) and value in modifiers[modifier_type]:
modifiers[modifier_type].erase(value)
_recalculate_modifier(modifier_type)
# Recalculate a modifier
func _recalculate_modifier(modifier_type: String) -> void:
match modifier_type:
"run_speed":
run_speed_modifier = 1.0 + sum(modifiers["run_speed"])
"stamina_regeneration":
stamina_regeneration_modifier = 1.0 + sum(modifiers["stamina_regeneration"])
"stamina_loss":
stamina_loss_modifier = 1.0 + sum(modifiers["stamina_loss"]) 5. Tie Modifiers to Skills or ItemsLink modifiers to the skill system (e.g., "athletics") or items: func update_skill_modifiers(skill_id: String, level: int) -> void:
if skill_id == "athletics":
remove_modifier("run_speed", run_speed_modifier - 1.0)
remove_modifier("stamina_regeneration", stamina_regeneration_modifier - 1.0)
remove_modifier("stamina_loss", stamina_loss_modifier - 1.0)
# Apply new modifiers based on skill level
add_modifier("run_speed", level * 0.01)
add_modifier("stamina_regeneration", level * 0.05)
add_modifier("stamina_loss", -level * 0.05) # Reduces stamina loss 6. HUD UpdatesEmit signals from the stamina_manager.connect("stamina_changed", self, "_on_stamina_changed")
func _on_stamina_changed(new_stamina: float):
update_stamina_HUD.emit(new_stamina) Benefits of This System
Would you like examples of tying items or events to this system? |
But then what if the stamina manager was a playerattribute called "stamina" instead? We'd need some kind of pool to drain from and some mechanic to determine what amount. If no pool called stamina is available, then the player will be unable to sprint. |
In order to facilitate overhaul mods, we should provide a bare-minimum of functionality that we can then extend using mods.
This requires the implementation of mod functionality and is going to take a while.
To resolve this issue:
Here is the start of the list, please add on to it if you know any:
Skills:
Maps:
The starting inventory items are listed in the
ItemManager
and are part of theCore
modThe text was updated successfully, but these errors were encountered: