Merge remote-tracking branch 'upstream/master'

This commit is contained in:
skelsoft
2021-07-18 06:52:49 +10:00
9 changed files with 145 additions and 101 deletions
+66 -41
View File
@@ -2584,28 +2584,28 @@
], ],
"charm": [ "charm": [
{ {
"minAmount": "1", "minAmount": "3",
"weight": "100.0", "weight": "16.0",
"id": "12158", "id": "12158",
"maxAmount": "1" "maxAmount": "3"
}, },
{ {
"minAmount": "1", "minAmount": "3",
"weight": "100.0", "weight": "64.0",
"id": "12159", "id": "12159",
"maxAmount": "1" "maxAmount": "3"
}, },
{ {
"minAmount": "1", "minAmount": "3",
"weight": "100.0", "weight": "16.0",
"id": "12160", "id": "12160",
"maxAmount": "1" "maxAmount": "3"
}, },
{ {
"minAmount": "1", "minAmount": "3",
"weight": "100.0", "weight": "4.0",
"id": "12163", "id": "12163",
"maxAmount": "1" "maxAmount": "3"
} }
], ],
"ids": "54,4673,4674,4675,4676", "ids": "54,4673,4674,4675,4676",
@@ -3945,25 +3945,25 @@
"charm": [ "charm": [
{ {
"minAmount": "1", "minAmount": "1",
"weight": "100.0", "weight": "20.0",
"id": "12158", "id": "12158",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "100.0", "weight": "75.0",
"id": "12159", "id": "12159",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "100.0", "weight": "4.0",
"id": "12160", "id": "12160",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "100.0", "weight": "1.0",
"id": "12163", "id": "12163",
"maxAmount": "1" "maxAmount": "1"
} }
@@ -23116,7 +23116,32 @@
"maxAmount": "1" "maxAmount": "1"
} }
], ],
"charm": [], "charm": [
{
"minAmount": "1",
"weight": "28.0",
"id": "12158",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "14.0",
"id": "12159",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "56.0",
"id": "12160",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "2.0",
"id": "12163",
"maxAmount": "1"
}
],
"ids": "2455,2456", "ids": "2455,2456",
"description": "Waterbirth Dagannoths", "description": "Waterbirth Dagannoths",
"main": [ "main": [
@@ -26326,25 +26351,25 @@
"charm": [ "charm": [
{ {
"minAmount": "1", "minAmount": "1",
"weight": "100.0", "weight": "12.0",
"id": "12158", "id": "12158",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "100.0", "weight": "12.0",
"id": "12159", "id": "12159",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "100.0", "weight": "72.0",
"id": "12160", "id": "12160",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "100.0", "weight": "4.0",
"id": "12163", "id": "12163",
"maxAmount": "1" "maxAmount": "1"
} }
@@ -34882,25 +34907,25 @@
"charm": [ "charm": [
{ {
"minAmount": "1", "minAmount": "1",
"weight": "100.0", "weight": "25.0",
"id": "12158", "id": "12158",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "100.0", "weight": "10.0",
"id": "12159", "id": "12159",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "100.0", "weight": "25.0",
"id": "12160", "id": "12160",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "100.0", "weight": "40.0",
"id": "12163", "id": "12163",
"maxAmount": "1" "maxAmount": "1"
} }
@@ -36939,28 +36964,28 @@
"default": [], "default": [],
"charm": [ "charm": [
{ {
"minAmount": "1", "minAmount": "2",
"weight": "100.0", "weight": "27.0",
"id": "12158", "id": "12158",
"maxAmount": "1" "maxAmount": "2"
}, },
{ {
"minAmount": "1", "minAmount": "2",
"weight": "100.0", "weight": "18.0",
"id": "12159", "id": "12159",
"maxAmount": "1" "maxAmount": "2"
}, },
{ {
"minAmount": "1", "minAmount": "2",
"weight": "100.0", "weight": "50.0",
"id": "12160", "id": "12160",
"maxAmount": "1" "maxAmount": "2"
}, },
{ {
"minAmount": "1", "minAmount": "2",
"weight": "100.0", "weight": "5.0",
"id": "12163", "id": "12163",
"maxAmount": "1" "maxAmount": "2"
} }
], ],
"ids": "2889", "ids": "2889",
@@ -44420,25 +44445,25 @@
"charm": [ "charm": [
{ {
"minAmount": "1", "minAmount": "1",
"weight": "100.0", "weight": "13.0",
"id": "12158", "id": "12158",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "100.0", "weight": "5.0",
"id": "12159", "id": "12159",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "100.0", "weight": "80.0",
"id": "12160", "id": "12160",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "100.0", "weight": "2.0",
"id": "12163", "id": "12163",
"maxAmount": "1" "maxAmount": "1"
} }
+31 -31
View File
@@ -4438,7 +4438,7 @@
{ {
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "This needs refining.", "examine": "This needs refining.",
"grand_exchange_price": "230", "grand_exchange_price": "204",
"tokkul_price": "25", "tokkul_price": "25",
"durability": null, "durability": null,
"name": "Iron ore", "name": "Iron ore",
@@ -4467,7 +4467,7 @@
"low_alchemy": "30", "low_alchemy": "30",
"high_alchemy": "45", "high_alchemy": "45",
"weight": "2", "weight": "2",
"grand_exchange_price": "205", "grand_exchange_price": "180",
"name": "Silver ore", "name": "Silver ore",
"tradeable": "true", "tradeable": "true",
"archery_ticket_price": "0", "archery_ticket_price": "0",
@@ -4485,7 +4485,7 @@
{ {
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "This needs refining.", "examine": "This needs refining.",
"grand_exchange_price": "319", "grand_exchange_price": "311",
"tokkul_price": "225", "tokkul_price": "225",
"durability": null, "durability": null,
"name": "Gold ore", "name": "Gold ore",
@@ -4523,7 +4523,7 @@
"low_alchemy": "64", "low_alchemy": "64",
"high_alchemy": "97", "high_alchemy": "97",
"weight": "1.75", "weight": "1.75",
"grand_exchange_price": "460", "grand_exchange_price": "420",
"name": "Mithril ore", "name": "Mithril ore",
"tradeable": "true", "tradeable": "true",
"archery_ticket_price": "0", "archery_ticket_price": "0",
@@ -4547,7 +4547,7 @@
"low_alchemy": "160", "low_alchemy": "160",
"high_alchemy": "240", "high_alchemy": "240",
"weight": "2.7", "weight": "2.7",
"grand_exchange_price": "1330", "grand_exchange_price": "1160",
"name": "Adamantite ore", "name": "Adamantite ore",
"tradeable": "true", "tradeable": "true",
"archery_ticket_price": "0", "archery_ticket_price": "0",
@@ -4588,7 +4588,7 @@
{ {
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "Hmm a non-renewable energy source!", "examine": "Hmm a non-renewable energy source!",
"grand_exchange_price": "350", "grand_exchange_price": "320",
"tokkul_price": "67", "tokkul_price": "67",
"durability": null, "durability": null,
"name": "Coal", "name": "Coal",
@@ -5539,7 +5539,7 @@
"shop_price": "17", "shop_price": "17",
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "One of the 4 basic elemental Runes.", "examine": "One of the 4 basic elemental Runes.",
"grand_exchange_price": "17", "grand_exchange_price": "18",
"tokkul_price": "6", "tokkul_price": "6",
"durability": null, "durability": null,
"name": "Fire rune", "name": "Fire rune",
@@ -5553,7 +5553,7 @@
"shop_price": "17", "shop_price": "17",
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "One of the 4 basic elemental Runes.", "examine": "One of the 4 basic elemental Runes.",
"grand_exchange_price": "17", "grand_exchange_price": "18",
"tokkul_price": "6", "tokkul_price": "6",
"durability": null, "durability": null,
"name": "Water rune", "name": "Water rune",
@@ -5567,7 +5567,7 @@
"shop_price": "17", "shop_price": "17",
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "One of the 4 basic elemental Runes.", "examine": "One of the 4 basic elemental Runes.",
"grand_exchange_price": "17", "grand_exchange_price": "18",
"tokkul_price": "6", "tokkul_price": "6",
"durability": null, "durability": null,
"name": "Air rune", "name": "Air rune",
@@ -5581,7 +5581,7 @@
"shop_price": "17", "shop_price": "17",
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "One of the 4 basic elemental Runes.", "examine": "One of the 4 basic elemental Runes.",
"grand_exchange_price": "17", "grand_exchange_price": "18",
"tokkul_price": "6", "tokkul_price": "6",
"durability": null, "durability": null,
"name": "Earth rune", "name": "Earth rune",
@@ -5595,7 +5595,7 @@
"shop_price": "17", "shop_price": "17",
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "Used for basic missile spells.", "examine": "Used for basic missile spells.",
"grand_exchange_price": "17", "grand_exchange_price": "18",
"tokkul_price": "4", "tokkul_price": "4",
"durability": null, "durability": null,
"name": "Mind rune", "name": "Mind rune",
@@ -5623,7 +5623,7 @@
"shop_price": "310", "shop_price": "310",
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "Used for medium missile spells.", "examine": "Used for medium missile spells.",
"grand_exchange_price": "235", "grand_exchange_price": "320",
"durability": null, "durability": null,
"name": "Death rune", "name": "Death rune",
"tradeable": "true", "tradeable": "true",
@@ -5636,7 +5636,7 @@
"shop_price": "372", "shop_price": "372",
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "Used for alchemy spells.", "examine": "Used for alchemy spells.",
"grand_exchange_price": "325", "grand_exchange_price": "380",
"durability": null, "durability": null,
"name": "Nature rune", "name": "Nature rune",
"tradeable": "true", "tradeable": "true",
@@ -5649,7 +5649,7 @@
"shop_price": "140", "shop_price": "140",
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "Used for small missile spells.", "examine": "Used for small missile spells.",
"grand_exchange_price": "145", "grand_exchange_price": "140",
"durability": null, "durability": null,
"name": "Chaos rune", "name": "Chaos rune",
"tradeable": "true", "tradeable": "true",
@@ -5662,7 +5662,7 @@
"shop_price": "378", "shop_price": "378",
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "Used for teleport spells.", "examine": "Used for teleport spells.",
"grand_exchange_price": "350", "grand_exchange_price": "380",
"durability": null, "durability": null,
"name": "Law rune", "name": "Law rune",
"tradeable": "true", "tradeable": "true",
@@ -5675,7 +5675,7 @@
"shop_price": "232", "shop_price": "232",
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "Used for enchant spells.", "examine": "Used for enchant spells.",
"grand_exchange_price": "180", "grand_exchange_price": "240",
"durability": null, "durability": null,
"name": "Cosmic rune", "name": "Cosmic rune",
"tradeable": "true", "tradeable": "true",
@@ -5688,7 +5688,7 @@
"shop_price": "550", "shop_price": "550",
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "Used for large missile spells.", "examine": "Used for large missile spells.",
"grand_exchange_price": "435", "grand_exchange_price": "560",
"durability": null, "durability": null,
"name": "Blood rune", "name": "Blood rune",
"tradeable": "true", "tradeable": "true",
@@ -5701,7 +5701,7 @@
"shop_price": "400", "shop_price": "400",
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "Used for high level curse spells.", "examine": "Used for high level curse spells.",
"grand_exchange_price": "230", "grand_exchange_price": "420",
"durability": null, "durability": null,
"name": "Soul rune", "name": "Soul rune",
"tradeable": "true", "tradeable": "true",
@@ -17251,7 +17251,7 @@
{ {
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "Logs cut from a magic tree.", "examine": "Logs cut from a magic tree.",
"grand_exchange_price": "750", "grand_exchange_price": "680",
"durability": null, "durability": null,
"name": "Magic logs", "name": "Magic logs",
"tradeable": "true", "tradeable": "true",
@@ -17273,7 +17273,7 @@
{ {
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "Logs cut from a yew tree.", "examine": "Logs cut from a yew tree.",
"grand_exchange_price": "360", "grand_exchange_price": "320",
"durability": null, "durability": null,
"name": "Yew logs", "name": "Yew logs",
"tradeable": "true", "tradeable": "true",
@@ -17295,7 +17295,7 @@
{ {
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "Logs cut from a maple tree.", "examine": "Logs cut from a maple tree.",
"grand_exchange_price": "180", "grand_exchange_price": "160",
"durability": null, "durability": null,
"name": "Maple logs", "name": "Maple logs",
"tradeable": "true", "tradeable": "true",
@@ -17339,7 +17339,7 @@
{ {
"ge_buy_limit": "25000", "ge_buy_limit": "25000",
"examine": "Logs cut from an Oak Tree.", "examine": "Logs cut from an Oak Tree.",
"grand_exchange_price": "160", "grand_exchange_price": "140",
"durability": null, "durability": null,
"name": "Oak logs", "name": "Oak logs",
"tradeable": "true", "tradeable": "true",
@@ -18029,7 +18029,7 @@
{ {
"ge_buy_limit": "1000", "ge_buy_limit": "1000",
"examine": "A semi precious stone.", "examine": "A semi precious stone.",
"grand_exchange_price": "41", "grand_exchange_price": "44",
"durability": null, "durability": null,
"name": "Opal", "name": "Opal",
"tradeable": "true", "tradeable": "true",
@@ -18049,7 +18049,7 @@
}, },
{ {
"ge_buy_limit": "1000", "ge_buy_limit": "1000",
"grand_exchange_price": "83", "grand_exchange_price": "84",
"durability": null, "durability": null,
"name": "Jade", "name": "Jade",
"archery_ticket_price": "0", "archery_ticket_price": "0",
@@ -18067,7 +18067,7 @@
{ {
"ge_buy_limit": "1000", "ge_buy_limit": "1000",
"examine": "A semi precious stone.", "examine": "A semi precious stone.",
"grand_exchange_price": "103", "grand_exchange_price": "120",
"durability": null, "durability": null,
"name": "Red topaz", "name": "Red topaz",
"tradeable": "true", "tradeable": "true",
@@ -18112,7 +18112,7 @@
{ {
"ge_buy_limit": "500", "ge_buy_limit": "500",
"examine": "An uncut diamond.", "examine": "An uncut diamond.",
"grand_exchange_price": "20000", "grand_exchange_price": "2160",
"tokkul_price": "300", "tokkul_price": "300",
"durability": null, "durability": null,
"name": "Uncut diamond", "name": "Uncut diamond",
@@ -18134,7 +18134,7 @@
{ {
"ge_buy_limit": "1000", "ge_buy_limit": "1000",
"examine": "An uncut ruby.", "examine": "An uncut ruby.",
"grand_exchange_price": "4970", "grand_exchange_price": "1140",
"tokkul_price": "150", "tokkul_price": "150",
"durability": null, "durability": null,
"name": "Uncut ruby", "name": "Uncut ruby",
@@ -18157,7 +18157,7 @@
"shop_price": "50", "shop_price": "50",
"ge_buy_limit": "1000", "ge_buy_limit": "1000",
"examine": "An uncut emerald.", "examine": "An uncut emerald.",
"grand_exchange_price": "2621", "grand_exchange_price": "580",
"tokkul_price": "75", "tokkul_price": "75",
"durability": null, "durability": null,
"name": "Uncut emerald", "name": "Uncut emerald",
@@ -18180,7 +18180,7 @@
"shop_price": "25", "shop_price": "25",
"ge_buy_limit": "1000", "ge_buy_limit": "1000",
"examine": "An uncut sapphire.", "examine": "An uncut sapphire.",
"grand_exchange_price": "1851", "grand_exchange_price": "420",
"tokkul_price": "37", "tokkul_price": "37",
"durability": null, "durability": null,
"name": "Uncut sapphire", "name": "Uncut sapphire",
@@ -19424,7 +19424,7 @@
{ {
"ge_buy_limit": "10000", "ge_buy_limit": "10000",
"examine": "I should take this to the tannery.", "examine": "I should take this to the tannery.",
"grand_exchange_price": "150", "grand_exchange_price": "140",
"durability": null, "durability": null,
"name": "Cowhide", "name": "Cowhide",
"tradeable": "true", "tradeable": "true",
@@ -19838,7 +19838,7 @@
{ {
"ge_buy_limit": "10000", "ge_buy_limit": "10000",
"examine": "I need a bow stave to attach this to.", "examine": "I need a bow stave to attach this to.",
"grand_exchange_price": "250", "grand_exchange_price": "240",
"durability": null, "durability": null,
"name": "Bow string", "name": "Bow string",
"tradeable": "true", "tradeable": "true",
@@ -604,6 +604,7 @@ public class Shop {
*/ */
public int getSellingValue(Item item, Player player) { public int getSellingValue(Item item, Player player) {
if (!item.getDefinition().isUnnoted()) { if (!item.getDefinition().isUnnoted()) {
player.setAttribute("shop:originalId",item.getId());
item = new Item(item.getNoteChange(), item.getAmount()); item = new Item(item.getNoteChange(), item.getAmount());
} }
int amount = getContainer(1).getAmount(item); int amount = getContainer(1).getAmount(item);
@@ -622,8 +623,10 @@ public class Shop {
* @return the selling value. * @return the selling value.
*/ */
private int getSellValue(Player player, int amount, Item item) { private int getSellValue(Player player, int amount, Item item) {
if(item.getAmount() > ContentAPI.amountInInventory(player, item.getId())){ int id = player.getAttribute("shop:originalId",item.getId());
item.setAmount(ContentAPI.amountInInventory(player, item.getId())); if(item.getAmount() > ContentAPI.amountInInventory(player, id)){
item.setAmount(ContentAPI.amountInInventory(player, id));
player.removeAttribute("shop:originalId");
} }
double diff = item.getDefinition().isStackable() ? 0.005 : 0.05; double diff = item.getDefinition().isStackable() ? 0.005 : 0.05;
double maxMod = 1.0 - (amount * diff); double maxMod = 1.0 - (amount * diff);
@@ -635,6 +638,7 @@ public class Shop {
minMod = 0.25; minMod = 0.25;
} }
double mod = (maxMod + minMod) / 2; double mod = (maxMod + minMod) / 2;
SystemLogger.logInfo("" + item.getDefinition().getAlchemyValue(highAlch) + " " + mod + " " + item.getAmount());
int value = (int) (item.getDefinition().getAlchemyValue(highAlch) * mod * item.getAmount()); int value = (int) (item.getDefinition().getAlchemyValue(highAlch) * mod * item.getAmount());
if(item.getId() == 12183){ if(item.getId() == 12183){
value = 25 * item.getAmount(); value = 25 * item.getAmount();
@@ -62,6 +62,12 @@ public class AggressiveBehavior {
* @return {@code True} if the NPC can select the entity as a target. * @return {@code True} if the NPC can select the entity as a target.
*/ */
public boolean canSelectTarget(Entity entity, Entity target) { public boolean canSelectTarget(Entity entity, Entity target) {
int regionId = target.getLocation().getRegionId();
if(target instanceof Player) {
if (RegionManager.forId(regionId).isTolerated(target.asPlayer())) {
return false;
}
}
if (!target.isActive() || DeathTask.isDead(target)) { if (!target.isActive() || DeathTask.isDead(target)) {
return false; return false;
} }
@@ -81,9 +81,10 @@ public final class AggressiveHandler {
Entity target = behavior.getLogicalTarget(entity, behavior.getPossibleTargets(entity, radius)); Entity target = behavior.getLogicalTarget(entity, behavior.getPossibleTargets(entity, radius));
if (target instanceof Player) { if (target instanceof Player) {
if (target.getAttribute("ignore_aggression", false)) { if (target.getAttribute("ignore_aggression", false)) {
if (((Player) target).getRights().equals(Rights.ADMINISTRATOR)) { return false;
return false; }
} if (((Player) target).getRights().equals(Rights.ADMINISTRATOR)) {
return false;
} }
} }
if (target != null) { if (target != null) {
@@ -5,7 +5,9 @@ import core.game.node.entity.combat.BattleState;
import core.game.node.entity.npc.AbstractNPC; import core.game.node.entity.npc.AbstractNPC;
import core.game.node.entity.npc.agg.AggressiveBehavior; import core.game.node.entity.npc.agg.AggressiveBehavior;
import core.game.node.entity.npc.agg.AggressiveHandler; import core.game.node.entity.npc.agg.AggressiveHandler;
import core.game.node.entity.player.Player;
import core.game.world.map.Location; import core.game.world.map.Location;
import core.game.world.map.RegionManager;
import core.plugin.Initializable; import core.plugin.Initializable;
import core.tools.RandomFunction; import core.tools.RandomFunction;
@@ -22,6 +24,10 @@ public final class RockCrabNPC extends AbstractNPC {
private static final AggressiveBehavior AGGRO_BEHAVIOR = new AggressiveBehavior() { private static final AggressiveBehavior AGGRO_BEHAVIOR = new AggressiveBehavior() {
@Override @Override
public boolean canSelectTarget(Entity entity, Entity target) { public boolean canSelectTarget(Entity entity, Entity target) {
int regionId = target.getLocation().getRegionId();
if(target instanceof Player){
if(RegionManager.forId(regionId).isTolerated(target.asPlayer())) return false;
}
RockCrabNPC npc = (RockCrabNPC) entity; RockCrabNPC npc = (RockCrabNPC) entity;
if (entity.getLocation().withinDistance(target.getLocation(), 3)) { if (entity.getLocation().withinDistance(target.getLocation(), 3)) {
npc.aggresor = true; npc.aggresor = true;
@@ -267,16 +267,10 @@ public final class HouseManager {
int diffX = player.getLocation().getX() - r.getBaseLocation().getX(); int diffX = player.getLocation().getX() - r.getBaseLocation().getX();
int diffY = player.getLocation().getY() - r.getBaseLocation().getY(); int diffY = player.getLocation().getY() - r.getBaseLocation().getY();
int diffZ = player.getLocation().getZ() - r.getBaseLocation().getZ(); int diffZ = player.getLocation().getZ() - r.getBaseLocation().getZ();
DynamicRegion dr = region;
DynamicRegion dd = dungeon;
RegionManager.getRegionCache().remove(dr);
RegionManager.getRegionCache().remove(dd);
region = null; region = null;
dungeon = null; dungeon = null;
enter(player, buildingMode, false); enter(player, buildingMode, false);
player.getProperties().setTeleportLocation((player.getViewport().getRegion() == dungeon ? dungeon : region).getBaseLocation().transform(diffX, diffY, diffZ)); player.getProperties().setTeleportLocation((player.getViewport().getRegion() == dungeon ? dungeon : region).getBaseLocation().transform(diffX, diffY, diffZ));
dr.flagInactive();
dd.flagInactive();
} }
/** /**
@@ -16,7 +16,9 @@ import rs09.game.world.repository.Repository;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
/** /**
* Represents a region. * Represents a region.
@@ -60,6 +62,11 @@ public class Region {
*/ */
private final List<MusicZone> musicZones = new ArrayList<>(20); private final List<MusicZone> musicZones = new ArrayList<>(20);
/**
* Keeps track of players and time in region for tolerance purposes
*/
private final HashMap<String,Long> tolerances = new HashMap<>();
/** /**
* If the region is active. * If the region is active.
*/ */
@@ -146,6 +153,7 @@ public class Region {
*/ */
public void add(Player player) { public void add(Player player) {
planes[player.getLocation().getZ()].add(player); planes[player.getLocation().getZ()].add(player);
tolerances.put(player.getUsername(), System.currentTimeMillis());
flagActive(); flagActive();
} }
@@ -175,9 +183,17 @@ public class Region {
*/ */
public void remove(Player player) { public void remove(Player player) {
player.getViewport().getCurrentPlane().remove(player); player.getViewport().getCurrentPlane().remove(player);
tolerances.remove(player.getUsername());
checkInactive(); checkInactive();
} }
/**
* Checks if player is tolerated by enemies in this region
*/
public boolean isTolerated(Player player){
return System.currentTimeMillis() - tolerances.getOrDefault(player.getUsername(), System.currentTimeMillis()) > TimeUnit.MINUTES.toMillis(10);
}
/** /**
* Checks if the region is inactive, if so it will start the inactivity flagging. * Checks if the region is inactive, if so it will start the inactivity flagging.
* @return {@code True} if the region is inactive. * @return {@code True} if the region is inactive.
@@ -299,31 +315,22 @@ public class Region {
} }
} }
/**
* Unloads a region - compatibility method for older uses
*/
private static void unload(Region r){
unload(r, false);
}
/** /**
* Unloads a region. * Unloads a region.
* @param r The region. * @param r The region.
*/ */
private static void unload(Region r, boolean force) { private static void unload(Region r) {
if(!force){ if (r.isViewed()) {
if (r.isViewed()) { SystemLogger.logErr("Players viewing region!");
SystemLogger.logErr("Players viewing region!"); r.flagActive();
return;
}
for (RegionPlane p : r.planes) {
if (!p.getPlayers().isEmpty()) {
SystemLogger.logErr("Players still in region!");
r.flagActive(); r.flagActive();
return; return;
} }
for (RegionPlane p : r.planes) {
if (!p.getPlayers().isEmpty()) {
SystemLogger.logErr("Players still in region!");
r.flagActive();
return;
}
}
} }
for (RegionPlane p : r.planes) { for (RegionPlane p : r.planes) {
p.clear(); p.clear();
@@ -90,6 +90,7 @@ public final class MultiwayCombatZone extends MapZone {
registerRegion(12603);//Callisto registerRegion(12603);//Callisto
registerRegion(14939);//Kalphite Stronghold Cave registerRegion(14939);//Kalphite Stronghold Cave
registerRegion(9532); //Isle north of Jatizso registerRegion(9532); //Isle north of Jatizso
registerRegion(10810); //Eastern rock crabs
} }
@Override @Override