Skip to content

Commit

Permalink
Moonglow Implementation (genshinsim#231)
Browse files Browse the repository at this point in the history
* Moonglow Implementation

* Fix normal attack bonus from Moonglow

* Fix restore energy time for Moonglow
  • Loading branch information
imring committed Feb 6, 2022
1 parent 0b40fcf commit 5771a29
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ import (
_ "github.com/genshinsim/gcsim/internal/weapons/catalyst/magicguide"
_ "github.com/genshinsim/gcsim/internal/weapons/catalyst/mappa"
_ "github.com/genshinsim/gcsim/internal/weapons/catalyst/memory"
_ "github.com/genshinsim/gcsim/internal/weapons/catalyst/moonglow"
_ "github.com/genshinsim/gcsim/internal/weapons/catalyst/perception"
_ "github.com/genshinsim/gcsim/internal/weapons/catalyst/prayer"
_ "github.com/genshinsim/gcsim/internal/weapons/catalyst/prototype"
Expand Down
70 changes: 70 additions & 0 deletions internal/weapons/catalyst/moonglow/moonglow.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package moonglow

import (
"fmt"

"github.com/genshinsim/gcsim/pkg/core"
)

func init() {
core.RegisterWeaponFunc("everlastingmoonglow", weapon)
core.RegisterWeaponFunc("everlasting moonglow", weapon)
core.RegisterWeaponFunc("moonglow", weapon)
}

func weapon(char core.Character, c *core.Core, r int, param map[string]int) string {
mheal := make([]float64, core.EndStatType)
mheal[core.Heal] = 0.075 + float64(r)*0.025
char.AddMod(core.CharStatMod{
Key: "moonglow-heal-bonus",
Amount: func() ([]float64, bool) {
return mheal, true
},
Expiry: -1,
})

nabuff := 0.0005 + float64(r)*0.0005
matk := make([]float64, core.EndStatType)
char.AddPreDamageMod(core.PreDamageMod{
Key: "moonglow-na-bonus",
Amount: func(atk *core.AttackEvent, t core.Target) ([]float64, bool) {
if atk.Info.AttackTag != core.AttackTagNormal {
return nil, false
}

matk[core.ATK] = nabuff * char.MaxHP()
return matk, true
},
Expiry: -1,
})

icd, dur := -1, -1
c.Events.Subscribe(core.PreBurst, func(args ...interface{}) bool {
if c.ActiveChar != char.CharIndex() {
return false
}
dur = c.F + 720 // 12s

return false
}, fmt.Sprintf("moonglow-onburst-%v", char.Name()))

c.Events.Subscribe(core.OnDamage, func(args ...interface{}) bool {
atk := args[1].(*core.AttackEvent)
if atk.Info.ActorIndex != char.CharIndex() {
return false
}
if atk.Info.AttackTag != core.AttackTagNormal {
return false
}
if dur < c.F || icd > c.F {
return false
}

char.AddEnergy(0.6)
icd = c.F + 6 // 0.1s

return false
}, fmt.Sprintf("moonglow-energy-%v", char.Name()))

return "everlastingmoonglow"
}

0 comments on commit 5771a29

Please sign in to comment.