mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-02 16:49:03 +00:00
Fix Some NPC's Turning When Clicked That Shouldn't (#624)
* Fix Some NPC's That Shouldn't Turn When Clicked * Fix Some NPC's That Shouldn't Turn When Clicked * Make immobileNpcs private * Npc.java IntelliJ Code Format
This commit is contained in:
@@ -64,7 +64,7 @@ public class CombatAssistant {
|
||||
}
|
||||
player.getPacketSender().sendSound(CombatSounds.getNpcBlockSound(NpcHandler.npcs[player.oldNpcIndex].npcType), 100, 0);
|
||||
}
|
||||
NpcHandler.npcs[i].facePlayer(player.playerId);
|
||||
NpcHandler.npcs[i].facePlayer(player);
|
||||
if (NpcHandler.npcs[i].underAttackBy > 0 && GameEngine.npcHandler.getsPulled(player, i)) {
|
||||
NpcHandler.npcs[i].killerId = player.playerId;
|
||||
} else if (NpcHandler.npcs[i].underAttackBy < 0 && !GameEngine.npcHandler.getsPulled(player, i)) {
|
||||
|
||||
@@ -157,11 +157,11 @@ public class NpcCombat {
|
||||
if (!NpcData.goodDistanceNpc(NpcHandler.npcs[i].npcId, c.getX(), c.getY(), NpcData.distanceRequired(NpcHandler.npcs[i].npcId)) || NpcData.inNpc(NpcHandler.npcs[i].npcId, c.getX(), c.getY())) {
|
||||
return;
|
||||
}
|
||||
NpcHandler.npcs[i].facePlayer(c.playerId);
|
||||
NpcHandler.npcs[i].facePlayer(c);
|
||||
boolean special = false;//specialCase(c,i);
|
||||
if (NpcData.checkClip(NpcHandler.npcs[i]) || special) {
|
||||
if (c.respawnTimer <= 0) {
|
||||
NpcHandler.npcs[i].facePlayer(c.playerId);
|
||||
NpcHandler.npcs[i].facePlayer(c);
|
||||
NpcHandler.npcs[i].attackTimer = NpcData.getNpcDelay(i);
|
||||
NpcHandler.npcs[i].hitDelayTimer = NpcData.getHitDelay(i);
|
||||
NpcHandler.npcs[i].attackType = 0;
|
||||
|
||||
@@ -428,7 +428,7 @@ public class DwarfCannon {
|
||||
player.globalDamageDealt += damage;
|
||||
target.killerId = player.playerId;
|
||||
target.killedBy = player.playerId;
|
||||
target.facePlayer(player.playerId);
|
||||
target.facePlayer(player);
|
||||
target.hitUpdateRequired2 = true;
|
||||
target.updateRequired = true;
|
||||
myBalls -= 1;
|
||||
|
||||
@@ -251,7 +251,7 @@ public class Pickpocket extends SkillHandler {
|
||||
if (player.goodDistance(player.absX, player.absY, NpcHandler.npcs[i].absX, NpcHandler.npcs[i].absY, 1) && player.heightLevel == NpcHandler.npcs[i].heightLevel) {
|
||||
if (!NpcHandler.npcs[i].underAttack) {
|
||||
NpcHandler.npcs[i].forceChat("What do you think you're doing?");
|
||||
NpcHandler.npcs[i].facePlayer(player.playerId);
|
||||
NpcHandler.npcs[i].facePlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.rs2.game.players.PlayerHandler;
|
||||
import com.rs2.util.Misc;
|
||||
import com.rs2.util.Stream;
|
||||
|
||||
import static com.rs2.game.content.StaticNpcList.*;
|
||||
|
||||
public class Npc {
|
||||
|
||||
public int npcId;
|
||||
@@ -176,8 +178,7 @@ public class Npc {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
Face
|
||||
* Face
|
||||
**/
|
||||
|
||||
public int FocusPointX = -1, FocusPointY = -1;
|
||||
@@ -215,8 +216,23 @@ public class Npc {
|
||||
str.writeWord(face);
|
||||
}
|
||||
|
||||
public void facePlayer(int player) {
|
||||
face = player + 32768;
|
||||
/**
|
||||
* NPC's That Don't Turn To Face The Player When Clicked
|
||||
*/
|
||||
private static int[] immobileNpcs = { //TODO Rename Appropriately
|
||||
OSPAK,
|
||||
STYRMIR,
|
||||
TORBRUND,
|
||||
FRIDGEIR,
|
||||
};
|
||||
|
||||
public void facePlayer(Player player) {
|
||||
for (int element : immobileNpcs) {
|
||||
if (npcType == (element)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
face = (player != null) ? player.playerId + 32768 : 32768;
|
||||
dirUpdateRequired = true;
|
||||
updateRequired = true;
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ public class NpcHandler {
|
||||
newNPC.attack = attack;
|
||||
newNPC.defence = defence;
|
||||
newNPC.spawnedBy = c.getId();
|
||||
newNPC.facePlayer(c.playerId);
|
||||
newNPC.facePlayer(c);
|
||||
if (headIcon) {
|
||||
c.getPacketSender().drawHeadicon(1, slot, 0, 0);
|
||||
}
|
||||
@@ -461,7 +461,7 @@ public class NpcHandler {
|
||||
|
||||
if (slaveOwner != null && slaveOwner.hasNpc && npcs[i].summoner) {
|
||||
if (slaveOwner.goodDistance(npcs[i].absX, npcs[i].absY, slaveOwner.absX, slaveOwner.absY, 15)) {
|
||||
NpcHandler.followPlayer(i, slaveOwner.playerId);
|
||||
NpcHandler.followPlayer(i, slaveOwner);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -587,7 +587,7 @@ public class NpcHandler {
|
||||
int p = npcs[i].killerId;
|
||||
if (PlayerHandler.players[p] != null) {
|
||||
Player c = (Client) PlayerHandler.players[p];
|
||||
followPlayer(i, c.playerId);
|
||||
followPlayer(i, c);
|
||||
if (npcs[i] == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -598,7 +598,7 @@ public class NpcHandler {
|
||||
} else {
|
||||
npcs[i].killerId = 0;
|
||||
npcs[i].underAttack = false;
|
||||
npcs[i].facePlayer(0);
|
||||
npcs[i].facePlayer(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -611,7 +611,7 @@ public class NpcHandler {
|
||||
}
|
||||
if ((!npcs[i].underAttack || npcs[i].walkingHome)
|
||||
&& npcs[i].randomWalk && !npcs[i].isDead) {
|
||||
npcs[i].facePlayer(0);
|
||||
npcs[i].facePlayer(null);
|
||||
npcs[i].killerId = 0;
|
||||
if (npcs[i].spawnedBy == 0) {
|
||||
if (npcs[i].absX > npcs[i].makeX
|
||||
@@ -730,7 +730,7 @@ public class NpcHandler {
|
||||
if (npcs[i].isDead) {
|
||||
if (npcs[i].actionTimer == 0 && npcs[i].applyDead == false && npcs[i].needRespawn == false) {
|
||||
npcs[i].updateRequired = true;
|
||||
npcs[i].facePlayer(0);
|
||||
npcs[i].facePlayer(null);
|
||||
npcs[i].killedBy = NpcData.getNpcKillerId(i);
|
||||
Player c = (Client) PlayerHandler.players[npcs[i].killedBy];
|
||||
if (c != null) {
|
||||
@@ -1197,15 +1197,15 @@ public class NpcHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void followPlayer(int i, int playerId) {
|
||||
if (PlayerHandler.players[playerId] == null) {
|
||||
public static void followPlayer(int i, Player player) {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
if (PlayerHandler.players[playerId].npcCanAttack == false) {
|
||||
if (player.npcCanAttack == false) {
|
||||
return;
|
||||
}
|
||||
if (PlayerHandler.players[playerId].respawnTimer > 0) {
|
||||
npcs[i].facePlayer(0);
|
||||
if (player.respawnTimer > 0) {
|
||||
npcs[i].facePlayer(null);
|
||||
npcs[i].randomWalk = true;
|
||||
npcs[i].underAttack = false;
|
||||
return;
|
||||
@@ -1216,12 +1216,12 @@ public class NpcHandler {
|
||||
}
|
||||
|
||||
if (!followPlayer(i) && npcs[i].npcType != 1532 && npcs[i].npcType != 1534) {
|
||||
npcs[i].facePlayer(playerId);
|
||||
npcs[i].facePlayer(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int playerX = PlayerHandler.players[playerId].absX;
|
||||
int playerY = PlayerHandler.players[playerId].absY;
|
||||
int playerX = player.absX;
|
||||
int playerY = player.absY;
|
||||
npcs[i].randomWalk = false;
|
||||
if (goodDistance(npcs[i].getX(), npcs[i].getY(), playerX, playerY, distanceRequired(i))) {
|
||||
return;
|
||||
@@ -1230,7 +1230,6 @@ public class NpcHandler {
|
||||
Npc npc = npcs[i];
|
||||
int x = npc.absX;
|
||||
int y = npc.absY;
|
||||
Player player = PlayerHandler.players[playerId];
|
||||
if (npcs[i].spawnedBy > 0
|
||||
|| x < npc.makeX + Constants.NPC_FOLLOW_DISTANCE
|
||||
&& x > npc.makeX - Constants.NPC_FOLLOW_DISTANCE
|
||||
@@ -1259,14 +1258,14 @@ public class NpcHandler {
|
||||
npc.moveX = GetMove(x, playerX); //Move East to player
|
||||
npc.moveY = GetMove(y, playerY);
|
||||
}
|
||||
npc.facePlayer(playerId);
|
||||
npc.facePlayer(player);
|
||||
handleClipping(i);
|
||||
npc.getRandomAndHomeNPCWalking(i);
|
||||
npc.updateRequired = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
npc.facePlayer(0);
|
||||
npc.facePlayer(null);
|
||||
npc.randomWalk = true;
|
||||
npc.underAttack = false;
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ public class ClickNPC implements PacketType {
|
||||
player.getY(), 2)) {
|
||||
player.turnPlayerTo(NpcHandler.npcs[player.npcClickIndex].getX(),
|
||||
NpcHandler.npcs[player.npcClickIndex].getY());
|
||||
NpcHandler.npcs[player.npcClickIndex].facePlayer(player.playerId);
|
||||
NpcHandler.npcs[player.npcClickIndex].facePlayer(player);
|
||||
player.getNpcs().firstClickNpc(player.npcType);
|
||||
player.post(new NpcFirstClickEvent(player.npcType));
|
||||
} else {
|
||||
@@ -256,7 +256,7 @@ public class ClickNPC implements PacketType {
|
||||
NpcHandler.npcs[player.npcClickIndex].getX(),
|
||||
NpcHandler.npcs[player.npcClickIndex].getY());
|
||||
NpcHandler.npcs[player.npcClickIndex]
|
||||
.facePlayer(player.playerId);
|
||||
.facePlayer(player);
|
||||
player.getNpcs().firstClickNpc(player.npcType);
|
||||
player.post(new NpcFirstClickEvent(player.npcType));
|
||||
container.stop();
|
||||
@@ -282,7 +282,7 @@ public class ClickNPC implements PacketType {
|
||||
player.getY(), 2)) {
|
||||
player.turnPlayerTo(NpcHandler.npcs[player.npcClickIndex].getX(),
|
||||
NpcHandler.npcs[player.npcClickIndex].getY());
|
||||
NpcHandler.npcs[player.npcClickIndex].facePlayer(player.playerId);
|
||||
NpcHandler.npcs[player.npcClickIndex].facePlayer(player);
|
||||
player.getNpcs().secondClickNpc(player.npcType);
|
||||
player.post(new NpcSecondClickEvent(player.npcType));
|
||||
} else {
|
||||
@@ -299,7 +299,7 @@ public class ClickNPC implements PacketType {
|
||||
NpcHandler.npcs[player.npcClickIndex].getX(),
|
||||
NpcHandler.npcs[player.npcClickIndex].getY());
|
||||
NpcHandler.npcs[player.npcClickIndex]
|
||||
.facePlayer(player.playerId);
|
||||
.facePlayer(player);
|
||||
player.getNpcs().secondClickNpc(player.npcType);
|
||||
player.post(new NpcSecondClickEvent(player.npcType));
|
||||
container.stop();
|
||||
@@ -326,7 +326,7 @@ public class ClickNPC implements PacketType {
|
||||
player.getY(), 2)) {
|
||||
player.turnPlayerTo(NpcHandler.npcs[player.npcClickIndex].getX(),
|
||||
NpcHandler.npcs[player.npcClickIndex].getY());
|
||||
NpcHandler.npcs[player.npcClickIndex].facePlayer(player.playerId);
|
||||
NpcHandler.npcs[player.npcClickIndex].facePlayer(player);
|
||||
player.getNpcs().thirdClickNpc(player.npcType);
|
||||
player.post(new NpcThirdClickEvent(player.npcType));
|
||||
} else {
|
||||
@@ -343,7 +343,7 @@ public class ClickNPC implements PacketType {
|
||||
NpcHandler.npcs[player.npcClickIndex].getX(),
|
||||
NpcHandler.npcs[player.npcClickIndex].getY());
|
||||
NpcHandler.npcs[player.npcClickIndex]
|
||||
.facePlayer(player.playerId);
|
||||
.facePlayer(player);
|
||||
player.getNpcs().thirdClickNpc(player.npcType);
|
||||
player.post(new NpcThirdClickEvent(player.npcType));
|
||||
container.stop();
|
||||
|
||||
Reference in New Issue
Block a user