Refactoring follow player/NPC variables and NPC magic numbers (#659)

* Refactoring follow player/NPC variables

* Magic number refactoring

* Added more NPC refactoring

* More NPC refactoring

* More refactoring and removed GWD NPCs

GWD was added in 2007, not 2006, so there's absolutely no reason why this code should exist in the server.

* Removed more GWD NPCs

* Refactored remaining NPC IDs
This commit is contained in:
ipkpjersi
2024-12-06 10:43:34 -05:00
committed by GitHub
parent 20ccc2399a
commit d2fe8b0769
14 changed files with 305 additions and 428 deletions
@@ -30,6 +30,8 @@ import com.rs2.util.Misc;
import com.rs2.world.Boundary;
import com.rs2.world.clip.PathFinder;
import static com.rs2.game.content.StaticNpcList.*;
/**
* @author whoever contributed
* @author Andrew (Mr Extremez)
@@ -89,7 +91,7 @@ public class CombatAssistant {
NpcHandler.npcs[i].gfx0(758);
}
if (Misc.random(NpcHandler.npcs[i].defence) > Misc.random(10 + calculateRangeAttack()) && !ignoreDef
|| (NpcHandler.npcs[i].npcType == 2881 || NpcHandler.npcs[i].npcType == 2883 && !ignoreDef)) {
|| (NpcHandler.npcs[i].npcType == DAGANNOTH_SUPREME || NpcHandler.npcs[i].npcType == DAGANNOTH_REX && !ignoreDef)) {
damage = 0;
}
if (Misc.random(4) == 1 && player.lastArrowUsed == 9242 && damage > 0) {
@@ -182,7 +184,7 @@ public class CombatAssistant {
if (Misc.random(NpcHandler.npcs[i].defence) > 10 + Misc.random(mageAtk()) + bonusAttack) {
damage = 0;
magicFailed = true;
} else if (NpcHandler.npcs[i].npcType == 2881 || NpcHandler.npcs[i].npcType == 2882) {
} else if (NpcHandler.npcs[i].npcType == DAGANNOTH_SUPREME || NpcHandler.npcs[i].npcType == DAGANNOTH_PRIME) {
damage = 0;
magicFailed = true;
}
@@ -278,7 +280,7 @@ public class CombatAssistant {
if (!fullVeracsEffect) {
if (Misc.random(NpcHandler.npcs[i].defence) > 10 + Misc.random(calcAtt())) {
damage = 0;
} else if (NpcHandler.npcs[i].npcType == 2882 || NpcHandler.npcs[i].npcType == 2883) {
} else if (NpcHandler.npcs[i].npcType == DAGANNOTH_PRIME || NpcHandler.npcs[i].npcType == DAGANNOTH_REX) {
damage = 0;
}
}
@@ -296,7 +298,7 @@ public class CombatAssistant {
guthansEffect = true;
}
}
if (player.fightMode == 3 && NpcHandler.npcs[i].npcType != 2459 && NpcHandler.npcs[i].npcType != 2460 && NpcHandler.npcs[i].npcType != 2461 && NpcHandler.npcs[i].npcType != 2462) {
if (player.fightMode == 3 && NpcHandler.npcs[i].npcType != PHEASANT && NpcHandler.npcs[i].npcType != PHEASANT_2460 && NpcHandler.npcs[i].npcType != PHEASANT_2461 && NpcHandler.npcs[i].npcType != PHEASANT_2462) {
player.getPlayerAssistant().addSkillXP(damage * CombatConstants.MELEE_EXP_RATE / 3, 0);
player.getPlayerAssistant().addSkillXP(damage * CombatConstants.MELEE_EXP_RATE / 3, 1);
player.getPlayerAssistant().addSkillXP(damage * CombatConstants.MELEE_EXP_RATE / 3, 2);
@@ -306,7 +308,7 @@ public class CombatAssistant {
player.getPlayerAssistant().refreshSkill(Constants.STRENGTH);
player.getPlayerAssistant().refreshSkill(Constants.HITPOINTS);
} else {
if (NpcHandler.npcs[i].npcType != 2459 && NpcHandler.npcs[i].npcType != 2460 && NpcHandler.npcs[i].npcType != 2461 && NpcHandler.npcs[i].npcType != 2462) {
if (NpcHandler.npcs[i].npcType != PHEASANT && NpcHandler.npcs[i].npcType != PHEASANT_2460 && NpcHandler.npcs[i].npcType != PHEASANT_2461 && NpcHandler.npcs[i].npcType != PHEASANT_2462) {
player.getPlayerAssistant().addSkillXP(damage * CombatConstants.MELEE_EXP_RATE, player.fightMode);
player.getPlayerAssistant().addSkillXP(damage * CombatConstants.MELEE_EXP_RATE / 3, 3);
player.getPlayerAssistant().refreshSkill(player.fightMode);
@@ -385,7 +387,7 @@ public class CombatAssistant {
if (i > 0 && NpcHandler.npcs[i] != null) {
if (NpcHandler.npcs[i].isDead) {
player.npcIndex = 0;
player.followId2 = 0;
player.followNpcId = 0;
player.faceNpc(0);
return;
}
@@ -411,7 +413,7 @@ public class CombatAssistant {
return;
} else {
if (player.usingMagic || player.usingBow || player.usingRangeWeapon) {
player.followId2 = 0;
player.followNpcId = 0;
}
player.stopMovement();
}
@@ -423,7 +425,7 @@ public class CombatAssistant {
if (i > 0 && PlayerHandler.players[i] != null) {
if (PlayerHandler.players[i].isDead) {
player.playerIndex = 0;
player.followId = 0;
player.followPlayerId = 0;
player.faceNpc(0);
return;
}
@@ -447,7 +449,7 @@ public class CombatAssistant {
return;
} else {
if (player.usingMagic || player.usingBow || player.usingRangeWeapon) {
player.followId = 0;
player.followPlayerId = 0;
}
player.stopMovement();
}
@@ -479,7 +481,7 @@ public class CombatAssistant {
if (!SlayerRequirements.itemNeededSlayer(player, i) || !player.getSlayer().canAttackNpc(i)) {
return;
}
if (NpcHandler.npcs[i].npcType == 757 && player.vampSlayer > 2) {
if (NpcHandler.npcs[i].npcType == COUNT_DRAYNOR && player.vampSlayer > 2) {
if (!player.getItemAssistant().playerHasItem(1549, 1) || !player.getItemAssistant().playerHasItem(2347, 1)) {
player.getPacketSender().sendMessage("You need a stake and hammer to attack count draynor.");
resetPlayerAttack();
@@ -491,12 +493,12 @@ public class CombatAssistant {
resetPlayerAttack();
return;
}
if (NpcHandler.npcs[i].npcType == 1676) {
if (NpcHandler.npcs[i].npcType == EXPERIMENT) {
player.getPacketSender().sendMessage("You don't have the heart to kill the poor creature again.");
resetPlayerAttack();
return;
}
if (NpcHandler.npcs[i].npcType == 411) {
if (NpcHandler.npcs[i].npcType == SWARM) {
player.getPacketSender().sendMessage("You can't attack a swarm!");
resetPlayerAttack();
return;
@@ -517,8 +519,8 @@ public class CombatAssistant {
return;
}
player.followId2 = i;
player.followId = 0;
player.followNpcId = i;
player.followPlayerId = 0;
if (player.attackTimer <= 0) {
player.usingBow = false;
player.usingRangeWeapon = false;
@@ -573,7 +575,7 @@ public class CombatAssistant {
return;
} else {
if (player.usingMagic || player.usingBow || player.usingRangeWeapon) {
player.followId2 = 0;
player.followNpcId = 0;
}
player.stopMovement();
}
@@ -803,7 +805,7 @@ public class CombatAssistant {
resetPlayerAttack();
return;
}
player.followId = i;
player.followPlayerId = i;
player.attackTimer = 0;
return;
}
@@ -876,7 +878,7 @@ public class CombatAssistant {
return;
} else {
if (player.usingMagic || player.usingBow || player.usingRangeWeapon) {
player.followId = 0;
player.followPlayerId = 0;
}
}
@@ -950,7 +952,7 @@ public class CombatAssistant {
if (checkSpecAmount(equippedWeapon)) {
player.lastArrowUsed = player.playerEquipment[player.playerArrows];
player.getSpecials().activateSpecial(player.playerEquipment[player.playerWeapon], o, i);
player.followId = player.playerIndex;
player.followPlayerId = player.playerIndex;
return;
} else {
player.getPacketSender().sendMessage("You don't have the required special energy to use this attack.");
@@ -985,7 +987,7 @@ public class CombatAssistant {
player.lastArrowUsed = 0;
player.rangeItemUsed = 0;
if (!player.usingBow && !player.usingMagic && !player.usingRangeWeapon) { // melee hit delay
player.followId = PlayerHandler.players[player.playerIndex].playerId;
player.followPlayerId = PlayerHandler.players[player.playerIndex].playerId;
player.hitDelay = getHitDelay();
player.delayedDamage = Misc.random(meleeMaxHit());
player.projectileStage = 0;
@@ -1006,7 +1008,7 @@ public class CombatAssistant {
player.usingBow = true;
}
player.usingBow = true;
player.followId = PlayerHandler.players[player.playerIndex].playerId;
player.followPlayerId = PlayerHandler.players[player.playerIndex].playerId;
player.lastWeaponUsed = player.playerEquipment[player.playerWeapon];
player.lastArrowUsed = player.playerEquipment[player.playerArrows];
player.gfx100(RangeData.getRangeStartGFX(player));
@@ -1019,7 +1021,7 @@ public class CombatAssistant {
player.rangeItemUsed = player.playerEquipment[player.playerWeapon];
player.getItemAssistant().deleteEquipment();
player.usingRangeWeapon = true;
player.followId = PlayerHandler.players[player.playerIndex].playerId;
player.followPlayerId = PlayerHandler.players[player.playerIndex].playerId;
player.gfx100(RangeData.getRangeStartGFX(player));
if (player.fightMode == 2) {
player.attackTimer--;
@@ -1694,7 +1696,7 @@ public class CombatAssistant {
}
public int getRequiredDistance() {
if (player.followId > 0 && player.freezeTimer <= 0) {
if (player.followPlayerId > 0 && player.freezeTimer <= 0) {
return player.isMoving ? 3 : 2;
}
return 1;
@@ -1743,12 +1745,12 @@ public class CombatAssistant {
public int getBonusAttack(int i) {
switch (NpcHandler.npcs[i].npcType) {
case 2883:
case DAGANNOTH_REX:
return Misc.random(50) + 30;
case 2026:
case 2027:
case 2029:
case 2030:
case DHAROK_THE_WRETCHED:
case GUTHAN_THE_INFESTED:
case TORAG_THE_CORRUPTED:
case VERAC_THE_DEFILED:
return Misc.random(50) + 30;
}
return 0;
@@ -18,6 +18,8 @@ import com.rs2.game.players.PlayerHandler;
import com.rs2.util.Misc;
import com.rs2.world.Boundary;
import static com.rs2.game.content.StaticNpcList.*;
public class NpcCombat {
public static void multiAttackDamage(int i) {
@@ -108,28 +110,28 @@ public class NpcCombat {
|| NpcHandler.npcs[i].isDead) {
return;
}
if (NpcHandler.npcs[i].npcType == 1532
|| NpcHandler.npcs[i].npcType == 1534
|| NpcHandler.npcs[i].npcType == 6145
if (NpcHandler.npcs[i].npcType == BARRICADE
|| NpcHandler.npcs[i].npcType == BARRICADE_1534
|| NpcHandler.npcs[i].npcType == 6145 //Unknown NPCs in 6000 range
|| NpcHandler.npcs[i].npcType == 6144
|| NpcHandler.npcs[i].npcType == 6143
|| NpcHandler.npcs[i].npcType == 6142
|| NpcHandler.npcs[i].npcType == 752) {
|| NpcHandler.npcs[i].npcType == LESSER_DEMON_752) {
return;
}
if (Boundary.isIn(c, Boundary.APE_ATOLL) && MonkeyData.isWearingGreegree(c)) {
return;
}
if (NpcHandler.npcs[i].npcType == 1401 && Boundary.isIn(c, Boundary.TUTORIAL) || c.tutorialProgress < 36) {
if (NpcHandler.npcs[i].npcType == CHICKEN_1401 && Boundary.isIn(c, Boundary.TUTORIAL) || c.tutorialProgress < 36) {
return;
}
if (NpcHandler.npcs[i].npcType == 9 && c.absX == 3180 && c.absY > 3433 && c.absY < 3447) {
if (NpcHandler.npcs[i].npcType == GUARD && c.absX == 3180 && c.absY > 3433 && c.absY < 3447) {
return;
}
if (NpcHandler.npcs[i].npcType == 374 && c.absY == 3372 && c.absX > 2522 && c.absX < 2532) {
if (NpcHandler.npcs[i].npcType == OGRE_374 && c.absY == 3372 && c.absX > 2522 && c.absX < 2532) {
return;
}
if (NpcHandler.npcs[i].npcType > 2462 && NpcHandler.npcs[i].npcType < 2468) {
if (NpcHandler.npcs[i].npcType > PHEASANT_2462 && NpcHandler.npcs[i].npcType < FROG_2469) {
if (Misc.random(5) == 0) {
NpcHandler.npcs[i].forceChat("Flee from me, " + c.playerName + "!");
} else if (Misc.random(5) == 1) {
@@ -203,7 +205,7 @@ public class NpcCombat {
c.getPlayerAssistant().createPlayersProjectile(nX, nY, offX, offY, 50, NpcHandler.getProjectileSpeed(i), NpcHandler.npcs[i].projectileId, 43, 31, -c.getId() - 1, 65);
}
int random = Misc.random(10);
if (NpcHandler.npcs[i].npcType == 222 && (NpcHandler.npcs[i].killerId > 0 && NpcHandler.npcs[i].underAttack) && !NpcHandler.npcs[i].isDead && (NpcHandler.npcs[i].HP < NpcHandler.npcs[i].MaxHP + 1)) {
if (NpcHandler.npcs[i].npcType == MONK && (NpcHandler.npcs[i].killerId > 0 && NpcHandler.npcs[i].underAttack) && !NpcHandler.npcs[i].isDead && (NpcHandler.npcs[i].HP < NpcHandler.npcs[i].MaxHP + 1)) {
if (random < 3) {
NpcHandler.npcs[i].HP += 2;
//NpcHandler.npcs[i].startAnimation(84);
@@ -245,14 +247,14 @@ 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) {
if (NpcHandler.npcs[i].npcType > PHEASANT_2462 && NpcHandler.npcs[i].npcType < FROG_2469 || NpcHandler.npcs[i].npcType > SPINNER_3751 && NpcHandler.npcs[i].npcType < DEFILER) {
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
}
if (NpcHandler.npcs[i].npcType > 3761 && NpcHandler.npcs[i].npcType < 3772) {
if (NpcHandler.npcs[i].npcType > TORCHER_3761 && NpcHandler.npcs[i].npcType < BRAWLER) {
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
}
switch (NpcHandler.npcs[i].npcType) {
case 1158://kq first form
case KALPHITE_QUEEN://kq first form
int kqRandom = Misc.random(3);
if (kqRandom == 2) {
NpcHandler.npcs[i].projectileId = 280; //gfx
@@ -262,7 +264,7 @@ public class NpcCombat {
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
}
break;
case 1160://kq secondform
case KALPHITE_QUEEN_1160://kq secondform
int kqRandom2 = Misc.random(3);
if (kqRandom2 == 2) {
NpcHandler.npcs[i].projectileId = 279; //gfx
@@ -272,19 +274,19 @@ public class NpcCombat {
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
}
break;
case 2607:
case TZHAARXIL_2607:
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
case 2591:
case TZHAARMEJ:
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
break;
case 172:
case 174:
case DARK_WIZARD:
case DARK_WIZARD_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 = AttackType.MAGIC.getValue();
break;
case 3068:
case SKELETAL_WYVERN:
if(Misc.random(10) > 7) {
NpcHandler.npcs[i].projectileId = 393; //red
NpcHandler.npcs[i].endGfx = 430;
@@ -295,28 +297,25 @@ public class NpcCombat {
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
}
break;
case 2892:
case SPINOLYP:
NpcHandler.npcs[i].projectileId = 94;
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
NpcHandler.npcs[i].endGfx = 95;
break;
case 2894:
case SPINOLYP_2894:
NpcHandler.npcs[i].projectileId = 298;
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
break;
/*
* Better Dragons
*/
case 5363: // Mithril-Dragon
case 53: // Red Dragon
case 54: // Black-Dragon
case 55: // Blue-Dragon
case 941: // Green-Dragon
case 4682:
case 5362:
case 1590:
case 1591:
case 1592:
case RED_DRAGON: // Red Dragon
case BLACK_DRAGON: // Black-Dragon
case BLUE_DRAGON: // Blue-Dragon
case GREEN_DRAGON: // Green-Dragon
case BRONZE_DRAGON:
case IRON_DRAGON:
case STEEL_DRAGON:
int random1 = Misc.random(3);
switch (random1) {
case 1:
@@ -331,7 +330,7 @@ public class NpcCombat {
break;
}
break;
case 134:
case POISON_SPIDER:
if (c.playerLevel[Constants.PRAYER] > 0) {
c.playerLevel[Constants.PRAYER]--;
c.getPlayerAssistant().refreshSkill(Constants.PRAYER);
@@ -340,9 +339,9 @@ public class NpcCombat {
}
break;
case 3590:
case 50:
case 742:
case STEEL_DRAGON_3590:
case KING_BLACK_DRAGON:
case ELVARG:
int random = Misc.random(4);
switch (random) {
case 0:
@@ -372,73 +371,7 @@ public class NpcCombat {
break;
}
break;
// arma npcs
case 2561:
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
break;
case 2560:
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
NpcHandler.npcs[i].projectileId = 1190;
break;
case 2559:
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
NpcHandler.npcs[i].projectileId = 1203;
break;
case 2558:
random = Misc.random(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 = AttackType.MAGIC.getValue();
NpcHandler.npcs[i].projectileId = 1198;
}
break;
// sara npcs
case 2562: // sara
random = Misc.random(1);
if (random == 0) {
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 = AttackType.MELEE.getValue();
}
break;
case 2563: // star
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
break;
case 2564: // growler
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
NpcHandler.npcs[i].projectileId = 1203;
break;
case 2565: // bree
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 = AttackType.MELEE.getValue();
} else {
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
NpcHandler.npcs[i].endGfx = 1211;
NpcHandler.npcs[i].projectileId = 288;
}
break;
case 2551:
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
break;
case 2552:
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
NpcHandler.npcs[i].projectileId = 1203;
break;
case 2553:
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
NpcHandler.npcs[i].projectileId = 1206;
break;
case 2025:
case AHRIM_THE_BLIGHTED:
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
int r = Misc.random(3);
if (r == 0) {
@@ -461,23 +394,23 @@ public class NpcCombat {
NpcHandler.npcs[i].projectileId = 156;
}
break;
case 2881:// supreme
case DAGANNOTH_SUPREME:// supreme
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
NpcHandler.npcs[i].projectileId = 298;
break;
case 2882:// prime
case DAGANNOTH_PRIME:// prime
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
NpcHandler.npcs[i].projectileId = 162;
NpcHandler.npcs[i].endGfx = 477;
break;
case 2028:
case KARIL_THE_TAINTED:
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
NpcHandler.npcs[i].projectileId = 27;
break;
case 3200:
case CHAOS_ELEMENTAL:
int r2 = Misc.random(1);
if (r2 == 0) {
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
@@ -491,7 +424,7 @@ public class NpcCombat {
NpcHandler.npcs[i].endGfx = 555;
}
break;
case 2745:
case TZTOKJAD:
int r3 = 0;
if (NpcHandler
.goodDistance(
@@ -516,13 +449,13 @@ public class NpcCombat {
NpcHandler.npcs[i].projectileId = -1;
}
break;
case 2743:
case KETZEK:
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
NpcHandler.npcs[i].projectileId = 445;
NpcHandler.npcs[i].endGfx = 446;
break;
case 2631:
case TOKXIL:
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
NpcHandler.npcs[i].projectileId = 443;
break;
@@ -1,6 +1,7 @@
package com.rs2.game.content.combat.npcs;
import com.rs2.GameEngine;
import com.rs2.game.content.StaticNpcList;
import com.rs2.game.content.combat.AttackType;
import com.rs2.game.npcs.NpcHandler;
import com.rs2.game.players.Player;
@@ -160,7 +161,7 @@ public enum NpcEmotes {
return e.getBlock();
} else {
switch (NpcHandler.npcs[i].npcType) {
case 2745:
case StaticNpcList.TZTOKJAD:
return 2653;
}
}
@@ -176,12 +177,12 @@ public enum NpcEmotes {
return e.getDead();
} else {
switch (NpcHandler.npcs[i].npcType) {
case 2745:
case StaticNpcList.TZTOKJAD:
return 2654;
case 1158:
case StaticNpcList.KALPHITE_QUEEN:
GameEngine.npcHandler.spawnSecondForm(player, i);
return 1187;
case 1160:
case StaticNpcList.KALPHITE_QUEEN_1160:
GameEngine.npcHandler.spawnFirstForm(player, i);
return 1182;
}
@@ -5,6 +5,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.StaticNpcList;
import com.rs2.game.content.combat.CombatConstants;
import com.rs2.game.npcs.Npc;
import com.rs2.game.npcs.NpcHandler;
@@ -450,7 +451,7 @@ public class DwarfCannon {
if (!npc.isDead && !npc.isDead && npc.HP != 0 && npc.npcType != 1266 && npc.npcType != 1268 && inDistance(theirX, theirY)) {
if (!npc.isDead && !npc.isDead && npc.HP != 0 && npc.npcType != StaticNpcList.ROCKS && npc.npcType != StaticNpcList.ROCKS_1268 && inDistance(theirX, theirY)) {
switch (rotation) {
case 1:
if (theirY > myY && theirX >= myX - 1 && theirX <= myX + 1) {
@@ -3,6 +3,7 @@ package com.rs2.game.content.minigames.magetrainingarena;
import java.util.Random;
import com.rs2.Constants;
import com.rs2.game.content.StaticNpcList;
import com.rs2.game.content.combat.magic.MagicData;
import com.rs2.game.content.combat.magic.MagicRequirements;
import com.rs2.game.content.music.sound.SoundList;
@@ -141,7 +142,7 @@ public class Alchemy {
// 1 in 4 chance of an item being free to alch
freeAlch = random.nextInt(values.length * 4);
for (int i = 0; i < NpcHandler.MAX_NPCS; i ++) {
if (NpcHandler.npcs[i] != null && NpcHandler.npcs[i].npcType == 3099) {
if (NpcHandler.npcs[i] != null && NpcHandler.npcs[i].npcType == StaticNpcList.ALCHEMY_GUARDIAN) {
NpcHandler.npcs[i].forceChat("Items are changing!");
}
}
@@ -13,6 +13,8 @@ import com.rs2.game.npcs.NpcHandler;
import com.rs2.game.players.Player;
import com.rs2.util.Misc;
import static com.rs2.game.content.StaticNpcList.*;
public class Stalls {
@@ -221,7 +223,7 @@ public class Stalls {
private static void failGuards(final Player p) {
for (int i = 1; i < NpcHandler.MAX_NPCS; i ++) {
if (NpcHandler.npcs[i] != null) {
if (NpcHandler.npcs[i].npcType == 32 || NpcHandler.npcs[i].npcType == 1317 || NpcHandler.npcs[i].npcType == 2236 || NpcHandler.npcs[i].npcType == 2571) {
if (NpcHandler.npcs[i].npcType == GUARD_32 || NpcHandler.npcs[i].npcType == MARKET_GUARD || NpcHandler.npcs[i].npcType == MARKET_GUARD_2236 || NpcHandler.npcs[i].npcType == MARKET_GUARD_2571) {
if (p.goodDistance(p.absX, p.absY, NpcHandler.npcs[i].absX, NpcHandler.npcs[i].absY, 7)
&& p.heightLevel == NpcHandler.npcs[i].heightLevel) {
if (!NpcHandler.npcs[i].underAttack) {
@@ -9,16 +9,18 @@ import com.rs2.world.clip.Region;
import java.util.ArrayList;
import static com.rs2.game.content.StaticNpcList.*;
public class NpcData {
public static final int[] npcsOnlyMage = { 907, 908, 909, 910, 911, 912,
913, 914 };// done
public static final int[][] transformNpc = { { 3223, 6006 },
{ 3224, 6007 }, { 3225, 6008 }, { 3226, 6009 } };// done
public static final int[] npcsCantKillYou = { 41, 951, 1017, 1401, 1402,
1692, 2313, 2314, 2315 };// done
public static final int[] npcCantAttack = { 1532, 1533, 1534, 1535 };
public static final int[] npcDontGiveXp = { 2459, 2460, 2461, 2462 };
public static final int[] npcsOnlyMage = { KOLODION_907, KOLODION_908, KOLODION_909, KOLODION_910, KOLODION_911, BATTLE_MAGE,
BATTLE_MAGE_913, BATTLE_MAGE_914 };// done
public static final int[][] transformNpc = { { MAN_3223, 6006 },
{ MAN_3224, 6007 }, { MAN_3225, 6008 }, { WOMAN_3226, 6009 } };// done // this transformNpc array seems to be unused, maybe can be removed? Maybe it's not even accurate? Idk I just fixed the magic numbers.
public static final int[] npcsCantKillYou = { CHICKEN, CHICKEN_951, CHICKEN_1017, CHICKEN_1401, CHICKEN_1402,
UNDEAD_CHICKEN, CHICKEN_2313, CHICKEN_2314, CHICKEN_2315 };// done
public static final int[] npcCantAttack = { BARRICADE, BARRICADE_1533, BARRICADE_1534, BARRICADE_1535 };
public static final int[] npcDontGiveXp = { PHEASANT, PHEASANT_2460, PHEASANT_2461, PHEASANT_2462 };
public static boolean cantKillYou(int npcType) {
for (int n : npcsCantKillYou) {
@@ -186,23 +188,13 @@ public class NpcData {
**/
public static int getNpcDelay(int i) {
switch (NpcHandler.npcs[i].npcType) {
case 2025:
case 2028:
case AHRIM_THE_BLIGHTED:
case KARIL_THE_TAINTED:
return 7;
case 2745:
case TZTOKJAD:
return 8;
case 2558:
case 2559:
case 2560:
case 2561:
case 2550:
return 6;
// saradomin gw boss
case 2562:
return 2;
default:
return 5;
}
@@ -213,21 +205,18 @@ public class NpcData {
**/
public static int getHitDelay(int i) {
switch (NpcHandler.npcs[i].npcType) {
case 2881:
case 2882:
case 3200:
case 2892:
case 2894:
case DAGANNOTH_SUPREME:
case DAGANNOTH_PRIME:
case CHAOS_ELEMENTAL:
case SPINOLYP:
case SPINOLYP_2894:
return 3;
case 2743:
case 2631:
case 2558:
case 2559:
case 2560:
case KETZEK:
case TOKXIL:
return 3;
case 2745:
case TZTOKJAD:
if (NpcHandler.npcs[i].attackType == AttackType.RANGE.getValue()
|| NpcHandler.npcs[i].attackType == AttackType.MAGIC.getValue()) {
return 5;
@@ -235,9 +224,9 @@ public class NpcData {
return 2;
}
case 2025:
case AHRIM_THE_BLIGHTED:
return 4;
case 2028:
case KARIL_THE_TAINTED:
return 3;
default:
@@ -250,31 +239,20 @@ public class NpcData {
**/
public static int getRespawnTime(int i) {
switch (NpcHandler.npcs[i].npcType) {
case 1158:
case 1160:
case KALPHITE_QUEEN:
case KALPHITE_QUEEN_1160:
return -1;
case 2881:
case 2882:
case 2883:
case 2558:
case 2559:
case 2560:
case 2561:
case 2562:
case 2563:
case 2564:
case 2550:
case 2551:
case 2552:
case 2553:
case DAGANNOTH_SUPREME:
case DAGANNOTH_PRIME:
case DAGANNOTH_REX:
return 100;
case 3777:
case 3778:
case 3779:
case 3780:
case PORTAL:
case PORTAL_3778:
case PORTAL_3779:
case PORTAL_3780:
return 500;
case 1532:
case 1534:
case BARRICADE:
case BARRICADE_1534:
return -1;
default:
return 25;
@@ -294,49 +272,39 @@ public class NpcData {
return 5;
}
switch (NpcHandler.npcs[i].npcType) {
case 2562:
case COAL:
return 2;
case 2881:// dag kings
case 2882:
case 3200:// chaos ele
case DAGANNOTH_SUPREME:// dag kings
case DAGANNOTH_PRIME:
case CHAOS_ELEMENTAL:// chaos ele
return 8;
case 2552:
case 2553:
case 2556:
case 2557:
case 2558:
case 2559:
case 2560:
case 2564:
case 2565:
return 9;
// things around dags
case 2892:
case 2894:
case SPINOLYP:
case SPINOLYP_2894:
return 10;
case 907 : // Kolodian
case 908 :
case 909 :
case 910 :
case 911 :
case 912 : // Zammy battlemage
case 913 : // Sara battlemage
case 914 : // Guthix battlemage
case 2591 : // TzHaar-Mej (Tzhaar mage guy)
case 2743 : // Ket-Zek (Tzhaar mage guy)
case 2745 : // TzTok-Jad
case 1158 : // Kalphite queen form 1
case 1160 : // Kalphite queen form 2
case 2025 : // Ahrim
case KOLODION_907 : // Kolodian
case KOLODION_908 :
case KOLODION_909 :
case KOLODION_910 :
case KOLODION_911 :
case BATTLE_MAGE : // Zammy battlemage
case BATTLE_MAGE_913 : // Sara battlemage
case BATTLE_MAGE_914 : // Guthix battlemage
case TZHAARMEJ : // TzHaar-Mej (Tzhaar mage guy)
case KETZEK : // Ket-Zek (Tzhaar mage guy)
case TZTOKJAD : // TzTok-Jad
case KALPHITE_QUEEN : // Kalphite queen form 1
case KALPHITE_QUEEN_1160 : // Kalphite queen form 2
case AHRIM_THE_BLIGHTED : // Ahrim
return 10;
case 2028 : // Karil
case 2631 : // Tok-Xil (Tzhaar ranging guy)
case 1183 : // Elf ranger
case 172: // dark wizards
case 174:
case KARIL_THE_TAINTED : // Karil
case TOKXIL : // Tok-Xil (Tzhaar ranging guy)
case ELF_WARRIOR : // Elf ranger
case DARK_WIZARD: // dark wizards
case DARK_WIZARD_174:
return 8;
case 941 : // Green drag
case 50 : // Kbd
case GREEN_DRAGON : // Green drag
case KING_BLACK_DRAGON : // Kbd
return 6;
}
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.StaticItemList;
import com.rs2.game.content.combat.AttackType;
import com.rs2.game.content.combat.CombatConstants;
import com.rs2.game.content.combat.npcs.NpcAggressive;
@@ -34,6 +35,8 @@ import org.json.JSONObject;
import java.io.*;
import java.lang.reflect.Type;
import static com.rs2.game.content.StaticNpcList.*;
// Facetypes: 1-Walk, 2-North, 3-South, 4-East, 5-West
public class NpcHandler {
@@ -48,7 +51,7 @@ public class NpcHandler {
CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
@Override
public void execute(CycleEventContainer container) {
spawnNpc2(1160, npcs[i].absX, npcs[i].absY, 0, 1, 230, 45, 500, 300, true);
spawnNpc2(KALPHITE_QUEEN_1160, npcs[i].absX, npcs[i].absY, 0, 1, 230, 45, 500, 300, true);
container.stop();
}
@@ -66,7 +69,7 @@ public class NpcHandler {
CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
@Override
public void execute(CycleEventContainer container) {
spawnNpc2(1158, npcs[i].absX, npcs[i].absY, 0, 1, 230, 45, 500, 300, true);
spawnNpc2(KALPHITE_QUEEN, npcs[i].absX, npcs[i].absY, 0, 1, 230, 45, 500, 300, true);
container.stop();
}
@@ -83,7 +86,7 @@ public class NpcHandler {
if (npcs[i] == null || foundRat != -1) {
continue;
}
if (npcs[i].npcType == 47 && !npcs[i].isDead) {
if (npcs[i].npcType == RAT && !npcs[i].isDead) {
if (goodDistance(npcs[npcIndex].absX, npcs[npcIndex].absY, npcs[i].absX, npcs[i].absY, 5)) {
foundRat = i;
continue;
@@ -101,13 +104,13 @@ public class NpcHandler {
CycleEventHandler.getSingleton().addEvent(this, new CycleEvent() {
@Override
public void execute(CycleEventContainer container) {
if (npcs[npcIndex].absX == npcs[npcs[npcIndex].chasingRat].absX && npcs[npcIndex].absY == npcs[npcs[npcIndex].chasingRat].absY && (beatChance || npcs[npcIndex].npcType >= 768 && npcs[npcIndex].npcType <= 773)) {
if (npcs[npcIndex].absX == npcs[npcs[npcIndex].chasingRat].absX && npcs[npcIndex].absY == npcs[npcs[npcIndex].chasingRat].absY && (beatChance || npcs[npcIndex].npcType >= CAT && npcs[npcIndex].npcType <= CAT_773)) {
npcs[npcs[npcIndex].chasingRat].isDead = true;
npcs[npcs[npcIndex].chasingRat].forceChat("Eek!");
npcs[npcIndex].forceChat("Meow!");
//startAnimation(9163, npcIndex);
slaveOwner.getPacketSender().sendMessage("The " + getNpcListName(NpcHandler.npcs[npcIndex].npcType) + " caught a rat!");
if (npcs[npcIndex].npcType >= 761 && npcs[npcIndex].npcType <= 766) {
if (npcs[npcIndex].npcType >= KITTEN_761 && npcs[npcIndex].npcType <= KITTEN_766) {
slaveOwner.ratsCaught++;
}
if (slaveOwner.ratsCaught == Pets.RATS_NEEDED_TO_GROW) {
@@ -214,19 +217,19 @@ public class NpcHandler {
npcs[slot] = newNPC;
}
public boolean switchesAttackers(int i) {
public boolean switchesAttackers(int i) { // This seems unused, that's probably not good
switch (npcs[i].npcType) {
case 2551:
case 2552:
case 2553:
case 2559:
case 2560:
case 2561:
case 2563:
case 2564:
case 2565:
case 2892:
case 2894:
case DWARVEN_MINER_2551:
case DWARVEN_MINER_2552:
case BLAST_FURNACE_FOREMAN:
case RUNITE_ORE:
case SILVER_ORE:
case GOLD_ORE:
case PERFECT_GOLD_ORE:
case ORDAN:
case JORZIK:
case SPINOLYP:
case SPINOLYP_2894:
return true;
}
return false;
@@ -500,7 +503,7 @@ public class NpcHandler {
}
}
if (npcs[i].npcType == 162) {
if (npcs[i].npcType == GNOME_TRAINER) {
if (npcs[i].getX() == 2475 && npcs[i].getY() == 3438) {
npcs[i].forceChat("Okay get over that log, quick quick!");
} else if (npcs[i].getX() == 2471 && npcs[i].getY() == 3427) {
@@ -518,22 +521,22 @@ public class NpcHandler {
}
}
if (npcs[i].npcType == 43) {
if (npcs[i].npcType == SHEEP_43) {
if (Misc.random(20) == 4) {
npcs[i].forceChat("Baa!");
}
}
if (npcs[i].npcType == 81 || npcs[i].npcType == 397 || npcs[i].npcType == 1766 || npcs[i].npcType == 1767 || npcs[i].npcType == 1768) {
if (npcs[i].npcType == COW || npcs[i].npcType == COW_397 || npcs[i].npcType == COW_CALF || npcs[i].npcType == COW_1767 || npcs[i].npcType == COW_CALF_1768) {
if (Misc.random(30) == 4) {
npcs[i].forceChat("Moo");
}
}
if (npcs[i].npcType == 45) {
if (npcs[i].npcType == DUCK_45) {
if (Misc.random(30) == 6) {
npcs[i].forceChat("Quack!");
}
}
if (npcs[i].npcType == 1685)
if (npcs[i].npcType == GRAVINGAS)
{
if (Misc.random(25) == 7) {
int rand = Misc.random(25);
@@ -771,7 +774,7 @@ public class NpcHandler {
// time
dropItems(i); // npc drops items!
FightCaves.tzhaarDeathHandler(i);
if (npcs[i].npcType == 2745) {
if (npcs[i].npcType == TZTOKJAD) {
FightCaves.handleJadDeath(i);
if (PlayerHandler.players[npcs[i].killerId] != null) {
PlayerHandler.players[npcs[i].killerId].spawnedHealers = 0;
@@ -799,36 +802,36 @@ public class NpcHandler {
handleratdeath2(i);
}
}
if (npcs[i].npcType > 3726 && npcs[i].npcType < 3732) {
if (npcs[i].npcType > RABBIT_3726 && npcs[i].npcType < SHIFTER) {
int damage = 10 + Misc.random(10);
player.playerLevel[Constants.HITPOINTS] = player.getPlayerAssistant().getLevelForXP(player.playerXP[Constants.HITPOINTS]) - damage;
player.getPlayerAssistant().refreshSkill(Constants.HITPOINTS);
player.handleHitMask(damage);
}
if (npcs[i].npcType == 655) {
if (npcs[i].npcType == TREE_SPIRIT_655) {
player.spiritTree = true;
player.getPacketSender().sendMessage(
"You have defeated the tree spirit.");
}
if (npcs[i].npcType > 412 && npcs[i].npcType < 419) {
if (npcs[i].npcType > BAT && npcs[i].npcType < ZOMBIE_419) {
player.golemSpawned = false;
}
if (npcs[i].npcType == 757 && player.vampSlayer == 3) {
if (npcs[i].npcType == COUNT_DRAYNOR && player.vampSlayer == 3) {
player.vampSlayer = 4;
}
if (npcs[i].npcType > 390 && npcs[i].npcType < 397) {
if (npcs[i].npcType > BIG_FISH && npcs[i].npcType < COW_397) {
RiverTroll.hasRiverTroll = false;
}
if (npcs[i].npcType > 418 && npcs[i].npcType < 425) {
if (npcs[i].npcType > ROCK_GOLEM_418 && npcs[i].npcType < SHADE) {
player.zombieSpawned = false;
}
if (npcs[i].npcType > 424 && npcs[i].npcType < 431) {
if (npcs[i].npcType > ZOMBIE_424 && npcs[i].npcType < WATCHMAN_431) {
player.shadeSpawned = false;
}
if (npcs[i].npcType > 437 && npcs[i].npcType < 444) {
if (npcs[i].npcType > CAPN_IZZY_NOBEARD && npcs[i].npcType < GOBLIN_444) {
player.treeSpiritSpawned = false;
}
if (npcs[i].npcType > 2462 && npcs[i].npcType < 2469) {
if (npcs[i].npcType > PHEASANT_2462 && npcs[i].npcType < FROG_2469) {
player.chickenSpawned = false;
}
npcs[i].absX = npcs[i].makeX;
@@ -837,11 +840,11 @@ public class NpcHandler {
npcs[i].animNumber = 0x328;
npcs[i].updateRequired = true;
npcs[i].animUpdateRequired = true;
if (npcs[i].npcType >= 2440 && npcs[i].npcType <= 2446) {
if (npcs[i].npcType >= DOORSUPPORT && npcs[i].npcType <= DOORSUPPORT_2446) {
GameEngine.objectManager.removeObject(npcs[i].absX,
npcs[i].absY);
}
} else if (npcs[i].actionTimer == 0 && npcs[i].needRespawn && npcs[i].npcType != 1158) {
} else if (npcs[i].actionTimer == 0 && npcs[i].needRespawn && npcs[i].npcType != KALPHITE_QUEEN) {
if (npcs[i].spawnedBy > 0) {
npcs[i] = null;
} else {
@@ -904,12 +907,12 @@ public class NpcHandler {
public boolean getsPulled(Player c, int i) {
switch (npcs[i].npcType) {
case 2550:
case DWARVEN_MINER_2550:
if (npcs[i].firstAttacker > 0) {
return false;
}
break;
case 87:
case GIANT_RAT_87:
if (Boundary.isIn(c, Boundary.TUTORIAL) || c.tutorialProgress < 36) {
return false;
}
@@ -920,21 +923,11 @@ public class NpcHandler {
public static boolean multiAttacks(int i) {
switch (npcs[i].npcType) {
case 1158: //kq
case KALPHITE_QUEEN: //kq
if (npcs[i].attackType == AttackType.MAGIC.getValue()) {
return true;
}
case 1160: //kq
if (npcs[i].attackType == AttackType.RANGE.getValue()) {
return true;
}
case 2558:
return true;
case 2562:
if (npcs[i].attackType == AttackType.MAGIC.getValue()) {
return true;
}
case 2550:
case KALPHITE_QUEEN_1160: //kq
if (npcs[i].attackType == AttackType.RANGE.getValue()) {
return true;
}
@@ -1049,15 +1042,15 @@ public class NpcHandler {
Player c = (Client) PlayerHandler.players[npcs[i].killedBy];
if (c != null) {
// These npcs shouldn't have drops
if (npcs[i].npcType == 2627 // Tz-Kih
|| npcs[i].npcType == 2630 // Tz-Kek
|| npcs[i].npcType == 2631 // Tok-Xil
|| npcs[i].npcType == 2638 // Neite
|| npcs[i].npcType == 2641 // Dragonkin
|| npcs[i].npcType == 2643 // R4ng3rNo0b889
|| npcs[i].npcType == 2645 // Love Cats
|| npcs[i].npcType == 1532 // Barricade
|| npcs[i].npcType == 153 // Butterfly
if (npcs[i].npcType == TZKIH // Tz-Kih
|| npcs[i].npcType == TZKEK_2630 // Tz-Kek
|| npcs[i].npcType == TOKXIL // Tok-Xil
|| npcs[i].npcType == NEITE_2638 // Neite
|| npcs[i].npcType == DRAGONKIN // Dragonkin
|| npcs[i].npcType == R4NG3RNO0B889 // R4ng3rNo0b889
|| npcs[i].npcType == LOVE_CATS_2645 // Love Cats
|| npcs[i].npcType == BARRICADE // Barricade
|| npcs[i].npcType == BUTTERFLY // Butterfly
|| PestControl.npcIsPCMonster(npcs[i].npcType)
|| FightCaves.isFightCaveNpc(i)) {
// These npcs shouldn't have drops
@@ -1074,36 +1067,36 @@ public class NpcHandler {
}
}
switch (npcs[i].npcType) {
case 2459:
case PHEASANT:
FreakyForester.killedPheasant(c, 0);
GameEngine.itemHandler.createGroundItem(c, 6178, npcs[i].absX, npcs[i].absY, 1, c.playerId);
GameEngine.itemHandler.createGroundItem(c, StaticItemList.RAW_PHEASANT, npcs[i].absX, npcs[i].absY, 1, c.playerId);
break;
case 2460:
case PHEASANT_2460:
FreakyForester.killedPheasant(c, 1);
GameEngine.itemHandler.createGroundItem(c, 6178, npcs[i].absX, npcs[i].absY, 1, c.playerId);
GameEngine.itemHandler.createGroundItem(c, StaticItemList.RAW_PHEASANT, npcs[i].absX, npcs[i].absY, 1, c.playerId);
break;
case 2461:
case PHEASANT_2461:
FreakyForester.killedPheasant(c, 2);
GameEngine.itemHandler.createGroundItem(c, 6178, npcs[i].absX, npcs[i].absY, 1, c.playerId);
GameEngine.itemHandler.createGroundItem(c, StaticItemList.RAW_PHEASANT, npcs[i].absX, npcs[i].absY, 1, c.playerId);
break;
case 2462:
case PHEASANT_2462:
FreakyForester.killedPheasant(c, 3);
GameEngine.itemHandler.createGroundItem(c, 6178, npcs[i].absX, npcs[i].absY, 1, c.playerId);
GameEngine.itemHandler.createGroundItem(c, StaticItemList.RAW_PHEASANT, npcs[i].absX, npcs[i].absY, 1, c.playerId);
break;
case 92:
case SKELETON_92:
if (c.restGhost == 3) {
GameEngine.itemHandler.createGroundItem(c, 553, npcs[i].absX, npcs[i].absY, 1, c.playerId);
GameEngine.itemHandler.createGroundItem(c, StaticItemList.SKULL, npcs[i].absX, npcs[i].absY, 1, c.playerId);
c.restGhost = 4;
}
break;
case 47:
case RAT:
if (c.witchspot == 1 || c.romeojuliet > 0 && c.romeojuliet < 9) {
GameEngine.itemHandler.createGroundItem(c, 300, npcs[i].absX, npcs[i].absY, 1, c.playerId);
GameEngine.itemHandler.createGroundItem(c, StaticItemList.RATS_TAIL, npcs[i].absX, npcs[i].absY, 1, c.playerId);
}
break;
case 645:
case JONNY_THE_BEARD:
if (c.shieldArrav == 5) {
GameEngine.itemHandler.createGroundItem(c, 761, npcs[i].absX, npcs[i].absY, 1, c.playerId);
GameEngine.itemHandler.createGroundItem(c, StaticItemList.SCROLL, npcs[i].absX, npcs[i].absY, 1, c.playerId);
}
break;
}
@@ -1202,11 +1195,11 @@ public class NpcHandler {
return false;
}
switch (npcs[i].npcType) {
case 1456:
case 2892:
case 2894:
case 1532:
case 1534:
case MONKEY_ARCHER:
case SPINOLYP:
case SPINOLYP_2894:
case BARRICADE:
case BARRICADE_1534:
return false;
}
return true;
@@ -1226,11 +1219,11 @@ public class NpcHandler {
return;
}
if (npcs[i].npcType == 1532 || npcs[i].npcType == 1534) {
if (npcs[i].npcType == BARRICADE || npcs[i].npcType == BARRICADE_1534) {
return;
}
if (!followPlayer(i) && npcs[i].npcType != 1532 && npcs[i].npcType != 1534) {
if (!followPlayer(i) && npcs[i].npcType != BARRICADE && npcs[i].npcType != BARRICADE_1534) {
npcs[i].facePlayer(player);
return;
}
@@ -1293,36 +1286,26 @@ public class NpcHandler {
**/
public static int distanceRequired(int i) {
switch (npcs[i].npcType) {
case 2025:
case 2028:
case AHRIM_THE_BLIGHTED:
case KARIL_THE_TAINTED:
return 6;
case 50:
case 2562:
case KING_BLACK_DRAGON:
case COAL:
return 2;
case 172: // dark wizards
case 174:
case 2881:// dag kings
case 2882:
case 3200:// chaos ele
case 2743:
case 2631:
case 2745:
case DARK_WIZARD: // dark wizards
case DARK_WIZARD_174:
case DAGANNOTH_SUPREME:// dag kings
case DAGANNOTH_PRIME:
case CHAOS_ELEMENTAL:// chaos ele
case KETZEK:
case TOKXIL:
case TZTOKJAD:
return 8;
case 2883:// rex
case DAGANNOTH_REX:// rex
return 1;
case 2552:
case 2553:
case 2556:
case 2557:
case 2558:
case 2559:
case 2560:
case 2564:
case 2565:
return 9;
// things around dags
case 2892:
case 2894:
case SPINOLYP:
case SPINOLYP_2894:
return 10;
default:
return 1;
@@ -1331,15 +1314,10 @@ public class NpcHandler {
public static int followDistance(int i) {
switch (npcs[i].npcType) {
case 2550:
case 2551:
case 2562:
case 2563:
return 8;
case 2883:
case DAGANNOTH_REX:
return 4;
case 2881:
case 2882:
case DAGANNOTH_SUPREME:
case DAGANNOTH_PRIME:
return 1;
}
return 0;
@@ -1347,21 +1325,21 @@ public class NpcHandler {
public static int getProjectileSpeed(int i) {
switch (npcs[i].npcType) {
case 2881:
case 2882:
case 3200:
case DAGANNOTH_SUPREME:
case DAGANNOTH_PRIME:
case CHAOS_ELEMENTAL:
return 85;
case 2745:
case TZTOKJAD:
return 130;
case 50:
case KING_BLACK_DRAGON:
return 90;
case 2025:
case AHRIM_THE_BLIGHTED:
return 85;
case 2028:
case KARIL_THE_TAINTED:
return 80;
default:
@@ -1371,22 +1349,22 @@ public class NpcHandler {
public static int offset(int i) {
switch (npcs[i].npcType) {
case 50:
case 110:
case 941:
case 1590:
case 1591:
case 1592:
case 2642:
case 55:
case 54:
case 53:
case KING_BLACK_DRAGON:
case FIRE_GIANT:
case GREEN_DRAGON:
case BRONZE_DRAGON:
case IRON_DRAGON:
case STEEL_DRAGON:
case KING_BLACK_DRAGON_2642:
case BLUE_DRAGON:
case BLACK_DRAGON:
case RED_DRAGON:
return 2;
case 2881:
case 2882:
case DAGANNOTH_SUPREME:
case DAGANNOTH_PRIME:
return 1;
case 2745:
case 2743:
case TZTOKJAD:
case KETZEK:
return 1;
}
return 0;
@@ -1403,13 +1381,13 @@ public class NpcHandler {
}
public boolean retaliates(int npcType) {
return npcType < 3777 || npcType > 3780
&& !(npcType >= 2440 && npcType <= 2446);
return npcType < PORTAL || npcType > PORTAL_3780
&& !(npcType >= DOORSUPPORT && npcType <= DOORSUPPORT_2446);
}
public static void handleSpecialEffects(Player c, int i, int damage) {
if (npcs[i].npcType == 2892 || npcs[i].npcType == 2894 || npcs[i].npcType == 1158
|| npcs[i].npcType == 1160) {
if (npcs[i].npcType == SPINOLYP || npcs[i].npcType == SPINOLYP_2894 || npcs[i].npcType == KALPHITE_QUEEN
|| npcs[i].npcType == KALPHITE_QUEEN_1160) {
if (damage > 0) {
if (c != null) {
if (c.playerLevel[Constants.PRAYER] > 0) {
@@ -1436,21 +1414,11 @@ public class NpcHandler {
public static int getMaxHit(int i) {
switch (npcs[i].npcType) {
case 1158:
case KALPHITE_QUEEN:
return 30;
case 2558:
if (npcs[i].attackType == AttackType.MAGIC.getValue()) {
return 28;
} else {
return 68;
}
case 1265:
case 1267:
case ROCK_CRAB:
case ROCK_CRAB_1267:
return 2;
case 2562:
return 31;
case 2550:
return 36;
}
return 1;
}
@@ -935,9 +935,9 @@ public abstract class Player {
}
}
if (followId > 0) {
if (followPlayerId > 0) {
getPlayerAssistant().followPlayer();
} else if (followId2 > 0) {
} else if (followNpcId > 0) {
getPlayerAssistant().followNpc();
}
@@ -1405,8 +1405,8 @@ public abstract class Player {
dialogueId, randomCoffin, newLocation, specEffect,
specBarId, attackLevelReq, defenceLevelReq, strengthLevelReq,
rangeLevelReq, magicLevelReq, slayerLevelReq, agilityLevelReq,
followId, skullTimer, nextChat = 0, talkingNpc = -1,
dialogueAction = 0, autocastId, followDistance, followId2,
followPlayerId, skullTimer, nextChat = 0, talkingNpc = -1,
dialogueAction = 0, autocastId, followDistance, followNpcId,
barrageCount = 0, delayedDamage = 0, delayedDamage2 = 0,
pcPoints = 0, magePoints = 0, desertTreasure = 0, skillAmount,
lastArrowUsed = -1, autoRet = 1, pcDamage = 0, xInterfaceId = 0,
@@ -567,7 +567,7 @@ public class PlayerAssistant {
public void stepAway() {
player.faceUpdate(player.followId + 32768);
player.faceUpdate(player.followPlayerId + 32768);
if (Region.getClipping(player.getX() - 1, player.getY(), player.heightLevel, -1, 0)) {
walkTo(-1, 0);
} else if (Region.getClipping(player.getX() + 1, player.getY(), player.heightLevel, 1, 0)) {
@@ -1345,7 +1345,7 @@ public class PlayerAssistant {
public void resetFollowers() {
for (Player player : PlayerHandler.players) {
if (player != null) {
if (player.followId == player.playerId) {
if (player.followPlayerId == player.playerId) {
Client c = (Client) player;
c.getPlayerAssistant().resetFollow();
}
@@ -1623,8 +1623,8 @@ public class PlayerAssistant {
}
public void followPlayer() {
if (PlayerHandler.players[player.followId] == null
|| PlayerHandler.players[player.followId].isDead) {
if (PlayerHandler.players[player.followPlayerId] == null
|| PlayerHandler.players[player.followPlayerId].isDead) {
resetFollow();
return;
}
@@ -1635,38 +1635,38 @@ public class PlayerAssistant {
return;
}
int otherX = PlayerHandler.players[player.followId].getX();
int otherY = PlayerHandler.players[player.followId].getY();
int otherX = PlayerHandler.players[player.followPlayerId].getX();
int otherY = PlayerHandler.players[player.followPlayerId].getY();
if (!player.goodDistance(otherX, otherY, player.getX(), player.getY(),
25)) {
player.followId = 0;
player.followPlayerId = 0;
resetFollow();
return;
}
int[] follow = getFollowLocation(otherX, otherY);
player.faceUpdate(player.followId + 32768);
player.faceUpdate(player.followPlayerId + 32768);
PathFinder.getPathFinder().findRoute(player, follow[0], follow[1], false, 1, 1);
}
public void followNpc() {
Npc npc = NpcHandler.npcs[player.followId2];
Npc npc = NpcHandler.npcs[player.followNpcId];
if (npc == null || npc.isDead) {
return;
}
int x = NpcHandler.npcs[player.followId2].getX();
int y = NpcHandler.npcs[player.followId2].getY();
int x = NpcHandler.npcs[player.followNpcId].getX();
int y = NpcHandler.npcs[player.followNpcId].getY();
if (!player.goodDistance(x, y, player.getX(), player.getY(), 25)) {
player.followId2 = 0;
player.followNpcId = 0;
resetFollow();
return;
}
int[] follow = getFollowLocation(x, y);
player.faceUpdate(player.followId2);
player.faceUpdate(player.followNpcId);
PathFinder.getPathFinder().findRoute(player, follow[0], follow[1], false, 1, 1);
}
@@ -1681,8 +1681,8 @@ public class PlayerAssistant {
}
public void resetFollow() {
player.followId = 0;
player.followId2 = 0;
player.followPlayerId = 0;
player.followNpcId = 0;
player.mageFollow = false;
}
@@ -133,7 +133,7 @@ public class AttackPlayer implements PacketType {
return;
}
if (player.getCombatAssistant().checkReqs()) {
player.followId = player.playerIndex;
player.followPlayerId = player.playerIndex;
if (!player.usingMagic && !usingBow && !usingOtherRangeWeapons) {
player.followDistance = 1;
player.getPlayerAssistant().followPlayer();
@@ -6,6 +6,7 @@ import com.rs2.event.CycleEventHandler;
import com.rs2.event.impl.NpcFirstClickEvent;
import com.rs2.event.impl.NpcSecondClickEvent;
import com.rs2.event.impl.NpcThirdClickEvent;
import com.rs2.game.content.StaticNpcList;
import com.rs2.game.content.combat.CombatConstants;
import com.rs2.game.content.combat.magic.MagicData;
import com.rs2.game.content.combat.range.RangeData;
@@ -152,7 +153,7 @@ public class ClickNPC implements PacketType {
return;
}
if (player.followId > 0) {
if (player.followPlayerId > 0) {
player.getPlayerAssistant().resetFollow();
}
if (player.attackTimer <= 0) {
@@ -198,7 +199,7 @@ public class ClickNPC implements PacketType {
}
if (NpcHandler.npcs[player.npcIndex].MaxHP == 0
|| NpcHandler.npcs[player.npcIndex].npcType == 944) {
|| NpcHandler.npcs[player.npcIndex].npcType == StaticNpcList.COMBAT_INSTRUCTOR) {
player.getPacketSender().sendMessage(
"You can't attack this npc.");
break;
@@ -19,7 +19,7 @@ public class FollowPlayer implements PacketType {
player.usingBow = false;
player.usingRangeWeapon = false;
player.followDistance = 1;
player.followId = followPlayer;
player.followPlayerId = followPlayer;
player.endCurrentTask();
}
}
@@ -82,7 +82,7 @@ public class Walking implements PacketType {
if (player.canWalkTutorial == false && player.tutorialProgress < 36) {
return;
}
if (player.followId > 0 || player.followId2 > 0) {
if (player.followPlayerId > 0 || player.followNpcId > 0) {
player.getPlayerAssistant().resetFollow();
}
if (player.getPlayerAction().checkWalking() == false) {