Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions internal/action/interaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ func InteractObject(o data.Object, isCompletedFn func() bool) error {
pos = data.Position{X: 7800, Y: 5919}
}

ctx.CurrentGame.AreaCorrection.Enabled = false
defer func() {
ctx.CurrentGame.AreaCorrection.ExpectedArea = ctx.Data.AreaData.Area
}()

var err error
for range 5 {
err = step.MoveTo(pos)
Expand Down
23 changes: 1 addition & 22 deletions internal/action/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,7 @@ func ensureAreaSync(ctx *context.Status, expectedArea area.ID) error {
func MoveToArea(dst area.ID) error {
ctx := context.Get()
ctx.SetLastAction("MoveToArea")
ctx.CurrentGame.AreaCorrection.Enabled = false
var isEntrance bool

defer func() {
// For open areas (non-entrance transitions), disable area correction
if !isEntrance {
if ctx.Data.PlayerUnit.Area == dst {
ctx.CurrentGame.AreaCorrection.ExpectedArea = dst
ctx.CurrentGame.AreaCorrection.Enabled = false
}
} else {
// For entrances
ctx.CurrentGame.AreaCorrection.ExpectedArea = dst
ctx.CurrentGame.AreaCorrection.Enabled = true
}
}()

if err := ensureAreaSync(ctx, ctx.Data.PlayerUnit.Area); err != nil {
return err
}
Expand All @@ -88,7 +73,6 @@ func MoveToArea(dst area.ID) error {
for _, a := range ctx.Data.AdjacentLevels {
if a.Area == dst {
lvl = a
isEntrance = a.IsEntrance
break
}
}
Expand Down Expand Up @@ -201,11 +185,6 @@ func MoveToArea(dst area.ID) error {

func MoveToCoords(to data.Position) error {
ctx := context.Get()
ctx.CurrentGame.AreaCorrection.Enabled = false
defer func() {
ctx.CurrentGame.AreaCorrection.ExpectedArea = ctx.Data.AreaData.Area
ctx.CurrentGame.AreaCorrection.Enabled = true
}()

if err := ensureAreaSync(ctx, ctx.Data.PlayerUnit.Area); err != nil {
return err
Expand Down
8 changes: 0 additions & 8 deletions internal/action/waypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ import (
func WayPoint(dest area.ID) error {
ctx := context.Get()
ctx.SetLastAction("WayPoint")
ctx.CurrentGame.AreaCorrection.Enabled = false
defer func() {
ctx.CurrentGame.AreaCorrection.ExpectedArea = dest
ctx.CurrentGame.AreaCorrection.Enabled = true
}()

if !ctx.Data.PlayerUnit.Area.IsTown() {
if err := ReturnTown(); err != nil {
Expand Down Expand Up @@ -62,9 +57,6 @@ func WayPoint(dest area.ID) error {
return err
}

// Set ExpectedArea after successful waypoint use, but only if it's not a town
ctx.CurrentGame.AreaCorrection.ExpectedArea = dest

// Wait for the game to load after using the waypoint
ctx.WaitForGameToLoad()

Expand Down
18 changes: 12 additions & 6 deletions internal/bot/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,24 @@ func (b *Bot) Run(ctx context.Context, firstRun bool, runs []run.Run) error {
time.Sleep(200 * time.Millisecond)
}

// extra RefreshGameData not needed for Legacygraphics/Portraits since Background loop will automatically refresh after 100ms
if b.ctx.CharacterCfg.ClassicMode && !b.ctx.Data.LegacyGraphics {
// Toggle Legacy if enabled
action.SwitchToLegacyMode()
b.ctx.RefreshGameData()
time.Sleep(150 * time.Millisecond)
}
// Hide merc/other players portraits if enabled
action.HidePortraits()

if b.ctx.CharacterCfg.HidePortraits && b.ctx.Data.OpenMenus.PortraitsShown {
action.HidePortraits()
time.Sleep(150 * time.Millisecond)
}
b.ctx.SwitchPriority(botCtx.PriorityHigh)

// Area correction
if err = action.AreaCorrection(); err != nil {
b.ctx.Logger.Warn("Area correction failed", "error", err)
// Area correction (only check if enabled)
if b.ctx.CurrentGame.AreaCorrection.Enabled {
if err = action.AreaCorrection(); err != nil {
b.ctx.Logger.Warn("Area correction failed", "error", err)
}
}

// Perform item pickup if enabled
Expand Down
11 changes: 10 additions & 1 deletion internal/run/travincal.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ func (t *Travincal) Name() string {
}

func (t *Travincal) Run() error {
defer func() {
t.ctx.CurrentGame.AreaCorrection.Enabled = false
}()

// Check if the character is a Berserker and swap to combat gear
if berserker, ok := t.ctx.Char.(*character.Berserker); ok {
if t.ctx.CharacterCfg.Character.BerserkerBarb.FindItemSwitch {
Expand All @@ -35,7 +39,12 @@ func (t *Travincal) Run() error {
if err != nil {
return err
}
//this is temporary needed for barb because have no cta; isrebuffrequired not working for him

// Only Enable Area Correction for Travincal
t.ctx.CurrentGame.AreaCorrection.ExpectedArea = area.Travincal
t.ctx.CurrentGame.AreaCorrection.Enabled = true

//TODO This is temporary needed for barb because have no cta; isrebuffrequired not working for him. We have ActiveWeaponSlot in d2go ready for that
action.Buff()

councilPosition := t.findCouncilPosition()
Expand Down