I added Squeal of Fortune to matrix 718. Everything works except the discard button which I will try to fix in the future.
I extracted all of the code from rune-evo
Check it out here
This is what I did to add Squeal of Fortune to matrix 718
Keep in mind that I am backtracking from memory.I may forget some steps due to memory leak, but
will try my best to make this tutorial complete.
First you need SquealOfFortune.java and Spinsmanager.java.
I will post them below
/src/com/rs/game/content/SquealOfFortune.java
Its up to you to figure out where the code goes
Code:
package com.rs.game.player.content;
import java.io.Serializable;
import com.rs.game.item.Item;
import com.rs.game.item.ItemsContainer;
import com.rs.game.player.Player;
import com.rs.utils.Utils;
public class SquealOfFortune implements Serializable {
/**
* Generated SerialUID.
*/
private static final long serialVersionUID = -2063410653116131907L;
public static int INTERFACE_ID = 1253;
public static int TAB_INTERFACE_ID = 0;
private Player player;
private int prizeId;
private boolean needPrize;
private static int[] UN_COMMON = { 23718, 23722, 23726, 23730, 23734,
23738, 23742, 23746, 23750, 23754, 23758, 23762, 23766, 23770,
23775, 23779, 23783, 23787, 23791, 23795, 23799, 23803, 23807,
23811, 23815 };
private static int[] RARE = { 23719, 23723, 23727, 23731, 23735, 23739,
23743, 23747, 23751, 23755, 23759, 23763, 23767, 23771, 23776,
23780, 23784, 23788, 23792, 23796, 23800, 23804, 23808, 23812,
23816 };
private static int[] COMMON = { 23717, 23721, 23725, 23729, 23733, 23737,
23741, 23745, 23749, 23753, 23757, 23761, 23765, 23769, 23774,
23778, 23782, 23786, 23790, 23794, 23798, 23802, 23806, 23810,
23814 };
private static int[] SUPER_RARE = { 23720, 23724, 23728, 23732, 23736,
23740, 23744, 23748, 23752, 23756, 23760, 23764, 23768, 23773,
23777, 23781, 23785, 23789, 23793, 23797, 23801, 23805, 23809,
23812 };
public void one() {
player.getPackets().sendGameMessage("made it past the beginning()");
}
public static int superRare() {
return SUPER_RARE[(int) (Math.random() * SUPER_RARE.length)];
}
public static int rare() {
return RARE[(int) (Math.random() * RARE.length)];
}
public static int common() {
return COMMON[(int) (Math.random() * COMMON.length)];
}
public static int uncommon() {
return UN_COMMON[(int) (Math.random() * UN_COMMON.length)];
}
private ItemsContainer<Item> items;
private int[] superRare;
private int[] rares;
private int[] common;
private int[] uncommon;
public SquealOfFortune(Player player) {
items = new ItemsContainer<Item>(13, false);
}
public void setPlayer(Player player) {
this.player = player;
}
/**
* Starts the fortune. RARE - 0, 4, 8 COMMON - 1, 5, 7, 10, 12 UNCOMMON - 2,
* 6, 9, 11
*/
public void start() {
items.clear();
player.getPackets().sendConfigByFile(11026, player.getSpins()); //was commented out damx
player.getPackets().sendConfigByFile(11155, Utils.random(1, 5));
player.getPackets().sendGlobalConfig(1928, 1);
for (int i = 0; i < 14; i++) {
if (i == 8 || i == 4) {
items.add(new Item(rare()));
} else if (i == 0) {
items.add(new Item(superRare()));
} else if (i == 2 || i == 6 || i == 9 || i == 11) {
items.add(new Item(uncommon()));
} else if (i == 1 || i == 5 || i == 7 || i == 10 || i == 12) {
items.add(new Item(common()));
} else {
items.add(new Item(common()));
}
}
player.getPackets().sendWindowsPane(INTERFACE_ID, 0);
sendInterItems();
}
/**
* Sends the Items in the reward container.
*/
public void sendInterItems() {
player.getPackets().sendItems(665, items);
int random = Utils.random(15000);
if (random < 10) {
superRare = new int[] { 0, 4, 8 };
prizeId = (int) superRare[(int) (Math.random() * superRare.length)];
System.out.println("You just won super rare!");
// super rare
} else if (random < 50) {
rares = new int[] { 0, 4, 8 };
prizeId = (int) rares[(int) (Math.random() * rares.length)];
System.out.println("You just won rare!");
// rare
} else if (random < 5000) {
// uncommon
uncommon = new int[] { 2, 6, 9, 11 };
prizeId = (int) uncommon[(int) (Math.random() * uncommon.length)];
System.out.println("uncommon");
} else {
// common
common = new int[] { 1, 3, 5, 7, 10, 12 };
prizeId = (int) common[(int) (Math.random() * common.length)];
System.out.println("common");
}
}
public void handleButtons(Player player, int buttonId) {
long currentTime = Utils.currentTimeMillis();
if (buttonId == 93) {
if (player.getSpins() == 0) {
items.clear();
player.getPackets().sendWindowsPane(
player.getInterfaceManager().hasRezizableScreen() ? 746
: 548, 0);
player.getPackets().sendGlobalConfig(1790, 0);
player.getPackets().sendRunScript(5906);
return;
} //damx
if (player.getLockDelay() >= currentTime) {
return;
}
player.lock(11);
player.getPackets().sendGlobalConfig(1781, Utils.getRandom(13));
player.getPackets().sendConfigByFile(10860, prizeId);
player.getPackets().sendGlobalConfig(1790, 1);
player.getPackets().sendConfigByFile(10861, prizeId);
player.setSpins(player.getSpins() - 1); //damx
}
else if (buttonId == 106) {
player.getPackets().sendWindowsPane(
player.getInterfaceManager().hasRezizableScreen() ? 746
: 548, 0);
items.clear();
} else if (buttonId == 273) {
start();
} else if (buttonId == 192) {
player.getInventory().addItem(new Item(items.get(prizeId).getId()));
player.getPackets().sendConfigByFile(10861, 0);
player.getPackets().sendGlobalConfig(1790, 0);
player.getPackets().sendHideIComponent(1253, 240, false);
player.getPackets().sendHideIComponent(1253, 178, false);
player.getPackets().sendHideIComponent(1253, 225, false);
player.getPackets().sendRunScript(5906);
items.clear();
} else if (buttonId == 258) {
items.clear();
player.getPackets().sendWindowsPane(
player.getInterfaceManager().hasRezizableScreen() ? 746 : 548, 0);
player.getPackets().sendGlobalConfig(1790, 0);
player.getPackets().sendRunScript(5906);
}
}
}
/src/com/rs/game/SpinsManager.java
Code:
package com.rs.game.player;
import java.io.*;
import java.util.Enumeration;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import com.rs.game.player.Player;
public class SpinsManager {
private transient Player player;
private boolean gotSpins = false;
private boolean ipSucess = false;
public SpinsManager(Player player) {
this.player = player;
}
public void checkIP() {
try {
ipSucess = false;
File file1 = new File("./data/playersaves/ipcheckspin/" + getDate()
+ " " + player.getSession().getIP() + ".txt");
boolean success = file1.createNewFile();
if (success) {
ipSucess = true;
Writer output = null;
output = new BufferedWriter(new FileWriter(file1));
output.write("Username: " + player.getUsername() + "");
output.close();
} else {
return;
}
} catch (IOException e) {
}
}
public void addSpins() {
checkIP();
try {
gotSpins = false;
File file = new File("./data/playersaves/spins/" + getDate() + " "
+ player.getUsername() + ".txt");
boolean success = file.createNewFile();
if (success) {
if (ipSucess == false)
return;
gotSpins = true;
player.getPackets().sendGameMessage(
"You recieved a free spin from Squeal Of Fortune.");
player.setSpins(player.getSpins() + 20); //damx 2
Writer output = null;
output = new BufferedWriter(new FileWriter(file));
output.write("" + gotSpins + "");
output.close();
}
} catch (IOException e) {
}
}
public static String getDate() {
DateFormat dateFormat = new SimpleDateFormat("MM dd yyyy");
Date date = new Date();
String currentDate = dateFormat.format(date);
date = null;
dateFormat = null;
return currentDate;
}
}
Next add this code to Player.java
Code:
private transient SquealOfFortune sof;
private transient SpinsManager spinsManager;
private int spins;
sof.setPlayer(this);
sof = new SquealOfFortune(this);
public SquealOfFortune getSquealOfFortune() {
return sof;
}
public SpinsManager getSpinsManager() {
return spinsManager;
}
public void setSpins(int spins) {
this.spins = spins;
}
public int getSpins() {
return spins;
}
Add this code to ButtonHandler.java
Code:
import com.rs.game.player.content.SquealOfFortune;
import com.rs.game.Animation;
import com.rs.game.Graphics;
if (interfaceId == 1253) {
player.getSquealOfFortune().handleButtons(player, componentId);
}
if (interfaceId == 1252) {
if (componentId == 3) {
} else if (componentId == 5) {
player.closeInterfaces();
player.getPackets().sendGameMessage("The icon will appear the next time you log in");
}
}
if (interfaceId == 1252) {
if(componentId == 3) {
if(player.getSpins() == 0) {
player.getPackets().sendGameMessage("You dont have enough Squeal of fortune spins to play.");
return;
}
player.getSquealOfFortune().start();
}
if(componentId == 5) {
player.getPackets().closeInterface(player.getInterfaceManager().hasRezizableScreen() ? 11 : 0);
player.getPackets().sendGameMessage("You closed the Squeal of fortune interface, you can access SOF by clicking on the SOF tab and click Play.");
}
}
if (interfaceId == 1139) {
if(componentId == 18) {
if(player.getSpins() == 0) {
player.getPackets().sendGameMessage("You dont have enough Squeal Of Fortune spins to play.");
return;
}
player.getSquealOfFortune().start();
}
if(componentId == 23) {
player.getPackets().sendOpenURL("LINK HERE FOR BUY SPINS");
}
}
if (interfaceId == 548 && componentId == 68) {
player.getPackets().sendIComponentText(1139, 10, " "+ player.getSpins() +" ");
}
Next add this code to InterfaceManager.java
Code:
//not sure which of is need to lazy to fix just add all
import com.rs.game.tasks.WorldTask;
import com.rs.game.tasks.WorldTasksManager;
import com.rs.utils.Utils;
import java.lang.management.ManagementFactory;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;
public void sendFullScreenInterfaces() {
player.getPackets().sendWindowsPane(746, 0);
sendTab(21, 752);
sendTab(22, 751);
sendTab(15, 745);
sendTab(25, 754);
sendTab(195, 748);
sendTab(196, 749);
sendTab(197, 750);
sendTab(198, 747);
player.getPackets().sendInterface(true, 752, 9, 137);
if (player.getSpins() == 0) {
player.getPackets().closeInterface(player.getInterfaceManager().hasRezizableScreen() ? 11 : 0);
} else {
player.getInterfaceManager().sendTab(player.getInterfaceManager().hasRezizableScreen() ? 11 : 0, 1252);
}
sendTab(120, 550); // friend list
sendTab(119, 1139);
player.getPackets().sendGlobalConfig(823, 1);
sendTab(121, 1109); // 551 ignore now friendchat
sendTab(122, 1110); // 589 old clan chat now new clan chat
sendTab(125, 187); // music
sendTab(126, 34); // notes
sendTab(129, 182); // logout*/
}
public void sendFixedInterfaces() {
player.getPackets().sendWindowsPane(548, 0);
sendTab(161, 752);
sendTab(37, 751);
sendTab(23, 745);
sendTab(25, 754);
sendTab(155, 747);
sendTab(151, 748);
sendTab(152, 749);
sendTab(153, 750);
player.getPackets().sendInterface(true, 752, 9, 137);
player.getPackets().sendInterface(true, 548, 9, 167);
if (player.getSpins() == 0) {
player.getPackets().closeInterface(
player.getInterfaceManager().hasRezizableScreen() ? 11 : 0);
} else {
player.getInterfaceManager().sendTab(
player.getInterfaceManager().hasRezizableScreen() ? 11 : 0,
1252);
}
If you want the lamps to work when you rub them
add this code to InventoryOptionsHandler.java
This code is not mine. I extracted it from rune-evo then assembled it. I am a Java noob. My past experience with Perl and Linux bash is the reason why I can
assemble some one else's code. I will look into eclipse as you suggested. I will have to see it they have it for Linux
This code is not mine. I extracted it from rune-evo then assembled it. I am a Java noob. My past experience with Perl and Linux bash is the reason why I can
assemble some one else's code. I will look into eclipse as you suggested. I will have to see it they have it for Linux
Thanks for the information.
Why not just do an enum and then iterate through the enum as a pose to that horrible code.
Don't release something that isn't yours if you're not going to at least improve it.
Perhaps give him examples of how it can be done better
I think I helped him enough my friend, I do not feed help to people who release other peoples work.
He could even iterate it through in array although I'd suggest an enum.
Literally it would be very easy to iterate it through an array if he can not configure that he shouldn't be programming, let alone releasing other peoples work.
Although if this was posted in the help section I would be more then happy to help you improve the code.
I think I helped him enough my friend, I do not feed help to people who release other peoples work.
He could even iterate it through in array although I'd suggest an enum.
Literally it would be very easy to iterate it through an array if he can not configure that he shouldn't be programming, let alone releasing other peoples work.
Although if this was posted in the help section I would be more then happy to help you improve the code.
Help me improve this code? Lol, also i'm not sure what you mean with
Literally it would be very easy to iterate it through an array if he can not configure that he shouldn't be programming
You understand you don't want to waste resources when you don't need them besides it's completely redundant, on the other hand an enumerated type seems like a better alternative since all your wanting to do is hold a set of constants.
Also at OP, does this even compile..? (assuming there is no class declaration lol)
Code:
//not sure which of is need to lazy to fix just add all
import com.rs.game.tasks.WorldTask;
import com.rs.game.tasks.WorldTasksManager;
import com.rs.utils.Utils;
import java.lang.management.ManagementFactory;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;
public void sendFullScreenInterfaces() {
player.getPackets().sendWindowsPane(746, 0);
sendTab(21, 752);
sendTab(22, 751);
sendTab(15, 745);
sendTab(25, 754);
sendTab(195, 748);
sendTab(196, 749);
sendTab(197, 750);
sendTab(198, 747);
player.getPackets().sendInterface(true, 752, 9, 137);
if (player.getSpins() == 0) {
player.getPackets().closeInterface(player.getInterfaceManager().hasRezizableScreen() ? 11 : 0);
} else {
player.getInterfaceManager().sendTab(player.getInterfaceManager().hasRezizableScreen() ? 11 : 0, 1252);
}
~No honour among thieves.
[Only registered and activated users can see links. ]