update merc

This commit is contained in:
vietdungdev
2026-04-26 13:39:16 +07:00
parent 3c36d2d1ad
commit 839b04fd89
4 changed files with 212 additions and 11 deletions

View File

@@ -30,6 +30,7 @@ type Data struct {
Corpse Corpse
Monsters Monsters
Corpses Monsters
Mercenary OwnMercenary
Game OnlineGame
PlayerUnit PlayerUnit
NPCs NPCs
@@ -100,19 +101,21 @@ func (r Room) IsInside(p Position) bool {
}
func (d Data) MercHPPercent() int {
for _, m := range d.Monsters {
if m.IsMerc() {
// Hacky thing to read merc life properly
maxLife := m.Stats[stat.MaxLife] >> 8
life := float64(m.Stats[stat.Life] >> 8)
if m.Stats[stat.Life] <= 32768 {
life = float64(m.Stats[stat.Life]) / 32768.0 * float64(maxLife)
}
// for _, m := range d.Monsters {
// if m.IsMerc() {
// // Hacky thing to read merc life properly
// maxLife := m.Stats[stat.MaxLife] >> 8
// life := float64(m.Stats[stat.Life] >> 8)
// if m.Stats[stat.Life] <= 32768 {
// life = float64(m.Stats[stat.Life]) / 32768.0 * float64(maxLife)
// }
return int(life / float64(maxLife) * 100)
}
// return int(life / float64(maxLife) * 100)
// }
// }
if d.Mercenary.Found {
return d.Mercenary.HPPercent
}
return 0
}

View File

@@ -9,6 +9,18 @@ import (
"github.com/hectorgimenez/d2go/pkg/data/superunique"
)
type OwnMercenary struct {
Found bool
ClassID npc.ID
UnitID UnitID
OwnerUnitID UnitID
OwnerName string
Position Position
Mode mode.NpcMode
IsCorpse bool
HPPercent int
}
type NPC struct {
ID npc.ID
Name string