I decided a little while ago I want to do some work on RSPS servers specifically on the Elvarg base. I already created a couple snippets which I have pulled into this thread. Mods you can delete the old posts I left hyperlinks above them. I plan to post many more snippets here using this thread.
Install guides for Elvarg servers are commented in the code itself.
I'm currently working on : Binging league and second life.
My current pace : Jumping ranks / Everyone thinks I'm someones alt.
Spoiler for Toys:
Spoiler for GFX Orb:
Sooo in my old server I had an epic housing system that kinda blew jag out of the water TBH anyways you could build an obelisk that allowed you to play with graphics this thing spewed projectiles all over the place. It had different configurable patterns and settings that modified how it behaved. This is a smaller itemized version of that. Unfortunately it seems I have forgotten how to send a projectile from one tile to another so this uses still GFX.
Features:
- Dialogue based settings menu allowing you to change the GFX, range(How far from the player the gfx can spawn), and duration(A timer system sends the gfx's in waves about 2 seconds apart duration adds waves).
- Item option allows players to open a website containing a GFX list.
- Spam safety. The orb is instantiated and has a boolean preventing scripting from infinitely spawning graphics objects.
Obvious potential improvements:
- Add projectiles.
- Add patterns of randomization.
- Add an OPTION to toggle between still GFX and Projectiles.
- Add speeds.
- Add configurable gfx count with gfx max variable.
Find:
if(equipmentSlot == -1) {
Server.getLogger().info("Attempting to equip item "+item.getId()+" which has no defined equipment slot.");
return;
}
Replace:
if(equipmentSlot == -1) {
if(player.getGFXOrb().handleFourthOption(player, item.getId()))
return;
Server.getLogger().info("Attempting to equip item "+item.getId()+" which has no defined equipment slot.");
return;
}
^^^ And never do that again. Actually you should fix that later but I'm to lazy right now.
*/
private static final int ORB_ID = 14000;
private static final int GFX_COUNT = 5;
private static final int MAX_RANGE = 5;
private static final int MAX_DURATION = 5;
private static final String GFX_LIST_URL = "https://everythingrs.com/tools/runescape/graphics";
private int range = 5;
private int gfxId = 280;
private int duration = 3;
private boolean active = false;
public boolean handleFirstOption(Player player, int itemId) {
if(itemId == ORB_ID) {
final int[] player_choice = {-1};
player.setDialogueOptions(new DialogueOptions() {
@Override
public void handleOption(Player player, int option) {
player_choice[0] = option;
player.getPacketSender().sendEnterAmountPrompt("Enter new value:");
}
});
Spoiler for Beacon Ring: Perhaps the most obnoxious, ill-concieved, innacurate item ever:
Well I set out to recreate the beacon ring which is used in the what lies below quest. You probably don't know or remember this but you used to be able to spam summon Zaff in the GE which was harmless but a ton of fun because people always freaked out. I wanted to recreate that... But failed miserably...
Problems:
- I can't remember the dialogues. D:
- I don't even remember what exactly happened when you used the ring.
- It has since changed.
- Not tested with scripting auto clickers.
To install: Place file in correct package, Open up item option handler or whatever the file that does that is called and add...
private static final int BEACON_RING = 11014;
private static final int GFX_ID = 110;
private static final int NPC_ID = 532;
private static final boolean zaffSpeaks = true;
private static final boolean euroMode = false; //Because why not XD
private static final String[] inLibraryDialogues = new String[2];
private static final String[] outLibraryDialogues = new String[2];
private static int zaffs = 0;
private static final int MAX_ZAFFS = 10;
static {
inLibraryDialogues[0] = "Nice Library.";
inLibraryDialogues[1] = "Bye Now.";
outLibraryDialogues[0] = euroMode ? "Oi this ain't the bloody Varrock library mate why have ye summoned me?" : "This isn't the Varrock library why have you summoned me here?";
outLibraryDialogues[1] = "Geologically challenged eh? I'll be on my way then...";
}
public static boolean handleRing(Player player, int itemId) {
if(itemId == BEACON_RING) {
summonZaff(player);
return true;
}
return false;
}
private static void summonZaff(Player player) {
if(zaffs >= MAX_ZAFFS)
return;
Position center = player.getPosition();
int xMod = Misc.getRandom(5);
int yMod = Misc.getRandom(5);
boolean xModNegative = Misc.getRandom(2) == 1;
boolean yModNegative = Misc.getRandom(2) == 1;
Position target = new Position(center.getX() + (xModNegative ? -xMod : xMod), center.getY() + (yModNegative ? -yMod : yMod), center.getZ());
NPC zaff = new NPC(NPC_ID, target);
zaff.setPositionToFace(center);
player.setPositionToFace(target);
Spoiler for Wardrobe: Drop-in configurable dialogue based robe set spawning object. :
My code basically allows you to turn any object with a click option into a vending machine for robes. By default all canifis and gnome robes (basic colored robes with no stats or significant value) are enabled and free. To add or remove the robes or change their price simply edit the enum. The dialogues are built off the enum values and will update automatically. This was designed to be added to Elvarg servers with minimal effort just drag and drop the file into the correct package (or edit the package) and add these two lines of code to your object handler. Don't forget to change the objectId from -1. For more details and redundant details open the spoiler and read the comments I left in the file.
/**
*
** What is this?:
*
* When I made my server I had an idea to create an interface for a wardrobe which you allow players to change the colors of their robes for a small fee.
* Well this is a far less fancy and uses dialogues to allow players to choose which robes they want to spawn.
*
**
*
* Features:
* - Item sets can be turned on or off and automatically added or removed from the dialogue menu by means of boolean in the enum.
* - Configurable buy price for each item set.
* - Easy to add more item sets.
* - Easy to install.
*
**
*
* Installing:
* - This was developed for elvarg if you have another source and want to adapt it figure it out.
* - Drop this file in Wardrobe.java at com.elvarg.game.model
* - Stick the following code in your object handler packet:
*
* if(Wardrobe.handleObjectClick(player, object))
* return;
*
* - The wardrobe is currently set to the edgeville bank booth ids. You may wish to change this.
*
**
*
* Why is my code so hideously cringy?:
* - I'm a hobbyist. Not a pro.
* - It was designed for light weight plug and play.
* - I habitually overcomplicate my life.
* - I wanted it fast and dirty.
* - Rewrite it yourself if you care to.
*
**
*/
/** Custom Settings **/
//For sets without gloves hats or boots (-1 in the enum) add these
//Default: Gloves: (False, Leather Gloves), Boots: (False, Leather Boots), Hat: (False, Unspecified)
private final boolean enAddGloves = false;
private final int addGloveId = 1059;
private final boolean enAddBoots = false;
private final int addBootId = 1061;
private final boolean enAddHat = false;
private final int addHatId = -1;
//Wardrobe Settings
private static final int wardrobeId = 6943;
private static final boolean checkPosition = false;
private static final Position[] wardrobePositions = new Position[] {
//If you want only certain wardrobes in certain locations to function place their positions here and turn checkPosition to true.
};
//Financial Settings
//The point at which the player is shown a confirmation dialogue before being allowed to purchase.
private static final int purchaseWarningThreshold = 25_000;
//Message Settings
private final boolean sendBlankSetMsg = true;
private final String blankSetMsg = "More sets coming soon.";
//If enabled will give wizard boots with the wizard sets. Warning: Could break economy. May wanna look into that first.
private final boolean giveWizardBoots = false;
/**
* The boolean value determines if the set shows up in the dialogue.
* The integers are hat, top, bottom, gloves, boots respectively.
* The last value is the price. 0 = free.
*/
private enum WardrobeData {
private int hatId;
private int topId;
private int bottomsId;
private int glovesId;
private int bootsId;
private boolean isActive;
private int price;
WardrobeData(int hatId, int topId, int bottomsId, int glovesId, int bootsId, boolean isActive, int price) {
this.hatId = hatId;
this.topId = topId;
this.bottomsId = bottomsId;
this.glovesId = glovesId;
this.bootsId = bootsId;
this.isActive = isActive;
this.price = price;
}
}
/**
* End Custom Settings everything beyond this point is necessary for script no touchy!
* **/
private static final Dialogue[] dialogues = new Dialogue[getActiveSets() / 4 + 1];
private static int optionPage = 1;
static {
for (int i = 0; i < dialogues.length; i++) {
dialogues[i] = createDialogue(i * 4);
}
}
private static int getActiveSets() {
int active = 0;
for (WardrobeData value : WardrobeData.values()) {
if(value.isActive)
active++;
}
return active;
}
private void confirmAdd(Player player, WardrobeData value) {
player.setDialogueOptions(new DialogueOptions() {
@Override
public void handleOption(Player player, int option) {
switch (option) {
case 1:
if(player.getInventory().contains(new Item(995, value.price))) {
player.getPacketSender().sendInterfaceRemoval();
player.getInventory().delete(995, value.price);
addItems(player, value);
} else {
player.getPacketSender().sendMessage("You don't have enough gold in your inventory to purchase the robes.");
player.getPacketSender().sendInterfaceRemoval();
}
break;
case 2:
player.getPacketSender().sendInterfaceRemoval();
break;
}
}
});
DialogueManager.start(player, new Dialogue() {
@Override
public DialogueType type() {
return DialogueType.OPTION;
}
@Override
public DialogueExpression animation() {
return DialogueExpression.DEFAULT;
}
@Override
public String[] dialogue() {
return new String[] {
"Confirm Purchase ("+Misc.insertCommasToNumber(String.valueOf(value.price))+")", "Nevermind",
};
}
});
}
private static Dialogue createDialogue(int lastOptionClicked) {
return new Dialogue() {
@Override
public DialogueType type() {
return DialogueType.OPTION;
}
@Override
public DialogueExpression animation() {
return DialogueExpression.DEFAULT;
}
@Override
public String[] dialogue() {
return refineDialogueOptionsForPage(lastOptionClicked);
}
};
}
private void openDialogueByLastOption(Player player, int lastOptionClicked) {
int toOpen = lastOptionClicked / 4;
if(dialogues.length > toOpen)
DialogueManager.start(player, dialogues[toOpen]);
}
/** Uses the last option clicked to determine what should be on the next page of options. **/
private static String[] refineDialogueOptionsForPage(int lastOptionClicked) {
ArrayList<String> options = buildAllDialogueOptionsFromEnum();
ArrayList<String> smallOptions = new ArrayList<>();
for (int i = 0; i < 4; i++) {
smallOptions.add(i, "---");
int index = (lastOptionClicked == 0 ? i : lastOptionClicked + i);
if(options.size() > index) {
smallOptions.set(i, options.get(index));
}
}
/** Calculates the amount of space required for the set. **/
private int getRequiredSlots(WardrobeData data) {
int slots = 0;
if(setHasHat(data))
slots++;
if(setHasTop(data))
slots++;
if(setHasBottoms(data))
slots++;
if(setHasGloves(data))
slots++;
if(setHasBoots(data))
slots++;
return slots;
}
private static ArrayList<String> buildAllDialogueOptionsFromEnum() {
ArrayList<String> strings = new ArrayList<>();
for (WardrobeData value : WardrobeData.values())
if(value.isActive)
strings.add(value.toString().toLowerCase().replace("_", " ") + " (" + Misc.insertCommasToNumber(String.valueOf(value.price)) + ")");
return strings;
}