So i finally figured how to make the boss pets summon if you get them as a drop. If that is all you are looking for skip ahead to step: 5. This will be the full tutorial on how to add everything, the npc the drop and a interface to access the pets . I will add 1 pet to show you how its done. Its the same steps for the rest.
I will suggest having a backup of your cache before doing any of this.
Tools you will need: Cache Editor: [Only registered and activated users can see links. ]
Step 1:
[SPOIL] Open up Frosty's Cache editor and load in your cache and select NPC and submit.
[/SPOIL]
Step 2:
[SPOIL] Now duplicate Npc 1 to the id you want your pet to be. For this post im using id 16000.
[/SPOIL]
Step 3:
[SPOIL] Now find the ID of the Boss you want to make a pet for. For this post i will be using King black dragon. so ID 50.
Now copy over the ints from King black dragon to 16000. I changed the Height to 22 and the Width to 22. Where it says Options change those to: null;null;null;null;null;
Make sure that there is 8 places in the model IDs. If your model only take up 4 spaces do -1;-1;-1;-1;
And with chat heads add a -1; before the real ID.
Save the npc and thats all the cache work done if you reload your server now and spawn npc 16000. You should see the npc you just added.
[/SPOIL]
Step 4:
[SPOIL] Now navigate to your source and find Pets.java
And add:
PET_NAME(-1, -1, -1, Npc ID, -1, -1, 0.0, 0),
Step 5:
[SPOIL] Now navigate to Player.java
And add:
Code:
private boolean KbdPet;
public boolean hasKbdPet() {
return KbdPet;
}
public void setKbdPet(boolean KbdPet) {
this.KbdPet = KbdPet;
}
[/SPOIL]
Step 6:
[SPOIL] Navigate to NPC.java
Search for "public void drop()"
In "try" method add:
Code:
if (this.getId() == 50 && Utils.getRandom(200) == 0) {//Kbd
if (killer.getPet() == null && killer.hasKbdPet() == false) {
killer.setKbdPet(true);
killer.getPetManager().spawnPet(Pets.KING_BLACK_DRAGON.getBabyItemId(), false);
killer.getPackets().sendGameMessage("You have now got yourself a new follower!");
return;
}
if (killer.hasKbdPet() == true) {
killer.getPackets().sendGameMessage(" ");
return;
} else {
killer.setKbdPet(true);
killer.getPackets().sendGameMessage("You have now got yourself a new follower! You can activate it with ;;bosspets.");
return;
}
}
[/SPOIL]
Step 7:
[SPOIL] Now to the interface. It doesnt have to be an interface, it can also be a command or dialogue. For this post im using interface 1312.
Navigate to your interfaces Folder and create a new .java
Name it "BossPets.java"
Now paste this:
Code:
package com.rs.game.player.content.interfaces;
import com.rs.game.player.Player;
import com.rs.utils.Utils;
import com.rs.Settings;
import com.rs.game.npc.pet.Pet;
import com.rs.game.player.content.pet.Pets;
import com.rs.game.player.content.pet.*;
public class BossPets {
public static void sendToggle(Player player) {
int INTER = 1312;
player.getInterfaceManager().sendInterface(INTER);
player.getPackets().sendIComponentText(INTER, 27, "Boss Pets");
player.getPackets().sendIComponentText(INTER, 38, "Toggle Kbd Pet");
player.getPackets().sendIComponentText(INTER, 46, " ");
player.getPackets().sendIComponentText(INTER, 54, " ");
player.getPackets().sendIComponentText(INTER, 62, " ");
player.getPackets().sendIComponentText(INTER, 70, " ");
player.getPackets().sendIComponentText(INTER, 78, " ");
player.getPackets().sendIComponentText(INTER, 86, " ");
player.getPackets().sendIComponentText(INTER, 94, " ");
player.getPackets().sendIComponentText(INTER, 102, " ");
player.getPackets().sendIComponentText(INTER, 40, " ");
}
public static void handleButtons(Player player, int componentId) {
if (componentId == 35) {
if (player.hasKbdPet() == true && player.getPet() == null) {
player.getPetManager().spawnPet(Pets.KING_BLACK_DRAGON.getBabyItemId(), false);
player.getPackets().sendGameMessage("You summon your Kbd pet");
} else if (player.hasKbdPet() == true && player.getPet() != null) {
player.getPackets().sendGameMessage("You need to dismiss your current follower.");
} else {
player.getPackets().sendGameMessage("You dont have this pet.");
}
}
if (componentId == 43) {
player.getPackets().sendGameMessage("43");
}
if (componentId == 51) {
player.getPackets().sendGameMessage("51");
}
if (componentId == 59) {
player.getPackets().sendGameMessage("59");
}
if (componentId == 67) {
player.getPackets().sendGameMessage("67");
}
if (componentId == 75) {
player.getPackets().sendGameMessage("75");
}
if (componentId == 83) {
player.getPackets().sendGameMessage("83");
}
if (componentId == 91) {
player.getPackets().sendGameMessage("91");
}
if (componentId == 99) {
player.getPackets().sendGameMessage("99");
}
if (componentId == 70) {
player.getPackets().sendGameMessage("70");
}
if (componentId == 69) {
player.getPackets().sendGameMessage("69");
}
}
}
[/SPOIL]
Step 8:
[SPOIL] Now navigate to ButtonHandler.java
and add this:
Code:
import com.rs.game.player.content.interfaces.BossPets;
if (interfaceId == 1312) {
BossPets.handleButtons(player, componentId);
}
[/SPOIL]
Step 9:
[SPOIL] Now to access your new interface. You can either add it to an object, npc or command. For this post im adding it to a command.
Navigate to regular.java or commands.java, depends on your source.
And add this:
Code:
import com.rs.game.player.content.interfaces.BossPets;
if (cmd[0].equals("bosspets")) {
BossPets.sendToggle(player);
return true;
}
[/SPOIL]
It is now all complete :-)
Preview:
[SPOIL] For this preview i removed the randomizer and added it to a easier NPC.
[/SPOIL]
Please feel free to ask if you have any questions or if something doesnt work for you, i will try my best to help out.
I don't understand why you'd make this a toggle-able thing when you can just use actual pet 'items' just like Jad pet has for example. Other than that part, everything displayed has already been released on numerous occasions. I'd still like an explanation of that question though as it makes no sense whatsoever. Also, this'd look VERY clumsy if one were to do say.. 50 boss pets.
EDIT:
Also, this is complete and utter nonsense:
Code:
if (componentId == 43) {
player.getPackets().sendGameMessage("43");
}
if (componentId == 51) {
player.getPackets().sendGameMessage("51");
}
if (componentId == 59) {
player.getPackets().sendGameMessage("59");
}
if (componentId == 67) {
player.getPackets().sendGameMessage("67");
}
if (componentId == 75) {
player.getPackets().sendGameMessage("75");
}
if (componentId == 83) {
player.getPackets().sendGameMessage("83");
}
if (componentId == 91) {
player.getPackets().sendGameMessage("91");
}
if (componentId == 99) {
player.getPackets().sendGameMessage("99");
}
if (componentId == 70) {
player.getPackets().sendGameMessage("70");
}
if (componentId == 69) {
player.getPackets().sendGameMessage("69");
}
Could've just gone with
player.getPackets().sendGameMessage("" + componentId);
Last edited by Kris; 02-13-2017 at 12:57 AM.
Reason: Found another 'major' mistake.
I don't understand why you'd make this a toggle-able thing when you can just use actual pet 'items' just like Jad pet has for example. Other than that part, everything displayed has already been released on numerous occasions. I'd still like an explanation of that question though as it makes no sense whatsoever. Also, this'd look VERY clumsy if one were to do say.. 50 boss pets.
EDIT:
Also, this is complete and utter nonsense:
Code:
if (componentId == 43) {
player.getPackets().sendGameMessage("43");
}
if (componentId == 51) {
player.getPackets().sendGameMessage("51");
}
if (componentId == 59) {
player.getPackets().sendGameMessage("59");
}
if (componentId == 67) {
player.getPackets().sendGameMessage("67");
}
if (componentId == 75) {
player.getPackets().sendGameMessage("75");
}
if (componentId == 83) {
player.getPackets().sendGameMessage("83");
}
if (componentId == 91) {
player.getPackets().sendGameMessage("91");
}
if (componentId == 99) {
player.getPackets().sendGameMessage("99");
}
if (componentId == 70) {
player.getPackets().sendGameMessage("70");
}
if (componentId == 69) {
player.getPackets().sendGameMessage("69");
}
Could've just gone with
player.getPackets().sendGameMessage("" + componentId);
To be honest i just find it cleaner without any inventory items. And so i thought of putting them into a interface. i added all the other compnentIds so it was easier just to copy from king black dragon pet into the other once..
Originally Posted by TartarusPS
I like the idea of being able to toggle between pets. Nice release!
To be honest i just find it cleaner without any inventory items. And so i thought of putting them into a interface. i added all the other compnentIds so it was easier just to copy from king black dragon pet into the other once..
Thanks
Okay I don't understand how this is any cleaner but alright. I think you've mistaken it with the inventory models that most people do - such as a representative 'book' or 'pouch' or whatever.. However you can just use the actual NPC model as an inventory model in case you didn't know.
However regarding the second part, alright. But what's up with the if sentences? You don't need any. Just print the componentId variable as I showed up there. No need to over-do the simple things.
Okay I don't understand how this is any cleaner but alright. I think you've mistaken it with the inventory models that most people do - such as a representative 'book' or 'pouch' or whatever.. However you can just use the actual NPC model as an inventory model in case you didn't know.
However regarding the second part, alright. But what's up with the if sentences? You don't need any. Just print the componentId variable as I showed up there. No need to over-do the simple things.
Alright. Not going to bash or anything, just trying to give some constructive criticism on some parts of this snippet before some douchebag comes here and flames you like hell. I can see beginners doing it this way - I myself used to think similarly to how you've thought this through when I didn't know much about java. To each their own I suppose. Good job.
Alright. Not going to bash or anything, just trying to give some constructive criticism on some parts of this snippet before some douchebag comes here and flames you like hell. I can see beginners doing it this way - I myself used to think similarly to how you've thought this through when I didn't know much about java. To each their own I suppose. Good job.