Cats/kalphite queen/random (#313)

- Did some work with the kalphite queen
This commit is contained in:
Mr Extremez
2019-12-22 14:59:26 -06:00
committed by Daniel Ginovker
parent 17e5e7ea5c
commit c5c1c2fc35
30 changed files with 372 additions and 1584 deletions
@@ -282,6 +282,26 @@ public class NpcCombat {
NpcHandler.npcs[i].attackType = 1;
}
switch (NpcHandler.npcs[i].npcType) {
case 1158://kq first form
int kqRandom = Misc.random(3);
if (kqRandom == 2) {
NpcHandler.npcs[i].projectileId = 280; //gfx
NpcHandler.npcs[i].attackType = 2;
NpcHandler.npcs[i].endGfx = 279;
} else {
NpcHandler.npcs[i].attackType = 0;
}
break;
case 1160://kq secondform
int kqRandom2 = Misc.random(3);
if (kqRandom2 == 2) {
NpcHandler.npcs[i].projectileId = 279; //gfx
NpcHandler.npcs[i].attackType = 1 + Misc.random(1);
NpcHandler.npcs[i].endGfx = 278;
} else {
NpcHandler.npcs[i].attackType = 0;
}
break;
case 2607:
NpcHandler.npcs[i].attackType = 1;
case 2591:
@@ -569,25 +589,17 @@ public class NpcCombat {
damage = c.playerLevel[GameConstants.HITPOINTS] - 1;
}
}
if (c.getPrayer().prayerActive[18]
&& !(NpcHandler.npcs[i].npcType == 2030)) { // protect
// from
// melee)
// {
// //
// protect
// from
// melee
if (c.getPrayer().prayerActive[18] && !(NpcHandler.npcs[i].npcType == 2030)) { // protect from melee
damage = 0;
} else if (c.getPrayer().prayerActive[18]
&& NpcHandler.npcs[i].npcType == 2030) {
} 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 (10 + Misc.random(MeleeData.calculateMeleeDefence(c)) > Misc.random(NpcHandler.npcs[i].attack)) {
if (NpcHandler.npcs[i].npcType == 1158 || NpcHandler.npcs[i].npcType == 1160)
damage = (damage / 2);
else
damage = 0;
}
}
if (c.playerLevel[3] - damage < 0) {
@@ -597,10 +609,11 @@ public class NpcCombat {
if (NpcHandler.npcs[i].attackType == 1) { // range
damage = Misc.random(NpcHandler.npcs[i].maxHit);
if (10 + Misc.random(c.getCombatAssistant()
.calculateRangeDefence()) > Misc
.random(NpcHandler.npcs[i].attack)) {
damage = 0;
if (10 + Misc.random(c.getCombatAssistant().calculateRangeDefence()) > Misc.random(NpcHandler.npcs[i].attack)) {
if (NpcHandler.npcs[i].npcType == 1158 || NpcHandler.npcs[i].npcType == 1160)
damage = (damage / 2);
else
damage = 0;
}
if (NpcData.cantKillYou(NpcHandler.npcs[i].npcType)) {
if (damage >= c.playerLevel[GameConstants.HITPOINTS]) {
@@ -618,8 +631,7 @@ public class NpcCombat {
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)) {
if (10 + Misc.random(c.getCombatAssistant().mageDef()) > Misc.random(NpcHandler.npcs[i].attack)) {
damage = 0;
magicFailed = true;
}
@@ -628,19 +640,23 @@ public class NpcCombat {
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(c.getPrayer().prayerActive[16]) { // protect from magic
if (NpcHandler.npcs[i].npcType == 1158) {
damage = (damage / 2);
} else {
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);
}
}
}
@@ -1,6 +1,8 @@
package com.rebotted.game.content.combat.npcs;
import com.rebotted.GameEngine;
import com.rebotted.game.npcs.NpcHandler;
import com.rebotted.game.players.Player;
/**
* Npc Emotes
@@ -163,7 +165,7 @@ public enum NpcEmotes {
return -1;
}
public static int getDeadEmote(int i) {
public static int getDeadEmote(Player player, int i) {
for (NpcEmotes e : NpcEmotes.values()) {
for (int f = 0; f < e.getNpcId().length; f++) {
if (NpcHandler.npcs[i].npcType == e.getNpcId()[f]) {
@@ -172,6 +174,12 @@ public enum NpcEmotes {
switch (NpcHandler.npcs[i].npcType) {
case 2745:
return 2654;
case 1158:
GameEngine.npcHandler.spawnSecondForm(player, i);
return 6242;
case 1160:
GameEngine.npcHandler.spawnFirstForm(player, i);
return 6233;
}
}
}
@@ -431,11 +431,11 @@ public class PestControl {
private void spawnNPC() {
//npcid, npcx, npcy, heightlevel, walking type, hp, att, def
for (int[] aPcNPCData : pcNPCData) {
GameEngine.npcHandler.spawnNpc2(aPcNPCData[0], aPcNPCData[1], aPcNPCData[2], 0, 0, 200, 0, 0, playersInGame() * 200);
GameEngine.npcHandler.spawnNpc2(aPcNPCData[0], aPcNPCData[1], aPcNPCData[2], 0, 0, 200, 0, 0, playersInGame() * 200, false);
}
for (int[] voidMonsters : voidMonsterData) {
//Server.npcHandler.spawnNpc2(voidMonsters[0], voidMonsters[1], voidMonsters[2], 0, 1, voidMonsters[NpcHandler.getNpcListHP(voidMonsters[0])], NpcHandler.getNpcListCombat(voidMonsters[0])/10, NpcHandler.getNpcListCombat(voidMonsters[0]), playersInGame() * 200);
GameEngine.npcHandler.spawnNpc2(voidMonsters[0], voidMonsters[1], voidMonsters[2], 0, 1, 500, 20, 200, 25);
GameEngine.npcHandler.spawnNpc2(voidMonsters[0], voidMonsters[1], voidMonsters[2], 0, 1, 500, 20, 200, 25, false);
}
}
}
@@ -1,6 +1,7 @@
package com.rebotted.game.dialogues;
import com.rebotted.GameConstants;
import com.rebotted.GameEngine;
import com.rebotted.game.content.quests.QuestAssistant;
import com.rebotted.game.content.quests.QuestRewards;
import com.rebotted.game.content.randomevents.FreakyForester;
@@ -3901,9 +3902,9 @@ public class DialogueHandler {
player.nextChat = 0;
break;
case 912:
player.getDialogueHandler().sendStatement(
"Catching rats is currently disabled.");
player.nextChat = 0;
GameEngine.npcHandler.catchRat(player.rememberNpcIndex);
player.getPacketSender().closeAllWindows();
player.nextChat = 0;
break;
case 913:
sendStatement("You shoo your cat away.");
@@ -59,11 +59,15 @@ public class Doors {
Doors d = getDoor(id, x, y, z);
if (d == null) {
//System.out.println("D: " + id + " null debug x: " + x + " y: " + y + ".");
return DoubleDoors.getSingleton().handleDoor(player, id, x, y, z);
}
//todo: improvment: if player manage to get to door then open the door.
if(player.distanceToPoint(x, y) > 1) return false;
if(player.distanceToPoint(x, y) > 1) {
//System.out.println("Door (single): " + id + " not in distance debug at x: " + x + " y: " + y + ".");
return false;
}
//Remove clipping for old door (gets added back in placeObject)
Region.removeClipping(x, y, z);
@@ -51,10 +51,12 @@ public class DoubleDoors {
DoubleDoors doorClicked = getDoor(id, x, y, z);
if (doorClicked == null) {
//System.out.println("Door: " + id + " null debug at x: " + x + " y: " + y + ".");
//GameEngine.objectHandler.placeObject(new Objects(-1, x, y, z, 0, 0, 0));
return true;
}
if (doorClicked.doorId > 12000) {
if (doorClicked.doorId > 15000) {
// System.out.println("Door: " + id + " clicking debug x: " + x + " y: " + y + ".");
return true; //nearly all of these are not opened
}
@@ -5,9 +5,9 @@ import com.rebotted.GameEngine;
import com.rebotted.game.content.minigames.castlewars.CastleWars;
import com.rebotted.game.npcs.NpcHandler;
import com.rebotted.game.players.Client;
import com.rebotted.game.players.MainFrameIDs;
import com.rebotted.game.players.Player;
import com.rebotted.game.players.PlayerHandler;
import com.rebotted.util.MainFrameIDs;
import com.rebotted.util.Misc;
public class ItemAssistant {
@@ -23,6 +23,7 @@ public class Npc {
public int summonedBy, size;
public int focusPointX, focusPointY, masterId;
public boolean turnUpdateRequired;
public int chasingRat = -1;
/**
* attackType: 0 = melee, 1 = range, 2 = mage
@@ -5,6 +5,7 @@ import com.rebotted.game.content.skills.core.Fishing;
import com.rebotted.game.content.skills.crafting.Tanning;
import com.rebotted.game.content.skills.thieving.Pickpocket;
import com.rebotted.game.content.traveling.Sailing;
import com.rebotted.game.npcs.impl.Pets;
import com.rebotted.game.players.Player;
import com.rebotted.game.players.PlayerAssistant;
import com.rebotted.game.shops.ShopAssistant;
@@ -21,6 +22,7 @@ public class NpcActions {
public void firstClickNpc(int npcType) {
c.clickNpcType = 0;
c.rememberNpcIndex = c.npcClickIndex;
c.npcClickIndex = 0;
Shops.dialogueShop(c, npcType);
if (Pickpocket.isNPC(c, npcType)) {
@@ -30,6 +32,15 @@ public class NpcActions {
if (Fishing.fishingNPC(c, npcType)) {
Fishing.fishingNPC(c, 1, npcType);
}
if (Pets.isCat(npcType)) {
if (NpcHandler.npcs[c.rememberNpcIndex].spawnedBy == c.playerId) {
c.getSummon().pickUpPet(c, c.summonId);
c.hasNpc = false;
c.summonId = -1;
} else {
c.getPacketSender().sendMessage("This is not your pet.");
}
}
switch (npcType) {
case 209:
c.getDialogueHandler().sendDialogues(3500, 209);
@@ -814,28 +825,6 @@ public class NpcActions {
}
break;
case 3506:
case 3507:
case 761:
case 760:
case 762:
case 763:
case 764:
case 765:
case 766:
case 767:
case 768:
case 769:
case 770:
case 771:
case 772:
case 773:
case 3505:
c.getSummon().pickUpClean(c, c.summonId);
c.hasNpc = false;
c.summonId = 0;
break;
case 804:
case 1041:
Tanning.sendTanningInterface(c);
@@ -996,9 +985,12 @@ public class NpcActions {
if (Fishing.fishingNPC(c, npcType)) {
Fishing.fishingNPC(c, 2, npcType);
}
if (npcType >= 761 && npcType <= 773 || npcType > 3504
&& npcType < 3508 && npcType != 767) {
c.getDialogueHandler().sendDialogues(908, npcType);
if (Pets.isCat(npcType)) {
if (NpcHandler.npcs[c.rememberNpcIndex].spawnedBy == c.playerId) {
c.getDialogueHandler().sendDialogues(908, npcType);
} else {
c.getPacketSender().sendMessage("This is not your pet.");
}
}
switch (npcType) {
@@ -1141,11 +1133,12 @@ public class NpcActions {
Pickpocket.attemptPickpocket(c, npcType);
return;
}
if (npcType >= 761 && npcType <= 773 && npcType != 767) {
if (NpcHandler.npcs[c.rememberNpcIndex].spawnedBy == c.playerId)
if (Pets.isCat(npcType)) {
if (NpcHandler.npcs[c.rememberNpcIndex].spawnedBy == c.playerId) {
c.getDialogueHandler().sendDialogues(910, npcType);
else
c.getPacketSender().sendMessage("This isn't your cat.");
} else {
c.getPacketSender().sendMessage("This is not your pet.");
}
}
switch (npcType) {
@@ -54,14 +54,6 @@ public class NpcData {
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;
@@ -256,6 +248,9 @@ public class NpcData {
**/
public static int getRespawnTime(int i) {
switch (NpcHandler.npcs[i].npcType) {
case 1158:
case 1160:
return -1;
case 2881:
case 2882:
case 2883:
@@ -7,6 +7,9 @@ import java.io.IOException;
import com.rebotted.GameConstants;
import com.rebotted.GameEngine;
import com.rebotted.event.CycleEvent;
import com.rebotted.event.CycleEventContainer;
import com.rebotted.event.CycleEventHandler;
import com.rebotted.game.content.combat.CombatConstants;
import com.rebotted.game.content.combat.npcs.NpcAggressive;
import com.rebotted.game.content.combat.npcs.NpcCombat;
@@ -19,6 +22,7 @@ import com.rebotted.game.content.randomevents.RandomEventHandler;
import com.rebotted.game.content.randomevents.RiverTroll;
import com.rebotted.game.npcs.drops.ItemDrop;
import com.rebotted.game.npcs.drops.NPCDropsHandler;
import com.rebotted.game.npcs.impl.Pets;
import com.rebotted.game.players.Client;
import com.rebotted.game.players.Player;
import com.rebotted.game.players.PlayerHandler;
@@ -33,6 +37,101 @@ public class NpcHandler {
public static int maxListedNPCs = 4000;
public static Npc npcs[] = new Npc[MAX_NPCS];
public static NpcList NpcList[] = new NpcList[maxListedNPCs];
public void spawnSecondForm(Player c, final int i) {
// npcs[i].gfx0(1055);
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);
container.stop();
}
@Override
public void stop() {
}
}, 15);
}
/**
* kq respawn first form
*/
public void spawnFirstForm(Player c, final int i) {
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);
container.stop();
}
@Override
public void stop() {
}
}, 15);
}
public void catchRat(final int npcIndex) {
int foundRat = -1;
for (int i = 0; i < MAX_NPCS; i++) {
if (npcs[i] == null || foundRat != -1) {
continue;
}
if(npcs[i].npcType == 47 && !npcs[i].isDead) {
if(goodDistance(npcs[npcIndex].absX, npcs[npcIndex].absY, npcs[i].absX, npcs[i].absY, 5)) {
foundRat = i;
continue;
}
}
}
final Client slaveOwner = (PlayerHandler.players[npcs[npcIndex].summonedBy] != null ? (Client) PlayerHandler.players[npcs[npcIndex].summonedBy] : null);
if(foundRat == -1) {
if(slaveOwner != null) {
slaveOwner.getPacketSender().sendMessage("The " + getNpcListName(NpcHandler.npcs[npcIndex].npcType) + " can't seem to find any rats nearby.");
}
} else {
npcs[npcIndex].chasingRat = foundRat;
boolean beatChance = (Misc.random(2) == 1 ? true : false);
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)) {
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)
slaveOwner.ratsCaught++;
if(slaveOwner.ratsCaught == Pets.RATS_NEEDED_TO_GROW) {
slaveOwner.getPacketSender().sendMessage("Your kitten has grown into a cat!");
int newNpcId = npcs[npcIndex].npcType+7;
int[] coords = {npcs[npcIndex].absX, npcs[npcIndex].absY, npcs[npcIndex].heightLevel};
spawnNpc3(slaveOwner, newNpcId, coords[0], coords[1], coords[2], 0, 120, 25, 200, 200, true, false, true);
npcs[npcIndex].absX = 0;
npcs[npcIndex].absY = 0;
npcs[npcIndex] = null;
//Spawns grown cat in spot of kitten.
slaveOwner.summonId = Pets.summonItemId(newNpcId);
slaveOwner.ratsCaught = 0;
}
npcs[npcIndex].chasingRat = -1;
} else {
if(slaveOwner != null)
slaveOwner.getPacketSender().sendMessage("The " + getNpcListName(NpcHandler.npcs[npcIndex].npcType) + " failed to catch the rat.");
npcs[npcIndex].chasingRat = -1;
}
container.stop();
}
@Override
public void stop() {
// TODO Auto-generated method stub
}
}, 4);
}
}
public NpcHandler() {
for (int i = 0; i < MAX_NPCS; i++) {
@@ -139,15 +238,6 @@ public class NpcHandler {
return 0;
}
public int npcSize(int i) {
switch (npcs[i].npcType) {
case 2883:
case 2882:
case 2881:
return 3;
}
return 0;
}
/**
* Summon npc, barrows, etc
@@ -201,7 +291,7 @@ public class NpcHandler {
npcs[slot] = newNPC;
}
public void spawnNpc2(int npcType, int x, int y, int heightLevel, int WalkingType, int HP, int maxHit, int attack, int defence) {
public void spawnNpc2(int npcType, int x, int y, int heightLevel, int WalkingType, int HP, int maxHit, int attack, int defence, boolean attackPlayer) {
// first, search for a free slot
int slot = -1;
for (int i = 1; i < MAX_NPCS; i++) {
@@ -225,6 +315,9 @@ public class NpcHandler {
newNPC.MaxHP = HP;
newNPC.maxHit = maxHit;
newNPC.attack = attack;
if (attackPlayer) {
newNPC.underAttack = true;
}
newNPC.defence = defence;
npcs[slot] = newNPC;
}
@@ -356,6 +449,13 @@ public class NpcHandler {
npcs[i].absX = slaveOwner.absX;
npcs[i].absY = slaveOwner.absY - 1;
}
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);
}
}
if (npcs[i].actionTimer > 0) {
npcs[i].actionTimer--;
@@ -385,7 +485,7 @@ public class NpcHandler {
}
}
if (npcs[i].spawnedBy > 0) { // delete summons npc
if (npcs[i].spawnedBy > 0) {
if (PlayerHandler.players[npcs[i].spawnedBy] == null
|| PlayerHandler.players[npcs[i].spawnedBy].heightLevel != npcs[i].heightLevel
|| PlayerHandler.players[npcs[i].spawnedBy].respawnTimer > 0
@@ -393,11 +493,10 @@ public class NpcHandler {
if (npcs[i].npcType == FightCaves.YT_HURKOT) {
Player c = ((Client)PlayerHandler.players[npcs[i].spawnedBy]);
int ranHeal = Misc.random(19);
if (ranHeal == 19)
int ranHeal = Misc.random(10);
if (ranHeal == 10)
FightCaves.healJad(c, i);
}
if (PlayerHandler.players[npcs[i].spawnedBy] != null) {
for (int o = 0; o < PlayerHandler.players[npcs[i].spawnedBy].barrowsNpcs.length; o++) {
if (npcs[i].npcType == PlayerHandler.players[npcs[i].spawnedBy].barrowsNpcs[o][0]) {
@@ -552,12 +651,11 @@ public class NpcHandler {
&& npcs[i].needRespawn == false) {
npcs[i].updateRequired = true;
npcs[i].facePlayer(0);
if (npcs[i].killedBy <= 0)
npcs[i].killedBy = NpcData.getNpcKillerId(i);
npcs[i].animNumber = NpcEmotes.getDeadEmote(i); // dead
// emote
Player c = (Client) PlayerHandler.players[npcs[i].killedBy];
if (c != null) {
if (npcs[i].killedBy <= 0)
npcs[i].killedBy = NpcData.getNpcKillerId(i);
npcs[i].animNumber = NpcEmotes.getDeadEmote(c, i); // dead emote
if (CombatConstants.COMBAT_SOUNDS
&& NpcHandler.npcs[i].npcType < 3177
&& NpcHandler.npcs[i].npcType > 3180) {
@@ -653,8 +751,7 @@ public class NpcHandler {
GameEngine.objectManager.removeObject(npcs[i].absX,
npcs[i].absY);
}
} else if (npcs[i].actionTimer == 0
&& npcs[i].needRespawn == true) {
} else if (npcs[i].actionTimer == 0 && npcs[i].needRespawn == true && npcs[i].npcType != 1158) {
if (npcs[i].spawnedBy > 0) {
npcs[i] = null;
} else {
@@ -735,6 +832,12 @@ public class NpcHandler {
public static boolean multiAttacks(int i) {
switch (npcs[i].npcType) {
case 1158: //kq
if (npcs[i].attackType == 2)
return true;
case 1160: //kq
if (npcs[i].attackType == 1)
return true;
case 2558:
return true;
case 2562:
@@ -1200,7 +1303,8 @@ public class NpcHandler {
}
public static void handleSpecialEffects(Player c, int i, int damage) {
if (npcs[i].npcType == 2892 || npcs[i].npcType == 2894) {
if (npcs[i].npcType == 2892 || npcs[i].npcType == 2894 || npcs[i].npcType == 1158
|| npcs[i].npcType == 1160) {
if (damage > 0) {
if (c != null) {
if (c.playerLevel[5] > 0) {
@@ -1226,6 +1330,8 @@ public class NpcHandler {
public static int getMaxHit(int i) {
switch (npcs[i].npcType) {
case 1158:
return 30;
case 2558:
if (npcs[i].attackType == 2) {
return 28;
@@ -1338,7 +1444,7 @@ public class NpcHandler {
for (int i = 0; i < maxListedNPCs; i++) {
if (NpcList[i] != null) {
if (NpcList[i].npcId == npcId) {
return NpcList[i].npcName;
return NpcList[i].npcName.replace("_", " ");
}
}
}
@@ -1408,6 +1514,9 @@ public class NpcHandler {
public boolean getNpcListAggressive(int npcId) {
return NPCDefinition.forId(npcId).isAggressive();
}
public int getNpcSize(int npcId) {
return NPCDefinition.forId(npcId).getSize();
}
}
@@ -1,91 +1,126 @@
package com.rebotted.game.npcs.impl;
import com.rebotted.GameEngine;
import com.rebotted.game.npcs.Npc;
import com.rebotted.game.npcs.NpcHandler;
import com.rebotted.game.players.Client;
import com.rebotted.game.players.Player;
import com.rebotted.game.players.PlayerSave;
import com.rebotted.world.clip.Region;
public class Pets {
public static final int RATS_NEEDED_TO_GROW = 10;
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 } };
//npc id, item id
private final static int[][] CATS = {
{ 3504, 7583 }, //hell kitten
{ 3506, 7584 }, //lazy hell kitten
{ 766, 1560 }, //pet kitten
{ 3507, 7585 }, //wily hellcat
{ 765, 1559 }, //pet kitten
{ 764, 1558 }, //pet kitten
{ 763, 1557 }, //pet kitten
{ 762, 1556 }, //pet kitten
{ 761, 1555 }, //pet kitten
{ 768, 1561 }, //pet cat
{ 769, 1562 }, //pet cat
{ 770, 1563 }, //pet cat
{ 771, 1564 }, //pet cat
{ 772, 1565 },//pet cat
{ 773, 1566 } //pet cat
};
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;
public static final int[] CAT_ITEMS = {
1555, 1556, 1557, 1558, 1559, 1560,
1561, 1562, 1563, 1564, 1565, 7585, 7583, 7584
};
public static boolean isCatItem(int itemId) {
for (int i = 0; i < CAT_ITEMS.length; i++) {
if (itemId == CAT_ITEMS[i]) {
return true;
}
}
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;
return false;
}
public static boolean isCat(int npcId) {
for (int i = 0; i < CATS.length; i++) {
if (npcId == CATS[i][0]) {
return true;
}
}
return false;
}
public static void dropPet(Player player, int itemId, int slot) {
if (player.hasNpc) {
player.getPacketSender().sendMessage("You already dropped your " + NpcHandler.getNpcListName(summonItemId(itemId)) + ".");
return;
}
player.getItemAssistant().deleteItem(itemId, slot, player.playerItemsN[slot]);
player.hasNpc = true;
player.getPacketSender().sendMessage("You drop your " + NpcHandler.getNpcListName(summonItemId(itemId)) + ".");
int offsetX = 0;
int offsetY = 0;
if (Region.getClipping(player.getX() - 1, player.getY(), player.heightLevel, -1, 0)) {
offsetX = -1;
} else if (Region.getClipping(player.getX() + 1, player.getY(), player.heightLevel, 1, 0)) {
offsetX = 1;
} else if (Region.getClipping(player.getX(), player.getY() - 1, player.heightLevel, 0, -1)) {
offsetY = -1;
} else if (Region.getClipping(player.getX(), player.getY() + 1, player.heightLevel, 0, 1)) {
offsetY = 1;
}
GameEngine.npcHandler.spawnNpc3(player, summonItemId(itemId), player.absX+offsetX, player.absY+offsetY, player.heightLevel, 0, 120, 25, 200, 200, false, false, true);
PlayerSave.saveGame(player);
}
public void quickPickup(Player player, int id) {
for (Npc i : NpcHandler.npcs) {
if (i == null) {
continue;
}
if (i.npcType == id) {
i.absX = 0;
i.absY = 0;
i = null;
}
}
}
public void pickUpPet(Player player, int id) {
if (player.getItemAssistant().hasFreeSlots(1)) {
for (Npc i : NpcHandler.npcs) {
if (i == null) {
continue;
}
if (i.npcType == id) {
player.startAnimation(827);
i.absX = 0;
i.absY = 0;
i = null;
for (int[] element : CATS) {
if (element[0] == id) {
player.getItemAssistant().addItem(element[1], 1);
}
}
}
}
} else {
player.getPacketSender().sendMessage("You do not have enough space in your inventory to do that.");
}
}
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;
for (int i = 0; i < CATS.length; i++) {
if (itemId == CATS[i][1]) {
return CATS[i][0];
}
}
return 0;
}
}
@@ -1611,12 +1611,12 @@ public class ObjectsActions {
// PARTY ROOM START
case 2417: // 26193 if falador
player.inPartyRoom = true;
//player.inPartyRoom = true;
PartyRoom.open(player);
break;
case 2416:
player.inPartyRoom = true;
//player.inPartyRoom = true;
PartyRoom.dropAll();
break;
@@ -0,0 +1,9 @@
package com.rebotted.game.players;
/**
* Easy access to common interface IDs
*/
public class MainFrameIDs {
public static final int DEPOSIT_BOX = 4465;
public static final int BANK = 5292; //Might be incorrect!!
}
@@ -512,7 +512,7 @@ public abstract class Player {
getPlayerAssistant().movePlayer(2657, 2639, 0);
}
if (hasNpc == true) {
getSummon().pickUpClean(this, summonId);
getSummon().pickUpPet(this, summonId);
}
if(GameEngine.ersSecret != null && !GameEngine.ersSecret.equals("") && this.playerRights < 2) {
@@ -600,7 +600,7 @@ public abstract class Player {
lastH = heightLevel;
CycleEventHandler.getSingleton().stopEvents(this);
if (hasNpc == true) {
getSummon().pickUpClean(this, summonId);
getSummon().pickUpPet(this, summonId);
}
if (forceLogout || System.currentTimeMillis() - logoutDelay > 2500) {
if (!isBot)
@@ -1270,7 +1270,7 @@ public abstract class Player {
lastPinSettings = -1, setPinDate = -1, changePinDate = -1,
deletePinDate = -1, firstPin, secondPin, thirdPin, fourthPin,
bankPin1, bankPin2, bankPin3, bankPin4, pinDeleteDateRequested,
rememberNpcIndex, lastLoginDate, selectedSkill, newHerb,
rememberNpcIndex, ratsCaught, lastLoginDate, selectedSkill, newHerb,
newItem, newXp, doingHerb, herbAmount, treeX, treeY, lastH,
cookingItem, cookingObject, summonId, npcId2 = 0, leatherType = -1,
weightCarried, teleotherType, rockX, rockY, itemUsing, tzKekTimer,
@@ -142,7 +142,7 @@ public class PlayerHandler {
players[i].lastY = players[i].absY;
players[i].lastH = players[i].heightLevel;
if (players[i].hasNpc == true) {
t.getSummon().pickUpClean(t, players[i].summonId);
t.getSummon().quickPickup(t, players[i].summonId);
}
if (players[i].duelStatus == 5) {
Client o = (Client) PlayerHandler.players[players[i].duelingWith];
@@ -213,7 +213,7 @@ public class PlayerHandler {
players[i].lastY = players[i].absY;
players[i].lastH = players[i].heightLevel;
if (players[i].hasNpc == true) {
t.getSummon().pickUpClean(t, players[i].summonId);
t.getSummon().quickPickup(t, players[i].summonId);
}
if (players[i].duelStatus == 5) {
Client o1 = (Client) PlayerHandler.players[players[i].duelingWith];
@@ -100,6 +100,9 @@ public class PlayerSave {
case "myBalls":
player.getCannon().myBalls = Integer.parseInt(token2);
break;
case "ratsCaught":
player.ratsCaught = Integer.parseInt(token2);
break;
case "cannonX":
player.cannonX = Integer.parseInt(token2);
break;
@@ -576,6 +579,8 @@ public class PlayerSave {
characterfile.newLine();
characterfile.write("lostCannon = " + player.lostCannon);
characterfile.newLine();
characterfile.write("ratsCaught = " + player.ratsCaught);
characterfile.newLine();
characterfile.write("cannonX = " + player.cannonX);
characterfile.newLine();
characterfile.write("cannonY = " + player.cannonY);