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

Chicken settings for scary auras #700

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions config/template/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ closeMiniPanel: false # Set to true to close the mini panel at start of game in
hidePortraits: true # Set to true to hide mercenary and other players portraits (avatar)
enableCubeRecipes: true # Enable cubing of flawlesses and tokens

chickenScaryAuras:
amplifyDamage: false
bloodMana: false
decrepify: false
lowerResist: false
fanaticism: false
might: false
conviction: false

health: # Healing configuration, all values in %
healingPotionAt: 75
manaPotionAt: 10
Expand Down
13 changes: 11 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,17 @@ type CharacterCfg struct {
UseCentralizedPickit bool `yaml:"useCentralizedPickit"`
HidePortraits bool `yaml:"hidePortraits"`

Scheduler Scheduler `yaml:"scheduler"`
Health struct {
Scheduler Scheduler `yaml:"scheduler"`
ChickenScaryAuras struct {
AmplifyDamage bool `yaml:"amplifyDamage"`
BloodMana bool `yaml:"bloodMana"`
Decrepify bool `yaml:"decrepify"`
LowerResist bool `yaml:"lowerResist"`
Fanaticism bool `yaml:"fanaticism"`
Might bool `yaml:"might"`
Conviction bool `yaml:"conviction"`
}
Health struct {
HealingPotionAt int `yaml:"healingPotionAt"`
ManaPotionAt int `yaml:"manaPotionAt"`
RejuvPotionAtLife int `yaml:"rejuvPotionAtLife"`
Expand Down
54 changes: 54 additions & 0 deletions internal/health/health_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"time"

"github.com/hectorgimenez/d2go/pkg/data"
"github.com/hectorgimenez/d2go/pkg/data/stat"
"github.com/hectorgimenez/d2go/pkg/data/state"
"github.com/hectorgimenez/koolo/internal/game"
)

Expand Down Expand Up @@ -105,5 +107,57 @@ func (hm *Manager) HandleHealthAndMana() error {
}
}

// Player scary aura check - great for use on hardcore
chickenAurasConfig := hm.data.CharacterCfg.ChickenScaryAuras

if chickenAurasConfig.AmplifyDamage && hm.data.PlayerUnit.States.HasState(state.Amplifydamage) {
return fmt.Errorf("%w: Player has amplify damage aura", ErrChicken)
}

if chickenAurasConfig.BloodMana && hm.data.PlayerUnit.States.HasState(state.BloodMana) {
life, _ := hm.data.PlayerUnit.FindStat(stat.Life, 0)
mana, _ := hm.data.PlayerUnit.FindStat(stat.Mana, 0)

// Blood mana causes damage to you every time you use mana to cast a spell.
// The damage is equal to the amount of mana that you used up when you cast the spell.
// This happens even for non-damaging spells, such as Teleport, or Enchant.

// This curse only damages yourself when a character's mana exceeds their health (otherwise your def is reduced).
if mana.Value >= life.Value {
return fmt.Errorf("%w: Player has blood mana aura", ErrChicken)
}
}

if chickenAurasConfig.Decrepify && hm.data.PlayerUnit.States.HasState(state.Decrepify) {
return fmt.Errorf("%w: Player has decrepify aura", ErrChicken)
}

if chickenAurasConfig.LowerResist && hm.data.PlayerUnit.States.HasState(state.Lowerresist) {
return fmt.Errorf("%w: Player has lower resist aura", ErrChicken)
}

if chickenAurasConfig.Fanaticism || chickenAurasConfig.Might || chickenAurasConfig.Conviction {
for _, m := range hm.data.Monsters.Enemies() {
var scaryAura string

if chickenAurasConfig.Fanaticism && m.States.HasState(state.Fanaticism) {
scaryAura = "fanaticism"
}

if chickenAurasConfig.Might && m.States.HasState(state.Might) {
scaryAura = "might"
}

if chickenAurasConfig.Conviction && m.States.HasState(state.Conviction) {
scaryAura = "conviction"
}

// TODO: Distance check?
if scaryAura != "" {
return fmt.Errorf("%w: Mob has %s aura", ErrChicken, scaryAura)
}
}
}

return nil
}
9 changes: 9 additions & 0 deletions internal/server/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,15 @@ func (s *HttpServer) characterSettings(w http.ResponseWriter, r *http.Request) {
return
}

// Chicken Scary Auras Config
cfg.ChickenScaryAuras.AmplifyDamage = r.Form.Has("chickenAmplifyDamage")
cfg.ChickenScaryAuras.BloodMana = r.Form.Has("chickenBloodMana")
cfg.ChickenScaryAuras.Decrepify = r.Form.Has("chickenDecrepify")
cfg.ChickenScaryAuras.LowerResist = r.Form.Has("chickenLowerResist")
cfg.ChickenScaryAuras.Fanaticism = r.Form.Has("chickenFanaticism")
cfg.ChickenScaryAuras.Might = r.Form.Has("chickenMight")
cfg.ChickenScaryAuras.Conviction = r.Form.Has("chickenConviction")

// Health config
cfg.Health.HealingPotionAt, _ = strconv.Atoi(r.Form.Get("healingPotionAt"))
cfg.Health.ManaPotionAt, _ = strconv.Atoi(r.Form.Get("manaPotionAt"))
Expand Down
39 changes: 39 additions & 0 deletions internal/server/templates/character_settings.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,44 @@
{{ end }}
</div>

<br><h3>Chicken scary aura settings</h3><br>
<label>When enabled, if your character receives one of these debuffs or a mob has a scary aura, you will immediately leave the game.</label><br>
<h4>Player debuffs</h4><br>
<fieldset class="grid">
<label>
<input id="chicken_amplify_damage" type="checkbox" name="chickenAmplifyDamage" {{ if .Config.ChickenScaryAuras.AmplifyDamage }}checked{{ end }}/>
Amplify Damage
</label>
<label>
<input id="chicken_blood_mana" type="checkbox" name="chickenBloodMana" {{ if .Config.ChickenScaryAuras.BloodMana }}checked{{ end }}/>
Blood Mana
</label>
<label>
<input id="chicken_decrepify" type="checkbox" name="chickenDecrepify" {{ if .Config.ChickenScaryAuras.Decrepify }}checked{{ end }}/>
Decrepify
</label>
<label>
<input id="chicken_lower_resist" type="checkbox" name="chickenLowerResist" {{ if .Config.ChickenScaryAuras.LowerResist }}checked{{ end }}/>
Decrepify
</label>
</fieldset>
<h4>Mob buffs</h4><br>
<fieldset class="grid">
<label>
<input id="chicken_fanaticism" type="checkbox" name="chickenFanaticism" {{ if .Config.ChickenScaryAuras.Fanaticism }}checked{{ end }}/>
Fanaticism
</label>
<label>
<input id="chicken_might" type="checkbox" name="chickenMight" {{ if .Config.ChickenScaryAuras.Might }}checked{{ end }}/>
Might
</label>
<label>
<input id="chicken_conviction" type="checkbox" name="chickenConviction" {{ if .Config.ChickenScaryAuras.Conviction }}checked{{ end }}/>
Conviction
</label>
<label>&nbsp;</label>
</fieldset>

<br><h3>Health settings</h3><br>
<fieldset class="grid">
<label>
Expand Down Expand Up @@ -304,6 +342,7 @@
value="{{ .Config.Health.ChickenAt }}"/>
</label>
</fieldset>

<h4>Belt Layout</h4><br>
<fieldset class="grid">
{{ range $index, $potionType := .Config.Inventory.BeltColumns }}
Expand Down