|
| 1 | +package azurelight |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + |
| 6 | + "github.com/genshinsim/gcsim/pkg/core" |
| 7 | + "github.com/genshinsim/gcsim/pkg/core/attributes" |
| 8 | + "github.com/genshinsim/gcsim/pkg/core/event" |
| 9 | + "github.com/genshinsim/gcsim/pkg/core/info" |
| 10 | + "github.com/genshinsim/gcsim/pkg/core/keys" |
| 11 | + "github.com/genshinsim/gcsim/pkg/core/player/character" |
| 12 | + "github.com/genshinsim/gcsim/pkg/modifier" |
| 13 | +) |
| 14 | + |
| 15 | +func init() { |
| 16 | + core.RegisterWeaponFunc(keys.Azurelight, NewWeapon) |
| 17 | +} |
| 18 | + |
| 19 | +const ( |
| 20 | + buffKey = "azurelight-buff" |
| 21 | +) |
| 22 | + |
| 23 | +type Weapon struct { |
| 24 | + Index int |
| 25 | +} |
| 26 | + |
| 27 | +func (w *Weapon) SetIndex(idx int) { w.Index = idx } |
| 28 | +func (w *Weapon) Init() error { return nil } |
| 29 | +func NewWeapon(c *core.Core, char *character.CharWrapper, p info.WeaponProfile) (info.Weapon, error) { |
| 30 | + var w Weapon |
| 31 | + refine := p.Refine |
| 32 | + |
| 33 | + m := make([]float64, attributes.EndStatType) |
| 34 | + atkp := 0.18 + 0.06*float64(refine) |
| 35 | + cd := 0.30 + 0.10*float64(refine) |
| 36 | + |
| 37 | + c.Events.Subscribe(event.OnSkill, func(args ...interface{}) bool { |
| 38 | + // don't proc if someone else used a skill |
| 39 | + if c.Player.Active() != char.Index { |
| 40 | + return false |
| 41 | + } |
| 42 | + |
| 43 | + // add buff |
| 44 | + char.AddStatMod(character.StatMod{ |
| 45 | + Base: modifier.NewBaseWithHitlag(buffKey, 12*60), |
| 46 | + AffectedStat: attributes.NoStat, |
| 47 | + Amount: func() ([]float64, bool) { |
| 48 | + if char.Energy == 0 { |
| 49 | + m[attributes.ATKP] = atkp * 2 |
| 50 | + m[attributes.CD] = cd |
| 51 | + } else { |
| 52 | + m[attributes.ATKP] = atkp |
| 53 | + m[attributes.CD] = 0 |
| 54 | + } |
| 55 | + return m, true |
| 56 | + }, |
| 57 | + }) |
| 58 | + |
| 59 | + return false |
| 60 | + }, fmt.Sprintf("azurelight-%v", char.Base.Key)) |
| 61 | + |
| 62 | + return &w, nil |
| 63 | +} |
0 commit comments