-
Notifications
You must be signed in to change notification settings - Fork 0
/
battlecruiser.go
65 lines (58 loc) · 1.72 KB
/
battlecruiser.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
package micro
import (
"bitbucket.org/aisee/veterran/bot"
"github.com/aiseeq/s2l/lib/scl"
"github.com/aiseeq/s2l/protocol/api"
"github.com/aiseeq/s2l/protocol/enums/ability"
"github.com/aiseeq/s2l/protocol/enums/buff"
)
func BattlecruiserRetreat(u *scl.Unit) bool {
if (u.HasAbility(ability.Effect_TacticalJump) && u.Hits < 150) ||
(!u.HasAbility(ability.Effect_TacticalJump) && u.Hits < u.HitsMax/2) ||
u.HasBuff(buff.RavenScramblerMissile) {
B.Groups.Add(bot.MechRetreat, u)
return true
}
return false
}
func BattlecruiserCast(u *scl.Unit, yamatoTargets map[api.UnitTag]int) bool {
if Targets.ForYamato.Exists() && u.HasAbility(ability.Effect_YamatoGun) {
targets := Targets.ForYamato.InRangeOf(u, 4).Filter(func(unit *scl.Unit) bool {
return unit.Hits-float64(yamatoTargets[unit.Tag]*240) > 0
})
if targets.Exists() {
target := targets.Filter(func(unit *scl.Unit) bool {
return unit.Hits-float64(yamatoTargets[unit.Tag]*240) <= 240
}).Max(scl.CmpHits)
if target == nil {
target = targets.Max(scl.CmpHits)
}
u.CommandTag(ability.Effect_YamatoGun, target.Tag)
yamatoTargets[target.Tag]++
return true
}
}
return false
}
func BattlecruisersAttack(u *scl.Unit) bool {
if Targets.All.Exists() {
u.Attack(Targets.ForYamato, Targets.AntiAir, Targets.Armed, Targets.All)
return true
}
return false
}
func BattlecruisersLogic(us scl.Units) {
if us.Empty() {
return
}
yamatoTargets := map[api.UnitTag]int{}
for _, u := range us {
if u.TargetAbility() == ability.Effect_YamatoGun {
yamatoTargets[u.TargetTag()]++
}
}
for _, u := range us {
_ = BattlecruiserRetreat(u) || u.EvadeEffects() || BattlecruiserCast(u, yamatoTargets) ||
BattlecruisersAttack(u) || DefaultExplore(u)
}
}