aboutsummaryrefslogtreecommitdiff
path: root/internal/game/sys_technology.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-07-01 22:30:31 -0400
committerhistoria <[not public]>2026-07-01 22:30:31 -0400
commitc14c2e403c75a913e1a6d962fb6fe64f013adae5 (patch)
tree75070293fe2535b594ac72e501cbf08a3f1146e0 /internal/game/sys_technology.go
parent8eec7b75ff9c8c368b252373db45fb891732d2ca (diff)
downloadthehouseoficarus-c14c2e403c75a913e1a6d962fb6fe64f013adae5.tar.gz
fix: combat formulas and mob attack types (mobs switch attack styles if safespotting)
Diffstat (limited to 'internal/game/sys_technology.go')
-rw-r--r--internal/game/sys_technology.go23
1 files changed, 12 insertions, 11 deletions
diff --git a/internal/game/sys_technology.go b/internal/game/sys_technology.go
index 9e6a635..c7214af 100644
--- a/internal/game/sys_technology.go
+++ b/internal/game/sys_technology.go
@@ -8,9 +8,9 @@ import (
"gopkg.in/yaml.v3"
"thehouseoficarus/internal/behavior"
+ "thehouseoficarus/internal/combat"
"thehouseoficarus/internal/net"
"thehouseoficarus/internal/player"
- "thehouseoficarus/internal/world"
)
type TechEffects struct {
@@ -44,8 +44,7 @@ var techByID map[string]*TechDef
func (g *Game) LoadTechs() error {
dir := filepath.Join(g.DataDir, "techs")
AllTechs = nil
- techByID = make(map[string]*TechDef)
- behavior.WalkYAMLDir(dir, func(path, id string, data []byte) error {
+ if err := behavior.WalkYAMLDir(dir, func(path, id string, data []byte) error {
var t TechDef
if err := yaml.Unmarshal(data, &t); err != nil {
return nil
@@ -53,7 +52,9 @@ func (g *Game) LoadTechs() error {
t.ID = id
AllTechs = append(AllTechs, &t)
return nil
- })
+ }); err != nil {
+ return err
+ }
techByID = make(map[string]*TechDef, len(AllTechs))
for _, t := range AllTechs {
techByID[t.ID] = t
@@ -199,8 +200,8 @@ func (g *Game) tryRecharge(sess *net.Session, p *player.Player, input string) bo
return false
}
-func (g *Game) applyTechProtection(p *player.Player, mob *world.MobInstance, dmg int) int {
- return g.damageAfterTechProtection(p, mob.AttackType, dmg)
+func (g *Game) applyTechProtection(p *player.Player, attackType string, dmg int) int {
+ return g.damageAfterTechProtection(p, attackType, dmg)
}
// damageAfterTechProtection reduces incoming damage if the player has the
@@ -220,16 +221,16 @@ func (g *Game) damageAfterTechProtection(p *player.Player, attackType string, dm
}
if attackType == "" {
- attackType = "crush"
+ attackType = combat.DefaultAttackType
}
var protectTechID string
- switch attackType {
- case "stab", "slash", "crush":
+ switch {
+ case combat.IsMeleeType(attackType):
protectTechID = "protect_melee"
- case "ranged":
+ case attackType == combat.AttackRanged:
protectTechID = "protect_ranged"
- case "science":
+ case attackType == combat.AttackScience:
protectTechID = "protect_science"
}