Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var _leaderName = "nnqqrands", // ~~~~EDIT THIS~~~~CaSe SeNsItIvE~~~~
- _attack = true, // ~~~~EDIT THIS~~~~true OR false~~~~
- _messages = true; // white 'Say' messages
- /*
- * Follower by kolton
- * To initiate the follow sequence make a TP and send command "1".
- *
- * Commands:
- * 1 - take leader's tp from town / move to leader's town
- * 2 - take leader's tp to town
- * 3 - town manager
- * a - attack toggle for all
- * <charname> a - attack toggle for <charname>
- * aon - attack on for all
- * <charname> aon - attack on for <charname>
- * aoff - attack off for all
- * <charname> aoff - attack off for <charname>
- * bo - barbarian precast
- * <charname> att <skillid> - change skill for <charname>
- * c - get corpse
- * p - pick items
- * r - revive
- * s - toggle stop
- * <charname> s - toggle stop <charname>
- * <charname> tp - make a TP. Needs a TP tome if not using custom libs.
- * quit - exit game
- *
- * a2-5 - move to appropriate act (after quest) !NOTE: Disable 'no sound' or game will crash!
- * talk <npc name> - talk to a npc in town
- */
- var _leader, _leaderUnit, _split, _sender, _msg, _piece, _msgtick, _result,
- _stop = false;
- function NTMain() {
- Include("libs/common/NTCommon.ntl");
- NTC_IncludeLibs();
- NTC_IncludeConfig("NTBot/char_configs");
- NT_LoadConfig();
- NTSI_LoadNIPFiles("NTBot/item_configs");
- NTA_Initialize();
- RegisterEvent(EVENT_GAMEMSG,
- function (msg, type) {
- if (type === 0 && msg.indexOf(_leaderName) > -1) {
- _split = msg.split(":");
- if (_split.length >= 1 && _split[1] != undefined) {
- _sender = _split[0].substring(3, _split[0].length - 3);
- _msg = _split[1].substring(1);
- if (_sender === _leaderName) {
- switch (_msg) {
- case "a": // attack toggle for everyone
- case (me.name + " a"): // individual attack toggle
- if (_attack) {
- _attack = false;
- Say("/w " + _leaderName + " Attack off");
- } else {
- _attack = true;
- Say("/w " + _leaderName + " Attack on");
- }
- break;
- case "aoff": // attack off for everyone
- case (me.name + " aoff"): // individual attack off
- Delay(150);
- _attack = false;
- Say("/w " + _leaderName + " Attack off");
- break;
- case "aon": // attack on for everyone
- case (me.name + " aon"): // individual attack off
- Delay(150);
- _attack = true;
- Say("/w " + _leaderName + " Attack on");
- break;
- case "c": // get corpse
- NTT_GetCorpses();
- break;
- case "p": // pick items
- Say("/w " + _leaderName + " Picking items.");
- NTSI_PickItems();
- break;
- case "r": // revive
- if (me.mode === 0 || me.mode === 17) {
- Say("/w " + _leaderName + " Reviving...");
- me.Cancel(0);
- me.Cancel(1);
- Delay(1000);
- if (NTTM_TownMove("portalspot")) {
- Say("/w " + _leaderName + " I'M ALIVE!!!");
- }
- }
- break;
- case "1": // take leader's tp to outside of town / change act if leader is in another town
- if (NTC_InTown() && NTC_InTown(_leader)) {
- Say("/w " + _leaderName + " Going to leader's town.");
- NTTM_CheckAct(CheckLeaderAct());
- NTTM_TownMove("portalspot");
- } else if(NTC_InTown()) {
- Say("/w " + _leaderName + " Taking portal to leader.");
- NTTM_CheckAct(CheckLeaderAct());
- NTTM_TownMove("portalspot");
- NTM_UsePortal(null, null, _leaderName);
- if (_attack) {
- ClearPosition();
- }
- }
- break;
- case "2": // take leader's tp to town
- if (!NTC_InTown()) {
- Delay(150);
- Say("/w " + _leaderName + " Going to town.");
- NTM_UsePortal(null, null, _leaderName);
- }
- break;
- case "3": // town manager
- if (NTC_InTown()) {
- Say("/w " + _leaderName + " Running town manager.");
- NTTMGR_TownManager();
- NTTM_TownMove("portalspot");
- Say("/w " + _leaderName + " Ready.");
- }
- break;
- case "quit": // exit game
- Say("/w " + _leaderName + " Good riddance.");
- Delay(500);
- ExitGame();
- break;
- case "bo": // barbarian precast
- if (me.classid == 4) {
- NTP_DoPrecast(true);
- }
- break;
- case "a2": // change act
- case "a3":
- case "a4":
- case "a5":
- ChangeAct(parseInt(_msg[1], 10));
- break;
- case "s": // stop toggle
- case (me.name + " s"): // individual stop toggle
- if (_stop) {
- _stop = false;
- Say("/w " + _leaderName + " resuming");
- } else {
- _stop = true;
- Say("/w " + _leaderName + " stopping");
- }
- break;
- case (me.name + " tp"):
- if (NTC_InTown()) {
- FL_Say("I'm in town.");
- break;
- }
- if (!NTM_MakeTP()) {
- FL_Say("Out of scrolls!");
- }
- break;
- }
- }
- if (msg.indexOf("talk") > -1) {
- Talk(msg.split(" ")[2]);
- NTTM_TownMove("portalspot");
- }
- if ((msg.indexOf(me.name) > -1 || msg.indexOf("all ") > -1) && msg.indexOf(" att ") > -1) {
- _piece = msg.split("att ");
- if (_piece && me.classid === 1) {
- Say("/w " + _leaderName + " Attack skill is " + parseInt(_piece[1]));
- NTConfig_AttackSkill[1] = parseInt(_piece[1]);
- NTConfig_AttackSkill[3] = parseInt(_piece[1]);
- }
- }
- }
- } else if (type === 4 && msg.indexOf(_leaderName) > -1 && (msg.indexOf("weaken") > -1 || msg.indexOf("timeout") > -1)) {
- Delay(500);
- ExitGame();
- }
- }
- );
- /*if (NTC_InTown()) {
- NTTMGR_TownManager();
- }*/
- if (!GetLeader(_leaderName)) {
- FL_Say("Leader not found or improperly configured file.");
- NTC_Delay(1000);
- ExitGame();
- } else {
- FL_Say("Leader found.");
- }
- NTC_PingDelay(200);
- while (!NTC_InMyParty(_leaderName)) {
- NTC_Delay(500);
- }
- FL_Say("Partied.");
- NTTM_TownMove("portalspot");
- while (NTC_InTown()) {
- NTC_Delay(250);
- }
- FL_Say("Initiate loop.");
- _leaderUnit = GetLeaderUnit(_leaderName);
- _msgtick = GetTickCount();
- while (NTC_InMyParty(_leaderName)) { // main loop
- while (!_leaderUnit) {
- if (GetTickCount() - _msgtick > 3000) {
- FL_Say("Leader unit not found!");
- _msgtick = GetTickCount();
- }
- _leaderUnit = GetLeaderUnit(_leaderName);
- Delay(500);
- }
- while (_stop) {
- NTC_Delay(200);
- }
- if (GetDistance(me, _leaderUnit) <= 50) {
- NTM_GetCloserInt(_leaderUnit);
- NTP_DoPrecast(false);
- }
- if (_attack) {
- ClearPosition(15);
- }
- if (_leader.areaid !== me.areaid && !NTC_InTown()) {
- while (_leader.areaid === 0) {
- Delay(100);
- }
- _result = CheckExit(_leader.areaid);
- if (_result) {
- switch (_result) {
- case 1:
- FL_Say("Taking stairs.");
- Delay(500);
- NTM_TakeStair(_leader.areaid);
- break;
- case 2:
- FL_Say("Using portal.");
- Delay(500);
- NTM_UsePortal(null, _leader.areaid);
- break;
- case 3:
- FL_Say("Taking waypoint.");
- Delay(500);
- NTM_TakeWaypoint(_leader.areaid);
- break;
- case 4:
- FL_Say("Special transit.");
- break;
- }
- while (me.areaid === 0) {
- Delay(100);
- }
- _leaderUnit = GetLeaderUnit(_leaderName);
- }
- }
- if (NTC_InTown()) {
- NTTM_TownMove("portalspot");
- while (NTC_InTown()) {
- NTC_Delay(250);
- }
- }
- NTC_Delay(25);
- }
- NTC_SendMsgToScript("NTBotGame.ntj", "SCRIPT_END");
- }
- //===============================================================================================================
- function GetLeaderUnit(name) {
- var _unit = NTC_FindUnit(NTC_UNIT_PLAYER);
- if (_unit) {
- do {
- if (_unit.name === name) {
- return _unit;
- }
- } while (_unit.GetNext());
- }
- return false;
- }
- function GetLeader(name) {
- _leader = GetPlayerUnit();
- if (_leader) {
- do {
- if (_leader.name === name) {
- return _leader;
- }
- } while (_leader.GetNext());
- }
- return false;
- }
- function CheckLeaderAct() {
- if (_leader.areaid <= 39) {
- return 1;
- } else if(_leader.areaid >= 40 && _leader.areaid <= 74) {
- return 2;
- } else if(_leader.areaid >= 75 && _leader.areaid <= 102) {
- return 3;
- } else if(_leader.areaid >= 103 && _leader.areaid <= 108) {
- return 4;
- }
- return 5;
- }
- function CheckExit(area) {
- var _unit = GetPresetUnits(me.areaid, NTC_UNIT_TILE);
- if (_unit) {
- for (var i = 0; i < _unit.length; i += 1) {
- if (_unit[i].subareaid === area) {
- return 1;
- }
- }
- }
- _unit = NTC_FindUnit(NTC_UNIT_OBJECT, GetLocaleString(3226));
- if (_unit) {
- do {
- if (_unit.subareaid === area || _unit.subareaid === area + 256 || _unit.subareaid === area + 768) {
- return 2;
- }
- } while (_unit.GetNext());
- }
- if (NTC_InTown(_leader)) {
- _unit = NTM_GetWaypointInt();
- if (_unit) {
- return 3;
- }
- }
- if((me.areaid === 74 && area === 54 || me.areaid === 54 && area === 74)) { // arcane portal
- NTM_TakeUnit(NTC_UNIT_OBJECT, 298);
- return 4;
- }
- if (me.areaid >= 66 && me.areaid <= 72 && area === 73) { // duriel's wall
- NTM_TakeUnit(NTC_UNIT_OBJECT, 100);
- return 4;
- }
- return 0;
- }
- function FL_Say(msg) {
- if (_messages) {
- Say(msg);
- }
- return true;
- }
- function QuestInteract(npc) {
- var i;
- NTM_GetCloserInt(npc);
- for (i = 0; i < 20; i += 1) {
- if (i % 5 === 0) {
- NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, npc);
- }
- if (i % 10 === 9) {
- while (!GetUIState(0x09)) {
- me.Cancel(0);
- NTC_Delay(100);
- }
- me.Cancel(1);
- break;
- }
- NTC_Delay(200);
- }
- }
- function Talk(name) {
- if (!NTC_InTown()) {
- FL_Say("I'm not in town!");
- return false;
- }
- var npc,
- names = ["gheed", "charsi", "akara", "kashya", "cain", "warriv", "fara", "lysander", "greiz",
- "elzix", "jehryn", "meshif", "drognan", "atma", "alkor", "asheara", "ormus", "hratli",
- "halbu", "tyrael", "jamella", "larzuk", "malah", "qual-kehk", "anya", "nihlathak"];
- if (names.indexOf(name.toLowerCase()) < 0) {
- FL_Say("Invalid NPC name.");
- return false;
- }
- if (!NTTM_TownMove(name.toLowerCase() === "jehryn" ? "palace" : name)) {
- return false;
- }
- npc = NTC_FindUnit(1);
- if (npc) {
- do {
- if (npc.name.replace(/ /g, "").toLowerCase() === name) {
- QuestInteract(npc);
- return true;
- }
- } while (npc.GetNext());
- }
- return false;
- }
- function ChangeAct(act) {
- var npc, portal;
- switch (act) {
- case 2:
- NTTM_TownMove("warriv");
- npc = NTC_FindUnit(1, 155);
- if (npc) {
- QuestInteract(npc);
- if (NTT_DoInteract(npc)) {
- me.SelectNPCMenu(0x0D36);
- }
- }
- break;
- case 3:
- NTTM_TownMove("palace");
- npc = NTC_FindUnit(1, 201);
- if (npc) {
- QuestInteract(npc);
- }
- NTTM_TownMove("meshif");
- npc = NTC_FindUnit(1, 210);
- if (npc) {
- QuestInteract(npc);
- if (NTT_DoInteract(npc)) {
- me.SelectNPCMenu(0x0D38);
- }
- }
- break;
- case 4:
- NTTM_TownMove("cain");
- npc = NTC_FindUnit(1, 245);
- if (npc) {
- QuestInteract(npc);
- }
- NTTM_TownMove("portalspot");
- if (me.areaid !== 102) {
- NTM_UsePortal(null, 102, null);
- }
- target = NTC_FindUnit(2, 342, 20);
- NTM_MoveTo(target.areaid, target.x - 3, target.y - 1);
- NTM_TakeUnit(NTC_UNIT_OBJECT, 342);
- break;
- case 5:
- NTTM_TownMove("tyrael");
- npc = NTC_FindUnit(1, NTC_NPC_ID_TYREAL_ACT_4);
- if(npc) {
- QuestInteract(npc);
- if (NTT_DoInteract(npc)) {
- me.SelectNPCMenu(0x58D2);
- }
- }
- }
- while (!me.areaid) {
- NTC_Delay(500);
- }
- NTC_PingDelay(2000);
- NTTM_TownMove("portalspot");
- Say("Act change successful");
- }
- function ClearPosition(range) {
- var i, orgx, orgy, monList, skipList, target, result,
- tele = NTC_GetSkillLevel(54),
- attackcount = 0;
- if (NTConfig_AttackSkill[1] < 0 || NTConfig_AttackSkill[3] < 0) {
- Print("ΓΏc1Set your attacks, noob!");
- return false;
- }
- if (!arguments.length) {
- range = 20;
- }
- orgx = me.x;
- orgy = me.y;
- skipList = [];
- MainLoop : while (_attack && attackcount < 300) {
- monList = [];
- target = NTC_FindUnit(NTC_UNIT_MONSTER);
- if (target) {
- do {
- if (skipList.indexOf(target.gid) < 0) {
- if (target.IsAttackable()) {
- if (NTA_IsValidMonster(target)) {
- if (GetDistance(orgx, orgy, target.x, target.y) <= range && (CheckCollision(me, target, 1) || tele)) {
- monList.push(new NTA_MonsterStats(target));
- }
- }
- } else {
- skipList.push(target.gid);
- }
- }
- } while (target.GetNext());
- }
- if (monList.length === 0) {
- break;
- }
- monList.sort(SortMonsters);
- target = NTC_FindUnit(NTC_UNIT_MONSTER, monList[0].gid);
- if (target && target.IsAttackable()) {
- result = NTA_Attack(target, attackcount % 30 === 0);
- //Say("!Attacking " + target.name + " " + target.classid);
- switch (result) {
- case 1:
- skipList.push(target.gid);
- monList.shift();
- break;
- case 2:
- case 3:
- attackcount += 1;
- break;
- default:
- return false;
- }
- } else {
- monList.shift();
- }
- }
- return true;
- }
- function SortMonsters(unitA, unitB) {
- var monID = [58, 59, 60, 61, 62, 101, 102, 103, 104, 105, 229, 278, 279, 280, 281, 282, 312, 645, 646, 647, 667, 668, 669, 670];
- if (monID.indexOf(unitA.classid) > -1) {
- return -1;
- } else if (GetDistance(me.x, me.y, unitA.x, unitA.y) < GetDistance(me.x, me.y, unitB.x, unitB.y)) {
- return -1;
- }
- return 1;
- }
- function NTA_MonsterStats(unit) {
- this.name = unit.name;
- this.x = unit.x;
- this.y = unit.y;
- this.gid = unit.gid;
- this.hp = unit.hp;
- this.classid = unit.classid;
- this.spectype = unit.spectype;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement