Skip to content

Commit

Permalink
Merge branch 'main' into Portraits
Browse files Browse the repository at this point in the history
  • Loading branch information
elobo91 authored Dec 29, 2024
2 parents 20aa096 + a607822 commit e1881ae
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 10 deletions.
5 changes: 5 additions & 0 deletions internal/action/cube_recipes.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,11 @@ func hasItemsForGrandCharmReroll(ctx *context.Status, items []data.Item) ([]data
grandCharm = itm
}
} else if isPerfectGem(itm) && len(perfectGems) < 3 {
// Skip perfect amethysts and rubies if configured
if (ctx.CharacterCfg.CubeRecipes.SkipPerfectAmethysts && itm.Name == "PerfectAmethyst") ||
(ctx.CharacterCfg.CubeRecipes.SkipPerfectRubies && itm.Name == "PerfectRuby") {
continue
}
perfectGems = append(perfectGems, itm)
}

Expand Down
5 changes: 5 additions & 0 deletions internal/action/stash.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ func shouldStashIt(i data.Item, firstRun bool) (bool, string, string) {
ctx := context.Get()
ctx.SetLastStep("shouldStashIt")

// Don't stash items in protected slots
if ctx.CharacterCfg.Inventory.InventoryLock[i.Position.Y][i.Position.X] == 0 {
return false, "", ""
}

// Don't stash items from quests during leveling process, it makes things easier to track
if _, isLevelingChar := ctx.Char.(context.LevelingCharacter); isLevelingChar && i.IsFromQuest() {
return false, "", ""
Expand Down
4 changes: 0 additions & 4 deletions internal/action/step/attack.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package step
import (
"errors"
"fmt"
"log/slog"
"math"
"time"

Expand Down Expand Up @@ -127,9 +126,6 @@ func isValidEnemy(monster data.Monster, ctx *context.Status) bool {

// Skip monsters in invalid positions
if !ctx.Data.AreaData.IsWalkable(monster.Position) {
ctx.Logger.Debug("Skipping monster in unwalkable position",
slog.Any("monster", monster.Name),
slog.Any("position", monster.Position))
return false
}

Expand Down
6 changes: 3 additions & 3 deletions internal/action/step/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/hectorgimenez/koolo/internal/utils"
)

const DistanceToFinishMoving = 7
const DistanceToFinishMoving = 4

func MoveTo(dest data.Position) error {
minDistanceToFinishMoving := DistanceToFinishMoving
Expand Down Expand Up @@ -112,8 +112,8 @@ func MoveTo(dest data.Position) error {
}

// This is a workaround to avoid the character to get stuck in the same position when the hitbox of the destination is too big
if distance < 20 && math.Abs(float64(previousDistance-distance)) < 5 {
minDistanceToFinishMoving += 5
if distance < 20 && math.Abs(float64(previousDistance-distance)) < 4 {
minDistanceToFinishMoving += 4
} else {
minDistanceToFinishMoving = DistanceToFinishMoving
}
Expand Down
8 changes: 5 additions & 3 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,10 @@ type CharacterCfg struct {
Items []item.Name `yaml:"items"`
} `yaml:"gambling"`
CubeRecipes struct {
Enabled bool `yaml:"enabled"`
EnabledRecipes []string `yaml:"enabledRecipes"`
Enabled bool `yaml:"enabled"`
EnabledRecipes []string `yaml:"enabledRecipes"`
SkipPerfectAmethysts bool `yaml:"skipPerfectAmethysts"`
SkipPerfectRubies bool `yaml:"skipPerfectRubies"`
} `yaml:"cubing"`
BackToTown struct {
NoHpPotions bool `yaml:"noHpPotions"`
Expand Down Expand Up @@ -308,7 +310,7 @@ func Load() error {

// Read character configs
for _, entry := range entries {
if !entry.IsDir() || entry.Name() == "template" {
if !entry.IsDir() {
continue
}

Expand Down
11 changes: 11 additions & 0 deletions internal/pather/path_finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ func (pf *PathFinder) GetPathFrom(from, to data.Position) (Path, int, bool) {
// We don't want to modify the original grid
grid := a.Grid.Copy()

// Special handling for Arcane Sanctuary (to allow pathing with platforms)
if pf.data.PlayerUnit.Area == area.ArcaneSanctuary && pf.data.CanTeleport() {
// Make all non-walkable tiles into low priority tiles for teleport pathing
for y := 0; y < len(grid.CollisionGrid); y++ {
for x := 0; x < len(grid.CollisionGrid[y]); x++ {
if grid.CollisionGrid[y][x] == game.CollisionTypeNonWalkable {
grid.CollisionGrid[y][x] = game.CollisionTypeLowPriority
}
}
}
}
// Lut Gholein map is a bit bugged, we should close this fake path to avoid pathing issues
if a.Area == area.LutGholein {
a.CollisionGrid[13][210] = game.CollisionTypeNonWalkable
Expand Down
2 changes: 2 additions & 0 deletions internal/server/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,8 @@ func (s *HttpServer) characterSettings(w http.ResponseWriter, r *http.Request) {
cfg.CubeRecipes.Enabled = r.Form.Has("enableCubeRecipes")
enabledRecipes := r.Form["enabledRecipes"]
cfg.CubeRecipes.EnabledRecipes = enabledRecipes
cfg.CubeRecipes.SkipPerfectAmethysts = r.Form.Has("skipPerfectAmethysts")
cfg.CubeRecipes.SkipPerfectRubies = r.Form.Has("skipPerfectRubies")
// Companion

// Companion config
Expand Down
8 changes: 8 additions & 0 deletions internal/server/templates/character_settings.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,14 @@
<input type="checkbox" style="padding-right: 30px" name="enableCubeRecipes" {{ if .Config.CubeRecipes.Enabled }}checked{{ end }}/>
Enable the bot to automatically cube item recipes.
</label><br>
<label>
<input type="checkbox" name="skipPerfectAmethysts" {{ if .Config.CubeRecipes.SkipPerfectAmethysts }}checked{{ end }}/>
Don't use Perfect Amethysts when rolling charms
</label><br>
<label>
<input type="checkbox" name="skipPerfectRubies" {{ if .Config.CubeRecipes.SkipPerfectRubies }}checked{{ end }}/>
Don't use Perfect Rubies when rolling charms
</label><br>

<div class="recipe-grid">
{{ range $index, $recipe := .RecipeList }}
Expand Down

0 comments on commit e1881ae

Please sign in to comment.