const _NTR_STRING_COW_KING = GetLocaleString(2850);
const _NTR_COW_KING_RANGE = 125;
const _NTR_STRING_PORTAL = GetLocaleString(3226);
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("NTBotGame.ntj", "NTTM_CheckAct()");
return;
}
NTTMGR_TownManager();
if(!NTTM_TownMove("waypoint"))
{
NTC_SendMsgToScript("NTBotGame.ntj", "NTTM_TownMove()");
return;
}
if(!NTM_TakeWaypoint(4))
{
NTC_SendMsgToScript("NTBotGame.ntj", "NTM_TakeWaypoint()");
return;
}
NTP_DoPrecast(true);
if(!NTM_MoveToPresetUnit(me.areaid, NTC_UNIT_MONSTER, 737, 10, 10))
{
NTC_SendMsgToScript("NTBotGame.ntj", "NTM_MoveToPresetUnit()");
return;
}
if(!NTM_UsePortal("Portal", 38))
{
NTC_SendMsgToScript("NTBotGame.ntj", "NTM_UsePortal()");
return;
}
Print("ÿc:[MooMooFarm Script]");
var _wirtbody, _cube, _leg, _portal, _stash, _items, i, _npc, prearea;
NTM_MoveTo(me.areaid, 25047, 5178);
if(NTA_ClearPosition(10))
NTSI_PickItems();
_wirtbody = NTC_FindUnit(NTC_UNIT_OBJECT, 268);
if(!_wirtbody)
{
NTC_SendMsgToScript("NTBotGame.ntj", "Wirt's body not found.");
return;
}
if(NTM_MoveTo(_wirtbody.areaid, _wirtbody.x+3, _wirtbody.y))
{
if(NTC_OpenChest(_wirtbody))
{
NTC_PingDelay(500);
for (i = 0; i < 10; i++)
{
_leg = NTC_FindUnit(NTC_UNIT_ITEM, 88);
if (_leg)
break;
}
if(!NTT_CheckSpace(_leg.xsize, _leg.ysize))
{
_prearea = me.areaid;
if(NTTM_CheckAct())
{
NTTMGR_TownManager(true);
NTTM_TownMove("portalspot")
NTM_UsePortal("BluePortal", _prearea)
}
}
for (i = 0; i < 20; i++)
{
if ((i % 5) == 0)
{
if (_leg.mode == 3 || _leg.mode == 5)
{
if (NTC_ClearCursor())
NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _leg);
}
}
NTC_PingDelay(100);
if (_leg.mode != 3 && _leg.mode != 5)
{
Print("ÿc4Got Leg");
NTC_PingDelay(200);
break;
}
}
}
}
if(!_leg)
{
NTC_SendMsgToScript("NTBotGame.ntj", "No leg found.");
return;
}
NTM_MakeTP();
NTM_UsePortal("BluePortal");
NTTM_TownMove("akara");
for(var i = 0 ; i < 10 ; i++)
{
_npc = NTC_FindUnit(NTC_UNIT_NPC, NTC_NPC_ID_AKARA);
if(_npc)
break;
}
if(_npc)
{
if(NTT_DoInteract(_npc))
{
if(NTT_DoTrade(_npc))
{
NTT_FillTome(_npc, 1);
NTT_FillTome(_npc, 0);
NTT_SecondTomeTP(_npc, "tbk", 1);
_portal = NTR_GetTP();
if(!_portal)
{
NTC_SendMsgToScript("NTBotGame.ntj", "No extra tome of townportal found.");
return;
}
}
}
me.Cancel(1);
}
NTTM_TownMove("stash");
for(var i = 0 ; i < 10 ; i++)
{
_stash = NTC_FindUnit(NTC_UNIT_OBJECT, NTC_UNIT_STASH);
if(_stash)
break;
}
if(NTT_DoInteract(_stash))
{
_items = me.GetItems(NTC_UNIT_CUBE);
_cube = _items[0];
if(!_cube)
{
NTC_SendMsgToScript("NTBotGame.ntj", "No cube found.");
return;
}
if(NTCU_CheckCubeInventoryInt() > 0)
{
NTCU_OpenCubeInt(_cube)
if(NTCU_ClearCubeInt() < 1)
{
NTC_SendMsgToScript("NTBotGame.ntj", "Cube cannot be emptied.");
return;
}
NTCU_CloseCubeInt();
}
NTCU_MoveItemToCubeInt(_cube,_leg)
NTCU_MoveItemToCubeInt(_cube,_portal)
NTCU_OpenCubeInt(_cube);
Transmute();
Transmute();
Transmute();
NTC_PingDelay(500);
NTCU_CloseCubeInt();
me.Cancel(1);
}
NTC_PingDelay(500);
if(!NTR_TakeCowPortal(12))
{
NTC_SendMsgToScript("NTBotGame.ntj", "Failed to take Cow Portal.");
return;
}
NTP_DoPrecast();
NTR_ClearRooms(150, NTC_UNIT_MONSTER, 773, _NTR_COW_KING_RANGE);
NTC_SendMsgToScript("NTBotGame.ntj", "SCRIPT_END");
}
// Internal functions
function NTR_GetTP()
{
var _portals = me.GetItems("tbk");
if (_portals)
{
for (var i = 0; i < _portals.length; i++)
{
if (_portals[i].mode == 0 && (_portals[i].itemloc != 0 || NTConfig_Columns[_portals[i].y][_portals[i].x] > 0))
{
return _portals[i];
}
}
}
return false;
}
function NTR_TakeCowPortal(range)
{
var _portal = NTC_FindUnit(NTC_UNIT_OBJECT, _NTR_STRING_PORTAL);
if (_portal)
{
var _isClick;
var _preAreaId = me.areaid;
do
{
if (GetDistance(me, _portal) < range && _portal.mode == 2)
{
for (var i = 0; i < 40; i++)
{
if ((i % 10) == 0)
{
if(NTM_GetCloserInt(_portal))
_isClick = NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _portal);
}
if (_isClick)
{
NTC_Delay(100);
break;
}
}
NTC_PingDelay(500);
if (me.areaid != _preAreaId)
{
NTC_PingDelay(200);
return true;
}
}
} while (_portal.GetNext());
}
return false;
}
function NTR_ClearRooms(range, type, id, distance)
{
var i;
var _unit;
var _preRoom;
var _addRooms = new Array();
var _removeRooms = new Array();
if (distance)
{
_unit = GetPresetUnits(me.areaid, type, id);
if (!_unit || _unit.length < 1)
return false;
}
_preRoom = GetRoom();
if (_preRoom)
{
do
{
if (distance)
{
if (GetDistance(_preRoom.x * 5, _preRoom.y * 5, _unit[0].roomx * 5, _unit[0].roomy * 5) < distance)
continue;
}
_addRooms.push([_preRoom.x * 5, _preRoom.y * 5]);
} while (_preRoom.GetNext());
}
if (_addRooms.length < 1)
return false;
_preRoom = [me.x, me.y];
while (_addRooms.length > 0)
{
_addRooms.sort(function (a, b) { return (GetDistance(_preRoom[0], _preRoom[1], a[0], a[1]) - GetDistance(_preRoom[0], _preRoom[1], b[0], b[1])); });
_removeRooms.push([_addRooms[0][0], _addRooms[0][1]]);
for (i = 1; i < _addRooms.length; i++)
{
if (GetDistance(_preRoom[0], _preRoom[1], _addRooms[i][0], _addRooms[i][1]) <= GetDistance(_preRoom[0], _preRoom[1], _addRooms[0][0], _addRooms[0][1]))
{
_removeRooms.push([_addRooms[i][0], _addRooms[i][1]]);
}
else
break;
}
if (_removeRooms.length > 1)
{
_removeRooms.sort(function (a, b) { return (b[0] - a[0]); });
if (_removeRooms[0][0] <= _preRoom[0])
{
_removeRooms.sort(function (a, b) { return (b[1] - a[1]); });
if (_removeRooms[0][1] <= _preRoom[1])
{
_removeRooms.sort(function (a, b) { return (a[0] - b[0]); });
if (_removeRooms[0][0] >= _preRoom[0])
_removeRooms.sort(function (a, b) { return (a[1] - b[1]); });
}
}
}
if (!range || GetDistance(me.x, me.y, _removeRooms[0][0], _removeRooms[0][1]) < range)
{
if (NTR_MoveTo(me.areaid, _removeRooms[0][0], _removeRooms[0][1], 3, true))
_preRoom = _removeRooms[0];
}
for (i = 0; i < _addRooms.length; i++)
{
if (_addRooms[i][0] == _removeRooms[0][0] && _addRooms[i][1] == _removeRooms[0][1])
{
_addRooms.splice(i, 1);
break;
}
}
_removeRooms.length = 0;
}
return true;
}
function NTR_MoveTo(areaId, x, y, retry, isClearPath)
{
if (x == me.x && y == me.y)
return true;
if (arguments.length < 4)
retry = 3;
if (arguments.length < 5)
isClearPath = false;
var i, j;
var _path;
var _checkPath;
var _preX, _preY;
_path = GetPath(areaId, me.x, me.y, x, y, true);
if (!_path)
return false;
for (i = 0; i < _path.length; i++)
{
if (NTR_CheckCowKing() || NTR_CheckSafe(_path[i][0], _path[i][1], 15))
{
for (j = 0; j < retry; j++)
{
if (NTM_TeleportTo(_path[i][0], _path[i][1]))
break;
}
if (j >= retry)
return false;
}
if (isClearPath && !NTR_CheckCowKing())
{
_preX = me.x;
_preY = me.y;
if(NTR_ClearPosition(30))
NTSI_PickItems();
if (me.x != _preX || me.y != _preY)
{
if ((i + 1) < _path.length)
{
_checkPath = GetPath(me.areaid, me.x, me.y, _path[i + 1][0], _path[i + 1][1], true);
if (_checkPath)
{
if (_checkPath.length > 1)
{
if (!NTM_MoveTo(me.areaid, _preX, _preY))
return false;
}
}
}
}
}
}
return true;
}
function NTR_CheckCowKing()
{
var _cowKing = NTC_FindUnit(NTC_UNIT_MONSTER, _NTR_STRING_COW_KING);
return (_cowKing && GetDistance(me, _cowKing) < _NTR_COW_KING_RANGE);
}
function NTR_CheckSafe(x, y, range)
{
var i;
var _target = NTC_FindUnit(NTC_UNIT_MONSTER);
if (_target)
{
do
{
if (GetDistance(x, y, _target.x, _target.y) < range && _target.IsAttackable())
{
for (i = 0; i < 6; i++)
{
if (NTConfig_AttackSkill[i] && NTA_GetResistance(_target, _NTA_SkillDamage[i]) < 100)
return false;
}
}
} while (_target.GetNext());
}
return true;
}
function NTR_ClearPosition(range, spectype)
{
if(NTConfig_AttackSkill[2] < 1)
return false;
if(arguments.length < 1)
range = 20;
if(arguments.length < 2)
spectype = 0;
var _killnum = 0;
var _target = NTC_FindUnit(NTC_UNIT_MONSTER);
if(_target)
{
var _orgx = me.x;
var _orgy = me.y;
do
{
if(_target.IsAttackable() && (spectype == 0 || (_target.spectype & spectype)) && GetDistance(_orgx, _orgy, _target.x, _target.y) < range)
{
if(_killnum == 0)
{
if(NTConfig_AttackSkill[0] > 0 && NTA_GetResistance(_target, _NTA_SkillDamage[0]) < 100 && CheckCollision(me, _target, 3))
NTC_CastSkill(NTConfig_AttackSkill[0], _NTA_SkillHand[0], _target);
}
if(NTR_CheckCowKing())
return false;
if(NTA_Attack(_target, false, 25))
_killnum++;
}
} while(_target.GetNext());
if(me.classid == NTC_CHAR_CLASS_PALADIN && NTConfig_CastRedemption)
{
if(_killnum > 2 && (parseInt(me.hp*100/me.hpmax) <= 80 || parseInt(me.mp*100/me.mpmax) <= 80))
{
NTC_PutSkill(124, NTC_HAND_RIGHT);
NTC_PingDelay(1100);
}
}
NTTMGR_CheckSafe(0x00, NTConfig_CheckMercSafe&0x01);
}
return true;
}
function NTT_SecondTomeTP(npc, type, amount)
{
var _items;
var _counter = 0;
if(arguments.length < 1)
return false;
if(arguments.length < 2)
type = 0;
if(arguments.length < 0)
amount = 1;
if(amount == 0)
return false;
if(type)
_items = npc.GetItems("tbk");
if(_items)
{
if(_items.length > 0)
{
for(var i = 0 ; i < amount ; i++)
{
if(NTT_ShopItem(_items[0], npc, 2))
_counter++;
}
}
}
return (_counter > 0);
}
|