Skip to content

Commit

Permalink
Add Portable Power Saw (genshinsim#1731)
Browse files Browse the repository at this point in the history
* init implement

* update curves, update weapon data

* update weapon data

* update weapon desc

* update weapon_data

* update pipeline, lint

* fix nits

---------

Co-authored-by: imring <vitaliyvorobets25@gmail.com>
  • Loading branch information
Athenaxdd and imring authored Oct 31, 2023
1 parent 0ea5c61 commit 715345c
Show file tree
Hide file tree
Showing 9 changed files with 208 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/weapons/claymore/powersaw/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package_name: powersaw
genshin_id: 12427
key: portablepowersaw
124 changes: 124 additions & 0 deletions internal/weapons/claymore/powersaw/powersaw.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package powersaw

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 = "portable-power-saw-icd"

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

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

type Weapon struct {
core *core.Core
char *character.CharWrapper
refine int
buff []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 Stoic'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 Roused effect will be granted for 10s.
// For each Symbol consumed, gain 40/50/60/70/80 Elemental Mastery,
// and 2s after the effect occurs, 2/2.5/3/3.5/4 Energy per Symbol consumed will be restored for said character.
// The Roused 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,
buff: 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("powersaw proc'd", glog.LogWeaponEvent, char.Index).
Write("index", idx)

return false
}, fmt.Sprintf("portable-power-saw-heal-%v", char.Base.Key.String()))

key := fmt.Sprintf("portable-power-saw-roused-%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 {
em := 30 + 10*float64(w.refine)
refund := 1.5 + 0.5*float64(w.refine)

// 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.buff[attributes.EM] = em * float64(count)

// add em buff
w.char.AddStatMod(character.StatMod{
Base: modifier.NewBaseWithHitlag("portable-power-saw-em", 10*60),
AffectedStat: attributes.EM,
Amount: func() ([]float64, bool) {
return w.buff, true
},
})

// regen energy after 2 secs
w.char.QueueCharTask(func() {
w.char.AddEnergy("portable-power-saw-energy", refund*float64(count))
}, 2*60)

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 @@ -3317,6 +3317,43 @@ var WeaponBaseMap = map[keys.Weapon]WeaponBase{
},
},
},
keys.PortablePowerSaw: {
AtkCurve: GROW_CURVE_ATTACK_204,
SpecializedCurve: GROW_CURVE_CRITICAL_201,
BaseAtk: 41.067100524902344,
BaseSpecialized: 0.11999999731779099,
Specialized: attributes.HPP,
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.Predator: {
AtkCurve: GROW_CURVE_ATTACK_201,
SpecializedCurve: GROW_CURVE_CRITICAL_201,
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 @@ -124,6 +124,7 @@ var weaponNames = []string{
"otherworldlystory",
"pocketgrimoire",
"polarstar",
"portablepowersaw",
"predator",
"primordialjadecutter",
"primordialjadewingedspear",
Expand Down Expand Up @@ -297,6 +298,7 @@ const (
OtherworldlyStory
PocketGrimoire
PolarStar
PortablePowerSaw
Predator
PrimordialJadeCutter
PrimordialJadeWingedSpear
Expand Down
2 changes: 2 additions & 0 deletions pkg/shortcut/weapons.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ var WeaponNameToKey = map[string]keys.Weapon{
"pocket": keys.PocketGrimoire,
"polarstar": keys.PolarStar,
"polar": keys.PolarStar,
"portablepowersaw": keys.PortablePowerSaw,
"powersaw": keys.PortablePowerSaw,
"predator": keys.Predator,
"primordialjadecutter": keys.PrimordialJadeCutter,
"jadecutter": keys.PrimordialJadeCutter,
Expand Down
1 change: 1 addition & 0 deletions pkg/simulation/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ import (
_ "github.com/genshinsim/gcsim/internal/weapons/claymore/nagamasa"
_ "github.com/genshinsim/gcsim/internal/weapons/claymore/oldmercspal"
_ "github.com/genshinsim/gcsim/internal/weapons/claymore/pines"
_ "github.com/genshinsim/gcsim/internal/weapons/claymore/powersaw"
_ "github.com/genshinsim/gcsim/internal/weapons/claymore/prototype"
_ "github.com/genshinsim/gcsim/internal/weapons/claymore/rainslasher"
_ "github.com/genshinsim/gcsim/internal/weapons/claymore/redhorn"
Expand Down
29 changes: 29 additions & 0 deletions ui/packages/docs/docs/reference/weapons/portablepowersaw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Portable Power Saw
---

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="portablepowersaw" data_src="weapon" />

## Known issues

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

## Names

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

## Params

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

## Fields

<FieldsTable item_key="portablepowersaw" data_src="weapon" />
3 changes: 3 additions & 0 deletions ui/packages/docs/src/components/Names/weapon_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@
"polarstar": [
"polar"
],
"portablepowersaw": [
"powersaw"
],
"predator": [],
"primordialjadecutter": [
"jadecutter",
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 @@ -637,6 +637,13 @@
"weapon_class": "WEAPON_BOW",
"image_name": "UI_EquipIcon_Bow_Worldbane"
},
"portablepowersaw": {
"id": 12427,
"key": "portablepowersaw",
"rarity": 4,
"weapon_class": "WEAPON_CLAYMORE",
"image_name": "UI_EquipIcon_Claymore_Mechanic"
},
"predator": {
"id": 15415,
"key": "predator",
Expand Down

0 comments on commit 715345c

Please sign in to comment.