forked from genshinsim/gcsim
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgildeddreams.go
More file actions
114 lines (100 loc) · 3.02 KB
/
Copy pathgildeddreams.go
File metadata and controls
114 lines (100 loc) · 3.02 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package gildeddreams
import (
"fmt"
"github.com/genshinsim/gcsim/pkg/core"
"github.com/genshinsim/gcsim/pkg/core/attributes"
"github.com/genshinsim/gcsim/pkg/core/event"
"github.com/genshinsim/gcsim/pkg/core/glog"
"github.com/genshinsim/gcsim/pkg/core/info"
"github.com/genshinsim/gcsim/pkg/core/keys"
"github.com/genshinsim/gcsim/pkg/core/player/character"
"github.com/genshinsim/gcsim/pkg/modifier"
)
func init() {
core.RegisterSetFunc(keys.GildedDreams, NewSet)
}
type Set struct {
buff []float64
c *core.Core
char *character.CharWrapper
Index int
Count int
}
func (s *Set) SetIndex(idx int) { s.Index = idx }
func (s *Set) GetCount() int { return s.Count }
func (s *Set) Init() error {
emCount := 0
atkCount := 0
for _, this := range s.c.Player.Chars() {
if s.char.Index == this.Index {
continue
}
if this.Base.Element != s.char.Base.Element {
emCount++
} else {
atkCount++
}
}
if emCount > 3 {
emCount = 3
}
if atkCount > 3 {
atkCount = 3
}
s.buff = make([]float64, attributes.EndStatType)
s.buff[attributes.EM] = 50 * float64(emCount)
s.buff[attributes.ATKP] = 0.14 * float64(atkCount)
return nil
}
// 2-Piece Bonus: Elemental Mastery +80.
// 4-Piece Bonus: Within 8s of triggering an Elemental Reaction, the character equipping this will obtain buffs based on the Elemental
// Type of the other party members. ATK is increased by 14% for each party member whose Elemental Type is the same as the equipping
// character, and Elemental Mastery is increased by 50 for every party member with a different Elemental Type. Each of the aforementioned
// buffs will count up to 3 characters. This effect can be triggered once every 8s. The character who equips this can still trigger its
// effects when not on the field.
func NewSet(c *core.Core, char *character.CharWrapper, count int, param map[string]int) (info.Set, error) {
s := Set{
c: c,
char: char,
Count: count,
}
if count >= 2 {
m := make([]float64, attributes.EndStatType)
m[attributes.EM] = 80
char.AddStatMod(character.StatMod{
Base: modifier.NewBase("gd-2pc", -1),
AffectedStat: attributes.EM,
Amount: func() ([]float64, bool) {
return m, true
},
})
}
if count >= 4 {
const icdKey = "gd-4pc-icd"
add := func(args ...interface{}) bool {
atk := args[1].(*info.AttackEvent)
if atk.Info.ActorIndex != char.Index {
return false
}
if char.StatusIsActive(icdKey) {
return false
}
char.AddStatus(icdKey, 8*60, true)
char.AddStatMod(character.StatMod{
Base: modifier.NewBaseWithHitlag("gd-4pc", 8*60),
AffectedStat: attributes.NoStat,
Amount: func() ([]float64, bool) {
return s.buff, true
},
})
c.Log.NewEvent("gilded dreams proc'd", glog.LogArtifactEvent, char.Index).
Write("em", s.buff[attributes.EM]).
Write("atk", s.buff[attributes.ATKP])
return false
}
for i := event.ReactionEventStartDelim + 1; i < event.OnShatter; i++ {
c.Events.Subscribe(i, add, fmt.Sprintf("gd-4pc-%v", char.Base.Key.String()))
}
}
return &s, nil
}