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:
ipkpjersi
2024-09-20 20:30:57 -04:00
committed by GitHub
parent 0e484985ad
commit cad090d8fe
57 changed files with 134756 additions and 134494 deletions
@@ -7,6 +7,47 @@ import java.math.BigInteger;
*/
public class ClientSettings {
/**
* @QoL
* Require control key to zoom the client
*/
public static boolean CONTROL_KEY_ZOOMING = false;
/**
* @QoL
* Show zoom level messages in chat when changing zoom levels
*/
public static boolean SHOW_ZOOM_LEVEL_MESSAGES = false;
/**
* @QoL
* Hide roofs
*/
public static boolean HIDE_ROOFS = false;
/**
* @QoL
* Hide buggy varrock sword shop snow
*/
public static boolean HIDE_BUGGY_VARROCK_SWORD_SHOP_SNOW = true;
/**
* @QoL
* Forces Server-Wide Snow floor
*/
public static boolean SNOW_FLOOR_FORCE_ENABLED = false;
/**
* @QoL
* Toggles Server-Wide Snow floor (for the designated month)
*/
public static boolean SNOW_FLOOR_ENABLED = true;
/**
* @QoL
* Forces Server-Wide Snow overlay
*/
public static boolean SNOW_OVERLAY_FORCE_ENABLED = false;
/**
* @QoL
* Toggles Server-Wide Snow overlay (for the designated month)
*/
public static boolean SNOW_OVERLAY_ENABLED = false;
/**
* @QoL
* Enables Server-Wide Snow In The Designated Month
+1 -1
View File
@@ -35,7 +35,7 @@ public final class Flo {
} else if (i == 1) {
anInt390 = stream.read3Bytes();
Calendar date = new GregorianCalendar();
if ((date.get(Calendar.MONTH) + 1) == 12) {
if (ClientSettings.SNOW_FLOOR_FORCE_ENABLED || (ClientSettings.SNOW_FLOOR_ENABLED && (date.get(Calendar.MONTH) + 1) == Integer.parseInt(ClientSettings.SNOW_MONTH.substring(1)))) {
anInt390 = 0xffffff;
}
method262(anInt390);
+39 -10
View File
@@ -2975,7 +2975,11 @@ public class Game extends RSApplet {
if (anInt1011 > 0) {
anInt1011--;
}
for (int j = 0; j < 5; j++) {
//TODO: Technically, this loop should be < 5 for authenticity, but until we reduce server inefficiencies
//(for example killing a bunch of cows results in client lag,
//likely from all the items on the ground for example), < 100 is fine.
//OSRS uses < 100 and there are no drawbacks from having this < 100.
for (int j = 0; j < 100; j++) {
if (!parsePacket()) {
break;
}
@@ -3758,7 +3762,7 @@ public class Game extends RSApplet {
worldController.method312(k - 4, j - 4);
}
}
if (l == 1062) {
if (l == 1062) { //Fifth click
anInt924 += baseX;
if (anInt924 >= 113) {
stream.createFrame(183);
@@ -5034,6 +5038,10 @@ public class Game extends RSApplet {
if (inputString.equals("::gfxtgl") || inputString.equals("::tglgfx") || inputString.equals("::togglerender") || inputString.equals("::togglegfx")) {
graphicsEnabled = !graphicsEnabled;
}
if (inputString.equals("::crtlkeyzoom") || inputString.equals("::controlkeyzoom")) {
ClientSettings.CONTROL_KEY_ZOOMING = !ClientSettings.CONTROL_KEY_ZOOMING;
pushMessage("Your control key zooming is now: " + (ClientSettings.CONTROL_KEY_ZOOMING ? "enabled" : "disabled"), 0, "");
}
if (myPrivilege >= 2) {
if (inputString.equals("::noclip"))
for (int k1 = 0; k1 < 4; k1++)
@@ -11571,7 +11579,7 @@ public class Game extends RSApplet {
// 15774 = Good/Bad Password
// 15767 = Drama Type
if (l7 == 15244) {
if (Flo.getTodaysDate().contains(ClientSettings.SNOW_MONTH)) {
if (ClientSettings.SNOW_OVERLAY_FORCE_ENABLED || (ClientSettings.SNOW_OVERLAY_ENABLED && Flo.getTodaysDate().contains(ClientSettings.SNOW_MONTH))) {
openInterfaceID = 15819;
} else {
openInterfaceID = 15801;
@@ -11814,8 +11822,8 @@ public class Game extends RSApplet {
draw3dScreen();
if (showInfo) {
int debugX = 0;
int debugY = 249;
int debugItems = 4;
int debugY = 234;
int debugItems = 5;
int debugWidth = 140;
int debugHeight = 25 + (debugItems * 15);
int fill = 0x5d5447;
@@ -11842,6 +11850,8 @@ public class Game extends RSApplet {
chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, Color.YELLOW.hashCode(), (myPlayer.smallX[0] + baseX) + ", " + (myPlayer.smallY[0] + baseY), debugY);
chatTextDrawingArea.textLeftShadow(true, debugX + 4, Color.WHITE.hashCode(), "Interface:", debugY += 15);
chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, Color.YELLOW.hashCode(), "" + openInterfaceID, debugY);
chatTextDrawingArea.textLeftShadow(true, debugX + 4, Color.WHITE.hashCode(), "Zoom level:", debugY += 15);
chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, Color.YELLOW.hashCode(), "" + zoom, debugY);
}
if (customSettingShowExperiencePerHour) {
@@ -12619,12 +12629,20 @@ public class Game extends RSApplet {
tabAreaAltered = true;
break;
case KeyEvent.VK_PAGE_UP:
if (zoom > -1)
if (zoom > -1) {
zoom--;
if (ClientSettings.SHOW_ZOOM_LEVEL_MESSAGES) {
pushMessage("Your zoom level is now: " + zoom, 0, "");
}
}
break;
case KeyEvent.VK_PAGE_DOWN:
if (zoom < (WorldController.drawDistance / 3))
if (zoom < (WorldController.drawDistance / 3)) {
zoom++;
if (ClientSettings.SHOW_ZOOM_LEVEL_MESSAGES) {
pushMessage("Your zoom level is now: " + zoom, 0, "");
}
}
break;
case KeyEvent.VK_V:
if (keyevent.isControlDown()) {
@@ -12783,7 +12801,7 @@ public class Game extends RSApplet {
inputTaken = true;
}
if (interfaceID == 15244) {
if (Flo.getTodaysDate().contains(ClientSettings.SNOW_MONTH)) {
if (ClientSettings.SNOW_OVERLAY_FORCE_ENABLED || (ClientSettings.SNOW_OVERLAY_ENABLED && Flo.getTodaysDate().contains(ClientSettings.SNOW_MONTH))) {
openInterfaceID = 15819;
} else {
openInterfaceID = 15801;
@@ -12806,14 +12824,25 @@ public class Game extends RSApplet {
public final void mouseWheelMoved(MouseWheelEvent e) {
int notches = e.getWheelRotation();
if (ClientSettings.CONTROL_KEY_ZOOMING && !e.isControlDown()) {
return;
}
// If mouse over main game screen, without anything else opened
if (openInterfaceID == -1 && mouseX < 515 && mouseY < 340) {
if (notches < 0) {
if (zoom > -1)
if (zoom > -1) {
zoom--;
if (ClientSettings.SHOW_ZOOM_LEVEL_MESSAGES) {
pushMessage("Your zoom level is now: " + zoom, 0, "");
}
}
} else {
if (zoom < (WorldController.drawDistance / 3))
if (zoom < (WorldController.drawDistance / 3)) {
zoom++;
if (ClientSettings.SHOW_ZOOM_LEVEL_MESSAGES) {
pushMessage("Your zoom level is now: " + zoom, 0, "");
}
}
}
}
}
+17 -2
View File
@@ -32,13 +32,28 @@ public final class Main {
ClientSettings.BILINEAR_MINIMAP_FILTERING = true;
ClientSettings.FIX_TRANSPARENCY_OVERFLOW = true;
ClientSettings.FULL_512PX_VIEWPORT = true;
Game.customSettingVisiblePlayerNames = true;
Game.customSettingMinItemValue = 1000;
ClientSettings.CONTROL_KEY_ZOOMING = true;
break;
case "-no-nav":
case "-disable-nav":
ClientSettings.SHOW_NAVBAR = false;
break;
case"-no-snow":
case"-hide-snow":
case"-disable-snow":
ClientSettings.SNOW_FLOOR_ENABLED = false;
ClientSettings.SNOW_FLOOR_FORCE_ENABLED = false;
ClientSettings.SNOW_OVERLAY_FORCE_ENABLED = false;
ClientSettings.SNOW_OVERLAY_ENABLED = false;
break;
case"-no-roofs":
case"-hide-roofs":
case"-disable-roofs":
ClientSettings.HIDE_ROOFS = true;
break;
case"-show-zoom":
ClientSettings.SHOW_ZOOM_LEVEL_MESSAGES = true;
break;
}
if (args[i].startsWith("-") && (i + 1) < args.length && !args[i + 1].startsWith("-")) {
switch(args[i]) {
@@ -146,7 +146,7 @@ final class ObjectManager {
k15 -= anIntArray127[k18];
k16 -= anIntArray128[k18];
}
if (k17 >= 1 && k17 < anInt147 - 1 && (!lowMem || (aByteArrayArrayArray149[0][l6][k17] & 2) != 0 || (aByteArrayArrayArray149[l][l6][k17] & 0x10) == 0 && method182(k17, l, l6) == anInt131)) {
if (k17 >= 1 && k17 < anInt147 - 1 && ((!hideBuggyVarrockSwordShopSnow && !hideRoofs && !lowMem) || (aByteArrayArrayArray149[0][l6][k17] & 2) != 0 || (aByteArrayArrayArray149[l][l6][k17] & 0x10) == 0 && method182(k17, l, l6) == anInt131)) {
if (l < anInt145) {
anInt145 = l;
}
@@ -456,7 +456,7 @@ final class ObjectManager {
}
private void method175(int i, WorldController worldController, CollisionMap class11, int j, int k, int l, int i1, int j1) {
if (lowMem && (aByteArrayArrayArray149[0][l][i] & 2) == 0) {
if ((hideRoofs || lowMem) && (aByteArrayArrayArray149[0][l][i] & 2) == 0) {
if ((aByteArrayArrayArray149[k][l][i] & 0x10) != 0) {
return;
}
@@ -1355,6 +1355,10 @@ final class ObjectManager {
private final byte[][][] aByteArrayArrayArray148;
private final byte[][][] aByteArrayArrayArray149;
static boolean lowMem = true;
static boolean hideRoofs = ClientSettings.HIDE_ROOFS;
static boolean hideBuggyVarrockSwordShopSnow = ClientSettings.HIDE_BUGGY_VARROCK_SWORD_SHOP_SNOW; //There is some buggy snow near Varrock sword shop, let's hide it. I know, this is not ideal, but it does work.
private static final int anIntArray152[] = {1, 2, 4, 8};
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-40
View File
@@ -3789,36 +3789,6 @@
"walk": 1,
"height": 0
},
{
"maxHit": 32,
"strength": 200,
"attack": 300,
"x": 1738,
"y": 5226,
"id": 3340,
"walk": 1,
"height": 0
},
{
"maxHit": 32,
"strength": 200,
"attack": 300,
"x": 1777,
"y": 5237,
"id": 3340,
"walk": 1,
"height": 0
},
{
"maxHit": 32,
"strength": 200,
"attack": 300,
"x": 1740,
"y": 5178,
"id": 3340,
"walk": 1,
"height": 0
},
{
"maxHit": 32,
"strength": 200,
@@ -3829,16 +3799,6 @@
"walk": 1,
"height": 0
},
{
"maxHit": 32,
"strength": 200,
"attack": 300,
"x": 1780,
"y": 5190,
"id": 3340,
"walk": 1,
"height": 0
},
{
"maxHit": 38,
"strength": 200,
@@ -0,0 +1,37 @@
package plugin.buttons.gameframe;
import com.rs2.event.SubscribesTo;
import com.rs2.event.impl.ButtonActionEvent;
import com.rs2.game.content.music.Music;
import com.rs2.game.players.Player;
import plugin.buttons.ButtonClick;
@SubscribesTo(ButtonActionEvent.class)
public final class SoundVolumeButtons extends ButtonClick {
@Override
protected void execute(Player player, ButtonActionEvent event) {
switch (event.getButton()) {
case 3173:
if (player.soundOn) {
player.soundOn = false;
} else {
player.getPacketSender().sendMessage("Your sound is already turned off.");
}
break;
case 3174:
case 3175:
case 3176:
case 3177:
player.soundOn = true;
break;
}
}
@Override
public boolean test(ButtonActionEvent event) {
return event.getButton() == 3173 || event.getButton() == 3174 || event.getButton() == 3175 || event.getButton() == 3176 || event.getButton() == 3177;
}
}
@@ -153,15 +153,15 @@ public class GameEngine {
}
if (!new File("data").exists()) {
System.out.println("************************************");
System.out.println("************************************");
System.out.println("************************************");
System.out.println("WARNING: I could not find the /data folder. You are LIKELY running this in the wrong directory!");
System.out.println("In IntelliJ, fix it by clicking \"Server\" > Edit Configurations at the top of your screen");
System.out.println("Then changing the \"Working Directory\" to be in \"2006Scape/2006Scape Server\", instead of just \"2006Scape\"");
System.out.println("************************************");
System.out.println("************************************");
System.out.println("************************************");
System.err.println("************************************");
System.err.println("************************************");
System.err.println("************************************");
System.err.println("WARNING: I could not find the /data folder. You are LIKELY running this in the wrong directory!");
System.err.println("In IntelliJ, fix it by clicking \"Server\" > Edit Configurations at the top of your screen");
System.err.println("Then changing the \"Working Directory\" to be in \"2006Scape/2006Scape Server\", instead of just \"2006Scape\"");
System.err.println("************************************");
System.err.println("************************************");
System.err.println("************************************");
System.exit(1);
}
@@ -0,0 +1,18 @@
package com.rs2.game.content.combat;
public enum AttackType {
MELEE(0),
RANGE(1),
MAGIC(2),
FIRE_BREATH(3);
private final int value;
AttackType(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
@@ -1,6 +1,7 @@
package com.rs2.game.content.combat.npcs;
import com.rs2.Constants;
import com.rs2.game.content.combat.AttackType;
import com.rs2.game.content.combat.CombatConstants;
import com.rs2.game.content.combat.melee.MeleeData;
import com.rs2.game.content.minigames.FightCaves;
@@ -8,6 +9,7 @@ import com.rs2.game.content.minigames.PestControl;
import com.rs2.game.content.music.sound.CombatSounds;
import com.rs2.game.content.music.sound.SoundList;
import com.rs2.game.items.impl.Greegree.MonkeyData;
import com.rs2.game.npcs.NPCDefinition;
import com.rs2.game.npcs.NpcData;
import com.rs2.game.npcs.NpcHandler;
import com.rs2.game.players.Client;
@@ -28,7 +30,7 @@ public class NpcCombat {
}
if (player.goodDistance(c.absX, c.absY,
NpcHandler.npcs[i].absX, NpcHandler.npcs[i].absY, 15)) {
if (NpcHandler.npcs[i].attackType == 2) {
if (NpcHandler.npcs[i].attackType == AttackType.MAGIC.getValue()) {
if (!c.getPrayer().prayerActive[16]) {
if (Misc.random(500) + 200 > Misc.random(c.getCombatAssistant().mageDef())) {
int dam = Misc.random(max);
@@ -42,7 +44,7 @@ public class NpcCombat {
c.dealDamage(0);
c.handleHitMask(0);
}
} else if (NpcHandler.npcs[i].attackType == 1) {
} else if (NpcHandler.npcs[i].attackType == AttackType.RANGE.getValue()) {
if (!c.getPrayer().prayerActive[17]) {
int dam = Misc.random(max);
if (Misc.random(500) + 200 > Misc.random(c
@@ -164,7 +166,7 @@ public class NpcCombat {
NpcHandler.npcs[i].facePlayer(c);
NpcHandler.npcs[i].attackTimer = NpcData.getNpcDelay(i);
NpcHandler.npcs[i].hitDelayTimer = NpcData.getHitDelay(i);
NpcHandler.npcs[i].attackType = 0;
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
if (CombatConstants.COMBAT_SOUNDS) {
if (PestControl.npcIsPCMonster(NpcHandler.npcs[i].npcType) || PestControl.isPCPortal(NpcHandler.npcs[i].npcType)) {
return;
@@ -176,7 +178,7 @@ public class NpcCombat {
} else {
loadSpell(c, i);
}
if (NpcHandler.npcs[i].attackType == 3) {
if (NpcHandler.npcs[i].attackType == AttackType.FIRE_BREATH.getValue()) {
NpcHandler.npcs[i].hitDelayTimer += 2;
}
if (NpcHandler.multiAttacks(i)) {
@@ -225,7 +227,7 @@ public class NpcCombat {
}
public static void loadSpell2(int i) {
NpcHandler.npcs[i].attackType = 3;
NpcHandler.npcs[i].attackType = AttackType.FIRE_BREATH.getValue();
int random = Misc.random(3);
if (random == 0) {
NpcHandler.npcs[i].projectileId = 393; // red
@@ -244,63 +246,63 @@ public class NpcCombat {
public static void loadSpell(Player c, int i) {
if (NpcHandler.npcs[i].npcType > 2462 && NpcHandler.npcs[i].npcType < 2469 || NpcHandler.npcs[i].npcType > 3751 && NpcHandler.npcs[i].npcType < 3762) {
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
}
if (NpcHandler.npcs[i].npcType > 3761 && NpcHandler.npcs[i].npcType < 3772) {
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
}
switch (NpcHandler.npcs[i].npcType) {
case 1158://kq first form
int kqRandom = Misc.random(3);
if (kqRandom == 2) {
NpcHandler.npcs[i].projectileId = 280; //gfx
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
NpcHandler.npcs[i].endGfx = 279;
} else {
NpcHandler.npcs[i].attackType = 0;
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
}
break;
case 1160://kq secondform
int kqRandom2 = Misc.random(3);
if (kqRandom2 == 2) {
NpcHandler.npcs[i].projectileId = 279; //gfx
NpcHandler.npcs[i].attackType = 1 + Misc.random(1);
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue() + Misc.random(1);
NpcHandler.npcs[i].endGfx = 278;
} else {
NpcHandler.npcs[i].attackType = 0;
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
}
break;
case 2607:
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
case 2591:
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
break;
case 172:
case 174:
NpcHandler.npcs[i].gfx100(96); // Dark Wizards use earth strike
NpcHandler.npcs[i].projectileId = 97;
NpcHandler.npcs[i].endGfx = 98;
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
break;
case 3068:
if(Misc.random(10) > 7) {
NpcHandler.npcs[i].projectileId = 393; //red
NpcHandler.npcs[i].endGfx = 430;
NpcHandler.npcs[i].attackType = 3;
NpcHandler.npcs[i].attackType = AttackType.FIRE_BREATH.getValue();
NpcData.startAnimation(2989, i);
} else {
NpcData.startAnimation(2980, i);
NpcHandler.npcs[i].attackType = 0;
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
}
break;
case 2892:
NpcHandler.npcs[i].projectileId = 94;
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
NpcHandler.npcs[i].endGfx = 95;
break;
case 2894:
NpcHandler.npcs[i].projectileId = 298;
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
break;
/*
* Better Dragons
@@ -320,12 +322,12 @@ public class NpcCombat {
case 1:
NpcHandler.npcs[i].projectileId = 393; // red
NpcHandler.npcs[i].endGfx = 430;
NpcHandler.npcs[i].attackType = 3;
NpcHandler.npcs[i].attackType = AttackType.FIRE_BREATH.getValue();
break;
default:
NpcHandler.npcs[i].projectileId = -1; // melee
NpcHandler.npcs[i].endGfx = -1;
NpcHandler.npcs[i].attackType = 0;
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
break;
}
break;
@@ -346,49 +348,49 @@ public class NpcCombat {
case 0:
NpcHandler.npcs[i].projectileId = 393; // red
NpcHandler.npcs[i].endGfx = 430;
NpcHandler.npcs[i].attackType = 3;
NpcHandler.npcs[i].attackType = AttackType.FIRE_BREATH.getValue();
break;
case 1:
NpcHandler.npcs[i].projectileId = 394; // green
NpcHandler.npcs[i].endGfx = 429;
NpcHandler.npcs[i].attackType = 3;
NpcHandler.npcs[i].attackType = AttackType.FIRE_BREATH.getValue();
break;
case 2:
NpcHandler.npcs[i].projectileId = 395; // white
NpcHandler.npcs[i].endGfx = 431;
NpcHandler.npcs[i].attackType = 3;
NpcHandler.npcs[i].attackType = AttackType.FIRE_BREATH.getValue();
break;
case 3:
NpcHandler.npcs[i].projectileId = 396; // blue
NpcHandler.npcs[i].endGfx = 428;
NpcHandler.npcs[i].attackType = 3;
NpcHandler.npcs[i].attackType = AttackType.FIRE_BREATH.getValue();
break;
case 4:
NpcHandler.npcs[i].projectileId = -1; // melee
NpcHandler.npcs[i].endGfx = -1;
NpcHandler.npcs[i].attackType = 0;
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
break;
}
break;
// arma npcs
case 2561:
NpcHandler.npcs[i].attackType = 0;
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
break;
case 2560:
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
NpcHandler.npcs[i].projectileId = 1190;
break;
case 2559:
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
NpcHandler.npcs[i].projectileId = 1203;
break;
case 2558:
random = Misc.random(1);
NpcHandler.npcs[i].attackType = 1 + random;
if (NpcHandler.npcs[i].attackType == 1) {
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue() + random;
if (NpcHandler.npcs[i].attackType == AttackType.RANGE.getValue()) {
NpcHandler.npcs[i].projectileId = 1197;
} else {
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
NpcHandler.npcs[i].projectileId = 1198;
}
break;
@@ -396,48 +398,48 @@ public class NpcCombat {
case 2562: // sara
random = Misc.random(1);
if (random == 0) {
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
NpcHandler.npcs[i].endGfx = 1224;
NpcHandler.npcs[i].projectileId = -1;
} else if (random == 1) {
NpcHandler.npcs[i].attackType = 0;
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
}
break;
case 2563: // star
NpcHandler.npcs[i].attackType = 0;
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
break;
case 2564: // growler
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
NpcHandler.npcs[i].projectileId = 1203;
break;
case 2565: // bree
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
NpcHandler.npcs[i].projectileId = 9;
break;
// bandos npcs
case 2550:
random = Misc.random(2);
if (random == 0 || random == 1) {
NpcHandler.npcs[i].attackType = 0;
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
} else {
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
NpcHandler.npcs[i].endGfx = 1211;
NpcHandler.npcs[i].projectileId = 288;
}
break;
case 2551:
NpcHandler.npcs[i].attackType = 0;
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
break;
case 2552:
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
NpcHandler.npcs[i].projectileId = 1203;
break;
case 2553:
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
NpcHandler.npcs[i].projectileId = 1206;
break;
case 2025:
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
int r = Misc.random(3);
if (r == 0) {
NpcHandler.npcs[i].gfx100(158);
@@ -460,30 +462,30 @@ public class NpcCombat {
}
break;
case 2881:// supreme
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
NpcHandler.npcs[i].projectileId = 298;
break;
case 2882:// prime
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
NpcHandler.npcs[i].projectileId = 162;
NpcHandler.npcs[i].endGfx = 477;
break;
case 2028:
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
NpcHandler.npcs[i].projectileId = 27;
break;
case 3200:
int r2 = Misc.random(1);
if (r2 == 0) {
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
NpcHandler.npcs[i].gfx100(550);
NpcHandler.npcs[i].projectileId = 551;
NpcHandler.npcs[i].endGfx = 552;
} else {
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
NpcHandler.npcs[i].gfx100(553);
NpcHandler.npcs[i].projectileId = 554;
NpcHandler.npcs[i].endGfx = 555;
@@ -503,25 +505,25 @@ public class NpcCombat {
r3 = Misc.random(1);
}
if (r3 == 0) {
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
NpcHandler.npcs[i].endGfx = 157;
NpcHandler.npcs[i].projectileId = 448;
} else if (r3 == 1) {
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
NpcHandler.npcs[i].projectileId = 451;
} else if (r3 == 2) {
NpcHandler.npcs[i].attackType = 0;
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
NpcHandler.npcs[i].projectileId = -1;
}
break;
case 2743:
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
NpcHandler.npcs[i].projectileId = 445;
NpcHandler.npcs[i].endGfx = 446;
break;
case 2631:
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
NpcHandler.npcs[i].projectileId = 443;
break;
}
@@ -550,10 +552,10 @@ public class NpcCombat {
}
if (c.respawnTimer <= 0) {
int damage = 0;
if (NpcHandler.npcs[i].attackType == 0) {
damage = Misc.random(NpcHandler.npcs[i].maxHit);
if (10 + Misc.random(c.getCombatAssistant().calcDef()) > Misc
.random(NpcHandler.npcs[i].attack)) {
if (NpcHandler.npcs[i].attackType == AttackType.MELEE.getValue()) {
damage = Misc.random(NPCDefinition.forId(NpcHandler.npcs[i].npcType).getMaxHit());
if (5 + Misc.random(c.getCombatAssistant().calcDef()) > Misc
.random(NPCDefinition.forId(NpcHandler.npcs[i].npcType).getAttackBonus())) {
damage = 0;
}
if (NpcData.cantKillYou(NpcHandler.npcs[i].npcType)) {
@@ -564,10 +566,10 @@ public class NpcCombat {
if (c.getPrayer().prayerActive[18] && !(NpcHandler.npcs[i].npcType == 2030)) { // protect from melee
damage = 0;
} else if (c.getPrayer().prayerActive[18] && NpcHandler.npcs[i].npcType == 2030) {
if (NpcHandler.npcs[i].attackType == 0) {
damage = Misc.random(NpcHandler.npcs[i].maxHit);
if (NpcHandler.npcs[i].attackType == AttackType.MELEE.getValue()) {
damage = Misc.random(NPCDefinition.forId(NpcHandler.npcs[i].npcType).getMaxHit());
}
if (10 + Misc.random(MeleeData.calculateMeleeDefence(c)) > Misc.random(NpcHandler.npcs[i].attack)) {
if (5 + Misc.random(MeleeData.calculateMeleeDefence(c)) > Misc.random(NPCDefinition.forId(NpcHandler.npcs[i].npcType).getAttackBonus())) {
if (NpcHandler.npcs[i].npcType == 1158 || NpcHandler.npcs[i].npcType == 1160)
damage = (damage / 2);
else
@@ -579,9 +581,9 @@ public class NpcCombat {
}
}
if (NpcHandler.npcs[i].attackType == 1) { // range
damage = Misc.random(NpcHandler.npcs[i].maxHit);
if (10 + Misc.random(c.getCombatAssistant().calculateRangeDefence()) > Misc.random(NpcHandler.npcs[i].attack)) {
if (NpcHandler.npcs[i].attackType == AttackType.RANGE.getValue()) { // range
damage = Misc.random(NPCDefinition.forId(NpcHandler.npcs[i].npcType).getMaxHit());
if (5 + Misc.random(c.getCombatAssistant().calculateRangeDefence()) > Misc.random(NPCDefinition.forId(NpcHandler.npcs[i].npcType).getAttackBonus())) {
if (NpcHandler.npcs[i].npcType == 1158 || NpcHandler.npcs[i].npcType == 1160)
damage = (damage / 2);
else
@@ -600,10 +602,10 @@ public class NpcCombat {
}
}
if (NpcHandler.npcs[i].attackType == 2) { // magic
damage = Misc.random(NpcHandler.npcs[i].maxHit);
if (NpcHandler.npcs[i].attackType == AttackType.MAGIC.getValue()) { // magic
damage = Misc.random(NPCDefinition.forId(NpcHandler.npcs[i].npcType).getMaxHit());
boolean magicFailed = false;
if (10 + Misc.random(c.getCombatAssistant().mageDef()) > Misc.random(NpcHandler.npcs[i].attack)) {
if (5 + Misc.random(c.getCombatAssistant().mageDef()) > Misc.random(NPCDefinition.forId(NpcHandler.npcs[i].npcType).getAttackBonus())) {
damage = 0;
magicFailed = true;
}
@@ -632,7 +634,7 @@ public class NpcCombat {
}
}
if (NpcHandler.npcs[i].attackType == 3) { // fire breath
if (NpcHandler.npcs[i].attackType == AttackType.FIRE_BREATH.getValue()) { // fire breath
int anti = c.getPlayerAssistant().antiFire();
switch (anti) {
case 0:// has no shield
@@ -1,6 +1,7 @@
package com.rs2.game.content.combat.npcs;
import com.rs2.GameEngine;
import com.rs2.game.content.combat.AttackType;
import com.rs2.game.npcs.NpcHandler;
import com.rs2.game.players.Player;
@@ -21,9 +22,9 @@ public enum NpcEmotes {
HOB_GOBLIN(new int[] {122, 123}, 164, 165, 167),
AHRIM(new int[] {2025}, 729, 404, 2304),
DHAROK(new int[] {2026}, 2067, 404, 2304),
GUTHAN(new int[] {2027}, 422, 404, 2304),
GUTHAN(new int[] {2027}, 2080, 404, 2304),
KARIL(new int[] {2028}, 2075, 404, 2304),
TORAG(new int[] {2029}, 0x814, 404, 2304),
TORAG(new int[] {2029}, 2068, 404, 2304),
VERAC(new int[] {2030}, 2062, 404, 2304),
BABY_DRAGON(new int[] {51, 52, 1589, 3376}, 25, 26, 28),
CHICKEN(new int[] {41}, 55, 56, 57),
@@ -39,7 +40,7 @@ public enum NpcEmotes {
COW(new int[] {81, 397, 1766, 1767, 1768}, 59, 60, 62),
BLOODVELD(new int[] {1618, 1619}, 1552, 1550, 1553),
IMP(new int[] {708}, 169, 170, 172),
DARK_WIZARD(new int[] {172, 13}, 711, 1834, 836),
DARK_WIZARD(new int[] {172, 13, 174}, 711, 1834, 836),
DUCK(new int[] {44, 45}, 7, 8, 9),
SPINOLYP(new int[] {2892, 2894}, 2868, 2864, 2865),
DWARF(new int[] {118, 119}, 99, 100, 102),
@@ -137,11 +138,11 @@ public enum NpcEmotes {
} else {
switch (NpcHandler.npcs[i].npcType) {
case 2745:
if (NpcHandler.npcs[i].attackType == 2) {
if (NpcHandler.npcs[i].attackType == AttackType.MAGIC.getValue()) {
return 2656;
} else if (NpcHandler.npcs[i].attackType == 1) {
} else if (NpcHandler.npcs[i].attackType == AttackType.RANGE.getValue()) {
return 2652;
} else if (NpcHandler.npcs[i].attackType == 0) {
} else if (NpcHandler.npcs[i].attackType == AttackType.MELEE.getValue()) {
return 2655;
}
@@ -179,10 +180,10 @@ public enum NpcEmotes {
return 2654;
case 1158:
GameEngine.npcHandler.spawnSecondForm(player, i);
return 6242;
return 1187;
case 1160:
GameEngine.npcHandler.spawnFirstForm(player, i);
return 6233;
return 1182;
}
}
}
@@ -277,7 +277,6 @@ public class Barrows {
c.barrowsNpcs[4][1] = 0;
c.barrowsNpcs[5][1] = 0;
c.barrowsKillCount = 0;
c.getPlayerAssistant().movePlayer(3565, 3288, 0);
}
@@ -72,7 +72,7 @@ public class Dueling {
o.getPacketSender().sendMessage(player.playerName + ":duelreq:");
}
} catch (Exception e) {
Misc.println("Error requesting duel.");
System.out.println("Error requesting duel.");
}
}
@@ -5,7 +5,13 @@ import com.rs2.game.players.Player;
public class BlackKnightsFortress {
public static void showInformation(Player client) {
for (int i = 8144; i < 8195; i++) {
for (int i = 8144; i < 8196; i++) {
client.getPacketSender().sendString("", i);
}
for (int i = 12174; i < (12174 + 50); i++) {
client.getPacketSender().sendString( "", i);
}
for (int i = 14945; i < (14945 + 100); i++) {
client.getPacketSender().sendString("", i);
}
client.getPacketSender().sendString("Black Knights' Fortress", 8144);
@@ -14,7 +14,13 @@ public class CooksAssistant {
private static final int FLOUR = 1933;
public static void showInformation(Player client) {
for (int i = 8144; i < 8195; i++) {
for (int i = 8144; i < 8196; i++) {
client.getPacketSender().sendString("", i);
}
for (int i = 12174; i < (12174 + 50); i++) {
client.getPacketSender().sendString( "", i);
}
for (int i = 14945; i < (14945 + 100); i++) {
client.getPacketSender().sendString("", i);
}
client.getPacketSender().sendString("@dre@Cook's Assistant", 8144);
@@ -10,7 +10,13 @@ import com.rs2.game.players.Player;
public class DoricsQuest {
public static void showInformation(Player client) {
for (int i = 8144; i < 8195; i++) {
for (int i = 8144; i < 8196; i++) {
client.getPacketSender().sendString("", i);
}
for (int i = 12174; i < (12174 + 50); i++) {
client.getPacketSender().sendString( "", i);
}
for (int i = 14945; i < (14945 + 100); i++) {
client.getPacketSender().sendString("", i);
}
client.getPacketSender().sendString("@dre@Dorics Quest", 8144);
@@ -10,7 +10,7 @@ import com.rs2.game.players.Player;
public class GertrudesCat {
public static void showInformation(Player client) {
for (int i = 8144; i < 8195; i++) {
for (int i = 8144; i < 8196; i++) {
client.getPacketSender().sendString("", i);
}
client.getPacketSender().sendString("@dre@Gertrudes Cat", 8144);
@@ -10,7 +10,13 @@ import com.rs2.game.players.Player;
public class LostCity {
public static void showInformation(Player client) {
for (int i = 8144; i < 8195; i++) {
for (int i = 8144; i < 8196; i++) {
client.getPacketSender().sendString("", i);
}
for (int i = 12174; i < (12174 + 50); i++) {
client.getPacketSender().sendString( "", i);
}
for (int i = 14945; i < (14945 + 100); i++) {
client.getPacketSender().sendString("", i);
}
client.getPacketSender().sendString("@dre@Lost City", 8144);
@@ -11,7 +11,13 @@ public class PiratesTreasure {
public static void showInformation(Player client) {
for (int i = 8144; i < 8195; i++) {
for (int i = 8144; i < 8196; i++) {
client.getPacketSender().sendString("", i);
}
for (int i = 12174; i < (12174 + 50); i++) {
client.getPacketSender().sendString( "", i);
}
for (int i = 14945; i < (14945 + 100); i++) {
client.getPacketSender().sendString("", i);
}
client.getPacketSender().sendString("@dre@Pirate's Treasure", 8144);
@@ -11,7 +11,13 @@ public class RestlessGhost {
public static void showInformation(Player client) {
for (int i = 8144; i < 8195; i++) {
for (int i = 8144; i < 8196; i++) {
client.getPacketSender().sendString("", i);
}
for (int i = 12174; i < (12174 + 50); i++) {
client.getPacketSender().sendString( "", i);
}
for (int i = 14945; i < (14945 + 100); i++) {
client.getPacketSender().sendString("", i);
}
client.getPacketSender().sendString("@dre@Restless Ghost", 8144);
@@ -10,7 +10,13 @@ import com.rs2.game.players.Player;
public class RomeoJuliet {
public static void showInformation(Player client) {
for (int i = 8144; i < 8195; i++) {
for (int i = 8144; i < 8196; i++) {
client.getPacketSender().sendString("", i);
}
for (int i = 12174; i < (12174 + 50); i++) {
client.getPacketSender().sendString( "", i);
}
for (int i = 14945; i < (14945 + 100); i++) {
client.getPacketSender().sendString("", i);
}
client.getPacketSender().sendString("@dre@Romeo & Juliet", 8144);
@@ -10,7 +10,13 @@ import com.rs2.game.players.Player;
public class RuneMysteries {
public static void showInformation(Player client) {
for (int i = 8144; i < 8195; i++) {
for (int i = 8144; i < 8196; i++) {
client.getPacketSender().sendString("", i);
}
for (int i = 12174; i < (12174 + 50); i++) {
client.getPacketSender().sendString( "", i);
}
for (int i = 14945; i < (14945 + 100); i++) {
client.getPacketSender().sendString("", i);
}
client.getPacketSender().sendString("@dre@Rune Mysteries", 8144);
@@ -10,7 +10,13 @@ import com.rs2.game.players.Player;
public class SheepShearer {
public static void showInformation(Player client) {
for (int i = 8144; i < 8195; i++) {
for (int i = 8144; i < 8196; i++) {
client.getPacketSender().sendString("", i);
}
for (int i = 12174; i < (12174 + 50); i++) {
client.getPacketSender().sendString( "", i);
}
for (int i = 14945; i < (14945 + 100); i++) {
client.getPacketSender().sendString("", i);
}
client.getPacketSender().sendString("@dre@Sheep Shearer", 8144);
@@ -20,7 +20,13 @@ public class ShieldArrav {
public static void showInformation(Player player) {
// Clear all lines
for (int i = 8144; i < 8195; i++) player.getPacketSender().sendString("", i);
for (int i = 8144; i < 8196; i++) player.getPacketSender().sendString("", i);
for (int i = 12174; i < (12174 + 50); i++) {
player.getPacketSender().sendString( "", i);
}
for (int i = 14945; i < (14945 + 100); i++) {
player.getPacketSender().sendString("", i);
}
// Set the title
player.getPacketSender().sendString("Shield of Arrav", 8144);
// Add content
@@ -14,7 +14,13 @@ public class VampyreSlayer {
public static void showInformation(Player client) {
// Clear all lines
for (int i = 8144; i < 8195; i++) client.getPacketSender().sendString("", i);
for (int i = 8144; i < 8196; i++) client.getPacketSender().sendString("", i);
for (int i = 12174; i < (12174 + 50); i++) {
client.getPacketSender().sendString( "", i);
}
for (int i = 14945; i < (14945 + 100); i++) {
client.getPacketSender().sendString("", i);
}
// Set the title
client.getPacketSender().sendString("Vampyre Slayer", 8144);
// Add content
@@ -10,7 +10,13 @@ import com.rs2.game.players.Player;
public class WitchsPotion {
public static void showInformation(Player client) {
for (int i = 8144; i < 8195; i++) {
for (int i = 8144; i < 8196; i++) {
client.getPacketSender().sendString("", i);
}
for (int i = 12174; i < (12174 + 50); i++) {
client.getPacketSender().sendString( "", i);
}
for (int i = 14945; i < (14945 + 100); i++) {
client.getPacketSender().sendString("", i);
}
client.getPacketSender().sendString("@dre@Witch's Potion", 8144);
@@ -50,10 +50,14 @@ public class AgilityShortcut {
}
break;
case 9326:
if (player.absX == 2773) {
handleAgility(player, 2, 0, 81, 3067, WALK, "You jump over the strange floor.");
if (player.absX == 2770) {
handleAgility(player, 2768, 10002, 81, 3067, MOVE, "You jump over the strange floor.");
} else if (player.absX == 2768) {
handleAgility(player, 2770, 10002, 81, 3067, MOVE, "You jump over the strange floor.");
} else if (player.absX == 2773) {
handleAgility(player, 2775, 10003, 81, 3067, MOVE, "You jump over the strange floor.");
} else if (player.absX == 2775) {
handleAgility(player, -2, 0, 81, 3067, WALK, "You jump over the strange floor.");
handleAgility(player, 2773, 10003, 81, 3067, MOVE, "You jump over the strange floor.");
}
break;
case 9321:
@@ -436,8 +436,8 @@ public class Slayer {
return;
}
if (c.slayerPoints < 30) {
c.getPacketSender().sendMessage("This requires atleast 30 slayer points, which you don't have.");
c.getDialogueHandler().sendNpcChat1("This requires atleast 30 slayer points, which you don't have.", c.npcType, NpcHandler.getNpcListName(c.talkingNpc));
c.getPacketSender().sendMessage("You need 30 slayer points to cancel a task.");
c.getDialogueHandler().sendNpcChat1("You need 30 slayer points to cancel a task.", c.npcType, NpcHandler.getNpcListName(c.talkingNpc));
c.nextChat = 0;
return;
}
@@ -454,8 +454,8 @@ public class Slayer {
return;
}
if (c.slayerPoints < 100) {
c.getPacketSender().sendMessage("This requires atleast 100 slayer points, which you don't have.");
c.getDialogueHandler().sendNpcChat1("This requires atleast 100 slayer points, which you don't have.", c.npcType, NpcHandler.getNpcListName(c.talkingNpc));
c.getPacketSender().sendMessage("You need 100 slayer points to remove a task.");
c.getDialogueHandler().sendNpcChat1("You need 100 slayer points to remove a task.", c.npcType, NpcHandler.getNpcListName(c.talkingNpc));
c.nextChat = 0;
return;
}
@@ -130,7 +130,13 @@ public class DesertHeat {
}
public static void showWarning(Player player) {
for (int i = 8144; i < 8195; i++) {
for (int i = 8144; i < 8196; i++) {
player.getPacketSender().sendString("", i);
}
for (int i = 12174; i < (12174 + 50); i++) {
player.getPacketSender().sendString( "", i);
}
for (int i = 14945; i < (14945 + 100); i++) {
player.getPacketSender().sendString("", i);
}
player.getPacketSender().sendString("@dre@DESERT WARNING", 8144);
@@ -3926,7 +3926,11 @@ public class DialogueHandler {
player.dialogueAction = 70;
break;
case 1009:
if (player.talkingNpc > 0) {
sendPlayerChat("Yes.");
} else {
player.getPacketSender().closeAllWindows();
}
player.getPlayerAssistant().movePlayer(1761, 5192, 0);
player.nextChat = 0;
break;
@@ -4024,6 +4028,11 @@ public class DialogueHandler {
case 1027:
player.getDialogueHandler().sendStatement("10 coins are removed from your inventory.");
//Fix Al-Kharid gate talking option by setting an object ID required by initKharid
player.objectId = 2882;
if (player.getY() == 3228) {
player.objectId = 2883;
}
OtherObjects.initKharid(player, player.objectId);
player.nextChat = 0;
break;
@@ -487,7 +487,7 @@ public class ItemAssistant {
if (item <= 0) {
return false;
}
if ((freeSlots() >= 1 || playerHasItem(item, 1))
if ((freeSlots() >= 1 || playerHasItem(item))
&& ItemDefinition.lookup(item).isStackable() || freeSlots() > 0
&& !ItemDefinition.lookup(item).isStackable()) {
for (int i = 0; i < player.playerItems.length; i++) {
@@ -56,7 +56,7 @@ public class ItemDefinitions {
defintions.put(item.id, new Definition(item));
}
} catch (FileNotFoundException fileex) {
Misc.println("items.json: file not found.");
System.out.println("items.json: file not found.");
}
}
@@ -112,7 +112,7 @@ public class UseItem {
default:
if (c.playerRights == 3) {
Misc.println("Player At Object id: " + objectID + " objectX: "
System.out.println("Player At Object id: " + objectID + " objectX: "
+ objectX + " objectY: " + objectY + " with Item id: "
+ itemId);
}
@@ -387,7 +387,7 @@ public class UseItem {
}
if (player.playerRights == 3) {
Misc.println("Player used Item id: " + itemUsed + " with Item id: " + useWith);
System.out.println("Player used Item id: " + itemUsed + " with Item id: " + useWith);
}
}
@@ -396,7 +396,7 @@ public class UseItem {
default:
if (c.playerRights == 3) {
Misc.println("Player used Item id: " + itemId
System.out.println("Player used Item id: " + itemId
+ " with Npc id: " + npcId + " With Slot : " + slot);
}
break;
@@ -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;
@@ -280,22 +281,25 @@ public class NpcData {
}
}
/**
* 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.");
}
}
@@ -110,6 +110,11 @@ public class ObjectsActions {
Stalls.attemptStall(player, objectType, objectX, objectY);
return;
}
//Prevent players getting stuck in level 28 wildy
if (objectType == 1752 && objectX == 3154 && objectY == 3743) {
player.getPacketSender().sendMessage("You find that ladder leads nowhere...");
return;
}
switch (objectType) {
case 6969: // Swamp Boaty
if (player.objectX == 3523 && player.objectY == 3284)
@@ -606,7 +606,7 @@ public abstract class Player {
System.out.println("EverythingRS API Disabled, highscores not saved!");
}
Misc.println("[DEREGISTERED]: " + playerName + "");
System.out.println("[DEREGISTERED]: " + playerName + "");
// HostList.getHostList().remove(session);
CycleEventHandler.getSingleton().stopEvents(this);
disconnected = true;
@@ -1342,7 +1342,7 @@ public abstract class Player {
public int miningAxe = -1, woodcuttingAxe = -1;
public boolean initialized, musicOn = true, luthas,
public boolean initialized, musicOn = true, soundOn = true, luthas,
playerIsCooking, disconnected, ruleAgreeButton,
rebuildNPCList, isActive, isKicked,
isSkulled, friendUpdate, newPlayer,
@@ -45,7 +45,7 @@ public class PlayerHandler {
players[slot].isActive = true;
players[slot].connectedFrom = client1.isBot ? "127.0.0.1" : ((InetSocketAddress) client1.getSession().getRemoteAddress()).getAddress().getHostAddress();
if (Constants.SERVER_DEBUG) {
Misc.println("Player Slot " + slot + " slot 0 " + players[0]
System.out.println("Player Slot " + slot + " slot 0 " + players[0]
+ " Player Hit " + players[slot]);
}
return true;
@@ -44,14 +44,14 @@ public class PlayerSave {
//it's the .gitignore :P
return 0;
}
Misc.println(playerName + ": character file not found.");
System.out.println(playerName + ": character file not found.");
player.newPlayer = false;
return 0;
}
try {
line = characterfile.readLine();
} catch (IOException ioexception) {
Misc.println(playerName + ": error loading file.");
System.out.println(playerName + ": error loading file.");
return 3;
}
while (EndOfFile == false && line != null) {
@@ -209,6 +209,9 @@ public class PlayerSave {
case "musicOn":
player.musicOn = Boolean.parseBoolean(token2);
break;
case "soundOn":
player.soundOn = Boolean.parseBoolean(token2);
break;
case "barrowsNpcs":
player.barrowsNpcs[Integer.parseInt(token3[0])][1] = Integer.parseInt(token3[1]);
break;
@@ -728,6 +731,8 @@ public class PlayerSave {
characterfile.newLine();
characterfile.write("musicOn = " + player.musicOn);
characterfile.newLine();
characterfile.write("soundOn = " + player.soundOn);
characterfile.newLine();
characterfile.write("needsNewTask = " + player.needsNewTask);
characterfile.newLine();
characterfile.write("luthas = " + player.luthas);
@@ -905,7 +910,7 @@ public class PlayerSave {
characterfile.newLine();
characterfile.close();
} catch (IOException ioexception) {
Misc.println(player.playerName + ": error writing file.");
System.out.println(player.playerName + ": error writing file.");
return false;
}
return true;
@@ -70,7 +70,7 @@ public class Trading {
player.getPacketSender().sendMessage("Other player is busy at the moment.");
}
} catch (Exception e) {
Misc.println("Error requesting trade.");
System.out.println("Error requesting trade.");
}
}
public boolean isCloseTo(Client tradedPlayer) {
@@ -142,7 +142,7 @@ public class ShopHandler {
totalshops++;
}
} catch (FileNotFoundException fileex) {
Misc.println("shops.json: file not found.");
System.out.println("shops.json: file not found.");
}
}
@@ -157,13 +157,13 @@ public class ShopHandler {
try {
characterfile = new BufferedReader(new FileReader("./data/cfg/" + 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.");
}
while (EndOfFile == false && line != null) {
line = line.trim();
@@ -191,7 +191,7 @@ public class PacketSender {
player.getItemAssistant().addSpecialBar(player.playerEquipment[player.playerWeapon]);
player.saveTimer = Constants.SAVE_TIMER;
player.saveCharacter = true;
Misc.println((player.isBot ? "[BOT-REGISTERED]" : "[REGISTERED]") + ": " + player.playerName + " (level-" + player.calculateCombatLevel() + ")");
System.out.println((player.isBot ? "[BOT-REGISTERED]" : "[REGISTERED]") + ": " + player.playerName + " (level-" + player.calculateCombatLevel() + ")");
player.handler.updatePlayer(player, player.outStream);
player.handler.updateNPC(player, player.outStream);
player.flushOutStream();
@@ -1165,6 +1165,9 @@ public class PacketSender {
*/
public PacketSender sendSound(int id, int volume, int delay) {
if (player != null && !player.soundOn) {
return this;
}
frame174(id, volume, delay);
return this;
}
@@ -1,6 +1,7 @@
package com.rs2.net.packets;
import com.rs2.Constants;
import com.rs2.event.impl.ObjectFifthClickEvent;
import com.rs2.game.dialogues.Dialogue;
import com.rs2.game.players.Player;
import com.rs2.net.Packet;
@@ -135,6 +136,7 @@ public class PacketHandler {
packetId[121] = cr;
packetId[210] = cr;
packetId[253] = new ItemClick2OnGroundItem();
packetId[228] = new ClickObject();
// packetId[ContinueDialoguePacketHandler.CONTINUE] = new
// ContinueDialoguePacketHandler();
}
@@ -23,7 +23,7 @@ import com.rs2.world.clip.Region;
public class ClickObject implements PacketType {
public static final int FIRST_CLICK = 132, SECOND_CLICK = 252,
THIRD_CLICK = 70, FOURTH_CLICK = 234;
THIRD_CLICK = 70, FOURTH_CLICK = 234, FIFTH_CLICK = 228;
public void onObjectReached(Player player, Consumer<Player> consumer) {
if (System.currentTimeMillis() - player.clickDelay < 300)
@@ -115,6 +115,12 @@ public class ClickObject implements PacketType {
player.objectY = packet.readUnsignedWordBigEndianA();
onObjectReached(player, (p) -> completeObjectClick(p, 4));
break;
case FIFTH_CLICK:
player.objectId = packet.readUnsignedWordA();
player.objectY = packet.readUnsignedWordA();
player.objectX = packet.readUnsignedWord();
onObjectReached(player, (p) -> completeObjectClick(p, 5));
break;
}
}
@@ -220,6 +226,12 @@ public class ClickObject implements PacketType {
player.fade(2442, 10147, 0);
break;
case 12230: // Mole lair rope
if (player.objectX == 1752 && player.objectY == 5136) {
player.getPlayerAssistant().movePlayer(2997, 3375, 0);
}
break;
case 1568:
if (player.objectX == 2399 && player.objectY == 3099) {
player.getPacketSender()
@@ -32,7 +32,7 @@ public class ClickingStuff implements PacketType {
player.tradeConfirmed2 = false;
player.getPacketSender().sendMessage("@red@Trade has been declined.");
opponent.getPacketSender().sendMessage("@red@Other player has declined the trade.");
Misc.println("trade reset");
System.out.println("trade reset");
player.getTrading().declineTrade();
opponent.getTrading().declineTrade();
}
@@ -65,6 +65,10 @@ public class Commands implements PacketType {
}
case "xprate":
if(Constants.VARIABLE_XP_RATE) {
if (arguments.length < 1 || !arguments[0].equals("confirm")) {
player.getPacketSender().sendMessage("You must type \"::xprate confirm\" to view the dialogue to change your XP rate.");
return;
}
if (player.getXPRate() == Constants.VARIABLE_XP_RATES[0]) {
player.getDialogueHandler().sendDialogues(10005, 2244);
return;
@@ -190,7 +194,7 @@ public class Commands implements PacketType {
if (count != 1) {
player.getPacketSender().sendMessage("There are currently " + count + " " + (playerCommand.equalsIgnoreCase("players") ? "players" : "player shops") + " online (" + PlayerHandler.getNonPlayerCount() + " staff member online).");
} else {
player.getPacketSender().sendMessage("There is currently " + count + " " + (playerCommand.equalsIgnoreCase("players") ? "player" : "player shop") + " online (\" + PlayerHandler.getNonPlayerCount() + \" staff member online).");
player.getPacketSender().sendMessage("There is currently " + count + " " + (playerCommand.equalsIgnoreCase("players") ? "player" : "player shop") + " online (" + PlayerHandler.getNonPlayerCount() + " staff member online).");
}
String[] players = new String[count];
@@ -205,7 +209,13 @@ public class Commands implements PacketType {
// Clear all lines
for (int i = 8144; i < 8195; i++) player.getPacketSender().sendString("", i);
for (int i = 8144; i < 8196; i++) player.getPacketSender().sendString("", i);
for (int i = 12174; i < (12174 + 50); i++) {
player.getPacketSender().sendString( "", i);
}
for (int i = 14945; i < (14945 + 100); i++) {
player.getPacketSender().sendString("", i);
}
player.getPacketSender().sendString("@dre@" + (playerCommand.equalsIgnoreCase("players") ? "Players" : "Player Shops"), 8144);
@@ -322,9 +332,14 @@ public class Commands implements PacketType {
};
// Clear all lines
for (int i = 8144; i < 8195; i++)
for (int i = 8144; i < 8196; i++)
player.getPacketSender().sendString("", i);
for (int i = 12174; i < (12174 + 50); i++) {
player.getPacketSender().sendString( "", i);
}
for (int i = 14945; i < (14945 + 100); i++) {
player.getPacketSender().sendString("", i);
}
player.getPacketSender().sendString("@dre@Commands", 8144);
int commandsLineNumber = 8147;
@@ -396,7 +411,13 @@ public class Commands implements PacketType {
};
// Clear all lines
for (int i = 8144; i < 8195; i++) player.getPacketSender().sendString("", i);
for (int i = 8144; i < 8196; i++) player.getPacketSender().sendString("", i);
for (int i = 12174; i < (12174 + 50); i++) {
player.getPacketSender().sendString( "", i);
}
for (int i = 14945; i < (14945 + 100); i++) {
player.getPacketSender().sendString("", i);
}
player.getPacketSender().sendString("@dre@Highscores", 8144);
@@ -101,7 +101,7 @@ public class ItemClick3 implements PacketType {
default:
if (player.playerRights == 3) {
Misc.println(player.playerName + " - Item3rdOption: " + itemId
System.out.println(player.playerName + " - Item3rdOption: " + itemId
+ " : " + itemId11 + " : " + itemId1);
}
break;
@@ -36,7 +36,7 @@ public class ItemOnGroundItem implements PacketType {
default:
if (player.playerRights == 3) {
Misc.println("ItemUsed " + itemUsed + " on Ground Item "
System.out.println("ItemUsed " + itemUsed + " on Ground Item "
+ groundItem);
}
break;
@@ -24,6 +24,10 @@ public class RemoveItem implements PacketType {
return;
}
if (interfaceId == 1688 && removeSlot == 3) {
player.getPlayerAssistant().resetAutocast();
}
player.endCurrentTask();
Weight.updateWeight(player);
@@ -90,22 +90,6 @@ public class Misc {
return str;
}
public static void print_debug(String str) {
System.out.print(str);
}
public static void println_debug(String str) {
System.out.println(str);
}
public static void print(String str) {
System.out.print(str);
}
public static void println(String str) {
System.out.println(str);
}
public static String Hex(byte data[]) {
return Hex(data, 0, data.length);
}
@@ -65,7 +65,7 @@ public class GlobalDropsHandler {
} catch (Exception e) {
e.printStackTrace();
}
Misc.println("Loaded " + globalDrops.size() + " global drops.");
System.out.println("Loaded " + globalDrops.size() + " global drops.");
for (Player player : PlayerHandler.players) {
Client player2 = (Client) player;
@@ -56,7 +56,7 @@ public final class ApolloHandler extends ChannelInboundHandlerAdapter {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable e) {
if (!e.getMessage().contains("An existing connection was forcibly closed by the remote host")) {
if (!e.getMessage().contains("An existing connection was forcibly closed by the remote host") && !e.getMessage().contains("Connection reset by peer")) {
logger.log(Level.WARNING, "Exception occured for channel: " + ctx.channel() + ", closing...", e);
}
ctx.channel().close();