From 3ba160a5d3fe34ea940d14710cb06c840cb38bc1 Mon Sep 17 00:00:00 2001 From: kdovtdc Date: Sat, 5 Oct 2024 16:22:24 +0200 Subject: [PATCH 1/3] Implement Inherently Unjust Destiny (LC) * init lc setup * register modifiers * added def and special shield listener to owner * implemented `state` struct with values for modifiers * implemented logic for modifiers --- .../inherentlyunjustdestiny/data.go | 71 +++++++++++ .../inherentlyunjustdestiny.go | 112 ++++++++++++++++++ pkg/key/lightcone.go | 1 + pkg/simulation/imports.go | 1 + 4 files changed, 185 insertions(+) create mode 100644 internal/lightcone/preservation/inherentlyunjustdestiny/data.go create mode 100644 internal/lightcone/preservation/inherentlyunjustdestiny/inherentlyunjustdestiny.go diff --git a/internal/lightcone/preservation/inherentlyunjustdestiny/data.go b/internal/lightcone/preservation/inherentlyunjustdestiny/data.go new file mode 100644 index 00000000..478de58f --- /dev/null +++ b/internal/lightcone/preservation/inherentlyunjustdestiny/data.go @@ -0,0 +1,71 @@ +// Code generated by "weapstat"; DO NOT EDIT. + +package inherentlyunjustdestiny + +import "github.com/simimpact/srsim/pkg/engine/equip/lightcone" + +var promotions = []lightcone.PromotionData{ + { + MaxLevel: 20, + HPBase: 48, + HPAdd: 7.2, + ATKBase: 19.2, + ATKAdd: 2.88, + DEFBase: 30, + DEFAdd: 4.5, + }, + { + MaxLevel: 30, + HPBase: 105.6, + HPAdd: 7.2, + ATKBase: 42.24, + ATKAdd: 2.88, + DEFBase: 66, + DEFAdd: 4.5, + }, + { + MaxLevel: 40, + HPBase: 182.4, + HPAdd: 7.2, + ATKBase: 72.96, + ATKAdd: 2.88, + DEFBase: 114, + DEFAdd: 4.5, + }, + { + MaxLevel: 50, + HPBase: 259.2, + HPAdd: 7.2, + ATKBase: 103.68, + ATKAdd: 2.88, + DEFBase: 162, + DEFAdd: 4.5, + }, + { + MaxLevel: 60, + HPBase: 336, + HPAdd: 7.2, + ATKBase: 134.4, + ATKAdd: 2.88, + DEFBase: 210, + DEFAdd: 4.5, + }, + { + MaxLevel: 70, + HPBase: 412.8, + HPAdd: 7.2, + ATKBase: 165.12, + ATKAdd: 2.88, + DEFBase: 258, + DEFAdd: 4.5, + }, + { + MaxLevel: 80, + HPBase: 489.6, + HPAdd: 7.2, + ATKBase: 195.84, + ATKAdd: 2.88, + DEFBase: 306, + DEFAdd: 4.5, + }, +} \ No newline at end of file diff --git a/internal/lightcone/preservation/inherentlyunjustdestiny/inherentlyunjustdestiny.go b/internal/lightcone/preservation/inherentlyunjustdestiny/inherentlyunjustdestiny.go new file mode 100644 index 00000000..b343a337 --- /dev/null +++ b/internal/lightcone/preservation/inherentlyunjustdestiny/inherentlyunjustdestiny.go @@ -0,0 +1,112 @@ +package inherentlyunjustdestiny + +import ( + "github.com/simimpact/srsim/pkg/engine" + "github.com/simimpact/srsim/pkg/engine/equip/lightcone" + "github.com/simimpact/srsim/pkg/engine/event" + "github.com/simimpact/srsim/pkg/engine/info" + "github.com/simimpact/srsim/pkg/engine/modifier" + "github.com/simimpact/srsim/pkg/engine/prop" + "github.com/simimpact/srsim/pkg/key" + "github.com/simimpact/srsim/pkg/model" +) + +const ( + Check = "inherently-unjust-destiny" + ShieldCdmg = "inherently-unjust-destiny-cdmg-buff" + AllIn = "inherently-unjust-destiny-vuln-debuff" +) + +type state struct { + chance float64 + vuln float64 + applieddynamic bool +} + +// Increases the wearer's DEF by 40/46/52/58/64%. When the wearer provides a Shield to an ally, +// the wearer's CRIT DMG increases by 40/46/52/58/64%, lasting for 2 turn(s). +// When the wearer's follow-up attack hits an enemy target, there is a 100/115/130/145/160% base chance +// to increase the DMG taken by the attacked enemy target by 10/11.5/13/14.5/16%, lasting for 2 turn(s). + +func init() { + lightcone.Register(key.InherentlyUnjustDestiny, lightcone.Config{ + CreatePassive: Create, + Rarity: 5, + Path: model.Path_PRESERVATION, + Promotions: promotions, + }) + + modifier.Register(Check, modifier.Config{ + Listeners: modifier.Listeners{ + OnBeforeHitAll: applyVuln, + }, + }) + + modifier.Register(ShieldCdmg, modifier.Config{ + Stacking: modifier.Replace, + StatusType: model.StatusType_STATUS_BUFF, + // CanDispel: true, + }) + + modifier.Register(AllIn, modifier.Config{ + Stacking: modifier.ReplaceBySource, + StatusType: model.StatusType_STATUS_DEBUFF, + // CanDispel: true, + Listeners: modifier.Listeners{ + OnBeforeBeingHitAll: func(mod *modifier.Instance, e event.HitStart) { + e.Hit.Defender.AddProperty(AllIn, prop.AllDamageTaken, mod.State().(state).vuln) + }, + }, + }) +} + +func Create(engine engine.Engine, owner key.TargetID, lc info.LightCone) { + defncdmgAmt := 0.34 + 0.06*float64(lc.Imposition) + chanceAmt := 0.85 + 0.15*float64(lc.Imposition) + vulnAmt := chanceAmt * 0.1 + + engine.AddModifier(owner, info.Modifier{ + Name: Check, + Source: owner, + Stats: info.PropMap{prop.DEFPercent: defncdmgAmt}, + State: &state{ + chance: chanceAmt, + vuln: vulnAmt, + applieddynamic: false, + }, + }) + + // Special shield listener for owner providing shields + engine.Events().ShieldAdded.Subscribe(func(event event.ShieldAdded) { + if event.Info.Source == owner { + engine.AddModifier(owner, info.Modifier{ + Name: ShieldCdmg, + Source: owner, + Duration: 2, + Stats: info.PropMap{prop.CritDMG: defncdmgAmt}, + }) + } + }) +} + +func applyVuln(mod *modifier.Instance, e event.HitStart) { + st := mod.State().(*state) + if e.Hit.AttackType == model.AttackType_INSERT { + mod.Engine().AddModifier(e.Defender, info.Modifier{ + Name: AllIn, + Source: mod.Owner(), + Duration: 2, + Stats: info.PropMap{prop.AllDamageTaken: st.vuln}, + Chance: st.chance, + }) + } + // Logic to apply the debuff on the first hit, ensuring that this hit also benefits from the vuln effect + if !mod.Engine().HasModifierFromSource(e.Defender, mod.Owner(), AllIn) { + st.applieddynamic = false + } else { + if !st.applieddynamic { + e.Hit.Defender.AddProperty(AllIn, prop.AllDamageTaken, st.vuln) + st.applieddynamic = true + } + } +} diff --git a/pkg/key/lightcone.go b/pkg/key/lightcone.go index a2a912c6..38924ce9 100644 --- a/pkg/key/lightcone.go +++ b/pkg/key/lightcone.go @@ -85,6 +85,7 @@ const ( Pioneering LightCone = "pioneering" WeAreWildfire LightCone = "we_are_wildfire" LandausChoice LightCone = "landaus_choice" + InherentlyUnjustDestiny LightCone = "inherently_unjust_destiny" ) // Abundance diff --git a/pkg/simulation/imports.go b/pkg/simulation/imports.go index dbe680a3..ee6312a9 100644 --- a/pkg/simulation/imports.go +++ b/pkg/simulation/imports.go @@ -92,6 +92,7 @@ import ( _ "github.com/simimpact/srsim/internal/lightcone/preservation/amber" _ "github.com/simimpact/srsim/internal/lightcone/preservation/dayoneofmynewlife" _ "github.com/simimpact/srsim/internal/lightcone/preservation/defense" + _ "github.com/simimpact/srsim/internal/lightcone/preservation/inherentlyunjustdestiny" _ "github.com/simimpact/srsim/internal/lightcone/preservation/landauschoice" _ "github.com/simimpact/srsim/internal/lightcone/preservation/momentofvictory" _ "github.com/simimpact/srsim/internal/lightcone/preservation/pioneering" From 469c8581febbb951a4d2d41fb70beccc89d70b2f Mon Sep 17 00:00:00 2001 From: kdovtdc Date: Sat, 5 Oct 2024 16:28:51 +0200 Subject: [PATCH 2/3] Fix linter --- .../inherentlyunjustdestiny/inherentlyunjustdestiny.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/internal/lightcone/preservation/inherentlyunjustdestiny/inherentlyunjustdestiny.go b/internal/lightcone/preservation/inherentlyunjustdestiny/inherentlyunjustdestiny.go index b343a337..2ba4df9c 100644 --- a/internal/lightcone/preservation/inherentlyunjustdestiny/inherentlyunjustdestiny.go +++ b/internal/lightcone/preservation/inherentlyunjustdestiny/inherentlyunjustdestiny.go @@ -103,10 +103,8 @@ func applyVuln(mod *modifier.Instance, e event.HitStart) { // Logic to apply the debuff on the first hit, ensuring that this hit also benefits from the vuln effect if !mod.Engine().HasModifierFromSource(e.Defender, mod.Owner(), AllIn) { st.applieddynamic = false - } else { - if !st.applieddynamic { - e.Hit.Defender.AddProperty(AllIn, prop.AllDamageTaken, st.vuln) - st.applieddynamic = true - } + } else if !st.applieddynamic { + e.Hit.Defender.AddProperty(AllIn, prop.AllDamageTaken, st.vuln) + st.applieddynamic = true } } From 35ff456f1eb6ddebdc4451f7e160a5698a592c2a Mon Sep 17 00:00:00 2001 From: kdovtdc Date: Sun, 24 Nov 2024 18:33:27 +0100 Subject: [PATCH 3/3] Update with `CanDispel` field --- .../inherentlyunjustdestiny/inherentlyunjustdestiny.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/lightcone/preservation/inherentlyunjustdestiny/inherentlyunjustdestiny.go b/internal/lightcone/preservation/inherentlyunjustdestiny/inherentlyunjustdestiny.go index 2ba4df9c..cb4cf5b4 100644 --- a/internal/lightcone/preservation/inherentlyunjustdestiny/inherentlyunjustdestiny.go +++ b/internal/lightcone/preservation/inherentlyunjustdestiny/inherentlyunjustdestiny.go @@ -45,13 +45,13 @@ func init() { modifier.Register(ShieldCdmg, modifier.Config{ Stacking: modifier.Replace, StatusType: model.StatusType_STATUS_BUFF, - // CanDispel: true, + CanDispel: true, }) modifier.Register(AllIn, modifier.Config{ Stacking: modifier.ReplaceBySource, StatusType: model.StatusType_STATUS_DEBUFF, - // CanDispel: true, + CanDispel: true, Listeners: modifier.Listeners{ OnBeforeBeingHitAll: func(mod *modifier.Instance, e event.HitStart) { e.Hit.Defender.AddProperty(AllIn, prop.AllDamageTaken, mod.State().(state).vuln)