Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var _leaderName = "kolx-a", // ~~~~EDIT THIS~~~~CaSe SeNsItIvE~~~~
- _attack = true, // ~~~~EDIT THIS~~~~true OR false~~~~
- _messages = true, // white 'say' messages
- _openContainers = true; // open chests/racks/barrels/stashes/etc.
- /*
- * Follower by kolton
- * To initiate the follow sequence make a TP and send command "1".
- *
- * Commands:
- * Main commands:
- * 1 - take leader's tp from town / move to leader's town
- * 2 - take leader's tp to town
- * 3 - town manager
- * c - get corpse
- * p - pick items
- * s - toggle stop
- * <charname> s - toggle stop <charname>
- * Attack:
- * 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>
- * Teleport: *** characters without teleport skill will ignore tele command ***
- * tele - toggle teleport for all
- * <charname> tele - toggle teleport for <charname>
- * tele on - teleport on for all
- * <charname> tele on - teleport on for <charname>
- * tele off - teleport off for all
- * <charname> tele off - teleport off for <charname>
- * Skills: *** refer to skills.txt ***
- * all skill <skillid> - change skill for all. refer to skills.txt
- * <charname> skill <skillid> - change skill for <charname>
- * <class> skill <skillid> - change skill for all characters of certain class *** any part of class name will do *** for example: "sorc skill 36", "zon skill 0", "din skill 106"
- * Auras: *** refer to skills.txt ***
- * all aura <skillid> - change aura for all paladins
- * <charname> aura <skillid> - change aura for <charname>
- * Town:
- * 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
- * Misc.
- * wp - all players activate a nearby wp
- * <charname> wp - <charname> activates a nearby wp
- * bo - barbarian precast
- * <charname> tp - make a TP. Needs a TP tome if not using custom libs.
- * reload - reload script. Use only in case of emergency, or after editing character config.
- * quit - exit game
- */
- var i, _leader, _leaderUnit, _split, _sender, _msg, _piece, _skill, _msgtick, _result, _charClass, _unit, _busy, _stop,
- _task = "";
- function NT_Follower() {
- addEventListener("chatmsg", ChatCommands);
- switch (me.classid) {
- case 0:
- _charClass = "amazon";
- break;
- case 1:
- _charClass = "sorceress";
- break;
- case 2:
- _charClass = "necromancer";
- break;
- case 3:
- _charClass = "paladin";
- break;
- case 4:
- _charClass = "barbarian";
- break;
- case 5:
- _charClass = "druid";
- break;
- case 6:
- _charClass = "assassin";
- break;
- }
- _leader = GetLeader(_leaderName);
- if (!_leader) {
- say("Leader not found or improperly configured file.");
- NTC_Delay(1000);
- quit();
- } else {
- FL_Say("Leader found.");
- }
- NTC_PingDelay(200);
- while (!NTC_InMyParty(_leaderName)) {
- NTC_Delay(500);
- }
- say(" Partied.");
- NTTM_TownMove("portalspot");
- while (NTC_InTown()) {
- if (_task !== "") {
- break;
- }
- NTC_Delay(50);
- }
- say(" Initiate loop.");
- //_leaderUnit = GetLeaderUnit(_leaderName);
- _msgtick = getTickCount();
- // =============
- // = main loop =
- // =============
- while (NTC_InMyParty(_leaderName)) {
- if (me.mode === 0 || me.mode === 17) {
- say(" Reviving...");
- me.revive();
- delay(2000);
- if (NTTM_TownMove("portalspot")) {
- say(" I'M ALIVE!!!");
- }
- }
- while (_stop) {
- NTC_Delay(200);
- }
- if (!NTC_InTown()) {
- while (!_leaderUnit) {
- if (getTickCount() - _msgtick > 3000) {
- FL_Say("Leader unit not found!");
- _msgtick = getTickCount();
- }
- _leaderUnit = GetLeaderUnit(_leaderName);
- delay(500);
- }
- if (getDistance(me, _leaderUnit) <= 50) {
- NTM_GetCloserInt(_leaderUnit);
- }
- if (_attack) {
- ClearPosition(20);
- }
- if (_leader.area !== me.area && !NTC_InTown()) {
- while (_leader.area === 0) {
- delay(100);
- }
- _result = CheckExit(_leader, _leader.area);
- if (_result) {
- switch (_result) {
- case 1:
- FL_Say("Taking stairs.");
- delay(500);
- NTM_TakeStairs(_leader.area);
- break;
- case 2:
- FL_Say("Using portal.");
- delay(500);
- NTM_UsePortal(null, _leader.area, null);
- break;
- case 3:
- FL_Say("Taking waypoint.");
- delay(500);
- NTM_TakeWaypoint(_leader.area);
- break;
- case 4:
- FL_Say("Special transit.");
- break;
- }
- while (me.area === 0) {
- delay(100);
- }
- _leaderUnit = GetLeaderUnit(_leaderName);
- }
- }
- }
- if (NTC_InTown()) {
- NTTM_TownMove("portalspot");
- while (NTC_InTown()) {
- if (_task !== "") {
- break;
- }
- NTC_Delay(50);
- }
- }
- // =========
- // = tasks =
- // =========
- switch (_task) {
- case "scatter":
- NTM_MoveTo(me.x + rand(-8, 8), me.y + rand(-8, 8));
- break;
- case "wp":
- case (me.name + " wp"):
- if (NTC_InTown()) {
- break;
- }
- _unit = NTC_GetUnit(2, "Waypoint");
- if (_unit) {
- for (i = 0; i < 20; i += 1) {
- if (i % 5 === 0) {
- if (NTM_GetCloserInt(_unit)) {
- _unit.interact();
- }
- }
- if (i % 5 === 4) {
- NTM_MoveTo(_unit.x + 6, _unit.y + 6);
- }
- NTC_Delay(400);
- if (getUIFlag(0x14)) {
- NTC_Delay(500);
- say(" Got the WP.");
- break;
- }
- }
- }
- if (!getUIFlag(0x14)) {
- say(" Failed to get the WP.");
- }
- me.cancel();
- break;
- case "c": // get corpse
- NTT_GetCorpses();
- break;
- case "p": // pick items
- say(" Picking items.");
- NTSI_PickItems();
- if (_openContainers) {
- OpenContainers(20);
- }
- 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) && CheckLeaderAct(_leader) !== me.act) {
- say(" Going to leader's town.");
- NTTM_CheckAct(CheckLeaderAct(_leader));
- NTTM_TownMove("portalspot");
- } else if (NTC_InTown()) {
- say(" Taking portal to outside.");
- NTTM_CheckAct(CheckLeaderAct(_leader));
- NTTM_TownMove("portalspot");
- NTM_UsePortal(null, null, _leaderName);
- ClearPosition(20);
- while (!GetLeaderUnit(_leaderName)) {
- ClearPosition(10);
- NTC_Delay(200);
- }
- }
- break;
- case "2": // take leader's tp to town
- if (!NTC_InTown()) {
- delay(150);
- say(" Going to town.");
- NTM_UsePortal(null, null, _leaderName);
- }
- break;
- case "3": // town manager
- if (NTC_InTown()) {
- say(" Running town manager.");
- NTTMGR_TownManager();
- NTTM_TownMove("portalspot");
- say(" Ready.");
- }
- 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(_task[1], 10));
- 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 (_task.indexOf("talk") > -1) {
- Talk(_task.split(" ")[1]);
- }
- _task = "";
- NTC_Delay(25);
- }
- return true;
- }
- function ChatCommands(nick, msg) {
- if (nick === _leaderName) {
- // ============
- // = triggers =
- // ============
- switch (msg) {
- case "s": // stop toggle
- case (me.name + " s"): // individual stop toggle
- if (_stop) {
- _stop = false;
- say(" resuming");
- } else {
- _stop = true;
- say(" stopping");
- }
- return;
- case "quit": // exit game
- say(" Good riddance.");
- delay(500);
- quit();
- return;
- case "tele":
- case (me.name + " tele"):
- if (NTC_CheckSkill(54)) {
- if (!NTConfig_Teleport) {
- NTConfig_Teleport = true;
- say(" Teleport on");
- } else {
- NTConfig_Teleport = false;
- say(" Teleport off");
- }
- }
- return;
- case "tele off":
- case (me.name + " tele off"):
- if (NTC_CheckSkill(54)) {
- NTConfig_Teleport = true;
- say(" Teleport on");
- }
- return;
- case "tele on":
- case (me.name + " tele on"):
- if (NTC_CheckSkill(54)) {
- NTConfig_Teleport = true;
- say(" Teleport off");
- }
- return;
- case "a": // attack toggle for everyone
- case (me.name + " a"): // individual attack toggle
- if (_attack) {
- _attack = false;
- say(" Attack off");
- } else {
- _attack = true;
- say(" Attack on");
- }
- return;
- case "aoff": // attack off for everyone
- case (me.name + " aoff"): // individual attack off
- delay(150);
- _attack = false;
- say(" Attack off");
- return;
- case "aon": // attack on for everyone
- case (me.name + " aon"): // individual attack off
- delay(150);
- _attack = true;
- say(" Attack on");
- return;
- }
- if (msg.indexOf(" skill ") > -1) {
- _piece = msg.split(" ")[0];
- if (_charClass.indexOf(_piece) > -1 || _piece === me.name || _piece === "all") {
- _skill = parseInt(msg.split(" ")[2], 10);
- if (NTC_CheckSkill(_skill)) {
- say(" Attack skill is " + _skill);
- NTConfig_AttackSkill[1] = _skill;
- NTConfig_AttackSkill[3] = _skill;
- NTA_Initialize();
- } else {
- say(" I don't have that skill.");
- }
- }
- return;
- }
- if (me.classid === 3 && msg.indexOf(" aura ")) {
- _piece = msg.split(" ")[0];
- if (_piece === me.name || _piece === "all") {
- _skill = parseInt(msg.split(" ")[2], 10);
- if (NTC_CheckSkill(_skill)) {
- say(" Active aura is " + _skill);
- NTC_PutSkill(_skill, 0);
- NTConfig_AttackSkill[2] = _skill;
- NTConfig_AttackSkill[4] = _skill;
- NTA_Initialize();
- } else {
- say(" I don't have that aura.");
- }
- }
- return;
- }
- if (_task === "") {
- _task = msg;
- } else {
- say("I'm busy with " + _task);
- }
- }
- }
- // ===================
- // === functions =====
- // ===================
- function GetLeaderUnit(name) {
- var _unit = NTC_GetUnit(0);
- if (_unit) {
- do {
- if (_unit.name === name) {
- return _unit;
- }
- } while (_unit.getNext());
- }
- return false;
- }
- function GetLeader(name) {
- var _party = getParty();
- if (_party) {
- do {
- if (_party.name === name) {
- return _party;
- }
- } while (_party.getNext());
- }
- return false;
- }
- function CheckLeaderAct(leader) {
- if (leader.area <= 39) {
- return 1;
- } else if(leader.area >= 40 && leader.area <= 74) {
- return 2;
- } else if(leader.area >= 75 && leader.area <= 102) {
- return 3;
- } else if(leader.area >= 103 && leader.area <= 108) {
- return 4;
- }
- return 5;
- }
- function CheckExit(leader, area) {
- var i,
- _unit, //= getPresetUnits(me.area, NTC_UNIT_TILE),
- _exits = getArea().exits;
- for (i = 0; i < _exits.length; i += 1) {
- if (_exits[i].target === area && _exits[i].type === 2) {
- return 1;
- }
- }
- if (NTC_InTown(leader)) {
- _unit = NTM_GetWaypointInt();
- if (_unit) {
- return 3;
- }
- }
- _unit = NTC_GetUnit(NTC_UNIT_OBJECT, "Portal");
- if (_unit) {
- do {
- if (_unit.objtype === area) {
- return 2;
- }
- } while (_unit.getNext());
- }
- if((me.area === 74 && area === 54 || me.area === 54 && area === 74)) { // arcane portal
- NTM_TakeUnit(NTC_UNIT_OBJECT, 298);
- return 4;
- }
- if (me.area >= 66 && me.area <= 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 Talk(name) {
- if (!NTC_InTown()) {
- say(" I'm not in town!");
- return false;
- }
- if (name) {
- name = name.toLowerCase();
- } else {
- say(" No NPC name given.");
- return false;
- }
- var npc, names;
- switch (me.act) {
- case 1:
- names = ["gheed", "charsi", "akara", "kashya", "cain", "warriv"];
- break;
- case 2:
- names = ["fara", "lysander", "greiz", "elzix", "jehryn", "meshif", "drognan", "atma", "cain"];
- break;
- case 3:
- names = ["alkor", "asheara", "ormus", "hratli", "cain"];
- break;
- case 4:
- names = ["halbu", "tyrael", "jamella", "cain"];
- break;
- case 5:
- names = ["larzuk", "malah", "qual-kehk", "anya", "nihlathak", "cain"];
- break;
- }
- if (names.indexOf(name) < 0) {
- say(" Invalid NPC.");
- return false;
- }
- if (!NTTM_TownMove(name === "jehryn" ? "palace" : name)) {
- NTTM_TownMove("portalspot");
- say(" Failed to move to town spot.");
- return false;
- }
- npc = NTC_GetUnit(1);
- if (npc) {
- do {
- if (npc.name.replace(/ /g, "").toLowerCase().indexOf(name) > -1) {
- if (NTT_DoInteract(npc)) {
- me.cancel();
- }
- NTTM_TownMove("portalspot");
- say(" Done talking.");
- return true;
- }
- } while (npc.getNext());
- }
- say(" NPC not found.");
- NTTM_TownMove("portalspot");
- return false;
- }
- function ChangeAct(act) {
- var npc, portal, preArea;
- preArea = me.area;
- switch (act) {
- case 2:
- if (me.area >= 40) {
- break;
- }
- NTTM_TownMove("warriv");
- npc = NTC_GetUnit(1, 155);
- if (npc) {
- if (NTT_DoInteract(npc)) {
- npc.useMenu(0x0D36);
- }
- }
- break;
- case 3:
- if (me.area >= 75) {
- break;
- }
- NTTM_TownMove("palace");
- npc = NTC_GetUnit(1, 201);
- if (npc) {
- if (NTT_DoInteract(npc)) {
- me.cancel();
- }
- }
- NTTM_TownMove("meshif");
- npc = NTC_GetUnit(1, 210);
- if (npc) {
- if (NTT_DoInteract(npc)) {
- npc.useMenu(0x0D38);
- }
- }
- break;
- case 4:
- if (me.area >= 103) {
- break;
- }
- if (NTC_InTown()) {
- NTTM_TownMove("cain");
- npc = NTC_GetUnit(1, 245);
- if (npc) {
- if (NTT_DoInteract(npc)) {
- me.cancel();
- }
- }
- NTTM_TownMove("portalspot");
- }
- if (me.area !== 102) {
- NTM_UsePortal(null, 102, null);
- }
- target = NTC_GetUnit(2, 342);
- NTM_MoveTo(target.x - 3, target.y - 1);
- NTM_TakeUnit(NTC_UNIT_OBJECT, 342);
- break;
- case 5:
- if (me.area >= 109) {
- break;
- }
- NTTM_TownMove("tyrael");
- npc = NTC_GetUnit(1, 367);
- if(npc) {
- if (NTT_DoInteract(npc)) {
- me.cancel();
- }
- NTM_TakeUnit(2, 566);
- }
- break;
- }
- NTC_PingDelay(2000);
- while (!me.area) {
- NTC_Delay(500);
- }
- if (me.area === preArea) {
- me.cancel();
- NTTM_TownMove("portalspot");
- FL_Say("Act change failed.");
- return;
- }
- NTTM_TownMove("portalspot");
- FL_Say("Act change successful.");
- if (act === 2) {
- say("Don't forget to talk to Drognan after getting the Viper Amulet!");
- }
- }
- function ClearPosition(range) {
- var i, orgx, orgy, monList, skipList, target, result,
- tele = NTC_CheckSkill(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) {
- if (me.mode === 0 || me.mode === 17) {
- return false;
- }
- if (attackcount % 5 === 0) { // testing
- monList = [];
- target = NTC_GetUnit(NTC_UNIT_MONSTER, null, MODE_ALIVE);
- if (target) {
- do {
- if (skipList.indexOf(target.gid) === -1 && getDistance(orgx, orgy, target.x, target.y) <= range && NTA_IsValidTarget(target)) {
- monList.push(copyUnit(target));
- }
- } while (target.getNext());
- }
- }
- if (monList.length === 0) {
- break;
- }
- monList.sort(SortMonsters);
- target = monList[0];
- if (NTA_IsValidTarget(target) && (!checkCollision(me, target, 0x1) || tele)) {
- result = NTA_Attack(target, attackcount % 30 === 0);
- switch (result) {
- case 1:
- skipList.push(target.gid);
- monList.shift();
- break;
- case 2:
- case 3:
- attackcount += 1;
- break;
- default:
- return false;
- }
- } else {
- skipList.push(target.gid);
- monList.shift();
- }
- }
- if (attackcount > 0) {
- switch (me.classid) {
- case 2:
- NTA_RaiseArmy();
- break;
- }
- NTT_ClearBelt();
- PickPotions(range);
- NTP_DoPrecast(false);
- }
- 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 PickPotions(range) {
- var i, item, itemList, classid, name;
- item = NTC_GetUnit(4);
- if (!item) {
- return false;
- }
- itemList = [];
- do {
- if ((item.mode === 3 || item.mode === 5) && item.itemType >= 76 && item.itemType <= 78 && getDistance(me.x, me.y, item.x, item.y) <= range) {
- if (NTSI_CheckItem(item)) {
- itemList.push(copyUnit(item));
- }
- }
- } while (item.getNext());
- while (itemList.length > 0) {
- //itemList.sort(NTSI_SortItems);
- item = itemList.shift();
- classid = item.classid;
- name = item.name;
- if (item && !NTSI_IsLimitedItemInt(item) && NTSI_PickUpItemInt(item)) {
- switch(classid) {
- case 515: // Rejuvenation Potion
- case 516: // Full Rejuvenation Potion
- print("Picked up "+ NTC_ItemQualityToD2Color[9] + name);
- break;
- case 587: // Minor Healing Potion
- case 588: // Light Healing Potion
- case 589: // Healing Potion
- case 590: // Greater Healing Potion
- case 591: // Super Healing Potion
- print("Picked up "+ NTC_ItemQualityToD2Color[10] + name);
- break;
- case 592: // Minor Mana Potion
- case 593: // Light Mana Potion
- case 594: // Mana Potion
- case 595: // Greater Mana Potion
- case 596: // Super Mana Potion
- print("Picked up "+ NTC_ItemQualityToD2Color[4] + name);
- break;
- }
- }
- }
- return true;
- }
- function OpenContainers(range) {
- var i, strings, unit, orgX, orgY;
- orgX = me.x;
- orgY = me.y;
- strings = ["chest", "LargeUrn", "Chest3", "Urn"];
- for (i = 0; i < strings.length; i += 1) {
- unit = NTC_GetUnit(2, strings[i]);
- if (unit) {
- do {
- if (getDistance(orgX, orgY, unit.x, unit.y) <= range && !checkCollision(me, unit, 0x1) && NTC_OpenChest(unit)) {
- NTSI_PickItems();
- }
- } while (unit.getNext());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement