-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathspy_active_moons.go
69 lines (61 loc) · 2.28 KB
/
spy_active_moons.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
origin = "1:2:3" // Celestial from where to spy from
spyFromSystem = 1 // Lower limit system to spy
spyToSystem = 299 // Upper limit system to spy
spy2send = 2 // Number of spy probes to send
playersToIgnore = ["Nickname1", "Nickname2"] // Name of players to ignore
alliancesToIgnore = ["Alliance1", "Alliance2"] // Name of alliances to ignore
//--------------------------------------------------------------------------------
originCelestial = GetCachedCelestial(origin)
if originCelestial == nil {
LogError("invalid origin coordinate", origin)
return
}
// Skip if player is inactive or player from my alliance
func shouldSkip(planetInfo) {
if planetInfo == nil { return true }
// Check ignored players list
for playerName in playersToIgnore {
if planetInfo.Player.Name == playerName {
return true
}
}
// Check ignored alliances list
for allianceName in alliancesToIgnore {
if (planetInfo.Alliance != nil && planetInfo.Alliance.Name == allianceName) {
return true
}
}
return planetInfo.Inactive || planetInfo.Vacation
}
// Sends spy probes to a coordinate
func spyCoord(coord) {
for {
slots = GetSlots()
if slots.InUse < slots.Total {
fleet = NewFleet()
fleet.SetOrigin(originCelestial)
fleet.SetDestination(coord)
fleet.SetMission(SPY)
fleet.AddShips(ESPIONAGEPROBE, spy2send)
fleet, err = fleet.SendNow()
Print("Sending probes to", coord)
break
} else {
SleepSec(30) // Wait 30s
}
}
}
// Foreach systems in the defined range, spy all active moons
if spyFromSystem < 1 { spyFromSystem = 1 }
if spyToSystem > SYSTEMS { spyToSystem = SYSTEMS }
for system = spyFromSystem; system <= spyToSystem; system++ {
systemInfos, _ = GalaxyInfos(originCelestial.GetCoordinate().Galaxy, system)
for i = 1; i <= 15; i++ {
planetInfo = systemInfos.Position(i)
if !shouldSkip(planetInfo) && planetInfo.Moon != nil {
pCoord = planetInfo.Coordinate
mCoord = pCoord.Moon()
spyCoord(mCoord)
}
}
}