mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-06 16:49:07 +00:00
Fixed grounditems
This commit is contained in:
@@ -18,8 +18,8 @@ public class ClientSettings {
|
|||||||
/**
|
/**
|
||||||
* The Servers Ip
|
* The Servers Ip
|
||||||
*/
|
*/
|
||||||
public final static String SERVER_IP = "35.226.247.68";
|
//public final static String SERVER_IP = "35.226.247.68";
|
||||||
//public final static String SERVER_IP = "127.0.0.1";
|
public final static String SERVER_IP = "127.0.0.1";
|
||||||
/**
|
/**
|
||||||
* The Npc Bits for the Server
|
* The Npc Bits for the Server
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
[2019/06/19] 22:04 irdb dropped 1 bronze sword absX: 3210 absY: 3218
|
||||||
@@ -2,18 +2,12 @@ package redone.net;
|
|||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
import redone.Server;
|
|
||||||
import redone.game.items.GroundItem;
|
|
||||||
import redone.game.items.ItemAssistant;
|
|
||||||
import redone.game.players.Client;
|
import redone.game.players.Client;
|
||||||
import redone.game.players.Player;
|
import redone.game.players.Player;
|
||||||
import redone.game.players.PlayerHandler;
|
import redone.game.players.PlayerHandler;
|
||||||
import redone.util.GameLogger;
|
|
||||||
import redone.util.Misc;
|
import redone.util.Misc;
|
||||||
import redone.world.clip.Region;
|
import redone.world.clip.Region;
|
||||||
|
|
||||||
import static redone.world.ItemHandler.HIDE_TICKS;
|
|
||||||
|
|
||||||
public class ActionSender {
|
public class ActionSender {
|
||||||
|
|
||||||
private final Client player;
|
private final Client player;
|
||||||
@@ -586,50 +580,7 @@ public class ActionSender {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createGroundItem(Client player, int itemId, int itemX, int itemY, int itemAmount, int playerId) {
|
|
||||||
System.out.println("Here");
|
|
||||||
if (itemId > 0) {
|
|
||||||
if (itemId >= 2412 && itemId <= 2414) {
|
|
||||||
player.getActionSender().sendMessage("The cape vanishes as it touches the ground.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (itemId > 4705 && itemId < 4760) {
|
|
||||||
for (int[] brokenBarrow : Server.itemHandler.brokenBarrows) {
|
|
||||||
if (brokenBarrow[0] == itemId) {
|
|
||||||
itemId = brokenBarrow[1];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!redone.game.items.Item.itemStackable[itemId] && itemAmount > 0) {
|
|
||||||
for (int j = 0; j < itemAmount; j++) {
|
|
||||||
player.getActionSender().createGroundItem(itemId, itemX, itemY, 1);
|
|
||||||
GroundItem item = new GroundItem(itemId, itemX, itemY, player.getH(), 1, player.playerId, HIDE_TICKS, PlayerHandler.players[playerId].playerName);
|
|
||||||
Server.itemHandler.addItem(item);
|
|
||||||
String itemName = ItemAssistant.getItemName(itemId).toLowerCase();
|
|
||||||
if (player.isDead == false && itemId != 526) {
|
|
||||||
if (player.getPlayerAssistant().isPlayer()) {
|
|
||||||
GameLogger.writeLog(player.playerName, "dropitem", player.playerName + " dropped " + itemAmount + " " + itemName + " absX: " + player.absX + " absY: " + player.absY + "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
player.getActionSender().createGroundItem(itemId, itemX, itemY, itemAmount);
|
|
||||||
GroundItem item = new GroundItem(itemId, itemX, itemY, player.getH(), itemAmount, player.playerId, HIDE_TICKS, PlayerHandler.players[playerId].playerName);
|
|
||||||
Server.itemHandler.addItem(item);
|
|
||||||
String itemName = ItemAssistant.getItemName(itemId).toLowerCase();
|
|
||||||
if (player.isDead == false && itemId != 526) {
|
|
||||||
if (player.getPlayerAssistant().isPlayer()) {
|
|
||||||
GameLogger.writeLog(player.playerName, "dropitem", player.playerName + " dropped " + itemAmount + " " + itemName + " absX: " + player.absX + " absY: " + player.absY + "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ActionSender createGroundItem(int itemID, int itemX, int itemY, int itemAmount) {
|
public ActionSender createGroundItem(int itemID, int itemX, int itemY, int itemAmount) {
|
||||||
System.out.println("Wtf fucks sake");
|
|
||||||
createGroundItem(this.player, itemID, itemX, itemY, itemAmount, this.player.getId());
|
|
||||||
player.getOutStream().createFrame(85);
|
player.getOutStream().createFrame(85);
|
||||||
player.getOutStream().writeByteC(itemY - 8 * player.mapRegionY);
|
player.getOutStream().writeByteC(itemY - 8 * player.mapRegionY);
|
||||||
player.getOutStream().writeByteC(itemX - 8 * player.mapRegionX);
|
player.getOutStream().writeByteC(itemX - 8 * player.mapRegionX);
|
||||||
|
|||||||
@@ -1,432 +1,432 @@
|
|||||||
package redone.world;
|
package redone.world;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import redone.Constants;
|
import redone.Constants;
|
||||||
import redone.game.items.GroundItem;
|
import redone.game.items.GroundItem;
|
||||||
import redone.game.items.ItemAssistant;
|
import redone.game.items.ItemAssistant;
|
||||||
import redone.game.items.ItemList;
|
import redone.game.items.ItemList;
|
||||||
import redone.game.players.Client;
|
import redone.game.players.Client;
|
||||||
import redone.game.players.Player;
|
import redone.game.players.Player;
|
||||||
import redone.game.players.PlayerHandler;
|
import redone.game.players.PlayerHandler;
|
||||||
import redone.util.GameLogger;
|
import redone.util.GameLogger;
|
||||||
import redone.util.Misc;
|
import redone.util.Misc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles ground items
|
* Handles ground items
|
||||||
**/
|
**/
|
||||||
|
|
||||||
public class ItemHandler {
|
public class ItemHandler {
|
||||||
|
|
||||||
public List<GroundItem> items = new ArrayList<GroundItem>();
|
public List<GroundItem> items = new ArrayList<GroundItem>();
|
||||||
public static final int HIDE_TICKS = 100;
|
public static final int HIDE_TICKS = 100;
|
||||||
|
|
||||||
public ItemHandler() {
|
public ItemHandler() {
|
||||||
for (int i = 0; i < Constants.ITEM_LIMIT; i++) {
|
for (int i = 0; i < Constants.ITEM_LIMIT; i++) {
|
||||||
ItemList[i] = null;
|
ItemList[i] = null;
|
||||||
}
|
}
|
||||||
loadItemList("item.cfg");
|
loadItemList("item.cfg");
|
||||||
loadItemPrices("prices.txt");
|
loadItemPrices("prices.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds item to list
|
* Adds item to list
|
||||||
**/
|
**/
|
||||||
public void addItem(GroundItem item) {
|
public void addItem(GroundItem item) {
|
||||||
items.add(item);
|
items.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes item from list
|
* Removes item from list
|
||||||
**/
|
**/
|
||||||
public void removeItem(GroundItem item) {
|
public void removeItem(GroundItem item) {
|
||||||
items.remove(item);
|
items.remove(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Item amount
|
* Item amount
|
||||||
**/
|
**/
|
||||||
|
|
||||||
public int itemAmount(String name, int itemId, int itemX, int itemY) {
|
public int itemAmount(String name, int itemId, int itemX, int itemY) {
|
||||||
for(GroundItem i : items) {
|
for(GroundItem i : items) {
|
||||||
if (i.hideTicks >= 1 && i.getName().equalsIgnoreCase(name)) {
|
if (i.hideTicks >= 1 && i.getName().equalsIgnoreCase(name)) {
|
||||||
if(i.getItemId() == itemId && i.getItemX() == itemX && i.getItemY() == itemY) {
|
if(i.getItemId() == itemId && i.getItemX() == itemX && i.getItemY() == itemY) {
|
||||||
return i.getItemAmount();
|
return i.getItemAmount();
|
||||||
}
|
}
|
||||||
} else if (i.hideTicks < 1) {
|
} else if (i.hideTicks < 1) {
|
||||||
if(i.getItemId() == itemId && i.getItemX() == itemX && i.getItemY() == itemY) {
|
if(i.getItemId() == itemId && i.getItemX() == itemX && i.getItemY() == itemY) {
|
||||||
return i.getItemAmount();
|
return i.getItemAmount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Item exists
|
* Item exists
|
||||||
**/
|
**/
|
||||||
public boolean itemExists(int itemId, int itemX, int itemY) {
|
public boolean itemExists(int itemId, int itemX, int itemY) {
|
||||||
for (GroundItem i : items) {
|
for (GroundItem i : items) {
|
||||||
if (i.getItemId() == itemId && i.getItemX() == itemX
|
if (i.getItemId() == itemId && i.getItemX() == itemX
|
||||||
&& i.getItemY() == itemY) {
|
&& i.getItemY() == itemY) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reloads any items if you enter a new region
|
* Reloads any items if you enter a new region
|
||||||
**/
|
**/
|
||||||
public void reloadItems(Client c) {
|
public void reloadItems(Client c) {
|
||||||
for (GroundItem i : items) {
|
for (GroundItem i : items) {
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
if (c.getItemAssistant().tradeable(i.getItemId())
|
if (c.getItemAssistant().tradeable(i.getItemId())
|
||||||
|| i.getName().equalsIgnoreCase(c.playerName)) {
|
|| i.getName().equalsIgnoreCase(c.playerName)) {
|
||||||
if (c.distanceToPoint(i.getItemX(), i.getItemY()) <= 60) {
|
if (c.distanceToPoint(i.getItemX(), i.getItemY()) <= 60) {
|
||||||
if (i.hideTicks > 0
|
if (i.hideTicks > 0
|
||||||
&& i.getName().equalsIgnoreCase(c.playerName)) {
|
&& i.getName().equalsIgnoreCase(c.playerName)) {
|
||||||
c.getActionSender().removeGroundItem(
|
c.getActionSender().removeGroundItem(
|
||||||
i.getItemId(), i.getItemX(), i.getItemY(),
|
i.getItemId(), i.getItemX(), i.getItemY(),
|
||||||
i.getItemAmount());
|
i.getItemAmount());
|
||||||
c.getActionSender().createGroundItem(
|
c.getActionSender().createGroundItem(
|
||||||
i.getItemId(), i.getItemX(), i.getItemY(),
|
i.getItemId(), i.getItemX(), i.getItemY(),
|
||||||
i.getItemAmount());
|
i.getItemAmount());
|
||||||
}
|
}
|
||||||
if (i.hideTicks == 0) {
|
if (i.hideTicks == 0) {
|
||||||
c.getActionSender().removeGroundItem(
|
c.getActionSender().removeGroundItem(
|
||||||
i.getItemId(), i.getItemX(), i.getItemY(),
|
i.getItemId(), i.getItemX(), i.getItemY(),
|
||||||
i.getItemAmount());
|
i.getItemAmount());
|
||||||
c.getActionSender().createGroundItem(
|
c.getActionSender().createGroundItem(
|
||||||
i.getItemId(), i.getItemX(), i.getItemY(),
|
i.getItemId(), i.getItemX(), i.getItemY(),
|
||||||
i.getItemAmount());
|
i.getItemAmount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void process() {
|
public void process() {
|
||||||
ArrayList<GroundItem> toRemove = new ArrayList<GroundItem>();
|
ArrayList<GroundItem> toRemove = new ArrayList<GroundItem>();
|
||||||
for (int j = 0; j < items.size(); j++) {
|
for (int j = 0; j < items.size(); j++) {
|
||||||
if (items.get(j) != null) {
|
if (items.get(j) != null) {
|
||||||
GroundItem i = items.get(j);
|
GroundItem i = items.get(j);
|
||||||
if (i.hideTicks > 0) {
|
if (i.hideTicks > 0) {
|
||||||
i.hideTicks--;
|
i.hideTicks--;
|
||||||
}
|
}
|
||||||
if (i.hideTicks == 1) { // item can now be seen by others
|
if (i.hideTicks == 1) { // item can now be seen by others
|
||||||
i.hideTicks = 0;
|
i.hideTicks = 0;
|
||||||
createGlobalItem(i);
|
createGlobalItem(i);
|
||||||
i.removeTicks = HIDE_TICKS;
|
i.removeTicks = HIDE_TICKS;
|
||||||
}
|
}
|
||||||
if (i.removeTicks > 0) {
|
if (i.removeTicks > 0) {
|
||||||
i.removeTicks--;
|
i.removeTicks--;
|
||||||
}
|
}
|
||||||
if (i.removeTicks == 1) {
|
if (i.removeTicks == 1) {
|
||||||
i.removeTicks = 0;
|
i.removeTicks = 0;
|
||||||
toRemove.add(i);
|
toRemove.add(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < toRemove.size(); j++) {
|
for (int j = 0; j < toRemove.size(); j++) {
|
||||||
GroundItem i = toRemove.get(j);
|
GroundItem i = toRemove.get(j);
|
||||||
removeGlobalItem(i, i.getItemId(), i.getItemX(), i.getItemY(),
|
removeGlobalItem(i, i.getItemId(), i.getItemX(), i.getItemY(),
|
||||||
i.getItemAmount());
|
i.getItemAmount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the ground item
|
* Creates the ground item
|
||||||
**/
|
**/
|
||||||
public int[][] brokenBarrows = { { 4708, 4860 }, { 4710, 4866 },
|
public int[][] brokenBarrows = { { 4708, 4860 }, { 4710, 4866 },
|
||||||
{ 4712, 4872 }, { 4714, 4878 }, { 4716, 4884 }, { 4720, 4896 },
|
{ 4712, 4872 }, { 4714, 4878 }, { 4716, 4884 }, { 4720, 4896 },
|
||||||
{ 4718, 4890 }, { 4720, 4896 }, { 4722, 4902 }, { 4732, 4932 },
|
{ 4718, 4890 }, { 4720, 4896 }, { 4722, 4902 }, { 4732, 4932 },
|
||||||
{ 4734, 4938 }, { 4736, 4944 }, { 4738, 4950 }, { 4724, 4908 },
|
{ 4734, 4938 }, { 4736, 4944 }, { 4738, 4950 }, { 4724, 4908 },
|
||||||
{ 4726, 4914 }, { 4728, 4920 }, { 4730, 4926 }, { 4745, 4956 },
|
{ 4726, 4914 }, { 4728, 4920 }, { 4730, 4926 }, { 4745, 4956 },
|
||||||
{ 4747, 4926 }, { 4749, 4968 }, { 4751, 4994 }, { 4753, 4980 },
|
{ 4747, 4926 }, { 4749, 4968 }, { 4751, 4994 }, { 4753, 4980 },
|
||||||
{ 4755, 4986 }, { 4757, 4992 }, { 4759, 4998 } };
|
{ 4755, 4986 }, { 4757, 4992 }, { 4759, 4998 } };
|
||||||
|
|
||||||
public void createGroundItem(Client player, int itemId, int itemX, int itemY, int itemAmount, int playerId) {
|
public void createGroundItem(Client player, int itemId, int itemX, int itemY, int itemAmount, int playerId) {
|
||||||
if (itemId > 0) {
|
if (itemId > 0) {
|
||||||
if (itemId >= 2412 && itemId <= 2414) {
|
if (itemId >= 2412 && itemId <= 2414) {
|
||||||
player.getActionSender().sendMessage("The cape vanishes as it touches the ground.");
|
player.getActionSender().sendMessage("The cape vanishes as it touches the ground.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (itemId > 4705 && itemId < 4760) {
|
if (itemId > 4705 && itemId < 4760) {
|
||||||
for (int[] brokenBarrow : brokenBarrows) {
|
for (int[] brokenBarrow : brokenBarrows) {
|
||||||
if (brokenBarrow[0] == itemId) {
|
if (brokenBarrow[0] == itemId) {
|
||||||
itemId = brokenBarrow[1];
|
itemId = brokenBarrow[1];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!redone.game.items.Item.itemStackable[itemId] && itemAmount > 0) {
|
if (!redone.game.items.Item.itemStackable[itemId] && itemAmount > 0) {
|
||||||
for (int j = 0; j < itemAmount; j++) {
|
for (int j = 0; j < itemAmount; j++) {
|
||||||
player.getActionSender().createGroundItem(itemId, itemX, itemY, 1);
|
player.getActionSender().createGroundItem(itemId, itemX, itemY, 1);
|
||||||
GroundItem item = new GroundItem(itemId, itemX, itemY, player.getH(), 1, player.playerId, HIDE_TICKS, PlayerHandler.players[playerId].playerName);
|
GroundItem item = new GroundItem(itemId, itemX, itemY, player.getH(), 1, player.playerId, HIDE_TICKS, PlayerHandler.players[playerId].playerName);
|
||||||
addItem(item);
|
addItem(item);
|
||||||
String itemName = ItemAssistant.getItemName(itemId).toLowerCase();
|
String itemName = ItemAssistant.getItemName(itemId).toLowerCase();
|
||||||
if (player.isDead == false && itemId != 526) {
|
if (player.isDead == false && itemId != 526) {
|
||||||
if (player.getPlayerAssistant().isPlayer()) {
|
if (player.getPlayerAssistant().isPlayer()) {
|
||||||
GameLogger.writeLog(player.playerName, "dropitem", player.playerName + " dropped " + itemAmount + " " + itemName + " absX: " + player.absX + " absY: " + player.absY + "");
|
GameLogger.writeLog(player.playerName, "dropitem", player.playerName + " dropped " + itemAmount + " " + itemName + " absX: " + player.absX + " absY: " + player.absY + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.getActionSender().createGroundItem(itemId, itemX, itemY, itemAmount);
|
player.getActionSender().createGroundItem(itemId, itemX, itemY, itemAmount);
|
||||||
GroundItem item = new GroundItem(itemId, itemX, itemY, player.getH(), itemAmount, player.playerId, HIDE_TICKS, PlayerHandler.players[playerId].playerName);
|
GroundItem item = new GroundItem(itemId, itemX, itemY, player.getH(), itemAmount, player.playerId, HIDE_TICKS, PlayerHandler.players[playerId].playerName);
|
||||||
addItem(item);
|
addItem(item);
|
||||||
String itemName = ItemAssistant.getItemName(itemId).toLowerCase();
|
String itemName = ItemAssistant.getItemName(itemId).toLowerCase();
|
||||||
if (player.isDead == false && itemId != 526) {
|
if (player.isDead == false && itemId != 526) {
|
||||||
if (player.getPlayerAssistant().isPlayer()) {
|
if (player.getPlayerAssistant().isPlayer()) {
|
||||||
GameLogger.writeLog(player.playerName, "dropitem", player.playerName + " dropped " + itemAmount + " " + itemName + " absX: " + player.absX + " absY: " + player.absY + "");
|
GameLogger.writeLog(player.playerName, "dropitem", player.playerName + " dropped " + itemAmount + " " + itemName + " absX: " + player.absX + " absY: " + player.absY + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows items for everyone who is within 60 squares
|
* Shows items for everyone who is within 60 squares
|
||||||
**/
|
**/
|
||||||
public void createGlobalItem(GroundItem i) {
|
public void createGlobalItem(GroundItem i) {
|
||||||
for (Player p : PlayerHandler.players) {
|
for (Player p : PlayerHandler.players) {
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
Client person = (Client) p;
|
Client person = (Client) p;
|
||||||
if (person != null) {
|
if (person != null) {
|
||||||
if (person.playerId != i.getItemController()) {
|
if (person.playerId != i.getItemController()) {
|
||||||
if (!person.getItemAssistant().tradeable(i.getItemId())
|
if (!person.getItemAssistant().tradeable(i.getItemId())
|
||||||
&& person.playerId != i.getItemController()) {
|
&& person.playerId != i.getItemController()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (person.distanceToPoint(i.getItemX(), i.getItemY()) <= 60) {
|
if (person.distanceToPoint(i.getItemX(), i.getItemY()) <= 60) {
|
||||||
person.getActionSender().createGroundItem(
|
person.getActionSender().createGroundItem(
|
||||||
i.getItemId(), i.getItemX(), i.getItemY(),
|
i.getItemId(), i.getItemX(), i.getItemY(),
|
||||||
i.getItemAmount());
|
i.getItemAmount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removing the ground item
|
* Removing the ground item
|
||||||
**/
|
**/
|
||||||
|
|
||||||
public void removeGroundItem(Client c, int itemId, int itemX, int itemY, boolean add) {
|
public void removeGroundItem(Client c, int itemId, int itemX, int itemY, boolean add) {
|
||||||
for (GroundItem i : items) {
|
for (GroundItem i : items) {
|
||||||
if (i.getItemId() == itemId && i.getItemX() == itemX
|
if (i.getItemId() == itemId && i.getItemX() == itemX
|
||||||
&& i.getItemY() == itemY) {
|
&& i.getItemY() == itemY) {
|
||||||
if (i.hideTicks > 0
|
if (i.hideTicks > 0
|
||||||
&& i.getName().equalsIgnoreCase(c.playerName)) {
|
&& i.getName().equalsIgnoreCase(c.playerName)) {
|
||||||
if (add) {
|
if (add) {
|
||||||
if (!c.getItemAssistant().specialCase(itemId)) {
|
if (!c.getItemAssistant().specialCase(itemId)) {
|
||||||
if (c.getItemAssistant().addItem(i.getItemId(),
|
if (c.getItemAssistant().addItem(i.getItemId(),
|
||||||
i.getItemAmount())) {
|
i.getItemAmount())) {
|
||||||
removeControllersItem(i, c, i.getItemId(),
|
removeControllersItem(i, c, i.getItemId(),
|
||||||
i.getItemX(), i.getItemY(),
|
i.getItemX(), i.getItemY(),
|
||||||
i.getItemAmount());
|
i.getItemAmount());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
removeControllersItem(i, c, i.getItemId(),
|
removeControllersItem(i, c, i.getItemId(),
|
||||||
i.getItemX(), i.getItemY(),
|
i.getItemX(), i.getItemY(),
|
||||||
i.getItemAmount());
|
i.getItemAmount());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
removeControllersItem(i, c, i.getItemId(),
|
removeControllersItem(i, c, i.getItemId(),
|
||||||
i.getItemX(), i.getItemY(), i.getItemAmount());
|
i.getItemX(), i.getItemY(), i.getItemAmount());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (i.hideTicks <= 0) {
|
} else if (i.hideTicks <= 0) {
|
||||||
if (add) {
|
if (add) {
|
||||||
if (c.getItemAssistant().addItem(i.getItemId(),
|
if (c.getItemAssistant().addItem(i.getItemId(),
|
||||||
i.getItemAmount())) {
|
i.getItemAmount())) {
|
||||||
removeGlobalItem(i, i.getItemId(), i.getItemX(),
|
removeGlobalItem(i, i.getItemId(), i.getItemX(),
|
||||||
i.getItemY(), i.getItemAmount());
|
i.getItemY(), i.getItemAmount());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
removeGlobalItem(i, i.getItemId(), i.getItemX(),
|
removeGlobalItem(i, i.getItemId(), i.getItemX(),
|
||||||
i.getItemY(), i.getItemAmount());
|
i.getItemY(), i.getItemAmount());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove item for just the item controller (item not global yet)
|
* Remove item for just the item controller (item not global yet)
|
||||||
**/
|
**/
|
||||||
|
|
||||||
public void removeControllersItem(GroundItem i, Client c, int itemId,
|
public void removeControllersItem(GroundItem i, Client c, int itemId,
|
||||||
int itemX, int itemY, int itemAmount) {
|
int itemX, int itemY, int itemAmount) {
|
||||||
c.getActionSender().removeGroundItem(itemId, itemX, itemY,
|
c.getActionSender().removeGroundItem(itemId, itemX, itemY,
|
||||||
itemAmount);
|
itemAmount);
|
||||||
removeItem(i);
|
removeItem(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove item for everyone within 60 squares
|
* Remove item for everyone within 60 squares
|
||||||
**/
|
**/
|
||||||
|
|
||||||
public void removeGlobalItem(GroundItem i, int itemId, int itemX,
|
public void removeGlobalItem(GroundItem i, int itemId, int itemX,
|
||||||
int itemY, int itemAmount) {
|
int itemY, int itemAmount) {
|
||||||
for (Player p : PlayerHandler.players) {
|
for (Player p : PlayerHandler.players) {
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
Client person = (Client) p;
|
Client person = (Client) p;
|
||||||
if (person != null) {
|
if (person != null) {
|
||||||
if (person.distanceToPoint(itemX, itemY) <= 60) {
|
if (person.distanceToPoint(itemX, itemY) <= 60) {
|
||||||
person.getActionSender().removeGroundItem(itemId,
|
person.getActionSender().removeGroundItem(itemId,
|
||||||
itemX, itemY, itemAmount);
|
itemX, itemY, itemAmount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
removeItem(i);
|
removeItem(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Item List
|
* Item List
|
||||||
**/
|
**/
|
||||||
|
|
||||||
public ItemList ItemList[] = new ItemList[Constants.ITEM_LIMIT];
|
public ItemList ItemList[] = new ItemList[Constants.ITEM_LIMIT];
|
||||||
|
|
||||||
public void newItemList(int ItemId, String ItemName,
|
public void newItemList(int ItemId, String ItemName,
|
||||||
String ItemDescription, double ShopValue, double LowAlch,
|
String ItemDescription, double ShopValue, double LowAlch,
|
||||||
double HighAlch, int Bonuses[]) {
|
double HighAlch, int Bonuses[]) {
|
||||||
// first, search for a free slot
|
// first, search for a free slot
|
||||||
int slot = -1;
|
int slot = -1;
|
||||||
for (int i = 0; i < 11740; i++) {
|
for (int i = 0; i < 11740; i++) {
|
||||||
if (ItemList[i] == null) {
|
if (ItemList[i] == null) {
|
||||||
slot = i;
|
slot = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slot == -1) {
|
if (slot == -1) {
|
||||||
return; // no free slot found
|
return; // no free slot found
|
||||||
}
|
}
|
||||||
ItemList newItemList = new ItemList(ItemId);
|
ItemList newItemList = new ItemList(ItemId);
|
||||||
newItemList.itemName = ItemName;
|
newItemList.itemName = ItemName;
|
||||||
newItemList.itemDescription = ItemDescription;
|
newItemList.itemDescription = ItemDescription;
|
||||||
newItemList.ShopValue = ShopValue;
|
newItemList.ShopValue = ShopValue;
|
||||||
newItemList.LowAlch = LowAlch;
|
newItemList.LowAlch = LowAlch;
|
||||||
newItemList.HighAlch = HighAlch;
|
newItemList.HighAlch = HighAlch;
|
||||||
newItemList.Bonuses = Bonuses;
|
newItemList.Bonuses = Bonuses;
|
||||||
ItemList[slot] = newItemList;
|
ItemList[slot] = newItemList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadItemPrices(String filename) {
|
public void loadItemPrices(String filename) {
|
||||||
try {
|
try {
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
Scanner s = new Scanner(new File("./data/cfg/" + filename));
|
Scanner s = new Scanner(new File("./data/cfg/" + filename));
|
||||||
while (s.hasNextLine()) {
|
while (s.hasNextLine()) {
|
||||||
String[] line = s.nextLine().split(" ");
|
String[] line = s.nextLine().split(" ");
|
||||||
ItemList temp = getItemList(Integer.parseInt(line[0]));
|
ItemList temp = getItemList(Integer.parseInt(line[0]));
|
||||||
if (temp != null) {
|
if (temp != null) {
|
||||||
temp.ShopValue = Integer.parseInt(line[1]);
|
temp.ShopValue = Integer.parseInt(line[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemList getItemList(int i) {
|
public ItemList getItemList(int i) {
|
||||||
for (redone.game.items.ItemList element : ItemList) {
|
for (redone.game.items.ItemList element : ItemList) {
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
if (element.itemId == i) {
|
if (element.itemId == i) {
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean loadItemList(String FileName) {
|
public boolean loadItemList(String FileName) {
|
||||||
String line = "";
|
String line = "";
|
||||||
String token = "";
|
String token = "";
|
||||||
String token2 = "";
|
String token2 = "";
|
||||||
String token2_2 = "";
|
String token2_2 = "";
|
||||||
String[] token3 = new String[10];
|
String[] token3 = new String[10];
|
||||||
boolean EndOfFile = false;
|
boolean EndOfFile = false;
|
||||||
BufferedReader characterfile = null;
|
BufferedReader characterfile = null;
|
||||||
try {
|
try {
|
||||||
characterfile = new BufferedReader(new FileReader("./data/cfg/"
|
characterfile = new BufferedReader(new FileReader("./data/cfg/"
|
||||||
+ FileName));
|
+ FileName));
|
||||||
} catch (FileNotFoundException fileex) {
|
} catch (FileNotFoundException fileex) {
|
||||||
Misc.println(FileName + ": file not found.");
|
Misc.println(FileName + ": file not found.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
line = characterfile.readLine();
|
line = characterfile.readLine();
|
||||||
} catch (IOException ioexception) {
|
} catch (IOException ioexception) {
|
||||||
Misc.println(FileName + ": error loading file.");
|
Misc.println(FileName + ": error loading file.");
|
||||||
// return false;
|
// return false;
|
||||||
}
|
}
|
||||||
while (EndOfFile == false && line != null) {
|
while (EndOfFile == false && line != null) {
|
||||||
line = line.trim();
|
line = line.trim();
|
||||||
int spot = line.indexOf("=");
|
int spot = line.indexOf("=");
|
||||||
if (spot > -1) {
|
if (spot > -1) {
|
||||||
token = line.substring(0, spot);
|
token = line.substring(0, spot);
|
||||||
token = token.trim();
|
token = token.trim();
|
||||||
token2 = line.substring(spot + 1);
|
token2 = line.substring(spot + 1);
|
||||||
token2 = token2.trim();
|
token2 = token2.trim();
|
||||||
token2_2 = token2.replaceAll("\t\t", "\t");
|
token2_2 = token2.replaceAll("\t\t", "\t");
|
||||||
token2_2 = token2_2.replaceAll("\t\t", "\t");
|
token2_2 = token2_2.replaceAll("\t\t", "\t");
|
||||||
token2_2 = token2_2.replaceAll("\t\t", "\t");
|
token2_2 = token2_2.replaceAll("\t\t", "\t");
|
||||||
token2_2 = token2_2.replaceAll("\t\t", "\t");
|
token2_2 = token2_2.replaceAll("\t\t", "\t");
|
||||||
token2_2 = token2_2.replaceAll("\t\t", "\t");
|
token2_2 = token2_2.replaceAll("\t\t", "\t");
|
||||||
token3 = token2_2.split("\t");
|
token3 = token2_2.split("\t");
|
||||||
if (token.equals("item")) {
|
if (token.equals("item")) {
|
||||||
int[] Bonuses = new int[12];
|
int[] Bonuses = new int[12];
|
||||||
for (int i = 0; i < 12; i++) {
|
for (int i = 0; i < 12; i++) {
|
||||||
if (token3[6 + i] != null) {
|
if (token3[6 + i] != null) {
|
||||||
Bonuses[i] = Integer.parseInt(token3[6 + i]);
|
Bonuses[i] = Integer.parseInt(token3[6 + i]);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newItemList(Integer.parseInt(token3[0]),
|
newItemList(Integer.parseInt(token3[0]),
|
||||||
token3[1].replaceAll("_", " "),
|
token3[1].replaceAll("_", " "),
|
||||||
token3[2].replaceAll("_", " "),
|
token3[2].replaceAll("_", " "),
|
||||||
Double.parseDouble(token3[4]),
|
Double.parseDouble(token3[4]),
|
||||||
Double.parseDouble(token3[4]),
|
Double.parseDouble(token3[4]),
|
||||||
Double.parseDouble(token3[6]), Bonuses);
|
Double.parseDouble(token3[6]), Bonuses);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (line.equals("[ENDOFITEMLIST]")) {
|
if (line.equals("[ENDOFITEMLIST]")) {
|
||||||
try {
|
try {
|
||||||
characterfile.close();
|
characterfile.close();
|
||||||
} catch (IOException ioexception) {
|
} catch (IOException ioexception) {
|
||||||
}
|
}
|
||||||
//return true;
|
//return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
line = characterfile.readLine();
|
line = characterfile.readLine();
|
||||||
} catch (IOException ioexception1) {
|
} catch (IOException ioexception1) {
|
||||||
EndOfFile = true;
|
EndOfFile = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
characterfile.close();
|
characterfile.close();
|
||||||
} catch (IOException ioexception) {
|
} catch (IOException ioexception) {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user