mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-07 16:49:07 +00:00
Update how player shop is handled (#501)
* Update how player shop is handled * Squashed commit of the following: commit5be0778dc9Author: Danial <admin@redsparr0w.com> Date: Sun Sep 19 14:24:12 2021 +1200 minor fixup commitef3b63b54fAuthor: Danial <admin@redsparr0w.com> Date: Sun Sep 19 14:11:27 2021 +1200 Add docker compose file for running servers in containers * Update DialogueHandler.java * Fix for models out of bounds * Revert "Squashed commit of the following:" This reverts commitd27d3c357c. * Other shop tidy up Show shops as combat level 0 Remove items from shop when shop logs off
This commit is contained in:
@@ -113,7 +113,7 @@ public final class Model extends Animable {
|
|||||||
if (aClass21Array1661 == null) {
|
if (aClass21Array1661 == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Class21 class21 = aClass21Array1661[j];
|
Class21 class21 = aClass21Array1661.length < j ? null : aClass21Array1661[j];
|
||||||
if (class21 == null) {
|
if (class21 == null) {
|
||||||
aOnDemandFetcherParent_1662.method548(j);
|
aOnDemandFetcherParent_1662.method548(j);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class Bot {
|
|||||||
botClient.setChatTextUpdateRequired(true);
|
botClient.setChatTextUpdateRequired(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatSellPrice(int price) {
|
public static String formatSellPrice(int price) {
|
||||||
DecimalFormat df = new DecimalFormat("#.##");
|
DecimalFormat df = new DecimalFormat("#.##");
|
||||||
if (price >= 1e9) {
|
if (price >= 1e9) {
|
||||||
return df.format(Math.floor(price / 1e8) / 10) + "b";
|
return df.format(Math.floor(price / 1e8) / 10) + "b";
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ public class BotHandler {
|
|||||||
public static void closeShop(Player player) {
|
public static void closeShop(Player player) {
|
||||||
Client shop = getPlayerShop(player.playerName);
|
Client shop = getPlayerShop(player.playerName);
|
||||||
if (shop == null) return;
|
if (shop == null) return;
|
||||||
|
ShopHandler.closePlayerShop(shop);
|
||||||
shop.getPlayerAssistant().movePlayer(0, 0, 0);
|
shop.getPlayerAssistant().movePlayer(0, 0, 0);
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
@@ -176,6 +177,15 @@ public class BotHandler {
|
|||||||
shop.getItemAssistant().addItem(currency, amount);
|
shop.getItemAssistant().addItem(currency, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int checkCoins(Player player) {
|
||||||
|
Client shop = getPlayerShop(player.playerName);
|
||||||
|
if (shop == null) return 0;
|
||||||
|
if (!shop.getItemAssistant().playerHasItem(currency)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return shop.getItemAssistant().getItemAmount(currency);
|
||||||
|
}
|
||||||
|
|
||||||
public static void takeCoins(Player player) {
|
public static void takeCoins(Player player) {
|
||||||
if (!player.getItemAssistant().playerHasItem(currency) && player.getItemAssistant().freeSlots() <= 0) {
|
if (!player.getItemAssistant().playerHasItem(currency) && player.getItemAssistant().freeSlots() <= 0) {
|
||||||
player.getPacketSender().sendMessage("You don't have enough space in your inventory.");
|
player.getPacketSender().sendMessage("You don't have enough space in your inventory.");
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.rs2.game.dialogues;
|
|||||||
|
|
||||||
import com.rs2.GameConstants;
|
import com.rs2.GameConstants;
|
||||||
import com.rs2.GameEngine;
|
import com.rs2.GameEngine;
|
||||||
|
import com.rs2.game.bots.Bot;
|
||||||
|
import com.rs2.game.bots.BotHandler;
|
||||||
import com.rs2.game.content.quests.QuestAssistant;
|
import com.rs2.game.content.quests.QuestAssistant;
|
||||||
import com.rs2.game.content.quests.QuestRewards;
|
import com.rs2.game.content.quests.QuestRewards;
|
||||||
import com.rs2.game.content.randomevents.FreakyForester;
|
import com.rs2.game.content.randomevents.FreakyForester;
|
||||||
@@ -7516,6 +7518,15 @@ public class DialogueHandler {
|
|||||||
player.getDialogueHandler().sendNpcChat(player.talkingNpc, ChatEmotes.HAPPY_JOYFUL, "Thank you again traveller. Happy Easter!");
|
player.getDialogueHandler().sendNpcChat(player.talkingNpc, ChatEmotes.HAPPY_JOYFUL, "Thank you again traveller. Happy Easter!");
|
||||||
player.getDialogueHandler().endDialogue();
|
player.getDialogueHandler().endDialogue();
|
||||||
break;
|
break;
|
||||||
|
case 10000:
|
||||||
|
int coins = BotHandler.checkCoins(player);
|
||||||
|
sendOption(
|
||||||
|
player.inPlayerShopArea() ? "Summon Shop" : "@red@Summon Shop", // 9178
|
||||||
|
"Close Shop", // 9179
|
||||||
|
coins > 0 ? "Withdraw Money (" + Bot.formatSellPrice(coins) + ")" : "@red@Withdraw Money (0 gp)"// 9180
|
||||||
|
);
|
||||||
|
player.dialogueAction = 10000;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void chatboxText(String text, String text1, String text2,
|
public void chatboxText(String text, String text1, String text2,
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.rs2.game.dialogues;
|
package com.rs2.game.dialogues;
|
||||||
|
|
||||||
|
import com.rs2.game.bots.Bot;
|
||||||
|
import com.rs2.game.bots.BotHandler;
|
||||||
import com.rs2.game.content.skills.crafting.JewelryMaking;
|
import com.rs2.game.content.skills.crafting.JewelryMaking;
|
||||||
import com.rs2.game.items.impl.Flowers;
|
import com.rs2.game.items.impl.Flowers;
|
||||||
import com.rs2.game.items.impl.Teles;
|
import com.rs2.game.items.impl.Teles;
|
||||||
@@ -93,6 +95,14 @@ public class DialogueOptions {
|
|||||||
case 7555: //lostCity 1
|
case 7555: //lostCity 1
|
||||||
player.getDialogueHandler().sendDialogues(3701, player.npcType);
|
player.getDialogueHandler().sendDialogues(3701, player.npcType);
|
||||||
return;
|
return;
|
||||||
|
case 10000: // Shop
|
||||||
|
if (!player.inPlayerShopArea()) {
|
||||||
|
player.getDialogueHandler().sendStatement("You need to be in a bank zone or trade area for this.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.getDialogueHandler().sendStatement("You summoned your shop!");
|
||||||
|
BotHandler.playerShop(player);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
player.dialogueAction = 0;
|
player.dialogueAction = 0;
|
||||||
player.getPacketSender().closeAllWindows();
|
player.getPacketSender().closeAllWindows();
|
||||||
@@ -177,6 +187,10 @@ public class DialogueOptions {
|
|||||||
case 7555:
|
case 7555:
|
||||||
player.getDialogueHandler().sendDialogues(3597, player.npcType);
|
player.getDialogueHandler().sendDialogues(3597, player.npcType);
|
||||||
return;
|
return;
|
||||||
|
case 10000:
|
||||||
|
player.getDialogueHandler().sendStatement("You close your shop!");
|
||||||
|
BotHandler.closeShop(player);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
player.dialogueAction = 0;
|
player.dialogueAction = 0;
|
||||||
player.getPacketSender().closeAllWindows();
|
player.getPacketSender().closeAllWindows();
|
||||||
@@ -264,6 +278,10 @@ public class DialogueOptions {
|
|||||||
case 7555:
|
case 7555:
|
||||||
player.getDialogueHandler().sendDialogues(3599, player.npcType);
|
player.getDialogueHandler().sendDialogues(3599, player.npcType);
|
||||||
return;
|
return;
|
||||||
|
case 10000:
|
||||||
|
player.getDialogueHandler().sendStatement("You withdraw " + Bot.formatSellPrice(BotHandler.checkCoins(player)) + " from your shop!");
|
||||||
|
BotHandler.takeCoins(player);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
player.dialogueAction = 0;
|
player.dialogueAction = 0;
|
||||||
player.getPacketSender().closeAllWindows();
|
player.getPacketSender().closeAllWindows();
|
||||||
|
|||||||
@@ -2526,6 +2526,10 @@ public abstract class Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int calculateCombatLevel() {
|
public int calculateCombatLevel() {
|
||||||
|
// Show the bots as level 0 combat
|
||||||
|
if (isBot) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
int j = getLevelForXP(playerXP[playerAttack]);
|
int j = getLevelForXP(playerXP[playerAttack]);
|
||||||
int k = getLevelForXP(playerXP[playerDefence]);
|
int k = getLevelForXP(playerXP[playerDefence]);
|
||||||
int l = getLevelForXP(playerXP[playerStrength]);
|
int l = getLevelForXP(playerXP[playerStrength]);
|
||||||
|
|||||||
@@ -526,8 +526,8 @@ public class ShopAssistant {
|
|||||||
int value = 0;
|
int value = 0;
|
||||||
int currency = 995;
|
int currency = 995;
|
||||||
// player owned shop
|
// player owned shop
|
||||||
boolean showIsOwnedByThisPlayer = ShopHandler.playerOwnsStore(player.shopId, player);
|
boolean shopIsOwnedByThisPlayer = ShopHandler.playerOwnsStore(player.shopId, player);
|
||||||
if (showIsOwnedByThisPlayer) { // PLayers own shop, no cost
|
if (shopIsOwnedByThisPlayer) { // PLayers own shop, no cost
|
||||||
value = 0;
|
value = 0;
|
||||||
currency = -1;
|
currency = -1;
|
||||||
} else if (isPlayerShop) { // Shop owned by another player
|
} else if (isPlayerShop) { // Shop owned by another player
|
||||||
@@ -573,7 +573,7 @@ public class ShopAssistant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String itemName = ItemAssistant.getItemName(itemID).toLowerCase();
|
String itemName = ItemAssistant.getItemName(itemID).toLowerCase();
|
||||||
if (!showIsOwnedByThisPlayer) {
|
if (!shopIsOwnedByThisPlayer) {
|
||||||
player.getItemAssistant().deleteItem(currency, totalValue);
|
player.getItemAssistant().deleteItem(currency, totalValue);
|
||||||
player.getPacketSender().sendMessage("You bought " + amount + " " + itemName + " for " + totalValue + " " + currencyName + "." );
|
player.getPacketSender().sendMessage("You bought " + amount + " " + itemName + " for " + totalValue + " " + currencyName + "." );
|
||||||
// If it is a player owned shop, we need to give them the coins
|
// If it is a player owned shop, we need to give them the coins
|
||||||
|
|||||||
@@ -94,17 +94,6 @@ public class ShopHandler {
|
|||||||
shopItemsDelay[i][j]++;
|
shopItemsDelay[i][j]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DidUpdate) {
|
|
||||||
for (int k = 1; k < PlayerHandler.players.length; k++) {
|
|
||||||
if (PlayerHandler.players[k] != null) {
|
|
||||||
if (PlayerHandler.players[k].isShopping && PlayerHandler.players[k].shopId == i) {
|
|
||||||
PlayerHandler.players[k].updateShop = true;
|
|
||||||
PlayerHandler.players[k].updateShop(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DidUpdate = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,6 +232,20 @@ public class ShopHandler {
|
|||||||
totalshops++;
|
totalshops++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void closePlayerShop(Client player) {
|
||||||
|
for (int id = getEmptyshop(); id >= 0; id--) {
|
||||||
|
if (shopName[id].equals(player.properName + "'s Store")) {
|
||||||
|
for (int i = 0; i < MAX_SHOP_ITEMS; i++) {
|
||||||
|
shopItems[id][i] = 0;
|
||||||
|
shopItemsN[id][i] = 0;
|
||||||
|
shopItemsSN[id][i] = 0;
|
||||||
|
shopItemsDelay[id][i] = 0;
|
||||||
|
}
|
||||||
|
refreshshop(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static int getEmptyshop() {
|
private static int getEmptyshop() {
|
||||||
for (int i = 0; i < MAX_SHOPS; i++) {
|
for (int i = 0; i < MAX_SHOPS; i++) {
|
||||||
if (shopName[i].equals("")) {
|
if (shopName[i].equals("")) {
|
||||||
@@ -266,6 +269,15 @@ public class ShopHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int k = 1; k < PlayerHandler.players.length; k++) {
|
||||||
|
if (PlayerHandler.players[k] != null) {
|
||||||
|
if (PlayerHandler.players[k].isShopping && PlayerHandler.players[k].shopId == shop_id) {
|
||||||
|
PlayerHandler.players[k].updateShop = true;
|
||||||
|
PlayerHandler.players[k].updateShop(shop_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getStock(int shop_id, int item_id) {
|
public static int getStock(int shop_id, int item_id) {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class Commands implements PacketType {
|
|||||||
|
|
||||||
public static void playerCommands(Player player, String playerCommand, String[] arguments) {
|
public static void playerCommands(Player player, String playerCommand, String[] arguments) {
|
||||||
switch (playerCommand.toLowerCase()) {
|
switch (playerCommand.toLowerCase()) {
|
||||||
case "hideYell":
|
case "hideyell":
|
||||||
player.hideYell = !player.hideYell;
|
player.hideYell = !player.hideYell;
|
||||||
player.getPacketSender().sendMessage("Your yell visibility preferences have been updated.");
|
player.getPacketSender().sendMessage("Your yell visibility preferences have been updated.");
|
||||||
break;
|
break;
|
||||||
@@ -173,9 +173,6 @@ public class Commands implements PacketType {
|
|||||||
case "prayer":
|
case "prayer":
|
||||||
player.getPacketSender().sendMessage(String.format("Prayer points: %d", player.playerLevel[5]));
|
player.getPacketSender().sendMessage(String.format("Prayer points: %d", player.playerLevel[5]));
|
||||||
break;
|
break;
|
||||||
case "shop":
|
|
||||||
BotHandler.playerShop(player);
|
|
||||||
break;
|
|
||||||
case "snow":
|
case "snow":
|
||||||
Calendar date = new GregorianCalendar();
|
Calendar date = new GregorianCalendar();
|
||||||
if ((date.get(Calendar.MONTH) + 1) == 12 && !player.inWild()) {
|
if ((date.get(Calendar.MONTH) + 1) == 12 && !player.inWild()) {
|
||||||
@@ -189,6 +186,9 @@ public class Commands implements PacketType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "shop":
|
||||||
|
player.getDialogueHandler().sendDialogues(10000, 0);
|
||||||
|
break;
|
||||||
case "withdrawshop":
|
case "withdrawshop":
|
||||||
player.getPacketSender().sendMessage("Shorter version: ::wshop");
|
player.getPacketSender().sendMessage("Shorter version: ::wshop");
|
||||||
case "wshop":
|
case "wshop":
|
||||||
|
|||||||
Reference in New Issue
Block a user