From f73256478a5b793614265ef8cccd08fec908565e Mon Sep 17 00:00:00 2001 From: guiyomu-dev <22749537+guiyomu-dev@users.noreply.github.com> Date: Wed, 4 Feb 2026 21:00:28 +0100 Subject: [PATCH] fix chance to cast attribute parsing --- pkg/nip/rule.go | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/pkg/nip/rule.go b/pkg/nip/rule.go index c754cbd..0ec5de8 100644 --- a/pkg/nip/rule.go +++ b/pkg/nip/rule.go @@ -401,9 +401,49 @@ func (r Rule) Evaluate(it data.Item) (RuleResult, error) { statFound := false var statValue int - if itemStat, found := it.FindStat(stat.ID(statData[0]), layer); found { - statValue = itemStat.Value - statFound = true + isChanceToCast := false + targetID := stat.ID(statData[0]) + + // Special cases, those encode skill ID and level in the layer + switch targetID { + case stat.SkillOnAttack, stat.SkillOnKill, stat.SkillOnDeath, stat.SkillOnHit, stat.SkillOnLevelUp, stat.SkillOnGetHit, stat.ItemChargedSkill: + isChanceToCast = true + } + + if isChanceToCast && (layer == 1 || layer == 2) { + var foundStat *stat.Data + for _, s := range it.Stats { + if s.ID == targetID { + foundStat = &s + break + } + } + + if foundStat == nil { + for _, s := range it.BaseStats { + if s.ID == targetID { + foundStat = &s + break + } + } + } + + if foundStat != nil { + statFound = true + skillID := foundStat.Layer >> 6 + level := foundStat.Layer & 0x3F + + if layer == 1 { + statValue = skillID + } else { + statValue = level + } + } + } else { + if itemStat, found := it.FindStat(stat.ID(statData[0]), layer); found { + statValue = itemStat.Value + statFound = true + } } // Special handling for stats not found