mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-05 16:49:06 +00:00
Various fixes and improvements (#640)
* Added more client settings for winter and hide roofs * Removed unnecessary local var and added Javadoc comment * Fixed dark wizards casting magic in melee range * Added AttackType enum * Removed extra asterisk * Removed attackType magic numbers * Enabled snow toggles by default * Combined snow month into one variable * Added option for fixes without custom settings Added option for fixes (and QoL tab) without overriding specific features. * Added more main args * Fixed typo * Added player sound saving We have it for music, so why not for sounds too? * Fixed typos * Added closed client exception to ignores * Fixed NPC definitions not loading * Replaced NPC definitions XML with JSON * Replaced NPCDefinition Array with HashMap * Use err for early exit output * Fixed KQ death causing client crash It had the wrong anims. * Added zoom level to debug info * Added zoom level messages option * Added fire breath attack type enum * Replaced remaining fire breath attack types * Fixed client lag This should technically not be necessary, but it's more of a workaround due to server inefficiencies (if you kill a bunch of cows, your client will start to lag and you will even stack hits, I suspect it's due to the ground items) until we fix the server inefficiencies. There's not really any downsides in changing this from 5 to 100, so it's a good change for now. * Make definitions private * Fixed dark wizards not attacking back * Improved comments * Removed extra giant mole spawns * Added mole lair rope action * Only send yes chat head when talking to NPC * Fixed removing item does not reset autocast * Fixed picking up stackable items with full inv * Fixed lvl 7 dark wizard anims * Added confirm param to xprate command and fixed players command * Removed usages of Misc.println This hides which file the println is actually called from, so it's actually better to remove this helper. * Don't move player when clicking on barrows check This is both unauthentic and unnecessary. * Removed unnecessary commented out code We don't even need it commented out tbh. * Fixed incorrect barrows NPC attack anims * Improved slayer points message * Fixed slayer task message cut off * Might as well make this naming consistent * Fixed typo * Fixed stronghold slayer dungeon getting stuck in wall * Require control key for zooming It's too easy to accidentally zoom in/out with the scroll wheel, so let's make it so you need the control key held to scroll wheel zoom in/out. * Added option for control key zooming This way, it's off by default so it works the way it always did by default. * Added alias for control key zoom * Fixed quest interface not emptying out completely * Updated slayer point dialogue to be more accurate * Fixed compile error * Fixed formatting * More formatting fixes * Added 5th click object handling (fixes pick-lock crash) * Fixed lower level NPCs always hitting 0 * Fixed NPCs having incorrect max hit Chickens were hitting 3's, ouch... * Fixed NPCs still hitting 0s This is much better now. Combat feels good. * Fixed boss max hits * Fixed al-kharid gate talking option * Copied over max hits from spawns.json to npcDefinitions.json This fixes a lot of NPCs. Many NPCs already seem to be correct. * Added workaround preventing players stuck in level 28 wildy * Changed comment to TODO * Added control key zoom toggle * Extracted config option to ClientSettings * added message for control key zooming
This commit is contained in:
@@ -2,25 +2,35 @@ package com.rs2.game.npcs;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.rs2.util.XStreamUtil;
|
||||
|
||||
public class NPCDefinition {
|
||||
|
||||
private static NPCDefinition[] definitions = null;
|
||||
|
||||
private static HashMap<Integer, NPCDefinition> definitions = new HashMap<>();
|
||||
|
||||
public static void init() throws IOException {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<NPCDefinition> defs = (List<NPCDefinition>) XStreamUtil.getXStream().fromXML(new FileInputStream("data/cfg/npcDefinitions.xml"));
|
||||
definitions = new NPCDefinition[3790];
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<NPCDefinition>>(){}.getType();
|
||||
List<NPCDefinition> defs;
|
||||
try (FileReader reader = new FileReader("data/cfg/npcDefinitions.json")) {
|
||||
defs = gson.fromJson(reader, type);
|
||||
}
|
||||
for (NPCDefinition def : defs) {
|
||||
definitions[def.getId()] = def;
|
||||
definitions.put(def.getId(), def);
|
||||
}
|
||||
}
|
||||
|
||||
public static NPCDefinition forId(int id) {
|
||||
NPCDefinition d = definitions[id];
|
||||
NPCDefinition d = definitions.get(id);
|
||||
if (d == null) {
|
||||
d = produceDefinition(id);
|
||||
}
|
||||
|
||||
@@ -1137,7 +1137,7 @@ public class NpcActions {
|
||||
break;
|
||||
default:
|
||||
if (player.playerRights == 3) {
|
||||
Misc.println("Third Click NPC : " + npcType);
|
||||
System.out.println("Third Click NPC : " + npcType);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.rs2.game.npcs;
|
||||
|
||||
import com.rs2.game.content.combat.AttackType;
|
||||
import com.rs2.game.content.minigames.FightCaves;
|
||||
import com.rs2.game.players.PlayerHandler;
|
||||
import com.rs2.util.Misc;
|
||||
@@ -227,8 +228,8 @@ public class NpcData {
|
||||
return 3;
|
||||
|
||||
case 2745:
|
||||
if (NpcHandler.npcs[i].attackType == 1
|
||||
|| NpcHandler.npcs[i].attackType == 2) {
|
||||
if (NpcHandler.npcs[i].attackType == AttackType.RANGE.getValue()
|
||||
|| NpcHandler.npcs[i].attackType == AttackType.MAGIC.getValue()) {
|
||||
return 5;
|
||||
} else {
|
||||
return 2;
|
||||
@@ -279,23 +280,26 @@ public class NpcData {
|
||||
return 25;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Distance required to attack
|
||||
* It's also worth checking {@link NpcHandler#distanceRequired}
|
||||
*/
|
||||
public static int distanceRequired(int i) {
|
||||
int distanceNeeded = 1;
|
||||
if (NpcHandler.npcs[i].attackType == 1) {
|
||||
return distanceNeeded += 7;
|
||||
} else if (NpcHandler.npcs[i].attackType == 2) {
|
||||
return distanceNeeded += 9;
|
||||
} else if (NpcHandler.npcs[i].attackType > 2) {
|
||||
return distanceNeeded += 4;
|
||||
if (NpcHandler.npcs[i].attackType == AttackType.RANGE.getValue()) {
|
||||
return 8;
|
||||
} else if (NpcHandler.npcs[i].attackType == AttackType.MAGIC.getValue()) {
|
||||
return 10;
|
||||
} else if (NpcHandler.npcs[i].attackType > AttackType.MAGIC.getValue()) {
|
||||
return 5;
|
||||
}
|
||||
switch (NpcHandler.npcs[i].npcType) {
|
||||
case 2562:
|
||||
return distanceNeeded += 1;
|
||||
return 2;
|
||||
case 2881:// dag kings
|
||||
case 2882:
|
||||
case 3200:// chaos ele
|
||||
return distanceNeeded += 7;
|
||||
return 8;
|
||||
case 2552:
|
||||
case 2553:
|
||||
case 2556:
|
||||
@@ -305,11 +309,11 @@ public class NpcData {
|
||||
case 2560:
|
||||
case 2564:
|
||||
case 2565:
|
||||
return distanceNeeded += 8;
|
||||
return 9;
|
||||
// things around dags
|
||||
case 2892:
|
||||
case 2894:
|
||||
return distanceNeeded += 9;
|
||||
return 10;
|
||||
case 907 : // Kolodian
|
||||
case 908 :
|
||||
case 909 :
|
||||
@@ -324,16 +328,18 @@ public class NpcData {
|
||||
case 1158 : // Kalphite queen form 1
|
||||
case 1160 : // Kalphite queen form 2
|
||||
case 2025 : // Ahrim
|
||||
return distanceNeeded += 9;
|
||||
return 10;
|
||||
case 2028 : // Karil
|
||||
case 2631 : // Tok-Xil (Tzhaar ranging guy)
|
||||
case 1183 : // Elf ranger
|
||||
return distanceNeeded += 7;
|
||||
case 172: // dark wizards
|
||||
case 174:
|
||||
return 8;
|
||||
case 941 : // Green drag
|
||||
case 50 : // Kbd
|
||||
return distanceNeeded += 5;
|
||||
return 6;
|
||||
}
|
||||
return distanceNeeded;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.rs2.GameEngine;
|
||||
import com.rs2.event.CycleEvent;
|
||||
import com.rs2.event.CycleEventContainer;
|
||||
import com.rs2.event.CycleEventHandler;
|
||||
import com.rs2.game.content.combat.AttackType;
|
||||
import com.rs2.game.content.combat.CombatConstants;
|
||||
import com.rs2.game.content.combat.npcs.NpcAggressive;
|
||||
import com.rs2.game.content.combat.npcs.NpcCombat;
|
||||
@@ -153,7 +154,8 @@ public class NpcHandler {
|
||||
try {
|
||||
NPCDefinition.init();
|
||||
} catch (Exception e) {
|
||||
//System.out.println("npc def error");
|
||||
System.out.println("npc def error: ");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,7 +265,7 @@ public class NpcHandler {
|
||||
}
|
||||
}
|
||||
if (slot == -1) {
|
||||
// Misc.println("No Free Slot");
|
||||
// System.out.println("No Free Slot");
|
||||
return; // no free slot found
|
||||
}
|
||||
Npc newNPC = new Npc(slot, npcType);
|
||||
@@ -310,7 +312,7 @@ public class NpcHandler {
|
||||
}
|
||||
}
|
||||
if (slot == -1) {
|
||||
// Misc.println("No Free Slot");
|
||||
// System.out.println("No Free Slot");
|
||||
return; // no free slot found
|
||||
}
|
||||
Npc newNPC = new Npc(slot, npcType);
|
||||
@@ -907,21 +909,21 @@ public class NpcHandler {
|
||||
public static boolean multiAttacks(int i) {
|
||||
switch (npcs[i].npcType) {
|
||||
case 1158: //kq
|
||||
if (npcs[i].attackType == 2) {
|
||||
if (npcs[i].attackType == AttackType.MAGIC.getValue()) {
|
||||
return true;
|
||||
}
|
||||
case 1160: //kq
|
||||
if (npcs[i].attackType == 1) {
|
||||
if (npcs[i].attackType == AttackType.RANGE.getValue()) {
|
||||
return true;
|
||||
}
|
||||
case 2558:
|
||||
return true;
|
||||
case 2562:
|
||||
if (npcs[i].attackType == 2) {
|
||||
if (npcs[i].attackType == AttackType.MAGIC.getValue()) {
|
||||
return true;
|
||||
}
|
||||
case 2550:
|
||||
if (npcs[i].attackType == 1) {
|
||||
if (npcs[i].attackType == AttackType.RANGE.getValue()) {
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
@@ -1138,7 +1140,8 @@ public class NpcHandler {
|
||||
int points = c.getSlayer().getDifficulty(c.slayerTask) * 4;
|
||||
c.slayerTask = -1;
|
||||
c.slayerPoints += points;
|
||||
c.getPacketSender().sendMessage("You completed your slayer task. You obtain " + points + " slayer points. Please talk to your slayer master.");
|
||||
c.getPacketSender().sendMessage("You completed your slayer task. You obtain " + points + " slayer points.");
|
||||
c.getPacketSender().sendMessage("Please talk to your slayer master for a new task.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1273,6 +1276,8 @@ public class NpcHandler {
|
||||
|
||||
/**
|
||||
* Distanced required to attack
|
||||
* If NPCs are maging in melee distance check that the NPC ID is actually in here.
|
||||
* It's also worth checking {@link NpcData#distanceRequired}
|
||||
**/
|
||||
public static int distanceRequired(int i) {
|
||||
switch (npcs[i].npcType) {
|
||||
@@ -1282,6 +1287,8 @@ public class NpcHandler {
|
||||
case 50:
|
||||
case 2562:
|
||||
return 2;
|
||||
case 172: // dark wizards
|
||||
case 174:
|
||||
case 2881:// dag kings
|
||||
case 2882:
|
||||
case 3200:// chaos ele
|
||||
@@ -1420,7 +1427,7 @@ public class NpcHandler {
|
||||
case 1158:
|
||||
return 30;
|
||||
case 2558:
|
||||
if (npcs[i].attackType == 2) {
|
||||
if (npcs[i].attackType == AttackType.MAGIC.getValue()) {
|
||||
return 28;
|
||||
} else {
|
||||
return 68;
|
||||
@@ -1467,7 +1474,7 @@ public class NpcHandler {
|
||||
spawn.getStrength());
|
||||
}
|
||||
} catch (FileNotFoundException fileex) {
|
||||
Misc.println("spawns.json: file not found.");
|
||||
System.out.println("spawns.json: file not found.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1484,13 +1491,13 @@ public class NpcHandler {
|
||||
try {
|
||||
characterfile = new BufferedReader(new FileReader(FileName));
|
||||
} catch (FileNotFoundException fileex) {
|
||||
Misc.println(FileName + ": file not found.");
|
||||
System.out.println(FileName + ": file not found.");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
line = characterfile.readLine();
|
||||
} catch (IOException ioexception) {
|
||||
Misc.println(FileName + ": error loading file.");
|
||||
System.out.println(FileName + ": error loading file.");
|
||||
// return false;
|
||||
}
|
||||
while (EndOfFile == false && line != null) {
|
||||
@@ -1581,7 +1588,7 @@ public class NpcHandler {
|
||||
newNPCList(npc.getId(), npc.getName(), npc.getCombat(), npc.getHitpoints());
|
||||
}
|
||||
} catch (FileNotFoundException fileex) {
|
||||
Misc.println("npc.json: file not found.");
|
||||
System.out.println("npc.json: file not found.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1597,14 +1604,14 @@ public class NpcHandler {
|
||||
try {
|
||||
characterfile = new BufferedReader(new FileReader(FileName));
|
||||
} catch (FileNotFoundException fileex) {
|
||||
Misc.println(FileName + ": file not found.");
|
||||
System.out.println(FileName + ": file not found.");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
line = characterfile.readLine();
|
||||
// characterfile.close();
|
||||
} catch (IOException ioexception) {
|
||||
Misc.println(FileName + ": error loading file.");
|
||||
System.out.println(FileName + ": error loading file.");
|
||||
// return false;
|
||||
}
|
||||
while (EndOfFile == false && line != null) {
|
||||
|
||||
@@ -28,7 +28,7 @@ public class NPCDropsHandler {
|
||||
try {
|
||||
npcDrops = new Gson().fromJson(new FileReader("./data/cfg/npcdrops.json"), NpcDrop[].class);
|
||||
} catch (FileNotFoundException fileex) {
|
||||
Misc.println("npcdrops.json: file not found.");
|
||||
System.out.println("npcdrops.json: file not found.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user