-
Notifications
You must be signed in to change notification settings - Fork 0
/
LumberJack.ns
85 lines (82 loc) · 3.6 KB
/
LumberJack.ns
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
label restart
VALLEY_COORDS = "XXX,YYY"
WAVES = 9
HEROES = "any,!trainer" //make sure heros are available for the no. of waves you set
CAP_CITY_COORDS = "XXX,YYY"
CAP_HEROES = "any,!trainer"
CAP_TROOPS = "s:5000"
MODIFIER = 35
START_COUNT = 450000 //Number of archers to resume script at if we fall below stop count.
STOP_COUNT = 400000 //Number of archers we cannot fall below to continue farming.
USEMAYOR = "no" //Do we want to use mayor? If so will set nomayor:1
//------Nothing to alter below here---------------------
label maintResuming
safevalleyfarm off
if (USEMAYOR == "Yes") config nomayor:1
gosub getTroops
echo "Valley is Level "+lev+" so we will attack with: "+TRP
waittime = round( (city.getTravelTime(city.fieldId, GetFieldId(VALLEY_COORDS), GetTroops(TRP), 5) * 2) / WAVES + 2)
if city.selfArmies.length > 0 goto resumeLoop
//-------------------------------------------------------
label attackLoop
if m_context.maintenanceStart goto maintenanceTime
if (city.getAvailableTroop().archer < STOP_COUNT) goto lowTroops
startTimeSplit = (date(date().time + ((city.getTravelTime(city.fieldId, GetFieldId(VALLEY_COORDS), GetTroops(TRP), 5) + 60) * 1000) + 5).toString().split(" ")[3]).split(":")
seconds = (startTimeSplit[0] * 3600) + (startTimeSplit[1] * 60) + (startTimeSplit[2] * 1) - MODIFIER
hour = floor(seconds/3600)*1
minute = floor(seconds MOD 3600 /60)
second = ((seconds MOD 3600 /60 - floor(seconds MOD 3600 /60)) * 60)
if (second < 0) minute--
if (second < 0) second = second+60
if (minute < 0) hour--
if (minute < 0) minute=minute+60
if (hour < 0) hour=hour+24
execute "abandon " + VALLEY_COORDS
execute "attack " + VALLEY_COORDS + " " + HEROES + " " + TRP
doThis = m_context.getCityManagerByFieldId(GetFieldId(CAP_CITY_COORDS)).script.callScript("attack " + VALLEY_COORDS + " " + CAP_HEROES + " " + CAP_TROOPS + " @:" + hour + ":" + minute + ":" + second)
execute "sleep " + waittime
goto attackLoop
//------------------------------------------
label maintenanceTime
if !m_context.maintenanceStart echo "Resuming script after maintenance."
if !m_context.maintenanceStart goto restart
sleep 30
goto maintenanceTime
label lowTroops
echo "Archers below "+FormatNumber(STOP_COUNT)+". Pausing Script, turning on SafeValleyFarming."
recallall
goal "safevalleyfarm 7,8,9,10"
goal "config nomayor:0"
label troopCheckLoop
if (city.getAvailableTroop().archer >= START_COUNT) echo "Resuming Farm script and disabling SVF"
if (city.getAvailableTroop().archer >= START_COUNT) goto resumeLoop
sleep 180
goto troopCheckLoop
label resumeLoop
Echo "Recalling all troops before doing anything else"
safevalleyfarm off
recallall
Z = 0
timeReturn = 0
label findReturnTime
if (Z >= city.selfArmies.length) goto gotTime
if (city.selfArmies[Z].reachTime > timeReturn) timeReturn = city.selfArmies[Z].reachTime
Z++
goto findReturnTime
label gotTime
sleepHours = date(timeReturn).getHours()
sleepMins = date(timeReturn).getMinutes()
sleepSecs = date(timeReturn).getSeconds()+5
if (sleepSecs > 59) sleepMins++
if (sleepSecs > 59) sleepSecs = sleepSecs - 60
if (sleepMins > 59) sleepHours++
if (sleepMins > 59) sleepMins = sleepMins - 60
if (sleepHours > 23) sleepHours = sleepHours - 24
sleepTime = sleepHours+":"+sleepMins+":"+sleepSecs
execute "sleep @:" + sleepTime
goto maintResuming
label getTroops
TROOPS = ["a:50","a:100","a:200","w:1,s:1,p:1,sw:1,a:400,wo:1","w:1,s:1,p:1,sw:1,c:1,a:800,wo:1","w:1,s:1,p:1,sw:1,c:1,a:1600,wo:1","w:1,s:1,p:1,sw:1,c:1,a:3200,wo:1","wo:1,w:1,s:1,p:1,sw:1,a:10000,c:1,b:100","wo:1,w:1,s:1,p:1,sw:1,a:16000,c:1,b:500","wo:1,w:1,s:1,p:1,sw:1,a:32000,c:1,b:1000"]
lev = GetLevel(GetFieldId(VALLEY_COORDS))
TRP = TROOPS[lev-1]
return