Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Range Gauge #1746

Merged
merged 12 commits into from
Dec 14, 2023
3 changes: 3 additions & 0 deletions internal/weapons/bow/rangegauge/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package_name: rangegauge
genshin_id: 15427
key: rangegauge
135 changes: 135 additions & 0 deletions internal/weapons/bow/rangegauge/rangegauge.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
package rangegauge

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"
"github.com/genshinsim/gcsim/pkg/core/player/character"
"github.com/genshinsim/gcsim/pkg/modifier"
)

const icdKey = "range-gauge-struggle-icd"

var symbol = []string{"unity-symbol-0", "unity-symbol-1", "unity-symbol-2"}

func init() {
core.RegisterWeaponFunc(keys.RangeGauge, NewWeapon)
}

type Weapon struct {
core *core.Core
char *character.CharWrapper
refine int
atkp []float64
eleDMGP []float64
Index int
}

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

// When the wielder is healed or heals others, they will gain a Unity's Symbol that lasts 30s, up to a maximum of 3 Symbols.
// When using their Elemental Skill or Burst, all Symbols will be consumed and the Struggle effect will be granted for 10s.
// For each Symbol consumed, gain 3/4/5/6/7% ATK and 7/8.5/10/11.5/13% All Elemental DMG Bonus.
// The Struggle effect can be triggered once every 15s,
// and Symbols can be gained even when the character is not on the field.

func NewWeapon(c *core.Core, char *character.CharWrapper, p info.WeaponProfile) (info.Weapon, error) {
w := &Weapon{
core: c,
char: char,
refine: p.Refine,
atkp: make([]float64, attributes.EndStatType),
eleDMGP: make([]float64, attributes.EndStatType),
}

c.Events.Subscribe(event.OnHeal, func(args ...interface{}) bool {
source := args[0].(*player.HealInfo)
index := args[1].(int)
amount := args[2].(float64)
if source.Caller != char.Index && index != char.Index { // heal others and get healed including wielder
return false
}
if amount <= 0 {
return false
}

// override oldest symbol
idx := 0
for i, s := range symbol {
if char.StatusExpiry(s) < char.StatusExpiry(symbol[idx]) {
idx = i
}
}
char.AddStatus((symbol[idx]), 30*60, true)

c.Log.NewEvent("range-gauge proc'd", glog.LogWeaponEvent, char.Index).
Write("index", idx)

w.consumeEnergy()
return false
}, fmt.Sprintf("range-gauge-heal-%v", char.Base.Key.String()))

key := fmt.Sprintf("range-gauge-struggle-%v", char.Base.Key.String())
c.Events.Subscribe(event.OnBurst, w.consumeEnergy, key)
c.Events.Subscribe(event.OnSkill, w.consumeEnergy, key)
return w, nil
}

func (w *Weapon) consumeEnergy(args ...interface{}) bool {
baseEleDMGP := 0.055 + 0.015*float64(w.refine)
atkp := 0.02 + 0.01*float64(w.refine)
duration := 10 * 60

// check for active before deleting symbol
if w.char.StatusIsActive(icdKey) {
return false
}
if w.core.Player.Active() != w.char.Index {
return false
}
count := 0
for _, s := range symbol {
if w.char.StatusIsActive(s) {
count++
}
w.char.DeleteStatus(s)
}
if count == 0 {
return false
}

w.char.AddStatus(icdKey, 15*60, true)
w.atkp[attributes.ATKP] = atkp * float64(count)

// add atk buff
w.char.AddStatMod(character.StatMod{
Base: modifier.NewBaseWithHitlag("range-gauge-atk-buff", duration),
AffectedStat: attributes.ATKP,
Amount: func() ([]float64, bool) {
return w.atkp, true
},
})

eleDMGP := baseEleDMGP * float64(count)
for i := attributes.PyroP; i <= attributes.DendroP; i++ {
w.eleDMGP[i] = eleDMGP
}

// add elemental dmg buff
w.char.AddStatMod(character.StatMod{
Base: modifier.NewBaseWithHitlag("range-gauge-eledmg-buff", duration),
AffectedStat: attributes.NoStat,
Amount: func() ([]float64, bool) {
return w.eleDMGP, true
},
})

return false
}
37 changes: 37 additions & 0 deletions pkg/core/curves/weaponcurves.go
Original file line number Diff line number Diff line change
Expand Up @@ -3687,6 +3687,43 @@ var WeaponBaseMap = map[keys.Weapon]WeaponBase{
},
},
},
keys.RangeGauge: {
AtkCurve: GROW_CURVE_ATTACK_202,
SpecializedCurve: GROW_CURVE_CRITICAL_201,
BaseAtk: 42.4010009765625,
BaseSpecialized: 0.05999999865889549,
Specialized: attributes.ATKP,
PromotionBonus: []PromoData{
{
MaxLevel: 20,
Atk: 0,
},
{
MaxLevel: 40,
Atk: 25.899999618530273,
},
{
MaxLevel: 50,
Atk: 51.900001525878906,
},
{
MaxLevel: 60,
Atk: 77.80000305175781,
},
{
MaxLevel: 70,
Atk: 103.69999694824219,
},
{
MaxLevel: 80,
Atk: 129.6999969482422,
},
{
MaxLevel: 90,
Atk: 155.60000610351562,
},
},
},
keys.RavenBow: {
AtkCurve: GROW_CURVE_ATTACK_102,
SpecializedCurve: GROW_CURVE_CRITICAL_101,
Expand Down
2 changes: 2 additions & 0 deletions pkg/core/keys/weapon.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ var weaponNames = []string{
"prototyperancour",
"prototypestarglitter",
"rainslasher",
"rangegauge",
"ravenbow",
"recurvebow",
"redhornstonethresher",
Expand Down Expand Up @@ -308,6 +309,7 @@ const (
PrototypeRancour
PrototypeStarglitter
Rainslasher
RangeGauge
RavenBow
RecurveBow
RedhornStonethresher
Expand Down
1 change: 1 addition & 0 deletions pkg/shortcut/weapons.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ var WeaponNameToKey = map[string]keys.Weapon{
"prototypestarglitter": keys.PrototypeStarglitter,
"starglitter": keys.PrototypeStarglitter,
"rainslasher": keys.Rainslasher,
"rangegauge": keys.RangeGauge,
"ravenbow": keys.RavenBow,
"raven": keys.RavenBow,
"recurvebow": keys.RecurveBow,
Expand Down
1 change: 1 addition & 0 deletions pkg/simulation/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ import (
_ "github.com/genshinsim/gcsim/internal/weapons/bow/polarstar"
_ "github.com/genshinsim/gcsim/internal/weapons/bow/predator"
_ "github.com/genshinsim/gcsim/internal/weapons/bow/prototype"
_ "github.com/genshinsim/gcsim/internal/weapons/bow/rangegauge"
_ "github.com/genshinsim/gcsim/internal/weapons/bow/raven"
_ "github.com/genshinsim/gcsim/internal/weapons/bow/recurve"
_ "github.com/genshinsim/gcsim/internal/weapons/bow/royal"
Expand Down
29 changes: 29 additions & 0 deletions ui/packages/docs/docs/reference/weapons/rangegauge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Range Gauge
---

import AoETable from "@site/src/components/AoE/AoETable";
import IssuesTable from "@site/src/components/Issues/IssuesTable";
import NamesList from "@site/src/components/Names/NamesList";
import ParamsTable from "@site/src/components/Params/ParamsTable";
import FieldsTable from "@site/src/components/Fields/FieldsTable";

## AoE Data

<AoETable item_key="rangegauge" data_src="weapon" />

## Known issues

<IssuesTable item_key="rangegauge" data_src="weapon" />

## Names

<NamesList item_key="rangegauge" data_src="weapon" />

## Params

<ParamsTable item_key="rangegauge" data_src="weapon" />

## Fields

<FieldsTable item_key="rangegauge" data_src="weapon" />
1 change: 1 addition & 0 deletions ui/packages/docs/src/components/Names/weapon_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
"starglitter"
],
"rainslasher": [],
"rangegauge": [],
"ravenbow": [
"raven"
],
Expand Down
7 changes: 7 additions & 0 deletions ui/packages/ui/src/Data/weapon_data.generated.json
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,13 @@
"weapon_class": "WEAPON_CLAYMORE",
"image_name": "UI_EquipIcon_Claymore_Perdue"
},
"rangegauge": {
"id": 15427,
"key": "rangegauge",
"rarity": 4,
"weapon_class": "WEAPON_BOW",
"image_name": "UI_EquipIcon_Bow_Mechanic"
},
"ravenbow": {
"id": 15301,
"key": "ravenbow",
Expand Down
8 changes: 7 additions & 1 deletion ui/packages/ui/src/Translation/locales/IngameNames.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
"prototyperancour": "Prototype Rancour",
"prototypestarglitter": "Prototype Starglitter",
"rainslasher": "Rainslasher",
"rangegauge": "Range Gauge",
"ravenbow": "Raven Bow",
"recurvebow": "Recurve Bow",
"redhornstonethresher": "Redhorn Stonethresher",
Expand Down Expand Up @@ -534,6 +535,7 @@
"prototyperancour": "试作斩岩",
"prototypestarglitter": "试作星镰",
"rainslasher": "雨裁",
"rangegauge": "测距规",
"ravenbow": "鸦羽弓",
"recurvebow": "反曲弓",
"redhornstonethresher": "赤角石溃杵",
Expand Down Expand Up @@ -836,6 +838,7 @@
"prototyperancour": "斬岩·試作",
"prototypestarglitter": "星鎌·試作",
"rainslasher": "雨裁",
"rangegauge": "レンジゲージ",
"ravenbow": "鴉羽の弓",
"recurvebow": "リカーブボウ",
"redhornstonethresher": "赤角石塵滅砕",
Expand Down Expand Up @@ -1138,6 +1141,7 @@
"prototyperancour": "Prototipo Rencor",
"prototypestarglitter": "Prototipo Estelar",
"rainslasher": "Segadora de la Lluvia",
"rangegauge": "Medidor Telemétrico",
"ravenbow": "Arco de Cuervo",
"recurvebow": "Arco Recurvo",
"redhornstonethresher": "Espadón Cornirrojo",
Expand Down Expand Up @@ -1440,6 +1444,7 @@
"prototyperancour": "Прототип: Злоба",
"prototypestarglitter": "Прототип: Звёздный блеск",
"rainslasher": "Дождерез",
"rangegauge": "Дальномер",
"ravenbow": "Лук ворона",
"recurvebow": "Изогнутый лук",
"redhornstonethresher": "Краснорогий камнеруб",
Expand Down Expand Up @@ -1742,6 +1747,7 @@
"prototyperancour": "Steinschneider-Prototyp",
"prototypestarglitter": "Sternsichel-Prototyp",
"rainslasher": "Regenschnitter",
"rangegauge": "Entfernungsmesser",
"ravenbow": "Rabenbogen",
"recurvebow": "Reflexbogen",
"redhornstonethresher": "Rothorn-Steinbrecher",
Expand Down Expand Up @@ -1811,4 +1817,4 @@
"xiphosmoonlight": "Mondlicht von Xiphos"
}
}
}
}