fix chance to cast attribute parsing
This commit is contained in:
@@ -401,10 +401,50 @@ func (r Rule) Evaluate(it data.Item) (RuleResult, error) {
|
|||||||
statFound := false
|
statFound := false
|
||||||
var statValue int
|
var statValue int
|
||||||
|
|
||||||
|
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 {
|
if itemStat, found := it.FindStat(stat.ID(statData[0]), layer); found {
|
||||||
statValue = itemStat.Value
|
statValue = itemStat.Value
|
||||||
statFound = true
|
statFound = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Special handling for stats not found
|
// Special handling for stats not found
|
||||||
if !statFound {
|
if !statFound {
|
||||||
|
|||||||
Reference in New Issue
Block a user