Jump to content
Sign in to follow this  
The Awesome

#1 [667/7**] Armour Repair Stand..

Recommended Posts

Information

Hello everyone, I'm here to share a Armour Repair Stand with you, you can easily add more amour to be repaired.
The reason: I decided share this because most of the Server does not have a Armour Repair Stand, so you can not get your broken item repaired.

Guide

First, open your source and then find a folder called: 'Dialogues'.
Create a new Java file called 'Repair'.

[CODE]
package com.rs.game.player.dialogues;

import com.rs.game.player.content.RepairItems;

public class Repair extends Dialogue {
private int itemId;

[MENTION=15855]Over[/MENTION]ride
public void start() {
itemId = (Integer) parameters[1];
sendOptionsDialogue("What would you like to do?", "Repair my item!", "How much would it cost?","Nevermind..");

}

[MENTION=15855]Over[/MENTION]ride
public void run(int interfaceId, int componentId) {
int amount = player.getInventory().getItems().getNumberOf(itemId);
if (stage == -1) {
if (componentId == OPTION_1) {
if (amount == 1) {
RepairItems.Repair(player,itemId,1);
return;
}
sendOptionsDialogue("What would you like to do?", "Repair one item.","Repair X of your items", "Repair all items.");
stage = 2;
} else if (componentId == OPTION_2) {
RepairItems.CheckPrice(player,itemId,amount);
} else {
end();
}

} else if (stage == 2) {
if (componentId == OPTION_1) {
RepairItems.Repair(player,itemId,1);
} else if (componentId == OPTION_2) {
player.getTemporaryAttributtes().put("Repair",
Integer.valueOf(0));
player.getTemporaryAttributtes().put("Ritem", itemId);
player.getPackets().sendRunScript(108,
new Object[] { "You have "+amount+" items that need to be repaired, How many would you like to repair?" });
end();
} else {
RepairItems.Repair(player,itemId,amount);
}
}
}

[MENTION=15855]Over[/MENTION]ride
public void finish() {

}
}
[/CODE]

After you have added the go to DiallogueHandler.Java and add this:
[CODE]
handledDialogues.put("Repair", (Class<Dialogue>) Class.forName(Repair.class.getCanonicalName()));
[/CODE]

Ok after you have done it, you should find a folder named: 'Content.
Then you need to add a java file called 'RepairItems'. And then add:
[CODE]
package com.rs.game.player.content;

import java.util.HashMap;
import java.util.Map;
import java.text.DecimalFormat;
import com.rs.game.item.Item;
import com.rs.game.player.Player;

public class RepairItems {

public enum BrokenItems {
GUTHANS_HELM(4908, 4724, 100000),

GUTHANS_PLATEBODY(4920, 4738, 100000),

GUTHANS_PLATESKIRT(4926, 4730, 100000),

GUTHANS_WARSPEAR(4914, 4726, 100000),

AHRIMS_HOOD(4860, 4708, 100000),

AHRIMS_STAFF(4866, 4710, 100000),

AHRIMS_ROBE_TOP(4872, 4712, 100000),

AHRIMS_ROBE_SKIRT(4878, 4714, 100000),

DHAROKS_HELM(4884, 4716, 100000),

DHAROKS_GREATAXE(4890, 4718, 100000),

DHAROKS_PLATEBODY(4896, 4720, 100000),

DHAROKS_PLATELEGS(4902, 4722, 100000),

KARILS_COIF(4932, 4732, 100000),

KARILS_CROSSBOW(4938, 4734, 100000),

KARILS_TOP(4944, 4736, 100000),

KARILS_SKIRT(4950, 4738, 100000),

TORAGS_HELM(4956, 4745, 100000),

TORAGS_HAMMER(4962, 4747, 100000),

TORAGS_PLATEBODY(4968, 4749, 100000),

TORAGS_PLATELEGS(4974, 4751, 100000),

VERACS_HELM(4980, 4753, 100000),

VERACS_FLAIL(4968, 4755, 100000),

VERACS_BRASSARD(4992, 4757, 100000),

VERACS_PLATESKIRT(4998, 4759, 100000),

TORVA_HELM(20138, 20135, 2000000),

TORVA_PLATE(20142, 20139, 2000000),

TORVA_LEGS(20146, 20143, 2000000),

TORVA_GLOVES(24979, 24977, 2000000),

TORVA_BOOTS(24985, 24983, 2000000),

PERNIX_COWL(20150, 20147, 1500000),

PERNIX_BODY(20154, 20151, 1500000),

PERNIX_CHAPS(20158, 20155, 1500000),

PERNIX_GLOVES(24976, 24974, 1500000),

PERNIX_BOOTS(24991, 24989, 1500000),

ZARYTE_BOW(20174, 20171, 2000000),

VIRTUS_MASK(20162, 20159, 1000000),

VIRTUS_TOP(20166, 20163, 1000000),

VIRTUS_LEGS(20170, 20167, 1000000),

VIRTUS_GLOVES(24982, 24980, 1000000),

VIRTUS_BOOTS(24988, 24986, 1000000);

private int id;
private int id2;
private int Price;

private static Map<Integer, BrokenItems> BROKENITEMS = new HashMap<Integer, BrokenItems>();

static {
for (BrokenItems brokenitems : BrokenItems.values()) {
BROKENITEMS.put(brokenitems.getId(), brokenitems);
}
}

public static BrokenItems forId(int id) {
return BROKENITEMS.get(id);
}

private BrokenItems(int id, int id2, int Price) {
this.id = id;
this.id2 = id2;
this.Price = Price;
}

public int getId() {
return id;
}

public int getId2() {
return id2;
}

public int getPrice() {
return Price;
}


}
public static void Repair(Player player,int itemId,int amount) {
final BrokenItems brokenitems = BrokenItems.forId(itemId);
Item item = new Item(brokenitems.getId(), 1);
int price = brokenitems.getPrice();
if (amount == 1) {
if (player.getInventory().containsItem(995, price)) {
player.getInventory().deleteItem(itemId, 1);
player.getInventory().deleteItem(995, price);
player.getInventory().addItem(brokenitems.getId2(), 1);
player.getDialogueManager().startDialogue("SimpleMessage","You have repaired your item("+item.getName()+") for "+getFormattedNumber(price)+" coins.");
return;
} else {
player.getDialogueManager().startDialogue("SimpleMessage","You dont have enough money to repair this item."+"You need "+getFormattedNumber(price)+" coins.");
return;
}
} else {
if (player.getInventory().containsItem(995, price * amount)) {
player.getInventory().deleteItem(itemId, amount);
player.getInventory().deleteItem(995, price * amount);
player.getInventory().addItem(brokenitems.getId2(), amount);
player.getDialogueManager().startDialogue("SimpleMessage","You have repaired your items("+amount+" X "+item.getName()+") for "+getFormattedNumber(price * amount)+" coins.");
return;
} else {
player.getDialogueManager().startDialogue("SimpleMessage","You dont have enough money to repair these items."+"You need "+getFormattedNumber(price * amount)+" coins.");
return;
}
}
}
public static void CheckPrice(Player player,int itemId, int amount) {
final BrokenItems brokenitems = BrokenItems.forId(itemId);
int price = brokenitems.getPrice();
player.getDialogueManager().startDialogue("SimpleNPCMessage",945,
"These items will cost you " +getFormattedNumber(price * amount)+" coins.");
return;
}
private static String getFormattedNumber(int amount) {
return new DecimalFormat("#,###,##0").format(amount).toString();
}

}
[/CODE]

Ok so to get the Armour Repair Stand to work you need to add this method in the folder named: 'ObjectHandler'.

Search for:
[CODE]'handleItemOnObject'. [/CODE]

Add this below.
[CODE]
} else if (object.getId() == 13715) {
if (BrokenItems.forId(itemId) == null) {
player.getDialogueManager().startDialogue("SimpleMessage","You can't repair this item.");
return;
}
player.getDialogueManager().startDialogue("Repair", 945, itemId);
return;
[/CODE]


Picture

By using your broken item on the 'Armour Repair',
will you get your armour repaired.
[IMG]http://i59.tinypic.com/2r70a6d.png[/IMG]


[I]Enjoy it.[/I]

Share this post


Link to post
Share on other sites
Looks alright, nice contribrution. :)

Share this post


Link to post
Share on other sites
This could have been done much easier. There was no need to create an enum to handle the id's etc. You could have just done something like this;

[code]
/**
*@author Format
*/
public int repairItem(int itemId) {

switch(itemId) {
case 4908: // Broken id
return 4724; // Fixed id
}
return -1;
}

public int getPrice(int itemId) {
switch (itemId) {
case 4908: // Item used (broken id)
return 10000; // Price
}
return 0;
}
[/code]

You could even do this

[code]
/**
*@author Format
*/
public int repairItem(String itemName) {

switch(itemName.toLowerCase();) {
case "guthan's helm 0": // Broken id
return 4724; // Fixed id
}
return -1;
}




public int getPrice(String itemName) {
switch (itemName.toLowerCase()) {
case "guthan's helm 0": // Item used (broken id)
return 10000; // Price
}
return 0;
}

[/code]
This is what I did for my Bob's Armour Repair system. But good job none the less.
Saves you writing an entire enum >.>

OT: Nice release. Edited by Format

Share this post


Link to post
Share on other sites
Sign in to follow this  

×