Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix when switching zone #518

Merged
merged 1 commit into from
Oct 20, 2024
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
10 changes: 2 additions & 8 deletions internal/action/tp_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package action
import (
"errors"
"fmt"

"github.com/hectorgimenez/d2go/pkg/data"

"github.com/hectorgimenez/d2go/pkg/data/object"
Expand Down Expand Up @@ -82,20 +83,13 @@ func UsePortalFrom(owner string) error {

for _, obj := range ctx.Data.Objects {
if obj.IsPortal() && obj.Owner == owner {
err := InteractObjectByID(obj.ID, func() bool {
return InteractObjectByID(obj.ID, func() bool {
if !ctx.Data.PlayerUnit.Area.IsTown() {
utils.Sleep(500)
return true
}
return false
})

if err == nil {
// Perform actions after re-entering the game area

}

return err
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/run/cows.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (a Cows) Run() error {
}

err = action.InteractObject(townPortal, func() bool {
return a.ctx.Data.PlayerUnit.Area == area.MooMooFarm
return a.ctx.Data.AreaData.Area == area.MooMooFarm && a.ctx.Data.AreaData.IsInside(a.ctx.Data.PlayerUnit.Position)
})
if err != nil {
return err
Expand Down Expand Up @@ -84,7 +84,7 @@ func (a Cows) getWirtsLeg() error {
return errors.New("tristram not found")
}
err = action.InteractObject(portal, func() bool {
return a.ctx.Data.PlayerUnit.Area == area.Tristram
return a.ctx.Data.AreaData.Area == area.Tristram && a.ctx.Data.AreaData.IsInside(a.ctx.Data.PlayerUnit.Position)
})
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion internal/run/leveling_act2.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (a Leveling) summoner() error {
}

err = action.InteractObject(portal, func() bool {
return a.ctx.Data.PlayerUnit.Area == area.CanyonOfTheMagi
return a.ctx.Data.PlayerUnit.Area == area.CanyonOfTheMagi && a.ctx.Data.AreaData.IsInside(a.ctx.Data.PlayerUnit.Position)
})
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion internal/run/pindleskin.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (p Pindleskin) Run() error {
}

err = action.InteractObject(redPortal, func() bool {
return p.ctx.Data.PlayerUnit.Area == area.NihlathaksTemple
return p.ctx.Data.AreaData.Area == area.NihlathaksTemple && p.ctx.Data.AreaData.IsInside(p.ctx.Data.PlayerUnit.Position)
})
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion internal/run/tristram.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (t Tristram) Run() error {

// Interact with the portal
if err = action.InteractObject(tristPortal, func() bool {
return t.ctx.Data.PlayerUnit.Area == area.Tristram
return t.ctx.Data.PlayerUnit.Area == area.Tristram && t.ctx.Data.AreaData.IsInside(t.ctx.Data.PlayerUnit.Position)
}); err != nil {
return err
}
Expand Down