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,129 @@
package com.rebotted.game.npcs;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.List;
import com.rebotted.util.XStreamUtil;
public class NPCDefinition {
private static NPCDefinition[] definitions = null;
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];
for (NPCDefinition def : defs) {
definitions[def.getId()] = def;
}
}
public static NPCDefinition forId(int id) {
NPCDefinition d = definitions[id];
if (d == null) {
d = produceDefinition(id);
}
return d;
}
private int id;
private String name, examine;
private int respawn = 0, combat = 0, hitpoints = 1, maxHit = 0, size = 1, attackSpeed = 4000, attackAnim = 422, defenceAnim = 404, deathAnim = 2304, attackBonus = 20, defenceMelee = 20, defenceRange = 20, defenceMage = 20;
private boolean attackable = false;
private boolean aggressive = false;
private boolean retreats = false;
private boolean poisonous = false;
public int getId() {
return id;
}
public String getName() {
return name;
}
public String getExamine() {
return examine;
}
public int getRespawn() {
return respawn;
}
public int getCombat() {
return combat;
}
public int getHitpoints() {
return hitpoints;
}
public int getMaxHit() {
return maxHit;
}
public int getSize() {
return size;
}
public boolean isAggressive() {
return aggressive;
}
public boolean retreats() {
return retreats;
}
public boolean isPoisonous() {
return poisonous;
}
public static NPCDefinition produceDefinition(int id) {
NPCDefinition def = new NPCDefinition();
def.id = id;
def.name = "NPC #" + def.id;
def.examine = "It's an NPC.";
return def;
}
public int getAttackSpeed() {
return attackSpeed;
}
public int getAttackAnimation() {
return attackAnim;
}
public int getDefenceAnimation() {
return defenceAnim;
}
public int getDeathAnimation() {
return deathAnim;
}
public boolean isAttackable() {
return attackable;
}
public int getAttackBonus() {
return attackBonus;
}
public int getDefenceRange() {
return defenceRange;
}
public int getDefenceMelee() {
return defenceMelee;
}
public int getDefenceMage() {
return defenceMage;
}
}
@@ -0,0 +1,464 @@
package com.rebotted.game.npcs;
import com.rebotted.event.CycleEvent;
import com.rebotted.event.CycleEventContainer;
import com.rebotted.event.CycleEventHandler;
import com.rebotted.game.items.ItemAssistant;
import com.rebotted.game.players.Player;
import com.rebotted.game.players.PlayerHandler;
import com.rebotted.util.Misc;
import com.rebotted.util.Stream;
public class Npc {
public int npcId;
public int npcType;
public int absX, absY;
public int heightLevel;
public static int lastX, lastY;
public int makeX, makeY, maxHit, defence, attack, moveX, moveY, direction, walkingType, hitsToHeal;
public int spawnX, spawnY;
public int viewX, viewY;
public boolean summoner;
public int summonedBy, size;
public int focusPointX, focusPointY, masterId;
public boolean turnUpdateRequired;
/**
* attackType: 0 = melee, 1 = range, 2 = mage
*/
public int attackType, projectileId, endGfx, spawnedBy, hitDelayTimer, HP,
MaxHP, hitDiff, animNumber, actionTimer, enemyX, enemyY,
combatLevel;
public boolean applyDead, isDead, needRespawn, respawns, aggressive;
public boolean walkingHome, underAttack;
public int freezeTimer, attackTimer, killerId, killedBy, oldIndex,
underAttackBy;
public long lastDamageTaken;
public boolean randomWalk;
public boolean dirUpdateRequired;
public boolean animUpdateRequired;
public boolean hitUpdateRequired;
public boolean updateRequired;
public boolean forcedChatRequired;
public boolean faceToUpdateRequired;
public int firstAttacker;
public String forcedText;
public boolean transformUpdateRequired = false, isTransformed = false;
public int transformId;
public Npc(int _npcId, int _npcType) {
npcId = _npcId;
npcType = _npcType;
direction = -1;
isDead = false;
applyDead = false;
actionTimer = 0;
randomWalk = true;
}
public void requestTransform(int id) {
transformId = id;
transformUpdateRequired = true;
updateRequired = true;
}
public boolean requestTransformTime(Player player, int itemId, int animation, final int currentId, final int newId, int transformTime, final int npcId) {
if (!player.getItemAssistant().playerHasItem(itemId)) {
player.getPacketSender().sendMessage("You need " + ItemAssistant.getItemName(itemId).toLowerCase() + " to do that.");
return false;
}
if (NpcHandler.npcs[npcId].isTransformed == true)
return false;
if (animation > 0)
player.startAnimation(animation);
NpcHandler.npcs[npcId].isTransformed = true;
requestTransform(newId);
CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() {
@Override
public void execute(CycleEventContainer container) {
requestTransform(currentId);
container.stop();
}
@Override
public void stop() {
NpcHandler.npcs[npcId].isTransformed = false;
}
}, transformTime);
return true;
}
public void appendTransformUpdate(Stream str) {
str.writeWordBigEndianA(transformId);
}
public void updateNPCMovement(Stream str) {
if (str != null) {
if (direction == -1) {
if (updateRequired) {
str.writeBits(1, 1);
str.writeBits(2, 0);
} else {
str.writeBits(1, 0);
}
} else {
str.writeBits(1, 1);
str.writeBits(2, 1);
str.writeBits(3, Misc.xlateDirectionToClient[direction]);
if (updateRequired) {
str.writeBits(1, 1);
} else {
str.writeBits(1, 0);
}
}
}
}
/**
* Text update
**/
public void forceChat(String text) {
forcedText = text;
forcedChatRequired = true;
updateRequired = true;
}
/**
* Graphics
**/
public int mask80var1 = 0;
public int mask80var2 = 0;
protected boolean mask80update = false;
public void appendMask80Update(Stream str) {
str.writeWord(mask80var1);
str.writeDWord(mask80var2);
}
public void gfx100(int gfx) {
mask80var1 = gfx;
mask80var2 = 6553600;
mask80update = true;
updateRequired = true;
}
public void gfx0(int gfx) {
mask80var1 = gfx;
mask80var2 = 65536;
mask80update = true;
updateRequired = true;
}
public void appendAnimUpdate(Stream str) {
str.writeWordBigEndian(animNumber);
str.writeByte(1);
}
public int startAnimation(int anim, int npcId) {
return animNumber;
}
/**
*
Face
**/
public int FocusPointX = -1, FocusPointY = -1;
public int face = 0;
private void appendSetFocusDestination(Stream str) {
str.writeWordBigEndian(FocusPointX);
str.writeWordBigEndian(FocusPointY);
}
public void turnNpc(int i, int j) {
FocusPointX = 2 * i + 1;
FocusPointY = 2 * j + 1;
updateRequired = true;
turnUpdateRequired = true;
}
public int getNextWalkingDirection2() {
int dir;
dir = Misc.direction(absX, absY, absX + moveX, absY + moveY);
dir >>= 1;
absX += moveX;
absY += moveY;
return dir;
}
public void getRandomAndHomeNPCWalking(int i) {
direction = -1;
if (NpcHandler.npcs[i].freezeTimer == 0) {
direction = getNextWalkingDirection2();
}
}
public void appendFaceEntity(Stream str) {
str.writeWord(face);
}
public void facePlayer(int player) {
face = player + 32768;
dirUpdateRequired = true;
updateRequired = true;
}
public void appendFaceToUpdate(Stream str) {
str.writeWordBigEndian(viewX);
str.writeWordBigEndian(viewY);
}
public void appendNPCUpdateBlock(Stream str) {
if (!updateRequired) {
return;
}
int updateMask = 0;
if (animUpdateRequired) {
updateMask |= 0x10;
}
if (hitUpdateRequired2) {
updateMask |= 8;
}
if (mask80update) {
updateMask |= 0x80;
}
if (dirUpdateRequired) {
updateMask |= 0x20;
}
if (forcedChatRequired) {
updateMask |= 1;
}
if (hitUpdateRequired) {
updateMask |= 0x40;
}
if (transformUpdateRequired) {
updateMask |= 2;
}
if (turnUpdateRequired) {
updateMask |= 4;
}
str.writeByte(updateMask);
if (animUpdateRequired) {
appendAnimUpdate(str);
}
if (hitUpdateRequired2) {
appendHitUpdate2(str);
}
if (mask80update) {
appendMask80Update(str);
}
if (dirUpdateRequired) {
appendFaceEntity(str);
}
if (forcedChatRequired) {
str.writeString(forcedText);
}
if (hitUpdateRequired) {
appendHitUpdate(str);
}
if (transformUpdateRequired) {
appendTransformUpdate(str);
}
if (turnUpdateRequired) {
appendSetFocusDestination(str);
}
}
public void clearUpdateFlags() {
updateRequired = false;
forcedChatRequired = false;
hitUpdateRequired = false;
hitUpdateRequired2 = false;
animUpdateRequired = false;
dirUpdateRequired = false;
transformUpdateRequired = false;
mask80update = false;
forcedText = null;
moveX = 0;
moveY = 0;
direction = -1;
focusPointX = -1;
focusPointY = -1;
turnUpdateRequired = false;
}
public int getNextWalkingDirection() {
int nextX = absX + moveX;
int nextY = absY + moveY;
int dir;
dir = Misc.direction(absX, absY, absX + moveX, absY + moveY);
for (Npc npc : NpcHandler.npcs) {
if (npc == null) {
continue;
}
if (npc.absX == nextX && npc.absY == nextY
&& npc.heightLevel == heightLevel) {
return -1;
}
}
for (Player p : PlayerHandler.players) {
if (p == null) {
continue;
}
if (p.absX == nextX && p.absY == nextY
&& p.heightLevel == heightLevel) {
return -1;
}
}
if (dir == -1) {
return -1;
}
dir >>= 1;
absX += moveX;
absY += moveY;
return dir;
}
public void getNextNPCMovement(int i) {
direction = -1;
if (NpcHandler.npcs[i].freezeTimer == 0) {
direction = getNextWalkingDirection();
}
}
public void appendHitUpdate(Stream str) {
if (HP <= 0) {
isDead = true;
}
str.writeByteC(hitDiff);
if (hitDiff > 0) {
str.writeByteS(1);
} else {
str.writeByteS(0);
}
str.writeByteS(HP);
str.writeByteC(MaxHP);
}
public int hitDiff2 = 0;
public boolean hitUpdateRequired2 = false;
public void appendHitUpdate2(Stream str) {
if (HP <= 0) {
isDead = true;
}
str.writeByteA(hitDiff2);
if (hitDiff2 > 0) {
str.writeByteC(1);
} else {
str.writeByteC(0);
}
str.writeByteA(HP);
str.writeByte(MaxHP);
}
public void handleHitMask(int damage) {
if (!hitUpdateRequired) {
hitUpdateRequired = true;
hitDiff = damage;
} else if (!hitUpdateRequired2) {
hitUpdateRequired2 = true;
hitDiff2 = damage;
}
updateRequired = true;
}
public int getX() {
return absX;
}
public int getY() {
return absY;
}
public int getLastX() {
return lastX;
}
public int getLastY() {
return lastY;
}
public void setAbsX(int absX) {
Npc.lastX = this.absX;
this.absX = absX;
}
public void setAbsY(int absY) {
Npc.lastY = this.absY;
this.absY = absY;
}
public void deleteNPC(Npc npc) {
setAbsX(0);
setAbsY(0);
npc = null;
}
public boolean inLesserNpc() {
return (absX >= 3108 && absX <= 3112 && absY >= 3156 && absY <= 3158 && heightLevel == 2);
}
public boolean inMulti() {
if (absX >= 3136
&& absX <= 3327
&& absY >= 3519
&& absY <= 3607
|| absX >= 2625
&& absX <= 2685
&& absY >= 2550
&& absY <= 2620 // Pest
// Control
|| absX >= 3190 && absX <= 3327 && absY >= 3648 && absY <= 3839
|| absX >= 3200 && absX <= 3390 && absY >= 3840 && absY <= 3967
|| absX >= 2992
&& absX <= 3007
&& absY >= 3912
&& absY <= 3967
|| absX >= 2946
&& absX <= 2959
&& absY >= 3816
&& absY <= 3831
|| absX >= 3008
&& absX <= 3199
&& absY >= 3856
&& absY <= 3903
|| absX >= 2667
&& absX <= 2685
&& absY >= 3712
&& absY <= 3730 // rock
// crabs
|| absX >= 3008 && absX <= 3071 && absY >= 3600 && absY <= 3711
|| absX >= 3072 && absX <= 3327 && absY >= 3608 && absY <= 3647
|| absX >= 2624 && absX <= 2690 && absY >= 2550 && absY <= 2619
|| absX >= 2371 && absX <= 2422 && absY >= 5062 && absY <= 5117
|| absX >= 2896 && absX <= 2927 && absY >= 3595 && absY <= 3630
|| absX >= 2892 && absX <= 2932 && absY >= 4435 && absY <= 4464
|| absX >= 2256 && absX <= 2287 && absY >= 4680 && absY <= 4711) {
return true;
}
return false;
}
public boolean inWild() {// beg, end, beg, end, beg, end, beg, end
if (absX > 2941 && absX < 3392 && absY > 3518 && absY < 3966
|| absX > 2941 && absX < 3392 && absY > 9918 && absY < 10366) {
return true;
}
return false;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,471 @@
package com.rebotted.game.npcs;
import java.util.ArrayList;
import com.rebotted.game.content.minigames.FightCaves;
import com.rebotted.game.players.PlayerHandler;
import com.rebotted.util.Misc;
import com.rebotted.world.clip.Region;
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 boolean cantKillYou(int npcType) {
for (int n : npcsCantKillYou) {
if (n == npcType) {
return true;
}
}
return false;
}
public static boolean onlyMage(int npcType) {
for (int element : npcsOnlyMage) {
if (npcType == element) {
return true;
}
}
return false;
}
public static boolean cantAttack(int npcType) {
for (int n : npcCantAttack) {
if (n == npcType) {
return true;
}
}
return false;
}
public static boolean dontGiveXp(int npcType) {
for (int n : npcDontGiveXp) {
if (n == npcType) {
return true;
}
}
return false;
}
/*
* public static boolean isAggressive(int i) { if
* (NPCHandler.npcs[i].aggressive && !onlyMage(NPCHandler.npcs[i].npcType))
* { return true; } if (NPCHandler.npcs[i].inWild() &&
* NPCHandler.npcs[i].MaxHP > 0 && !onlyMage(NPCHandler.npcs[i].npcType)) {
* return true; } return false; }
*/
public static int getNpcKillerId(int npcId) {
int oldDamage = 0;
int killerId = 0;
for (int p = 1; p < PlayerHandler.players.length; p++) {
if (PlayerHandler.players[p] != null) {
if (PlayerHandler.players[p].lastNpcAttacked == npcId) {
if (PlayerHandler.players[p].totalDamageDealt > oldDamage) {
oldDamage = PlayerHandler.players[p].totalDamageDealt;
killerId = p;
}
PlayerHandler.players[p].totalDamageDealt = 0;
}
}
}
return killerId;
}
public static int getCloseRandomPlayer(int i) {
ArrayList<Integer> players = new ArrayList<Integer>();
for (int j = 0; j < PlayerHandler.players.length; j++) {
if (PlayerHandler.players[j] != null) {
if (NpcHandler.goodDistance(
PlayerHandler.players[j].absX,
PlayerHandler.players[j].absY,
NpcHandler.npcs[i].absX,
NpcHandler.npcs[i].absY,
2 + NpcHandler.distanceRequired(i)
+ NpcHandler.followDistance(i))
|| FightCaves.isFightCaveNpc(i)) {
if (PlayerHandler.players[j].underAttackBy <= 0
&& PlayerHandler.players[j].underAttackBy2 <= 0
|| PlayerHandler.players[j].inMulti()) {
if (PlayerHandler.players[j].heightLevel == NpcHandler.npcs[i].heightLevel) {
players.add(j);
}
}
}
}
}
if (players.size() > 0) {
return players.get(Misc.random(players.size() - 1));
} else {
return 0;
}
}
public static void startAnimation(int animId, int i) {
NpcHandler.npcs[i].animNumber = animId;
NpcHandler.npcs[i].animUpdateRequired = true;
NpcHandler.npcs[i].updateRequired = true;
}
public static void handleClipping(int i) {
Npc npc = NpcHandler.npcs[i];
if (npc.moveX == 1 && npc.moveY == 1) {
if ((Region
.getClipping(npc.absX + 1, npc.absY + 1, npc.heightLevel) & 0x12801e0) != 0) {
npc.moveX = 0;
npc.moveY = 0;
if ((Region
.getClipping(npc.absX, npc.absY + 1, npc.heightLevel) & 0x1280120) == 0) {
npc.moveY = 1;
} else {
npc.moveX = 1;
}
}
} else if (npc.moveX == -1 && npc.moveY == -1) {
if ((Region
.getClipping(npc.absX - 1, npc.absY - 1, npc.heightLevel) & 0x128010e) != 0) {
npc.moveX = 0;
npc.moveY = 0;
if ((Region
.getClipping(npc.absX, npc.absY - 1, npc.heightLevel) & 0x1280102) == 0) {
npc.moveY = -1;
} else {
npc.moveX = -1;
}
}
} else if (npc.moveX == 1 && npc.moveY == -1) {
if ((Region
.getClipping(npc.absX + 1, npc.absY - 1, npc.heightLevel) & 0x1280183) != 0) {
npc.moveX = 0;
npc.moveY = 0;
if ((Region
.getClipping(npc.absX, npc.absY - 1, npc.heightLevel) & 0x1280102) == 0) {
npc.moveY = -1;
} else {
npc.moveX = 1;
}
}
} else if (npc.moveX == -1 && npc.moveY == 1) {
if ((Region
.getClipping(npc.absX - 1, npc.absY + 1, npc.heightLevel) & 0x128013) != 0) {
npc.moveX = 0;
npc.moveY = 0;
if ((Region
.getClipping(npc.absX, npc.absY + 1, npc.heightLevel) & 0x1280120) == 0) {
npc.moveY = 1;
} else {
npc.moveX = -1;
}
}
} // Checking Diagonal movement.
if (npc.moveY == -1) {
if ((Region.getClipping(npc.absX, npc.absY - 1, npc.heightLevel) & 0x1280102) != 0) {
npc.moveY = 0;
}
} else if (npc.moveY == 1) {
if ((Region.getClipping(npc.absX, npc.absY + 1, npc.heightLevel) & 0x1280120) != 0) {
npc.moveY = 0;
}
} // Checking Y movement.
if (npc.moveX == 1) {
if ((Region.getClipping(npc.absX + 1, npc.absY, npc.heightLevel) & 0x1280180) != 0) {
npc.moveX = 0;
}
} else if (npc.moveX == -1) {
if ((Region.getClipping(npc.absX - 1, npc.absY, npc.heightLevel) & 0x1280108) != 0) {
npc.moveX = 0;
}
} // Checking X movement.
}
/**
* Attack delays
**/
public static int getNpcDelay(int i) {
switch (NpcHandler.npcs[i].npcType) {
case 2025:
case 2028:
return 7;
case 2745:
return 8;
case 2558:
case 2559:
case 2560:
case 2561:
case 2550:
return 6;
// saradomin gw boss
case 2562:
return 2;
default:
return 5;
}
}
/**
* Hit delays
**/
public static int getHitDelay(int i) {
switch (NpcHandler.npcs[i].npcType) {
case 2881:
case 2882:
case 3200:
case 2892:
case 2894:
return 3;
case 2743:
case 2631:
case 2558:
case 2559:
case 2560:
return 3;
case 2745:
if (NpcHandler.npcs[i].attackType == 1
|| NpcHandler.npcs[i].attackType == 2) {
return 5;
} else {
return 2;
}
case 2025:
return 4;
case 2028:
return 3;
default:
return 2;
}
}
/**
* Npc respawn time
**/
public static int getRespawnTime(int i) {
switch (NpcHandler.npcs[i].npcType) {
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:
return 100;
case 3777:
case 3778:
case 3779:
case 3780:
return 500;
case 1532:
case 1534:
return -1;
default:
return 25;
}
}
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;
}
switch (NpcHandler.npcs[i].npcType) {
case 2562:
return distanceNeeded += 1;
case 2881:// dag kings
case 2882:
case 3200:// chaos ele
return distanceNeeded += 7;
case 2552:
case 2553:
case 2556:
case 2557:
case 2558:
case 2559:
case 2560:
case 2564:
case 2565:
return distanceNeeded += 8;
// things around dags
case 2892:
case 2894:
return distanceNeeded += 9;
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
return distanceNeeded += 9;
case 2028 : // Karil
case 2631 : // Tok-Xil (Tzhaar ranging guy)
case 1183 : // Elf ranger
return distanceNeeded += 7;
case 941 : // Green drag
case 50 : // Kbd
return distanceNeeded += 5;
}
return distanceNeeded;
}
public static boolean goodDistanceNpc(int i, int x2, int y2, int distance) {
for (int x = NpcHandler.npcs[i].getX(); x <= NpcHandler.npcs[i].getX() + NpcHandler.npcs[i].size; x++) {
for (int y = NpcHandler.npcs[i].getY(); y <= NpcHandler.npcs[i].getY() + NpcHandler.npcs[i].size; y++) {
if (Misc.goodDistance(x, y, x2, y2, distance)) {
return true;
}
}
}
return false;
}
public static boolean checkClip(Npc n) {
int x2 = 0, y2 = 0, x3 = 0, y3 = 0;
if (n.killerId > 0) {
if (PlayerHandler.players[n.killerId] == null) {
return false;
}
x2 = PlayerHandler.players[n.killerId].getX();
y2 = PlayerHandler.players[n.killerId].getY();
} else if (n.masterId > 0) {
if (PlayerHandler.players[n.masterId] == null) {
return false;
}
x2 = PlayerHandler.players[n.masterId].getX();
y2 = PlayerHandler.players[n.masterId].getY();
} else {
return false;
}
int x = n.getX(); // -1
int y = n.getY(); // 1
final int dis = distanceRequired(n.npcId) + n.size;
int dis2 = 0;
final boolean melee = distanceRequired(n.npcId) < 2;
if (n.size < 1 && x != x2 && y != y2) {
return false;
}
// Algorithm starts here
int w = x2 - x;
int h = y2 - y;
int dx1 = 0, dy1 = 0, dx2 = 0, dy2 = 0;
if (w < 0) {
dx1 = -1;
} else if (w > 0) {
dx1 = 1;
}
if (h < 0) {
dy1 = -1;
} else if (h > 0) {
dy1 = 1;
}
if (w < 0) {
dx2 = -1;
} else if (w > 0) {
dx2 = 1;
}
int longest = Math.abs(w);
int shortest = Math.abs(h);
if (!(longest > shortest)) {
longest = Math.abs(h);
shortest = Math.abs(w);
if (h < 0) {
dy2 = -1;
} else if (h > 0) {
dy2 = 1;
}
dx2 = 0;
}
int numerator = longest >> 1;
boolean firstCheck = false;
for (int i = 0; i <= longest; i++) {
if (dis2 > dis) {
return false;
}
dis2++;
x3 = x;
y3 = y;
numerator += shortest;
if (!(numerator < longest)) {
numerator -= longest;
x += dx1;
y += dy1;
} else {
x += dx2;
y += dy2;
}
if (!firstCheck) {
if (melee) {
if (!Region.getClipping(x, y, n.heightLevel, x - x3, y - y3)) {
return false;
}
}
if (x == x2 && y == y2) {
break;
}
firstCheck = true;
}
if (melee) {
if (!Region.getClipping(x, y, n.heightLevel, x - x3, y - y3)) {
return false;
}
}
if (x == x2 && y == y2) {
return true;
}
}
return true;
}
public static boolean inNpc(int i, int x2, int y2) {
if (NpcHandler.npcs[i].size < 1) {
if (x2 == NpcHandler.npcs[i].getX() && y2 == NpcHandler.npcs[i].getY()) {
return true;
}
} else {
for (int x = NpcHandler.npcs[i].getX(); x <= NpcHandler.npcs[i].getX() + NpcHandler.npcs[i].size; x++) {
for (int y = NpcHandler.npcs[i].getY(); y <= NpcHandler.npcs[i].getY() + NpcHandler.npcs[i].size; y++) {
if (x2 == x && y2 == y) {
return true;
}
}
}
}
return false;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,13 @@
package com.rebotted.game.npcs;
public class NpcList {
public int npcId;
public String npcName;
public int npcCombat;
public int npcHealth;
public NpcList(int _npcId) {
npcId = _npcId;
}
}
@@ -0,0 +1,143 @@
package com.rebotted.game.npcs;
/**
* NPC Sizes.
* @author Primadude.
*/
public class NpcSize {
/**
* Gets the size of the specified NPC.
*
* @param npcType
* The type of the NPC.
* @return The NPC size.
*/
public static int getNPCSize(int npcType) {
int NPC_TYPE = 0;
int NPC_SIZE = 1;
for (int[] element : NPC_SIZES) {
if (npcType == element[NPC_TYPE]) {
return element[NPC_SIZE];
}
}
return 1;
}
/**
* NPC Sizes. {NPC TYPE, SIZE}.
*/
private static final int[][] NPC_SIZES = { { 49, 2 }, { 50, 5 }, { 51, 2 },
{ 52, 2 }, { 53, 4 }, { 54, 4 }, { 55, 4 }, { 69, 2 }, { 78, 2 },
{ 79, 2 }, { 80, 2 }, { 81, 2 }, { 82, 2 }, { 83, 3 }, { 84, 3 },
{ 85, 2 }, { 86, 2 }, { 87, 2 }, { 88, 2 }, { 89, 2 }, { 95, 2 },
{ 96, 2 }, { 97, 2 }, { 105, 2 }, { 106, 2 }, { 107, 2 },
{ 108, 2 }, { 110, 2 }, { 111, 2 }, { 112, 2 }, { 113, 2 },
{ 114, 2 }, { 115, 2 }, { 116, 2 }, { 117, 2 }, { 130, 3 },
{ 133, 2 }, { 135, 3 }, { 136, 2 }, { 137, 2 }, { 138, 2 },
{ 141, 2 }, { 142, 2 }, { 143, 2 }, { 144, 2 }, { 146, 2 },
{ 147, 2 }, { 148, 2 }, { 149, 2 }, { 150, 2 }, { 269, 2 },
{ 270, 2 }, { 271, 2 }, { 374, 2 }, { 397, 2 }, { 446, 2 },
{ 667, 3 }, { 677, 3 }, { 742, 4 }, { 752, 2 }, { 839, 2 },
{ 840, 2 }, { 852, 2 }, { 853, 2 }, { 854, 2 }, { 855, 2 },
{ 856, 2 }, { 857, 2 }, { 858, 2 }, { 859, 2 }, { 860, 2 },
{ 861, 2 }, { 862, 2 }, { 863, 2 }, { 864, 2 }, { 865, 2 },
{ 866, 2 }, { 867, 2 }, { 868, 2 }, { 869, 2 }, { 870, 2 },
{ 871, 2 }, { 873, 2 }, { 874, 2 }, { 875, 2 }, { 876, 2 },
{ 879, 2 }, { 880, 2 }, { 899, 2 }, { 909, 3 }, { 911, 3 },
{ 934, 3 }, { 939, 2 }, { 941, 4 }, { 950, 2 }, { 955, 2 },
{ 978, 2 }, { 986, 2 }, { 987, 2 }, { 991, 2 }, { 997, 3 },
{ 998, 3 }, { 999, 3 }, { 1000, 3 }, { 1003, 2 }, { 1005, 2 },
{ 1010, 2 }, { 1047, 2 }, { 1052, 2 }, { 1053, 2 }, { 1069, 2 },
{ 1095, 2 }, { 1096, 2 }, { 1097, 2 }, { 1098, 2 }, { 1099, 2 },
{ 1100, 2 }, { 1115, 2 }, { 1116, 2 }, { 1117, 2 }, { 1125, 3 },
{ 1126, 2 }, { 1127, 2 }, { 1128, 2 }, { 1129, 2 }, { 1135, 2 },
{ 1136, 2 }, { 1137, 2 }, { 1139, 2 }, { 1151, 2 }, { 1153, 2 },
{ 1154, 3 }, { 1155, 4 }, { 1156, 2 }, { 1157, 4 }, { 1158, 5 },
{ 1159, 5 }, { 1160, 5 }, { 1172, 3 }, { 1173, 3 }, { 1179, 2 },
{ 1180, 2 }, { 1181, 2 }, { 1195, 2 }, { 1196, 2 }, { 1197, 2 },
{ 1198, 2 }, { 1213, 2 }, { 1222, 2 }, { 1224, 2 }, { 1326, 2 },
{ 1328, 2 }, { 1329, 2 }, { 1330, 2 }, { 1335, 2 }, { 1341, 2 },
{ 1342, 2 }, { 1343, 2 }, { 1344, 2 }, { 1345, 2 }, { 1346, 2 },
{ 1347, 2 }, { 1348, 3 }, { 1349, 3 }, { 1350, 3 }, { 1351, 3 },
{ 1352, 3 }, { 1353, 3 }, { 1354, 3 }, { 1355, 3 }, { 1356, 3 },
{ 1373, 2 }, { 1431, 2 }, { 1432, 2 }, { 1438, 2 }, { 1459, 2 },
{ 1460, 2 }, { 1461, 2 }, { 1462, 2 }, { 1472, 3 }, { 1505, 2 },
{ 1506, 2 }, { 1507, 2 }, { 1508, 2 }, { 1509, 2 }, { 1516, 3 },
{ 1521, 2 }, { 1522, 2 }, { 1542, 3 }, { 1555, 2 }, { 1556, 2 },
{ 1558, 2 }, { 1559, 2 }, { 1575, 2 }, { 1578, 3 }, { 1580, 2 },
{ 1581, 2 }, { 1582, 2 }, { 1583, 2 }, { 1584, 2 }, { 1585, 2 },
{ 1586, 2 }, { 1587, 2 }, { 1588, 2 }, { 1589, 2 }, { 1590, 4 },
{ 1591, 4 }, { 1592, 4 }, { 1600, 2 }, { 1601, 2 }, { 1602, 2 },
{ 1603, 2 }, { 1604, 2 }, { 1605, 2 }, { 1606, 2 }, { 1607, 2 },
{ 1608, 3 }, { 1609, 3 }, { 1610, 3 }, { 1611, 3 }, { 1612, 2 },
{ 1616, 2 }, { 1617, 2 }, { 1618, 2 }, { 1619, 2 }, { 1620, 2 },
{ 1621, 3 }, { 1627, 2 }, { 1628, 2 }, { 1631, 2 }, { 1632, 2 },
{ 1653, 2 }, { 1654, 2 }, { 1655, 2 }, { 1656, 2 }, { 1657, 2 },
{ 1676, 2 }, { 1677, 2 }, { 1681, 2 }, { 1689, 3 }, { 1691, 2 },
{ 1693, 2 }, { 1719, 2 }, { 1720, 2 }, { 1721, 2 }, { 1722, 2 },
{ 1723, 2 }, { 1728, 2 }, { 1730, 2 }, { 1731, 2 }, { 1732, 2 },
{ 1733, 2 }, { 1734, 2 }, { 1735, 2 }, { 1736, 2 }, { 1737, 2 },
{ 1738, 2 }, { 1739, 3 }, { 1740, 3 }, { 1741, 2 }, { 1742, 3 },
{ 1743, 3 }, { 1744, 3 }, { 1745, 2 }, { 1746, 2 }, { 1747, 3 },
{ 1748, 3 }, { 1750, 2 }, { 1766, 2 }, { 1767, 2 }, { 1768, 2 },
{ 1778, 2 }, { 1779, 2 }, { 1780, 2 }, { 1781, 2 }, { 1782, 2 },
{ 1783, 2 }, { 1784, 2 }, { 1785, 2 }, { 1786, 2 }, { 1787, 2 },
{ 1792, 2 }, { 1802, 2 }, { 1803, 2 }, { 1804, 2 }, { 1811, 2 },
{ 1812, 2 }, { 1813, 2 }, { 1821, 2 }, { 1828, 2 }, { 1873, 2 },
{ 1943, 2 }, { 1944, 2 }, { 1945, 2 }, { 1946, 2 }, { 1951, 2 },
{ 1952, 2 }, { 1953, 2 }, { 1954, 2 }, { 1955, 2 }, { 1956, 2 },
{ 1970, 2 }, { 1971, 2 }, { 1990, 2 }, { 1993, 2 }, { 1996, 2 },
{ 1998, 2 }, { 1999, 2 }, { 2000, 2 }, { 2022, 3 }, { 2033, 2 },
{ 2038, 2 }, { 2039, 2 }, { 2040, 2 }, { 2041, 2 }, { 2042, 2 },
{ 2043, 2 }, { 2044, 2 }, { 2045, 2 }, { 2046, 2 }, { 2047, 2 },
{ 2048, 2 }, { 2049, 2 }, { 2050, 2 }, { 2051, 2 }, { 2052, 2 },
{ 2053, 2 }, { 2054, 2 }, { 2055, 2 }, { 2056, 2 }, { 2057, 2 },
{ 2060, 3 }, { 2063, 2 }, { 2064, 2 }, { 2065, 2 }, { 2240, 2 },
{ 2252, 2 }, { 2254, 2 }, { 2255, 2 }, { 2289, 2 }, { 2317, 2 },
{ 2417, 2 }, { 2418, 2 }, { 2419, 2 }, { 2434, 2 }, { 2452, 2 },
{ 2453, 2 }, { 2482, 2 }, { 2534, 3 }, { 2554, 3 }, { 2555, 3 },
{ 2556, 3 }, { 2557, 3 }, { 2558, 3 }, { 2559, 3 }, { 2560, 3 },
{ 2561, 3 }, { 2562, 3 }, { 2563, 3 }, { 2629, 2 }, { 2630, 2 },
{ 2631, 3 }, { 2632, 3 }, { 2637, 2 }, { 2640, 2 }, { 2641, 3 },
{ 2642, 5 }, { 2644, 2 }, { 2651, 2 }, { 2722, 2 }, { 2723, 2 },
{ 2736, 2 }, { 2737, 2 }, { 2739, 3 }, { 2740, 3 }, { 2741, 4 },
{ 2742, 4 }, { 2743, 5 }, { 2744, 5 }, { 2745, 5 }, { 2783, 3 },
{ 2801, 2 }, { 2803, 3 }, { 2804, 2 }, { 2805, 2 }, { 2806, 2 },
{ 2809, 2 }, { 2810, 2 }, { 2811, 2 }, { 2812, 2 }, { 2813, 2 },
{ 2814, 2 }, { 2815, 2 }, { 2849, 2 }, { 2850, 2 }, { 2880, 2 },
{ 2881, 3 }, { 2882, 3 }, { 2883, 3 }, { 2885, 2 }, { 2886, 2 },
{ 2889, 2 }, { 2890, 2 }, { 2919, 3 }, { 2920, 3 }, { 2921, 3 },
{ 3051, 2 }, { 3052, 2 }, { 3053, 2 }, { 3054, 2 }, { 3055, 2 },
{ 3056, 2 }, { 3058, 2 }, { 3063, 2 }, { 3064, 2 }, { 3066, 2 },
{ 3068, 3 }, { 3069, 3 }, { 3070, 3 }, { 3071, 3 }, { 3072, 2 },
{ 3076, 2 }, { 3077, 2 }, { 3100, 2 }, { 3101, 2 }, { 3103, 2 },
{ 3124, 2 }, { 3125, 2 }, { 3129, 2 }, { 3130, 2 }, { 3132, 2 },
{ 3133, 2 }, { 3134, 2 }, { 3135, 2 }, { 3140, 3 }, { 3154, 2 },
{ 3200, 3 }, { 3203, 3 }, { 3301, 3 }, { 3309, 2 }, { 3332, 5 },
{ 3333, 5 }, { 3334, 5 }, { 3337, 3 }, { 3338, 3 }, { 3339, 4 },
{ 3340, 3 }, { 3347, 2 }, { 3376, 2 }, { 3398, 2 }, { 3419, 2 },
{ 3420, 2 }, { 3421, 2 }, { 3423, 2 }, { 3443, 2 }, { 3444, 2 },
{ 3445, 3 }, { 3446, 2 }, { 3447, 2 }, { 3448, 3 }, { 3463, 2 },
{ 3464, 2 }, { 3466, 2 }, { 3467, 2 }, { 3468, 2 }, { 3469, 5 },
{ 3470, 5 }, { 3471, 5 }, { 3472, 5 }, { 3476, 3 }, { 3477, 3 },
{ 3484, 2 }, { 3493, 3 }, { 3494, 5 }, { 3497, 3 }, { 3498, 3 },
{ 3499, 3 }, { 3500, 3 }, { 3501, 3 }, { 3502, 3 }, { 3519, 2 },
{ 3530, 3 }, { 3556, 2 }, { 3558, 2 }, { 3585, 2 }, { 3586, 2 },
{ 3587, 2 }, { 3588, 2 }, { 3589, 3 }, { 3590, 3 }, { 3591, 3 },
{ 3592, 3 }, { 3593, 3 }, { 3594, 2 }, { 3599, 3 }, { 3600, 4 },
{ 3601, 5 }, { 3602, 3 }, { 3603, 3 }, { 3604, 4 }, { 3605, 5 },
{ 3606, 2 }, { 3607, 2 }, { 3608, 2 }, { 3609, 2 }, { 3610, 2 },
{ 3611, 2 }, { 3612, 3 }, { 3613, 3 }, { 3614, 3 }, { 3636, 2 },
{ 3637, 4 }, { 3645, 2 }, { 3646, 2 }, { 3647, 2 }, { 3649, 2 },
{ 3650, 2 }, { 3651, 2 }, { 3652, 2 }, { 3653, 2 }, { 3654, 2 },
{ 3655, 2 }, { 3656, 2 }, { 3657, 2 }, { 3658, 3 }, { 3659, 3 },
{ 3660, 3 }, { 3661, 2 }, { 3662, 2 }, { 3664, 2 }, { 3665, 2 },
{ 3666, 2 }, { 3667, 2 }, { 3668, 2 }, { 3669, 2 }, { 3670, 2 },
{ 3675, 2 }, { 3676, 2 }, { 3681, 3 }, { 3772, 2 }, { 3773, 2 },
{ 3774, 2 }, { 3775, 2 }, { 3776, 2 }, { 6142, 3 }, { 6143, 3 },
{ 6144, 3 }, { 6145, 3 }, { 3808, 3 }, { 3819, 3 }, { 3835, 5 },
{ 3836, 5 } };
}
@@ -0,0 +1,32 @@
package com.rebotted.game.npcs.drops;
import com.rebotted.util.Misc;
public class ItemDrop {
public int item_id, chance;
public int[] amounts;
ItemDrop (int item_id, int[]amounts, int chance) {
this.item_id = item_id;
this.amounts = amounts;
this.chance = chance;
}
ItemDrop (int item_id, int amount, int chance) {
this.item_id = item_id;
this.amounts = new int[]{amount, amount};
this.chance = chance;
}
public int getChance(){
return this.chance;
}
public int getItemID(){
return this.item_id;
}
public int getAmount(){
return Misc.random(this.amounts[0], this.amounts[1]);
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,250 @@
package com.rebotted.game.npcs.drops;
import com.rebotted.GameEngine;
import com.rebotted.game.items.ItemList;
import com.rebotted.util.Misc;
/**
* Npc Drops Handler
* @author Andrew (Mr Extremez)
*/
public class NPCDropsHandler {
public static int // found on http://runescape.wikia.com/wiki/Drop_rate
ALWAYS = 0,
COINSRATE = 3,
COMMON = 32,
UNCOMMON = 64,
RARE = 256,
VERY_RARE = 512;
/**
* Handles the npc drops for the npc names.
*
* @param NPCId
* @return
*/
public static final ItemDrop[] NPC_DROPS(String npc, int NPCId) {
if (npc.equals("man") || npc.equals("woman") || npc.equals("drunken_man")) {
return NPCDrops.man;
} else if (npc.equals("skeletal_wyvern")) {
return NPCDrops.wyvern;
} else if (npc.equals("dark_beast")) {
return NPCDrops.darkbeast;
} else if (npc.equals("shade")) {
return NPCDrops.shade;
} else if (npc.equals("watchman")) {
return NPCDrops.watchman;
} else if (npc.equals("river_troll")) {
return NPCDrops.rivertroll;
} else if (npc.equals("cave_crawler")) {
return NPCDrops.cavecrawler;
} else if (npc.equals("thief")) {
return NPCDrops.thief;
} else if (npc.equals("tzhaar-xil") || npc.equals("Tzhaar-Xil")) {
return NPCDrops.tzhaarxil;
} else if (npc.equals("tzhaar-ket") || npc.equals("Tzhaar-Ket")) {
return NPCDrops.tzhaarket;
} else if (npc.equals("tzhaar-hur") || npc.equals("Tzhaar-Hur")) {
return NPCDrops.tzhaarhur;
} else if (npc.equals("tzhaar-mej") || npc.equals("Tzhaar-Mej")) {
return NPCDrops.tzhaarmej;
} else if (npc.equals("tree_spirit")) {
return NPCDrops.treespirit;
} else if (npc.equals("unicorn")) {
return NPCDrops.unicorn;
} else if (npc.equals("evil_chicken")) {
return NPCDrops.evilchicken;
} else if (npc.equals("white_knight")) {
return NPCDrops.whiteknight;
} else if (npc.equals("black_knight")) {
return NPCDrops.blackknight;
} else if (npc.equals("bear")) {
return NPCDrops.bear;
} else if (npc.equals("jogre")) {
return NPCDrops.jogre;
} else if (npc.equals("ogre")) {
return NPCDrops.ogre;
} else if (npc.equals("chaos_druid")) {
return NPCDrops.chaosdruid;
} else if (npc.equals("jailer")) {
return NPCDrops.jailer;
} else if (npc.equals("fire_giant") || npc.equals("Fire_giant")) {
return NPCDrops.firegiant;
} else if (npc.equals("basilisk")) {
return NPCDrops.basilisk;
} else if (npc.equals("baby_blue_dragon") || npc.equals("baby_red_dragon") || npc.equals("baby_dragon")) {
return NPCDrops.babybluedragon;
} else if (npc.equals("red_dragon")) {
return NPCDrops.reddragon;
} else if (npc.equals("elf_warrior")) {
return NPCDrops.elfwarrior;
} else if (npc.equals("dagannoth")) {
return NPCDrops.dagannoth;
} else if (npc.equals("giant_mole")) {
return NPCDrops.giantmole;
} else if (npc.equals("dagannoth_supreme")) {
return NPCDrops.dagannothsupereme;
} else if (npc.equals("chaos_elemental")) {
return NPCDrops.chaoselemental;
} else if (npc.equals("dagannoth_prime")) {
return NPCDrops.dagannothprime;
} else if (npc.equals("dagannoth_rex")) {
return NPCDrops.daggannothrex;
} else if (npc.equals("monkey_guard")) {
return NPCDrops.monkeyguard;
} else if (npc.equals("monk")) {
return NPCDrops.monk;
} else if (npc.equals("abyssal_demon")) {
return NPCDrops.abyssaldemon;
} else if (npc.equals("pyrefiend")) {
return NPCDrops.pyrefiend;
} else if (npc.equals("aberrant_spectre")
|| npc.equals("aberrant_specter")
|| npc.equals("aberant_specter")) {
return NPCDrops.abberantspectre;
} else if (npc.equals("earth_warrior")) {
return NPCDrops.earthwarrior;
} else if (npc.equals("gargoyle")) {
return NPCDrops.gargoyle;
} else if (npc.equals("dust_devil") || npc.equals("dustdevil")) {
return NPCDrops.dustdevil;
} else if (npc.equals("cockatrice")) {
return NPCDrops.cockatrice;
} else if (npc.equals("infernal_mage")) {
return NPCDrops.infernalmage;
} else if (npc.equals("nechryael")) {
return NPCDrops.nechryael;
} else if (npc.equals("bloodveld")) {
return NPCDrops.bloodveld;
} else if (npc.equals("turoth")) {
return NPCDrops.turoth;
} else if (npc.equals("banshee")) {
return NPCDrops.banshee;
} else if (npc.equals("crawling_hand")) {
return NPCDrops.crawlinghand;
} else if (npc.equals("highwayman")) {
return NPCDrops.highwayman;
} else if (npc.equals("wild_dog") || npc.equals("battle_mage")) {
return NPCDrops.alwaysbones;
} else if (npc.equals("kalphite_queen")) {
return NPCDrops.kalphitequeen;
} else if (npc.equals("kalphite_worker")) {
return NPCDrops.kalphiteworker;
} else if (npc.equals("kalphite_soldier")) {
return NPCDrops.kalphitesoldier;
} else if (npc.equals("kalphite_guardian")) {
return NPCDrops.kalphiteguardian;
} else if (npc.equals("bat") || npc.equals("giant_bat")) {
return NPCDrops.bat;
} else if (npc.equals("bronze_dragon")) {
return NPCDrops.bronzedragon;
} else if (npc.equals("black_dragon")) {
return NPCDrops.blackdragon;
} else if (npc.equals("iron_dragon")) {
return NPCDrops.irondragon;
} else if (npc.equals("steel_dragon")) {
return NPCDrops.steeldragon;
} else if (npc.equals("moss_giant")) {
return NPCDrops.mossgiant;
} else if (npc.equals("greater_demon")) {
return NPCDrops.greaterdemon;
} else if (npc.equals("black_demon")) {
return NPCDrops.blackdemon;
} else if (npc.equals("dwarf")) {
return NPCDrops.dwarf;
} else if (npc.equals("jelly")) {
return NPCDrops.jelly;
} else if (npc.equals("rock_crab")) {
return NPCDrops.rockcrab;
} else if (npc.equals("rockslug")) {
return NPCDrops.rockslug;
} else if (npc.equals("king_black_dragon")) {
return NPCDrops.kingblackdragon;
} else if (npc.equals("green_dragon")) {
return NPCDrops.greendragon;
} else if (npc.equals("blue_dragon")) {
return NPCDrops.bluedragon;
} else if (npc.equals("goblin")) {
return NPCDrops.goblin;
} else if (npc.equals("lesser_demon") || npc.equals("Lesser_demon")
|| npc.equals("lesserdemon")) {
return NPCDrops.lesserdemon;
} else if (npc.equals("guard") || npc.equals("jail_guard")) {
return NPCDrops.guard;
} else if (npc.equals("al-kharid_warrior")) {
return NPCDrops.alkharidwarrior;
} else if (npc.equals("ice_warrior")) {
return NPCDrops.icewarrior;
} else if (npc.equals("kurask")) {
return NPCDrops.kurask;
} else if (npc.equals("ice_giant")) {
return NPCDrops.icegiant;
} else if (npc.equals("hobgoblin")) {
return NPCDrops.hobgoblin;
} else if (npc.equals("pirate")) {
return NPCDrops.pirate;
} else if (npc.equals("zombie")) {
return NPCDrops.zombie;
} else if (npc.equals("skeleton")) {
return NPCDrops.skeleton;
} else if (npc.equals("deadly_red_spider")) {
return NPCDrops.deadlyredspider;
} else if (npc.equals("rat")) {
return NPCDrops.rat;
} else if (npc.equals("imp")) {
return NPCDrops.imp;
} else if (npc.equals("cow") || npc.equals("cow_calf")) {
return NPCDrops.cow;
} else if (npc.equals("chicken") || npc.equals("rooster")) {
return NPCDrops.chicken;
} else if (npc.equals("hill_giant")) {
return NPCDrops.hillgiant;
} else if (npc.equals("giant_rat")) {
return NPCDrops.giantrat;
} else if (npc.equals("dark_wizard")) {
return NPCDrops.darkwizard;
} else {
return NPCDrops.DEFAULT;
}
}
/**
* Gets the item name
*
* @param ItemID
* @return
*/
public static int i(String ItemName) {
return getItemId(ItemName);
}
/**
* Item name main method
*
* @param itemName
* @return
*/
public static int getItemId(String itemName) {
for (ItemList i : GameEngine.itemHandler.ItemList) {
if (i != null) {
if (i.itemName.equalsIgnoreCase(itemName)) {
return i.itemId;
}
}
}
return -1;
}
/**
* Misc.random in shorter form
*
* @param random
* @return
*/
public static int r(int random) {
return Misc.random(random);
}
}
@@ -0,0 +1,50 @@
package com.rebotted.game.npcs.impl;
import com.rebotted.event.CycleEvent;
import com.rebotted.event.CycleEventContainer;
import com.rebotted.event.CycleEventHandler;
import com.rebotted.game.players.Player;
/**
* @author Tom
*/
public class MilkCow {
/**
* The empty bucket Id
*/
private static int BUCKET = 1925;
/**
* The bucket of milk Id
*/
private static int BUCKET_OF_MILK = 1927;
public static void milk(final Player player) {
if (!player.getItemAssistant().playerHasItem(BUCKET)) {
player.getPacketSender().sendMessage("You need a bucket in order to milk this cow.");
return;
} else {
player.startAnimation(2305);
player.milking = true;
CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() {
@Override
public void execute(CycleEventContainer container) {
player.getItemAssistant().deleteItem(BUCKET, 1);
player.getPacketSender().sendMessage("You milk the cow.");
player.getItemAssistant().addItem(BUCKET_OF_MILK, 1);
container.stop();
}
@Override
public void stop() {
player.milking = false;
}
}, 7);
return;
}
}
}
@@ -0,0 +1,91 @@
package com.rebotted.game.npcs.impl;
import com.rebotted.game.npcs.Npc;
import com.rebotted.game.npcs.NpcHandler;
import com.rebotted.game.players.Client;
import com.rebotted.game.players.Player;
public class Pets {
private final int[][] catArray = { { 3505, 7583 }, { 3506, 7584 },
{ 766, 1560 }, { 3507, 7585 }, { 765, 1559 }, { 764, 1558 },
{ 763, 1557 }, { 762, 1556 }, { 761, 1555 }, { 768, 1561 },
{ 769, 1562 }, { 770, 1563 }, { 771, 1564 }, { 772, 1565 },
{ 773, 1566 } };
public static final int[] CAT_ITEMS = { 1555, 1556, 1557, 1558, 1559, 1560,
1561, 1562, 1563, 1564, 1565, 7585, 7584 };
public void pickUp(Client c, int Type) {
for (Npc i : NpcHandler.npcs) {
if (i == null) {
continue;
}
}
for (Npc i : NpcHandler.npcs) {
if (i != null) {
if (i.npcType == Type) {
if (i.spawnedBy == c.playerId && i.spawnedBy > 0) {
i.absX = 0;
i.absY = 0;
i = null;
break;
}
}
}
}
}
public void pickUpClean(Player c, int id) {
for (int[] element : catArray) {
if (element[0] == id) {
c.getItemAssistant().addItem(element[1], 1);
}
}
for (Npc i : NpcHandler.npcs) {
if (i == null) {
continue;
}
if (i.npcType == id) {
i.absX = 0;
i.absY = 0;
}
}
c.hasNpc = false;
}
public static int summonItemId(int itemId) {
if (itemId == 1555) {
return 761;
} else if (itemId == 1556) {
return 762;
} else if (itemId == 1557) {
return 763;
} else if (itemId == 1558) {
return 764;
} else if (itemId == 1559) {
return 765;
} else if (itemId == 1560) {
return 766;
} else if (itemId == 1561) {
return 768;
} else if (itemId == 1562) {
return 769;
} else if (itemId == 1563) {
return 770;
} else if (itemId == 1564) {
return 771;
} else if (itemId == 1565) {
return 772;
} else if (itemId == 1566) {
return 773;
} else if (itemId == 7585) {
return 3507;
} else if (itemId == 7584) {
return 3506;
} else if (itemId == 7583) {
return 3505;
}
return 0;
}
}