Skip to content

Commit

Permalink
Made diablo run safer (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
SoundsLegit authored Jun 14, 2024
1 parent b396e0c commit d86c0ef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
10 changes: 10 additions & 0 deletions internal/action/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ func (b *Builder) MoveToArea(dst area.ID) *Chain {
}, Resettable())
}

func (b *Builder) MoveToCoordsWithMinDistance(to data.Position, minDistance int, opts ...step.MoveToStepOption) *Chain {
return b.MoveTo(func(d game.Data) (data.Position, bool) {
distance := pather.DistanceFromMe(d, to)
if distance <= minDistance {
return d.PlayerUnit.Position, false
}
return to, true
}, opts...)
}

func (b *Builder) MoveToCoords(to data.Position, opts ...step.MoveToStepOption) *Chain {
return b.MoveTo(func(d game.Data) (data.Position, bool) {
return to, true
Expand Down
22 changes: 11 additions & 11 deletions internal/run/diablo.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,17 @@ func (a Diablo) BuildActions() (actions []action.Action) {
}, step.StopAtDistance(10)))

// Try to calculate based on a square boundary around the seal which corner is safer, then tele there
//actions = append(actions, action.NewStepChain(func(d game.Data) []step.Step {
// if obj, found := d.Objects.FindOne(seal); found {
// pos := a.getLessConcurredCornerAroundSeal(d, obj.Position)
// return []step.Step{step.MoveTo(pos)}
// }
// return []step.Step{}
//}))
actions = append(actions, action.NewStepChain(func(d game.Data) []step.Step {
if obj, found := d.Objects.FindOne(seal); found {
pos := a.getLessConcurredCornerAroundSeal(d, obj.Position)
return []step.Step{step.MoveTo(pos)}
}
return []step.Step{}
}))

// Kill all the monsters close to the seal and item pickup
actions = append(actions,
a.builder.ClearAreaAroundPlayer(13, data.MonsterAnyFilter()),
a.builder.ClearAreaAroundPlayer(20, data.MonsterAnyFilter()),
a.builder.ItemPickup(false, 40),
)

Expand Down Expand Up @@ -328,7 +328,7 @@ func (a Diablo) generateClearActions(positions []data.Position, filter data.Mons
multiplier := 1

if pather.IsWalkable(pos, d.AreaOrigin, d.CollisionGrid) {
return []action.Action{a.builder.MoveToCoords(pos)}
return []action.Action{a.builder.MoveToCoordsWithMinDistance(pos, 30)}
}

for _ = range 2 {
Expand All @@ -337,7 +337,7 @@ func (a Diablo) generateClearActions(positions []data.Position, filter data.Mons
newPos := data.Position{X: pos.X + (i * multiplier), Y: pos.Y + (i * multiplier)}

if pather.IsWalkable(newPos, d.AreaOrigin, d.CollisionGrid) {
return []action.Action{a.builder.MoveToCoords(newPos)}
return []action.Action{a.builder.MoveToCoordsWithMinDistance(newPos, 30)}
}

}
Expand All @@ -346,7 +346,7 @@ func (a Diablo) generateClearActions(positions []data.Position, filter data.Mons
}

// Let it fail then
return []action.Action{a.builder.MoveToCoords(pos)}
return []action.Action{a.builder.MoveToCoordsWithMinDistance(pos, 30)}
}),
// Skip storm casters for now completely while clearing non-seals
a.builder.ClearAreaAroundPlayer(35, func(m data.Monsters) []data.Monster {
Expand Down

0 comments on commit d86c0ef

Please sign in to comment.