/
worthyAttr.go
172 lines (149 loc) · 6.38 KB
/
worthyAttr.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
package sde
import (
"fmt"
"github.com/THUNDERGROOVE/SDETool2/log"
"reflect"
"sort"
"strings"
"time"
)
var WorthyAttributes map[string]AtterSet
type AtterSet struct {
SetName string
AttributeName string
DoRangeFilter bool
DoIntervalFilter bool
ValueFunc func(t SDEType, val interface{}) interface{}
}
func init() {
defer Debug(time.Now())
WorthyAttributes = make(map[string]AtterSet, 0)
// Biotic stuff
WorthyAttributes["mCharProp.meleeDamage"] = AtterSet{SetName: "Biotics", AttributeName: "melee damage"}
WorthyAttributes["mCharProp.maxStamina"] = AtterSet{SetName: "Biotics", AttributeName: "stamina"}
WorthyAttributes["mCharProp.staminaRecoveryPerSecond"] = AtterSet{SetName: "Biotics", AttributeName: "stamina recovery"}
WorthyAttributes["mVICProp.groundSpeed"] = AtterSet{SetName: "Biotics", AttributeName: "speed", DoRangeFilter: true}
WorthyAttributes["mCharProp.movementSprint.groundSpeedScale"] = AtterSet{SetName: "Biotics", AttributeName: "sprint speed", DoRangeFilter: true,
ValueFunc: func(t SDEType, val interface{}) interface{} {
if v, ok := t.Attributes["mVICProp.groundSpeed"]; ok {
if speed, kk := val.(float64); kk {
if scale, kkk := v.(float64); kkk {
log.Info("Speed:", speed, "scale:", scale)
return interface{}(float64(speed * scale))
}
}
} else {
log.LogError("Type assertion error. speed:", reflect.TypeOf(v), "val:", reflect.TypeOf(val))
}
return interface{}(float64(-1))
}}
WorthyAttributes["mCharProp.movementRun.strafeSpeedScale"] = AtterSet{SetName: "Biotics", AttributeName: "strafe speed", DoRangeFilter: true,
ValueFunc: func(t SDEType, val interface{}) interface{} {
if v, ok := t.Attributes["mVICProp.groundSpeed"]; ok {
if speed, kk := val.(float64); kk {
if scale, kkk := v.(float64); kkk {
log.Info("Speed:", speed, "scale:", scale)
return interface{}(float64(speed * scale))
}
}
} else {
log.LogError("Type assertion error. speed:", reflect.TypeOf(v), "val:", reflect.TypeOf(val))
}
return interface{}(float64(-1))
}}
// Regen
WorthyAttributes["mVICProp.healArmorRate"] = AtterSet{SetName: "Regeneration", AttributeName: "armor repair rate"}
WorthyAttributes["mVICProp.healShieldRate"] = AtterSet{SetName: "Regeneration", AttributeName: "shield recharge rate"}
WorthyAttributes["mVICProp.shieldRechargeDelay"] = AtterSet{SetName: "Regeneration", AttributeName: "shield recharge delay"}
WorthyAttributes["mVICProp.shieldRechargePauseOnShieldDepleted"] = AtterSet{SetName: "Regeneration", AttributeName: "shield depleted delay"}
//HP
WorthyAttributes["mVICProp.maxArmor"] = AtterSet{SetName: "HP", AttributeName: "armor"}
WorthyAttributes["mVICProp.maxShield"] = AtterSet{SetName: "HP", AttributeName: "shield"}
//Fitting
WorthyAttributes["mVICProp.maxPowerReserve"] = AtterSet{SetName: "Fitting", AttributeName: "PG"}
WorthyAttributes["mVICProp.maxCpuReserve"] = AtterSet{SetName: "Fitting", AttributeName: "CPU"}
WorthyAttributes["mVICProp.amountCpuUsage"] = AtterSet{SetName: "Fitting", AttributeName: "CPU usage"}
WorthyAttributes["mVICProp.amountPowerUsage"] = AtterSet{SetName: "Fitting", AttributeName: "PG usage"}
//EWAR
WorthyAttributes["mVICProp.signatureScanPrecision"] = AtterSet{SetName: "EWAR", AttributeName: "scan precision"}
WorthyAttributes["mVICProp.signatureScanProfile"] = AtterSet{SetName: "EWAR", AttributeName: "scan profile"}
WorthyAttributes["mVICProp.signatureScanRadius"] = AtterSet{SetName: "EWAR", AttributeName: "scan radius", DoRangeFilter: true}
// Weapon
WorthyAttributes["mFireMode0.instantHitDamage"] = AtterSet{SetName: "Weapon", AttributeName: "damage"}
WorthyAttributes["mFireMode0.fireInterval"] = AtterSet{SetName: "Weapon", AttributeName: "rate of fire", DoIntervalFilter: true}
WorthyAttributes["mFireMode0.magazineSize"] = AtterSet{SetName: "Weapon", AttributeName: "magazine size"}
WorthyAttributes["mFireMode0.maxAmmoCount"] = AtterSet{SetName: "Weapon", AttributeName: "total ammo"}
WorthyAttributes["mFireMode0.reloadTime"] = AtterSet{SetName: "Weapon", AttributeName: "reload time"}
//Misc
WorthyAttributes["metaLevel"] = AtterSet{SetName: "Misc", AttributeName: "meta level"}
}
func PrintWorthyStats(t SDEType) {
defer Debug(time.Now())
p := make(map[string][]string)
// Iterate attributes for matches
for k, v := range WorthyAttributes {
if val, ok := t.Attributes[k]; ok {
if _, kk := p[v.SetName]; !kk {
p[v.SetName] = make([]string, 0)
}
if v.ValueFunc != nil {
val = v.ValueFunc(t, val)
}
if v.DoRangeFilter {
val = DoRangeFilter(val)
}
if v.DoIntervalFilter {
val = IntervalFilter(val)
}
p[v.SetName] = append(p[v.SetName], fmt.Sprintf("%v: %v", v.AttributeName, val))
}
}
// Check modifiers.
for k, v := range t.Attributes {
if strings.Contains(k, ".attributeName") {
index := strings.Split(strings.Split(k, "modifier.")[1], ".")[0]
for kk, vv := range WorthyAttributes {
if vstr, ok := v.(string); ok {
log.Info("Attribute", k, "is of index", index, "?")
if kk == vstr {
log.Info("Holy tits found a match")
val := t.Attributes[fmt.Sprintf("modifier.%v.modifierValue", index)]
mod := t.Attributes[fmt.Sprintf("modifier.%v.modifierType", index)]
if vv.DoRangeFilter {
p[vv.SetName] = append(p[vv.SetName], fmt.Sprintf("modifies: %v by %v using %v", vv.AttributeName, DoRangeFilter(val), mod))
} else {
p[vv.SetName] = append(p[vv.SetName], fmt.Sprintf("modifies: %v by %v using %v", vv.AttributeName, val, mod))
}
}
} else {
log.LogError("Attribute name wasn't a stirng? o:")
}
}
}
}
keys := make([]string, 0)
for k, _ := range p {
keys = append(keys, k)
}
sort.Strings(keys)
for _, key := range keys {
fmt.Printf("=== %v ===\n", key)
for _, vv := range p[key] {
fmt.Printf(" %v\n", vv)
}
}
}
func DoRangeFilter(i interface{}) float64 {
if v, ok := i.(float64); ok {
return float64(v / 100)
}
log.Info("Do range filter had no float in interface :/ got", reflect.TypeOf(i))
return float64(-1)
}
func IntervalFilter(i interface{}) float64 {
if v, ok := i.(float64); ok {
return float64(v * 6000)
}
log.Info("Interval filter had no float in interface :/ got", reflect.TypeOf(i))
return float64(-1)
}