Skip to content

Commit

Permalink
peakpatrolsong init
Browse files Browse the repository at this point in the history
  • Loading branch information
kengzzzz committed Sep 15, 2024
1 parent efa9f11 commit 4b9def2
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/weapons/sword/peakpatrolsong/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package_name: peakpatrolsong
genshin_id: 11516
key: peakpatrolsong
63 changes: 63 additions & 0 deletions internal/weapons/sword/peakpatrolsong/data_gen.textproto
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
id: 11516
key: "peakpatrolsong"
rarity: 5
weapon_class: WEAPON_SWORD_ONE_HAND
image_name: "UI_Gacha_EquipIcon_Sword_XochitlsTube"
base_stats: {
base_props: {
prop_type: FIGHT_PROP_BASE_ATTACK
initial_value: 44.3358
curve: GROW_CURVE_ATTACK_304
}
base_props: {
prop_type: FIGHT_PROP_DEFENSE_PERCENT
initial_value: 0.18
curve: GROW_CURVE_CRITICAL_301
}
promo_data: {
max_level: 20
}
promo_data: {
max_level: 40
add_props: {
prop_type: FIGHT_PROP_BASE_ATTACK
value: 31.1
}
}
promo_data: {
max_level: 50
add_props: {
prop_type: FIGHT_PROP_BASE_ATTACK
value: 62.2
}
}
promo_data: {
max_level: 60
add_props: {
prop_type: FIGHT_PROP_BASE_ATTACK
value: 93.4
}
}
promo_data: {
max_level: 70
add_props: {
prop_type: FIGHT_PROP_BASE_ATTACK
value: 124.5
}
}
promo_data: {
max_level: 80
add_props: {
prop_type: FIGHT_PROP_BASE_ATTACK
value: 155.6
}
}
promo_data: {
max_level: 90
add_props: {
prop_type: FIGHT_PROP_BASE_ATTACK
value: 186.7
}
}
}
name_text_hash_map: 999999999
98 changes: 98 additions & 0 deletions internal/weapons/sword/peakpatrolsong/peakpatrolsong.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package peakpatrolsong

import (
"fmt"

"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/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.RegisterWeaponFunc(keys.PeakPatrolSong, NewWeapon)
}

type Weapon struct {
Index int
stacks int
}

const (
buffKey = "peakpatrolsong-buff"
buffDur = 6 * 60
teamBuffKey = "peakpatrolsong-team-buff"
teamBuffDur = 15 * 60
icdKey = "peakpatrolsong-buff-icd"
icdDur = 0.1 * 60
)

func (w *Weapon) SetIndex(idx int) { w.Index = idx }
func (w *Weapon) Init() error { return nil }

func NewWeapon(c *core.Core, char *character.CharWrapper, p info.WeaponProfile) (info.Weapon, error) {
w := &Weapon{}
r := float64(p.Refine)

d := make([]float64, attributes.EndStatType)
b := make([]float64, attributes.EndStatType)

def := 0.045 + 0.015*r
bonusMulti := 0.09 + 0.03*r
maxBonus := 0.27 + 0.09*r

c.Events.Subscribe(event.OnEnemyDamage, func(args ...interface{}) bool {
atk := args[1].(*combat.AttackEvent)
if atk.Info.ActorIndex != char.Index {
return false
}
if atk.Info.AttackTag != attacks.AttackTagNormal && atk.Info.AttackTag != attacks.AttackTagPlunge {
return false
}
if char.StatusIsActive(icdKey) {
return false
}

if !char.StatModIsActive(buffKey) {
w.stacks = 0
}
if w.stacks < 2 {
w.stacks++
}

d[attributes.DEFP] = def * float64(w.stacks)
char.AddStatMod(character.StatMod{
Base: modifier.NewBaseWithHitlag(buffKey, buffDur),
AffectedStat: attributes.DEFP,
Amount: func() ([]float64, bool) {
return d, true
},
})

if w.stacks == 2 {
bonus := bonusMulti * char.TotalDef() / 1000.0
bonus = min(bonus, maxBonus)
for i := attributes.PyroP; i <= attributes.DendroP; i++ {
b[i] = bonus
}
for _, this := range c.Player.Chars() {
this.AddStatMod(character.StatMod{
Base: modifier.NewBaseWithHitlag(teamBuffKey, teamBuffDur),
Amount: func() ([]float64, bool) {
return b, true
},
})
}
}

char.AddStatus(icdKey, icdDur, true)
return false
}, fmt.Sprintf("peakpatrolsong-hit-%v", char.Base.Key.String()))

return w, nil
}
25 changes: 25 additions & 0 deletions internal/weapons/sword/peakpatrolsong/peakpatrolsong_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/core/keys/weapon.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ var weaponNames = []string{
"oathsworneye",
"oldmercspal",
"otherworldlystory",
"peakpatrolsong",
"pocketgrimoire",
"polarstar",
"portablepowersaw",
Expand Down Expand Up @@ -331,6 +332,7 @@ const (
OathswornEye
OldMercsPal
OtherworldlyStory
PeakPatrolSong
PocketGrimoire
PolarStar
PortablePowerSaw
Expand Down
1 change: 1 addition & 0 deletions pkg/shortcut/weapons.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ var WeaponNameToKey = map[string]keys.Weapon{
"oldmercspal": keys.OldMercsPal,
"otherworldlystory": keys.OtherworldlyStory,
"otherworldly": keys.OtherworldlyStory,
"pps": keys.PeakPatrolSong,
"pocketgrimoire": keys.PocketGrimoire,
"pocket": keys.PocketGrimoire,
"polarstar": keys.PolarStar,
Expand Down
1 change: 1 addition & 0 deletions pkg/simulation/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ import (
_ "github.com/genshinsim/gcsim/internal/weapons/sword/keyofkhajnisut"
_ "github.com/genshinsim/gcsim/internal/weapons/sword/lion"
_ "github.com/genshinsim/gcsim/internal/weapons/sword/mistsplitter"
_ "github.com/genshinsim/gcsim/internal/weapons/sword/peakpatrolsong"
_ "github.com/genshinsim/gcsim/internal/weapons/sword/primordial"
_ "github.com/genshinsim/gcsim/internal/weapons/sword/prototype"
_ "github.com/genshinsim/gcsim/internal/weapons/sword/royal"
Expand Down

0 comments on commit 4b9def2

Please sign in to comment.