Server-authoritative Godot 4.6 strategy game. Includes the headless WebSocket game server, the browser client, and Nix packaging (server and web-export derivations plus a NixOS module) for deployment.
24 lines
749 B
GDScript
24 lines
749 B
GDScript
class_name BuildingEffect
|
|
|
|
extends Resource
|
|
|
|
## One stat a building improves, and how it scales with the building's level.
|
|
## A building may carry several of these. The value contributed at a given
|
|
## level is base_value * level^exponent: exponent 1.0 is linear, below 1.0 is
|
|
## sublinear (diminishing returns), above 1.0 is superlinear.
|
|
|
|
## The stat this effect feeds. See the EFFECT_* constants on ProtoBuilding.
|
|
@export var stat : String = ""
|
|
|
|
## Value contributed at level 1.
|
|
@export var base_value : float = 0.0
|
|
|
|
## Level exponent. 1.0 = linear, 0.5 = square-root (sublinear).
|
|
@export_range(0.0, 2.0) var exponent : float = 1.0
|
|
|
|
|
|
func value_at(level: int) -> float:
|
|
if level <= 0:
|
|
return 0.0
|
|
return base_value * pow(float(level), exponent)
|