forked from ogame-ninja/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspy_moons_activity.go
62 lines (56 loc) · 2.19 KB
/
spy_moons_activity.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
origin = GetCachedCelestial("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
maxActivity = 20 // Maximum moon activity
// 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(origin)
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(origin.GetCoordinate().Galaxy, system)
for i = 1; i <= 15; i++ {
planetInfo = systemInfos.Position(i)
if !shouldSkip(planetInfo) && planetInfo.Moon != nil && planetInfo.Moon.Activity >= 15 && planetInfo.Moon.Activity <= maxActivity {
pCoord = planetInfo.Coordinate
mCoord = pCoord.Moon()
spyCoord(mCoord)
}
}
}