How to.....
The bot stay and do nothing near tp spot
Code:
//cmd vars - do NOT touch
var _MyDT_PreMessage = "";
var _sealpos = 0;
var safex;
var safey;
var prevx;
var prevy;
//leader var, will be in char config, maybe
var leader = "LEADER NAME HERE";
function NTMain() {
Include("libs/common/NTCommon.ntl");
NTC_IncludeLibs();
NTC_IncludeConfig("NTBot/char_configs");
NT_LoadConfig();
NTSI_LoadNIPFiles("NTBot/item_configs");
NTA_Initialize();
if(!NTTM_CheckAct()) {
NTC_SendMsgToScript("MWBotGame.ntj", "NTTM_CheckAct()");
return;
}
NTC_Delay(2000);
if(!NTTM_CheckAct(4)) {
NTC_SendMsgToScript("MWBotGame.ntj", "NTTM_CheckAct()");
return;
}
RegisterEvent(EVENT_GAMEMSG, quitfunc);
TD_File("NTBot/bots/TeamD.txt", 1);
if(me.classid == 1) {
if(!NTTM_CheckAct(1)) {
NTC_SendMsgToScript("MWBotGame.ntj", "NTTM_CheckAct()");
return;
}
if(NTConfig_DelayStart)
NTC_Delay(20000);
Print("Loading sorc function");
NTTMGR_TownManager();
TD_Sorcfunc();
}
if(me.classid == 3) {
Print("Loading hammer function");
NTTMGR_TownManager();
NTTM_TownMove("portalspot");
while(1) {
TD_TeamCommands();
Delay(200);
}
}
if(me.classid == 4) {
Print("Loading barb function");
NTTMGR_TownManager();
NTTM_TownMove("portalspot");
while(1) {
TD_TeamCommands();
Delay(200);
}
}
NTC_SendMsgToScript("MWBotGame.ntj", "SCRIPT_END");
}
function TD_Sorcfunc() { //work in progress!
NTC_Delay(500);
if(!NTTM_TownMove("waypoint")) {
NTC_SendMsgToScript("MWBotGame.ntj", "NTTM_TownMove()");
return;
}
if(!NTM_TakeWaypoint(107)) {
NTC_SendMsgToScript("MWBotGame.ntj", "NTM_TakeWaypoint()");
return;
}
NTC_Delay(500);
NTM_MoveTo(me.areaid, me.x+5, me.y);
for(var i = 0 ; i < 5 ; i++) {
if(NTM_MakeTP())
break;
}
TD_File("NTBot/bots/TeamD.txt", 1, ".bo");
while(!me.GetState(32))
NTC_Delay(500);
NTP_DoPrecast(true);
if(!TD_MoveTo(108, 7802, 5591)) { //urdars! and svs!
NTC_SendMsgToScript("MWBotGame.ntj", "TD_MoveTo()");
return;
}
if(TD_DetectLayout(1) == 1) {
TD_MoveTo(me.areaid, 7701, 5299);
TD_Deploy(7681, 5299, 0, 0, 15, 15);
for(var i = 0 ; i < 5 ; i++) {
if(NTM_MakeTP())
break;
}
} else {
TD_MoveTo(me.areaid, 7700, 5313);
TD_Deploy(7680, 5313, 15, 15, 0, 0);
for(var i = 0 ; i < 5 ; i++) {
if(NTM_MakeTP())
break;
}
}
TD_File("NTBot/bots/TeamD.txt", 1, ".s1"); //vizier
if(!TD_VizierSeal()){
NTC_SendMsgToScript("MWBotGame.ntj", "Seal opening");
return;
}
NTM_MoveTo(me.areaid, safex, safey);
while(!TD_IsPlayerOut()) {
NTA_KillMonster(GetLocaleString(2851));
NTA_ClearPosition(10);
NTSI_PickItems();
NTM_MoveTo(me.areaid, safex, safey);
}
if(!NTTMGR_CheckSafe(NTConfig_CheckSelfSafe, NTConfig_CheckMercSafe))
{
NTC_SendMsgToScript("MWBotGame.ntj", "NTTMGR_CheckSafe()");
return;
}
NTP_DoPrecast(true);
if(TD_DetectLayout(3) == 1) {
TD_MoveTo(me.areaid, 7900, 5291);
TD_Deploy(7920, 5291, 15, 15, 0, 0);
for(var i = 0 ; i < 5 ; i++) {
if(NTM_MakeTP())
break;
}
} else {
TD_MoveTo(me.areaid, 7910, 5278);
TD_Deploy(7930, 5278, 0, 15, 15, 0);
for(var i = 0 ; i < 5 ; i++) {
if(NTM_MakeTP())
break;
}
}
TD_File("NTBot/bots/TeamD.txt", 1, ".s3"); //infector
if(!TD_InfectorSeal()){
NTC_SendMsgToScript("MWBotGame.ntj", "Seal opening");
return;
}
NTM_MoveTo(me.areaid, safex, safey);
while(!TD_IsPlayerOut()) {
NTA_KillMonster(GetLocaleString(2853));
NTA_ClearPosition(10);
NTSI_PickItems();
NTM_MoveTo(me.areaid, safex, safey);
}
if(!NTTMGR_CheckSafe(NTConfig_CheckSelfSafe, NTConfig_CheckMercSafe))
{
NTC_SendMsgToScript("MWBotGame.ntj", "NTTMGR_CheckSafe()");
return;
}
NTP_DoPrecast(true);
if(TD_DetectLayout(2) == 1) {
TD_MoveTo(me.areaid, 7776, 5230);
TD_Deploy(7776, 5220, 0, 0, 15, 15);
for(var i = 0 ; i < 5 ; i++) {
if(NTM_MakeTP())
break;
}
} else {
TD_MoveTo(me.areaid, 7779, 5200);
TD_Deploy(7779, 5180, 0, 0, 15, 15);
for(var i = 0 ; i < 5 ; i++) {
if(NTM_MakeTP())
break;
}
}
TD_File("NTBot/bots/TeamD.txt", 1, ".s2"); //de seis
if(!TD_DeSeisSeal()){
NTC_SendMsgToScript("MWBotGame.ntj", "Seal opening");
return;
}
NTM_MoveTo(me.areaid, safex, safey);
while(!TD_IsPlayerOut()) {
NTA_ClearPosition(10);
NTSI_PickItems();
NTM_MoveTo(me.areaid, safex, safey);
}
if(!NTTMGR_CheckSafe(NTConfig_CheckSelfSafe, NTConfig_CheckMercSafe))
{
NTC_SendMsgToScript("MWBotGame.ntj", "NTTMGR_CheckSafe()");
return;
}
NTP_DoPrecast(true);
if(!NTM_MoveTo(me.areaid, 7792, 5292)) {
NTC_SendMsgToScript("MWBotGame.ntj", "NTM_MoveTo()");
return;
}
NTM_MakeTP();
TD_File("NTBot/bots/TeamD.txt", 1, ".d");
NTC_FindUnit(NTC_UNIT_MONSTER, 243, 100);
if(!NTA_KillMonster(243)) {
NTC_SendMsgToScript("MWBotGame.ntj", "NTA_KillMonster()");
return;
}
NTSI_PickItems();
//anything else?
}
//--internal functions--
function quitfunc(msg, type) { //quit when leader leaves game
if(msg.indexOf(leader) != -1 && (msg.indexOf("weaken") != -1 || msg.indexOf("timeout") != -1)) { //if leader quits
//if(msg.indexOf("weaken") != -1 || msg.indexOf("timeout") != -1) { //if anyone quits
NTC_Delay(500);
ExitGame();
}
}
function TD_Preattack(classid, extrahammers) { //extra hammers = hammers cast after the seal boss is spawned
NTC_PutSkill(NTConfig_AttackSkill[4], NTC_HAND_RIGHT);
while(!NTC_FindUnit(NTC_UNIT_MONSTER, classid))
NTC_CastSkill(NTConfig_AttackSkill[3], 2);
for(var i = 0 ; i < extrahammers ; i++) {
NTC_CastSkill(NTConfig_AttackSkill[3], 2);
}
}
function TD_VizierSeal() { //vizier
for(var i = 0 ; i < 5 ; i++){
NTM_MoveToPresetUnit(me.areaid, 2, 395);
var _seal = NTC_FindUnit(NTC_UNIT_OBJECT, 395, 5);
NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _seal);
NTC_Delay(350);
if(_seal.mode <= 0)
NTM_MoveTo(me.areaid, safex, safey);
else
break;
NTC_Delay(250);
if(i == 4 && _seal.mode <= 0)
return false;
}
for(i = 0 ; i < 5 ; i++){
NTM_MoveToPresetUnit(me.areaid, 2, 396);
_seal = NTC_FindUnit(NTC_UNIT_OBJECT, 396, 5);
NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _seal);
NTC_Delay(350);
if(_seal.mode <= 0)
NTM_MoveTo(me.areaid, safex, safey);
else
break;
NTC_Delay(250);
if(i == 4 && _seal.mode <= 0)
return false;
}
return true;
}
function TD_DeSeisSeal(){ //de seis
for(var i = 0 ; i < 5 ; i++){
NTM_MoveToPresetUnit(me.areaid, 2, 394);
_seal = NTC_FindUnit(NTC_UNIT_OBJECT, 394, 5);
NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _seal);
NTC_Delay(350);
if(_seal.mode <= 0)
NTM_MoveTo(me.areaid, safex, safey);
else
break;
NTC_Delay(250);
if(i == 4 && _seal.mode <= 0)
return false;
}
return true;
}
function TD_InfectorSeal() { //infector
for(var i = 0 ; i < 5 ; i++){
NTM_MoveToPresetUnit(me.areaid, 2, 393);
_seal = NTC_FindUnit(NTC_UNIT_OBJECT, 393, 5);
NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _seal);
NTC_Delay(350);
if(_seal.mode <= 0)
NTM_MoveTo(me.areaid, safex, safey);
else
break;
NTC_Delay(250);
if(i == 4 && _seal.mode <= 0)
return false;
}
for(i = 0 ; i < 5 ; i++){
NTM_MoveToPresetUnit(me.areaid, 2, 392);
_seal = NTC_FindUnit(NTC_UNIT_OBJECT, 392, 5);
NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _seal);
NTC_Delay(350);
if(_seal.mode <= 0)
NTM_MoveTo(me.areaid, safex, safey);
else
break;
NTC_Delay(250);
if(i == 4 && _seal.mode <= 0)
return false;
}
return true;
}
function TD_TeamCommands() {
var _msg = TD_File("NTBot/bots/TeamD.txt", 0);
if (_msg && _msg != _MyDT_PreMessage) {
_MyDT_PreMessage = _msg;
switch (_msg.substring(_msg.indexOf("/") + 1)) {
case ".bo":
if(me.classid == 3) { //Hammerdin
NTM_UsePortal("BluePortal", 107, leader);
NTC_Delay(500);
NTP_DoPrecast(true);
//while(!me.GetState(32))
NTC_Delay(3500);
if(!NTM_UsePortal("BluePortal", 103, leader)) //or make my own?
NTTM_CheckAct();
}
if(me.classid == 4) { //Barb
NTM_UsePortal("BluePortal", 107, leader);
while(!me.GetState(32))
NTP_DoPrecast(true);
if(!NTM_UsePortal("BluePortal", 103, leader)) //or make my own?
NTTM_CheckAct();
}
break;
case ".s1": //vizier
if(me.classid == 3) { //Hammerdin
NTM_UsePortal("BluePortal", 108, leader);
TD_Preattack(GetLocaleString(2851), 5);
TD_KillMonster(GetLocaleString(2851));
NTA_ClearPosition(5);
NTSI_PickItems();
if(!NTM_UsePortal("BluePortal", 103, leader)) //or make my own?
NTTM_CheckAct();
NTP_DoPrecast(true);
}
if(me.classid == 4) { //Barb
NTM_UsePortal("BluePortal", 108, leader);
//for(var i = 0 ; i < 3 ; i++) {
NTC_CastSkill(130, NTC_HAND_RIGHT);
// Delay(300);
//}
NTP_DoPrecast(true);
if(!NTM_UsePortal("BluePortal", 103, leader)) //or make my own?
NTTM_CheckAct();
}
break;
case ".s2": //de seis
if(me.classid == 3) { //Hammerdin
NTM_UsePortal("BluePortal", 108, leader);
TD_Preattack(GetLocaleString(2852), 10);
TD_KillMonster(GetLocaleString(2852));
NTA_ClearPosition(15);
NTSI_PickItems();
if(!NTM_UsePortal("BluePortal", 103, leader)) //or make my own?
NTTM_CheckAct();
NTP_DoPrecast(true);
}
if(me.classid == 4) { //Barb
NTM_UsePortal("BluePortal", 108, leader);
for(var i = 0 ; i < 3 ; i++) {
NTC_CastSkill(130, NTC_HAND_RIGHT);
Delay(300);
}
NTP_DoPrecast(true);
if(!NTM_UsePortal("BluePortal", 103, leader)) //or make my own?
NTTM_CheckAct();
}
break;
case ".s3": //infector
if(me.classid == 3) { //Hammerdin
NTM_UsePortal("BluePortal", 108, leader);
TD_Preattack(GetLocaleString(2853), 5);
TD_KillMonster(GetLocaleString(2853));
NTA_ClearPosition(15);
NTSI_PickItems();
if(!NTM_UsePortal("BluePortal", 103, leader)) //or make my own?
NTTM_CheckAct();
NTP_DoPrecast(true);
}
if(me.classid == 4) { //Barb
NTM_UsePortal("BluePortal", 108, leader);
//for(var i = 0 ; i < 1 ; i++) {
NTC_CastSkill(130, NTC_HAND_RIGHT);
// Delay(300);
//}
NTP_DoPrecast(true);
if(!NTM_UsePortal("BluePortal", 103, leader)) //or make my own?
NTTM_CheckAct();
}
break;
case ".d":
if(me.classid == 3) { //Hammerdin
NTM_UsePortal("BluePortal", 108, leader);
NTC_FindUnit(NTC_UNIT_MONSTER, 243, 100);
if(!TD_KillMonster(243)) {
NTC_SendMsgToScript("MWBotGame.ntj", "TD_KillMonster()");
return;
}
NTSI_PickItems();
}
if(me.classid == 4) { //Barb
NTM_UsePortal("BluePortal", 108, leader);
NTP_DoPrecast(true);
//do something until diablo dies
var _diablo = NTC_FindUnit(NTC_UNIT_MONSTER, 243)
while(_diablo && _diablo.hp > 0)
NTC_Delay(500);
}
break;
case ".u": //urdars! and svs!
if(me.classid == 3) { //Hammerdin
NTM_UsePortal("BluePortal", 108, leader);
if(NTC_FindUnit(NTC_UNIT_MONSTER, 362))
TD_Preattack(362, 5);
else if(NTC_FindUnit(NTC_UNIT_MONSTER, 189))
TD_Preattack(189, 5);
NTA_ClearPosition(15);
NTSI_PickItems();
if(!NTM_UsePortal("BluePortal", 103, leader)) //or make my own?
NTTM_CheckAct();
NTP_DoPrecast(true);
}
if(me.classid == 4) { //Barb - ADD SOMETHING EVENTUALLY
//Say("Kolton you lazy bastard!");
NTC_Delay(250);
}
break;
}
}
}
function TD_DetectLayout(seal) {
switch(seal) {
case 1:
_sealpos = GetPresetUnits(me.areaid, NTC_UNIT_OBJECT);
for(var i = 0 ; i < _sealpos.length ; i++) {
if(_sealpos[i].id == 396) {
if(_sealpos[i].roomy*5 + _sealpos[i].y == 5275)
return 1;
else
return 2;
break;
}
}
break;
case 2:
_sealpos = GetPresetUnits(me.areaid, NTC_UNIT_OBJECT);
for(i = 0 ; i < _sealpos.length ; i++) {
if(_sealpos[i].id == 394) {
if(_sealpos[i].roomx*5 + _sealpos[i].x == 7773)
return 1;
else
return 2;
break;
}
}
break;
case 3:
_sealpos = GetPresetUnits(me.areaid, NTC_UNIT_OBJECT);
for(i = 0 ; i < _sealpos.length ; i++) {
if(_sealpos[i].id == 392) {
if(_sealpos[i].roomx*5 + _sealpos[i].x == 7893)
return 1;
else
return 2;
break;
}
}
break;
}
}
function TD_IsPlayerOut(area) { //function by Thursty
var _player;
var _myPartyId;
_player = GetPlayerUnit();
_myPartyId = _player.partyid;
if(arguments.length < 1)
_area = me.areaid;
else
_area = area;
do {
if(_player.areaid == _area && _myPartyId == _player.partyid)
return false;
NTC_Delay(100);
} while(_player.GetNext());
return true;
}
function TD_File(path, mode, msg, delay) { //big thanks to all the koreans out there
var _msg = "";
var _line = "";
var _fileHandle;
var _isFileCheck = false;
if (arguments.length < 3) msg = "";
if (arguments.length < 4) delay = (mode > 0) ? 5 : 2;
while (delay--) {
if (mode == 2 && !_isFileCheck) {
_fileHandle = FileOpen(path, 0);
if (!_fileHandle)
_fileHandle = FileOpen(path, 1);
if (_fileHandle)
_fileHandle.Close();
_isFileCheck = true;
}
_fileHandle = FileOpen(path, mode);
if (_fileHandle)
break;
if (delay)
Delay(200);
}
if (_fileHandle) {
if (mode == 0) {
while (!_fileHandle.eof) {
_line = _fileHandle.ReadLine();
if (_line || !_fileHandle.eof)
_msg += _line + msg;
}
}
else if (msg)
_fileHandle.WriteLine(msg);
_fileHandle.Close();
}
return _msg;
}
function TD_MoveTo(areaid, x, y, retry, clearpath)
{
var i, n;
var _teleport;
var _path;
var _retry = 0;
if(x == me.x && y == me.y)
return true;
if(arguments.length < 4)
retry = 3;
if(arguments.length < 5)
clearpath = false;
if(NTC_InTown() || NTC_GetSkillLevel(54) < 1)
_teleport = false;
else
_teleport = true;
_path = GetPath(areaid, me.x, me.y, x, y, _teleport);
if(!_path)
return false;
for(i = 0 ; i < _path.length ; i++)
{
for(n = 0 ; n < 2 ; n++)
{
if(_teleport)
{
if(NTM_TeleportTo(_path[i][0], _path[i][1])){
if(TDConfig_FindUrdarsAndVenoms)
TD_FindUrdar();
break;
}
}
else
{
if(NTM_WalkTo(_path[i][0], _path[i][1]))
break;
}
}
if(n < 2)
{
if(clearpath)
{
if(!NTA_ClearPosition(20, true, 2))
return false;
NTP_DoPrecast(false);
NTM_MoveTo(me.areaid, _path[i][0], _path[i][1], 1);
}
}
else if(_retry < retry)
{
_path = GetPath(areaid, me.x, me.y, x, y, _teleport);
if(!_path)
return false;
i = -1;
_retry++;
}
else
return false;
}
return true;
}
function TD_FindUrdar(){
var _urdar = NTC_FindUnit(NTC_UNIT_MONSTER, 189);
var _sv = NTC_FindUnit(NTC_UNIT_MONSTER, 362);
if(_urdar){
do{
if (_urdar.classid == 189 && (_urdar.spectype == 9 || _urdar.spectype == 17) && _urdar.mode != 0 && _urdar.hp > 0 && _urdar.mode != 12 && _urdar.IsAttackable()){
NTC_SendLogToOOG(NTC_LOG_COMMON, "˙c8Killing Urdars!"); //COMMENT THIS LINE IF TESTING IS SUCCESSFUL
//NTM_MoveTo(me.areaid, _urdar.x, _urdar.y);
TD_Deploy(_urdar.x, _urdar.y, 20, 20, 0, 20);
for(var i = 0 ; i < 5 ; i++) {
if(NTM_MakeTP())
break;
}
TD_File("NTBot/bots/TeamD.txt", 1, ".u");
NTA_ClearPosition(12);
while(!TD_IsPlayerOut()) {
NTA_ClearPosition();
NTSI_PickItems();
}
TD_File("NTBot/bots/TeamD.txt", 1, "bla");
NTC_Delay(250);
break;
}
} while(_urdar.GetNext());
}
else if(_sv){
do{
if (_sv.classid == 362 && (_sv.spectype == 9 || _sv.spectype == 17) && _sv.mode != 0 && _sv.hp > 0 && _sv.mode != 12 && _sv.IsAttackable()){
NTC_SendLogToOOG(NTC_LOG_COMMON, "˙c8Killing Super Venoms!"); //COMMENT THIS LINE IF TESTING IS SUCCESSFUL
//NTM_MoveTo(me.areaid, _sv.x, _sv.y);
TD_Deploy(_sv.x, _sv.y, 20, 20, 0, 20);
for(var i = 0 ; i < 5 ; i++) {
if(NTM_MakeTP())
break;
}
prevx = me.x;
prevy = me.y;
TD_File("NTBot/bots/TeamD.txt", 1, ".u");
NTA_ClearPosition(15);
while(!TD_IsPlayerOut()) {
NTA_ClearPosition();
NTSI_PickItems();
NTM_MoveTo(me.areaid, prevx, prevy);
}
TD_File("NTBot/bots/TeamD.txt", 1, "bla");
NTC_Delay(250);
break;
}
} while(_sv.GetNext());
}
}
function TD_Deploy(x, y, plusx, minusx, plusy, minusy) { //you can build up to 5 positions (x-shaped), center position is x, y; rest are +/- offsets
var _monster = NTC_FindUnit(NTC_UNIT_MONSTER);
var num = [0, 0, 0, 0, 0];
var firstnum = 100;
if(!_monster)
return NTM_MoveTo(me.areaid, x, y);
do {
if(GetDistance(_monster.x, _monster.y, x, y) <= 15)
if(_monster.classid != 306)
num[0]++;
if(GetDistance(_monster.x, _monster.y, x + plusx, y) <= 15)
if(_monster.classid != 306)
num[1]++;
if(GetDistance(_monster.x, _monster.y, x - minusx, y) <= 15)
if(_monster.classid != 306)
num[2]++;
if(GetDistance(_monster.x, _monster.y, x, y + plusy) <= 15)
if(_monster.classid != 306)
num[3]++;
if(GetDistance(_monster.x, _monster.y, x, y - minusy) <= 15)
if(_monster.classid != 306)
num[4]++;
}while(_monster.GetNext())
for(var i = 0 ; i < num.length ; i++) {
//Print("˙c1" + num[i] + " ˙c:monsters at position ˙c;" + i); //doesn't count storm casters as of v0.8
if(num[i] < firstnum)
firstnum = num[i];
}
if(firstnum == num[0]) {
safex = x;
safey = y;
NTM_MoveTo(me.areaid, x, y);
}
else if(firstnum == num[1]) {
safex = x + plusx;
safey = y;
NTM_MoveTo(me.areaid, x + plusx, y);
}
else if(firstnum == num[2]) {
safex = x - minusx;
safey = y;
NTM_MoveTo(me.areaid, x - minusx, y);
}
else if(firstnum == num[3]) {
safex = x;
safey = y + plusy;
NTM_MoveTo(me.areaid, x, y + plusy);
}
else if(firstnum == num[4]) {
safex = x;
safey = y - minusy;
NTM_MoveTo(me.areaid, x, y - minusy);
}
}
function TD_KillMonster(classid)
{
var _target;
if(NTConfig_AttackSkill[1] < 1)
return false;
_target = NTC_FindUnit(NTC_UNIT_MONSTER, classid, 5);
if(!_target)
return false;
if(_target.IsAttackable())
{
var _attackcount = 0;
while(_attackcount < 300 && NTA_IsValidMonster(_target))
{
if(NTA_Attack(_target, (_attackcount%30) == 0) < 2)
break;
if((_attackcount%10) == 5)
NTM_MoveTo(me.areaid, _target.x+5, _target.y);
else if((_attackcount%10) == 0)
NTM_MoveTo(me.areaid, _target.x, _target.y+5);
_attackcount++;
}
}
return (_target.hp <= 0 || _target.mode == 0 || _target.mode == 12);
}






