Squash everything because testbot wants me to rebase

# Conflicts:
#	Server/src/main/core/game/world/map/Location.kt
#	Server/src/main/core/game/world/map/RegionManager.kt
This commit is contained in:
Player Name 2026-05-30 18:14:37 +02:00
parent be744e73b3
commit 9dbd71c41f
188 changed files with 7097 additions and 10946 deletions

View file

@ -1,7 +1,7 @@
variables:
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true -Xmx3g"
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true -Xmx4g -Xms2g"
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
# when running from the command line.
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-fast --show-version"

View file

@ -1,27 +0,0 @@
<parsing>
<ObjectAction mode="add" id="1814" x="3090" y="3475" z="0" type="4" direction="nw"/>
<ObjectAction mode="add" id="2646" x="2445" y="3413" z="0" direction="nw"/>
<ObjectAction mode="add" id="2646" x="2447" y="3414" z="0" direction="e"/>
<ObjectAction mode="add" id="2646" x="2447" y="3421" z="0" direction="nw"/>
<ObjectAction mode="remove" id="37670" x="3292" y="3299" z="0"/>
<ObjectAction mode="add" id="37304" x="3292" y="3299" z="0"/>
<ObjectAction mode="add" id="20987" x="3821" y="2996" z="0"/>
<ObjectAction mode="remove" id="356" x="2804" y="3428" z="0"/>
<ObjectAction mode="add" id="356" x="2804" y="3428" z="0"/>
<ObjectAction mode="remove" id="20228" x="2537" y="3573" z="0"/>
<ObjectAction mode="add" id="27663" x="2537" y="3573" z="0" direction="w"/>
<ObjectAction mode="add" id="39237" x="2957" y="3266" z="0" direction="n"/>
<ObjectAction mode="add" id="39245" x="2956" y="3270" z="0" direction="se"/>
<ObjectAction mode="add" id="39242" x="2955" y="3273" z="0" direction="w"/>
<ObjectAction mode="add" id="39241" x="2955" y="3274" z="0" />
<ObjectAction mode="add" id="20987" x="2821" y="2996" z="0" direction="s"/>
<ObjectAction mode="add" id="21301" x="2662" y="3162" z="0" direction="e"/>
<ObjectAction mode="add" id="4176" x="2629" y="3661" z="2" type="4" direction="e"/>
</parsing>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,165 @@
[
{
"mode": "add",
"id": "1814",
"location": "3090, 3475, 0",
"type": "4",
"direction": "nw"
},
{
"mode": "add",
"id": "2646",
"location": "2445, 3413, 0",
"direction": "nw"
},
{
"mode": "add",
"id": "2646",
"location": "2447, 3414, 0",
"direction": "e"
},
{
"mode": "add",
"id": "2646",
"location": "2447, 3421, 0",
"direction": "nw"
},
{
"comment": "Prison Pete Random",
"mode": "add",
"id": "36788",
"location": "2094, 4465, 0",
"type": "10",
"direction": "e"
},
{
"comment": "Green Portal",
"mode": "remove",
"id": "11371",
"location": "2085, 4457, 0"
},
{
"comment": "Lever",
"mode": "remove",
"id": "10817",
"location": "2083, 4460, 0"
},
{
"comment": "Lever",
"mode": "add",
"id": "26191",
"location": "2083, 4460, 0",
"type": "10",
"direction": "e"
},
{
"comment": "Window",
"mode": "add",
"id": "26184",
"location": "2084, 4459, 0",
"type": "0",
"direction": "n"
},
{
"comment": "Door",
"mode": "add",
"id": "26186",
"location": "2085, 4459, 0",
"type": "0",
"direction": "n"
},
{
"comment": "Door",
"mode": "add",
"id": "26188",
"location": "2086, 4459, 0",
"type": "0",
"direction": "n"
},
{
"comment": "Window",
"mode": "add",
"id": "26184",
"location": "2087, 4459, 0",
"type": "0",
"direction": "n"
},
{
"mode": "remove",
"id": "37670",
"location": "3292, 3299, 0"
},
{
"mode": "add",
"id": "37304",
"location": "3292, 3299, 0"
},
{
"mode": "add",
"id": "20987",
"location": "3821, 2996, 0"
},
{
"mode": "remove",
"id": "356",
"location": "2804, 3428, 0"
},
{
"mode": "add",
"id": "356",
"location": "2804, 3428, 0"
},
{
"mode": "remove",
"id": "20228",
"location": "2537, 3573, 0"
},
{
"mode": "add",
"id": "27663",
"location": "2537, 3573, 0",
"direction": "w"
},
{
"mode": "add",
"id": "39237",
"location": "2957, 3266, 0",
"direction": "n"
},
{
"mode": "add",
"id": "39245",
"location": "2956, 3270, 0",
"direction": "se"
},
{
"mode": "add",
"id": "39242",
"location": "2955, 3273, 0",
"direction": "w"
},
{
"mode": "add",
"id": "39241",
"location": "2955, 3274, 0"
},
{
"mode": "add",
"id": "20987",
"location": "2821, 2996, 0",
"direction": "s"
},
{
"mode": "add",
"id": "21301",
"location": "2662, 3162, 0",
"direction": "e"
},
{
"mode": "add",
"id": "4176",
"location": "2629, 3661, 2",
"type": "4",
"direction": "e"
}
]

View file

@ -252,6 +252,7 @@
<configuration>
<useFile>false</useFile>
<trimStackTrace>false</trimStackTrace>
<argLine>-Xmx4g -Xms2g</argLine>
</configuration>
<version>2.22.0</version>
</plugin>

View file

@ -99,12 +99,18 @@ class ShootingStar(var level: ShootingStarType = ShootingStarType.values().rando
return ShootingStarType.values()[level.ordinal - 1]
}
/**
* Clears the current star object or sprite
*/
fun clear() {
SceneryBuilder.remove(starObject)
clearSprite()
}
/**
* Fires the shooting star (spawns a new one). Only used when spawning new shooting stars, not for downgrading existing ones.
*/
fun fire() {
SceneryBuilder.remove(starObject)
clearSprite()
SceneryBuilder.add(starObject)
if(!isSpawned) {
(0..2).forEach {

View file

@ -17,6 +17,7 @@ import core.game.world.GameWorld
import core.tools.Log
import core.tools.secondsToTicks
import content.data.Quests
import core.game.node.scenery.SceneryBuilder
class ShootingStarPlugin : LoginListener, InteractionListener, TickListener, Commands, StartupListener {
override fun login(player: Player) {
@ -46,6 +47,7 @@ class ShootingStarPlugin : LoginListener, InteractionListener, TickListener, Com
// Check if it's time to fire a new one
if (star.ticks >= tickDelay && !star.spriteSpawned) {
star.clear()
star.rebuildVars()
star.fire()
}
@ -133,11 +135,12 @@ class ShootingStarPlugin : LoginListener, InteractionListener, TickListener, Com
}
override fun defineCommands() {
define("tostar", Privilege.ADMIN, description = "Teleports you adjacent to the currently active star.") { player, _ ->
teleport(player, star.starObject.location.transform(1,1,0))
define("tostar", Privilege.ADMIN, description = "Teleports you inside the currently active star.") { player, _ ->
teleport(player, star.starObject.location.transform(0, 0, 0))
}
define("submit", Privilege.ADMIN, description = "Rebuilds and fires the shooting star event immediately.") { _, _ ->
star.clear()
star.rebuildVars()
star.fire()
}

View file

@ -8,12 +8,15 @@ import core.game.node.item.Item
import core.tools.RandomFunction
import org.rs09.consts.Items
import content.global.ame.RandomEventNPC
import core.api.sendMessage
import core.api.utils.WeightBasedTable
import core.game.world.map.MapDistance
val ids = (2463..2468).toList()
class EvilChickenNPC(override var loot: WeightBasedTable? = null) : RandomEventNPC(2463) {
val phrases = arrayOf("Bwuk","Bwuk bwuk bwuk","Flee from me, @name!","Begone, @name!","Bwaaaauuuk bwuk bwuk","MUAHAHAHAHAAA!")
var sentMessage = false
override fun talkTo(npc: NPC) {}
override fun init() {
@ -31,13 +34,17 @@ class EvilChickenNPC(override var loot: WeightBasedTable? = null) : RandomEventN
}
override fun tick() {
if(!player.location.withinDistance(this.location,8)){
this.terminate()
}
if(getWorldTicks() % 10 == 0){
sendChat(phrases.random().replace("@name",player.username.capitalize()))
if (!sentMessage) {
if (!player.location.withinDistance(this.location, 8)) {
// https://www.youtube.com/watch?v=v9p_I_Tq3JE
sendMessage(player, "The Evil Chicken realises you're out of range and vanishes.")
sentMessage = true
terminate()
}
if (getWorldTicks() % 10 == 0) {
sendChat(phrases.random().replace("@name", player.username.capitalize()))
}
}
super.tick()
if(!player.viewport.currentPlane.npcs.contains(this)) this.clear()
}
}

View file

@ -15,6 +15,7 @@ import core.game.node.entity.player.Player
import core.game.system.task.Pulse
import core.game.world.GameWorld.Pulser
import core.game.world.map.Location
import core.game.world.map.RegionManager
import core.game.world.map.zone.ZoneBorders
import core.game.world.map.zone.ZoneRestriction
import core.game.world.update.flag.context.Graphics
@ -109,73 +110,17 @@ class MazeInterface : InteractionListener, EventHook<TickEvent>, MapArea {
addItemOrDrop(player, REWARD_ITEM[randomNumber], itemQuantity.toInt())
}
}
/**
* Chest Location to rotation mapping.
* This is needed as it is impossible to obtain the underlying chest scenery for the rotation.
* 0: Facing North, 1: Facing East, 2: Facing South, 3: Facing West
*/
val chestLocationRotationMap = mapOf(
Location(2930, 4595, 0).toString() to 2,
Location(2924, 4572, 0).toString() to 2,
Location(2925, 4573, 0).toString() to 0,
Location(2900, 4578, 0).toString() to 2,
Location(2901, 4560, 0).toString() to 1,
Location(2890, 4599, 0).toString() to 2,
Location(2896, 4591, 0).toString() to 2,
Location(2895, 4592, 0).toString() to 1,
Location(2901, 4560, 0).toString() to 3,
Location(2918, 4590, 0).toString() to 1,
Location(2917, 4590, 0).toString() to 3,
)
/**
* Chest Interaction workaround
*
* The issue here is that the walls(3626) of the Maze are overlapping some(not all) chest sceneries.
*
* The types for the wallScenery:
* Type 0 - flat panel |
* Type 2 - right angle panel with rotation 0:r 1:7 2:> 3:L
* Type 3 - corner post . for angle edges of walls
*/
fun overrideScenery(wallScenery: core.game.node.scenery.Scenery, chestSceneryId: Int): core.game.node.scenery.Scenery {
if (wallScenery.id == chestSceneryId) {
replaceScenery(wallScenery, Scenery.CHEST_3636, 30)
wallScenery.isActive = true
return wallScenery // Return the chest scenery as the wallScenery isn't there.
}
addScenery(Scenery.CHEST_3636, wallScenery.location, chestLocationRotationMap[wallScenery.location.toString()] ?: 0, 10)
addScenery(wallScenery)
// replaceScenery(newChestScenery, Scenery.CHEST_3636, 3) // didn't work for an underlying scenery
// I did a world pulse since everyone will get to see the chest open.
Pulser.submit(object : Pulse(30) {
override fun pulse(): Boolean {
addScenery(Scenery.CHEST_3635, wallScenery.location, chestLocationRotationMap[wallScenery.location.toString()] ?: 0, 10)
addScenery(wallScenery)
return true
}
})
// Return the chest scenery to replace PacketProcessor so that MISMATCH will not happen.
return core.game.node.scenery.Scenery(
chestSceneryId,
wallScenery.location,
chestLocationRotationMap[wallScenery.location.toString()] ?: 0
)
}
}
override fun defineListeners() {
// This somehow doesn't trigger as the scenery.id != objId (3626 != 3635)
on(Scenery.CHEST_3635, IntType.SCENERY, "open") { player, node ->
lock(player, 3)
animate(player, 536)
replaceScenery(node.asScenery(), Scenery.CHEST_3636, 3)
if (getAttribute(player, MAZE_ATTRIBUTE_TICKS_LEFT, 0) > 0 && getAttribute(player, MAZE_ATTRIBUTE_CHESTS_OPEN, 0) < 10) {
animate(player, 536)
// val actualScenery = RegionManager.getObject(node.location.z, node.location.x, node.location.y, 3626)
val tableRoll = CHEST_REWARDS.roll()
addItemOrBank(player, tableRoll[0].id, tableRoll[0].amount)
when (tableRoll[0].id){
when (tableRoll[0].id) {
Items.AIR_RUNE_556 -> sendItemDialogue(player, Items.AIR_RUNE_556, "You've found some air runes!")
Items.WATER_RUNE_555 -> sendItemDialogue(player, Items.WATER_RUNE_555, "You've found some water runes!")
Items.EARTH_RUNE_557 -> sendItemDialogue(player, Items.EARTH_RUNE_557, "You've found some earth runes!")
@ -187,7 +132,7 @@ class MazeInterface : InteractionListener, EventHook<TickEvent>, MapArea {
Items.STRENGTH_POTION2_117 -> sendItemDialogue(player, Items.STRENGTH_POTION2_117, "You've found a strength potion!")
Items.DEFENCE_POTION2_135 -> sendItemDialogue(player, Items.DEFENCE_POTION2_135, "You've found a defence potion!")
}
setAttribute(player, MAZE_ATTRIBUTE_CHESTS_OPEN, getAttribute(player, MAZE_ATTRIBUTE_CHESTS_OPEN, 0))
setAttribute(player, MAZE_ATTRIBUTE_CHESTS_OPEN, getAttribute(player, MAZE_ATTRIBUTE_CHESTS_OPEN, 0) + 1)
} else {
sendMessage(player,"You find nothing of interest.")
}

View file

@ -3,7 +3,9 @@ package content.global.ame.events.rivertroll
import core.game.node.entity.Entity
import core.game.node.entity.npc.NPC
import content.global.ame.RandomEventNPC
import core.api.getWorldTicks
import core.api.utils.WeightBasedTable
import core.game.world.map.MapDistance
val ids = (391..396).toList()
@ -21,10 +23,12 @@ class RiverTrollRENPC(override var loot: WeightBasedTable? = null) : RandomEvent
super.finalizeDeath(killer)
}
override fun tick() {
if(!player.location.withinDistance(this.location,8)){
if (!player.location.withinDistance(this.location, 8)) {
this.terminate()
}
super.tick()
if(!player.viewport.currentPlane.npcs.contains(this)) this.clear()
if (!player.location.withinDistance(this.location, MapDistance.RENDERING.distance)) {
this.clear()
}
}
}

View file

@ -3,7 +3,9 @@ package content.global.ame.events.rockgolem
import core.game.node.entity.Entity
import core.game.node.entity.npc.NPC
import content.global.ame.RandomEventNPC
import core.api.getWorldTicks
import core.api.utils.WeightBasedTable
import core.game.world.map.MapDistance
val ids = (413..418).toList()
@ -21,10 +23,12 @@ class RockGolemRENPC(override var loot: WeightBasedTable? = null) : RandomEventN
super.finalizeDeath(killer)
}
override fun tick() {
if(!player.location.withinDistance(this.location,8)){
if (!player.location.withinDistance(this.location, 8)) {
this.terminate()
}
super.tick()
if(!player.viewport.currentPlane.npcs.contains(this)) this.clear()
if (!player.location.withinDistance(this.location, MapDistance.RENDERING.distance)) {
this.clear()
}
}
}

View file

@ -3,7 +3,9 @@ package content.global.ame.events.shade
import core.game.node.entity.Entity
import core.game.node.entity.npc.NPC
import content.global.ame.RandomEventNPC
import core.api.getWorldTicks
import core.api.utils.WeightBasedTable
import core.game.world.map.MapDistance
class ShadeRENPC(override var loot: WeightBasedTable? = null) : RandomEventNPC(425){
val ids = (425..430).toList()
@ -20,10 +22,12 @@ class ShadeRENPC(override var loot: WeightBasedTable? = null) : RandomEventNPC(4
super.finalizeDeath(killer)
}
override fun tick() {
if(!player.location.withinDistance(this.location,8)){
if (!player.location.withinDistance(this.location, 8)) {
this.terminate()
}
super.tick()
if(!player.viewport.currentPlane.npcs.contains(this)) this.clear()
if (!player.location.withinDistance(this.location, MapDistance.RENDERING.distance)) {
this.clear()
}
}
}

View file

@ -3,7 +3,9 @@ package content.global.ame.events.treespirit
import core.game.node.entity.Entity
import core.game.node.entity.npc.NPC
import content.global.ame.RandomEventNPC
import core.api.getWorldTicks
import core.api.utils.WeightBasedTable
import core.game.world.map.MapDistance
val ids = (438..443).toList()
@ -21,10 +23,12 @@ class TreeSpiritRENPC(override var loot: WeightBasedTable? = null) : RandomEvent
super.finalizeDeath(killer)
}
override fun tick() {
if(!player.location.withinDistance(this.location,8)){
if (!player.location.withinDistance(this.location, 8)) {
this.terminate()
}
super.tick()
if(!player.viewport.currentPlane.npcs.contains(this)) this.clear()
if (!player.location.withinDistance(this.location, MapDistance.RENDERING.distance)) {
this.clear()
}
}
}

View file

@ -3,7 +3,9 @@ package content.global.ame.events.zombie
import core.game.node.entity.Entity
import core.game.node.entity.npc.NPC
import content.global.ame.RandomEventNPC
import core.api.getWorldTicks
import core.api.utils.WeightBasedTable
import core.game.world.map.MapDistance
class ZombieRENPC(override var loot: WeightBasedTable? = null) : RandomEventNPC(419){
val ids = (419..424).toList()
@ -20,10 +22,12 @@ class ZombieRENPC(override var loot: WeightBasedTable? = null) : RandomEventNPC(
super.finalizeDeath(killer)
}
override fun tick() {
if(!player.location.withinDistance(this.location,8)){
if (!player.location.withinDistance(this.location, 8)) {
this.terminate()
}
super.tick()
if(!player.viewport.currentPlane.npcs.contains(this)) this.clear()
if (!player.location.withinDistance(this.location, MapDistance.RENDERING.distance)) {
this.clear()
}
}
}

View file

@ -21,6 +21,7 @@ import core.game.bots.CombatBotAssembler
import core.game.bots.Script
import core.game.interaction.IntType
import core.game.interaction.InteractionListeners
import core.game.world.repository.Repository
import core.tools.Log
import java.io.File
import java.io.FileReader
@ -114,7 +115,7 @@ class Adventurer(val style: CombatStyle): Script() {
}
private fun otherPlayersNearby(): Boolean {
val localPlayers = RegionManager.getLocalPlayers(bot)
val localPlayers = RegionManager.getLocalPlayers(bot.location)
val otherPlayers = localPlayers.filter { it.name != bot.name }
return otherPlayers.isNotEmpty()
}
@ -503,7 +504,7 @@ class Adventurer(val style: CombatStyle): Script() {
dateCode == 404 -> lineAlt = dialogue.getLines("easter").rand()
}
var localPlayers = RegionManager.getLocalPlayers(bot)
val localPlayers = RegionManager.getLocalPlayers(bot.location)
if (localPlayers.isNotEmpty()) {
val localPlayer = localPlayers
.filter { it.name != bot.name }

View file

@ -58,7 +58,7 @@ class CannonballSmelter : Script() {
} else if(!coalMine.insideBorder(bot)){
scriptAPI.walkTo(coalMine.randomLoc)
} else {
val rock = scriptAPI.getNearestObjectByPredicate({node -> node?.name?.equals("rocks", true)!! && MiningNode.forId(node?.id!!).reward == Items.COAL_453 })
val rock = scriptAPI.getNearestObjectByPredicate({node -> node?.name?.equals("rocks", true)!! && MiningNode.forId(node.id)?.reward == Items.COAL_453 })
if(rock != null) {
scriptAPI.interact(bot, rock, "mine")
} else {
@ -75,7 +75,7 @@ class CannonballSmelter : Script() {
var loc = ironMine.randomLoc
scriptAPI.walkTo(loc)
} else {
val rock = scriptAPI.getNearestObjectByPredicate({node -> node?.name?.equals("rocks", true)!! && MiningNode.forId(node?.id!!).reward == Items.IRON_ORE_440 })
val rock = scriptAPI.getNearestObjectByPredicate({node -> node?.name?.equals("rocks", true)!! && MiningNode.forId(node.id)?.reward == Items.IRON_ORE_440 })
//rock?.let { InteractionListeners.run(rock.id, IntType.SCENERY,"mine",bot,rock) }
if(rock != null) {
scriptAPI.interact(bot, rock, "mine")

View file

@ -22,6 +22,7 @@ import core.game.bots.Script
import core.game.interaction.IntType
import core.game.interaction.InteractionListeners
import core.game.world.ImmerseWorld
import core.game.world.repository.Repository
import java.io.File
import java.io.FileReader
import java.util.Random
@ -262,10 +263,12 @@ class DoublingMoney : Script() {
minDist = min(minDist, loc.getDistance(bot.location))
}
if (minDist > 1) return 2
RegionManager.forId(bot.location.regionId).planes[bot.location.z].players.forEach {
if (AIRepository.PulseRepository[it?.username?.lowercase()]?.botScript is DoublingMoney
&& it != bot
&& it.location.getDistance(bot.location) <= 1) {
val region = RegionManager.forId(bot.location.regionId)
val players = region.assemblePlayerList(bot.location.z)
for (player in players) {
if (AIRepository.PulseRepository[player.username.lowercase()]?.botScript is DoublingMoney
&& player != bot
&& player.location.getDistance(bot.location) <= 1) {
return 2
}
}

View file

@ -79,7 +79,7 @@ public final class ChainhitSpecialHandler extends RangeSwingHandler implements P
if (!((Player) entity).getSettings().drainSpecial(SPECIAL_ENERGY)) {
return -1;
}
state.setStyle(CombatStyle.RANGE);
state.setStyle(CombatStyle.RANGE);
if (victim instanceof NPC) {
NPC npc = victim.asNpc();
if (npc.getId() == 2440) {
@ -186,9 +186,9 @@ public final class ChainhitSpecialHandler extends RangeSwingHandler implements P
if (list == null) {
int distance = 5;
if (victim instanceof NPC) {
e.setAttribute("chain-hit_v", list = RegionManager.getLocalNpcs(e, distance));
e.setAttribute("chain-hit_v", list = RegionManager.getLocalNPCs(e.getLocation(), distance));
} else {
e.setAttribute("chain-hit_v", list = RegionManager.getLocalPlayers(e, distance));
e.setAttribute("chain-hit_v", list = RegionManager.getLocalPlayers(e.getLocation(), distance));
}
list.remove(e);
list.remove(victim);

View file

@ -13,7 +13,6 @@ import core.game.world.map.RegionManager;
import core.game.world.update.flag.context.Graphics;
import core.tools.RandomFunction;
import java.util.ArrayList;
import java.util.List;
/**
@ -56,14 +55,18 @@ public final class ChinchompaSwingHandler extends RangeSwingHandler {
return -1;
}
// ! Initial capacity of 14, but has dynamic size? i.e. we are not restricting to a max of 14 targets hit here now
List<Entity> targetCandidates = new ArrayList<>(14);
targetCandidates.addAll(RegionManager.getSurroundingNPCs(victim, 14, entity));
targetCandidates.addAll(RegionManager.getSurroundingPlayers(victim, 14, entity));
// https://oldschool.runescape.wiki/w/Chinchompa - shit source but it's better than what was here before
@SuppressWarnings("rawtypes") List targetCandidates;
if (victim instanceof Player) {
targetCandidates = RegionManager.getSurroundingPlayers(victim, 9);
} else {
targetCandidates = RegionManager.getSurroundingNPCs(victim, 11);
}
BattleState[] targets = new BattleState[targetCandidates.size()];
int count = 0;
for (Entity e : targetCandidates) {
if (canSwing(entity, e) != InteractionType.NO_INTERACT && e.isAttackable(entity, CombatStyle.RANGE, false)) {
for (Object o : targetCandidates) {
Entity e = (Entity) o;
if (e != entity && canSwing(entity, e) != InteractionType.NO_INTERACT && e.isAttackable(entity, CombatStyle.RANGE, false)) {
BattleState s = targets[count++] = new BattleState(entity, e);
s.setStyle(CombatStyle.RANGE);
int hit = 0;

View file

@ -76,12 +76,12 @@ public final class PowerstabSpecialHandler extends MeleeSwingHandler implements
return super.swing(entity, victim, state);
}
@SuppressWarnings("rawtypes")
List list = victim instanceof NPC ? RegionManager.getSurroundingNPCs(entity, 9, entity) : RegionManager.getSurroundingPlayers(entity, 9, entity);
List list = victim instanceof NPC ? RegionManager.getSurroundingNPCs(entity, 9) : RegionManager.getSurroundingPlayers(entity, 9);
BattleState[] targets = new BattleState[list.size()];
int count = 0;
for (Object o : list) {
Entity e = (Entity) o;
if (CombatStyle.RANGE.getSwingHandler().canSwing(entity, e) != InteractionType.NO_INTERACT && e.isAttackable(entity, CombatStyle.RANGE, false)) {
if (e != entity && CombatStyle.RANGE.getSwingHandler().canSwing(entity, e) != InteractionType.NO_INTERACT && e.isAttackable(entity, CombatStyle.RANGE, false)) {
BattleState s = targets[count++] = new BattleState(entity, e);
int hit = 0;
if (isAccurateImpact(entity, e)) {

View file

@ -77,12 +77,12 @@ public final class SpearWallSpecialHandler extends MeleeSwingHandler implements
return super.swing(entity, victim, state);
}
@SuppressWarnings("rawtypes")
List list = victim instanceof NPC ? RegionManager.getSurroundingNPCs(entity, 9, entity) : RegionManager.getSurroundingPlayers(entity, 9, entity);
List list = victim instanceof NPC ? RegionManager.getSurroundingNPCs(entity, 9) : RegionManager.getSurroundingPlayers(entity, 9);
BattleState[] targets = new BattleState[list.size()];
int count = 0;
for (Object o : list) {
Entity e = (Entity) o;
if (CombatStyle.RANGE.getSwingHandler().canSwing(entity, e) != InteractionType.NO_INTERACT && e.isAttackable(entity, CombatStyle.RANGE, false)) {
if (e != entity && CombatStyle.RANGE.getSwingHandler().canSwing(entity, e) != InteractionType.NO_INTERACT && e.isAttackable(entity, CombatStyle.RANGE, false)) {
BattleState s = targets[count++] = new BattleState(entity, e);
int hit = 0;
hit = RandomFunction.random(calculateHit(entity, e, 1.0) + 1);

View file

@ -2,7 +2,9 @@ package content.global.handlers.item.equipment.special;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import core.game.world.repository.Repository;
import core.plugin.Initializable;
import content.global.skill.summoning.familiar.Familiar;
import core.game.node.entity.Entity;
@ -98,7 +100,10 @@ public final class SweepSpecialHandler extends MeleeSwingHandler implements Plug
Direction dir = Direction.getDirection(x - entity.getLocation().getX(), y - entity.getLocation().getY());
List<BattleState> l = new ArrayList<>(20);
l.add(new BattleState(entity, victim));
for (Entity n : victim instanceof NPC ? RegionManager.getSurroundingNPCs(victim, 9, entity, victim) : RegionManager.getSurroundingPlayers(victim, 9, entity, victim)) {
for (Entity n : victim instanceof NPC ? RegionManager.getSurroundingNPCs(victim, 9) : RegionManager.getSurroundingPlayers(victim, 9)) {
if (n == entity) {
continue;
}
if (n instanceof Familiar) {
continue;
}

View file

@ -21,47 +21,47 @@ import java.util.Objects;
@Initializable
public final class SoftclayPlugin extends UseWithHandler {
/**
* Represents the clay item.
*/
private static final Item CLAY = new Item(Items.CLAY_434);
/**
* Represents the clay item.
*/
private static final Item CLAY = new Item(Items.CLAY_434);
/**
* Represents the soft clay item.
*/
private static final Item SOFT_CLAY = new Item(Items.SOFT_CLAY_1761);
/**
* Represents the soft clay item.
*/
private static final Item SOFT_CLAY = new Item(Items.SOFT_CLAY_1761);
/**
* Represents the bowl of water item.
*/
private static final Item BOWL_OF_WATER = new Item(Items.BOWL_OF_WATER_1921);
/**
* Represents the bowl of water item.
*/
private static final Item BOWL_OF_WATER = new Item(Items.BOWL_OF_WATER_1921);
/**
* Represents the empty bowl item.
*/
private static final Item BOWL = new Item(Items.BOWL_1923);
/**
* Represents the empty bowl item.
*/
private static final Item BOWL = new Item(Items.BOWL_1923);
/**
* Represents the empty bucket item.
*/
private static final Item BUCKET = new Item(Items.BUCKET_1925);
/**
* Represents the empty bucket item.
*/
private static final Item BUCKET = new Item(Items.BUCKET_1925);
/**
* Represents the bucket of water item.
*/
private static final Item BUCKET_OF_WATER = new Item(Items.BUCKET_OF_WATER_1929);
/**
* Represents the jug item.
*/
private static final Item JUG = new Item(Items.JUG_1935);
/**
* Represents the jug item.
*/
private static final Item JUG = new Item(Items.JUG_1935);
/**
* Represents the jug of water item.
*/
private static final Item JUG_OF_WATER = new Item(Items.JUG_OF_WATER_1937);
/**
/**
* Constructs a new {@code SoftclayPlugin} {@code Object}.
*/
public SoftclayPlugin() {
@ -70,7 +70,7 @@ public final class SoftclayPlugin extends UseWithHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(1921, ITEM_TYPE, this);
addHandler(1921, ITEM_TYPE, this);
addHandler(1929, ITEM_TYPE, this);
addHandler(1937, ITEM_TYPE, this);
return this;
@ -115,33 +115,33 @@ public final class SoftclayPlugin extends UseWithHandler {
* @return {@code True} if so.
*/
private boolean create(final Player player, NodeUsageEvent event) {
Item removeItem = null;
Item returnItem = null;
if (event.getUsedItem().getId() == Items.BUCKET_OF_WATER_1929 || event.getBaseItem().getId() == Items.BUCKET_OF_WATER_1929) {
removeItem = BUCKET_OF_WATER;
returnItem = BUCKET;
}
if (event.getUsedItem().getId() == Items.BOWL_OF_WATER_1921 || event.getBaseItem().getId() == Items.BOWL_OF_WATER_1921) {
removeItem = BOWL_OF_WATER;
returnItem = BOWL;
}
if (event.getUsedItem().getId() == Items.JUG_OF_WATER_1937 || event.getBaseItem().getId() == Items.JUG_OF_WATER_1937) {
removeItem = JUG_OF_WATER;
returnItem = JUG;
}
Item removeItem = null;
Item returnItem = null;
if (event.getUsedItem().getId() == Items.BUCKET_OF_WATER_1929 || event.getBaseItem().getId() == Items.BUCKET_OF_WATER_1929) {
removeItem = BUCKET_OF_WATER;
returnItem = BUCKET;
}
if (event.getUsedItem().getId() == Items.BOWL_OF_WATER_1921 || event.getBaseItem().getId() == Items.BOWL_OF_WATER_1921) {
removeItem = BOWL_OF_WATER;
returnItem = BOWL;
}
if (event.getUsedItem().getId() == Items.JUG_OF_WATER_1937 || event.getBaseItem().getId() == Items.JUG_OF_WATER_1937) {
removeItem = JUG_OF_WATER;
returnItem = JUG;
}
if (player.getInventory().containsItem(CLAY) && player.getInventory().containsItem(Objects.requireNonNull(removeItem))) {
player.getInventory().remove(removeItem);
player.getInventory().remove(CLAY);
player.getPacketDispatch().sendMessage("You mix the clay and water. You now have some soft, workable clay.");
player.getInventory().add(SOFT_CLAY);
player.getInventory().add(returnItem);
if (!player.getAchievementDiaryManager().hasCompletedTask(DiaryType.LUMBRIDGE, 0, 6) && player.getViewport().getRegion().getId() == 12341) {
player.getAchievementDiaryManager().finishTask(player, DiaryType.LUMBRIDGE, 0, 6);
}
player.getInventory().remove(removeItem);
player.getInventory().remove(CLAY);
player.getPacketDispatch().sendMessage("You mix the clay and water. You now have some soft, workable clay.");
player.getInventory().add(SOFT_CLAY);
player.getInventory().add(returnItem);
if (!player.getAchievementDiaryManager().hasCompletedTask(DiaryType.LUMBRIDGE, 0, 6) && player.getLocation().getRegionId() == 12341) {
player.getAchievementDiaryManager().finishTask(player, DiaryType.LUMBRIDGE, 0, 6);
}
return true;
} else {
return false;
}
return false;
}
}
}

View file

@ -15,30 +15,19 @@ import org.rs09.consts.Sounds
* @author Ceikry
*/
class WaterSourceListener : InteractionListener {
// NOTE '9695' should be removed from the array below once the sink object can be used directly, this is a temporary
// solution.
// this is ugly!
private val waterSources = intArrayOf(21355, 16302, 6827, 11661, 24160, 34577, 15936, 15937, 15938, 23920, 35469, 24265, 153, 879, 880, 2864, 6232, 10436, 10437, 10827, 11007, 11759, 21764, 22973, 24161, 24214, 24265, 28662, 30223, 30820, 34579, 36781, 873, 874, 4063, 6151, 8699, 9143, 9684, 9695, 10175, 12279, 12974, 13563, 13564, 14868, 14917, 14918, 15678, 16704, 16705, 20358, 22715, 24112, 24314, 25729, 25929, 26966, 29105, 33458, 34082, 34411, 34496, 34547, 34566, 35762, 36971, 37154, 37155, 878, 884, 3264, 3305, 3359, 4004, 4005, 6097, 6249, 6549, 8747, 8927, 11793, 12201, 12897, 24166, 26945, 31359, 32023, 32024, 34576, 35671, 40063, 13561, 13563, 13559, 12089)
private val waterSources = intArrayOf(21355, 16302, 6827, 11661, 24160, 34577, 15936, 15937, 15938, 23920, 35469, 24265, 153, 879, 880, 2864, 6232, 10436, 10437, 10827, 11007, 11759, 21764, 22973, 24161, 24214, 24265, 28662, 30223, 30820, 34579, 36781, 873, 874, 4063, 6151, 8699, 9143, 9684, 10175, 12279, 12974, 13563, 13564, 14868, 14917, 14918, 15678, 16704, 16705, 20358, 22715, 24112, 24314, 25729, 25929, 26966, 29105, 33458, 34082, 34411, 34496, 34547, 34566, 35762, 36971, 37154, 37155, 878, 884, 3264, 3305, 3359, 4004, 4005, 6097, 6249, 6549, 8747, 8927, 11793, 12201, 12897, 24166, 26945, 31359, 32023, 32024, 34576, 35671, 40063, 13561, 13563, 13559, 12089)
private val nonWellableMsg = "If I drop my @ down there, I don't think I'm likely to get it back."
private val animation = Animation(832)
override fun defineListeners()
{
override fun defineListeners() {
onUseWith(IntType.SCENERY, WaterVessel.getInputs(), *waterSources){ player, used, with ->
val vessel = WaterVessel.forId(used.id) ?: return@onUseWith false
if(with.name.contains("well", ignoreCase = true) && !vessel.wellable)
{
sendMessage(player, formatMsgText(used.name, nonWellableMsg))
return@onUseWith true
}
if(with.id == 9695 && player.location.regionId != 11571)
{
return@onUseWith false
}
//ugly achievement code, achievement system sux
if(vessel == WaterVessel.BUCKET && with.id == 11661)
{
@ -67,15 +56,6 @@ class WaterSourceListener : InteractionListener {
return@onUseWith true
}
// This is needed to make the crafting guild sink work, but technically it's wrong as it is the noticeboard and
// not the sink being used. This is a temporary solution until the sink object can be used directly.
setDest(IntType.SCENERY, intArrayOf(9695), "use") { player, node ->
if (player.location.regionId == 11571){
return@setDest Location.create(2934, 3280, 0)
}
return@setDest node.location
}
}
private fun formatMsgText(name: String, template: String): String

View file

@ -413,7 +413,7 @@ class TableListener : InteractionListener {
}
val droppedItem = used.dropItem
if (droppedItem.id == Items.COINS_995) playAudio(player, DROP_COINS_SOUND) else playAudio(player, DROP_ITEM_SOUND)
GroundItemManager.create(droppedItem, Location(nearestX, nearestY), player)
GroundItemManager.create(droppedItem, Location(nearestX, nearestY, player.location.z), player)
setAttribute(player, "droppedItem:${droppedItem.id}", getWorldTicks() + 2)
PlayerParser.save(player)

View file

@ -19,6 +19,7 @@ import core.game.world.GameWorld;
import core.game.world.map.*;
import core.game.world.map.zone.MapZone;
import core.game.world.map.zone.ZoneBuilder;
import core.game.world.repository.Repository;
import core.game.world.update.flag.context.Animation;
import core.plugin.Initializable;
import core.plugin.Plugin;
@ -37,300 +38,302 @@ import static core.api.ContentAPIKt.*;
@Initializable
public final class BrimhavenArena extends MapZone implements Plugin<Object> {
/**
* The location based traps.
*/
private static final Map<Location, MovementHook> LOCATION_TRAPS = new HashMap<>();
/**
* The location based traps.
*/
private static final Map<Location, MovementHook> LOCATION_TRAPS = new HashMap<>();
/**
* The overlay component.
*/
private static final Component OVERLAY = new Component(5);
/**
* The overlay component.
*/
private static final Component OVERLAY = new Component(5);
/**
* The ticket dispenser locations.
*/
private static final Location[] DISPENSERS = new Location[24];
/**
* The ticket dispenser locations.
*/
private static final Location[] DISPENSERS = new Location[24];
/**
* The agility ticket reward item.
*/
private static final Item TICKET = new Item(2996);
/**
* The agility ticket reward item.
*/
private static final Item TICKET = new Item(2996);
/**
* If the saw blade is currently active.
*/
public static boolean sawBladeActive;
/**
* If the saw blade is currently active.
*/
public static boolean sawBladeActive;
/**
* Constructs a new {@code BrimhavenArena} {@code Object}.
*/
public BrimhavenArena() {
super("Brimhaven agility arena", true);
}
/**
* Constructs a new {@code BrimhavenArena} {@code Object}.
*/
public BrimhavenArena() {
super("Brimhaven agility arena", true);
}
/**
* Sets the current ticket dispenser target.
*
* @param player The player.
*/
private void setDispenser(Player player) {
if (!player.getAttribute("brim-tagged", false)) {
player.setAttribute("brim-tagcount", 0);
}
player.setAttribute("brim-tagged", false);
setVarp(player, 309, 0);
int index = RandomFunction.randomize(DISPENSERS.length);
if (index == player.getAttribute("brim-tag", -1)) {
index = (index + 1) % DISPENSERS.length;
}
int iconSlot = player.getAttribute("brim-icon", -1);
if (iconSlot > -1) {
HintIconManager.removeHintIcon(player, iconSlot);
}
player.setAttribute("brim-tag", index);
player.setAttribute("brim-icon", HintIconManager.registerHeightHintIcon(player, DISPENSERS[index], 50));
}
/**
* Sets the current ticket dispenser target.
*
* @param player The player.
*/
private void setDispenser(Player player) {
if (!player.getAttribute("brim-tagged", false)) {
player.setAttribute("brim-tagcount", 0);
}
player.setAttribute("brim-tagged", false);
setVarp(player, 309, 0);
int index = RandomFunction.randomize(DISPENSERS.length);
if (index == player.getAttribute("brim-tag", -1)) {
index = (index + 1) % DISPENSERS.length;
}
int iconSlot = player.getAttribute("brim-icon", -1);
if (iconSlot > -1) {
HintIconManager.removeHintIcon(player, iconSlot);
}
player.setAttribute("brim-tag", index);
player.setAttribute("brim-icon", HintIconManager.registerHeightHintIcon(player, DISPENSERS[index], 50));
}
@Override
public boolean enter(Entity entity) {
if (entity instanceof Player) {
Player player = (Player) entity;
player.getInterfaceManager().openOverlay(OVERLAY);
setDispenser(player);
}
return super.enter(entity);
}
@Override
public boolean enter(Entity entity) {
if (entity instanceof Player) {
Player player = (Player) entity;
player.getInterfaceManager().openOverlay(OVERLAY);
setDispenser(player);
}
return super.enter(entity);
}
@Override
public boolean leave(Entity entity, boolean logout) {
if (entity instanceof Player && !logout) {
Player player = (Player) entity;
player.getInterfaceManager().closeOverlay();
player.removeAttribute("brim-tag");
player.removeAttribute("brim-tagcount");
int iconSlot = player.getAttribute("brim-icon", -1);
if (iconSlot > -1) {
HintIconManager.removeHintIcon(player, iconSlot);
player.removeAttribute("brim-icon");
}
}
return super.enter(entity);
}
@Override
public boolean leave(Entity entity, boolean logout) {
if (entity instanceof Player && !logout) {
Player player = (Player) entity;
player.getInterfaceManager().closeOverlay();
player.removeAttribute("brim-tag");
player.removeAttribute("brim-tagcount");
int iconSlot = player.getAttribute("brim-icon", -1);
if (iconSlot > -1) {
HintIconManager.removeHintIcon(player, iconSlot);
player.removeAttribute("brim-icon");
}
}
return super.enter(entity);
}
@Override
public boolean interact(Entity entity, Node node, Option option) {
if (node instanceof Scenery) {
Scenery object = (Scenery) node;
if (object.getId() == 3610) {
ClimbActionHandler.climb((Player) entity, Animation.create(828), object.getLocation().transform(0, 0, 3));
return true;
}
if (object.getId() == 3608 || object.getId() == 3581) {
Player player = (Player) entity;
if (!object.getLocation().equals(DISPENSERS[player.getAttribute("brim-tag", 0)])) {
player.getPacketDispatch().sendMessage("Tag the pillar indicated by the yellow arrow to get an Agility ticket.");
return true;
}
if (player.getAttribute("brim-tagged", false)) {
player.getPacketDispatch().sendMessage("You have already tagged this pillar.");
return true;
}
player.setAttribute("brim-tagged", true);
int tags = player.getAttribute("brim-tagcount", 0) + 1;
player.setAttribute("brim-tagcount", tags);
setVarp(player, 309, 4);
if (tags > 1) {
int amount = 1;
if (!player.getInventory().add(new Item(TICKET.getId(), amount))) {
GroundItemManager.create(new GroundItem(new Item(TICKET.getId(), amount), player.getLocation(), player));
}
player.getAchievementDiaryManager().finishTask(player, DiaryType.KARAMJA, 1, 0);
player.getDialogueInterpreter().sendItemMessage(TICKET.getId(), "You have received an Agility Arena Ticket!");
player.getPacketDispatch().sendMessage("You have received an Agility Arena Ticket!");
return true;
}
player.getPacketDispatch().sendMessage("You get tickets by tagging more than one pillar in a row, tag the next pillar!");
player.getDialogueInterpreter().sendDialogue("You get tickets by tagging more than one pillar in a row. <col=C04000>Tag the", "<col=C04000>next pillar for a ticket!</col>");
return true;
}
}
return false;
}
@Override
public boolean interact(Entity entity, Node node, Option option) {
if (node instanceof Scenery) {
Scenery object = (Scenery) node;
if (object.getId() == 3610) {
ClimbActionHandler.climb((Player) entity, Animation.create(828), object.getLocation().transform(0, 0, 3));
return true;
}
if (object.getId() == 3608 || object.getId() == 3581) {
Player player = (Player) entity;
if (!object.getLocation().equals(DISPENSERS[player.getAttribute("brim-tag", 0)])) {
player.getPacketDispatch().sendMessage("Tag the pillar indicated by the yellow arrow to get an Agility ticket.");
return true;
}
if (player.getAttribute("brim-tagged", false)) {
player.getPacketDispatch().sendMessage("You have already tagged this pillar.");
return true;
}
player.setAttribute("brim-tagged", true);
int tags = player.getAttribute("brim-tagcount", 0) + 1;
player.setAttribute("brim-tagcount", tags);
setVarp(player, 309, 4);
if (tags > 1) {
int amount = 1;
if (!player.getInventory().add(new Item(TICKET.getId(), amount))) {
GroundItemManager.create(new GroundItem(new Item(TICKET.getId(), amount), player.getLocation(), player));
}
player.getAchievementDiaryManager().finishTask(player, DiaryType.KARAMJA, 1, 0);
player.getDialogueInterpreter().sendItemMessage(TICKET.getId(), "You have received an Agility Arena Ticket!");
player.getPacketDispatch().sendMessage("You have received an Agility Arena Ticket!");
return true;
}
player.getPacketDispatch().sendMessage("You get tickets by tagging more than one pillar in a row, tag the next pillar!");
player.getDialogueInterpreter().sendDialogue("You get tickets by tagging more than one pillar in a row. <col=C04000>Tag the", "<col=C04000>next pillar for a ticket!</col>");
return true;
}
}
return false;
}
@Override
public boolean move(Entity e, Location loc, Location dest) {
if (!e.getLocks().isMovementLocked() && e instanceof Player) {
MovementHook hook = LOCATION_TRAPS.get(loc);
if (hook != null) {
e.setDirection(Direction.getLogicalDirection(loc, dest));
return hook.handle(e, loc);
}
}
return super.move(e, loc, dest);
}
@Override
public boolean move(Entity e, Location loc, Location dest) {
if (!e.getLocks().isMovementLocked() && e instanceof Player) {
MovementHook hook = LOCATION_TRAPS.get(loc);
if (hook != null) {
e.setDirection(Direction.getLogicalDirection(loc, dest));
return hook.handle(e, loc);
}
}
return super.move(e, loc, dest);
}
@Override
public void locationUpdate(Entity e, Location last) {
if (!e.getLocks().isMovementLocked() && e instanceof Player) {
MovementHook hook = LOCATION_TRAPS.get(e.getLocation());
if (hook != null) {
if (!hook.handle(e, e.getLocation())) {
if (e.getPulseManager().isMovingPulse()) {
e.getPulseManager().clear();
}
e.getWalkingQueue().reset();
}
}
}
}
@Override
public void locationUpdate(Entity e, Location last) {
if (!e.getLocks().isMovementLocked() && e instanceof Player) {
MovementHook hook = LOCATION_TRAPS.get(e.getLocation());
if (hook != null) {
if (!hook.handle(e, e.getLocation())) {
if (e.getPulseManager().isMovingPulse()) {
e.getPulseManager().clear();
}
e.getWalkingQueue().reset();
}
}
}
}
@Override
public void configure() {
registerRegion(11157);
PressurePad pad = new PressurePad();
LOCATION_TRAPS.put(Location.create(2800, 9579, 3), pad);
LOCATION_TRAPS.put(Location.create(2799, 9579, 3), pad);
LOCATION_TRAPS.put(Location.create(2800, 9557, 3), pad);
LOCATION_TRAPS.put(Location.create(2799, 9557, 3), pad);
LOCATION_TRAPS.put(Location.create(2772, 9585, 3), pad);
LOCATION_TRAPS.put(Location.create(2772, 9584, 3), pad);
FloorSpikes spikes = new FloorSpikes();
LOCATION_TRAPS.put(Location.create(2800, 9568, 3), spikes);
LOCATION_TRAPS.put(Location.create(2799, 9568, 3), spikes);
LOCATION_TRAPS.put(Location.create(2772, 9552, 3), spikes);
LOCATION_TRAPS.put(Location.create(2772, 9551, 3), spikes);
LOCATION_TRAPS.put(Location.create(2761, 9573, 3), spikes);
LOCATION_TRAPS.put(Location.create(2761, 9574, 3), spikes);
DartTrap dart = new DartTrap();
LOCATION_TRAPS.put(Location.create(2788, 9557, 3), dart);
LOCATION_TRAPS.put(Location.create(2789, 9557, 3), dart);
LOCATION_TRAPS.put(Location.create(2794, 9573, 3), dart);
LOCATION_TRAPS.put(Location.create(2794, 9574, 3), dart);
LOCATION_TRAPS.put(Location.create(2777, 9568, 3), dart);
LOCATION_TRAPS.put(Location.create(2778, 9568, 3), dart);
SpinningBlades blade = new SpinningBlades();
LOCATION_TRAPS.put(Location.create(2778, 9579, 3), blade);
LOCATION_TRAPS.put(Location.create(2783, 9574, 3), blade);
LOCATION_TRAPS.put(Location.create(2778, 9557, 3), blade);
BladeTrap trap = new BladeTrap();
LOCATION_TRAPS.put(Location.create(2788, 9579, 3), trap);
LOCATION_TRAPS.put(Location.create(2789, 9579, 3), trap);
LOCATION_TRAPS.put(Location.create(2783, 9551, 3), trap);
LOCATION_TRAPS.put(Location.create(2783, 9552, 3), trap);
LOCATION_TRAPS.put(Location.create(2761, 9584, 3), trap);
LOCATION_TRAPS.put(Location.create(2761, 9585, 3), trap);
int index = 0;
for (int x = 2761; x < 2815; x += 11) {
for (int y = 9546; y < 9600; y += 11) {
if (x == 2805 && y == 9590) {
continue;
}
DISPENSERS[index++] = Location.create(x, y, 3);
}
}
@Override
public void configure() {
registerRegion(11157);
PressurePad pad = new PressurePad();
LOCATION_TRAPS.put(Location.create(2800, 9579, 3), pad);
LOCATION_TRAPS.put(Location.create(2799, 9579, 3), pad);
LOCATION_TRAPS.put(Location.create(2800, 9557, 3), pad);
LOCATION_TRAPS.put(Location.create(2799, 9557, 3), pad);
LOCATION_TRAPS.put(Location.create(2772, 9585, 3), pad);
LOCATION_TRAPS.put(Location.create(2772, 9584, 3), pad);
FloorSpikes spikes = new FloorSpikes();
LOCATION_TRAPS.put(Location.create(2800, 9568, 3), spikes);
LOCATION_TRAPS.put(Location.create(2799, 9568, 3), spikes);
LOCATION_TRAPS.put(Location.create(2772, 9552, 3), spikes);
LOCATION_TRAPS.put(Location.create(2772, 9551, 3), spikes);
LOCATION_TRAPS.put(Location.create(2761, 9573, 3), spikes);
LOCATION_TRAPS.put(Location.create(2761, 9574, 3), spikes);
DartTrap dart = new DartTrap();
LOCATION_TRAPS.put(Location.create(2788, 9557, 3), dart);
LOCATION_TRAPS.put(Location.create(2789, 9557, 3), dart);
LOCATION_TRAPS.put(Location.create(2794, 9573, 3), dart);
LOCATION_TRAPS.put(Location.create(2794, 9574, 3), dart);
LOCATION_TRAPS.put(Location.create(2777, 9568, 3), dart);
LOCATION_TRAPS.put(Location.create(2778, 9568, 3), dart);
SpinningBlades blade = new SpinningBlades();
LOCATION_TRAPS.put(Location.create(2778, 9579, 3), blade);
LOCATION_TRAPS.put(Location.create(2783, 9574, 3), blade);
LOCATION_TRAPS.put(Location.create(2778, 9557, 3), blade);
BladeTrap trap = new BladeTrap();
LOCATION_TRAPS.put(Location.create(2788, 9579, 3), trap);
LOCATION_TRAPS.put(Location.create(2789, 9579, 3), trap);
LOCATION_TRAPS.put(Location.create(2783, 9551, 3), trap);
LOCATION_TRAPS.put(Location.create(2783, 9552, 3), trap);
LOCATION_TRAPS.put(Location.create(2761, 9584, 3), trap);
LOCATION_TRAPS.put(Location.create(2761, 9585, 3), trap);
int index = 0;
for (int x = 2761; x < 2815; x += 11) {
for (int y = 9546; y < 9600; y += 11) {
if (x == 2805 && y == 9590) {
continue;
}
DISPENSERS[index++] = Location.create(x, y, 3);
}
}
GameWorld.getPulser().submit(new Pulse(1) {
@Override
public boolean pulse() {
Region r = RegionManager.forId(11157);
if (!r.isActive()) {
return false;
}
if (GameWorld.getTicks() % 100 == 0) {
for (RegionPlane plane : r.getPlanes()) {
for (Player player : plane.getPlayers()) {
setDispenser(player);
}
}
handlePlankSwitching();
}
int ticks = 3;
if (GameWorld.getTicks() % ticks == 0) {
sawBladeActive = !sawBladeActive;
if (sawBladeActive) {
Scenery object = RegionManager.getObject(3, 2788, 9579);
SceneryBuilder.replace(object, object.transform(3567, object.getRotation(), 10), ticks);
object = RegionManager.getObject(3, 2789, 9579);
SceneryBuilder.replace(object, object.transform(0), ticks);
@Override
public boolean pulse() {
Region r = RegionManager.forId(11157);
if (!r.isActive()) {
return false;
}
if (GameWorld.getTicks() % 100 == 0) {
for (int z = 0; z < 4; z++) {
for (Player player : r.assemblePlayerList(z)) {
if (player != null) {
setDispenser(player);
}
}
}
handlePlankSwitching();
}
int ticks = 3;
if (GameWorld.getTicks() % ticks == 0) {
sawBladeActive = !sawBladeActive;
if (sawBladeActive) {
Scenery object = RegionManager.getObject(3, 2788, 9579);
SceneryBuilder.replace(object, object.transform(3567, object.getRotation(), 10), ticks);
object = RegionManager.getObject(3, 2789, 9579);
SceneryBuilder.replace(object, object.transform(0), ticks);
object = RegionManager.getObject(3, 2783, 9551);
SceneryBuilder.replace(object, object.transform(3567, object.getRotation(), 10), ticks);
object = RegionManager.getObject(3, 2783, 9552);
SceneryBuilder.replace(object, object.transform(0), ticks);
object = RegionManager.getObject(3, 2783, 9551);
SceneryBuilder.replace(object, object.transform(3567, object.getRotation(), 10), ticks);
object = RegionManager.getObject(3, 2783, 9552);
SceneryBuilder.replace(object, object.transform(0), ticks);
object = RegionManager.getObject(3, 2761, 9584);
SceneryBuilder.replace(object, object.transform(3567, object.getRotation(), 10), ticks);
object = RegionManager.getObject(3, 2761, 9585);
SceneryBuilder.replace(object, object.transform(0), ticks);
}
}
return false;
}
});
}
object = RegionManager.getObject(3, 2761, 9584);
SceneryBuilder.replace(object, object.transform(3567, object.getRotation(), 10), ticks);
object = RegionManager.getObject(3, 2761, 9585);
SceneryBuilder.replace(object, object.transform(0), ticks);
}
}
return false;
}
});
}
/**
* Switches the plank states.
*/
private static void handlePlankSwitching() {
boolean[] available = new boolean[3];
for (int i = 0; i < 1 + RandomFunction.randomize(2); i++) {
available[RandomFunction.randomize(3)] = true;
}
for (int i = 0; i < 3; i++) {
boolean avail = available[i];
for (PlankSet set : PlankSet.values()) {
Location l = set.entrance[i];
for (int x = 1; x < set.exit[i].getX() - l.getX(); x++) {
Scenery object = RegionManager.getObject(l.transform(x, 0, 0));
if(object != null)
SceneryBuilder.replace(object, object.transform(avail ? 3573 : 3576));
}
RegionManager.getObject(set.entrance[i]).setCharge(avail ? 1000 : 500);
RegionManager.getObject(set.exit[i]).setCharge(avail ? 1000 : 500);
}
}
}
/**
* Switches the plank states.
*/
private static void handlePlankSwitching() {
boolean[] available = new boolean[3];
for (int i = 0; i < 1 + RandomFunction.randomize(2); i++) {
available[RandomFunction.randomize(3)] = true;
}
for (int i = 0; i < 3; i++) {
boolean avail = available[i];
for (PlankSet set : PlankSet.values()) {
Location l = set.entrance[i];
for (int x = 1; x < set.exit[i].getX() - l.getX(); x++) {
Scenery object = RegionManager.getObject(l.transform(x, 0, 0));
if(object != null)
SceneryBuilder.replace(object, object.transform(avail ? 3573 : 3576));
}
RegionManager.getObject(set.entrance[i]).setCharge(avail ? 1000 : 500);
RegionManager.getObject(set.exit[i]).setCharge(avail ? 1000 : 500);
}
}
}
/**
* The plank obstacles.
*
* @author Emperor
*/
private static enum PlankSet {
FIRST(new Location[]{Location.create(2797, 9591, 3), Location.create(2797, 9590, 3), Location.create(2797, 9589, 3)}, new Location[]{Location.create(2802, 9591, 3), Location.create(2802, 9590, 3), Location.create(2802, 9589, 3)}), SECOND(new Location[]{Location.create(2764, 9558, 3), Location.create(2764, 9557, 3), Location.create(2764, 9556, 3)}, new Location[]{Location.create(2769, 9558, 3), Location.create(2769, 9557, 3), Location.create(2769, 9556, 3)});
/**
* The plank obstacles.
*
* @author Emperor
*/
private static enum PlankSet {
FIRST(new Location[]{Location.create(2797, 9591, 3), Location.create(2797, 9590, 3), Location.create(2797, 9589, 3)}, new Location[]{Location.create(2802, 9591, 3), Location.create(2802, 9590, 3), Location.create(2802, 9589, 3)}), SECOND(new Location[]{Location.create(2764, 9558, 3), Location.create(2764, 9557, 3), Location.create(2764, 9556, 3)}, new Location[]{Location.create(2769, 9558, 3), Location.create(2769, 9557, 3), Location.create(2769, 9556, 3)});
/**
* Constructs a new {@code PlankSet} {@code Object}.
*
* @param entrance The entrance locations for each plank.
* @param exit The exit locations for each plank.
*/
private PlankSet(Location[] entrance, Location[] exit) {
this.entrance = entrance;
this.exit = exit;
}
/**
* Constructs a new {@code PlankSet} {@code Object}.
*
* @param entrance The entrance locations for each plank.
* @param exit The exit locations for each plank.
*/
private PlankSet(Location[] entrance, Location[] exit) {
this.entrance = entrance;
this.exit = exit;
}
/**
* The entrance location of the plank.
*/
Location[] entrance;
/**
* The entrance location of the plank.
*/
Location[] entrance;
/**
* The exit location of the plank.
*/
Location[] exit;
}
/**
* The exit location of the plank.
*/
Location[] exit;
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ZoneBuilder.configure(this);
return this;
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ZoneBuilder.configure(this);
return this;
}
@Override
public Object fireEvent(String identifier, Object... args) {
return null;
}
@Override
public Object fireEvent(String identifier, Object... args) {
return null;
}
}

View file

@ -241,7 +241,7 @@ public final class BuildRoomDialogue extends DialoguePlugin {
}
int rotation = directions[index].toInteger();
boundaries.clear();
Location base = player.getViewport().getRegion().getBaseLocation().transform(roomX << 3, roomY << 3, player.getLocation().getZ());
Location base = player.getLocation().getRegion().getBaseLocation().transform(roomX << 3, roomY << 3, player.getLocation().getZ());
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
Scenery[] objects = room.getChunk().getObjects(x, y);

View file

@ -8,10 +8,7 @@ import core.game.node.item.Item;
import core.game.node.scenery.Scenery;
import core.game.node.scenery.SceneryBuilder;
import core.game.system.task.Pulse;
import core.game.world.map.BuildRegionChunk;
import core.game.world.map.Direction;
import core.game.world.map.Location;
import core.game.world.map.Region;
import core.game.world.map.*;
import core.game.world.update.flag.context.Animation;
import core.net.packet.PacketRepository;
import core.net.packet.context.ContainerContext;
@ -250,7 +247,7 @@ public final class BuildingUtils {
if (reg == null) {
continue;
}
BuildRegionChunk chunk = (BuildRegionChunk) reg.getPlanes()[plane % 3].getChunks()[l.getChunkX()][l.getChunkY()];
RegionChunk chunk = reg.getChunks()[l.getChunkX()][l.getChunkY()][plane % 3];
Scenery[] objects = chunk.getObjects(h.getCurrentX(), h.getCurrentY());
for (Scenery o : objects) {
if (o != null && o.getType() == object.getType()) {
@ -284,14 +281,15 @@ public final class BuildingUtils {
hotspot.setDecorationIndex(decIndex);
break;
case RECURSIVE:
BuildRegionChunk chunk = (BuildRegionChunk) region.getPlanes()[l.getZ()].getChunks()[l.getChunkX()][l.getChunkY()];
RegionChunk chunk = region.getChunks()[l.getChunkX()][l.getChunkY()][l.getZ()];
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
Hotspot h = room.getHotspot(hotspot.getHotspot(), x, y);
if (h != null) {
h.setDecorationIndex(decIndex);
int objectId = hotspot.getHotspot().getObjectId(style);
Scenery o = chunk.get(x, y, chunk.getIndex(x, y, objectId));
int index = chunk.getIndex(x, y, objectId, -1);
Scenery o = chunk.getObjects()[index][x][y];
if (o != null && objectId == o.getId()) {
SceneryBuilder.replace(o, o.transform(hotspot.getHotspot().getDecorations()[decIndex].getObjectId(style)));
}
@ -301,7 +299,7 @@ public final class BuildingUtils {
break;
case LINKED:
BuildHotspot[] linkedHotspots = BuildHotspot.getLinkedHotspots(hotspot.getHotspot());
chunk = (BuildRegionChunk) region.getPlanes()[l.getZ()].getChunks()[l.getChunkX()][l.getChunkY()];
chunk = region.getChunks()[l.getChunkX()][l.getChunkY()][l.getZ()];
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
for (BuildHotspot bh : linkedHotspots) {
@ -309,7 +307,8 @@ public final class BuildingUtils {
if (h != null) {
h.setDecorationIndex(decIndex);
int objectId = bh.getObjectId(style);
Scenery o = chunk.get(x, y, chunk.getIndex(x, y, objectId));
int index = chunk.getIndex(x, y, objectId, -1);
Scenery o = chunk.getObjects()[index][x][y];
if (o != null && objectId == o.getId()) {
SceneryBuilder.replace(o, o.transform(bh.getDecorations()[decIndex].getObjectId(style)));
}
@ -385,7 +384,7 @@ public final class BuildingUtils {
if (reg == null) {
continue;
}
BuildRegionChunk chunk = (BuildRegionChunk) reg.getPlanes()[plane % 3].getChunks()[l.getChunkX()][l.getChunkY()];
RegionChunk chunk = reg.getChunks()[l.getChunkX()][l.getChunkY()][plane % 3];
Scenery[] objects = chunk.getObjects(h.getCurrentX(), h.getCurrentY());
for (Scenery o : objects) {
if (o != null && o.getType() == object.getType()) {
@ -417,13 +416,14 @@ public final class BuildingUtils {
hotspot.setDecorationIndex(-1);
break;
case RECURSIVE:
BuildRegionChunk chunk = (BuildRegionChunk) region.getPlanes()[l.getZ()].getChunks()[l.getChunkX()][l.getChunkY()];
RegionChunk chunk = region.getChunks()[l.getChunkX()][l.getChunkY()][l.getZ()];
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
Hotspot h = room.getHotspot(hotspot.getHotspot(), x, y);
if (h != null) {
int objectId = hotspot.getHotspot().getDecorations()[h.getDecorationIndex()].getObjectId(style);
Scenery o = chunk.get(x, y, chunk.getIndex(x, y, objectId));
int index = chunk.getIndex(x, y, objectId, -1);
Scenery o = chunk.getObjects()[index][x][y];
h.setDecorationIndex(-1);
if (o != null && objectId == o.getId()) {
SceneryBuilder.replace(o, o.transform(hotspot.getHotspot().getObjectId(style)));
@ -434,14 +434,15 @@ public final class BuildingUtils {
break;
case LINKED:
BuildHotspot[] linkedHotspots = BuildHotspot.getLinkedHotspots(hotspot.getHotspot());
chunk = (BuildRegionChunk) region.getPlanes()[l.getZ()].getChunks()[l.getChunkX()][l.getChunkY()];
chunk = region.getChunks()[l.getChunkX()][l.getChunkY()][l.getZ()];
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
for (BuildHotspot bh : linkedHotspots) {
Hotspot h = room.getHotspot(bh, x, y);
if (h != null) {
int objectId = bh.getDecorations()[h.getDecorationIndex()].getObjectId(style);
Scenery o = chunk.get(x, y, chunk.getIndex(x, y, objectId));
int index = chunk.getIndex(x, y, objectId, -1);
Scenery o = chunk.getObjects()[index][x][y];
h.setDecorationIndex(-1);
if (o != null && objectId == o.getId()) {
SceneryBuilder.replace(o, o.transform(bh.getObjectId(style)));

View file

@ -10,6 +10,7 @@ import core.game.world.map.*;
import core.game.world.map.build.DynamicRegion;
import core.game.world.map.zone.ZoneBorders;
import core.game.world.map.zone.ZoneBuilder;
import core.game.world.repository.Repository;
import core.game.world.update.flag.context.Animation;
import core.tools.Log;
import org.jetbrains.annotations.NotNull;
@ -20,6 +21,7 @@ import core.game.world.GameWorld;
import org.rs09.consts.Sounds;
import java.awt.*;
import java.util.ArrayList;
import static core.api.ContentAPIKt.*;
import static core.api.regionspec.RegionSpecificationKt.fillWith;
@ -195,8 +197,8 @@ public final class HouseManager {
}
private void updateVarbits(Player player, boolean build) {
setVarp(player, 261, build ? 1 : 0);
setVarp(player, 262, getRoomAmount());
setVarp(player, 261, build ? 1 : 0);
setVarp(player, 262, getRoomAmount());
}
private void unlockMusicTrack(Player player) {
@ -241,13 +243,13 @@ public final class HouseManager {
* Reloads the house.
* @param player The player.
* @param buildingMode If building mode should be enabled.
* NOTE: I think we should avoid this method, it might be causing some issues. It's actually really suspicious...
* NOTE: I think we should avoid this method, it might be causing some issues. It's actually really suspicious...
*/
public void reload(Player player, boolean buildingMode) {
int diffX = player.getLocation().getLocalX();
int diffY = player.getLocation().getLocalY();
int diffZ = player.getLocation().getZ();
boolean inDungeon = player.getViewport().getRegion() == dungeonRegion;
boolean inDungeon = player.getLocation().getRegion() == dungeonRegion;
this.buildingMode = buildingMode;
construct();
Location newLoc = (dungeonRegion == null ? houseRegion : (inDungeon ? dungeonRegion : houseRegion)).getBaseLocation().transform(diffX,diffY,diffZ);
@ -260,22 +262,17 @@ public final class HouseManager {
*/
public void expelGuests(Player player) {
if (isLoaded()) {
for (RegionPlane plane : houseRegion.getPlanes()) {
for (Player p : plane.getPlayers()) {
for (int z = 0; z < 4; z++) {
ArrayList<Player> players = new ArrayList<>(houseRegion.assemblePlayerList(z));
if (dungeonRegion != null) {
players.addAll(dungeonRegion.assemblePlayerList(z));
}
for (Player p : players) {
if (p != player) {
leave(p);
}
}
}
if (dungeonRegion != null) {
for (RegionPlane plane : dungeonRegion.getPlanes()) {
for (Player p : plane.getPlayers()) {
if (p != player) {
leave(p);
}
}
}
}
}
}
@ -375,7 +372,6 @@ public final class HouseManager {
ZoneBorders borders = DynamicRegion.reserveArea(8,8);
DynamicRegion region = new DynamicRegion(-1, borders.getSouthWestX() >> 6, borders.getSouthWestY() >> 6);
region.setBorders(borders);
region.setUpdateAllPlanes(true);
region.setBuild(true);
RegionManager.addRegion(region.getId(), region);
return region;
@ -393,12 +389,12 @@ public final class HouseManager {
}
@Override
public BuildRegionChunk getChunk(int x, int y, int plane, @NotNull DynamicRegion dyn) {
return rooms[plane][x][y].getChunk().copy(dyn.getPlanes()[plane]);
public @Nullable RegionChunk getChunk(int x, int y, int plane, @NotNull DynamicRegion dyn) {
return rooms[plane][x][y].getChunk().copy();
}
@Override
public void afterSetting(@Nullable BuildRegionChunk chunk, int x, int y, int plane, @NotNull DynamicRegion dyn) {
public void afterSetting(@Nullable RegionChunk chunk, int x, int y, int plane, @NotNull DynamicRegion dyn) {
rooms[plane][x][y].loadDecorations(dyn != manager.dungeonRegion ? plane : 3, chunk, manager);
}
}
@ -406,8 +402,8 @@ public final class HouseManager {
private void prepareHouseChunks(HousingStyle style, DynamicRegion target, boolean buildingMode, Room[][][] rooms) {
Region from = RegionManager.forId(style.getRegionId());
Region.load(from, true);
RegionChunk defaultChunk = from.getPlanes()[style.getPlane()].getRegionChunk(1, 0);
RegionChunk defaultSkyChunk = from.getPlanes()[1].getRegionChunk(0,0);
RegionChunk defaultChunk = from.getChunks()[1][0][style.getPlane()];
RegionChunk defaultSkyChunk = from.getChunks()[0][0][1];
RoomLoadContract loadRooms = new RoomLoadContract(this, buildingMode, rooms);
RegionSpecification spec = new RegionSpecification(
@ -430,7 +426,7 @@ public final class HouseManager {
private void prepareDungeonChunks(HousingStyle style, DynamicRegion target, DynamicRegion house, boolean buildingMode, Room[][] rooms) {
Region from = RegionManager.forId(style.getRegionId());
Region.load(from, true);
RegionChunk defaultChunk = from.getPlanes()[style.getPlane()].getRegionChunk(3, 0);
RegionChunk defaultChunk = from.getChunks()[3][0][style.getPlane()];
RoomLoadContract loadRooms = new RoomLoadContract(this, buildingMode, new Room[][][]{rooms});
RegionSpecification spec = new RegionSpecification(
@ -688,7 +684,7 @@ public final class HouseManager {
* @return {@code True} if so.
*/
public boolean isInHouse(Player player) {
return isLoaded() && (player.getViewport().getRegion() == houseRegion || player.getViewport().getRegion() == dungeonRegion);
return isLoaded() && (player.getLocation().getRegion() == houseRegion || player.getLocation().getRegion() == dungeonRegion);
}
/**
@ -697,7 +693,7 @@ public final class HouseManager {
* @return {@code True} if so.
*/
public static boolean isInDungeon(Player player) {
return player.getViewport().getRegion() == player.getHouseManager().dungeonRegion;
return player.getLocation().getRegion() == player.getHouseManager().dungeonRegion;
}
/**

View file

@ -12,36 +12,35 @@ import java.util.Arrays;
*/
public enum HousingStyle {
// open door ids are doorId + 1
BASIC_WOOD (1, 5000, 7503, 0, 13100, 13101, 13098, Decoration.BASIC_WOOD_WINDOW),
BASIC_STONE (10, 5000, 7503, 1, 13094, 13096, 1902, Decoration.BASIC_STONE_WINDOW),
WHITEWASHED_STONE (20, 7500, 7503, 2, 13006, 13007, 1415, Decoration.WHITEWASHED_STONE_WINDOW),
FREMENNIK_STYLE_WOOD(30, 10000, 7503, 3, 13109, 13107, 13111, Decoration.FREMENNIK_WINDOW),
TROPICAL_WOOD (40, 15000, 7759, 0, 13016, 13015, 13011, Decoration.TROPICAL_WOOD_WINDOW),
FANCY_STONE (50, 25000, 7759, 1, 13119, 13118, 13116, Decoration.FANCY_STONE_WINDOW);
// open door ids are doorId + 1
BASIC_WOOD (1, 5000, 7503, 0, 13100, 13101, 13098, 13098, Decoration.BASIC_WOOD_WINDOW),
BASIC_STONE (10, 5000, 7503, 1, 13094, 13096, 1902, 13090, Decoration.BASIC_STONE_WINDOW),
WHITEWASHED_STONE (20, 7500, 7503, 2, 13006, 13007, 1415, 1415, Decoration.WHITEWASHED_STONE_WINDOW),
FREMENNIK_STYLE_WOOD(30, 10000, 7503, 3, 13109, 13107, 13111, 13111, Decoration.FREMENNIK_WINDOW),
TROPICAL_WOOD (40, 15000, 7759, 0, 13016, 13015, 13011, 13011, Decoration.TROPICAL_WOOD_WINDOW),
FANCY_STONE (50, 25000, 7759, 1, 13119, 13118, 13116, 13116, Decoration.FANCY_STONE_WINDOW);
/**
* Array of all Dungeon Wall IDs.
* From Region 7503, Location.create(1898, 5084, 0)
*/
private static final int[] DUNGEON_WALL_IDS = {
13019, 13020, 13021, 13022, 13023, 13024, 13025, 13026, 13027, 13028,
13029, 13030, 13031, 13032, 13033, 13034, 13035, 13036, 13037, 13046,
13048, 13049, 13050, 13051, 13055, 13056, 13058, 13059, 13060, 13061,
13062, 13063, 13065, 13066, 13067, 13068, 13069, 13070, 13072, 13073,
13074, 13075, 13076, 13077, 13079, 13080, 13081, 13082, 13083, 13084,
13086, 13087, 13088, 13089
};
/**
* Array of all Dungeon Wall IDs.
* From Region 7503, Location.create(1898, 5084, 0)
*/
private static final int[] DUNGEON_WALL_IDS = {
13019, 13020, 13021, 13022, 13023, 13024, 13025, 13026, 13027, 13028,
13029, 13030, 13031, 13032, 13033, 13034, 13035, 13036, 13037, 13046,
13048, 13049, 13050, 13051, 13055, 13056, 13058, 13059, 13060, 13061,
13062, 13063, 13065, 13066, 13067, 13068, 13069, 13070, 13072, 13073,
13074, 13075, 13076, 13077, 13079, 13080, 13081, 13082, 13083, 13084,
13086, 13087, 13088, 13089
};
/**
* Checks if the provided ID is a dungeon wall.
* @param id The object ID.
* @return {@code true} if it's a dungeon wall.
*/
public static boolean isDungeonWall(int id) {
return Arrays.binarySearch(DUNGEON_WALL_IDS, id) >= 0;
}
/**
* Checks if the provided ID is a dungeon wall.
* @param id The object ID.
* @return {@code true} if it's a dungeon wall.
*/
public static boolean isDungeonWall(int id) {
return Arrays.binarySearch(DUNGEON_WALL_IDS, id) >= 0;
}
/**
* The level required.
@ -77,21 +76,26 @@ public enum HousingStyle {
* The wall id.
*/
private final int wallId;
/**
* A second wall id, used for walls behind fireplaces in some house styles.
* Only used for the basic stone house style, who knows why. Same as wallId for other house styles.
*/
private final int secondWallId;
/**
* The window style
*/
private final Decoration window;
/**
* Checks if the player has the level.
*
* @param player the player.
* @return {@code True} if so.
*/
public boolean hasLevel(Player player) {
return player.getSkills().getStaticLevel(Skills.CONSTRUCTION) >= levelRequirement;
}
/**
* Checks if the player has the level.
* @param player the player.
* @return {@code True} if so.
*/
public boolean hasLevel(Player player) {
return player.getSkills().getStaticLevel(Skills.CONSTRUCTION) >= levelRequirement;
}
/**
* Constructs a new {@code HousingStyle} {@code Object}
@ -100,8 +104,11 @@ public enum HousingStyle {
* @param regionId The region id for this style.
* @param plane The plane for this style.
* @param doorId The door object id used in this style.
* @param secondDoorId The second-door object id used in this style.
* @param wallId The wall object id used in this style.
* @param secondWallId The second-wall object id used in this style.
*/
private HousingStyle(int level, int cost, int regionId, int plane, int doorId, int secondDoorId, int wallId, Decoration window) {
HousingStyle(int level, int cost, int regionId, int plane, int doorId, int secondDoorId, int wallId, int secondWallId, Decoration window) {
this.levelRequirement = level;
this.cost = cost;
this.regionId = regionId;
@ -109,6 +116,7 @@ public enum HousingStyle {
this.doorId = doorId;
this.secondDoorId = secondDoorId;
this.wallId = wallId;
this.secondWallId = secondWallId;
this.window = window;
}
@ -159,7 +167,15 @@ public enum HousingStyle {
public int getWallId() {
return wallId;
}
/**
* Gets the second wall used in this style.
* @return The wall object id.
*/
public int getSecondWallId() {
return secondWallId;
}
/**
* Gets the window id for this style of house
* @return The windows object id
@ -175,4 +191,4 @@ public enum HousingStyle {
public int getSecondDoorId() {
return secondDoorId;
}
}
}

View file

@ -1,6 +1,5 @@
package content.global.skill.construction;
import core.game.node.entity.player.Player;
import core.game.node.scenery.Constructed;
import core.game.node.scenery.Scenery;
@ -16,7 +15,6 @@ import static core.api.ContentAPIKt.log;
*
*/
public final class Room {
/**
* The default room type.
*/
@ -95,7 +93,7 @@ public final class Room {
public void decorate(HousingStyle style) {
Region region = RegionManager.forId(style.getRegionId());
Region.load(region, true);
chunk = region.getPlanes()[style.getPlane()].getRegionChunk(properties.getChunkX(), properties.getChunkY());
chunk = region.getChunks()[properties.getChunkX()][properties.getChunkY()][style.getPlane()];
}
/**
@ -126,28 +124,24 @@ public final class Room {
* Loads all the decorations.
* @param housePlane The plane.
* @param chunk The chunk used in the dynamic region.
*/
public void loadDecorations(int housePlane, BuildRegionChunk chunk, HouseManager house) {
for (int i = 0; i < hotspots.length; i++) {
Hotspot spot = hotspots[i];
*/
public void loadDecorations(int housePlane, RegionChunk chunk, HouseManager house) {
for (Hotspot spot : hotspots) {
int x = spot.getChunkX();
int y = spot.getChunkY();
if (spot.getHotspot() == null) {
continue;
}
int index = chunk.getIndex(x, y, spot.getHotspot().getObjectId(house.getStyle()));
Scenery[][] objects = chunk.getObjects(index);
int id = spot.getHotspot().getObjectId(house.getStyle());
int index = chunk.getIndex(x, y, id, -1);
Scenery[][] objects = chunk.getObjects()[index];
Scenery object = objects[x][y];
if (object != null && object.getId() == spot.getHotspot().getObjectId(house.getStyle())) {
if (spot.getDecorationIndex() > -1 && spot.getDecorationIndex() < spot.getHotspot().getDecorations().length) {
int id = spot.getHotspot().getDecorations()[spot.getDecorationIndex()].getObjectId(house.getStyle());
id = spot.getHotspot().getDecorations()[spot.getDecorationIndex()].getObjectId(house.getStyle());
if (spot.getHotspot().getType() == BuildHotspotType.CREST) {
id += house.getCrest().ordinal();
}
SceneryBuilder.replace(object, object.transform(id, object.getRotation(), chunk.getCurrentBase().transform(x, y, 0)));
}
else if (object.getId() == BuildHotspot.WINDOW.getObjectId(house.getStyle()) || (!house.isBuildingMode() && object.getId() == BuildHotspot.CHAPEL_WINDOW.getObjectId(house.getStyle()))) {
chunk.add(object.transform(house.getStyle().getWindowStyle().getObjectId(house.getStyle()), object.getRotation(), object.getType()));
} else if (object.getId() == BuildHotspot.WINDOW.getObjectId(house.getStyle()) || (!house.isBuildingMode() && object.getId() == BuildHotspot.CHAPEL_WINDOW.getObjectId(house.getStyle()))) {
SceneryBuilder.replace(object, object.transform(house.getStyle().getWindowStyle().getObjectId(house.getStyle()), object.getRotation(), object.getType()));
}
int[] pos = RegionChunk.getRotatedPosition(x, y, object.getSizeX(), object.getSizeY(), 0, rotation.toInteger());
spot.setCurrentX(pos[0]);
@ -159,30 +153,29 @@ public final class Room {
}
if (!house.isBuildingMode()) {
placeDoors(housePlane, house, chunk);
removeHotspots(housePlane, house, chunk);
removeHotspots(house, chunk);
}
}
/**
* Removes the building hotspots from the room.
* @param housePlane The room's plane in house.
* @param house The house manager.
* @param chunk The region chunk used.
*/
private void removeHotspots(int housePlane, HouseManager house, BuildRegionChunk chunk) {
private void removeHotspots(HouseManager house, RegionChunk chunk) {
if (properties.isRoof()) return;
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
for (int i = 0; i < BuildRegionChunk.ARRAY_SIZE; i++) {
Scenery object = chunk.get(x, y, i);
for (int i = 0; i < RegionChunk.ARRAY_SIZE; i++) {
Scenery object = chunk.getObjects()[i][x][y];
if (object != null) {
int id = object.getId();
boolean isBuilt = object instanceof Constructed;
boolean isWall = HousingStyle.isDungeonWall(id) || id == house.getStyle().getWallId();
boolean isDoor = id == house.getStyle().getDoorId() || id == house.getStyle().getSecondDoorId();
if (!isBuilt && !isWall && !isDoor) {
int id = object.getId();
boolean isBuilt = !object.getDefinition().hasAction("build");
boolean isGround = object.getType() == 22 && !object.getDefinition().hasOptions();
boolean isWall = HousingStyle.isDungeonWall(id) || id == house.getStyle().getWallId() || id == house.getStyle().getSecondWallId();
boolean isDoor = id == house.getStyle().getDoorId() || id == house.getStyle().getSecondDoorId();
if (!isBuilt && !isGround && !isWall && !isDoor) {
SceneryBuilder.remove(object);
chunk.remove(object);
}
}
}
@ -197,14 +190,14 @@ public final class Room {
* @param house The house manager.
* @param chunk The region chunk used.
*/
private void placeDoors(int housePlane, HouseManager house, BuildRegionChunk chunk) {
private void placeDoors(int housePlane, HouseManager house, RegionChunk chunk) {
Room[][][] rooms = house.getRooms();
int rx = chunk.getCurrentBase().getChunkX();
int ry = chunk.getCurrentBase().getChunkY();
for (int i = 0; i < BuildRegionChunk.ARRAY_SIZE; i++) {
for (int i = 0; i < RegionChunk.ARRAY_SIZE; i++) {
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
Scenery object = chunk.get(x, y, i);
Scenery object = chunk.getObjects()[i][x][y];
if (object != null && BuildingUtils.isDoorHotspot(object)) {
boolean edge = false;
Room otherRoom = null;
@ -274,7 +267,7 @@ public final class Room {
return object.getId() % 2 != 0 ? house.getStyle().getDoorId() : house.getStyle().getSecondDoorId();
}
}
return room.getProperties().isDungeon() ? 13065 : house.getStyle().getWallId();
return room.getProperties().isDungeon() ? 13065 : house.getStyle().getWallId(); //otherWallId is only used behind fireplaces
}
/**
@ -423,5 +416,4 @@ public final class Room {
public Direction getRotation() {
return rotation;
}
}

View file

@ -920,7 +920,7 @@ public enum RoomProperties {
public boolean[] getExits() {
Region region = RegionManager.forId(7503);
Region.load(region, true);
RegionChunk chunk = region.getPlanes()[0].getRegionChunk(chunkX, chunkY);
RegionChunk chunk = region.getChunks()[chunkX][chunkY][0];
return new boolean[] { isExit(chunk, 7, 3), isExit(chunk, 3, 0), isExit(chunk, 0, 3), isExit(chunk, 3, 7) };
}

View file

@ -29,18 +29,18 @@ public final class StaircasePlugin extends OptionHandler {
public Plugin<Object> newInstance(Object arg) throws Throwable {
ClassScanner.definePlugin(new BuildDialogue());
ClassScanner.definePlugin(new ClimbPohLadder());
// 13497 - 13502 are normal stairs
// 13503 - 13506 are spiral stairs
// 13497 - 13502 are normal stairs
// 13503 - 13506 are spiral stairs
for (int i = 13497; i <= 13506; i++) {
SceneryDefinition.forId(i).getHandlers().put("option:climb", this);
SceneryDefinition.forId(i).getHandlers().put("option:climb-up", this);
SceneryDefinition.forId(i).getHandlers().put("option:climb-down", this);
SceneryDefinition.forId(i).getHandlers().put("option:remove-room", this);
}
// 13409 is dungeon entrance
// 13409 is dungeon entrance
SceneryDefinition.forId(13409).getHandlers().put("option:enter", this);
SceneryDefinition.forId(13409).getHandlers().put("option:remove-room", this);
// 13328 - 13330 are dungeon ladders
// 13328 - 13330 are dungeon ladders
for (int id = 13328; id <= 13330; id++) {
SceneryDefinition.forId(id).getHandlers().put("option:climb", this);
SceneryDefinition.forId(id).getHandlers().put("option:remove-room", this);
@ -74,43 +74,43 @@ public final class StaircasePlugin extends OptionHandler {
return true;
case "remove-room":
int currentZ = player.getLocation().getZ();
int chunkX = player.getLocation().getChunkX();
int chunkY = player.getLocation().getChunkY();
int currentZ = player.getLocation().getZ();
int chunkX = player.getLocation().getChunkX();
int chunkY = player.getLocation().getChunkY();
// must be in building mode
if(!player.getHouseManager().isBuildingMode()) {
player.getPacketDispatch().sendMessage("You can only do this in building mode.");
return true;
}
// must be in building mode
if(!player.getHouseManager().isBuildingMode()) {
player.getPacketDispatch().sendMessage("You can only do this in building mode.");
return true;
}
// if you're in the dungeon, try and remove the room at Z = 0 from the house region.
if (HouseManager.isInDungeon(player)) {
player.getDialogueInterpreter().open("con:remove", null, new int[]{chunkX, chunkY}, 0);
// if you're in the dungeon, try and remove the room at Z = 0 from the house region.
if (HouseManager.isInDungeon(player)) {
player.getDialogueInterpreter().open("con:remove", null, new int[]{chunkX, chunkY}, 0);
// From ground floor (z=0), stairs could lead to 1st floor (z=1) or the dungeon (z=3)
} else {
// garden dungeon entrance and oubliette ladders don't need a height selection
if(node.getId() == 13409 || node.getId() == 13675 || node.getId() == 13676 || node.getId() == 13677 || node.getId() == 13678 || node.getId() == 13679 || node.getId() == 13680) {
player.getDialogueInterpreter().open("con:remove", null, new int[]{chunkX, chunkY}, 3);
} else {
player.getDialogueInterpreter().sendOptions("Remove which room?", "Room Above", "Room Below", "Cancel");
player.getDialogueInterpreter().addAction((interId, btn) -> {
if (btn == 2) { // Above
player.getDialogueInterpreter().open("con:remove", null, new int[]{chunkX, chunkY}, currentZ + 1);
} else if (btn == 3) { // Below
if (currentZ - 1 == -1) {
player.getDialogueInterpreter().open("con:remove", null, new int[]{chunkX, chunkY}, 3);
} else {
player.getDialogueInterpreter().open("con:remove", null, new int[]{chunkX, chunkY}, currentZ - 1);
}
// From ground floor (z=0), stairs could lead to 1st floor (z=1) or the dungeon (z=3)
} else {
// garden dungeon entrance and oubliette ladders don't need a height selection
if(node.getId() == 13409 || node.getId() == 13675 || node.getId() == 13676 || node.getId() == 13677 || node.getId() == 13678 || node.getId() == 13679 || node.getId() == 13680) {
player.getDialogueInterpreter().open("con:remove", null, new int[]{chunkX, chunkY}, 3);
} else {
player.getDialogueInterpreter().sendOptions("Remove which room?", "Room Above", "Room Below", "Cancel");
player.getDialogueInterpreter().addAction((interId, btn) -> {
if (btn == 2) { // Above
player.getDialogueInterpreter().open("con:remove", null, new int[]{chunkX, chunkY}, currentZ + 1);
} else if (btn == 3) { // Below
if (currentZ - 1 == -1) {
player.getDialogueInterpreter().open("con:remove", null, new int[]{chunkX, chunkY}, 3);
} else {
player.getDialogueInterpreter().open("con:remove", null, new int[]{chunkX, chunkY}, currentZ - 1);
}
}
});
}
}
});
}
}
return true;
}
return true;
case "climb":
if (HouseManager.isInDungeon(player)) {
@ -151,7 +151,7 @@ public final class StaircasePlugin extends OptionHandler {
if (plane < 0) { //Dungeon
plane = 3;
}
else if (player.getViewport().getRegion() == house.getDungeonRegion() && plane == 1) {//going up
else if (player.getLocation().getRegion() == house.getDungeonRegion() && plane == 1) {//going up
plane = 0;
}
Room room = house.getRooms()[plane][roomX][roomY];
@ -165,7 +165,7 @@ public final class StaircasePlugin extends OptionHandler {
}
} else {
Location destination = l.transform(0, 0, z);
if (player.getViewport().getRegion() == house.getDungeonRegion()) {
if (player.getLocation().getRegion() == house.getDungeonRegion()) {
destination = house.getHouseRegion().getBaseLocation().transform(l.getLocalX(), l.getLocalY(), 0);
}
else if (plane == 3) {
@ -417,7 +417,7 @@ public final class StaircasePlugin extends OptionHandler {
for (Direction d : dirs) {
if (d == room.getRotation()) {
r.setRotation(d);
// todo this just puts a default set of stairs in the dungeon. The below code works for skill/quest hall, but not a dungeon entrance.
// todo this just puts a default set of stairs in the dungeon. The below code works for skill/quest hall, but not a dungeon entrance.
//Hotspot stairs = room.getStairs();
//int index = stairs != null ? stairs.getDecorationIndex() : -1;
BuildingUtils.buildRoom(player, r, plane, roomX, roomY, r.getExits(), true);

View file

@ -525,7 +525,7 @@ public class HouseServantDialogue extends DialoguePlugin {
@Override
public boolean pulse() {
if (player == null || player.getHouseManager().getHouseRegion() != player.getViewport().getRegion()) { //TODO: Check if in dungeon?
if (player == null || player.getHouseManager().getHouseRegion() != player.getLocation().getRegion()) { //TODO: Check if in dungeon?
return true;
}
int amt = player.getBank().getAmount(item.getId());

View file

@ -20,62 +20,62 @@ import static core.api.ContentAPIKt.playAudio;
*/
public final class SpinningPulse extends SkillPulse<Item> {
/**
* Represents the animation to use.
*/
private static final Animation ANIMATION = new Animation(896);
/**
* Represents the animation to use.
*/
private static final Animation ANIMATION = new Animation(896);
/**
* Represents the type of spinning item.
*/
private final SpinningItem type;
/**
* Represents the type of spinning item.
*/
private final SpinningItem type;
/**
* Represents the amount to spin.
*/
private int ammount;
/**
* Represents the amount to spin.
*/
private int ammount;
/**
* Represents the ticks passed.
*/
private int ticks;
/**
* Represents the ticks passed.
*/
private int ticks;
/**
* Constructs a new {@code SpinningPulse.java} {@Code Object}
*
* @param player
* @param node
*/
public SpinningPulse(Player player, Item node, int ammount, SpinningItem def) {
super(player, node);
this.type = def;
this.ammount = ammount;
}
/**
* Constructs a new {@code SpinningPulse.java} {@Code Object}
*
* @param player
* @param node
*/
public SpinningPulse(Player player, Item node, int ammount, SpinningItem def) {
super(player, node);
this.type = def;
this.ammount = ammount;
}
@Override
public boolean checkRequirements() {
player.getInterfaceManager().close();
if (player.getSkills().getLevel(Skills.CRAFTING) < type.getLevel()) {
player.getPacketDispatch().sendMessage("You need a crafting level of " + type.getLevel() + " to make this.");
return false;
}
if (!player.getInventory().contains(type.getNeed(), 1)) {
player.getPacketDispatch().sendMessage("You need " + ItemDefinition.forId(type.getNeed()).getName() + " to do this.");
return false;
}
return true;
}
@Override
public boolean checkRequirements() {
player.getInterfaceManager().close();
if (player.getSkills().getLevel(Skills.CRAFTING) < type.getLevel()) {
player.getPacketDispatch().sendMessage("You need a crafting level of " + type.getLevel() + " to make this.");
return false;
}
if (!player.getInventory().contains(type.getNeed(), 1)) {
player.getPacketDispatch().sendMessage("You need " + ItemDefinition.forId(type.getNeed()).getName() + " to do this.");
return false;
}
return true;
}
@Override
public void animate() {
if (ticks % 5 == 0) {
player.animate(ANIMATION);
playAudio(player, Sounds.SPINNING_2590);
}
}
@Override
public void animate() {
if (ticks % 5 == 0) {
player.animate(ANIMATION);
playAudio(player, Sounds.SPINNING_2590);
}
}
@Override
public boolean reward() {
@Override
public boolean reward() {
int tickThreshhold = 4;
if (player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(2)
&& player.getLocation().withinDistance(Location.create(2711,3471,1))
@ -83,31 +83,31 @@ public final class SpinningPulse extends SkillPulse<Item> {
&& player.getEquipment().get(EquipmentContainer.SLOT_HAT).getId() == 14631) {
tickThreshhold = 2;
}
if (++ticks % tickThreshhold != 0) {
return false;
}
if (player.getInventory().remove(new Item(type.getNeed(), 1))) {
final Item item = new Item(type.getProduct(), 1);
player.getInventory().add(item);
player.getSkills().addExperience(Skills.CRAFTING, type.getExp(), true);
if (++ticks % tickThreshhold != 0) {
return false;
}
if (player.getInventory().remove(new Item(type.getNeed(), 1))) {
final Item item = new Item(type.getProduct(), 1);
player.getInventory().add(item);
player.getSkills().addExperience(Skills.CRAFTING, type.getExp(), true);
// Seers achievement diary
if (player.getViewport().getRegion().getId() == 10806
&& !player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(0, 4)) {
if (player.getAttribute("diary:seers:bowstrings-spun", 0) >= 4) {
player.setAttribute("/save:diary:seers:bowstrings-spun", 5);
player.getAchievementDiaryManager().finishTask(player, DiaryType.SEERS_VILLAGE, 0, 4);
} else {
player.setAttribute("/save:diary:seers:bowstrings-spun", player.getAttribute("diary:seers:bowstrings-spun", 0) + 1);
}
}
}
ammount--;
return ammount < 1;
}
// Seers achievement diary
if (player.getLocation().getRegionId() == 10806
&& !player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(0, 4)) {
if (player.getAttribute("diary:seers:bowstrings-spun", 0) >= 4) {
player.setAttribute("/save:diary:seers:bowstrings-spun", 5);
player.getAchievementDiaryManager().finishTask(player, DiaryType.SEERS_VILLAGE, 0, 4);
} else {
player.setAttribute("/save:diary:seers:bowstrings-spun", player.getAttribute("diary:seers:bowstrings-spun", 0) + 1);
}
}
}
ammount--;
return ammount < 1;
}
@Override
public void message(int type) {
}
@Override
public void message(int type) {
}
}

View file

@ -138,7 +138,7 @@ public final class FireMakingPulse extends SkillPulse<Item> {
player.faceLocation(object.getFaceLocation(player.getLocation()));
player.getSkills().addExperience(Skills.FIREMAKING,fire.getXp());
int playerRegion = player.getViewport().getRegion().getId();
int playerRegion = player.getLocation().getRegionId();
setLastFire();
player.dispatch(new LitFireEvent(fire.getLogId()));

View file

@ -29,6 +29,7 @@ import core.game.node.scenery.SceneryBuilder
import core.game.system.command.sets.STATS_BASE
import core.game.system.command.sets.STATS_LOGS
import core.game.world.map.RegionManager
import core.game.world.repository.Repository
import core.tools.RandomFunction
import org.rs09.consts.Items
import org.rs09.consts.NPCs
@ -212,14 +213,13 @@ class WoodcuttingListener : InteractionListener {
fun animateWoodcutting(player: Player) {
if (!player.animator.isAnimating) {
player.animate(SkillingTool.getHatchet(player).animation)
val playersAroundMe: List<Player> = RegionManager.getLocalPlayers(player, 2)
val playersAroundMe: List<Player> = RegionManager.getLocalPlayers(player.location, 2)
.stream()
.filter { p: Player -> p.username != player.username }
.filter { p -> p.name != player.name }
.toList()
val soundIndex = RandomFunction.random(0, woodcuttingSounds.size)
for (p in playersAroundMe) {
playAudio(p, woodcuttingSounds[soundIndex])
for (player in playersAroundMe) {
playAudio(player, woodcuttingSounds[soundIndex])
}
}
}
@ -260,7 +260,7 @@ class WoodcuttingListener : InteractionListener {
}
// Seers village medium reward - extra normal log while in seer's village
if (reward == 1511 && player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(1) && player.getViewport().getRegion().getId() == 10806) {
if (reward == 1511 && player.achievementDiaryManager.getDiary(DiaryType.SEERS_VILLAGE).isComplete(1) && player.getLocation().regionId == 10806) {
amount = 2
}
return amount

View file

@ -21,6 +21,7 @@ import core.game.node.scenery.SceneryBuilder;
import core.game.system.task.Pulse;
import core.game.world.map.Location;
import core.game.world.map.RegionManager;
import core.game.world.repository.Repository;
import core.game.world.update.flag.context.Animation;
import core.tools.RandomFunction;
import org.rs09.consts.Sounds;
@ -38,248 +39,244 @@ import static core.game.system.command.sets.StatAttributeKeysKt.STATS_LOGS;
* @author ceik
*/
public class WoodcuttingSkillPulse extends Pulse {
private int[] woodcuttingSounds = {
Sounds.WOODCUTTING_HIT_3038,
Sounds.WOODCUTTING_HIT_3039,
Sounds.WOODCUTTING_HIT_3040,
Sounds.WOODCUTTING_HIT_3041,
Sounds.WOODCUTTING_HIT_3042
};
private int[] woodcuttingSounds = {
Sounds.WOODCUTTING_HIT_3038,
Sounds.WOODCUTTING_HIT_3039,
Sounds.WOODCUTTING_HIT_3040,
Sounds.WOODCUTTING_HIT_3041,
Sounds.WOODCUTTING_HIT_3042
};
private WoodcuttingNode resource;
private int ticks;
private Player player;
private Scenery node;
protected boolean resetAnimation = true;
private WoodcuttingNode resource;
private int ticks;
private Player player;
private Scenery node;
protected boolean resetAnimation = true;
public WoodcuttingSkillPulse(Player player, Scenery node) {
super(1, player, node);
this.player = player;
this.node = node;
super.stop();
}
public WoodcuttingSkillPulse(Player player, Scenery node) {
super(1, player, node);
this.player = player;
this.node = node;
super.stop();
}
public void message(int type) {
if (type == 0) {
player.getPacketDispatch().sendMessage("You swing your axe at the tree...");
}
}
public void message(int type) {
if (type == 0) {
player.getPacketDispatch().sendMessage("You swing your axe at the tree...");
}
}
@Override
public boolean pulse() {
if (!checkRequirements()) {
return true;
}
animate();
return reward();
}
@Override
public boolean pulse() {
if (!checkRequirements()) {
return true;
}
animate();
return reward();
}
@Override
public void stop() {
if (resetAnimation) {
player.animate(new Animation(-1, Animator.Priority.HIGH));
}
super.stop();
message(1);
}
@Override
public void stop() {
if (resetAnimation) {
player.animate(new Animation(-1, Animator.Priority.HIGH));
}
super.stop();
message(1);
}
@Override
public void start() {
resource = WoodcuttingNode.forId(node.getId());
if (resource == null) {
return;
}
if (checkRequirements()) {
super.start();
message(0);
}
}
@Override
public void start() {
resource = WoodcuttingNode.forId(node.getId());
if (resource == null) {
return;
}
if (checkRequirements()) {
super.start();
message(0);
}
}
public boolean checkRequirements() {
if (player.getSkills().getLevel(Skills.WOODCUTTING) < resource.getLevel()) {
player.getPacketDispatch().sendMessage("You need a woodcutting level of " + resource.getLevel() + " to chop this tree.");
return false;
}
if (SkillingTool.getHatchet(player) == null) {
player.getPacketDispatch().sendMessage("You do not have an axe to use.");
return false;
}
if (player.getInventory().freeSlots() < 1) {
player.getDialogueInterpreter().sendDialogue("Your inventory is too full to hold any more " + ItemDefinition.forId(resource.getReward()).getName().toLowerCase() + ".");
return false;
}
return true;
}
public boolean checkRequirements() {
if (player.getSkills().getLevel(Skills.WOODCUTTING) < resource.getLevel()) {
player.getPacketDispatch().sendMessage("You need a woodcutting level of " + resource.getLevel() + " to chop this tree.");
return false;
}
if (SkillingTool.getHatchet(player) == null) {
player.getPacketDispatch().sendMessage("You do not have an axe to use.");
return false;
}
if (player.getInventory().freeSlots() < 1) {
player.getDialogueInterpreter().sendDialogue("Your inventory is too full to hold any more " + ItemDefinition.forId(resource.getReward()).getName().toLowerCase() + ".");
return false;
}
return true;
}
public void animate() {
if(!player.getAnimator().isAnimating()) {
player.animate(SkillingTool.getHatchet(player).getAnimation());
public void animate() {
if (!player.getAnimator().isAnimating()) {
player.animate(SkillingTool.getHatchet(player).getAnimation());
for (Player p : RegionManager.getLocalPlayers(player.getLocation(), 2)) {
if (p.getName() == player.getName()) {
continue;
}
int soundIndex = RandomFunction.random(0, woodcuttingSounds.length);
playAudio(p, woodcuttingSounds[soundIndex]);
}
}
}
List<Player> playersAroundMe = RegionManager.getLocalPlayers(player, 2)
.stream()
.filter(p -> !p.getUsername().equals(player.getUsername()))
.collect(Collectors.toList());
public boolean reward() {
if (++ticks % 4 != 0) {
return false;
}
if (node.getId() == 10041) {
player.getDialogueInterpreter().sendDialogues(2574, FacialExpression.FURIOUS, RandomFunction.random(2) == 1 ? "You'll blow my cover! I'm meant to be hidden!" : "Will you stop that?");
return true;
}
if (!checkReward(SkillingTool.getHatchet(player))) {
return false;
}
int soundIndex = RandomFunction.random(0, woodcuttingSounds.length);
// 20% chance to auto burn logs when using "inferno adze" item
if (SkillingTool.getHatchet(player).getId() == 13661 && RandomFunction.random(100) < 25) {
player.sendMessage("You chop some logs. The heat of the inferno adze incinerates them.");
Projectile.create(player, null, 1776, 35, 30, 20, 25).transform(player, new Location(player.getLocation().getX() + 2, player.getLocation().getY()), true, 25, 25).send();
player.getSkills().addExperience(Skills.WOODCUTTING, resource.getExperience());
player.getSkills().addExperience(Skills.FIREMAKING, resource.getExperience());
return rollDepletion();
}
for (Player p : playersAroundMe) {
playAudio(p, woodcuttingSounds[soundIndex]);
}
}
}
//actual reward calculations
int reward = resource.getReward();
int rewardAmount = 0;
if (reward > 0) {
reward = calculateReward(reward); // calculate rewards
rewardAmount = calculateRewardAmount(reward); // calculate amount
public boolean reward() {
if (++ticks % 4 != 0) {
return false;
}
if (node.getId() == 10041) {
player.getDialogueInterpreter().sendDialogues(2574, FacialExpression.FURIOUS, RandomFunction.random(2) == 1 ? "You'll blow my cover! I'm meant to be hidden!" : "Will you stop that?");
return true;
}
if (!checkReward(SkillingTool.getHatchet(player))) {
return false;
}
//add experience
double experience = calculateExperience(resource.reward, rewardAmount);
// 20% chance to auto burn logs when using "inferno adze" item
if (SkillingTool.getHatchet(player).getId() == 13661 && RandomFunction.random(100) < 25) {
player.sendMessage("You chop some logs. The heat of the inferno adze incinerates them.");
Projectile.create(player, null, 1776, 35, 30, 20, 25).transform(player, new Location(player.getLocation().getX() + 2, player.getLocation().getY()), true, 25, 25).send();
player.getSkills().addExperience(Skills.WOODCUTTING, resource.getExperience());
player.getSkills().addExperience(Skills.FIREMAKING, resource.getExperience());
return rollDepletion();
}
player.getSkills().addExperience(Skills.WOODCUTTING, experience, true);
//actual reward calculations
int reward = resource.getReward();
int rewardAmount = 0;
if (reward > 0) {
reward = calculateReward(reward); // calculate rewards
rewardAmount = calculateRewardAmount(reward); // calculate amount
//send the message for the resource reward
player.getPacketDispatch().sendMessage("You get some " + ItemDefinition.forId(reward).getName().toLowerCase() + ".");
//give the reward
player.getInventory().add(new Item(reward, rewardAmount));
player.dispatch(new ResourceProducedEvent(reward, rewardAmount, node, -1));
int cutLogs = player.getAttribute(STATS_BASE + ":" + STATS_LOGS,0);
player.setAttribute("/save:" + STATS_BASE + ":" + STATS_LOGS,++cutLogs);
//add experience
double experience = calculateExperience(resource.reward, rewardAmount);
//calculate bonus bird nest for mining
int chance = 282;
if (RandomFunction.random(chance) == chance / 2) {
if(SkillcapePerks.isActive(SkillcapePerks.NEST_HUNTER,player)){
if(!player.getInventory().add(BirdNest.getRandomNest(false).getNest())){
BirdNest.drop(player);
}
} else {
BirdNest.drop(player);
}
}
player.getSkills().addExperience(Skills.WOODCUTTING, experience, true);
}
//send the message for the resource reward
player.getPacketDispatch().sendMessage("You get some " + ItemDefinition.forId(reward).getName().toLowerCase() + ".");
//give the reward
player.getInventory().add(new Item(reward, rewardAmount));
player.dispatch(new ResourceProducedEvent(reward, rewardAmount, node, -1));
int cutLogs = player.getAttribute(STATS_BASE + ":" + STATS_LOGS,0);
player.setAttribute("/save:" + STATS_BASE + ":" + STATS_LOGS,++cutLogs);
return rollDepletion();
}
//calculate bonus bird nest for mining
int chance = 282;
if (RandomFunction.random(chance) == chance / 2) {
if(SkillcapePerks.isActive(SkillcapePerks.NEST_HUNTER,player)){
if(!player.getInventory().add(BirdNest.getRandomNest(false).getNest())){
BirdNest.drop(player);
}
} else {
BirdNest.drop(player);
}
}
private boolean rollDepletion() {
//transform to depleted version
//OSRS and RS3 Wikis both agree: All trees present in 2009 are a 1/8 fell chance, aside from normal trees/dead trees which are 100%
//OSRS: https://oldschool.runescape.wiki/w/Woodcutting scroll down to the mechanics section
//RS3 : https://runescape.wiki/w/Woodcutting scroll down to the mechanics section, and expand the tree felling chances table
if (resource.getRespawnRate() > 0) {
if (RandomFunction.roll(8) || resource.identifier == 1 || resource.identifier == 2 || resource.identifier == 3 || resource.identifier == 6) {
if (resource.isFarming()) {
FarmingPatch fPatch = FarmingPatch.forObject(node.asScenery());
if(fPatch != null) {
Patch patch = fPatch.getPatchFor(player, true);
patch.setCurrentState(patch.getCurrentState() + 1);
}
return true;
}
if (resource.getEmptyId() > -1) {
SceneryBuilder.replace(node, node.transform(resource.getEmptyId()), resource.getRespawnDuration());
} else {
SceneryBuilder.replace(node, node.transform(0), resource.getRespawnDuration());
}
node.setActive(false);
}
playAudio(player, Sounds.TREE_FALLING_2734);
return true;
}
}
return false;
}
return rollDepletion();
}
private int calculateRewardAmount(int reward) {
int amount = 1;
private boolean rollDepletion() {
//transform to depleted version
//OSRS and RS3 Wikis both agree: All trees present in 2009 are a 1/8 fell chance, aside from normal trees/dead trees which are 100%
//OSRS: https://oldschool.runescape.wiki/w/Woodcutting scroll down to the mechanics section
//RS3 : https://runescape.wiki/w/Woodcutting scroll down to the mechanics section, and expand the tree felling chances table
if (resource.getRespawnRate() > 0) {
if (RandomFunction.roll(8) || resource.identifier == 1 || resource.identifier == 2 || resource.identifier == 3 || resource.identifier == 6) {
if (resource.isFarming()) {
FarmingPatch fPatch = FarmingPatch.forObject(node.asScenery());
if(fPatch != null) {
Patch patch = fPatch.getPatchFor(player, true);
patch.setCurrentState(patch.getCurrentState() + 1);
}
return true;
}
if (resource.getEmptyId() > -1) {
SceneryBuilder.replace(node, node.transform(resource.getEmptyId()), resource.getRespawnDuration());
} else {
SceneryBuilder.replace(node, node.transform(0), resource.getRespawnDuration());
}
node.setActive(false);
// 3239: Hollow tree (bark) 10% chance of obtaining
if (reward == 3239 && RandomFunction.random(100) >= 10) {
amount = 0;
}
playAudio(player, Sounds.TREE_FALLING_2734);
return true;
}
}
return false;
}
// Seers village medium reward - extra normal log while in seer's village
if (reward == 1511
&& player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(1)
&& player.getLocation().getRegionId() == 10806) {
amount = 2;
}
private int calculateRewardAmount(int reward) {
int amount = 1;
return amount;
}
// 3239: Hollow tree (bark) 10% chance of obtaining
if (reward == 3239 && RandomFunction.random(100) >= 10) {
amount = 0;
}
private double calculateExperience(int reward, int amount) {
double experience = resource.getExperience();
// Seers village medium reward - extra normal log while in seer's village
if (reward == 1511
&& player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(1)
&& player.getViewport().getRegion().getId() == 10806) {
amount = 2;
}
if(player.getLocation().getRegionId() == 10300){
return 1.0;
}
return amount;
}
// Bark
if (reward == 3239) {
// If we receive the item, give the full experience points otherwise give the base amount
if (amount >= 1) {
experience = 275.2;
} else {
amount = 1;
}
}
private double calculateExperience(int reward, int amount) {
double experience = resource.getExperience();
// Seers village medium reward - extra 10% xp from maples while wearing headband
if (reward == 1517
&& player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(1)
&& player.getEquipment().get(EquipmentContainer.SLOT_HAT) != null
&& player.getEquipment().get(EquipmentContainer.SLOT_HAT).getId() == 14631) {
experience *= 1.10;
}
if(player.getLocation().getRegionId() == 10300){
return 1.0;
}
return experience * amount;
}
// Bark
if (reward == 3239) {
// If we receive the item, give the full experience points otherwise give the base amount
if (amount >= 1) {
experience = 275.2;
} else {
amount = 1;
}
}
private int calculateReward(int reward) {
return reward;
}
// Seers village medium reward - extra 10% xp from maples while wearing headband
if (reward == 1517
&& player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(1)
&& player.getEquipment().get(EquipmentContainer.SLOT_HAT) != null
&& player.getEquipment().get(EquipmentContainer.SLOT_HAT).getId() == 14631) {
experience *= 1.10;
}
return experience * amount;
}
private int calculateReward(int reward) {
return reward;
}
/**
* Checks if the player gets rewarded.
*
* @return {@code True} if so.
*/
private boolean checkReward(SkillingTool tool) {
int skill = Skills.WOODCUTTING;
int level = player.getSkills().getLevel(skill) + player.getFamiliarManager().getBoost(skill);
double hostRatio = RandomFunction.randomDouble(100.0);
double lowMod = tool == SkillingTool.BLACK_AXE ? resource.tierModLow / 2 : resource.tierModLow;
double low = resource.baseLow + (tool.ordinal() * lowMod);
double highMod = tool == SkillingTool.BLACK_AXE ? resource.tierModHigh / 2 : resource.tierModHigh;
double high = resource.baseHigh + (tool.ordinal() * highMod);
double clientRatio = RandomFunction.getSkillSuccessChance(low,high,level);
return hostRatio < clientRatio;
}
/**
* Checks if the player gets rewarded.
*
* @return {@code True} if so.
*/
private boolean checkReward(SkillingTool tool) {
int skill = Skills.WOODCUTTING;
int level = player.getSkills().getLevel(skill) + player.getFamiliarManager().getBoost(skill);
double hostRatio = RandomFunction.randomDouble(100.0);
double lowMod = tool == SkillingTool.BLACK_AXE ? resource.tierModLow / 2 : resource.tierModLow;
double low = resource.baseLow + (tool.ordinal() * lowMod);
double highMod = tool == SkillingTool.BLACK_AXE ? resource.tierModHigh / 2 : resource.tierModHigh;
double high = resource.baseHigh + (tool.ordinal() * highMod);
double clientRatio = RandomFunction.getSkillSuccessChance(low,high,level);
return hostRatio < clientRatio;
}
}

View file

@ -173,6 +173,6 @@ enum class ImplingSpawnLocations (val type: ImplingSpawnTypes, vararg val locati
object ImplingClipper : ClipMaskSupplier {
override fun getClippingFlag (z: Int, x: Int, y: Int) : Int {
var flag = RegionManager.getClippingFlag(z, x, y)
return flag and (RegionFlags.SOLID_TILE.inv()) and (RegionFlags.TILE_OBJECT.inv()) //Allow walking on water and flying over small objects, but keep all other tile flags the same.
return flag and (ChunkFlags.SOLID_TILE.inv()) and (ChunkFlags.TILE_OBJECT.inv()) //Allow walking on water and flying over small objects, but keep all other tile flags the same.
}
}

View file

@ -2,6 +2,7 @@ package content.global.skill.magic.lunar;
import core.game.node.entity.combat.spell.MagicSpell;
import core.game.node.entity.combat.spell.Runes;
import core.game.world.repository.Repository;
import core.plugin.Initializable;
import core.game.node.entity.skill.Skills;
import core.game.node.Node;
@ -111,14 +112,14 @@ public final class HealSpell extends MagicSpell {
playGlobalAudio(o.getLocation(), Sounds.LUNAR_HEAL_OTHER_INDIVIDUAL_2892);
o.graphics(GRAPHICS);
} else {
List<Player> players = RegionManager.getLocalPlayers(player, 1);
if (!super.meetsRequirements(player, true, true)) {
if (!super.meetsRequirements(player, true, true)) {
return false;
}
int percentage = (int) Math.ceil(player.getSkills().getLifepoints() * 0.75);
List<Player> players = RegionManager.getLocalPlayers(player.getLocation(), 1);
for (Iterator<Player> it = players.iterator(); it.hasNext();) {
Player p = it.next();
if (p == player || !p.getSettings().isAcceptAid() || !p.isActive() || p.getSkills().getLifepoints() == p.getSkills().getMaximumLifepoints()) {
if (p.getName() == player.getName() || !p.getSettings().isAcceptAid() || !p.isActive() || p.getSkills().getLifepoints() == p.getSkills().getMaximumLifepoints()) {
it.remove();
}
}

View file

@ -497,16 +497,16 @@ class LunarListeners : SpellListener("lunar"), Commands {
removeRunes(player, true)
visualizeSpell(player, Animations.LUNAR_SPELLBOOK_CURE_GROUP_4409, Graphics.LUNAR_SPELLBOOK_CURE_GROUP_744, 130, Sounds.LUNAR_CURE_GROUP_2882)
curePoison(player)
for(acct in RegionManager.getLocalPlayers(player, 1)) {
if(!acct.isActive || acct.locks.isInteractionLocked) {
for (player in RegionManager.getLocalPlayers(player.location, 1)) {
if (!player.isActive || player.locks.isInteractionLocked) {
continue
}
if(!acct.settings.isAcceptAid) {
if (!player.settings.isAcceptAid) {
continue
}
curePoison(acct)
sendMessage(acct, "You have been cured of poison.")
visualizeSpell(acct, -1, Graphics.LUNAR_SPELLBOOK_CURE_GROUP_744, 130, Sounds.LUNAR_CURE_OTHER_INDIVIDUAL_2889)
curePoison(player)
sendMessage(player, "You have been cured of poison.")
visualizeSpell(player, -1, Graphics.LUNAR_SPELLBOOK_CURE_GROUP_744, 130, Sounds.LUNAR_CURE_OTHER_INDIVIDUAL_2889)
}
addXP(player, 74.0)
}
@ -818,12 +818,12 @@ class LunarListeners : SpellListener("lunar"), Commands {
}
private fun sendGroupTeleport(player: Player, xp: Double, destName: String, loc: Location){
RegionManager.getLocalPlayers(player, 1).forEach {
if(it == player) return@forEach
if(it.isTeleBlocked) return@forEach
if(!it.isActive) return@forEach
if(!it.settings.isAcceptAid) return@forEach
if(it.ironmanManager.isIronman) return@forEach
RegionManager.getLocalPlayers(player.location, 1).forEach {
if (it.name == player.name) return@forEach
if (it.isTeleBlocked) return@forEach
if (!it.isActive) return@forEach
if (!it.settings.isAcceptAid) return@forEach
if (it.ironmanManager.isIronman) return@forEach
setAttribute(it, "t-o_location", loc)
openInterface(it, Components.TELEPORT_OTHER_326)
setInterfaceText(it, player.username, Components.TELEPORT_OTHER_326, 1)

View file

@ -12,6 +12,7 @@ import core.game.bots.AIPlayer;
import core.game.node.entity.player.link.SpellBookManager.SpellBook;
import core.game.node.item.Item;
import core.game.world.map.RegionManager;
import core.game.world.repository.Repository;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.plugin.Initializable;
@ -52,19 +53,17 @@ public final class StatBoostSpell extends MagicSpell {
player.getPacketDispatch().sendMessage("You can't cast this spell on that item.");
return false;
}
List<Player> pl = RegionManager.getLocalPlayers(player, 1);
int plSize = pl.size() - 1;
List<Player> pl = RegionManager.getLocalPlayers(player.getLocation(), 1);
int doses = potion.getDose(item);
if (pl.size() == 0) {
if (pl.isEmpty()) {
return false;
}
if (!super.meetsRequirements(player, true, false)) {
return false;
}
int size = 0;
for (Player players : pl) {
Player o = (Player) players;
if (size >= doses) break;
for (Player o : pl) {
if (size >= doses) break;
if (!o.isActive() || o.getLocks().isInteractionLocked() || o == player) {
continue;
}
@ -86,11 +85,11 @@ public final class StatBoostSpell extends MagicSpell {
player.animate(ANIMATION);
player.graphics(GRAPHICS);
player.getInventory().remove(item);
int newIndex = (potion.getIds().length - doses) + size;
if (newIndex > potion.getIds().length - 1) {
player.getInventory().add(new Item(229));
return true;
}
int newIndex = (potion.getIds().length - doses) + size;
if (newIndex > potion.getIds().length - 1) {
player.getInventory().add(new Item(229));
return true;
}
player.getInventory().add(new Item(potion.getIds()[newIndex]));
return true;
}

View file

@ -2,6 +2,7 @@ package content.global.skill.magic.lunar;
import content.data.consumables.Consumables;
import core.game.consumable.Potion;
import core.game.world.repository.Repository;
import core.plugin.Initializable;
import core.game.node.entity.combat.spell.MagicSpell;
import core.game.node.entity.combat.spell.Runes;
@ -27,7 +28,7 @@ public class StatRestoreSpell extends MagicSpell {
private static final Animation ANIMATION = new Animation(4413);
private static final Graphics GRAPHICS = new Graphics(733, 130);
private static final Consumables[] acceptedPotions = new Consumables[] { Consumables.RESTORE, Consumables.SUPER_RESTO, Consumables.PRAYER, Consumables.ENERGY, Consumables.SUPER_ENERGY };
private static final Consumables[] acceptedPotions = new Consumables[] { Consumables.RESTORE, Consumables.SUPER_RESTO, Consumables.PRAYER, Consumables.ENERGY, Consumables.SUPER_ENERGY };
public StatRestoreSpell() {
super(SpellBook.LUNAR, 81, 84, null, null, null, new Item[] { new Item(Runes.ASTRAL_RUNE.getId(), 2), new Item(Runes.EARTH_RUNE.getId(), 10), new Item(Runes.WATER_RUNE.getId(), 10) });
@ -45,34 +46,32 @@ public class StatRestoreSpell extends MagicSpell {
Item item = ((Item) target);
player.getInterfaceManager().setViewedTab(6);
if (Consumables.getConsumableById(item.getId()) == null) {
player.getPacketDispatch().sendMessage("You can only cast this spell on a potion.");
return false;
}
if (Consumables.getConsumableById(item.getId()) == null) {
player.getPacketDispatch().sendMessage("You can only cast this spell on a potion.");
return false;
}
final Potion potion = (Potion) Consumables.getConsumableById(item.getId()).getConsumable();
if (potion == null) {
player.getPacketDispatch().sendMessage("You can only cast this spell on a potion.");
player.getPacketDispatch().sendMessage("You can only cast this spell on a potion.");
return false;
}
if (!item.getDefinition().isTradeable() || !isRestore(potion)) {
player.getPacketDispatch().sendMessage("You can't cast this spell on that item.");
return false;
}
List<Player> pl = RegionManager.getLocalPlayers(player, 2);
int plSize = pl.size() - 1;
List<Player> pl = RegionManager.getLocalPlayers(player.getLocation(), 2);
int doses = potion.getDose(item);
if (pl.size() == 0) {
if (pl.isEmpty()) {
return false;
}
if (!super.meetsRequirements(player, true, false)) {
return false;
}
int size = 0;
for (Player players : pl) {
if (size >= doses) break;
Player o = (Player) players;
for (Player o : pl) {
if (size >= doses) break;
if (!o.isActive() || o.getLocks().isInteractionLocked() || o == player) {
continue;
}
@ -93,20 +92,20 @@ public class StatRestoreSpell extends MagicSpell {
player.animate(ANIMATION);
player.graphics(GRAPHICS);
player.getInventory().remove(item);
int newIndex = (potion.getIds().length - doses) + size;
if (newIndex > potion.getIds().length - 1) {
player.getInventory().add(new Item(229));
return true;
}
int newIndex = (potion.getIds().length - doses) + size;
if (newIndex > potion.getIds().length - 1) {
player.getInventory().add(new Item(229));
return true;
}
player.getInventory().add(new Item(potion.getIds()[newIndex]));
return true;
}
private boolean isRestore(Potion p) {
for (int i = 0; i < acceptedPotions.length; i++) {
if (p == acceptedPotions[i].getConsumable())
return true;
}
for (int i = 0; i < acceptedPotions.length; i++) {
if (p == acceptedPotions[i].getConsumable())
return true;
}
return false;
}

View file

@ -152,9 +152,9 @@ public class ForgeRegentNPC extends Familiar {
familiar.moveStep();
GroundItemManager.destroy(ground);
player.getSkills().addExperience(Skills.FIREMAKING, log.getXp() + 10);
familiar.faceLocation(object.getFaceLocation(familiar.getLocation()));
familiar.faceLocation(object.getFaceLocation(familiar.getLocation()));
SceneryBuilder.add(object, log.getLife(), FireMakingPulse.getAsh(player, log, object));
if (player.getViewport().getRegion().getId() == 10806) {
if (player.getLocation().getRegionId() == 10806) {
player.getAchievementDiaryManager().finishTask(player, DiaryType.SEERS_VILLAGE, 1, 9);
}
return true;

View file

@ -56,7 +56,7 @@ public class GiantChinchompaNPC extends Familiar {
if (!isOwnerAttackable()) {
return false;
}
final List<Entity> entitys = RegionManager.getLocalEntitys(owner, 6);
final List<Entity> entitys = RegionManager.getLocalEntities(owner.getLocation(), 6);
entitys.remove(owner);
entitys.remove(this);
sendChat("Squeak!");

View file

@ -133,7 +133,7 @@ public class PyreLordNPC extends Familiar {
player.getSkills().addExperience(Skills.FIREMAKING, log.getXp() + 10);
familiar.faceLocation(object.getFaceLocation(familiar.getLocation()));
SceneryBuilder.add(object, log.getLife(), FireMakingPulse.getAsh(player, log, object));
if (player.getViewport().getRegion().getId() == 10806) {
if (player.getLocation().getRegionId() == 10806) {
player.getAchievementDiaryManager().finishTask(player, DiaryType.SEERS_VILLAGE, 1, 9);
}
return true;

View file

@ -70,7 +70,7 @@ public class SmokeDevilNPC extends Familiar {
if (!isOwnerAttackable()) {
return false;
}
final List<Entity> entitys = RegionManager.getLocalEntitys(this, 1);
final List<Entity> entitys = RegionManager.getLocalEntities(location, 1);
entitys.remove(this);
entitys.remove(owner);
visualize(Animation.create(7820), Graphics.create(1375));

View file

@ -41,7 +41,7 @@ public class SpiritTzKihNPC extends Familiar {
@Override
protected boolean specialMove(FamiliarSpecial special) {
final List<Entity> entitys = RegionManager.getLocalEntitys(owner, 8);
final List<Entity> entitys = RegionManager.getLocalEntities(owner.getLocation(), 8);
if (entitys.size() == 0) {
return false;
}

View file

@ -72,7 +72,7 @@ public final class KittenInteractDialogue extends DialoguePlugin {
player.sendChat("Go on puss...kill that rat!");
boolean cant = true;
NPC rat = null;
for (NPC n : RegionManager.getLocalNpcs(player.getLocation(), 10)) {
for (NPC n : RegionManager.getLocalNPCs(player.getLocation(), 10)) {
if (!n.getName().contains("rat")) {
cant = false;
continue;

View file

@ -115,7 +115,7 @@ public final class StallThiefPulse extends SkillPulse<Scenery> {
SceneryBuilder.replace(node, node.transform(stall.getEmpty(node.getId())), stall.getDelay());
}
final Item item = stall.getRandomLoot();
player.getInventory().add(item);
player.getInventory().add(item);
player.getSkills().addExperience(Skills.THIEVING, stall.getExperience(), true);
if (item.getId() == 1987) {
player.getPacketDispatch().sendMessage("You steal grapes from the grape stall.");
@ -135,9 +135,9 @@ public final class StallThiefPulse extends SkillPulse<Scenery> {
if(stall == Stall.CANDLES) {
return;
}
if (type == 0) {
player.getPacketDispatch().sendMessage("You attempt to steal some " + stall.msgItem + " from the " + stall.name().toLowerCase().replace('_', ' '));
}
if (type == 0) {
player.getPacketDispatch().sendMessage("You attempt to steal some " + stall.msgItem + " from the " + stall.name().toLowerCase().replace('_', ' '));
}
}
/**
@ -156,7 +156,7 @@ public final class StallThiefPulse extends SkillPulse<Scenery> {
player.sendMessage("A higher power smites you");
return false;
}
for (NPC npc : RegionManager.getLocalNpcs(player.getLocation(), 8)) {
for (NPC npc : RegionManager.getLocalNPCs(player.getLocation(), 8)) {
if (!npc.getProperties().getCombatPulse().isAttacking() && (npc.getId() == 32 || npc.getId() == 2236)) {
npc.sendChat("Hey! Get your hands off there!");
npc.getProperties().getCombatPulse().attack(player);

View file

@ -19,8 +19,11 @@ import content.global.skill.summoning.familiar.Familiar;
import core.game.node.scenery.Scenery;
import core.game.system.task.Pulse;
import core.game.world.map.Location;
import core.game.world.map.Region;
import core.game.world.map.RegionChunk;
import core.game.world.map.RegionManager;
import core.game.world.map.zone.ZoneBorders;
import core.game.world.repository.Repository;
import core.game.world.update.flag.context.Graphics;
import core.net.packet.PacketRepository;
import core.net.packet.context.CameraContext;
@ -32,6 +35,7 @@ import core.plugin.Initializable;
import core.tools.RandomFunction;
import core.game.world.GameWorld;
import core.plugin.ClassScanner;
import org.jetbrains.annotations.NotNull;
import java.util.stream.IntStream;
@ -84,37 +88,41 @@ public final class BarrowsActivityPlugin extends ActivityPlugin {
@Override
public boolean pulse() {
boolean end = true;
for (Player p : RegionManager.getRegionPlayers(14231)) {
end = false;
int index = p.getAttribute("barrow:drain-index", -1);
if (index > -1) {
p.removeAttribute("barrow:drain-index");
p.getPacketDispatch().sendItemOnInterface(-1, 1, 24, index);
continue;
}
if (p.getLocation().getZ() == 0 && p.getAttribute("barrow:looted", false) && getWorldTicks() % 3 == 0) {
if (RandomFunction.random(15) == 0) {
p.getImpactHandler().manualHit(p, RandomFunction.random(5), HitsplatType.NORMAL);
Graphics.send(Graphics.create(405), p.getLocation());
Region region = RegionManager.forId(14231);
Region.load(region);
for (int z = 0; z < 4; z++) {
for (Player p : region.assemblePlayerList(z)) {
end = false;
int index = p.getAttribute("barrow:drain-index", -1);
if (index > -1) {
p.removeAttribute("barrow:drain-index");
p.getPacketDispatch().sendItemOnInterface(-1, 1, 24, index);
continue;
}
}
int drain = 8;
if (p.getLocation().getZ() == 0 && p.getAttribute("barrow:looted", false) && getWorldTicks() % 3 == 0) {
if (RandomFunction.random(15) == 0) {
p.getImpactHandler().manualHit(p, RandomFunction.random(5), HitsplatType.NORMAL);
Graphics.send(Graphics.create(405), p.getLocation());
}
}
int drain = 8;
//if (p.getLocks().isLocked("barrow:drain") || RandomFunction.random(100) % 2 == 0) {
// continue;
//}
for (boolean killed : p.getSavedData().getActivityData().getBarrowBrothers()) {
if (killed) {
drain += 1;
//if (p.getLocks().isLocked("barrow:drain") || RandomFunction.random(100) % 2 == 0) {
// continue;
//}
for (boolean killed : p.getSavedData().getActivityData().getBarrowBrothers()) {
if (killed) {
drain += 1;
}
}
if (getWorldTicks() % 30 == 0) {
p.getSkills().decrementPrayerPoints(drain);
p.getLocks().lock("barrow:drain", (3 + RandomFunction.random(15)) * 3);
index = 1 + RandomFunction.random(6);
p.setAttribute("barrow:drain-index", index);
p.getPacketDispatch().sendItemZoomOnInterface(4761 + RandomFunction.random(12), 100, 24, index);
p.getPacketDispatch().sendAnimationInterface(9810, 24, index);
}
}
if(getWorldTicks() % 30 == 0){
p.getSkills().decrementPrayerPoints(drain);
p.getLocks().lock("barrow:drain", (3 + RandomFunction.random(15)) * 3);
index = 1 + RandomFunction.random(6);
p.setAttribute("barrow:drain-index", index);
p.getPacketDispatch().sendItemZoomOnInterface(4761 + RandomFunction.random(12), 100, 24, index);
p.getPacketDispatch().sendAnimationInterface(9810, 24, index);
}
}
return end;
@ -130,7 +138,7 @@ public final class BarrowsActivityPlugin extends ActivityPlugin {
@Override
public void locationUpdate(Entity e, Location last) {
if (e instanceof Player && e.getViewport().getRegion().getId() == 14231) {
if (e instanceof Player && e.getLocation().getRegionId() == 14231) {
boolean tunnel = false;
for (ZoneBorders border : MINI_TUNNELS) {
if (border.insideBorder(e)) {
@ -140,7 +148,7 @@ public final class BarrowsActivityPlugin extends ActivityPlugin {
}
Player player = (Player) e;
if ((getVarp(player, 1270) == 1) != tunnel) {
setVarp(player, 1270, tunnel ? 3 : 0, true);
setVarp(player, 1270, tunnel ? 3 : 0, true);
}
}
}
@ -213,7 +221,7 @@ public final class BarrowsActivityPlugin extends ActivityPlugin {
public static void shuffleCatacombs(Player player) {
int value = TUNNEL_CONFIGS[RandomFunction.random(TUNNEL_CONFIGS.length)];
value |= 1 << (6 + RandomFunction.random(4));
setVarp(player, 452, value);
setVarp(player, 452, value);
}
@Override
@ -293,10 +301,10 @@ public final class BarrowsActivityPlugin extends ActivityPlugin {
return true;
case 6774:
player.lock(1);
int brother = player.getSavedData().getActivityData().getBarrowTunnelIndex();
if (!player.getSavedData().getActivityData().getBarrowBrothers()[brother] && !player.getAttribute("brother:" + brother, false)) {
BarrowsCrypt.getCrypt(brother).spawnBrother(player, RegionManager.getTeleportLocation(target.getCenterLocation(), 4));
}
int brother = player.getSavedData().getActivityData().getBarrowTunnelIndex();
if (!player.getSavedData().getActivityData().getBarrowBrothers()[brother] && !player.getAttribute("brother:" + brother, false)) {
BarrowsCrypt.getCrypt(brother).spawnBrother(player, RegionManager.getTeleportLocation(target.getCenterLocation(), 4));
}
player.setAttribute("barrow:opened_chest", true);
sendConfiguration(player);
return true;
@ -335,7 +343,7 @@ public final class BarrowsActivityPlugin extends ActivityPlugin {
if (player.getAttribute("barrow:opened_chest", false)) {
config |= 1 << 16;
}
setVarp(player, 453, config);
setVarp(player, 453, config);
}
@Override

View file

@ -100,8 +100,9 @@ public final class TelekineticGrabSpell extends MagicSpell {
@Override
public boolean cast(final Entity entity, final Node target) {
if (!(target instanceof GroundItem))
return false;
if (!(target instanceof GroundItem)) {
return false;
}
final GroundItem ground = (GroundItem) target;
if (!canCast(entity, ground)) {
return false;
@ -131,32 +132,34 @@ public final class TelekineticGrabSpell extends MagicSpell {
Player player = entity instanceof Player ? (Player) entity : null;
GroundItem g = GroundItemManager.get(ground.getId(), ground.getLocation(), player);
if (g == null) {
player.getPacketDispatch().sendMessage("Too late!");
if (player != null) {
player.getPacketDispatch().sendMessage("Too late!");
}
return true;
}
if (g == SpecialGroundItems.AHAB_BEER.asGroundItem()){
player.getDialogueInterpreter().open(2692, new NPC(2692), true);
if (g == SpecialGroundItems.AHAB_BEER.asGroundItem()) {
if (player != null) {
player.getDialogueInterpreter().open(2692, new NPC(2692), true);
}
return true;
}
if (player == null) {
return true;
}
boolean teleZone = player.getZoneMonitor().isInZone("Telekinetic Theatre") && g.getId() == 6888;
if (player != null) {
if (g == null || !g.isActive()) {
player.getPacketDispatch().sendMessage("Too late!");
return true;
}
playAudio(player, Sounds.VULNERABILITY_IMPACT_3008);
if (!teleZone) {
player.getInventory().add(new Item(g.getId(), g.getAmount(), g.getCharge()));
} else {
TelekineticZone zone = TelekineticZone.getZone(player);
zone.moveStatue();
player.lock(getDelay());
}
player.getPacketDispatch().sendPositionedGraphics(END_GRAPHIC, ground.getLocation());
if (!g.isActive()) {
player.getPacketDispatch().sendMessage("Too late!");
return true;
}
playAudio(player, Sounds.VULNERABILITY_IMPACT_3008);
if (!teleZone) {
player.getInventory().add(new Item(g.getId(), g.getAmount(), g.getCharge()));
} else {
TelekineticZone zone = TelekineticZone.getZone(player);
zone.moveStatue();
player.lock(getDelay());
}
player.getPacketDispatch().sendPositionedGraphics(END_GRAPHIC, ground.getLocation());
if (!teleZone) {
GroundItemManager.destroy(g);
}

View file

@ -140,7 +140,7 @@ public final class PCObjectHandler extends OptionHandler {
handleTurretTower(player, session, object);
return true;
}
if (!object.isActive() || !session.getBarricades().contains(object)) {
if (!object.isActive() || (getObjectType(object.getId()) == 9 && !session.getBarricades().contains(object))) {
return true;
}
if (option.equals("repair")) { // Handle barricades
@ -229,16 +229,15 @@ public final class PCObjectHandler extends OptionHandler {
int dir = open ? object.getRotation() : rotation;
Direction direction = Direction.get(!open ? dir : ((3 + dir) % 4));
if (session.getBarricades().contains(object) && session.getBarricades().contains(second)) {
session.getBarricades().remove(object);
session.getBarricades().remove(second);
Location l = object.getLocation().transform(direction.getStepX(), direction.getStepY(), 0);
Scenery replacement = new Scenery(object.getId() + (open ? 1 : -1), l, 0, open ? rotation : ((direction.toInteger() + 3) % 4));
session.getBarricades().remove(object);
SceneryBuilder.replace(object, replacement);
session.getBarricades().add(replacement);
l = second.getLocation().transform(direction.getStepX(), direction.getStepY(), 0);
replacement = new Scenery(second.getId() + (open ? 1 : -1), l, 0, open ? getRotation(second) : ((direction.toInteger() + 3) % 4));
session.getBarricades().remove(second);
SceneryBuilder.replace(second, replacement);
session.getBarricades().add(replacement);
}
@ -295,7 +294,7 @@ public final class PCObjectHandler extends OptionHandler {
* @param objectId The object id.
* @return The object type.
*/
private static int getObjectType(int objectId) {
static int getObjectType(int objectId) {
if (objectId == 14225 || objectId == 14226 || objectId == 14228 || objectId == 14229) {
return 9;
}

View file

@ -8,12 +8,9 @@ import core.game.node.entity.combat.BattleState;
import core.game.node.entity.npc.AbstractNPC;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.world.map.Direction;
import core.game.world.map.Location;
import core.game.world.map.RegionPlane;
import core.game.world.map.*;
import core.game.world.update.flag.context.Animation;
import core.tools.RandomFunction;
import content.minigame.pestcontrol.monsters.PCRavagerNPC;
import content.minigame.pestcontrol.monsters.PCSpinnerNPC;
/**
@ -146,8 +143,8 @@ public final class PCPortalNPC extends AbstractNPC {
public void tick() {
super.tick();
if (session != null) {
RegionPlane plane = getViewport().getCurrentPlane();
if (plane != null && session.getTicks() % 35 - plane.getPlayers().size() == 0 && plane.getNpcs().size() < 100) {
Region region = RegionManager.forId(location.getRegionId());
if (session.getTicks() % 35 - region.assemblePlayerList(0).size() == 0 && region.assembleNpcList(0).size() < 100) {
spawnNPCs();
}
if (updateLifepoints && session.getTicks() % 10 == 0) {
@ -187,9 +184,7 @@ public final class PCPortalNPC extends AbstractNPC {
int index = getDifficultyIndex();
Random r = RandomFunction.RANDOM;
int amount = index + 1;
if (getViewport().getCurrentPlane() != null) {
amount += getViewport().getCurrentPlane().getPlayers().size() / 10;
}
amount += RegionManager.getLocalPlayers(location).size() / 10;
if (getDifficultyIndex() == 0) {
amount += ((getDifficultyIndex() + 1) * 3) / 2;
}

View file

@ -20,10 +20,12 @@ import core.game.node.item.Item;
import core.game.system.task.Pulse;
import core.game.world.GameWorld;
import core.game.world.map.Location;
import core.game.world.map.RegionChunk;
import core.game.world.map.build.DynamicRegion;
import core.game.world.map.zone.RegionZone;
import core.game.world.map.zone.ZoneBuilder;
import core.game.world.map.zone.ZoneRestriction;
import core.game.world.repository.Repository;
import core.plugin.Initializable;
import core.plugin.ClassScanner;
import core.tools.RandomFunction;
@ -125,40 +127,48 @@ public final class PestControlActivityPlugin extends ActivityPlugin {
if (!session.isActive()) {
return;
}
for (final Player p : session.getRegion().getPlanes()[0].getPlayers()) {
p.getProperties().setTeleportLocation(getLeaveLocation());
if (!success) {
p.getDialogueInterpreter().open(3781, true, 0, true);
// default,
// type,
// default
} else if (success && p.getAttribute("pc_zeal", 0) >= 50) {
int amount = type.ordinal() + 2;
p.getSavedData().getActivityData().increasePestPoints(amount);
Item coins = new Item(995, p.getProperties().getCurrentCombatLevel() * 10);
if (!p.getInventory().add(coins)) {
GroundItemManager.create(coins, p);
RegionChunk[][][] chunks = session.getRegion().getChunks();
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
for (int z = 0; z < 4; z++) {
RegionChunk chunk = chunks[x][y][z];
for (Player p : chunk.getPlayers()) {
p.getProperties().setTeleportLocation(getLeaveLocation());
if (!success) {
p.getDialogueInterpreter().open(3781, true, 0, true);
// default,
// type,
// default
} else if (p.getAttribute("pc_zeal", 0) >= 50) {
int amount = type.ordinal() + 2;
p.getSavedData().getActivityData().increasePestPoints(amount);
Item coins = new Item(995, p.getProperties().getCurrentCombatLevel() * 10);
if (!p.getInventory().add(coins)) {
GroundItemManager.create(coins, p);
}
// default, type, name
p.getDialogueInterpreter().open(3781, true, 1, type.ordinal() == 0 ? "two" : type.ordinal() == 1 ? "three" : "four");
} else {
// default type, default
p.getDialogueInterpreter().open(3781, true, 2, true);
}
p.removeAttribute("pc_zeal");
p.removeExtension(PestControlSession.class);
p.fullRestore();
if (isPoisoned(p)) {
curePoison(p);
}
PulseManager.cancelDeathTask(p);
GameWorld.getPulser().submit(new Pulse(1, p) {
@Override
public boolean pulse() {
p.getSkills().restore();
return true;
}
});
}
}
// default, type, name
p.getDialogueInterpreter().open(3781, true, 1, type.ordinal() == 0 ? "two" : type.ordinal() == 1 ? "three" : "four");
} else {
// default type, default
p.getDialogueInterpreter().open(3781, true, 2, true);
}
p.removeAttribute("pc_zeal");
p.removeExtension(PestControlSession.class);
p.fullRestore();
if (isPoisoned(p)) {
curePoison(p);
}
PulseManager.cancelDeathTask(p);
GameWorld.getPulser().submit(new Pulse(1, p) {
@Override
public boolean pulse() {
p.getSkills().restore();
return true;
}
});
}
session.getRegion().getRegionZones().clear();
session.setActive(false);
@ -293,7 +303,7 @@ public final class PestControlActivityPlugin extends ActivityPlugin {
@Override
public boolean death(Entity e, Entity killer) {
if (e instanceof Player && e.getViewport().getRegion().getRegionId() == 10536) {
if (e instanceof Player && e.getLocation().getRegion().getRegionId() == 10536) {
PestControlSession session = e.getExtension(PestControlSession.class);
if (session != null) {
Location l = session.getRegion().getBaseLocation();

View file

@ -8,8 +8,6 @@ import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.node.scenery.Scenery;
import core.game.world.map.Location;
import core.game.world.map.Point;
import core.game.world.map.RegionPlane;
import core.game.world.map.build.DynamicRegion;
import core.tools.RandomFunction;
@ -21,12 +19,6 @@ import static core.api.ContentAPIKt.*;
* @author Emperor
*/
public final class PestControlSession {
/**
* The barricade object offsets.
*/
private static final Point[] OBJECT_OFFSETS = { new Point(46, 33), new Point(46, 32), new Point(32, 25), new Point(33, 25), new Point(19, 32), new Point(19, 33), new Point(49, 33), new Point(49, 32), new Point(49, 31), new Point(49, 30), new Point(52, 27), new Point(52, 26), new Point(52, 25), new Point(52, 24), new Point(52, 14), new Point(52, 13), new Point(52, 12), new Point(52, 11), new Point(42, 18), new Point(43, 18), new Point(44, 18), new Point(45, 18), new Point(32, 15), new Point(33, 15), new Point(34, 15), new Point(35, 15), new Point(23, 18), new Point(24, 18), new Point(25, 18), new Point(26, 18), new Point(13, 11), new Point(13, 12), new Point(13, 13), new Point(13, 14), new Point(12, 28), new Point(12, 29), new Point(12, 30), new Point(12, 31), };
/**
* The object ids of non-attackable barricades/gates.
*/
@ -123,7 +115,7 @@ public final class PestControlSession {
* @param message The message to send.
*/
public void sendMessage(String message) {
for (Player p : region.getPlanes()[0].getPlayers()) {
for (Player p : region.assemblePlayerList(0)) {
if (p.isActive()) {
p.getPacketDispatch().sendMessage(message);
}
@ -136,7 +128,7 @@ public final class PestControlSession {
* @param child The child id.
*/
public void sendString(String message, int child) {
for (Player p : region.getPlanes()[0].getPlayers()) {
for (Player p : region.assemblePlayerList(0)) {
if (p.isActive()) {
p.getPacketDispatch().sendString(message, 408, child);
}
@ -164,9 +156,9 @@ public final class PestControlSession {
* @param value The message value to send.
*/
public void sendConfig(int value) {
for (Player p : region.getPlanes()[0].getPlayers()) {
for (Player p : region.assemblePlayerList(0)) {
if (p.isActive()) {
setVarp(p, 719, value);
setVarp(p, 719, value);
}
}
}
@ -191,7 +183,7 @@ public final class PestControlSession {
message = "The red, south-western portal shield has dropped!";
break;
}
for (Player p : region.getPlanes()[0].getPlayers()) {
for (Player p : region.assemblePlayerList(0)) {
if (p.isActive()) {
p.getPacketDispatch().sendInterfaceConfig(408, 18 + (index << 1), true);
p.getPacketDispatch().sendMessage(message);
@ -233,8 +225,7 @@ public final class PestControlSession {
}
}
for (Player p : remainingPlayers)
{
for (Player p : remainingPlayers) {
int priority = p.getAttribute("pc_prior", 0) + 1;
p.getPacketDispatch().sendMessage("You have been given priority level " + priority + " over other players in joining the next");
p.getPacketDispatch().sendMessage("game.");
@ -264,7 +255,7 @@ public final class PestControlSession {
Random r = RandomFunction.RANDOM;
Location l = region.getBaseLocation();
p.getProperties().setTeleportLocation(l.transform(32 + r.nextInt(4), 49 + r.nextInt(6), 0));
setVarp(p, 1147, 0);
setVarp(p, 1147, 0);
p.getDialogueInterpreter().sendDialogues(3781, FacialExpression.FURIOUS, "You must defend the Void Knight while the portals are", "unsummoned. The ritual takes twenty minutes though,", "so you can help out by destroying them yourselves!", "Now GO GO GO!");
}
@ -272,9 +263,17 @@ public final class PestControlSession {
* Initializes the barricades list.
*/
private void initBarricadesList() {
RegionPlane p = region.getPlanes()[0];
for (Point point : OBJECT_OFFSETS) {
barricades.add(p.getObjects()[point.getX()][point.getY()]);
for (int chunkX = 0; chunkX < 8; chunkX++) {
for (int chunkY = 0; chunkY < 8; chunkY++) {
List<Scenery> objects = region.getChunks()[chunkX][chunkY][0].assembleObjectList();
for (Scenery object : objects) {
boolean isActualBarricade = PCObjectHandler.getObjectType(object.getId()) == 9;
boolean isGate = object.getId() > 14232;
if (isActualBarricade || isGate) {
barricades.add(object);
}
}
}
}
}
@ -385,5 +384,4 @@ public final class PestControlSession {
public List<Scenery> getBarricades() {
return barricades;
}
}

View file

@ -46,7 +46,7 @@ public class SquireDialogue extends DialoguePlugin {
interpreter.sendDialogues(3781, FacialExpression.HALF_GUILTY, "Congratulations! You managed to destroy all the portals!", "We've awarded you " + points + " Void Knight Commendation", "points. Please also accept these coins as a reward.");
stage = 100;
} else {// won and not awarded.
interpreter.sendDialogues(3781, FacialExpression.HALF_GUILTY, "Congratulations! You managed to destroy all the portals!", "However, you did not succeed in reaching the required", "amount of damage delt we cannot grant you a reward.");
interpreter.sendDialogues(3781, FacialExpression.HALF_GUILTY, "Congratulations! You managed to destroy all the portals!", "However, you did not succeed in reaching the required", "amount of damage dealt we cannot grant you a reward.");
stage = 101;
}
return true;

View file

@ -29,7 +29,7 @@ public final class VoidSealPlugin extends OptionHandler {
@Override
public boolean handle(Player player, Node node, String option) {
if (player.getViewport().getRegion().getRegionId() != 10536) {
if (player.getLocation().getRegionId() != 10536) {
player.getPacketDispatch().sendMessage("You can only use the seal in Pest Control.");
return true;
}
@ -48,7 +48,7 @@ public final class VoidSealPlugin extends OptionHandler {
player.getInventory().replace(replace, item.getSlot());
}
player.graphics(Graphics.create(1177));
for (NPC npc : RegionManager.getLocalNpcs(player, 2)) {
for (NPC npc : RegionManager.getLocalNPCs(player.getLocation(), 2)) {
if (canTarget(npc)) {
npc.getImpactHandler().manualHit(player, 7 + RandomFunction.randomize(5), HitsplatType.NORMAL, 1);
npc.graphics(Graphics.create(1176));

View file

@ -7,8 +7,6 @@ import core.game.world.map.Location
import core.game.world.map.RegionManager
import core.game.world.map.path.Pathfinder
import core.tools.RandomFunction
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import content.minigame.pestcontrol.PestControlHelper.GATE_ENTRIES
import content.minigame.pestcontrol.PestControlHelper.getMyPestControlSession1
import core.game.world.GameWorld
@ -63,7 +61,7 @@ class CombatState(val bot: PestControlTestBot) {
if (portal != null) {
if(bot.location.withinDistance(portal.location,10) && portal.isActive){
val spinners = ArrayList<NPC>()
RegionManager.getLocalNpcs(bot).forEach {
RegionManager.getLocalNPCs(bot.location).forEach {
if(it.name.toLowerCase().equals("spinner") && it.location.withinDistance(bot.location,10)) spinners.add(it)
}
if(spinners.isNotEmpty()){

View file

@ -7,8 +7,6 @@ import core.game.world.map.Location
import core.game.world.map.RegionManager
import core.game.world.map.path.Pathfinder
import core.tools.RandomFunction
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import content.minigame.pestcontrol.PestControlHelper.GATE_ENTRIES
import content.minigame.pestcontrol.PestControlHelper.getMyPestControlSession2
import core.game.world.GameWorld
@ -62,7 +60,7 @@ class CombatStateIntermediate(val bot: PestControlTestBot2) {
if (portal != null) {
if(bot.location.withinDistance(portal.location,10) && portal.isActive){
val spinners = ArrayList<NPC>()
RegionManager.getLocalNpcs(bot).forEach {
RegionManager.getLocalNPCs(bot.location).forEach {
if(it.name.toLowerCase().equals("spinner") && it.location.withinDistance(bot.location,10)) spinners.add(it)
}
if(spinners.isNotEmpty()){

View file

@ -114,7 +114,7 @@ public class PCRavagerNPC extends AbstractNPC {
GameWorld.getPulser().submit(new Pulse(1, this, o) {
@Override
public boolean pulse() {
if (getViewport().getRegion().isActive() && session.getBarricades().remove(o)) {
if (getLocation().getRegion().isActive() && session.getBarricades().remove(o)) {
session.getBarricades().add(newTarget);
SceneryBuilder.replace(o, newTarget);
}
@ -173,10 +173,10 @@ public class PCRavagerNPC extends AbstractNPC {
return true;
}
@Override
public boolean shouldPreventStacking(Entity mover) {
return mover instanceof NPC;
}
@Override
public boolean shouldPreventStacking(Entity mover) {
return mover instanceof NPC;
}
@Override
public void onImpact(final Entity entity, BattleState state) {

View file

@ -15,6 +15,7 @@ import core.game.system.task.Pulse;
import core.game.world.GameWorld;
import core.game.world.map.Location;
import core.game.world.map.RegionManager;
import core.game.world.repository.Repository;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.tools.RandomFunction;
@ -100,9 +101,9 @@ public final class PCSpinnerNPC extends AbstractNPC {
*/
public void explode() {
animate(getProperties().getDeathAnimation());
for (Player p : RegionManager.getLocalPlayers(this, 1)) {
for (Player p : RegionManager.getLocalPlayers(location, 1)) {
p.getImpactHandler().manualHit(this, 5, HitsplatType.POISON);
applyPoison(p, this, 1);
applyPoison(p, this, 1);
}
GameWorld.getPulser().submit(new Pulse(1, this) {
@Override

View file

@ -75,10 +75,10 @@ public final class PCSplatterNPC extends AbstractNPC {
}
}
@Override
public boolean shouldPreventStacking(Entity mover) {
return mover instanceof NPC;
}
@Override
public boolean shouldPreventStacking(Entity mover) {
return mover instanceof NPC;
}
@Override
public void onImpact(final Entity entity, BattleState state) {
@ -132,10 +132,10 @@ public final class PCSplatterNPC extends AbstractNPC {
}
}
}
for (Player p : RegionManager.getLocalPlayers(this, 1)) {
for (Player p : RegionManager.getLocalPlayers(location, 1)) {
p.getImpactHandler().manualHit(this, RandomFunction.random(minimum, maximum), null);
}
for (NPC npc : RegionManager.getLocalNpcs(this, 1)) {
for (NPC npc : RegionManager.getLocalNPCs(location, 1)) {
if (npc != this) {
npc.getImpactHandler().manualHit(this, RandomFunction.random(minimum, maximum), null);
}

View file

@ -11,6 +11,7 @@ import core.game.world.map.zone.ZoneBorders
import core.game.world.map.RegionManager
import core.game.system.task.Pulse
import content.global.skill.hunter.bnet.BNetTypes
import core.game.world.repository.Repository
import org.rs09.consts.Items
@ -27,7 +28,7 @@ class ImpDefenderBehavior : NPCBehavior(6074) {
var nextCaptureTick = getAttribute(self, "next-capture-tick", 0)
if (getWorldTicks() < nextCaptureTick) return true
var players = RegionManager.getLocalPlayers(self, 2)
var players = RegionManager.getLocalPlayers(self.location, 2)
for (player in players) {
var lowestTierImpling = BNetTypes.getImpling(player)
if (lowestTierImpling == null) continue

View file

@ -1,7 +1,5 @@
package content.minigame.sorceress;
import java.util.List;
import core.game.component.Component;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.CombatSwingHandler;
@ -12,6 +10,8 @@ import core.game.system.task.Pulse;
import core.game.world.GameWorld;
import core.game.world.map.Direction;
import core.game.world.map.Location;
import core.game.world.map.RegionManager;
import core.game.world.repository.Repository;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.net.packet.PacketRepository;
@ -194,20 +194,11 @@ public final class SorceressElementalNPC extends AbstractNPC {
return respawn;
}
/**
* Gets the tilesIndex.
* @return The tilesIndex.
*/
public int getTilesIndex() {
return tilesIndex;
}
@Override
public void tick() {
super.tick();
List<Player> players = getViewport().getCurrentPlane().getPlayers();
for (Player player : players) {
if (player == null || !player.isActive() || player.getLocks().isInteractionLocked() || DeathTask.isDead(player) || !canTeleport(player) || !CombatSwingHandler.isProjectileClipped(this, player, false)) {
for (Player player : RegionManager.getLocalPlayers(location)) {
if (!player.isActive() || player.getLocks().isInteractionLocked() || DeathTask.isDead(player) || !canTeleport(player) || !CombatSwingHandler.isProjectileClipped(this, player, false)) {
continue;
}
animate(new Animation(5803));

View file

@ -1,8 +1,6 @@
package content.minigame.vinesweeper
import BlinkinDialogue
import FarmerDialogue.Companion.FARMER_FLAG_LINES
import WinkinDialogue
import content.minigame.vinesweeper.FarmerDialogue.Companion.FARMER_FLAG_LINES
import content.minigame.vinesweeper.Vinesweeper.Companion.FARMERS
import content.minigame.vinesweeper.Vinesweeper.Companion.FARMER_CLEAR_RADIUS
import content.minigame.vinesweeper.Vinesweeper.Companion.HOLES
@ -492,10 +490,10 @@ class Vinesweeper : InteractionListener, InterfaceListener, MapArea {
dest.player.incrementAttribute("/save:vinesweeper:points", points)
dest.player.inventory.add(Item(Items.FLAG_12625, 1))
sendUpdatedPoints(dest.player)
for (neighbor in RegionManager.getLocalPlayers(npc)) {
if (neighbor != dest.player) {
neighbor.incrementAttribute("/save:vinesweeper:points", points / 2)
sendUpdatedPoints(neighbor)
for (player in RegionManager.getLocalPlayers(npc.location)) {
if (player.name != dest.player.name) {
player.incrementAttribute("/save:vinesweeper:points", points / 2)
sendUpdatedPoints(player)
}
}
}
@ -572,21 +570,23 @@ class VinesweeperNPC : AbstractNPC {
}
override fun handleTickActions() {
val dest = seedDestinations.find { sd -> sd.loc == location }
if (locks.isMovementLocked() || locks.isInteractionLocked())
if (locks.isMovementLocked || locks.isInteractionLocked)
return
if(dest != null) {
for(npc in RegionManager.getRegionPlane(location).npcs) {
if(npc is VinesweeperNPC) {
npc.seedDestinations.remove(dest)
npc.resetWalk()
if (dest != null) {
val npcs = location.region.assembleNpcList(0)
for (npc in npcs) {
if (npc !is VinesweeperNPC || npc.seedDestinations.isEmpty() /*npc is not currently walking towards a seed*/) {
continue
}
npc.seedDestinations.remove(dest)
npc.resetWalk()
}
val scenery = getScenery(dest.loc)
if(scenery != null) {
if(id in RABBITS) {
if (scenery != null) {
if (id in RABBITS) {
handleRabbitSeed(scenery, dest)
} else {
if(dest.alive) {
if (dest.alive) {
handleFarmerFlag(scenery, dest)
} else {
handleFarmerSeed(scenery, dest)
@ -653,13 +653,13 @@ class VinesweeperNPC : AbstractNPC {
animate(Animation(Animations.GNOME_FARMER_DIG_FLAG_8725))
GameWorld.Pulser.submit(object: Pulse(3) {
override fun pulse(): Boolean {
when(i++) {
when (i++) {
0 -> {
sendChat(FARMER_FLAG_LINES.FIND_FLAG.line)
}
1 -> {
SceneryBuilder.replace(scenery, scenery.transform(HOLES[0]))
if(SEED_LOCS.contains(dest.loc)) {
if (SEED_LOCS.contains(dest.loc)) {
sendChat(FARMER_FLAG_LINES.FIND_SEED.line)
animate(Animation(Animations.GNOME_FARMER_HOORAY_8731))
sendPoints(npc,dest)

View file

@ -1,3 +1,5 @@
package content.minigame.vinesweeper
import core.game.component.Component
import core.game.node.item.GroundItemManager
import core.game.node.item.Item

View file

@ -126,7 +126,7 @@ public class BurthorpeTrainNPC extends AbstractNPC {
case 1061:// sergant
sendChat(MESSAGES[RandomFunction.random(MESSAGES.length)]);
delay = System.currentTimeMillis() + 9000 + RandomFunction.random(1000, 5000);
final List<NPC> soldiers = RegionManager.getLocalNpcs(this);
final List<NPC> soldiers = RegionManager.getLocalNPCs(location);
NPC soldier = null;
while (soldier == null) {
soldier = soldiers.get(RandomFunction.random(soldiers.size()));
@ -164,7 +164,7 @@ public class BurthorpeTrainNPC extends AbstractNPC {
GameWorld.getPulser().submit(new Pulse(2) {
@Override
public boolean pulse() {
final List<NPC> soldiers = RegionManager.getLocalNpcs(BurthorpeTrainNPC.this, 12);
final List<NPC> soldiers = RegionManager.getLocalNPCs(location, 12);
for (NPC n : soldiers) {
if (n.getId() != 1064) {
continue;

View file

@ -111,12 +111,18 @@ public final class DummyRoom extends OptionHandler {
setDelay(10);
timeStamp = GameWorld.getTicks();
dummy = RandomFunction.getRandomElement(Dummy.values());
SceneryBuilder.replace(RegionManager.getObject(dummy.getObject().getLocation()), dummy.getObject(), 11);
Scenery dummyObject = RegionManager.getObject(dummy.getObject().getLocation());
if (dummyObject != null) {
SceneryBuilder.replace(dummyObject, dummy.getObject(), 11);
}
activeDummy = true;
if (dummy == Dummy.CONTROLLED && controlled == null) {
Location l = Location.create(2860, 3551, 0);
controlled = new Scenery(dummy.getObject().getId(), l, 10, 1);
SceneryBuilder.replace(RegionManager.getObject(l), controlled, 11);
Scenery controlledObject = RegionManager.getObject(l);
if (controlledObject != null) {
SceneryBuilder.replace(controlledObject, controlled, 11);
}
}
return false;
}

View file

@ -143,7 +143,7 @@ class FaladorAchievementDiary : DiaryEventHookBase(DiaryType.FALADOR) {
)
override fun onInteracted(player: Player, event: InteractionEvent) {
when (player.viewport.region.id) {
when (player.location.regionId) {
12084 -> {
if (event.option == "burst" && event.target.id in PARTY_BALLOONS) {
finishTask(
@ -179,7 +179,7 @@ class FaladorAchievementDiary : DiaryEventHookBase(DiaryType.FALADOR) {
}
override fun onResourceProduced(player: Player, event: ResourceProducedEvent) {
when (player.viewport.region.id) {
when (player.location.regionId) {
11828 -> when (event.itemId) {
Items.YEW_LOGS_1515, Items.MAGIC_LOGS_1513 -> {
if (inBorders(player, PARK_TREE_PATCH_AREA)) {
@ -195,7 +195,7 @@ class FaladorAchievementDiary : DiaryEventHookBase(DiaryType.FALADOR) {
}
override fun onNpcKilled(player: Player, event: NPCKillEvent) {
when (player.viewport.region.id) {
when (player.location.regionId) {
11828 -> if (event.npc.id in PARK_DUCKS && inBorders(event.npc, PARK_POND_AREA)) {
finishTask(
player,

View file

@ -26,6 +26,7 @@ import core.game.world.map.Direction;
import core.game.world.map.Location;
import core.game.world.map.RegionManager;
import core.game.world.map.zone.impl.DarkZone;
import core.game.world.repository.Repository;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.net.packet.PacketRepository;

View file

@ -201,7 +201,7 @@ public class FortressGuardDialogue extends DialoguePlugin {
case 54:
end();
DoorActionHandler.handleAutowalkDoor(player, RegionManager.getObject(0, 3020, 3515));
List<NPC> npcs = RegionManager.getLocalNpcs(player);
List<NPC> npcs = RegionManager.getLocalNPCs(player.getLocation());
for (NPC npc : npcs) {
if (npc.getId() == 179) {
npc.getProperties().getCombatPulse().attack(player);

View file

@ -103,7 +103,7 @@ public final class GoblinVillageNPC extends AbstractNPC {
if (delay < System.currentTimeMillis() && !getProperties().getCombatPulse().isAttacking()) {
final int rand = RandomFunction.random(1, 4);
if (rand == 2) {
final List<NPC> surronding = RegionManager.getLocalNpcs(this, 10);
final List<NPC> surronding = RegionManager.getLocalNPCs(location, 10);
for (NPC n : surronding) {
if (n.getId() == getId()) {
continue;

View file

@ -3,14 +3,14 @@ package content.region.asgarnia.goblinvillage.handlers
import core.game.interaction.IntType
import core.game.interaction.InteractionListener
import core.game.node.entity.combat.DeathTask
import core.game.world.map.RegionManager.getLocalNpcs
import core.game.world.map.RegionManager.getLocalNPCs
import org.rs09.consts.Scenery
class GoblinVillagePopulationListener : InteractionListener{
override fun defineListeners() {
on(Scenery.SIGNPOST_31301, IntType.SCENERY, "read") { player, node ->
var population = 3 // This covers General Wartface, General Bentnoze and Grubfoot
val npcs = getLocalNpcs(player, 50) // This radius covers more than the goblin village.
val npcs = getLocalNPCs(player.location, 50) // This radius covers more than the goblin village.
// There should be 18 Goblins walking around.
// 10 are within the village walls where the generals are.
// 8 of them are fighting each other on the west of the path to the village.

View file

@ -15,7 +15,7 @@ class WineOfZamorakInteraction : InteractionListener {
PickupHandler.take(player, wine as GroundItem)
return@on true
}
val npcs = RegionManager.getLocalNpcs(player)
val npcs = RegionManager.getLocalNPCs(player.location)
for (n in npcs) {
if (n.id == 188) {
n.sendChat("Hands off zamorak's wine!")

View file

@ -53,7 +53,7 @@ public final class PetshopOwnerTaverly extends DialoguePlugin {
@Override
public boolean open(Object... args) {
if (args.length > 1) {
List<NPC> npcs = RegionManager.getLocalNpcs(player);
List<NPC> npcs = RegionManager.getLocalNPCs(player.getLocation());
for (NPC n : npcs) {
if (n.getId() == 6893) {
npc = n;

View file

@ -9,6 +9,8 @@ import core.game.system.task.Pulse;
import core.game.world.GameWorld;
import core.game.world.map.Direction;
import core.game.world.map.Location;
import core.game.world.map.RegionManager;
import core.game.world.repository.Repository;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.net.packet.PacketRepository;
@ -28,122 +30,122 @@ import java.util.List;
@Initializable
public class NoraTHaggNPC extends AbstractNPC {
boolean walkdir;
boolean walkdir;
public NoraTHaggNPC() {
super(896, Location.create(2904, 3463, 0));
}
private Location getRespawnLocation() {
return Location.create(2900, 3473, 0);
}
public NoraTHaggNPC() {
super(896, Location.create(2904, 3463, 0));
}
private Location getRespawnLocation() {
return Location.create(2900, 3473, 0);
}
private NoraTHaggNPC(int id, Location location) {
super(id, location);
}
private NoraTHaggNPC(int id, Location location) {
super(id, location);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
this.configure();
init();
return super.newInstance(arg);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
this.configure();
init();
return super.newInstance(arg);
}
private boolean canTeleport(Entity t) {
int playerX = t.getLocation().getX();
int npcX = getLocation().getX();
int[] sectors = { 2904, 2907, 2910, 2914, 2918, 2922, 2926, 2928 };
for (int i = 0; i < sectors.length -1; i++) {
if (npcX >= sectors[i] && npcX <= sectors[i+1] && playerX >= sectors[i] && playerX <= sectors[i+1]) {
if (playerX < npcX && getDirection() == Direction.WEST || playerX > npcX && getDirection() == Direction.EAST) {
return true;
}
if (playerX == npcX) {
return true;
}
}
}
return false;
}
private boolean canTeleport(Entity t) {
int playerX = t.getLocation().getX();
int npcX = getLocation().getX();
int[] sectors = { 2904, 2907, 2910, 2914, 2918, 2922, 2926, 2928 };
for (int i = 0; i < sectors.length -1; i++) {
if (npcX >= sectors[i] && npcX <= sectors[i+1] && playerX >= sectors[i] && playerX <= sectors[i+1]) {
if (playerX < npcX && getDirection() == Direction.WEST || playerX > npcX && getDirection() == Direction.EAST) {
return true;
}
if (playerX == npcX) {
return true;
}
}
}
return false;
}
@Override
public AbstractNPC construct(int id, Location location, Object... objects) {
return new NoraTHaggNPC(id, location);
}
@Override
public AbstractNPC construct(int id, Location location, Object... objects) {
return new NoraTHaggNPC(id, location);
}
@Override
public int[] getIds() {
return new int[] { 896 };
}
@Override
public int[] getIds() {
return new int[] { 896 };
}
@Override
public int getWalkRadius() {
return 50;
}
@Override
public int getWalkRadius() {
return 50;
}
public void configure() {
super.configure();
setWalks(false);
setPathBoundMovement(true);
}
public void configure() {
super.configure();
setWalks(false);
setPathBoundMovement(true);
}
private void sendTeleport(final Player player) {
player.lock();
GameWorld.getPulser().submit(new Pulse(1) {
int delay = 0;
private void sendTeleport(final Player player) {
player.lock();
GameWorld.getPulser().submit(new Pulse(1) {
int delay = 0;
@Override
public boolean pulse() {
if (delay == 0) {
face(player);
player.getInventory().remove(WitchsHousePlugin.BALL);
player.getInventory().remove(WitchsHousePlugin.KEY);
player.getInventory().remove(WitchsHousePlugin.DOOR_KEY);
sendChat("Stop! Thief!");
player.getPacketDispatch().sendMessage("You've been spotted by the witch.");
player.graphics(new Graphics(110, 100));
PacketRepository.send(MinimapState.class, new MinimapStateContext(player, 2));
} else if (delay == 2) {
sendChat("Klarata... Seppteno... Valkan!");
face(null);
} else if (delay == 4) {
player.getProperties().setTeleportLocation(Location.create(getRespawnLocation()));
PacketRepository.send(MinimapState.class, new MinimapStateContext(player, 0));
face(null);
player.unlock();
return true;
}
delay++;
return false;
}
});
}
@Override
public boolean pulse() {
if (delay == 0) {
face(player);
player.getInventory().remove(WitchsHousePlugin.BALL);
player.getInventory().remove(WitchsHousePlugin.KEY);
player.getInventory().remove(WitchsHousePlugin.DOOR_KEY);
sendChat("Stop! Thief!");
player.getPacketDispatch().sendMessage("You've been spotted by the witch.");
player.graphics(new Graphics(110, 100));
PacketRepository.send(MinimapState.class, new MinimapStateContext(player, 2));
} else if (delay == 2) {
sendChat("Klarata... Seppteno... Valkan!");
face(null);
} else if (delay == 4) {
player.getProperties().setTeleportLocation(Location.create(getRespawnLocation()));
PacketRepository.send(MinimapState.class, new MinimapStateContext(player, 0));
face(null);
player.unlock();
return true;
}
delay++;
return false;
}
});
}
@Override
public void tick() {
super.tick();
List<Player> players = getViewport().getCurrentPlane().getPlayers();
if(getLocation().getX() == 2930){
walkdir = false;
} else if(getLocation().getX() == 2904){
walkdir = true;
}
for (Player player : players) {
if (player == null || !player.isActive() || player.getLocks().isInteractionLocked() || DeathTask.isDead(player) || !canTeleport(player) || !CombatSwingHandler.isProjectileClipped(this, player, false)) {
continue;
}
animate(new Animation(5803));
sendTeleport(player);
player.getPacketDispatch().sendMessage("" + getLocation() + " matches? " + (getLocation().getX() == 2904));
}
if (location.getX() != 2930 && walkdir) {
this.getWalkingQueue().reset();
this.getWalkingQueue().addPath(location.getX() + 1,3463,true);
} else if (location.getX() != 2904 && !walkdir) {
this.getWalkingQueue().reset();
this.getWalkingQueue().addPath(location.getX() - 1,3463,true);
}
}
@Override
public void tick() {
super.tick();
List<Player> players = RegionManager.getLocalPlayers(location);
if(getLocation().getX() == 2930){
walkdir = false;
} else if(getLocation().getX() == 2904){
walkdir = true;
}
for (Player player : players) {
if (player == null || !player.isActive() || player.getLocks().isInteractionLocked() || DeathTask.isDead(player) || !canTeleport(player) || !CombatSwingHandler.isProjectileClipped(this, player, false)) {
continue;
}
animate(new Animation(5803));
sendTeleport(player);
player.getPacketDispatch().sendMessage("" + getLocation() + " matches? " + (getLocation().getX() == 2904));
}
if (location.getX() != 2930 && walkdir) {
this.getWalkingQueue().reset();
this.getWalkingQueue().addPath(location.getX() + 1,3463,true);
} else if (location.getX() != 2904 && !walkdir) {
this.getWalkingQueue().reset();
this.getWalkingQueue().addPath(location.getX() - 1,3463,true);
}
}
}

View file

@ -19,165 +19,165 @@ import core.plugin.Initializable;
@Initializable
public class WitchsExperimentNPC extends AbstractNPC {
private ExperimentType type;
private boolean commenced;
Player p;
private ExperimentType type;
private boolean commenced;
Player p;
public WitchsExperimentNPC() {
super(0, null);
}
public WitchsExperimentNPC() {
super(0, null);
}
WitchsExperimentNPC(int id, Location location, Player player) {
super(id, location);
this.setWalks(true);
this.setRespawn(false);
this.type = WitchsExperimentNPC.ExperimentType.forId(id);
p = player;
}
WitchsExperimentNPC(int id, Location location, Player player) {
super(id, location);
this.setWalks(true);
this.setRespawn(false);
this.type = WitchsExperimentNPC.ExperimentType.forId(id);
p = player;
}
@Override
public void handleTickActions() {
super.handleTickActions();
if(!p.isActive() || !RegionManager.getLocalPlayers(this).contains(p)){
p.removeAttribute("witchs-experiment:npc_spawned");
clear();
}
if (!getProperties().getCombatPulse().isAttacking()) {
getProperties().getCombatPulse().attack(p);
}
}
@Override
public void handleTickActions() {
super.handleTickActions();
if (!p.isActive() || !RegionManager.getLocalPlayers(location).contains(p)) {
p.removeAttribute("witchs-experiment:npc_spawned");
clear();
}
if (!getProperties().getCombatPulse().isAttacking()) {
getProperties().getCombatPulse().attack(p);
}
}
@Override
public void startDeath(Entity killer) {
if (killer == p) {
type.transform(this, p);
return;
}
super.startDeath(killer);
}
@Override
public void startDeath(Entity killer) {
if (killer == p) {
type.transform(this, p);
return;
}
super.startDeath(killer);
}
@Override
public boolean isAttackable(Entity entity, CombatStyle style, boolean message) {
return p == entity;
}
@Override
public boolean isAttackable(Entity entity, CombatStyle style, boolean message) {
return p == entity;
}
@Override
public boolean canSelectTarget(Entity target) {
if (target instanceof Player) {
Player p = (Player) target;
return p == this.p;
}
return true;
}
@Override
public boolean canSelectTarget(Entity target) {
if (target instanceof Player) {
Player p = (Player) target;
return p == this.p;
}
return true;
}
@Override
public AbstractNPC construct(int id, Location location, Object... objects) {
return new WitchsExperimentNPC(id, location, null);
}
@Override
public AbstractNPC construct(int id, Location location, Object... objects) {
return new WitchsExperimentNPC(id, location, null);
}
@Override
public int[] getIds() {
return new int[] { 897, 898, 899, 900 };
}
@Override
public int[] getIds() {
return new int[] { 897, 898, 899, 900 };
}
public void setType(ExperimentType type) {
this.type = type;
}
public void setType(ExperimentType type) {
this.type = type;
}
public ExperimentType getType() {
return type;
}
public ExperimentType getType() {
return type;
}
public void setCommenced(boolean commenced) {
this.commenced = commenced;
}
public void setCommenced(boolean commenced) {
this.commenced = commenced;
}
public enum ExperimentType {
FIRST(897, ""),
SECOND(898, "The shapeshifter's body begins to deform!", "The shapeshifter turns into a spider!"),
THIRD(899, "The shapeshifter's body begins to twist!", "The shapeshifter turns into a bear!"),
FOURTH(900, "The shapeshifter's body pulses!", "The shapeshifter turns into a wolf!"),
END(-1, ""),
public enum ExperimentType {
FIRST(897, ""),
SECOND(898, "The shapeshifter's body begins to deform!", "The shapeshifter turns into a spider!"),
THIRD(899, "The shapeshifter's body begins to twist!", "The shapeshifter turns into a bear!"),
FOURTH(900, "The shapeshifter's body pulses!", "The shapeshifter turns into a wolf!"),
END(-1, ""),
;
;
private int id;
private String[] message;
private int id;
private String[] message;
ExperimentType(int id, String... message) {
this.id = id;
this.message = message;
}
ExperimentType(int id, String... message) {
this.id = id;
this.message = message;
}
/**
* Transforms the new npc.
*/
public void transform(final WitchsExperimentNPC npc, final Player player) {
final ExperimentType newType = next();
npc.lock();
npc.getPulseManager().clear();
npc.getWalkingQueue().reset();
player.setAttribute("/save:witchs_house:experiment_id",this.id);
GameWorld.getPulser().submit(new Pulse(1, npc, player) {
int counter;
/**
* Transforms the new npc.
*/
public void transform(final WitchsExperimentNPC npc, final Player player) {
final ExperimentType newType = next();
npc.lock();
npc.getPulseManager().clear();
npc.getWalkingQueue().reset();
player.setAttribute("/save:witchs_house:experiment_id",this.id);
GameWorld.getPulser().submit(new Pulse(1, npc, player) {
int counter;
@Override
public boolean pulse() {
switch (++counter) {
@Override
public boolean pulse() {
switch (++counter) {
case 1:
npc.unlock();
npc.getAnimator().reset();
npc.fullRestore();
npc.setType(newType);
npc.transform(newType.getId());
npc.getImpactHandler().setDisabledTicks(1);
if (newType != END) {
npc.getProperties().getCombatPulse().attack(player);
}
if (newType.getMessage() != null && newType != END) {
player.sendMessage(newType.getMessage()[0]);
player.sendMessage(newType.getMessage()[1]);
}
if (newType == END) {
player.setAttribute("witchs_house:experiment_killed",true);
npc.clear();
return false;
}
player.unlock();
return true;
}
return false;
}
case 1:
npc.unlock();
npc.getAnimator().reset();
npc.fullRestore();
npc.setType(newType);
npc.transform(newType.getId());
npc.getImpactHandler().setDisabledTicks(1);
if (newType != END) {
npc.getProperties().getCombatPulse().attack(player);
}
if (newType.getMessage() != null && newType != END) {
player.sendMessage(newType.getMessage()[0]);
player.sendMessage(newType.getMessage()[1]);
}
if (newType == END) {
player.setAttribute("witchs_house:experiment_killed",true);
npc.clear();
return false;
}
player.unlock();
return true;
}
return false;
}
});
}
});
}
public static ExperimentType forId(int id) {
for (ExperimentType type : values()) {
if (type.getId() == id) {
return type;
}
}
return null;
}
public static ExperimentType forId(int id) {
for (ExperimentType type : values()) {
if (type.getId() == id) {
return type;
}
}
return null;
}
private static ExperimentType[] experimentTypes = values();
private static ExperimentType[] experimentTypes = values();
public ExperimentType next()
{
return experimentTypes[this.ordinal() + 1];
}
public ExperimentType next()
{
return experimentTypes[this.ordinal() + 1];
}
public int getId() {
return id;
}
public int getId() {
return id;
}
public String[] getMessage() {
return message;
}
public String[] getMessage() {
return message;
}
}
}
}

View file

@ -12,8 +12,10 @@ import core.game.node.entity.combat.equipment.ArmourSet;
import core.game.node.entity.impl.Projectile;
import core.game.node.entity.impl.Animator.Priority;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.world.map.RegionManager;
import core.game.world.map.zone.ZoneBorders;
import core.game.world.repository.Repository;
import core.game.world.update.flag.context.Animation;
import core.tools.RandomFunction;
@ -66,7 +68,7 @@ public final class GWDGraardorSwingHandler extends CombatSwingHandler {
ticks += (int) Math.ceil(entity.getLocation().getDistance(victim.getLocation()) * 0.3);
NPC npc = (NPC) entity;
List<BattleState> list = new ArrayList<>(20);
for (Entity t : RegionManager.getLocalPlayers(npc, 28)) {
for (Player t : RegionManager.getLocalPlayers(npc.getLocation(), 28)) {
if (!CHAMBER.insideBorder(t.getLocation())) {
continue;
}

View file

@ -12,10 +12,12 @@ import core.game.node.entity.combat.equipment.ArmourSet;
import core.game.node.entity.impl.Projectile;
import core.game.node.entity.impl.Animator.Priority;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.world.map.Direction;
import core.game.world.map.Location;
import core.game.world.map.RegionManager;
import core.game.world.map.zone.ZoneBorders;
import core.game.world.repository.Repository;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.tools.RandomFunction;
@ -83,7 +85,7 @@ public final class GWDKreeArraSwingHandler extends CombatSwingHandler {
ticks += (int) Math.ceil(entity != null ? entity.getLocation().getDistance(victim.getLocation()) : 0.0 * 0.3);
NPC npc = (NPC) entity;
List<BattleState> list = new ArrayList<>(20);
for (Entity t : RegionManager.getLocalPlayers(npc, 28)) {
for (Player t : RegionManager.getLocalPlayers(npc.getLocation(), 28)) {
if (!CHAMBER.insideBorder(t.getLocation())) {
continue;
}

View file

@ -11,7 +11,9 @@ import core.game.node.entity.combat.InteractionType;
import core.game.node.entity.combat.equipment.ArmourSet;
import core.game.node.entity.impl.Animator.Priority;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.world.map.RegionManager;
import core.game.world.repository.Repository;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.tools.RandomFunction;
@ -59,7 +61,7 @@ public class GWDZilyanaSwingHandler extends CombatSwingHandler {
} else {
NPC npc = (NPC) entity;
List<BattleState> list = new ArrayList<>(20);
for (Entity t : RegionManager.getLocalPlayers(npc.getCenterLocation(), (npc.size() >> 1) + 2)) {
for (Player t : RegionManager.getLocalPlayers(npc.getCenterLocation(), (npc.size() >> 1) + 2)) {
if (t.getLocation().getX() < 2908 && t.isAttackable(npc, CombatStyle.MAGIC, false)) {
list.add(new BattleState(entity, t));
}

View file

@ -61,7 +61,7 @@ public final class GodWarsNPC extends AbstractNPC {
@Override
public List<Entity> getPossibleTargets(Entity entity, int radius) {
List<Entity> targets = new ArrayList<>(20);
for (Player player : RegionManager.getLocalPlayers(entity, radius)) {
for (Player player : RegionManager.getLocalPlayers(entity.getLocation(), radius)) {
if (canSelectTarget(entity, player)) {
targets.add(player);
}
@ -69,7 +69,7 @@ public final class GodWarsNPC extends AbstractNPC {
if (!targets.isEmpty()) {
return targets;
}
for (NPC npc : RegionManager.getLocalNpcs(entity, radius)) {
for (NPC npc : RegionManager.getLocalNPCs(entity.getLocation(), radius)) {
if (canSelectTarget(entity, npc)) {
targets.add(npc);
}
@ -115,9 +115,9 @@ public final class GodWarsNPC extends AbstractNPC {
@Override
public boolean isAttackable(Entity entity, CombatStyle style, boolean message) {
if (style == CombatStyle.MELEE && faction == GodWarsFaction.ARMADYL && entity instanceof Player) {
if(message) {
((Player) entity).getPacketDispatch().sendMessage("The aviansie is flying too high for you to attack using melee.");
}
if(message) {
((Player) entity).getPacketDispatch().sendMessage("The aviansie is flying too high for you to attack using melee.");
}
return false;
}
return super.isAttackable(entity, style, message);

View file

@ -49,7 +49,7 @@ class AlKharidWarriorNPC : AbstractNPC {
if (entity is Player) {
if (target == null) {
target = entity
RegionManager.getLocalNpcs(entity, supportRange).forEach {
RegionManager.getLocalNPCs(entity.location, supportRange).forEach {
if (it.id == NPCs.AL_KHARID_WARRIOR_18 && !it.properties.combatPulse.isAttacking && it != this) {
it.sendChat("Brother, I shall help thee with this infidel!")
it.attack(entity)

View file

@ -64,7 +64,7 @@ public final class LadyKeliDialogue extends DialoguePlugin {
case 60:
case 100:
npc.sendChat("You tricked me, and tied me up, Guards kill this stranger!");
List<NPC> npcc = RegionManager.getLocalNpcs(player);
List<NPC> npcc = RegionManager.getLocalNPCs(player.getLocation());
for (NPC n : npcc) {
if (n.getId() == 917) {
n.sendChat("Yes M'lady");

View file

@ -23,8 +23,7 @@ class BanditNPC(id: Int = NPCs.BANDIT_1926, location: Location? = null) : Abstra
override fun tick() {
if (!inCombat()) {
val players = RegionManager.getLocalPlayers(this, 5)
for (player in players) {
for (player in RegionManager.getLocalPlayers(location, 5)) {
if (player.inCombat()) continue
if (hasGodItem(player, God.SARADOMIN)) {
sendChat("Time to die, Saradominist filth!")
@ -47,7 +46,7 @@ class BanditNPC(id: Int = NPCs.BANDIT_1926, location: Location? = null) : Abstra
override fun onImpact(entity: Entity?, state: BattleState?) {
if (entity is Player) {
RegionManager.getLocalNpcs(entity, supportRange).forEach {
RegionManager.getLocalNPCs(entity.location, supportRange).forEach {
if (it.id == NPCs.BANDIT_1926 && !it.properties.combatPulse.isAttacking && it != this) {
it.sendChat("You picked the wrong place to start trouble!")
it.attack(entity)

View file

@ -47,7 +47,7 @@ public final class BedabinPlugin extends OptionHandler {
player.getPacketDispatch().sendMessage("You walk back out the tent.");
break;
}
player.getDialogueInterpreter().open(834, RegionManager.getNpc(player, 834));
player.getDialogueInterpreter().open(834, RegionManager.getNpc(player.getLocation(), 834, 16));
break;
}
break;

View file

@ -19,6 +19,7 @@ import core.game.system.task.Pulse;
import core.game.world.GameWorld;
import core.game.world.map.Location;
import core.game.world.map.RegionManager;
import core.game.world.repository.Repository;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.plugin.Initializable;
@ -211,7 +212,7 @@ public final class KalphiteQueenNPC extends AbstractNPC {
*/
private BattleState[] getRangeTargets(Entity e, Entity victim) {
List<BattleState> list = new ArrayList<>(20);
for (Entity t : RegionManager.getLocalPlayers(victim, -1 + (int) e.getCenterLocation().getDistance(victim.getLocation()))) {
for (Player t : RegionManager.getLocalPlayers(victim.getLocation(), -1 + (int) e.getCenterLocation().getDistance(victim.getLocation()))) {
if (t.isAttackable(e, CombatStyle.RANGE, false)) {
list.add(new BattleState(e, t));
}
@ -315,12 +316,12 @@ public final class KalphiteQueenNPC extends AbstractNPC {
return;
}
if (style == CombatStyle.MAGIC) {
BattleState[] states = new BattleState[entity.getViewport().getCurrentPlane().getPlayers().size() + 1];
BattleState[] states = new BattleState[RegionManager.getLocalPlayers(entity.getLocation()).size() + 1];
int index = 1;
if (states.length == 0) {
return;
}
for (Player p : entity.getViewport().getCurrentPlane().getPlayers()) {
for (Player p : RegionManager.getLocalPlayers(entity.getLocation())) {
if (p != victim) {
states[index++] = new BattleState(entity, p);
}

View file

@ -80,7 +80,7 @@ public final class KhardianInteractionPlugin extends OptionHandler {
if (!failed) {
player.getSkills().addExperience(Skills.WOODCUTTING, 10, true);
}
SceneryBuilder.replace(((Scenery) node), new Scenery(DRY_CACTUS, node.getLocation()), SPAWN_DELAY + RandomFunction.random(RegionManager.getLocalPlayers(player).size() / 2));
SceneryBuilder.replace(((Scenery) node), new Scenery(DRY_CACTUS, node.getLocation()), SPAWN_DELAY + RandomFunction.random(RegionManager.getLocalPlayers(player.getLocation()).size() / 2));
break;
}
return true;

View file

@ -108,7 +108,7 @@ public final class AnaDialogue extends DialoguePlugin {
case 3:
player.getInventory().add(TouristTrap.WROUGHT_IRON_KEY, player);
player.getPacketDispatch().sendMessage("Ana spots Irena and waves...");
NPC irena = RegionManager.getNpc(player, 4986);
NPC irena = RegionManager.getNpc(player.getLocation(), 4986, 16);
irena.sendChat("Hi Ana!");
quest.setStage(player, 98);
end();

View file

@ -12,6 +12,7 @@ import core.game.system.task.Pulse;
import core.game.world.GameWorld;
import core.game.world.map.Location;
import core.game.world.map.RegionManager;
import core.game.world.repository.Repository;
import core.plugin.ClassScanner;
import core.tools.RandomFunction;
@ -307,8 +308,8 @@ public final class DesertGuardDialogue extends DialoguePlugin {
* Method used to warn players whom are breaking rules.
*/
private void warn() {
final List<Player> players = RegionManager.getLocalPlayers(this);
for (final Player player : players) {
final List<Player> players = RegionManager.getLocalPlayers(location);
for (Player player : players) {
if (player.getAttribute("guard-warning", 0) > GameWorld.getTicks() || !player.getZoneMonitor().isInZone("mining camp") || player.inCombat() || !player.getLocation().withinDistance(this.getLocation(), 8)) {
continue;
}

View file

@ -167,7 +167,7 @@ class FremennikAchievementDiary : DiaryEventHookBase(DiaryType.FREMENNIK) {
}
override fun onResourceProduced(player: Player, event: ResourceProducedEvent) {
when (player.viewport.region.id) {
when (player.location.regionId) {
10553 -> if (event.source.id in FISHING_SPOTS) {
finishTask(
player,
@ -204,7 +204,7 @@ class FremennikAchievementDiary : DiaryEventHookBase(DiaryType.FREMENNIK) {
}
override fun onNpcKilled(player: Player, event: NPCKillEvent) {
when (player.viewport.region.id) {
when (player.location.regionId) {
10042, 10554 -> if (event.npc.id in ROCK_CRABS) {
progressIncrementalTask(
player,
@ -260,7 +260,7 @@ class FremennikAchievementDiary : DiaryEventHookBase(DiaryType.FREMENNIK) {
}
override fun onPickedUp(player: Player, event: PickUpEvent) {
when (player.viewport.region.id) {
when (player.location.regionId) {
10810 -> if (event.itemId == Items.SEAWEED_401) {
progressIncrementalTask(
player,
@ -284,7 +284,7 @@ class FremennikAchievementDiary : DiaryEventHookBase(DiaryType.FREMENNIK) {
}
override fun onSummoningPointsRecharged(player: Player, event: SummoningPointsRechargeEvent) {
when (player.viewport.region.id) {
when (player.location.regionId) {
10552 -> if (event.obelisk.id == Scenery.SMALL_OBELISK_29944) {
finishTask(
player,
@ -296,7 +296,7 @@ class FremennikAchievementDiary : DiaryEventHookBase(DiaryType.FREMENNIK) {
}
override fun onInteracted(player: Player, event: InteractionEvent) {
when (player.viewport.region.id) {
when (player.location.regionId) {
10811 -> if (event.target.id == Scenery.COLLAPSED_TRAP_19233 && inBorders(player, RELLEKKA_HUNTING_AREA) && event.option == "dismantle") {
finishTask(
player,

View file

@ -8,8 +8,6 @@ import core.game.node.entity.player.Player
import core.game.node.entity.player.link.diary.DiaryType
import core.game.node.entity.player.link.music.MusicEntry
import core.game.node.entity.skill.Skills
import content.global.skill.gather.woodcutting.WoodcuttingSkillPulse
import core.game.node.scenery.Scenery
import core.game.system.task.Pulse
import core.game.world.map.Location
import core.game.world.map.RegionManager
@ -23,6 +21,7 @@ import core.game.system.config.ItemConfigParser
import core.game.world.GameWorld.Pulser
import content.data.Quests
import core.game.interaction.QueueStrength
import core.game.node.Node
class TFTInteractionListeners : InteractionListener {
@ -74,7 +73,7 @@ class TFTInteractionListeners : InteractionListener {
removeItem(player,LOW_ALC_KEG)
setAttribute(player,"/save:fremtrials:keg-mixed", true)
sendMessage(player,"The cherry bomb in the pipe goes off.")
RegionManager.getLocalEntitys(player).stream().forEach { e -> e.sendChat("What was THAT??") }
RegionManager.getLocalNPCs(player.location).stream().forEach { e -> e.sendChat("What was THAT??") }
sendMessage(player,"You mix the kegs together.")
} else {
player.dialogueInterpreter?.sendDialogue("I can't do this right now. I should create","a distraction.")
@ -204,7 +203,7 @@ class TFTInteractionListeners : InteractionListener {
setAttribute(player,"/save:fremtrials:maze-complete",true)
DestRoom(2662, 10034, 2668, 10039).getCenter()
}
else -> getRandomLocation(player)
else -> getRandomLocation(player, portal)
}
return@on true
}
@ -280,17 +279,15 @@ class TFTInteractionListeners : InteractionListener {
return Location((swx + nex) / 2, (swy + ney) / 2).transform(1,0,0)
}
fun getRandomLocation(player: Player?): Location{
var obj: Scenery? = null
while(obj?.id != 5138) {
val objects = player?.viewport?.chunks?.random()?.random()?.objects
obj = objects?.random()?.random()
if(obj == null || obj.location?.equals(Location(0,0,0))!!){
continue
fun getRandomLocation(player: Player, portal: Node): Location {
val objects = player.location.region.assembleObjectList(player.location.z)
objects.shuffle()
for (o in objects) {
if (o.id == 5138) {
return o.location
}
}
return obj.location
return portal.location
}
fun hasEquippableItems(player: Player?): Boolean {

View file

@ -10,6 +10,7 @@ import core.game.node.entity.npc.AbstractNPC;
import core.game.node.entity.player.Player;
import core.game.world.map.Location;
import core.game.world.map.RegionManager;
import core.game.world.repository.Repository;
import core.tools.RandomFunction;
/**
@ -70,7 +71,7 @@ public final class DagannothKingNPC extends AbstractNPC {
state.setEstimatedHit(RandomFunction.random(type.getMaxHit() - 5, type.getMaxHit()));
}
if (type != DagType.REX && RandomFunction.random(5) <= 2) {
List<Player> players = RegionManager.getLocalPlayers(this, 9);
List<Player> players = RegionManager.getLocalPlayers(location, 9);
if (players.size() <= 1) {
return;
}

View file

@ -17,6 +17,7 @@ import core.game.node.entity.combat.CombatStyle;
import core.game.node.entity.npc.AbstractNPC;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.node.item.GroundItemManager;
import core.game.node.scenery.SceneryBuilder;
import core.game.system.task.Pulse;
import core.game.world.GameWorld;
@ -71,7 +72,7 @@ public final class WaterBirthDungeonZone extends MapZone implements Plugin<Objec
public boolean move(Entity e, Location from, Location to) {
for (Location location : DOOR_SUPPORTS) {
if (location.equals(to)) {
List<NPC> npcs = RegionManager.getLocalNpcs(location, 0);
List<NPC> npcs = RegionManager.getLocalNPCs(location, 0);
NPC npc = null;
if (npcs.size() != 0) {
npc = npcs.get(0);
@ -243,10 +244,10 @@ public final class WaterBirthDungeonZone extends MapZone implements Plugin<Objec
* allows both players and pet rocks to activate the pad
*/
private boolean pressurePadActivated(Player player, Location location) {
if (RegionManager.getLocalPlayers(location,0).size() > 0) {
if (!RegionManager.getLocalPlayers(location, 0).isEmpty()) {
return true;
}
if (RegionManager.getRegionPlane(location).getItem(Items.PET_ROCK_3695,location,player) != null) {
if (GroundItemManager.get(Items.PET_ROCK_3695, location, player) != null) {
return true;
}
return false;
@ -411,9 +412,9 @@ public final class WaterBirthDungeonZone extends MapZone implements Plugin<Objec
if (entity.getLocation().getDistance(getLocation()) <= 3) {
if (entity instanceof Player) {
Player player = entity.asPlayer();
if(message) {
player.sendMessage("The door is propped securely shut from this side...");
}
if(message) {
player.sendMessage("The door is propped securely shut from this side...");
}
}
return false;
}

View file

@ -188,7 +188,7 @@ public class SilkMerchantPlugin extends DialoguePlugin {
npc = (NPC) args[0];
if (player.getSavedData().getGlobalData().getSilkSteal() > System.currentTimeMillis()) {
end();
for (NPC npc : RegionManager.getLocalNpcs(player.getLocation(), 8)) {
for (NPC npc : RegionManager.getLocalNPCs(player.getLocation(), 8)) {
if (!npc.getProperties().getCombatPulse().isAttacking() && npc.getId() == 32) {
npc.sendChat("Hey! Get your hands off there!");
npc.getProperties().getCombatPulse().attack(player);

View file

@ -8,6 +8,7 @@ import core.game.dialogue.*
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.game.world.map.Location
import core.game.world.map.RegionManager
import core.plugin.Initializable
import core.tools.END_DIALOGUE
import org.rs09.consts.*
@ -130,12 +131,9 @@ class AlomoneDialogue(player: Player? = null) : DialoguePlugin(player) {
// active dialogue or speaking to alomone, and just dealing with the fact that their hazeel is not on the map. relogging and restarting
// the dialogue would get these players a new hazeel.
private fun Player.findNpcInViewport(npcId: Int): NPC? {
val viewport = viewport ?: return null
for (plane in viewport.viewingPlanes) {
for (npc in plane.npcs) {
if (npc.id == npcId) {
return npc
}
for (npc in RegionManager.getLocalNPCs(location)) {
if (npc.id == npcId) {
return npc
}
}
return null

View file

@ -56,7 +56,7 @@ class MournerKidnapDialogueFile : DialogueFile(){
// Figure out who we are. It needs to be this since we can enter this dialogue from a door
// Do this for the first time regardless of where we are
if (stage == 0) {
RegionManager.getLocalNpcs(player!!, 2).forEach {
RegionManager.getLocalNPCs(player!!.location, 2).forEach {
if (it.id == NPCs.MOURNER_3216) {
closeMourner = it
resetFace(closeMourner!!)
@ -78,7 +78,7 @@ class MournerKidnapDialogueFile : DialogueFile(){
2 -> npcl(FacialExpression.HALF_WORRIED, " This is highly irregular. Please wait...").also { stage++ }
3 -> {
// Look further for the other one
RegionManager.getLocalNpcs(player!!, 10).forEach {
RegionManager.getLocalNPCs(player!!.location, 10).forEach {
if (it.id == NPCs.MOURNER_3216 && it != closeMourner){
farMourner = it
resetFace(farMourner!!)

View file

@ -43,7 +43,7 @@ class BloatedToadNPC : AbstractNPC {
super.handleTickActions()
if (ticksToLive-- <= 0) {
val toDamage = RegionManager.getLocalEntitys(this.location, 2)
val toDamage = RegionManager.getLocalEntities(this.location, 2)
for (entity in toDamage) {
if (entity == this) continue

View file

@ -6,7 +6,6 @@ import core.game.node.entity.combat.ImpactHandler.HitsplatType;
import core.game.node.entity.impl.Projectile;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.audio.Audio;
import core.game.node.entity.skill.Skills;
import core.game.node.item.Item;
import core.game.node.scenery.Scenery;
@ -51,10 +50,10 @@ public final class DMCHandler implements LogoutListener {
*/
private DMCRevolution direction = DMCRevolution.NORTH;
private CannonTimer timer;
private CannonTimer timer;
public DMCHandler() {
this.player = null;
this.player = null;
}
/**
@ -78,7 +77,7 @@ public final class DMCHandler implements LogoutListener {
Location l = cannon.getLocation().transform(1, 1, 0);
playGlobalAudio(l, Sounds.MCANNON_TURN_2877);
direction = DMCRevolution.values()[(direction.ordinal() + 1) % DMCRevolution.values().length];
for (NPC npc : RegionManager.getLocalNpcs(l, 10)) {
for (NPC npc : RegionManager.getLocalNPCs(l, 10)) {
if (direction.isInSight(npc.getLocation().getX() - l.getX(), npc.getLocation().getY() - l.getY()) && npc.isAttackable(player, CombatStyle.RANGE, false) && CombatSwingHandler.isProjectileClipped(npc, l, false)) {
int speed = (int) (25 + (l.getDistance(npc.getLocation()) * 10));
Projectile.create(l, npc.getLocation(), 53, 40, 36, 20, speed, 0, 128).send();
@ -106,8 +105,8 @@ public final class DMCHandler implements LogoutListener {
return;
}
if (timer.isFiring()) {
timer.setFiring(false);
return;
timer.setFiring(false);
return;
}
if (cannonballs < 1) {
int amount = player.getInventory().getAmount(new Item(2));
@ -127,7 +126,7 @@ public final class DMCHandler implements LogoutListener {
player.sendMessage("Your cannon is already fully loaded.");
}
}
timer.setFiring(true);
timer.setFiring(true);
}
/**
@ -138,7 +137,7 @@ public final class DMCHandler implements LogoutListener {
return;
}
player.sendMessage("Your cannon has " + (decay ? "decayed" : "been destroyed") + "!");
for (Player p : RegionManager.getLocalPlayers(player)) {
for (Player p : RegionManager.getLocalPlayers(player.getLocation())) {
p.getPacketDispatch().sendPositionedGraphic(189, 0, 1, cannon.getLocation());
}
clear(false);
@ -194,15 +193,15 @@ public final class DMCHandler implements LogoutListener {
player.getPacketDispatch().sendMessage("You add the furnace.");
SceneryBuilder.remove(object);
handler.configure(SceneryBuilder.add(object = object.transform(6)));
handler.timer = (CannonTimer) spawnTimer ("dmc:timer", handler);
registerTimer (player, handler.timer);
handler.timer = (CannonTimer) spawnTimer ("dmc:timer", handler);
registerTimer (player, handler.timer);
return true;
}
playGlobalAudio(player.getLocation(), Sounds.MCANNON_SETUP_2876);
if(count != 0) {
SceneryBuilder.remove(object);
SceneryBuilder.add(object = object.transform(object.getId() + 1));
}
if(count != 0) {
SceneryBuilder.remove(object);
SceneryBuilder.add(object = object.transform(object.getId() + 1));
}
return ++count == 4;
}
});

Some files were not shown because too many files have changed in this diff Show more