-
Notifications
You must be signed in to change notification settings - Fork 0
/
HeroTrainer.ns
46 lines (40 loc) · 1.17 KB
/
HeroTrainer.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
label autorun
//***********
//LV10 NPC Hero Trainer
//***********
HERO = "Trebator" //Set Hero name here
TYPE = "cav" //cav or arch training. Transports are not used to optimise speed.
RADIUS = 15 //How far out to look for NPC's.
//***********
//STOP EDITING
//***********
TROOPS = TYPE.substr(0, 1) + ":" + (city.getMaxArmySize() - 5k) + ",s:5k"
echo "Troops are: " + TROOPS
echo "Finding NPC's to train on"
NPCS = FindField(city.x,city.y,RADIUS,12,10).sort(city.compareByDistanceToCastle)
echo "Found "+NPCS.length+" Level 10 NPCs within "+RADIUS+" miles."
if NPCS.length < 1 goto noNPCS
echo "Preparing to farm."
label setup
TIME = date().getTime()
X = 0
label theLoop
if X>=NPCS.length gosub waitForHour
if (date().getTime() - TIME > 3600000) goto setup
execute "attack " + FieldIdToCoords(NPCS[X++]) + " " + HERO + " " + TROOPS
execute "waithero " + HERO
if ( m_context.maintenanceStart > 0 ) goto sleepy
sleep 15
loop theLoop
label waitForHour
PAST = date().getTime() - TIME
LEFT = (3600000-PAST)/1000
execute "sleep " + LEFT
return
label sleepy
if ( m_context.maintenanceStart == 0 ) goto autorun
sleep 65
loop sleepy
label noNPCS
echo "Found no NPC's to farm on. Ending script."
end