diff options
| author | historia <[not public]> | 2026-07-13 15:07:28 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-07-13 15:07:28 -0400 |
| commit | 93a412aed2b11406399504c81d6d19ed1341908a (patch) | |
| tree | d99f0c283e6684d266676438fbec4e550bf9c774 /internal/game/sys_hazard.go | |
| parent | fcc9c0a83df82093efd3a85e8e0dc0768653ea87 (diff) | |
| download | thehouseoficarus-93a412aed2b11406399504c81d6d19ed1341908a.tar.gz | |
feat(admin): hide irrelevant combat stats for task mobs, show relevant combat stats for hazards
Diffstat (limited to 'internal/game/sys_hazard.go')
| -rw-r--r-- | internal/game/sys_hazard.go | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/internal/game/sys_hazard.go b/internal/game/sys_hazard.go index 6e9c40d..40455fc 100644 --- a/internal/game/sys_hazard.go +++ b/internal/game/sys_hazard.go @@ -36,7 +36,7 @@ func (g *Game) HazardTick() { continue } hz, err := g.World.LoadHazard(room.Hazard) - if err != nil || hz == nil { + if err != nil || hz == nil || hz.Combat == nil { p.HazardTimer = 0 continue } @@ -51,10 +51,7 @@ func (g *Game) HazardTick() { continue } - speed := hz.Speed - if speed <= 0 { - speed = 5 - } + speed := hz.SpeedTicks() p.HazardTimer++ if float64(p.HazardTimer) >= speed { p.HazardTimer = 0 @@ -73,15 +70,25 @@ func (g *Game) hasEquipped(p *player.Player, itemID string) bool { } func (g *Game) rollHazard(sess *net.Session, p *player.Player, hz *world.HazardDef) { - attackType := hz.AttackType - if attackType == "" { - attackType = combat.DefaultAttackType - } - - attRoll := combat.AttackRoll(combat.NPCEffective(hz.Attack), hz.AttackBonus) + attackType := hz.AttackType() _, _, defStyleBonus := combat.AttackStyleBonus(string(p.AttackStyle)) totals := g.playerEquipBonuses(p) + + var attRoll int + var maxHit int + switch attackType { + case combat.AttackRanged: + attRoll = combat.AttackRoll(combat.NPCEffective(hz.Combat.Stats.Ranged), hz.Combat.Stats.Bonuses.RangedBonus) + maxHit = hz.Combat.Stats.MaxRangedHit + case combat.AttackScience: + attRoll = combat.AttackRoll(combat.ScienceEffective(hz.Combat.Stats.Science), hz.Combat.Stats.Bonuses.ScienceBonus) + maxHit = hz.EffectiveMaxScienceHit() + default: + attRoll = combat.AttackRoll(combat.NPCEffective(hz.Combat.Stats.Attack), hz.Combat.Stats.Bonuses.AttackBonus) + maxHit = hz.Combat.Stats.MaxMeleeHit + } + equipDef := combat.SelectBonus(attackType, totals.StabDefense, totals.SlashDefense, totals.CrushDefense, totals.ScienceDefense, totals.RangedDefense) @@ -90,7 +97,7 @@ func (g *Game) rollHazard(sess *net.Session, p *player.Player, hz *world.HazardD defStyleBonus), equipDef) if combat.HitCheck(attRoll, defRoll) { - g.applyHazardHit(sess, p, hz) + g.applyHazardHit(sess, p, hz, attackType, maxHit) } else { miss := hz.MissMessage if miss == "" { @@ -101,13 +108,12 @@ func (g *Game) rollHazard(sess *net.Session, p *player.Player, hz *world.HazardD } } -func (g *Game) applyHazardHit(sess *net.Session, p *player.Player, hz *world.HazardDef) { - maxHit := hz.MaxHit +func (g *Game) applyHazardHit(sess *net.Session, p *player.Player, hz *world.HazardDef, attackType string, maxHit int) { if maxHit < 1 { maxHit = 1 } dmg := combat.RollDamage(maxHit) - dmg = g.damageAfterTechProtection(p, hz.AttackType, dmg) + dmg = g.damageAfterTechProtection(p, attackType, dmg) if dmg < 0 { dmg = 0 } |
