Cleanup part 1 (#213)

* Clean up part 1

- Removed lots of dead code
- Removed unncessary files not in use
- Cleaned up small bits of code
- Removed a few warnings
- Server.java ---> GameEngine.java
- Constants.java ---> GameConstants.java

* Cape Dye

Rewrote cape dying

* Packaging

- redone ----> com.rebotted

* PacketSender/clean up

- ActionSender ---> PacketSender
- Moved many more packets to packetsender
- Cleaned up more dead code

* Merge Client/Player

- Merged Client.java with Player.java (both were doing same thing so redundant to have both)
- Removed some more dead code
- Tidy a few small things up

* Quests/more clean up

- Removed more dead code
- Made quests static in order to clean them up a bit

* More cleanup

- Removed some more of the dead quest code
- Correcting naming of some of the shop variables
This commit is contained in:
Mr Extremez
2019-11-25 11:08:56 -06:00
committed by Daniel Ginovker
parent 3d1ae1b288
commit d876a923b9
379 changed files with 80684 additions and 83170 deletions
@@ -0,0 +1,31 @@
package com.rebotted.game.content.combat.npcs;
import com.rebotted.game.content.minigames.FightCaves;
import com.rebotted.game.content.minigames.PestControl;
import com.rebotted.game.npcs.NpcHandler;
public class NpcAggressive {
/**
* Aggressive monsters
*/
private static final int[] AGGRESSIVE_MONSTERS = {
1155, 374, 1157, 1158, 1159, 1160, 141, 1459, 1456, 96, 97, 142,
2550, 2551, 2552, 2553, 2558, 2559, 2560, 2561, 2562, 2563,
2564, 2565, 2892, 2894, 2881, 2882, 2883, 1593, 144, 112, 84, 3068,
50, 1590, 1591, 1592, 53, 54, 55, 178, 49, 2455, 2456, 2454,
82, 752, 1608, 1609, 1610, 1827, 2783, 1926, 1931, 2457, 412, 1604, 1612,
110, 1611, 83, 941, 49, 117, 111, 125, 1154, 107, 1342, 1338, 447, 448, 449, 917,
1265, 1267
};
public static boolean isAggressive(int i) {
boolean aggressive = NpcHandler.npcs[i].inWild() || PestControl.npcIsPCMonster(NpcHandler.npcs[i].npcType) || FightCaves.isFightCaveNpc(i);
for (int element : AGGRESSIVE_MONSTERS) {
if (NpcHandler.npcs[i].npcType == element || aggressive) {
return true;
}
}
return false;
}
}
@@ -0,0 +1,678 @@
package com.rebotted.game.content.combat.npcs;
import com.rebotted.GameConstants;
import com.rebotted.game.content.combat.CombatAssistant;
import com.rebotted.game.content.combat.melee.MeleeData;
import com.rebotted.game.content.minigames.FightCaves;
import com.rebotted.game.content.music.sound.CombatSounds;
import com.rebotted.game.content.music.sound.SoundList;
import com.rebotted.game.npcs.NpcData;
import com.rebotted.game.npcs.NpcHandler;
import com.rebotted.game.players.Client;
import com.rebotted.game.players.Player;
import com.rebotted.game.players.PlayerHandler;
import com.rebotted.util.Misc;
public class NpcCombat {
public static void multiAttackDamage(int i) {
int max = NpcHandler.getMaxHit(i);
for (Player player : PlayerHandler.players) {
if (player != null) {
Client c = (Client) player;
if (c.isDead || c.heightLevel != NpcHandler.npcs[i].heightLevel) {
continue;
}
if (player.goodDistance(c.absX, c.absY,
NpcHandler.npcs[i].absX, NpcHandler.npcs[i].absY, 15)) {
if (NpcHandler.npcs[i].attackType == 2) {
if (!c.getPrayer().prayerActive[16]) {
if (Misc.random(500) + 200 > Misc.random(c
.getCombatAssistant().mageDef())) {
int dam = Misc.random(max);
c.dealDamage(dam);
c.handleHitMask(dam);
} else {
c.dealDamage(0);
c.handleHitMask(0);
}
} else {
c.dealDamage(0);
c.handleHitMask(0);
}
} else if (NpcHandler.npcs[i].attackType == 1) {
if (!c.getPrayer().prayerActive[17]) {
int dam = Misc.random(max);
if (Misc.random(500) + 200 > Misc.random(c
.getCombatAssistant()
.calculateRangeDefence())) {
c.dealDamage(dam);
c.handleHitMask(dam);
} else {
c.dealDamage(0);
c.handleHitMask(0);
}
} else {
c.dealDamage(0);
c.handleHitMask(0);
}
}
if (NpcHandler.npcs[i].endGfx > 0) {
c.gfx0(NpcHandler.npcs[i].endGfx);
}
}
c.getPlayerAssistant().refreshSkill(3);
}
}
}
public static void multiAttackGfx(int i, int gfx) {
if (NpcHandler.npcs[i].projectileId < 0) {
return;
}
for (Player player : PlayerHandler.players) {
if (player != null) {
Client c = (Client) player;
if (c.heightLevel != NpcHandler.npcs[i].heightLevel) {
continue;
}
if (player.goodDistance(c.absX, c.absY,
NpcHandler.npcs[i].absX, NpcHandler.npcs[i].absY, 15)) {
int nX = NpcHandler.npcs[i].getX() + NpcHandler.offset(i);
int nY = NpcHandler.npcs[i].getY() + NpcHandler.offset(i);
int pX = c.getX();
int pY = c.getY();
int offX = (nY - pY) * -1;
int offY = (nX - pX) * -1;
c.getPlayerAssistant().createPlayersProjectile(nX, nY,
offX, offY, 50, NpcHandler.getProjectileSpeed(i),
NpcHandler.npcs[i].projectileId, 43, 31,
-c.getId() - 1, 65);
}
}
}
}
public static void attackPlayer(Player c, int i) {
if (NpcHandler.npcs[i] != null) {
if (NpcHandler.npcs[i].isDead) {
return;
}
if (c.npcCanAttack == false) {
return;
}
if (NpcHandler.npcs[i].inLesserNpc()) {
return;
}
if (c.inDraynorBuilding()) {
if (NpcHandler.npcs[i].npcType == 172 || NpcHandler.npcs[i].npcType == 174) {
return;
}
}
if (NpcHandler.npcs[i].absY == 3228 && c.absY == 3227) {
return;
}
if (NpcHandler.npcs[i].absY == 3224 && c.absY == 3225) {
return;
}
if (NpcHandler.npcs[i].absY == 3226 && c.absY == 3227) {
return;
}
if (NpcHandler.npcs[i].absY == 3228 && c.absY == 3227) {
return;
}
if (NpcHandler.npcs[i].npcType > 2462 && NpcHandler.npcs[i].npcType < 2468) {
if (Misc.random(5) == 0) {
NpcHandler.npcs[i].forceChat("Flee from me, " + c.playerName + "!");
} else if (Misc.random(5) == 1) {
NpcHandler.npcs[i].forceChat("Begone, " + c.playerName + "!");
} else if (Misc.random(5) == 2) {
NpcHandler.npcs[i].forceChat("Bwuk");
} else if (Misc.random(5) == 3) {
NpcHandler.npcs[i].forceChat("Bwuk bwuk bwuk");
} else if (Misc.random(5) == 4) {
NpcHandler.npcs[i].forceChat("MUAHAHAHAHAAA!");
} else if (Misc.random(5) == 5) {
NpcHandler.npcs[i].forceChat("Bwaaaaaaauk bwuk bwuk");
}
}
if (NpcHandler.npcs[i].npcType == 1532
|| NpcHandler.npcs[i].npcType == 1534
|| NpcHandler.npcs[i].npcType == 6145
|| NpcHandler.npcs[i].npcType == 6144
|| NpcHandler.npcs[i].npcType == 6143
|| NpcHandler.npcs[i].npcType == 6142
|| NpcHandler.npcs[i].npcType == 752) {
return;
}
if (NpcHandler.npcs[i].npcType == 1401 && c.isInTut()
|| c.tutorialProgress < 36) {
return;
}
if (NpcHandler.npcs[i].npcType == 9 && 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) {
return;
}
if (!NpcHandler.npcs[i].inMulti() && NpcHandler.npcs[i].underAttackBy > 0 && NpcHandler.npcs[i].underAttackBy != c.playerId) {
NpcHandler.npcs[i].killerId = 0;
return;
}
if (!NpcHandler.npcs[i].inMulti()
&& (c.underAttackBy > 0 || c.underAttackBy2 > 0
&& c.underAttackBy2 != i)) {
NpcHandler.npcs[i].killerId = 0;
return;
}
if (NpcHandler.npcs[i].heightLevel != c.heightLevel) {
NpcHandler.npcs[i].killerId = 0;
return;
}
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);
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].attackTimer = NpcData.getNpcDelay(i);
NpcHandler.npcs[i].hitDelayTimer = NpcData.getHitDelay(i);
NpcHandler.npcs[i].attackType = 0;
if (GameConstants.COMBAT_SOUNDS
&& NpcHandler.npcs[i].npcType < 3177
&& NpcHandler.npcs[i].npcType > 3180) {
c.getPacketSender()
.sendSound(
CombatSounds
.getNpcAttackSounds(NpcHandler.npcs[i].npcType),
100, 0);
}
if (special) {
loadSpell2(i);
} else {
loadSpell(c, i);
}
if (NpcHandler.npcs[i].attackType == 3) {
NpcHandler.npcs[i].hitDelayTimer += 2;
}
if (NpcHandler.multiAttacks(i)) {
multiAttackGfx(i, NpcHandler.npcs[i].projectileId);
NpcData.startAnimation(NpcEmotes.getAttackEmote(i), i);
if (GameConstants.COMBAT_SOUNDS
&& NpcHandler.npcs[i].npcType < 3177
&& NpcHandler.npcs[i].npcType > 3180) {
c.getPacketSender()
.sendSound(
CombatSounds
.getNpcAttackSounds(NpcHandler.npcs[i].npcType),
100, 0);
}
NpcHandler.npcs[i].oldIndex = c.playerId;
return;
}
if (NpcHandler.npcs[i].projectileId > 0) {
int nX = NpcHandler.npcs[i].getX()
+ NpcHandler.offset(i);
int nY = NpcHandler.npcs[i].getY()
+ NpcHandler.offset(i);
int pX = c.getX();
int pY = c.getY();
int offX = (nY - pY) * -1;
int offY = (nX - pX) * -1;
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 (random < 3) {
NpcHandler.npcs[i].HP += 2;
//NpcHandler.npcs[i].startAnimation(84);
NpcHandler.npcs[i].updateRequired = true;
}
}
c.underAttackBy2 = i;
c.singleCombatDelay2 = System.currentTimeMillis();
NpcHandler.npcs[i].oldIndex = c.playerId;
NpcData.startAnimation(NpcEmotes.getAttackEmote(i), i);
if (GameConstants.COMBAT_SOUNDS
&& NpcHandler.npcs[i].npcType < 3177
&& NpcHandler.npcs[i].npcType > 3180) {
c.getPacketSender()
.sendSound(
CombatSounds
.getNpcAttackSounds(NpcHandler.npcs[i].npcType),
100, 0);
}
c.getPacketSender().closeAllWindows();
}
}
}
}
public static void loadSpell2(int i) {
NpcHandler.npcs[i].attackType = 3;
int random = Misc.random(3);
if (random == 0) {
NpcHandler.npcs[i].projectileId = 393; // red
NpcHandler.npcs[i].endGfx = 430;
} else if (random == 1) {
NpcHandler.npcs[i].projectileId = 394; // green
NpcHandler.npcs[i].endGfx = 429;
} else if (random == 2) {
NpcHandler.npcs[i].projectileId = 395; // white
NpcHandler.npcs[i].endGfx = 431;
} else if (random == 3) {
NpcHandler.npcs[i].projectileId = 396; // blue
NpcHandler.npcs[i].endGfx = 428;
}
}
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;
}
if (NpcHandler.npcs[i].npcType > 3761 && NpcHandler.npcs[i].npcType < 3772) {
NpcHandler.npcs[i].attackType = 1;
}
switch (NpcHandler.npcs[i].npcType) {
case 2607:
NpcHandler.npcs[i].attackType = 1;
case 2591:
case 172:
case 174:
NpcHandler.npcs[i].attackType = 2;
break;
case 3068:
if(Misc.random(10) > 7) {
NpcHandler.npcs[i].projectileId = 393; //red
NpcHandler.npcs[i].endGfx = 430;
NpcHandler.npcs[i].attackType = 3;
NpcData.startAnimation(2989, i);
} else {
NpcData.startAnimation(2980, i);
NpcHandler.npcs[i].attackType = 0;
}
break;
case 2892:
NpcHandler.npcs[i].projectileId = 94;
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].endGfx = 95;
break;
case 2894:
NpcHandler.npcs[i].projectileId = 298;
NpcHandler.npcs[i].attackType = 1;
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:
int random1 = Misc.random(3);
switch (random1) {
case 1:
NpcHandler.npcs[i].projectileId = 393; // red
NpcHandler.npcs[i].endGfx = 430;
NpcHandler.npcs[i].attackType = 3;
break;
default:
NpcHandler.npcs[i].projectileId = -1; // melee
NpcHandler.npcs[i].endGfx = -1;
NpcHandler.npcs[i].attackType = 0;
break;
}
break;
case 134:
if (c.playerLevel[5] > 0) {
c.playerLevel[5]--;
c.getPlayerAssistant().refreshSkill(5);
c.getPlayerAssistant().appendPoison(5);
c.getCombatAssistant().resetPlayerAttack();
}
break;
case 3590:
case 50:
case 742:
int random = Misc.random(4);
switch (random) {
case 0:
NpcHandler.npcs[i].projectileId = 393; // red
NpcHandler.npcs[i].endGfx = 430;
NpcHandler.npcs[i].attackType = 3;
break;
case 1:
NpcHandler.npcs[i].projectileId = 394; // green
NpcHandler.npcs[i].endGfx = 429;
NpcHandler.npcs[i].attackType = 3;
break;
case 2:
NpcHandler.npcs[i].projectileId = 395; // white
NpcHandler.npcs[i].endGfx = 431;
NpcHandler.npcs[i].attackType = 3;
break;
case 3:
NpcHandler.npcs[i].projectileId = 396; // blue
NpcHandler.npcs[i].endGfx = 428;
NpcHandler.npcs[i].attackType = 3;
break;
case 4:
NpcHandler.npcs[i].projectileId = -1; // melee
NpcHandler.npcs[i].endGfx = -1;
NpcHandler.npcs[i].attackType = 0;
break;
}
break;
// arma npcs
case 2561:
NpcHandler.npcs[i].attackType = 0;
break;
case 2560:
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].projectileId = 1190;
break;
case 2559:
NpcHandler.npcs[i].attackType = 2;
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].projectileId = 1197;
} else {
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].projectileId = 1198;
}
break;
// sara npcs
case 2562: // sara
random = Misc.random(1);
if (random == 0) {
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].endGfx = 1224;
NpcHandler.npcs[i].projectileId = -1;
} else if (random == 1) {
NpcHandler.npcs[i].attackType = 0;
}
break;
case 2563: // star
NpcHandler.npcs[i].attackType = 0;
break;
case 2564: // growler
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].projectileId = 1203;
break;
case 2565: // bree
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].projectileId = 9;
break;
// bandos npcs
case 2550:
random = Misc.random(2);
if (random == 0 || random == 1) {
NpcHandler.npcs[i].attackType = 0;
} else {
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].endGfx = 1211;
NpcHandler.npcs[i].projectileId = 288;
}
break;
case 2551:
NpcHandler.npcs[i].attackType = 0;
break;
case 2552:
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].projectileId = 1203;
break;
case 2553:
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].projectileId = 1206;
break;
case 2025:
NpcHandler.npcs[i].attackType = 2;
int r = Misc.random(3);
if (r == 0) {
NpcHandler.npcs[i].gfx100(158);
NpcHandler.npcs[i].projectileId = 159;
NpcHandler.npcs[i].endGfx = 160;
}
if (r == 1) {
NpcHandler.npcs[i].gfx100(161);
NpcHandler.npcs[i].projectileId = 162;
NpcHandler.npcs[i].endGfx = 163;
}
if (r == 2) {
NpcHandler.npcs[i].gfx100(164);
NpcHandler.npcs[i].projectileId = 165;
NpcHandler.npcs[i].endGfx = 166;
}
if (r == 3) {
NpcHandler.npcs[i].gfx100(155);
NpcHandler.npcs[i].projectileId = 156;
}
break;
case 2881:// supreme
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].projectileId = 298;
break;
case 2882:// prime
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].projectileId = 162;
NpcHandler.npcs[i].endGfx = 477;
break;
case 2028:
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].projectileId = 27;
break;
case 3200:
int r2 = Misc.random(1);
if (r2 == 0) {
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].gfx100(550);
NpcHandler.npcs[i].projectileId = 551;
NpcHandler.npcs[i].endGfx = 552;
} else {
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].gfx100(553);
NpcHandler.npcs[i].projectileId = 554;
NpcHandler.npcs[i].endGfx = 555;
}
break;
case 2745:
int r3 = 0;
if (NpcHandler
.goodDistance(
NpcHandler.npcs[i].absX,
NpcHandler.npcs[i].absY,
PlayerHandler.players[NpcHandler.npcs[i].spawnedBy].absX,
PlayerHandler.players[NpcHandler.npcs[i].spawnedBy].absY,
1)) {
r3 = Misc.random(2);
} else {
r3 = Misc.random(1);
}
if (r3 == 0) {
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].endGfx = 157;
NpcHandler.npcs[i].projectileId = 448;
} else if (r3 == 1) {
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].endGfx = 451;
NpcHandler.npcs[i].projectileId = -1;
} else if (r3 == 2) {
NpcHandler.npcs[i].attackType = 0;
NpcHandler.npcs[i].projectileId = -1;
}
break;
case 2743:
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].projectileId = 445;
NpcHandler.npcs[i].endGfx = 446;
break;
case 2631:
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].projectileId = 443;
break;
}
}
public static void registerNpcHit(int i) {
if (NpcHandler.npcs[i] != null) {
if (PlayerHandler.players[NpcHandler.npcs[i].oldIndex] == null) {
return;
}
if (NpcHandler.npcs[i].isDead) {
return;
}
Client c = (Client) PlayerHandler.players[NpcHandler.npcs[i].oldIndex];
if (NpcHandler.multiAttacks(i)) {
NpcCombat.multiAttackDamage(i);
return;
}
if (c.playerIndex <= 0 && c.npcIndex <= 0) {
if (c.autoRet == 1 && NpcHandler.npcs[i].npcType != 411) {
c.npcIndex = i;
}
}
if (c.attackTimer <= 3 || c.attackTimer == 0 && c.npcIndex == 0 && c.oldNpcIndex == 0) {
c.startAnimation(c.getCombatAssistant().getBlockEmote());
}
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)) {
damage = 0;
}
if (NpcData.cantKillYou(NpcHandler.npcs[i].npcType)) {
if (damage >= c.playerLevel[GameConstants.HITPOINTS]) {
damage = c.playerLevel[GameConstants.HITPOINTS] - 1;
}
}
if (c.getPrayer().prayerActive[18]
&& !(NpcHandler.npcs[i].npcType == 2030)) { // protect
// from
// melee)
// {
// //
// 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 (10 + Misc
.random(MeleeData.calculateMeleeDefence(c)) > Misc
.random(NpcHandler.npcs[i].attack)) {
damage = 0;
}
}
if (c.playerLevel[3] - damage < 0) {
damage = c.playerLevel[3];
}
}
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)) {
damage = 0;
}
if (NpcData.cantKillYou(NpcHandler.npcs[i].npcType)) {
if (damage >= c.playerLevel[GameConstants.HITPOINTS]) {
damage = c.playerLevel[GameConstants.HITPOINTS] - 1;
}
}
if (c.getPrayer().prayerActive[17]) { // protect from range
damage = 0;
}
if (c.playerLevel[3] - damage < 0) {
damage = c.playerLevel[3];
}
}
if (NpcHandler.npcs[i].attackType == 2) { // magic
damage = Misc.random(NpcHandler.npcs[i].maxHit);
boolean magicFailed = false;
if (10 + Misc.random(c.getCombatAssistant().mageDef()) > Misc
.random(NpcHandler.npcs[i].attack)) {
damage = 0;
magicFailed = true;
}
if (NpcData.cantKillYou(NpcHandler.npcs[i].npcType)) {
if (damage >= c.playerLevel[GameConstants.HITPOINTS]) {
damage = c.playerLevel[GameConstants.HITPOINTS] - 1;
}
}
if (c.getPrayer().prayerActive[16]) { // protect from magic
damage = 0;
magicFailed = true;
}
if (c.playerLevel[3] - damage < 0) {
damage = c.playerLevel[3];
}
if (NpcHandler.npcs[i].endGfx > 0 && (!magicFailed || FightCaves.isFightCaveNpc(i))) {
c.gfx100(NpcHandler.npcs[i].endGfx);
} else {
c.gfx100(85);
c.getPacketSender().sendSound(SoundList.MAGE_FAIL,
100, 0);
}
}
if (NpcHandler.npcs[i].attackType == 3) { // fire breath
int anti = c.getPlayerAssistant().antiFire();
switch (anti) {
case 0:// has no shield
damage = Misc.random(45) + 10;
c.getPacketSender().sendMessage("You are badly burnt by the dragon fire!");
break;
case 1:// has a shield
if (c.getItemAssistant().playerHasEquipped(5, 1540)) {
damage = Misc.random(4) + 1;
c.getPacketSender().sendMessage("Your shield protects you from the fire.");
}
break;
case 2:// melee
damage = Misc.random(5);
break;
}
}
if (damage > 0) {
CombatAssistant.applyRecoilNPC(c, damage, i);
}
NpcHandler.handleSpecialEffects(c, i, damage);
c.logoutDelay = System.currentTimeMillis(); // logout delay
c.handleHitMask(damage);
c.playerLevel[3] -= damage;
c.getPlayerAssistant().refreshSkill(3);
FightCaves.tzKihEffect(c, i, damage);
c.updateRequired = true;
}
}
}
}
@@ -0,0 +1,182 @@
package com.rebotted.game.content.combat.npcs;
import com.rebotted.game.npcs.NpcHandler;
/**
* Npc Emotes
* @author Andrew (Mr Extremez)
*/
public enum NpcEmotes {
MAN(new int[] {1, 2, 3, 4, 5, 6}, 422, 1834, 836),
GARGOYLE(new int[] {1610, 1611}, 1517, 1519, 1518),
SKELETAL_WYVERN(new int[] {3068}, 2989, 2988, 2987),
BAT(new int[] {412, 78}, 30, 31, 36),
BEAR(new int[] {105, 106}, 41, 42, 44),
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),
KARIL(new int[] {2028}, 2075, 404, 2304),
TORAG(new int[] {2029}, 0x814, 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),
KBD_METAL_DRAGON(new int [] {50, 1590, 1591, 1592}, 80, 89, 92),
DRAGON(new int[] {53, 54, 55, 941}, 91, 89, 92),
BASILISK(new int[] {1616, 1617, 4228}, 1546, 1547, 1548),
BLOOD_WORM(new int[] {2031}, 2070, 2072, 2073),
TREE_SPIRIT(new int[] {438, 439, 440, 441, 442, 443}, 94, 95, 97),
ZOMBIE(new int[] {73, 74, 75, 76, 751}, 299, 300, 302),
ROCK_GOLEM(new int[] {413, 414, 415, 416, 417, 418}, 153, 154, 156),
RIVER_TROLL(new int[] {391, 392, 393, 394, 395, 396}, 284, 285, 287),
GOBLIN(new int[] {100, 101, 102, 1769, 1770, 1771, 1772, 1773, 1774, 1775, 1776}, 309, 312, 313),
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),
DUCK(new int[] {44, 45}, 7, 8, 9),
SPINOLYP(new int[] {2892, 2894}, 2868, 2864, 2865),
DWARF(new int[] {118, 119}, 99, 100, 102),
DEFILER(new int[] {3762, 3763, 3764, 3765, 3766, 3767, 3768, 3769, 3770, 3771}, 3920, 3921, 3922),
SPINNER(new int[] {3747, 3748, 3749, 3750, 3751}, 3908, 3909, 3910),
SHIFTER(new int[] {3732, 3733, 3734, 3735, 3736, 3737, 3738, 3739, 3740, 3741}, 3901, 3902, 3903),
RAVAGER(new int[] {3742, 3743, 3744, 3745, 3746}, 3915, 3916, 3917),
BRAWLER(new int[] {3772, 3773, 3774, 3775, 3776}, 3897, 3895, 3894),
SPLATTER(new int[] {3727, 3728, 3729, 3730, 3731}, 3891, 3890, 3888),
TORCHER(new int[] {3752, 3753, 3754, 3755, 3756, 3757, 3758, 3759, 3760, 3761}, 3882, 3880, 3881),
KALPHITE_WORKER(new int[] {1153, 1154, 1155, 1156, 1157, 1158, 1161}, 1184, 1186, 1187),
KALPHITE_QUEEN(new int[] {1159}, 1185, 1186, 1187),
KALPHITE_QUEEN_2(new int[] {1160}, 1177, 1179, 1182),
DEMON(new int[] {82, 83, 84, 1472}, 64, 65, 67),
DUST_DEVIL(new int[] {1624}, 1557, 1555, 1558),
CHAOS_ELEMENTAL(new int[] {3200}, 3146, 3148, 3147),
GIANT(new int[] {110, 111, 112, 113, 116, 117}, 128, 129, 131),
DAGGANOTH_PRIME(new int[] {2881}, 2855, 2852, 2856),
DAGGANOTH_SUPREME(new int[] {2882}, 2854, 2852, 2856),
DAGGANOTH_REX(new int[] {2883}, 2851, 2852, 2856),
WHITE_KNIGHT(new int[] {1092, 19}, 406, -1, 843),
KNIGHT_WARRIOR(new int[] {125, 178, 179}, 451, -1, 843),
PORTAL(new int[] {3777, 3778, 3779, 3780}, -1, -1, -1),
DARK_BEAST(new int[] {2783}, 2731, 2732, 2733),
TZHAAR_NPCS(new int[] {2604, 2598, 2591}, 2609, 2606, 2607),
TZHAAR_MEJ(new int[] {2591}, 2612, 2606, 2607),
TZHAAR_KET(new int[] {2610, 2615}, 2612, 2606, 2608),
TZHAAR_XIL(new int[] {2607}, 2611, 2610, 2607),
TZ_KIH(new int[] {2627}, 2621, 2622, 2620),
TZ_KEK(new int[] {2629, 2630, 2736, 2738}, 2625, 2626, 2627),
TOK_XIL(new int[] {2631, 2632}, 2628, 2629, 2630),
TZHAAR_YT(new int[] {2741, 2742, 2746}, 2637, 2635, 2638),
KET_ZEK(new int[] {2743, 2744}, 2644, 2645, 2646),
COCKATRICE(new int[] {1620, 1621}, 1562, 1560, 1563),
GNOME_CHILD(new int[] {160, 161}, 191, 194, 196),
GNOME_GUARD(new int[] {163, 164}, 192, 193, 196),
GNOME_WOMAN(new int[] {168, 169}, 190, 193, 196),
TUROTH(new int[] {1626, 1627, 1628, 1629, 1630, 1631, 1632}, 1595, 1596, 1597),
GHOST(new int[] {103, 104, 491}, 123, 124, 126),
ROCK_CRAB(new int[] {1265, 1267}, 1312, 1313, 1314),
DOG_WOLF(new int[] {96, 97, 99, 1593, 1594, 141, 142, 143}, 75, 76, 78),
SPIDER(new int[] {58, 59, 60, 62, 63, 64, 134, 1009, 2035}, 143, 144, 146),
UNICORN(new int[] {89, 133, 987}, 289, 290, 292),
OGRE(new int[] {114, 115, 374}, 359, 360, 361),
FIEND(new int[] {1633, 1634, 1635, 1636, 3406}, 1582, 1581, 1580),
BANSHEE(new int[] {1612}, 1523, 1525, 1524),
EXPERIMENT_25(new int[] {1677}, 1616, 1617, 1618),
EXPERIMENT_25_2(new int[] {1678}, 1612, 1613, 1614),
EXPERIMENT_51(new int[] {1676}, 1626, 1627, 1628),
ABYSSAL_DEMON(new int[] {1615}, 1537, 1539, 1538),
NECHRYAEL(new int[] {1613}, 1528, 1529, 1530),
SCORPION(new int[] {144, 107, 108}, 246, 247, 248),
SMALL_SPIDER(new int[] {61}, 280, 279, 273),
PIT_SCORPION(new int[] {109}, 270, 271, 273),
CRAWLING_HAND(new int[] {1648, 1649, 1650, 1651, 1652, 1653, 1654, 1655, 1656, 1657}, 1592, 1591, 1590),
ABBERANT_SPECTRE(new int[] {1604, 1605, 1606, 1607}, 1507, 1509, 1508),
INFERNAL_MAGE(new int[] {1643, 1644, 1645, 1646, 1647}, 429, 430, 2304),
MONKEY_GUARD(new int[] {1455, 1459, 1460}, 1402, 1403, 1404),
RAT(new int[] {86, 87, 88, 224, 446, 748, 950, 978, 2033}, 138, 139, 141),
SMALL_RAT(new int[] {47, 2032}, 2705, 2706, 2707),
DAGGANOTH(new int[] {1338, 1340, 1341, 1342, 2455, 2456}, 1341, 1340, 1342),
SKELETON(new int[] {90, 91, 92, 93}, 260, 261, 263);
int[] npcId;
int attackAnim, blockAnim, deadAnim;
private NpcEmotes(int[] npcId, int attackAnim, int blockAnim, int deadAnim) {
this.npcId = npcId;
this.attackAnim = attackAnim;
this.blockAnim = blockAnim;
this.deadAnim = deadAnim;
}
private int[] getNpcId() {
return npcId;
}
private int getAttack() {
return attackAnim;
}
private int getBlock() {
return blockAnim;
}
private int getDead() {
return deadAnim;
}
public static int getAttackEmote(int i) {
for (NpcEmotes e : NpcEmotes.values()) {
for (int f = 0; f < e.getNpcId().length; f++) {
if (NpcHandler.npcs[i].npcType == e.getNpcId()[f]) {
return e.getAttack();
} else {
switch (NpcHandler.npcs[i].npcType) {
case 2745:
if (NpcHandler.npcs[i].attackType == 2) {
return 2656;
} else if (NpcHandler.npcs[i].attackType == 1) {
return 2652;
} else if (NpcHandler.npcs[i].attackType == 0) {
return 2655;
}
}
}
}
}
return 0x326;
}
public static int getBlockEmote(int i) {
for (NpcEmotes e : NpcEmotes.values()) {
for (int f = 0; f < e.getNpcId().length; f++) {
if (NpcHandler.npcs[i].npcType == e.getNpcId()[f]) {
return e.getBlock();
} else {
switch (NpcHandler.npcs[i].npcType) {
case 2745:
return 2653;
}
}
}
}
return -1;
}
public static int getDeadEmote(int i) {
for (NpcEmotes e : NpcEmotes.values()) {
for (int f = 0; f < e.getNpcId().length; f++) {
if (NpcHandler.npcs[i].npcType == e.getNpcId()[f]) {
return e.getDead();
} else {
switch (NpcHandler.npcs[i].npcType) {
case 2745:
return 2654;
}
}
}
}
return 2304;
}
}