Browse Source

Add files via upload

Tera Coder 7 years ago
parent
commit
6bd53d87ab
4 changed files with 139 additions and 80 deletions
  1. 74 0
      config.js
  2. 58 71
      index.js
  3. 5 4
      manifest.json
  4. 2 5
      module.json

+ 74 - 0
config.js

@@ -0,0 +1,74 @@
+module.exports = {
+    enable: true,
+    enableAuto: true,
+	interval: 30,
+	throttleMax: 90,
+	scanInterval: 100,
+	radius: 250,
+
+    blacklist: [
+        7214, // Scroll of Resurrection
+		//91344, // Fashion Coupon
+        139113, 166718, 213026, // 행운의 상자 (K TERA)
+        169886, 169887, 169888, 169889, 169890, 169891, // Locked ???? Strongbox
+
+		//98512, // Pansophic Ash	
+		//98513, // Essence
+		//98590, // Veilthroch
+
+        //98599, // Devil's Claws
+        //98600, // Dragon Skull
+		
+		88784, // Powerful Transcendent Mask
+		88785, // Keen Transcendent Mask
+		88786, // Bitter Trasncendent Mask
+		88787, // Energetic Transcendent Mask
+		
+		88849, // Powerful Bahaar's Mask
+        88850, // Keen Bahaar's Mask
+        88851, // Bitter Bahaar's Mask
+        88852, // Energetic Bahaar's Mask
+		
+		201656, // Hidden Weapon Sheath
+		202017, // Transparent Mask
+		
+		88827, // Belt Amplifier I
+		88832, // Belt Amplifier II
+		88831, // Circlet Amplifier I
+		88836, // Circlet Amplifier II
+		88829, // Earring Amplifier I
+		88834, // Earring Amplifier II
+		88828, // Necklace Amplifier I
+		88833, // Necklace Amplifier II
+		88830, // Ring Amplifier I
+		88835, // Ring Amplifier II     
+		
+		88837, // Accessory Amplifier Coin
+      
+		//98653, // Supreme Metal
+		//98654, // Springy Draco Limb
+		//98655, // Weight Pendulum
+        98656, // Sacred Mallet
+		
+		//88840, // Bahaar's Amplifier Coin
+		88841, // Bahaar's Handwear Amplifier
+		88842, // Bahaar's Footwear Amplifier
+		
+		98667, // Skill Optimization Scroll I
+		98669, // Skill Optimization Scroll II
+		
+		//89040, // yellow relic
+		//89020, // blue power relic
+		//89010, // green crit relic
+		//89000, // green power relic
+		//89030, // blue crit relic
+		
+		//89130, // blue crit halidom
+		//89110, // green crit halidom
+		//89140, // yellow halidom
+		//89120, // blue power halidom
+		//89100 // green power halidom
+		
+		
+    ]
+}

+ 58 - 71
index.js

@@ -1,72 +1,59 @@
-'use strict'
-
-module.exports = function Loot(mod) {
-	let location = null
-	let lootTimeout = null
-	let items = new Map()
-
-	mod.command.add('loot', {
-		$default() {
-			mod.settings.enabled = !mod.settings.enabled
-			mod.command.message(`${mod.settings.enabled ? 'en' : 'dis'}abled`)
-		},
-		auto() {
-			mod.settings.auto = !mod.settings.auto
-			mod.command.message(`auto-loot ${mod.settings.auto ? 'en' : 'dis'}abled`)
-		}
-	})
-
-	mod.game.me.on('change_zone', () => {
-		items.clear()
-	})
-
-	mod.hook('S_RETURN_TO_LOBBY', 1, () => {
-		items.clear()
-	})
-
-	mod.hook('C_PLAYER_LOCATION', 5, event => {
-		location = event.loc
-	})
-
-	mod.hook('S_SPAWN_DROPITEM', 7, event => {
-		if (mod.settings.blacklist.includes(event.item))
-			return
-		// is motes?
-		if (8000 <= event.item && event.item <= 8025)
-			return
-
-		if (event.owners.some(owner => owner.playerId === mod.game.me.playerId)) {
-			items.set(event.gameId, Object.assign(event, {priority: 0}))
-
-			if (mod.settings.auto && !lootTimeout)
-				tryLoot()
-		}
-	})
-
-	mod.hook('C_TRY_LOOT_DROPITEM', 4, () => {
-		if (mod.settings.enabled && !lootTimeout)
-			lootTimeout = setTimeout(tryLoot, mod.settings.interval)
-	})
-
-	mod.hook('S_DESPAWN_DROPITEM', 4, event => {
-		items.delete(event.gameId)
-	})
-
-	function tryLoot() {
-		clearTimeout(lootTimeout)
-		lootTimeout = null
-
-		if (!items.size || mod.game.me.mounted)
-			return
-
-		for(let item of [...items.values()].sort((a, b) => a.priority - b.priority))
-			if (location.dist3D(item.loc) <= mod.settings.radius) {
-				mod.toServer('C_TRY_LOOT_DROPITEM', 4, item)
-				lootTimeout = setTimeout(tryLoot, Math.min(mod.settings.interval * ++item.priority, mod.settings.throttleMax))
-				return
-			}
-
-		if (mod.settings.auto)
-			setTimeout(tryLoot, mod.settings.scanInterval)
-	}
+'use strict';
+const config = require('./config.js');
+
+module.exports = function AutoLootOld(mod) {
+    const cmd = mod.command || mod.require.command;
+
+    let enable = config.enable,
+        enableAuto = config.enableAuto,
+        interval = config.interval,
+        throttleMax = config.throttleMax,
+        scanInterval = config.scanInterval,
+        radius = config.radius;
+
+    let location = null,
+        items = new Map(),
+		lootTimeout = null;
+
+	cmd.add('loot', {
+		$default() {
+			enable = !enable;
+			mod.command.message(`${enable ? 'en' : 'dis'}abled`);
+		},
+		auto() {
+			enableAuto = !enableAuto;
+			mod.command.message(`auto-loot ${enableAuto ? 'en' : 'dis'}abled`);
+		}
+	});
+
+    mod.game.me.on('change_zone', () => { items.clear(); });
+	
+	mod.hook('S_RETURN_TO_LOBBY', 1, () => { items.clear(); });
+    mod.hook('C_PLAYER_LOCATION', 5, (e) => { location = e.loc; });
+    mod.hook('S_SYSTEM_MESSAGE', 1, (e) => { if (e.message === '@41') return false });
+    mod.hook('C_TRY_LOOT_DROPITEM', 4, () => { if(enable && !lootTimeout) lootTimeout = setTimeout(tryLoot, interval); });
+    mod.hook('S_DESPAWN_DROPITEM', 4, (e) => { items.delete(e.gameId); });
+
+    mod.hook('S_SPAWN_DROPITEM', 7, (e) => {
+        if(!(config.blacklist.includes(e.item)) && (e.item < 8000 || e.item > 8025) && e.owners.some(owner => owner.playerId === mod.game.me.playerId)){
+            //items.set(e.gameId, e);
+			items.set(e.gameId, Object.assign(e, {priority: 0}));
+			if(enableAuto && !lootTimeout) tryLoot();
+        }
+    });
+
+    function tryLoot() {
+		clearTimeout(lootTimeout);
+		lootTimeout = null;
+		if(!items.size || mod.game.me.mounted) return;
+		for(let item of [...items.values()].sort((a, b) => a.priority - b.priority)){
+			if(location.dist3D(item.loc) <= radius){
+				mod.toServer('C_TRY_LOOT_DROPITEM', 4, item);
+				//lootTimeout = setTimeout(tryLoot, interval);
+				lootTimeout = setTimeout(tryLoot, Math.min(interval * ++item.priority, throttleMax));
+				return;
+			}
+		}
+		if(enableAuto) setTimeout(tryLoot, scanInterval);
+    }
 }

+ 5 - 4
manifest.json

@@ -1,14 +1,15 @@
 {
 	"files": {
-		"index.js": "fa20fc9ddfc41b569af8ee7175c306cbb7e63aefc6be3d2bcc8f98c6298a2cd1",
-		"module.json": "5f4c83783cdd190a6b60106ce5933c2bb89d76d893ce027199081e84cfc021fb",
-		"settings_migrator.js": "1fc8ca27d4cde2c3a0cfbb8cbc3cbb5ea6c5c0c8fce45f6a9d6af88b4d044085"
+		"index.js": "5d268b228592955224a633de74225685f2e1a98a9c4824ed6517ce5abef65f07",
+		"manifest.json": "6b07697513fcf79c4e4bee592f45582426d2b382fb241f0174189e111dff9a59",
+		"module.json": "a01a5b00c3e5c836b22c66112c65845fab23600f96dc6da84e2be44fd4b39890"
 	},
 	"defs": {
 		"C_PLAYER_LOCATION": 5,
 		"C_TRY_LOOT_DROPITEM": 4,
 		"S_DESPAWN_DROPITEM": 4,
 		"S_RETURN_TO_LOBBY": 1,
-		"S_SPAWN_DROPITEM": 7
+		"S_SPAWN_DROPITEM": 7,
+		"S_SYSTEM_MESSAGE": 1
 	}
 }

+ 2 - 5
module.json

@@ -1,10 +1,7 @@
 {
   "disableAutoUpdate": false,
-  "servers": ["https://raw.githubusercontent.com/valkyr1e-tera/loot/master/"],
+  "servers": ["https://raw.githubusercontent.com/TerableCoder/auto-loot/master/"],
   "options": {
-    "niceName": "loot",
-    "settingsVersion": 3,
-    "settingsFile": "config.json",
-    "settingsMigrator": "settings_migrator.js"
+    "niceName": "auto-loot",
   }
 }