Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE]IronMan Modes[DO NOT MERGE] #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions 2006Redone Server/src/redone/game/content/IronMan.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package redone.game.content;

import redone.game.players.Client;

/**
*
* Holds Ironman configs and assisting methods
* @author Fritz (TheRedArmy - http://www.rune-server.ee/members/theredarmy/)
* @Dark98
*
*/
public class IronMan {

/**
* Mode ids and names
*/
public final static int IRONMAN_MODE = 1;
public final static int HC_IRONMAN_MODE = 2;
public final static int ULTIMATE_IRONMAN = 3;
public final static String[] MODE_NAMES = { "IronMan", "Hardcore IronMan", "Ultimate IronMan" };

/**
* Gets the player's current game type
* @param player - Player whose game type is being fetched
* @return - Player's game type
*/
public static int getMode(Client player) {
return player.ironMan;
}

/**
* Sets the players game type
* @param player - Player whose game type is being set
* @param mode - Game type player is being set to
*/
public static void setMode(Client player, int mode) {
player.ironMan = (mode);
}

/**
* Gets the player's game type name
* @param player - Player whose game type name is being fetched
* @return - Player's game type name
*/
public static String getModeName(Client player) {
return MODE_NAMES[getMode(player) - 1];
}

/**
* Exchanges items for notes and notes for items when items are used on a bank booth
* @param player - Player using item on bank booth
* @param item - Item being used on the bank booth
* @param objectID - Object item is being used on
*/
/*public static void exchangeNotes(Client player, Item item, int objectID) {
if (objectID != 26972 || !player.getItems().playerHasItem(item, 1))
return;
int amount = player.getItems().getItemAmount(item);
int freeSlots = player.getItems().freeSlots();
if (item.isNote()) {
amount = amount > freeSlots && amount != freeSlots + 1 ? freeSlots : amount;
player.getItems().deleteItem(item, amount);
player.getItems().addItem(ItemContainer.getItem(item.getId() - 1), amount);
player.sendMessage("You exchange your notes for items");
} else if (ItemContainer.getItem(item.getId() + 1).isNote()) {
player.getItems().deleteItem(item, amount);
player.getItems().addItem(ItemContainer.getItem(item.getId() + 1), amount);
player.sendMessage("You exchange your items for notes");
} else
player.sendMessage("This cannot be noted");
}*/
}
13 changes: 12 additions & 1 deletion 2006Redone Server/src/redone/game/content/minigames/Dueling.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import redone.Constants;
import redone.Server;
import redone.game.content.IronMan;
import redone.game.content.combat.prayer.PrayerDrain;
import redone.game.content.minigames.castlewars.CastleWars;
import redone.game.items.GameItem;
Expand All @@ -29,6 +30,7 @@ public Dueling(Client Client) {

public void requestDuel(int id) {
try {
Client o = (Client) PlayerHandler.players[id];
if (id == player.playerId) {
return;
}
Expand All @@ -39,14 +41,23 @@ public void requestDuel(int id) {
player.getActionSender().sendMessage("You can not stake currently.");
return;
}
if (IronMan.getMode(player) >= IronMan.IRONMAN_MODE) {
player.getActionSender().sendMessage("You cannot duel as a " + IronMan.getModeName(player) + ".");
resetDuel();
return;
}
if (IronMan.getMode(o) >= IronMan.IRONMAN_MODE) {
player.getActionSender().sendMessage(o.playerName + " is a " + IronMan.getModeName(o) + " and cannot duel.");
resetDuel();
return;
}
if (!player.inDuelArena()) {
player.getActionSender().sendMessage("You must be in the duel arena to do that.");
return;
}
resetDuel();
resetDuelItems();
player.duelingWith = id;
Client o = (Client) PlayerHandler.players[id];
if (o == null) {
return;
}
Expand Down
39 changes: 34 additions & 5 deletions 2006Redone Server/src/redone/game/dialogues/DialogueHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -5755,7 +5755,7 @@ public void sendDialogues(int dialogue, int npcId) {
"Lumbridge Guide or one of the Tutors - these can be found by",
"looking for the question mark icon on your mini-map. If you find",
"you are lost at any time, look for a signpost.");
player.nextChat = 3116;
player.nextChat = 3514;
player.canWalkTutorial = true;
break;

Expand Down Expand Up @@ -6595,10 +6595,39 @@ public void sendDialogues(int dialogue, int npcId) {
QuestRewards.blackKnightReward(player);
player.nextChat = 0;
break;

case 3514:
sendStatement("Please Choose Your GameMode");
player.nextChat = 3515;
player.dialogueAction = 3515;
break;
case 3515:
sendOption4("Regular", "IronMan", "Hardcore IronMan", "Ultimate IronMan");
break;
case 3516:
sendStatement3("You have Chosen Regular Mode.", "Are you sure this is the game mode you want?", "You won't be able to change this later on!");
player.nextChat = 3520;
player.dialogueAction = 3520;
break;
case 3517:
sendStatement3("You have Chosen IronMan Mode.", "Are you sure this is the game mode you want?", "You won't be able to change this later on!");
player.nextChat = 3520;
player.dialogueAction = 3520;
break;
case 3518:
sendStatement3("You have Chosen Hardcore IronMan Mode.", "Are you sure this is the game mode you want?", "You won't be able to change this later on!");
player.nextChat = 3520;
player.dialogueAction = 3520;
break;
case 3519:
sendStatement3("You have Chosen Ultimate IronMan Mode.", "Are you sure this is the game mode you want?", "You won't be able to change this later on!");
player.nextChat = 3520;
player.dialogueAction = 3520;
break;
case 3520:
sendOption2("Yes", "No, Go back.");
break;
}

}
}

public void chatboxText(Client c, String text, String text1, String text2,
String text3, String title) {
Expand Down Expand Up @@ -6723,7 +6752,7 @@ public void sendStatement2(String s, String s1) {
public void sendStatement3(String s, String s1, String s2) {
player.getPlayerAssistant().sendFrame126(s, 364);
player.getPlayerAssistant().sendFrame126(s1, 365);
player.getPlayerAssistant().sendFrame126(s1, 366);
player.getPlayerAssistant().sendFrame126(s2, 366);
player.getPlayerAssistant().sendFrame126("Click here to continue", 367);
player.getPlayerAssistant().sendChatInterface(363);
}
Expand Down
5 changes: 5 additions & 0 deletions 2006Redone Server/src/redone/game/items/ItemAssistant.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import redone.Constants;
import redone.Server;
import redone.game.content.IronMan;
import redone.game.content.minigames.castlewars.CastleWars;
import redone.game.items.impl.Weight;
import redone.game.npcs.NpcHandler;
Expand Down Expand Up @@ -2068,6 +2069,10 @@ public boolean bankItem(int itemID, int fromSlot, int amount) {
c.otherBank = false;
return false;
}
if (IronMan.getMode(c) == IronMan.ULTIMATE_IRONMAN) {
c.getActionSender().sendMessage("You cannot bank as a " + IronMan.getModeName(c) + ".");
return false;
}
if (c.playerItemsN[fromSlot] <= 0) {
return false;
}
Expand Down
5 changes: 2 additions & 3 deletions 2006Redone Server/src/redone/game/players/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public abstract class Player {
doorDelay, doubleDoorDelay, buySlayerTimer, lastIncrease,
boneDelay, botAttempts, leverDelay = 0, farmTime, searchObjectDelay = 0;


private Npc specialTarget = null;
private Npc specialTarget = null;
public void setSpecialTarget(Npc target) {
this.specialTarget = target;
}
Expand Down Expand Up @@ -116,7 +115,7 @@ public Npc getSpecialTarget() {
teleOtherSlot = -1, tutorialProgress, Cookstage1 = 1,
woodcuttingTree, smeltAmount, knightS, otherDirection,
brightness = 3, recoilHits, droppedItem = -1,
spawnedHealers, cannonX = 0, cannonY = 0;
spawnedHealers, cannonX = 0, cannonY = 0, ironMan = 0;

public Pets getSummon() {
return pets;
Expand Down
16 changes: 16 additions & 0 deletions 2006Redone Server/src/redone/game/players/PlayerAssistant.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import redone.event.CycleEvent;
import redone.event.CycleEventContainer;
import redone.event.CycleEventHandler;
import redone.game.content.IronMan;
import redone.game.content.combat.magic.MagicData;
import redone.game.content.combat.prayer.PrayerDrain;
import redone.game.content.combat.range.RangeData;
Expand Down Expand Up @@ -1432,6 +1433,10 @@ public void openUpBank() {
player.isBanking = false;
return;
}
if (IronMan.getMode(player) == IronMan.ULTIMATE_IRONMAN) {
player.getActionSender().sendMessage("You cannot bank as an " + IronMan.getModeName(player) + ".");
return;
}
if (player.inWild()) {
player.getActionSender().sendMessage(
"You can't open up a bank in the wilderness!");
Expand Down Expand Up @@ -1921,6 +1926,17 @@ public void applyDead() {
} else if(player.clickedTree == true) {
player.clickedTree = false;
}
if (IronMan.getMode(player) == IronMan.HC_IRONMAN_MODE) {
IronMan.setMode(player, IronMan.IRONMAN_MODE);
PlayerSave.saveGame(player);
player.getActionSender().sendMessage("You have fallen as a Hardcore IronMan, your Hardcore status has been revoked.");
}
if(IronMan.getMode(player) == IronMan.ULTIMATE_IRONMAN) {
player.getItemAssistant().dropAllItems();
player.getItemAssistant().deleteAllItems();
PlayerSave.saveGame(player);
player.getActionSender().sendMessage("You have fallen as a Ultimate IronMan, all your items have been dropped.");
}
resetDamageDone();
player.specAmount = 10;
player.getItemAssistant().addSpecialBar(
Expand Down
6 changes: 6 additions & 0 deletions 2006Redone Server/src/redone/game/players/PlayerSave.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.security.NoSuchAlgorithmException;
import java.util.Base64;

import redone.game.content.IronMan;
import redone.util.Misc;

public class PlayerSave {
Expand Down Expand Up @@ -91,6 +92,9 @@ public static int loadPlayerInfo(Client player, String playerName, String player
case "character-rights":
player.playerRights = Integer.parseInt(token2);
break;
case "ironman":
player.ironMan = Integer.parseInt(token2);
break;
case "blackMarks":
player.blackMarks = Integer.parseInt(token2);
break;
Expand Down Expand Up @@ -572,6 +576,8 @@ public static boolean saveGame(Client player) {
characterfile.write("character-rights = ", 0, 19);
characterfile.write(Integer.toString(player.playerRights), 0,Integer.toString(player.playerRights).length());
characterfile.newLine();
characterfile.write("ironman = " + IronMan.getMode(player));
characterfile.newLine();
characterfile.write("hasStarter = ", 0, 13);
characterfile.write(Boolean.toString(player.hasStarter), 0, Boolean
.toString(player.hasStarter).length());
Expand Down
9 changes: 9 additions & 0 deletions 2006Redone Server/src/redone/game/players/Trading.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import redone.event.CycleEvent;
import redone.event.CycleEventContainer;
import redone.event.CycleEventHandler;
import redone.game.content.IronMan;
import redone.game.content.minigames.castlewars.CastleWars;
import redone.game.items.GameItem;
import redone.game.items.Item;
Expand Down Expand Up @@ -40,6 +41,14 @@ public void requestTrade(int id) {
player.getActionSender().sendMessage("If you need to you can type ::amibotting, to see if your botting.");
return;
}
if (IronMan.getMode(player) >= IronMan.IRONMAN_MODE) {
player.getActionSender().sendMessage("You cannot trade as a " + IronMan.getModeName(player) + ".");
return;
}
if (IronMan.getMode(o) >= IronMan.IRONMAN_MODE) {
player.getActionSender().sendMessage(o.playerName + " is a " + IronMan.getModeName(o) + " they stand alone.");
return;
}
/*if (c.connectedFrom.equals(o.connectedFrom)) {
c.getActionSender().sendMessage("You cannot trade your own IP.");
return;
Expand Down
6 changes: 6 additions & 0 deletions 2006Redone Server/src/redone/game/shops/ShopAssistant.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package redone.game.shops;

import redone.Constants;
import redone.game.content.IronMan;
import redone.game.items.Item;
import redone.game.items.ItemAssistant;
import redone.game.items.ItemDefinitions;
Expand Down Expand Up @@ -425,6 +426,11 @@ public boolean addShopItem(int itemID, int amount) {
private static final int FISHING_ITEMS[] = {383, 371, 377, 359, 321, 341, 353, 345, 327, 317};

public boolean buyItem(int itemID, int fromSlot, int amount) {
if (IronMan.getMode(player) >= IronMan.IRONMAN_MODE
&& ShopHandler.ShopSModifier[player.myShopId] == 1) {
player.getActionSender().sendMessage("You cannot buy from shops players can sell to as a " + IronMan.getModeName(player) + ".");
return false;
}
if (amount > 0) {
if (amount > ShopHandler.ShopItemsN[player.myShopId][fromSlot]) {
amount = ShopHandler.ShopItemsN[player.myShopId][fromSlot];
Expand Down
25 changes: 25 additions & 0 deletions 2006Redone Server/src/redone/net/packets/impl/ClickingButtons.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import redone.Constants;
import redone.Server;
import redone.game.content.IronMan;
import redone.game.content.combat.Specials;
import redone.game.content.combat.magic.CastOnOther;
import redone.game.content.combat.magic.MagicData;
Expand Down Expand Up @@ -1508,11 +1509,19 @@ public void processPacket(final Client player, int packetType, int packetSize) {
Teles.necklaces(player);
return;
}
if(player.dialogueAction == 3520) {
player.getDialogueHandler().sendDialogues(3116, player.npcType);
return;
}
player.dialogueAction = 0;
player.getPlayerAssistant().removeAllWindows();
break;

case 9158:
if(player.dialogueAction == 3520) {
player.getDialogueHandler().sendDialogues(3514, player.npcType);
return;
}
if (player.dialogueAction == 8) {
player.getPlayerAssistant().fixAllBarrows();
} else if (player.dialogueAction == 29) {
Expand Down Expand Up @@ -1711,6 +1720,10 @@ public void processPacket(final Client player, int packetType, int packetSize) {
break;

case 9178:
if (player.dialogueAction == 3515) {
IronMan.setMode(player, 0);
player.getDialogueHandler().sendDialogues(3516, player.npcType);
}
if (player.dialogueAction == 2) {
player.getPlayerAssistant().startTeleport(3428, 3538, 0, "modern");
}
Expand Down Expand Up @@ -1784,6 +1797,10 @@ public void processPacket(final Client player, int packetType, int packetSize) {
break;

case 9179:
if (player.dialogueAction == 3515) {
IronMan.setMode(player, IronMan.IRONMAN_MODE);
player.getDialogueHandler().sendDialogues(3517, player.npcType);
}
if (player.dialogueAction == 2) {
player.getPlayerAssistant().startTeleport(2884, 3395, 0,
"modern");
Expand Down Expand Up @@ -1854,6 +1871,10 @@ public void processPacket(final Client player, int packetType, int packetSize) {
break;

case 9180:
if (player.dialogueAction == 3515) {
IronMan.setMode(player, IronMan.HC_IRONMAN_MODE);
player.getDialogueHandler().sendDialogues(3518, player.npcType);
}
if (player.dialogueAction == 2) {
player.getPlayerAssistant().startTeleport(2471, 10137, 0,
"modern");
Expand Down Expand Up @@ -1927,6 +1948,10 @@ public void processPacket(final Client player, int packetType, int packetSize) {
break;

case 9181:
if (player.dialogueAction == 3515) {
IronMan.setMode(player, IronMan.ULTIMATE_IRONMAN);
player.getDialogueHandler().sendDialogues(3519, player.npcType);
}
if (player.dialogueAction == 2) {
player.getPlayerAssistant().startTeleport(2669, 3714, 0, "modern");
}
Expand Down
Loading