-
Notifications
You must be signed in to change notification settings - Fork 88
/
alhaitham.go
85 lines (74 loc) · 2.01 KB
/
alhaitham.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package alhaitham
import (
tmpl "github.com/genshinsim/gcsim/internal/template/character"
"github.com/genshinsim/gcsim/pkg/core"
"github.com/genshinsim/gcsim/pkg/core/attacks"
"github.com/genshinsim/gcsim/pkg/core/attributes"
"github.com/genshinsim/gcsim/pkg/core/combat"
"github.com/genshinsim/gcsim/pkg/core/event"
"github.com/genshinsim/gcsim/pkg/core/glog"
"github.com/genshinsim/gcsim/pkg/core/keys"
"github.com/genshinsim/gcsim/pkg/core/player/character"
"github.com/genshinsim/gcsim/pkg/core/player/character/profile"
)
func init() {
core.RegisterCharFunc(keys.Alhaitham, NewChar)
}
type char struct {
*tmpl.Character
mirrorCount int
lastInfusionSrc int
c2Counter int
}
func NewChar(s *core.Core, w *character.CharWrapper, _ profile.CharacterProfile) error {
c := char{}
c.Character = tmpl.NewWithWrapper(s, w)
c.EnergyMax = 70
c.NormalHitNum = normalHitNum
c.BurstCon = 5
c.SkillCon = 3
w.Character = &c
return nil
}
func (c *char) Init() error {
c.onExitField()
c.a4()
return nil
}
func (c *char) onExitField() {
c.Core.Events.Subscribe(event.OnCharacterSwap, func(args ...interface{}) bool {
// do nothing if previous char wasn't alhaitham
prev := args[0].(int)
if prev != c.Index {
return false
}
c.lastInfusionSrc = -1 //Might prevent undesired behaviour
if c.mirrorCount > 0 {
c.mirrorCount = 0
c.Core.Log.NewEvent("Alhaitham left the field, mirror lost", glog.LogCharacterEvent, c.Index)
}
return false
}, "alhaitham-exit")
}
func (c *char) Snapshot(ai *combat.AttackInfo) combat.Snapshot {
ds := c.Character.Snapshot(ai)
if c.mirrorCount > 0 { //weapon infusion can't be overriden for haitham
switch ai.AttackTag {
case attacks.AttackTagNormal:
case attacks.AttackTagPlunge:
case attacks.AttackTagExtra:
default:
return ds
}
ai.Element = attributes.Dendro
}
return ds
}
func (c *char) Condition(fields []string) (any, error) {
switch fields[0] {
case "mirrors":
return c.mirrorCount, nil
default:
return c.Character.Condition(fields)
}
}