Unify XP progression and enable ability ranks

This commit is contained in:
dingo
2026-09-10 06:08:49 -04:00
parent 906a07ff66
commit ac695b3270
17 changed files with 313 additions and 43 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
version: 1
xpCurve: { base: 100, quadratic: 10 }
combatRules:
maxMobs: 512
maxProjectiles: 256
@@ -248,7 +249,7 @@ crafting:
- {"id": "recipe_component", "revision": 1, "name": "Building component", "description": "Starter building component recipe.", "profession": "builder", "level": 1, "xp": 20, "inputs": {"wood": 4, "ore": 1}, "outputs": {"building_component": 1}, "stats": {}, "titles": []}
# Milestone 7 provisional progression and resurrection tuning.
powers: {"weapons": [{"id": "blades", "name": "Blades", "description": "Blades proficiency", "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000}, {"id": "polearms", "name": "Polearms", "description": "Polearms proficiency", "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000}], "powers": [{"id": "arc_bolt", "name": "Arc bolt", "description": "Arc bolt", "kind": "spell", "attackId": "arc_bolt", "targeting": "target", "resurrection": false, "weapon": "", "weaponLevel": 1, "requirements": {"level": 1, "stats": {}, "titles": []}, "parents": {}, "book": true, "mana": 5, "castSeconds": 0.5, "cooldown": 2, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000, "basePower": 10}, {"id": "mend", "name": "Mend", "description": "Mend", "kind": "spell", "attackId": "mend", "targeting": "target", "resurrection": false, "weapon": "", "weaponLevel": 1, "requirements": {"level": 1, "stats": {}, "titles": []}, "parents": {}, "book": true, "mana": 5, "castSeconds": 0, "cooldown": 2, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000, "basePower": 10}, {"id": "renewal", "name": "Renewal aura", "description": "Renewal aura", "kind": "spell", "attackId": "renewal_aura", "targeting": "aura", "resurrection": false, "weapon": "", "weaponLevel": 1, "requirements": {"level": 1, "stats": {}, "titles": []}, "parents": {"mend": 2}, "book": false, "mana": 10, "castSeconds": 0, "cooldown": 10, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000, "basePower": 10}, {"id": "revive", "name": "Resurrection", "description": "Resurrection", "kind": "spell", "attackId": "", "targeting": "target", "resurrection": true, "weapon": "", "weaponLevel": 1, "requirements": {"level": 1, "stats": {}, "titles": []}, "parents": {}, "book": true, "mana": 20, "castSeconds": 0, "cooldown": 30, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000, "basePower": 0}, {"id": "cleave", "name": "Cleave", "description": "Cleave", "kind": "ability", "attackId": "cleave", "targeting": "target", "resurrection": false, "weapon": "blades", "weaponLevel": 2, "requirements": {"level": 1, "stats": {"strength": 2}, "titles": []}, "parents": {}, "book": false, "mana": 0, "castSeconds": 0, "cooldown": 2, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1, "basePower": 0}], "weaponXp": 10, "spellXp": 10, "revivalRange": 3, "revivalHealth": 0.25}
powers: {"weapons": [{"id": "blades", "name": "Blades", "description": "Blades proficiency", "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000}, {"id": "polearms", "name": "Polearms", "description": "Polearms proficiency", "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000}], "powers": [{"id": "arc_bolt", "name": "Arc bolt", "description": "Arc bolt", "kind": "spell", "attackId": "arc_bolt", "targeting": "target", "resurrection": false, "weapon": "", "weaponLevel": 1, "requirements": {"level": 1, "stats": {}, "titles": []}, "parents": {}, "book": true, "mana": 5, "castSeconds": 0.5, "cooldown": 2, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000, "basePower": 10}, {"id": "mend", "name": "Mend", "description": "Mend", "kind": "spell", "attackId": "mend", "targeting": "target", "resurrection": false, "weapon": "", "weaponLevel": 1, "requirements": {"level": 1, "stats": {}, "titles": []}, "parents": {}, "book": true, "mana": 5, "castSeconds": 0, "cooldown": 2, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000, "basePower": 10}, {"id": "renewal", "name": "Renewal aura", "description": "Renewal aura", "kind": "spell", "attackId": "renewal_aura", "targeting": "aura", "resurrection": false, "weapon": "", "weaponLevel": 1, "requirements": {"level": 1, "stats": {}, "titles": []}, "parents": {"mend": 2}, "book": false, "mana": 10, "castSeconds": 0, "cooldown": 10, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000, "basePower": 10}, {"id": "revive", "name": "Resurrection", "description": "Resurrection", "kind": "spell", "attackId": "", "targeting": "target", "resurrection": true, "weapon": "", "weaponLevel": 1, "requirements": {"level": 1, "stats": {}, "titles": []}, "parents": {}, "book": true, "mana": 20, "castSeconds": 0, "cooldown": 30, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000, "basePower": 0}, {"id": "cleave", "name": "Cleave", "description": "Cleave", "kind": "ability", "attackId": "cleave", "targeting": "target", "resurrection": false, "weapon": "blades", "weaponLevel": 2, "requirements": {"level": 1, "stats": {"strength": 2}, "titles": []}, "parents": {}, "book": false, "mana": 0, "castSeconds": 0, "cooldown": 2, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000, "basePower": 0}], "weaponXp": 10, "spellXp": 10, "revivalRange": 3, "revivalHealth": 0.25}
# Milestone 8a provisional structure limits and blueprints. Recipes are authored in Control.
building:
+6
View File
@@ -19,6 +19,7 @@ type Recipe struct {
}
type Balance struct {
XPCurve *XPCurve `yaml:"xpCurve"`
Housing *HousingRules `yaml:"housing"`
Building *BuildingContent `yaml:"building"`
Powers *PowerContent `yaml:"powers"`
@@ -84,6 +85,11 @@ func Parse(data []byte) (Balance, error) {
return b, b.Validate()
}
func (b Balance) Validate() error {
if b.XPCurve != nil {
if e := b.XPCurve.Validate(); e != nil {
return e
}
}
if b.Housing != nil {
if e := b.Housing.Validate(); e != nil {
return e
+1 -1
View File
@@ -72,7 +72,7 @@ func (r CraftRules) Loss(level int64) float64 {
func SkillLevel(s GatheringSkill, xp int64) (int64, int64) {
level := int64(1)
for level < s.MaxLevel {
need := s.BaseXP + (level-1)*s.XPPerLevel
need := XPForLevel(level + 1)
if xp < need {
return level, need - xp
}
+65
View File
@@ -0,0 +1,65 @@
package content
import (
"fmt"
"go.yaml.in/yaml/v3"
"sync"
)
type XPCurve struct {
Base int64 `yaml:"base"`
Quadratic int64 `yaml:"quadratic"`
}
func (x XPCurve) Validate() error {
if x.Base != 100 || x.Quadratic != 10 {
return fmt.Errorf("XP curve must be 100 + 10(L-2)^2")
}
return nil
}
// This global gameplay rule applies to existing worlds and copied definitions too.
// Read its tuning once from the embedded balance instead of a character's legacy curve.
var currentXPCurve = sync.OnceValue(func() XPCurve {
var b struct {
XP XPCurve `yaml:"xpCurve"`
}
if e := yaml.Unmarshal(balance, &b); e != nil {
panic(e)
}
if e := b.XP.Validate(); e != nil {
panic(e)
}
return b.XP
})
func XPForLevel(target int64) int64 {
x := currentXPCurve()
n := max(int64(0), min(target, int64(10000))-2)
return x.Base + x.Quadratic*n*n
}
func RebaseLevelXP(xp, oldCost, newCost int64) int64 {
return min(newCost-1, int64(float64(xp)/float64(oldCost)*float64(newCost)))
}
// Rebase legacy total XP without taking away levels or granting migration rewards.
func RebaseSkillXP(s GatheringSkill, xp int64) int64 {
level := int64(1)
for level < s.MaxLevel {
cost := s.BaseXP + (level-1)*s.XPPerLevel
if xp < cost {
break
}
xp -= cost
level++
}
total := int64(0)
for l := int64(2); l <= level; l++ {
total += XPForLevel(l)
}
if level < s.MaxLevel {
total += RebaseLevelXP(xp, s.BaseXP+(level-1)*s.XPPerLevel, XPForLevel(level+1))
}
return total
}