Browse Source

hope u liek

Lambda 7 years ago
commit
89faba3fb1
5 changed files with 191 additions and 0 deletions
  1. 15 0
      README.md
  2. 126 0
      index.js
  3. 17 0
      manifest.json
  4. 15 0
      module.json
  5. 18 0
      settings_migrator.js

+ 15 - 0
README.md

@@ -0,0 +1,15 @@
+
+# Instant-Revive
+
+After you press revive there is a few seconds delay before you can actually move and use skills, which is frequently enough for you to die again (under new boss attack or just in some sort of ground-puddle aoe damage such as fire on Bahaars arena edges), but now with this module:  
+You can **revive instantly** without the "getting up" animation and start moving and using skills right away!  
+Also works on your party members! So you can lock onto them as Priest and use pull or heal right away, saving them from Bahaars fire or anything else as soon as they hit their "revive" button!  
+
+# Commands  
+- !`irevive` to toggle module (DEFAULT: ON)  
+- !`irevive party` to toggle party functions which are useful if you are a Priest (DEFAULT: OFF)  
+- !`irevive drama` to toggle drama when dying (DEFAULT: OFF) (might increase the probabily of dead body being in the wrong place for ressurection visually on your screen)   
+
+# Notes
+
+also disables black & white screen effect when you die  

+ 126 - 0
index.js

@@ -0,0 +1,126 @@
+module.exports = function Instant_revive(mod) {
+	const command = mod.command;
+	let partyMembers = [],
+		isDead = {};
+	
+	mod.game.initialize("me");
+	
+	command.add('irevive', {
+		$none() {
+			mod.settings.enabled = !mod.settings.enabled;
+			command.message(`for Self: ${mod.settings.enabled ? 'En' : 'Dis'}abled`);
+		},
+		party() {
+			mod.settings.party = !mod.settings.party;
+			command.message(`for Party: ${mod.settings.party ? 'En' : 'Dis'}abled`);
+			if (!mod.settings.party)
+			{
+				partyMembers.length = 0;
+				command.message(`If you enable it again later while you are in a party - you will need to rejoin your party after that for this to work again`);
+			}
+		},
+		drama() {
+			mod.settings.drama = !mod.settings.drama;
+			command.message(`Drama: ${mod.settings.drama ? 'En' : 'Dis'}abled`);
+		}
+	});
+	
+	mod.hook('S_CREATURE_LIFE', 3, {order: 9999}, ({gameId, alive, loc})=>{
+		if(mod.settings.enabled)
+		{
+			const member = partyMembers.find((memb) => memb.gameId === gameId);
+			if (!member && gameId !== mod.game.me.gameId) return;
+			
+			if(!alive)
+			{
+				isDead[gameId] = true;
+				moveBody(gameId, loc); // doesn't help at all I think
+				if(mod.settings.drama)
+				{
+					setTimeout(fakeDeath, 300, gameId, loc, 0);
+					setTimeout(fakeDeath, 5000, gameId, loc, 1);
+				}
+				else
+				{
+					setTimeout(fakeDeath, 300, gameId, loc, 1);
+				}
+				return false; // we wont't have to waste time reviving if we don't die
+			}
+			else
+			{
+				fakeDeathEnd(gameId, loc);
+				isDead[gameId] = false;
+			}
+		}
+	});
+	
+	mod.hook('S_PARTY_MEMBER_LIST', 7, ({members}) => {
+		if (!mod.settings.party) return;
+		
+		partyMembers = members;
+	});
+	
+	mod.hook('S_LEAVE_PARTY_MEMBER', 2, ({playerId}) => {
+		const mpos = partyMembers.findIndex((memb) => memb.playerId === playerId);
+		if (mpos === -1) return;
+		
+		delete isDead[partyMembers[mpos].gameId];
+		partyMembers.splice(mpos, 1);
+	});
+	
+	mod.hook('S_LEAVE_PARTY', 'raw', () => {
+		partyMembers.length = 0;
+	})
+
+	function fakeDeath(Id, Loc, Stage)
+	{
+		if(isDead[Id])
+		{
+			mod.send('S_ACTION_STAGE', 9, {	
+				gameId: Id,
+				templateId: 11006,
+				speed: 1,
+				projectileSpeed: 1,
+				stage: Stage,
+				id: 9999999,
+				effectScale: 1,
+				dest: Loc,
+				loc: Loc,
+				skill: {
+					reserved: 0,
+					npc: false,
+					type: 1,
+					huntingZoneId: 0,
+					id: 70300
+				}});
+		}
+	}
+	
+	function fakeDeathEnd(Id, Loc)
+	{
+		mod.send('S_ACTION_END', 5, {	
+			gameId: Id,
+			templateId: 11006,
+			type: 25,
+			id: 9999999,
+			loc: Loc,
+			skill: {
+				reserved: 0,
+				npc: false,
+				type: 1,
+				huntingZoneId: 0,
+				id: 70300
+			}});
+	}
+	
+	function moveBody(Id, Loc)
+	{
+		mod.send('S_USER_LOCATION', 5, {	
+			gameId: Id,
+			loc: Loc,
+			speed: 250,
+			dest: Loc,
+			type: 7
+		});
+	}
+}

+ 17 - 0
manifest.json

@@ -0,0 +1,17 @@
+{
+	"files": {
+		"README.md": "bcd84495d10e10cf31f8ba6780416243530267874917697bb2f1b782088dca7b",
+		"index.js": "6f5e5d6868d6a62f5d76c3e39bc33a62952709f1ad68a04afe172ac5a4916be2",
+		"module.json": "ed003376acf3807b44a08b852397cc948e65574aaec9f9b891c2585fd35edc97",
+		"settings_migrator.js": "f97c5a0de378cdb754a0eede1ad14176d6cd6fc28013b6bc48063a6a80e48ec1"
+	},
+	"defs": {
+		"S_ACTION_END": 5,
+		"S_ACTION_STAGE": 9,
+		"S_CREATURE_LIFE": 3,
+		"S_LEAVE_PARTY": "raw",
+		"S_LEAVE_PARTY_MEMBER": 2,
+		"S_PARTY_MEMBER_LIST": 7,
+		"S_USER_LOCATION": 5
+	}
+}

+ 15 - 0
module.json

@@ -0,0 +1,15 @@
+{
+	"disableAutoUpdate": false,
+	"name": "instant-revive",
+	"author": "Lambda11",
+	"description": "Makes your revive instant",
+	"options": {
+		"niceName": "Instant-Revive",
+		"guiName": "Instant-Revive",
+		"settingsVersion": 1,
+		"settingsFile": "config.json",
+		"settingsMigrator": "settings_migrator.js"
+	},
+	"servers": ["https://raw.githubusercontent.com/Lambda11/instant-revive/master/"],
+	"supportUrl": "https://github.com/Lambda11/instant-revive/issues"
+}

+ 18 - 0
settings_migrator.js

@@ -0,0 +1,18 @@
+const DefaultSettings = {
+    "enabled": true,
+    "party": false,
+	"drama": false
+}
+
+module.exports = function MigrateSettings(from_ver, to_ver, settings) {
+    if (from_ver === undefined) {
+        // Migrate legacy config file
+        return Object.assign(Object.assign({}, DefaultSettings), settings);
+    } else if (from_ver === null) {
+        // No config file exists, use default settings
+        return DefaultSettings;
+    } else {
+        // Migrate from older version (using the new system) to latest one
+        throw new Error('So far there is only one settings version and this should never be reached!');
+    }
+}