game: add enemy mods

This commit is contained in:
2025-08-22 07:49:02 +02:00
parent 40d6162b95
commit 950d177936
14 changed files with 173 additions and 35 deletions

View File

@@ -3,13 +3,20 @@ extends Resource
enum ModType { ADDITIVE, MULTIPLICATIVE, ABSOLUTE, BOOL }
@export var mod_name: String
@export var mod_property: String
@export var mod_value: float
@export var mod_value_bool: bool = false
@export var mod_type: ModType = ModType.MULTIPLICATIVE
func get_calculated(enemy: EnemyBase, key: String) -> Variant:
assert(enemy.has_property(key), "tried to calculate property '%s' where base value does not exist on %s" % [key, enemy])
var adjective: String
static func get_calculated(enemy: EnemyBase, key: String) -> Variant:
assert(
enemy.has_property(key),
"tried to calculate property '%s' where base value does not exist on %s" % [key, enemy]
)
var base_value = enemy.get(key)
var add = 0.0
var mul = 1.0
@@ -17,11 +24,11 @@ func get_calculated(enemy: EnemyBase, key: String) -> Variant:
if mod.mod_property == key:
match mod.mod_type:
ModType.ADDITIVE:
add += mod.mod_value
add += mod.mod_value
ModType.MULTIPLICATIVE:
mul *= mod.mod_value
mul *= mod.mod_value
ModType.ABSOLUTE:
return mod.mod_value
return mod.mod_value
ModType.BOOL:
return mod.mod_value_bool
return mod.mod_value_bool
return (base_value + add) * mul